blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2c6b64ad1d9568be7d5c69b077bbc42e7655a980 | 11854ba2b6b92c5ddaea7298b3e41b7c935a64b1 | /benchmark_functions/devel/src_test/es/udc/gii/common/eaf/benchmark/constrained_real_param/g07/G07ConstraintFunction_g6Test.java | e89f05c1086c60bece6f1489e3cbab254c803e34 | []
| no_license | failiz/JEAF | c42d2181ff60310d089b88772e29433800273cf8 | 112584484dab01b5722420b15cdbe530d5973ad0 | refs/heads/master | 2021-06-20T22:21:46.903548 | 2021-06-09T07:10:49 | 2021-06-09T07:10:49 | 217,526,830 | 0 | 1 | null | 2019-10-25T12:16:27 | 2019-10-25T12:16:27 | null | UTF-8 | Java | false | false | 1,190 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package es.udc.gii.common.eaf.benchmark.constrained_real_param.g07;
import es.udc.gii.common.eaf.benchmark.constrained_real_param.CEC2006Test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author pilar
*/
public class G07ConstraintFunction_g6Test {
public G07ConstraintFunction_g6Test() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
/**
* Test of evaluate method, of class G07ConstraintFunction_g6.
*/
@Test
public void testEvaluate() {
System.out.println("evaluate");
double[] values = CEC2006Test.loadBestKnownSolution(7);
G07Test.normalize(values);
G07ConstraintFunction_g6 instance = new G07ConstraintFunction_g6();
double expResult = 0.0;
double result = instance.evaluate(values);
boolean cond = (CEC2006Test.error(expResult, result) <= CEC2006Test.epsilon);
assertTrue(cond);
}
} | [
"[email protected]"
]
| |
6a493289290c7eea4c4782a301dc7a48ad8af969 | e117cf86d80242a7be7281c676cd14882efe1672 | /src/main/java/web/controller/chapter6/request/ConsumesController.java | c69d024f4c46c8dc63049c8aab5a004c5d41984b | []
| no_license | 506967734/WebDemo | 5697a6ebcec3c225618573677bc1c08d7801509f | 7936881ca0d80f5a80524831102bd822882bb6a9 | refs/heads/master | 2020-12-30T12:36:09.464366 | 2017-05-16T01:20:46 | 2017-05-16T01:20:46 | 91,399,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,169 | java | package web.controller.chapter6.request;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* 此种方式相对使用@RequestMapping 的“headers = "Content-Type=application/json"”更能表明你的目的
*/
@Controller
public class ConsumesController {
//Content-Type 请求的内容类型
@RequestMapping(value = "/request/consumes", consumes = {"application/json"})
public String test(HttpServletRequest request) throws IOException {
//表示请求的内容区数据为json数据
InputStream is = request.getInputStream();
byte bytes[] = new byte[request.getContentLength()];
is.read(bytes);
//得到请求中的内容区数据(以CharacterEncoding解码)
//此处得到数据后你可以通过如json-lib转换为其他对象
String jsonStr = new String(bytes, request.getCharacterEncoding());
System.out.println("json data:" + jsonStr);
return "success";
}
}
| [
"[email protected]"
]
| |
e8c3c35e9612290527fde74f7c16935eba57716a | 7c9fba431772cc027c07674166604f093899c1b8 | /commons-vfs2/src/main/java/org/apache/commons/vfs2/function/VfsConsumer.java | e1100e5857c42618448406fc9b2f711a78397b19 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
]
| permissive | PeterAlfredLee/commons-vfs | e54c81f4ce2f40a8af7f24def551405733fc86b4 | 923a5715a060c10fb462c4bdfd53fd37fa4531bd | refs/heads/master | 2023-01-24T09:47:41.059971 | 2021-04-05T14:32:21 | 2021-04-05T14:32:21 | 249,661,309 | 0 | 0 | Apache-2.0 | 2023-01-12T03:07:34 | 2020-03-24T09:11:02 | Java | UTF-8 | Java | false | false | 2,231 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.vfs2.function;
import java.util.Objects;
import org.apache.commons.vfs2.FileSystemException;
/**
* A {@link java.util.function.Consumer} that throws {@link FileSystemException}.
*
* @param <T> the type of the input to the operation
*
* @since 2.5.0
*/
@FunctionalInterface
public interface VfsConsumer<T> {
/**
* Performs this operation on the given argument.
*
* @param t the input argument
* @throws FileSystemException Thrown when VFS detects an error.
*/
void accept(T t) throws FileSystemException;
/**
* Returns a composed {@code Consumer} that performs, in sequence, this operation followed by the {@code after}
* operation. If performing either operation throws an exception, it is relayed to the caller of the composed
* operation. If performing this operation throws an exception, the {@code after} operation will not be performed.
*
* @param after the operation to perform after this operation
* @return a composed {@code Consumer} that performs in sequence this operation followed by the {@code after}
* operation
* @throws NullPointerException if {@code after} is null
*/
default VfsConsumer<T> andThen(final VfsConsumer<? super T> after) {
Objects.requireNonNull(after);
return (final T t) -> {
accept(t);
after.accept(t);
};
}
} | [
"[email protected]"
]
| |
919f6a7e5ce537af638c2a96fd2886bc0a352564 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-14227-21-18-PESA_II-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/XWiki_ESTest.java | e0608e0d777c49fec91ece4ed6f24e1ac7ec944b | []
| no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 530 | java | /*
* This file was automatically generated by EvoSuite
* Sun Jan 19 15:08:03 UTC 2020
*/
package com.xpn.xwiki;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class XWiki_ESTest extends XWiki_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"[email protected]"
]
| |
9083fcedbf0424d08f9ae6c188e4c969f7682c95 | fc82321b56b89dfb17c5ed851ab9e08b4971a93a | /src/Banking_management/Home.java | c6a71489126d2cb5b0e2f9e8a3c9a4fa5727b879 | []
| no_license | MajedAbdullah5/002-BANKING-MANAGEMENT-SYSTEM | 258d3eeaa911e9540aa7f480525204f6806b3764 | e584c8525e46d3b4ac3880c834493d3235a1548e | refs/heads/master | 2022-12-01T23:52:57.540740 | 2020-08-20T11:57:05 | 2020-08-20T11:57:05 | 288,992,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 62,522 | java | package Banking_management;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import net.proteanit.sql.DbUtils;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
public class Home extends JFrame {
private JPanel contentPane;
Connection conn;
ResultSet rs;
PreparedStatement ps;
private JTextField allTimeDate;
private JTextField searchUser;
private JTextField name;
private JTextField dob;
private JTextField nationality;
private JTextField gender;
private JTextField address;
private JTextField accountno;
private JTextField accounttype;
private JTextField amount;
private JTextField mobile;
private JTextField secq;
private JTextField depositText;
private JTextField withdrawText;
private JTextField textField_3;
private JTextField textField_5;
private JTextField textField_6;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_4;
private JLabel labelBalance;
private JLabel labelBalance_1;
private JLabel lblNewLabel_13;
private JTable transTable;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
//here you can put the selected theme class name in JTattoo
UIManager.setLookAndFeel("com.jtattoo.plaf.fast.FastLookAndFeel");
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Home frame = new Home();
frame.setTitle("Banking Management");
frame.setVisible(true);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
});
}
/**
* Create the frame.
* @throws SQLException
*/
public Home() throws SQLException {
conn = null;
ps = null;
rs = null;
conn = (Connection) ConnectionDB.connect();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 1024, 508);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JPanel panel = new JPanel();
contentPane.add(panel, BorderLayout.CENTER);
SpringLayout sl_panel = new SpringLayout();
panel.setLayout(sl_panel);
allTimeDate = new JTextField();
allTimeDate.setHorizontalAlignment(SwingConstants.CENTER);
sl_panel.putConstraint(SpringLayout.EAST, allTimeDate, -117, SpringLayout.EAST, panel);
allTimeDate.setEditable(false);
allTimeDate.setFont(new Font("Tahoma", Font.PLAIN, 18));
panel.add(allTimeDate);
allTimeDate.setColumns(10);
searchUser = new JTextField();
searchUser.setHorizontalAlignment(SwingConstants.CENTER);
sl_panel.putConstraint(SpringLayout.NORTH, allTimeDate, 16, SpringLayout.SOUTH, searchUser);
sl_panel.putConstraint(SpringLayout.NORTH, searchUser, 20, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, searchUser, -411, SpringLayout.SOUTH, panel);
searchUser.setFont(new Font("Tahoma", Font.PLAIN, 18));
panel.add(searchUser);
searchUser.setColumns(10);
//Calendar();
JButton btnNewButton_1 = new JButton("");
sl_panel.putConstraint(SpringLayout.EAST, searchUser, -10, SpringLayout.WEST, btnNewButton_1);
sl_panel.putConstraint(SpringLayout.SOUTH, btnNewButton_1, 48, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.NORTH, btnNewButton_1, 20, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, btnNewButton_1, 889, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.EAST, btnNewButton_1, -10, SpringLayout.EAST, panel);
btnNewButton_1.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-eye-30.png"));
panel.add(btnNewButton_1);
JLabel lblNewLabel = new JLabel("Banking Management");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel, 32, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel, 32, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, lblNewLabel, 84, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, lblNewLabel, 447, SpringLayout.WEST, panel);
lblNewLabel.setFont(new Font("Lucida Sans", Font.BOLD, 30));
panel.add(lblNewLabel);
JLabel lblUser = new JLabel("User name: ");
sl_panel.putConstraint(SpringLayout.WEST, searchUser, 0, SpringLayout.EAST, lblUser);
sl_panel.putConstraint(SpringLayout.NORTH, lblUser, 21, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, lblUser, 179, SpringLayout.EAST, lblNewLabel);
sl_panel.putConstraint(SpringLayout.EAST, lblUser, -273, SpringLayout.EAST, panel);
lblUser.setFont(new Font("Tahoma", Font.PLAIN, 16));
panel.add(lblUser);
JLabel lblDate = new JLabel("Date:");
sl_panel.putConstraint(SpringLayout.SOUTH, lblUser, -12, SpringLayout.NORTH, lblDate);
sl_panel.putConstraint(SpringLayout.WEST, allTimeDate, 6, SpringLayout.EAST, lblDate);
sl_panel.putConstraint(SpringLayout.NORTH, lblDate, 61, SpringLayout.NORTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, lblDate, 0, SpringLayout.WEST, lblUser);
sl_panel.putConstraint(SpringLayout.EAST, lblDate, -279, SpringLayout.EAST, panel);
lblDate.setFont(new Font("Tahoma", Font.PLAIN, 16));
panel.add(lblDate);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
sl_panel.putConstraint(SpringLayout.SOUTH, allTimeDate, -27, SpringLayout.NORTH, tabbedPane);
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
sl_panel.putConstraint(SpringLayout.SOUTH, lblDate, -30, SpringLayout.NORTH, tabbedPane);
sl_panel.putConstraint(SpringLayout.NORTH, tabbedPane, -340, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.WEST, tabbedPane, 0, SpringLayout.WEST, panel);
sl_panel.putConstraint(SpringLayout.SOUTH, tabbedPane, 0, SpringLayout.SOUTH, panel);
sl_panel.putConstraint(SpringLayout.EAST, tabbedPane, 0, SpringLayout.EAST, panel);
panel.add(tabbedPane);
JPanel profile = new JPanel();
profile.setToolTipText("");
profile.setBackground(Color.WHITE);
profile.setForeground(Color.BLACK);
tabbedPane.addTab("Profile", null, profile, null);
SpringLayout sl_profile = new SpringLayout();
profile.setLayout(sl_profile);
name = new JTextField();
sl_profile.putConstraint(SpringLayout.NORTH, name, 28, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.EAST, name, 411, SpringLayout.WEST, profile);
name.setEditable(false);
name.setHorizontalAlignment(SwingConstants.CENTER);
name.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(name);
name.setColumns(10);
dob = new JTextField();
sl_profile.putConstraint(SpringLayout.WEST, name, 0, SpringLayout.WEST, dob);
sl_profile.putConstraint(SpringLayout.SOUTH, name, -18, SpringLayout.NORTH, dob);
sl_profile.putConstraint(SpringLayout.EAST, dob, -590, SpringLayout.EAST, profile);
dob.setEditable(false);
dob.setHorizontalAlignment(SwingConstants.CENTER);
dob.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(dob);
dob.setColumns(10);
nationality = new JTextField();
sl_profile.putConstraint(SpringLayout.EAST, nationality, -590, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.NORTH, dob, -47, SpringLayout.NORTH, nationality);
sl_profile.putConstraint(SpringLayout.SOUTH, dob, -19, SpringLayout.NORTH, nationality);
sl_profile.putConstraint(SpringLayout.NORTH, nationality, 121, SpringLayout.NORTH, profile);
nationality.setEditable(false);
sl_profile.putConstraint(SpringLayout.SOUTH, nationality, -161, SpringLayout.SOUTH, profile);
nationality.setHorizontalAlignment(SwingConstants.CENTER);
nationality.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(nationality);
nationality.setColumns(10);
gender = new JTextField();
sl_profile.putConstraint(SpringLayout.WEST, gender, 0, SpringLayout.WEST, name);
gender.setEditable(false);
gender.setHorizontalAlignment(SwingConstants.CENTER);
gender.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(gender);
gender.setColumns(10);
address = new JTextField();
sl_profile.putConstraint(SpringLayout.SOUTH, gender, -20, SpringLayout.NORTH, address);
sl_profile.putConstraint(SpringLayout.EAST, address, -590, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.NORTH, address, 217, SpringLayout.NORTH, profile);
address.setEditable(false);
sl_profile.putConstraint(SpringLayout.SOUTH, address, -65, SpringLayout.SOUTH, profile);
address.setHorizontalAlignment(SwingConstants.CENTER);
address.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(address);
address.setColumns(10);
accountno = new JTextField();
sl_profile.putConstraint(SpringLayout.NORTH, accountno, 28, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.EAST, accountno, -174, SpringLayout.EAST, profile);
accountno.setEditable(false);
accountno.setHorizontalAlignment(SwingConstants.CENTER);
accountno.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(accountno);
accountno.setColumns(10);
accounttype = new JTextField();
sl_profile.putConstraint(SpringLayout.SOUTH, accountno, -18, SpringLayout.NORTH, accounttype);
sl_profile.putConstraint(SpringLayout.NORTH, accounttype, 74, SpringLayout.NORTH, profile);
accounttype.setEditable(false);
accounttype.setHorizontalAlignment(SwingConstants.CENTER);
accounttype.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(accounttype);
accounttype.setColumns(10);
amount = new JTextField();
sl_profile.putConstraint(SpringLayout.EAST, amount, -174, SpringLayout.EAST, profile);
amount.setEditable(false);
sl_profile.putConstraint(SpringLayout.NORTH, amount, 121, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, accounttype, -19, SpringLayout.NORTH, amount);
amount.setHorizontalAlignment(SwingConstants.CENTER);
amount.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(amount);
amount.setColumns(10);
mobile = new JTextField();
sl_profile.putConstraint(SpringLayout.NORTH, gender, 0, SpringLayout.NORTH, mobile);
sl_profile.putConstraint(SpringLayout.NORTH, mobile, 169, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.EAST, mobile, -174, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, amount, -20, SpringLayout.NORTH, mobile);
mobile.setEditable(false);
mobile.setHorizontalAlignment(SwingConstants.CENTER);
mobile.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(mobile);
mobile.setColumns(10);
secq = new JTextField();
sl_profile.putConstraint(SpringLayout.EAST, secq, -174, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, mobile, -20, SpringLayout.NORTH, secq);
sl_profile.putConstraint(SpringLayout.NORTH, secq, 217, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, secq, -65, SpringLayout.SOUTH, profile);
secq.setEditable(false);
secq.setHorizontalAlignment(SwingConstants.CENTER);
secq.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 20));
profile.add(secq);
secq.setColumns(10);
JLabel lblName = new JLabel("Name:");
sl_profile.putConstraint(SpringLayout.WEST, lblName, 135, SpringLayout.WEST, profile);
sl_profile.putConstraint(SpringLayout.EAST, lblName, -794, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.NORTH, lblName, 33, SpringLayout.NORTH, profile);
lblName.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblName);
JLabel lblDateOfBirth = new JLabel("Date of birth:");
sl_profile.putConstraint(SpringLayout.WEST, dob, 6, SpringLayout.EAST, lblDateOfBirth);
sl_profile.putConstraint(SpringLayout.NORTH, lblDateOfBirth, 79, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblName, -26, SpringLayout.NORTH, lblDateOfBirth);
sl_profile.putConstraint(SpringLayout.WEST, lblDateOfBirth, 102, SpringLayout.WEST, profile);
sl_profile.putConstraint(SpringLayout.EAST, lblDateOfBirth, -794, SpringLayout.EAST, profile);
lblDateOfBirth.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblDateOfBirth);
JLabel lblNationality = new JLabel("Nationality:");
sl_profile.putConstraint(SpringLayout.WEST, nationality, 6, SpringLayout.EAST, lblNationality);
sl_profile.putConstraint(SpringLayout.NORTH, lblNationality, 126, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblDateOfBirth, -27, SpringLayout.NORTH, lblNationality);
sl_profile.putConstraint(SpringLayout.EAST, lblNationality, -794, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.WEST, lblNationality, 113, SpringLayout.WEST, profile);
lblNationality.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblNationality);
JLabel lblGender = new JLabel("Gender: ");
sl_profile.putConstraint(SpringLayout.NORTH, lblGender, 174, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblGender, -116, SpringLayout.SOUTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblNationality, -28, SpringLayout.NORTH, lblGender);
sl_profile.putConstraint(SpringLayout.WEST, lblGender, 135, SpringLayout.WEST, profile);
sl_profile.putConstraint(SpringLayout.EAST, lblGender, -794, SpringLayout.EAST, profile);
lblGender.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblGender);
JLabel lblAddress = new JLabel("Address:");
sl_profile.putConstraint(SpringLayout.WEST, address, 8, SpringLayout.EAST, lblAddress);
sl_profile.putConstraint(SpringLayout.NORTH, lblAddress, 31, SpringLayout.SOUTH, lblGender);
sl_profile.putConstraint(SpringLayout.WEST, lblAddress, 132, SpringLayout.WEST, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblAddress, -65, SpringLayout.SOUTH, profile);
sl_profile.putConstraint(SpringLayout.EAST, lblAddress, -796, SpringLayout.EAST, profile);
lblAddress.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblAddress);
JLabel lblAccountNo = new JLabel("Account no:");
sl_profile.putConstraint(SpringLayout.NORTH, lblAccountNo, 36, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.WEST, lblAccountNo, 116, SpringLayout.EAST, name);
sl_profile.putConstraint(SpringLayout.EAST, lblAccountNo, -378, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.WEST, accountno, 6, SpringLayout.EAST, lblAccountNo);
lblAccountNo.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblAccountNo);
JLabel lblNewLabel_1 = new JLabel("Account type:");
sl_profile.putConstraint(SpringLayout.WEST, accounttype, 6, SpringLayout.EAST, lblNewLabel_1);
sl_profile.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 82, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblNewLabel_1, -208, SpringLayout.SOUTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblAccountNo, -26, SpringLayout.NORTH, lblNewLabel_1);
sl_profile.putConstraint(SpringLayout.WEST, lblNewLabel_1, 114, SpringLayout.EAST, dob);
sl_profile.putConstraint(SpringLayout.EAST, lblNewLabel_1, -378, SpringLayout.EAST, profile);
lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblNewLabel_1);
JLabel lblCaste = new JLabel("Amount:");
sl_profile.putConstraint(SpringLayout.NORTH, lblCaste, 27, SpringLayout.SOUTH, lblNewLabel_1);
sl_profile.putConstraint(SpringLayout.WEST, amount, 7, SpringLayout.EAST, lblCaste);
sl_profile.putConstraint(SpringLayout.WEST, lblCaste, 148, SpringLayout.EAST, nationality);
sl_profile.putConstraint(SpringLayout.EAST, lblCaste, -379, SpringLayout.EAST, profile);
lblCaste.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblCaste);
JLabel lblMobile = new JLabel("Mobile:");
sl_profile.putConstraint(SpringLayout.EAST, gender, -148, SpringLayout.WEST, lblMobile);
sl_profile.putConstraint(SpringLayout.WEST, mobile, 6, SpringLayout.EAST, lblMobile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblCaste, -26, SpringLayout.NORTH, lblMobile);
sl_profile.putConstraint(SpringLayout.WEST, lblMobile, 0, SpringLayout.WEST, lblCaste);
sl_profile.putConstraint(SpringLayout.EAST, lblMobile, -378, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.NORTH, lblMobile, 175, SpringLayout.NORTH, profile);
lblMobile.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblMobile);
JLabel lblSecurityQ = new JLabel("Security Q:");
sl_profile.putConstraint(SpringLayout.NORTH, lblSecurityQ, 225, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblSecurityQ, -65, SpringLayout.SOUTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, lblMobile, -30, SpringLayout.NORTH, lblSecurityQ);
sl_profile.putConstraint(SpringLayout.WEST, secq, 6, SpringLayout.EAST, lblSecurityQ);
sl_profile.putConstraint(SpringLayout.WEST, lblSecurityQ, 133, SpringLayout.EAST, address);
sl_profile.putConstraint(SpringLayout.EAST, lblSecurityQ, -378, SpringLayout.EAST, profile);
lblSecurityQ.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(lblSecurityQ);
JButton btnNewButton = new JButton("Edit");
sl_profile.putConstraint(SpringLayout.EAST, accounttype, -57, SpringLayout.WEST, btnNewButton);
sl_profile.putConstraint(SpringLayout.EAST, btnNewButton, -10, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.WEST, btnNewButton, -117, SpringLayout.EAST, profile);
sl_profile.putConstraint(SpringLayout.NORTH, btnNewButton, 72, SpringLayout.NORTH, profile);
sl_profile.putConstraint(SpringLayout.SOUTH, btnNewButton, 107, SpringLayout.NORTH, profile);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
name.setEditable(true);
dob.setEditable(true);
address.setEditable(true);
mobile.setEditable(true);
secq.setEditable(true);
}
});
btnNewButton.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-edit-26.png"));
btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(btnNewButton);
JButton btnSave = new JButton("Save");
sl_profile.putConstraint(SpringLayout.WEST, btnSave, 57, SpringLayout.EAST, mobile);
sl_profile.putConstraint(SpringLayout.SOUTH, btnSave, -109, SpringLayout.SOUTH, profile);
sl_profile.putConstraint(SpringLayout.EAST, btnSave, 0, SpringLayout.EAST, btnNewButton);
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int choise = JOptionPane.showConfirmDialog(null, "Are you sure?","Update information",JOptionPane.YES_NO_OPTION);
if(choise == JOptionPane.YES_NO_OPTION) {
String sql = "update account set name=?,dob=?,address=?,mobile=?,sec_q=? where name=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(6,searchUser.getText());
ps.setString(1, name.getText());
ps.setString(2, dob.getText());
ps.setString(3, address.getText());
ps.setString(4, mobile.getText());
ps.setString(5, secq.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Update Successfull!");
updateUserInfo();
getBalanceUpdate();
}
catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1);
}
}
else{
JOptionPane.showMessageDialog(null, "Information haven't updated!");
}
}
});
sl_profile.putConstraint(SpringLayout.NORTH, btnSave, 168, SpringLayout.NORTH, profile);
btnSave.setHorizontalAlignment(SwingConstants.LEFT);
btnSave.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-save-25.png"));
btnSave.setFont(new Font("Tahoma", Font.PLAIN, 16));
profile.add(btnSave);
JPanel deposit = new JPanel();
tabbedPane.addTab("Deposit", null, deposit, null);
SpringLayout sl_deposit = new SpringLayout();
deposit.setLayout(sl_deposit);
JLabel lblAvailableBalance = new JLabel("Balance:");
sl_deposit.putConstraint(SpringLayout.NORTH, lblAvailableBalance, 10, SpringLayout.NORTH, deposit);
sl_deposit.putConstraint(SpringLayout.WEST, lblAvailableBalance, 48, SpringLayout.WEST, deposit);
sl_deposit.putConstraint(SpringLayout.SOUTH, lblAvailableBalance, 85, SpringLayout.NORTH, deposit);
sl_deposit.putConstraint(SpringLayout.EAST, lblAvailableBalance, 256, SpringLayout.WEST, deposit);
lblAvailableBalance.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-money-60.png"));
lblAvailableBalance.setFont(new Font("Verdana", Font.BOLD, 30));
deposit.add(lblAvailableBalance);
labelBalance = new JLabel("00");
sl_deposit.putConstraint(SpringLayout.NORTH, labelBalance, 18, SpringLayout.NORTH, lblAvailableBalance);
sl_deposit.putConstraint(SpringLayout.WEST, labelBalance, 7, SpringLayout.EAST, lblAvailableBalance);
labelBalance.setFont(new Font("Verdana", Font.BOLD, 30));
deposit.add(labelBalance);
JLabel Userlabel = new JLabel("");
sl_deposit.putConstraint(SpringLayout.NORTH, Userlabel, 28, SpringLayout.SOUTH, lblAvailableBalance);
Userlabel.setHorizontalAlignment(SwingConstants.LEFT);
Userlabel.setFont(new Font("Tahoma", Font.BOLD, 18));
deposit.add(Userlabel);
depositText = new JTextField();
depositText.setHorizontalAlignment(SwingConstants.CENTER);
depositText.setFont(new Font("Verdana", Font.BOLD, 30));
sl_deposit.putConstraint(SpringLayout.SOUTH, Userlabel, 0, SpringLayout.SOUTH, depositText);
sl_deposit.putConstraint(SpringLayout.EAST, Userlabel, -159, SpringLayout.WEST, depositText);
sl_deposit.putConstraint(SpringLayout.NORTH, depositText, 92, SpringLayout.NORTH, deposit);
sl_deposit.putConstraint(SpringLayout.EAST, depositText, -126, SpringLayout.EAST, deposit);
deposit.add(depositText);
depositText.setColumns(10);
JLabel Accountlabel = new JLabel("");
sl_deposit.putConstraint(SpringLayout.NORTH, Accountlabel, 25, SpringLayout.SOUTH, Userlabel);
sl_deposit.putConstraint(SpringLayout.WEST, Accountlabel, 234, SpringLayout.WEST, deposit);
sl_deposit.putConstraint(SpringLayout.SOUTH, Accountlabel, -84, SpringLayout.SOUTH, deposit);
Accountlabel.setHorizontalAlignment(SwingConstants.LEFT);
Accountlabel.setFont(new Font("Tahoma", Font.BOLD, 18));
deposit.add(Accountlabel);
JButton btnDeposit = new JButton("Deposit");
sl_deposit.putConstraint(SpringLayout.WEST, btnDeposit, 620, SpringLayout.WEST, deposit);
sl_deposit.putConstraint(SpringLayout.EAST, Accountlabel, -159, SpringLayout.WEST, btnDeposit);
sl_deposit.putConstraint(SpringLayout.EAST, btnDeposit, -126, SpringLayout.EAST, deposit);
sl_deposit.putConstraint(SpringLayout.SOUTH, depositText, -27, SpringLayout.NORTH, btnDeposit);
btnDeposit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(depositText.getText().isEmpty() || depositText.getText().matches("[a-zA-Z_]+")) {
JOptionPane.showMessageDialog(null, "Please enter valid operation!");
}
else {
int Dbalance = Integer.parseInt(depositText.getText());
int bal = Integer.parseInt(getBalance());
int total = Dbalance+bal;
String finalBalance = String.valueOf(total);
int choise = JOptionPane.showConfirmDialog(null, "Do you want to Deposit money?","Deposit",JOptionPane.YES_NO_OPTION);
if(choise==JOptionPane.YES_OPTION) {
String sql = "update account set balance=? where name=?";
try {
if(!(Dbalance<=0)) {
ps = conn.prepareStatement(sql);
ps.setString(2, searchUser.getText());
ps.setString(1, finalBalance);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Balance Deposited!");
setDeposit();
getBalanceUpdate();
}
else {
JOptionPane.showMessageDialog(null, "Balance can't be empty!");
}
}
catch (Exception e1) {
JOptionPane.showMessageDialog(null, "Balance failed to deposit!");
JOptionPane.showMessageDialog(null, e1);
}
}
else {
JOptionPane.showMessageDialog(null, "Deposit Cancelled!");
}
}
}
});
sl_deposit.putConstraint(SpringLayout.NORTH, btnDeposit, 184, SpringLayout.NORTH, deposit);
sl_deposit.putConstraint(SpringLayout.WEST, depositText, 0, SpringLayout.WEST, btnDeposit);
btnDeposit.setFont(new Font("Serif", Font.BOLD, 30));
btnDeposit.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\Downloads\\icons8-deposit-50.png"));
deposit.add(btnDeposit);
JLabel lblName_1 = new JLabel("NAME:");
sl_deposit.putConstraint(SpringLayout.EAST, lblName_1, -809, SpringLayout.EAST, deposit);
sl_deposit.putConstraint(SpringLayout.WEST, Userlabel, 55, SpringLayout.EAST, lblName_1);
sl_deposit.putConstraint(SpringLayout.NORTH, lblName_1, 11, SpringLayout.NORTH, Userlabel);
lblName_1.setFont(new Font("Tahoma", Font.BOLD, 18));
deposit.add(lblName_1);
JLabel lblAccountNo_1 = new JLabel("ACCOUNT NO:");
sl_deposit.putConstraint(SpringLayout.NORTH, lblAccountNo_1, 11, SpringLayout.NORTH, Accountlabel);
sl_deposit.putConstraint(SpringLayout.EAST, lblAccountNo_1, 0, SpringLayout.EAST, lblName_1);
lblAccountNo_1.setFont(new Font("Tahoma", Font.BOLD, 18));
deposit.add(lblAccountNo_1);
JPanel transfer = new JPanel();
tabbedPane.addTab("Transfer", null, transfer, null);
SpringLayout sl_transfer = new SpringLayout();
transfer.setLayout(sl_transfer);
JPanel panel_2 = new JPanel();
panel_2.setFont(new Font("Tahoma", Font.PLAIN, 17));
panel_2.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
sl_transfer.putConstraint(SpringLayout.NORTH, panel_2, 0, SpringLayout.NORTH, transfer);
sl_transfer.putConstraint(SpringLayout.WEST, panel_2, 0, SpringLayout.WEST, transfer);
sl_transfer.putConstraint(SpringLayout.SOUTH, panel_2, 310, SpringLayout.NORTH, transfer);
sl_transfer.putConstraint(SpringLayout.EAST, panel_2, 515, SpringLayout.WEST, transfer);
transfer.add(panel_2);
JPanel panel_1 = new JPanel();
sl_transfer.putConstraint(SpringLayout.NORTH, panel_1, 0, SpringLayout.NORTH, transfer);
sl_transfer.putConstraint(SpringLayout.WEST, panel_1, 6, SpringLayout.EAST, panel_2);
SpringLayout sl_panel_2 = new SpringLayout();
panel_2.setLayout(sl_panel_2);
JLabel lblNewLabel_11 = new JLabel("Balance:");
sl_panel_2.putConstraint(SpringLayout.NORTH, lblNewLabel_11, 69, SpringLayout.NORTH, panel_2);
sl_panel_2.putConstraint(SpringLayout.WEST, lblNewLabel_11, 10, SpringLayout.WEST, panel_2);
lblNewLabel_11.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-money-60.png"));
lblNewLabel_11.setFont(new Font("Verdana", Font.BOLD, 30));
panel_2.add(lblNewLabel_11);
JLabel lblNewLabel_12 = new JLabel("Name");
sl_panel_2.putConstraint(SpringLayout.NORTH, lblNewLabel_12, 6, SpringLayout.SOUTH, lblNewLabel_11);
sl_panel_2.putConstraint(SpringLayout.WEST, lblNewLabel_12, 32, SpringLayout.WEST, lblNewLabel_11);
lblNewLabel_12.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_12.setFont(new Font("Verdana", Font.PLAIN, 20));
panel_2.add(lblNewLabel_12);
lblNewLabel_13 = new JLabel("00");
sl_panel_2.putConstraint(SpringLayout.EAST, lblNewLabel_12, 0, SpringLayout.EAST, lblNewLabel_13);
sl_panel_2.putConstraint(SpringLayout.NORTH, lblNewLabel_13, 8, SpringLayout.NORTH, lblNewLabel_11);
sl_panel_2.putConstraint(SpringLayout.WEST, lblNewLabel_13, 6, SpringLayout.EAST, lblNewLabel_11);
sl_panel_2.putConstraint(SpringLayout.SOUTH, lblNewLabel_13, -7, SpringLayout.SOUTH, lblNewLabel_11);
lblNewLabel_13.setFont(new Font("Verdana", Font.BOLD, 30));
panel_2.add(lblNewLabel_13);
JLabel lblNewLabel_14 = new JLabel("Account No");
sl_panel_2.putConstraint(SpringLayout.NORTH, lblNewLabel_14, 20, SpringLayout.SOUTH, lblNewLabel_12);
sl_panel_2.putConstraint(SpringLayout.WEST, lblNewLabel_14, 40, SpringLayout.WEST, panel_2);
sl_panel_2.putConstraint(SpringLayout.SOUTH, lblNewLabel_14, -99, SpringLayout.SOUTH, panel_2);
sl_panel_2.putConstraint(SpringLayout.EAST, lblNewLabel_14, 4, SpringLayout.EAST, lblNewLabel_12);
lblNewLabel_14.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_14.setFont(new Font("Verdana", Font.PLAIN, 20));
panel_2.add(lblNewLabel_14);
JLabel lblFrom = new JLabel("Transferring from");
lblFrom.setForeground(new Color(255, 140, 0));
sl_panel_2.putConstraint(SpringLayout.NORTH, lblFrom, 10, SpringLayout.NORTH, panel_2);
sl_panel_2.putConstraint(SpringLayout.WEST, lblFrom, 140, SpringLayout.WEST, panel_2);
lblFrom.setFont(new Font("Verdana", Font.BOLD, 20));
panel_2.add(lblFrom);
sl_transfer.putConstraint(SpringLayout.SOUTH, panel_1, 0, SpringLayout.SOUTH, transfer);
sl_transfer.putConstraint(SpringLayout.EAST, panel_1, 1, SpringLayout.EAST, transfer);
transfer.add(panel_1);
SpringLayout sl_panel_1 = new SpringLayout();
panel_1.setLayout(sl_panel_1);
JLabel lblTransferringTo = new JLabel("Transferring to");
sl_panel_1.putConstraint(SpringLayout.NORTH, lblTransferringTo, 10, SpringLayout.NORTH, panel_1);
sl_panel_1.putConstraint(SpringLayout.WEST, lblTransferringTo, 147, SpringLayout.WEST, panel_1);
lblTransferringTo.setForeground(new Color(255, 140, 0));
lblTransferringTo.setFont(new Font("Verdana", Font.BOLD, 20));
panel_1.add(lblTransferringTo);
textField_1 = new JTextField();
sl_panel_1.putConstraint(SpringLayout.WEST, textField_1, 189, SpringLayout.WEST, panel_1);
sl_panel_1.putConstraint(SpringLayout.SOUTH, textField_1, -207, SpringLayout.SOUTH, panel_1);
textField_1.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 16));
panel_1.add(textField_1);
textField_1.setColumns(10);
JLabel lblCheckAvailability = new JLabel("Check Availability:");
sl_panel_1.putConstraint(SpringLayout.WEST, lblCheckAvailability, 20, SpringLayout.WEST, panel_1);
lblCheckAvailability.setFont(new Font("Verdana", Font.PLAIN, 16));
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblCheckAvailability, 0, SpringLayout.SOUTH, textField_1);
sl_panel_1.putConstraint(SpringLayout.EAST, lblCheckAvailability, -17, SpringLayout.WEST, textField_1);
panel_1.add(lblCheckAvailability);
JButton btnNewButton_3 = new JButton("");
sl_panel_1.putConstraint(SpringLayout.WEST, btnNewButton_3, 6, SpringLayout.EAST, textField_1);
sl_panel_1.putConstraint(SpringLayout.SOUTH, btnNewButton_3, 0, SpringLayout.SOUTH, textField_1);
sl_panel_1.putConstraint(SpringLayout.EAST, btnNewButton_3, -45, SpringLayout.EAST, panel_1);
btnNewButton_3.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-search-24.png"));
btnNewButton_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(textField_1.getText().isEmpty()||textField_1.getText().matches("[a-zA-Z_]+")) {
JOptionPane.showMessageDialog(null, "Please enter user account number!");
}
else {
String sql = "select * from account where acc=?";
try {
ps= conn.prepareStatement(sql);
ps.setString(1, textField_1.getText());
rs = ps.executeQuery();
if(rs.next()) {
String val = rs.getString("acc");
textField_2.setText(val);
JOptionPane.showMessageDialog(null, "User found!");
}
else {
JOptionPane.showMessageDialog(null, "User not found!");
}
}
catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1);
}
}
}
});
sl_panel_1.putConstraint(SpringLayout.NORTH, btnNewButton_3, 0, SpringLayout.NORTH, textField_1);
panel_1.add(btnNewButton_3);
textField_2 = new JTextField();
sl_panel_1.putConstraint(SpringLayout.NORTH, textField_2, 31, SpringLayout.SOUTH, textField_1);
sl_panel_1.putConstraint(SpringLayout.EAST, textField_2, -45, SpringLayout.EAST, panel_1);
textField_2.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 16));
panel_1.add(textField_2);
textField_2.setColumns(10);
JLabel lblAccountNo_2 = new JLabel("Account No:");
sl_panel_1.putConstraint(SpringLayout.NORTH, lblAccountNo_2, 30, SpringLayout.SOUTH, lblCheckAvailability);
sl_panel_1.putConstraint(SpringLayout.WEST, textField_2, 17, SpringLayout.EAST, lblAccountNo_2);
sl_panel_1.putConstraint(SpringLayout.WEST, lblAccountNo_2, 73, SpringLayout.WEST, panel_1);
sl_panel_1.putConstraint(SpringLayout.EAST, lblAccountNo_2, 0, SpringLayout.EAST, lblCheckAvailability);
lblAccountNo_2.setFont(new Font("Verdana", Font.PLAIN, 16));
panel_1.add(lblAccountNo_2);
textField_4 = new JTextField();
sl_panel_1.putConstraint(SpringLayout.SOUTH, textField_2, -17, SpringLayout.NORTH, textField_4);
sl_panel_1.putConstraint(SpringLayout.NORTH, textField_4, 188, SpringLayout.NORTH, panel_1);
sl_panel_1.putConstraint(SpringLayout.EAST, textField_4, -45, SpringLayout.EAST, panel_1);
sl_panel_1.putConstraint(SpringLayout.SOUTH, textField_4, -94, SpringLayout.SOUTH, panel_1);
textField_4.setFont(new Font("Yu Gothic UI Semilight", Font.PLAIN, 16));
panel_1.add(textField_4);
textField_4.setColumns(10);
JLabel lblAmount = new JLabel("Amount:");
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblAccountNo_2, -33, SpringLayout.NORTH, lblAmount);
sl_panel_1.putConstraint(SpringLayout.WEST, textField_4, 17, SpringLayout.EAST, lblAmount);
sl_panel_1.putConstraint(SpringLayout.NORTH, lblAmount, -1, SpringLayout.NORTH, textField_4);
sl_panel_1.putConstraint(SpringLayout.WEST, lblAmount, 102, SpringLayout.WEST, panel_1);
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblAmount, -102, SpringLayout.SOUTH, panel_1);
sl_panel_1.putConstraint(SpringLayout.EAST, lblAmount, 0, SpringLayout.EAST, lblCheckAvailability);
lblAmount.setFont(new Font("Verdana", Font.PLAIN, 16));
panel_1.add(lblAmount);
JButton btnTransfer = new JButton("Transfer");
btnTransfer.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-data-transfer-24.png"));
btnTransfer.setFont(new Font("Tahoma", Font.PLAIN, 20));
btnTransfer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(textField_2.getText().isEmpty() || textField_2.getText().matches("[a-zA-Z_]+")) {
JOptionPane.showMessageDialog(null, "Please enter account number to transfer");
}
else {
if(textField_4.getText().isEmpty() || textField_4.getText().matches("[a-zA-Z_]+")) {
JOptionPane.showMessageDialog(null, "Please enter amount to transfer");
}
else {
int choise = JOptionPane.showConfirmDialog(null, "Do you want to transfer money?","Transfer",JOptionPane.YES_NO_OPTION);
if(choise == JOptionPane.YES_OPTION) {
try {
getSubtractionUpdate();
getBalanceUpdate();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "Unable to add amount");
}
}
else {
JOptionPane.showMessageDialog(null, "Transfer cancelled!");
}
}
}
}
});
sl_panel_1.putConstraint(SpringLayout.NORTH, btnTransfer, 15, SpringLayout.SOUTH, textField_4);
sl_panel_1.putConstraint(SpringLayout.WEST, btnTransfer, 189, SpringLayout.WEST, panel_1);
sl_panel_1.putConstraint(SpringLayout.SOUTH, btnTransfer, -44, SpringLayout.SOUTH, panel_1);
sl_panel_1.putConstraint(SpringLayout.EAST, btnTransfer, -45, SpringLayout.EAST, panel_1);
panel_1.add(btnTransfer);
JPanel withdraw = new JPanel();
tabbedPane.addTab("Withdraw", null, withdraw, null);
SpringLayout sl_withdraw = new SpringLayout();
withdraw.setLayout(sl_withdraw);
JLabel lblAvailableBalance_1 = new JLabel("Balance:");
sl_withdraw.putConstraint(SpringLayout.NORTH, lblAvailableBalance_1, 14, SpringLayout.NORTH, withdraw);
sl_withdraw.putConstraint(SpringLayout.EAST, lblAvailableBalance_1, -738, SpringLayout.EAST, withdraw);
lblAvailableBalance_1.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-money-60.png"));
lblAvailableBalance_1.setFont(new Font("Verdana", Font.BOLD, 30));
withdraw.add(lblAvailableBalance_1);
labelBalance_1 = new JLabel("00");
sl_withdraw.putConstraint(SpringLayout.NORTH, labelBalance_1, 11, SpringLayout.NORTH, lblAvailableBalance_1);
sl_withdraw.putConstraint(SpringLayout.WEST, labelBalance_1, 6, SpringLayout.EAST, lblAvailableBalance_1);
labelBalance_1.setFont(new Font("Verdana", Font.BOLD, 30));
withdraw.add(labelBalance_1);
withdrawText = new JTextField();
sl_withdraw.putConstraint(SpringLayout.NORTH, withdrawText, 90, SpringLayout.NORTH, withdraw);
sl_withdraw.putConstraint(SpringLayout.SOUTH, withdrawText, -155, SpringLayout.SOUTH, withdraw);
sl_withdraw.putConstraint(SpringLayout.EAST, withdrawText, -123, SpringLayout.EAST, withdraw);
withdrawText.setHorizontalAlignment(SwingConstants.CENTER);
withdrawText.setFont(new Font("Verdana", Font.BOLD, 30));
withdrawText.setColumns(10);
withdraw.add(withdrawText);
JButton btnDeposit_1 = new JButton("Withdraw");
sl_withdraw.putConstraint(SpringLayout.NORTH, btnDeposit_1, 33, SpringLayout.SOUTH, withdrawText);
btnDeposit_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(withdrawText.getText().isEmpty() || withdrawText.getText().matches("[a-zA-Z_]+")) {
JOptionPane.showMessageDialog(null, "Please enter valid operation!");
}
else {
int choise = JOptionPane.showConfirmDialog(null, "Do you want to withdraw money?","Withdraw",JOptionPane.YES_NO_OPTION);
int DBalance = Integer.parseInt(getBalance());
int UBalance = Integer.parseInt(getUserBalance());
int Balance = DBalance-UBalance;
if(choise == JOptionPane.YES_OPTION) {
String finalBalance = String.valueOf(Balance);
String sql = "update account set balance=? where name=?";
try {
if(DBalance>=UBalance) {
ps = conn.prepareStatement(sql);
ps.setString(2, searchUser.getText());
ps.setString(1, finalBalance);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Balance Withdrawn!");
setWithdraw();
getBalanceUpdate();
}
else {
JOptionPane.showMessageDialog(null, "Balance Exceeded!");
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "Balance failed to Withdraw!");
}
}
else {
JOptionPane.showMessageDialog(null, "Withdraw Cancelled!");
}
}
}
});
LocalDate date = java.time.LocalDate.now();
String finalDate = date.toString();
allTimeDate.setText(finalDate);
btnDeposit_1.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\Downloads\\icons8-atm-50.png"));
sl_withdraw.putConstraint(SpringLayout.WEST, btnDeposit_1, 0, SpringLayout.WEST, withdrawText);
sl_withdraw.putConstraint(SpringLayout.SOUTH, btnDeposit_1, -63, SpringLayout.SOUTH, withdraw);
sl_withdraw.putConstraint(SpringLayout.EAST, btnDeposit_1, 0, SpringLayout.EAST, withdrawText);
btnDeposit_1.setFont(new Font("Serif", Font.BOLD, 30));
withdraw.add(btnDeposit_1);
JLabel lblName_1_1 = new JLabel("NAME:");
sl_withdraw.putConstraint(SpringLayout.WEST, lblName_1_1, 124, SpringLayout.WEST, withdraw);
sl_withdraw.putConstraint(SpringLayout.WEST, withdrawText, 439, SpringLayout.EAST, lblName_1_1);
sl_withdraw.putConstraint(SpringLayout.NORTH, lblName_1_1, 26, SpringLayout.NORTH, withdrawText);
lblName_1_1.setFont(new Font("Tahoma", Font.BOLD, 18));
withdraw.add(lblName_1_1);
JLabel lblAccountNo_1_1 = new JLabel("ACCOUNT NO:");
sl_withdraw.putConstraint(SpringLayout.NORTH, lblAccountNo_1_1, 44, SpringLayout.SOUTH, lblName_1_1);
sl_withdraw.putConstraint(SpringLayout.EAST, lblAccountNo_1_1, 0, SpringLayout.EAST, lblName_1_1);
lblAccountNo_1_1.setFont(new Font("Tahoma", Font.BOLD, 18));
withdraw.add(lblAccountNo_1_1);
JLabel lblNewLabel_2 = new JLabel("New label");
sl_withdraw.putConstraint(SpringLayout.NORTH, lblNewLabel_2, 42, SpringLayout.SOUTH, lblAvailableBalance_1);
sl_withdraw.putConstraint(SpringLayout.WEST, lblNewLabel_2, 21, SpringLayout.EAST, lblName_1_1);
sl_withdraw.putConstraint(SpringLayout.EAST, lblNewLabel_2, -202, SpringLayout.WEST, withdrawText);
lblNewLabel_2.setFont(new Font("Verdana", Font.BOLD, 20));
withdraw.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("New label");
sl_withdraw.putConstraint(SpringLayout.NORTH, lblNewLabel_3, 40, SpringLayout.SOUTH, lblNewLabel_2);
lblNewLabel_3.setFont(new Font("Verdana", Font.BOLD, 20));
sl_withdraw.putConstraint(SpringLayout.WEST, lblNewLabel_3, 0, SpringLayout.WEST, lblNewLabel_2);
withdraw.add(lblNewLabel_3);
JPanel transaction = new JPanel();
tabbedPane.addTab("Transaction", null, transaction, null);
JPanel panel_3 = new JPanel();
GroupLayout gl_transaction = new GroupLayout(transaction);
gl_transaction.setHorizontalGroup(
gl_transaction.createParallelGroup(Alignment.LEADING)
.addComponent(panel_3, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 991, Short.MAX_VALUE)
);
gl_transaction.setVerticalGroup(
gl_transaction.createParallelGroup(Alignment.LEADING)
.addComponent(panel_3, GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
);
JScrollPane scrollPane = new JScrollPane();
GroupLayout gl_panel_3 = new GroupLayout(panel_3);
gl_panel_3.setHorizontalGroup(
gl_panel_3.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 991, Short.MAX_VALUE)
);
gl_panel_3.setVerticalGroup(
gl_panel_3.createParallelGroup(Alignment.LEADING)
.addComponent(scrollPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
);
JPanel panel_4 = new JPanel();
scrollPane.setViewportView(panel_4);
transTable = new JTable();
transTable.setRowSelectionAllowed(false);
transTable.setRowMargin(10);
transTable.setRowHeight(35);
transTable.setIntercellSpacing(new Dimension(5, 0));
transTable.setFont(new Font("Tahoma", Font.PLAIN, 16));
transTable.setEnabled(false);
transTable.setAutoCreateRowSorter(true);
JLabel lblNewLabel_6 = new JLabel("ID");
lblNewLabel_6.setFont(new Font("Tahoma", Font.PLAIN, 16));
JLabel lblNewLabel_7 = new JLabel("USER NAME");
lblNewLabel_7.setFont(new Font("Tahoma", Font.PLAIN, 16));
JLabel lblNewLabel_8 = new JLabel("DATE");
lblNewLabel_8.setFont(new Font("Tahoma", Font.PLAIN, 16));
JLabel lblNewLabel_9 = new JLabel("DEPOSIT");
lblNewLabel_9.setFont(new Font("Tahoma", Font.PLAIN, 16));
JLabel lblNewLabel_10 = new JLabel("WITHDRAW");
lblNewLabel_10.setFont(new Font("Tahoma", Font.PLAIN, 16));
GroupLayout gl_panel_4 = new GroupLayout(panel_4);
gl_panel_4.setHorizontalGroup(
gl_panel_4.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_4.createSequentialGroup()
.addGroup(gl_panel_4.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_4.createSequentialGroup()
.addGap(74)
.addComponent(lblNewLabel_6, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
.addGap(134)
.addComponent(lblNewLabel_7, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
.addGap(120)
.addComponent(lblNewLabel_8, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE)
.addGap(164)
.addComponent(lblNewLabel_9, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
.addGap(118)
.addComponent(lblNewLabel_10, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE))
.addComponent(transTable, GroupLayout.PREFERRED_SIZE, 990, GroupLayout.PREFERRED_SIZE))
.addContainerGap(146, Short.MAX_VALUE))
);
gl_panel_4.setVerticalGroup(
gl_panel_4.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_4.createSequentialGroup()
.addGap(22)
.addGroup(gl_panel_4.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel_6, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_7, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_8, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_9, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_10, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(transTable, GroupLayout.PREFERRED_SIZE, 1391, GroupLayout.PREFERRED_SIZE)
.addContainerGap(24, Short.MAX_VALUE))
);
panel_4.setLayout(gl_panel_4);
panel_3.setLayout(gl_panel_3);
transaction.setLayout(gl_transaction);
JPanel changepin = new JPanel();
tabbedPane.addTab("Change Pin", null, changepin, null);
SpringLayout sl_changepin = new SpringLayout();
changepin.setLayout(sl_changepin);
JLabel lblChangePin = new JLabel("Change Pin");
sl_changepin.putConstraint(SpringLayout.NORTH, lblChangePin, 35, SpringLayout.NORTH, changepin);
sl_changepin.putConstraint(SpringLayout.WEST, lblChangePin, 78, SpringLayout.WEST, changepin);
lblChangePin.setFont(new Font("Verdana", Font.BOLD, 30));
changepin.add(lblChangePin);
JButton btnNewButton_2 = new JButton("Change Pin");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int choise = JOptionPane.showConfirmDialog(null, "Are you sure?","Change pin",JOptionPane.YES_NO_OPTION);
if(choise == JOptionPane.YES_OPTION) {
String oldPin = getPin();
String sql = "update account set pin=? where name=?";
try {
if(textField_3.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Enter old pin!");
}
else {
if(!(oldPin.equals(textField_3.getText()))) {
JOptionPane.showMessageDialog(null, "Enter correct pin!");
}else {
if(textField_5.getText().equals("")||textField_6.getText().equals("") ) {
JOptionPane.showMessageDialog(null, "new pin can't left empty!");
}
else {
if((textField_5.getText().length() <=4) || (textField_5.getText().length() >=8)) {
JOptionPane.showMessageDialog(null, "4-8 character!");
}
else {
if(!(textField_6.getText().equals(textField_5.getText()))) {
JOptionPane.showMessageDialog(null, "Pin didn't match!");
}
else {
ps = conn.prepareStatement(sql);
ps.setString(2, searchUser.getText());
ps.setString(1,textField_5.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Pin Changed!");
}
}
}
}
}
}
catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "Pin failed to retreive!");
JOptionPane.showMessageDialog(null, e1);
}
}
else {
JOptionPane.showMessageDialog(null, "Cancelled!");
}
}
});
btnNewButton_2.setFont(new Font("Tahoma", Font.BOLD, 20));
sl_changepin.putConstraint(SpringLayout.NORTH, btnNewButton_2, -63, SpringLayout.SOUTH, changepin);
sl_changepin.putConstraint(SpringLayout.SOUTH, btnNewButton_2, -25, SpringLayout.SOUTH, changepin);
sl_changepin.putConstraint(SpringLayout.EAST, btnNewButton_2, -301, SpringLayout.EAST, changepin);
changepin.add(btnNewButton_2);
textField_3 = new JTextField();
sl_changepin.putConstraint(SpringLayout.WEST, btnNewButton_2, 0, SpringLayout.WEST, textField_3);
textField_3.setFont(new Font("Tahoma", Font.PLAIN, 20));
changepin.add(textField_3);
textField_3.setColumns(10);
textField_5 = new JTextField();
sl_changepin.putConstraint(SpringLayout.SOUTH, textField_5, -139, SpringLayout.SOUTH, changepin);
sl_changepin.putConstraint(SpringLayout.WEST, textField_3, 0, SpringLayout.WEST, textField_5);
sl_changepin.putConstraint(SpringLayout.SOUTH, textField_3, -16, SpringLayout.NORTH, textField_5);
sl_changepin.putConstraint(SpringLayout.EAST, textField_3, 0, SpringLayout.EAST, textField_5);
sl_changepin.putConstraint(SpringLayout.EAST, textField_5, -301, SpringLayout.EAST, changepin);
textField_5.setFont(new Font("Tahoma", Font.PLAIN, 20));
changepin.add(textField_5);
textField_5.setColumns(10);
textField_6 = new JTextField();
sl_changepin.putConstraint(SpringLayout.NORTH, textField_6, 19, SpringLayout.SOUTH, textField_5);
sl_changepin.putConstraint(SpringLayout.WEST, textField_6, 0, SpringLayout.WEST, textField_3);
textField_6.setFont(new Font("Tahoma", Font.PLAIN, 20));
changepin.add(textField_6);
textField_6.setColumns(10);
JLabel lblNewLabel_4 = new JLabel("Old pin:");
lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 20));
sl_changepin.putConstraint(SpringLayout.SOUTH, lblNewLabel_4, 0, SpringLayout.SOUTH, textField_3);
sl_changepin.putConstraint(SpringLayout.EAST, lblNewLabel_4, -29, SpringLayout.WEST, textField_3);
changepin.add(lblNewLabel_4);
JLabel lblNewLabel_5 = new JLabel("New pin:");
lblNewLabel_5.setFont(new Font("Tahoma", Font.PLAIN, 20));
sl_changepin.putConstraint(SpringLayout.SOUTH, lblNewLabel_5, 0, SpringLayout.SOUTH, textField_5);
sl_changepin.putConstraint(SpringLayout.EAST, lblNewLabel_5, 0, SpringLayout.EAST, lblNewLabel_4);
changepin.add(lblNewLabel_5);
JLabel lblConfirmPin = new JLabel("Confirm pin:");
lblConfirmPin.setFont(new Font("Tahoma", Font.PLAIN, 20));
sl_changepin.putConstraint(SpringLayout.NORTH, lblConfirmPin, 30, SpringLayout.SOUTH, lblNewLabel_5);
sl_changepin.putConstraint(SpringLayout.EAST, lblConfirmPin, 0, SpringLayout.EAST, lblNewLabel_4);
changepin.add(lblConfirmPin);
JPanel about = new JPanel();
tabbedPane.addTab("About", null, about, null);
JLabel lblDeveloperInfo = new JLabel("Developer Info");
lblDeveloperInfo.setFont(new Font("Tahoma", Font.BOLD, 20));
JLabel lblNameAbdullaAl = new JLabel("Name: Abdulla al jaber");
lblNameAbdullaAl.setFont(new Font("Tahoma", Font.PLAIN, 15));
JLabel lblUniversityNanjingUniversity = new JLabel("University: Nanjing university of information science and technology");
lblUniversityNanjingUniversity.setFont(new Font("Tahoma", Font.PLAIN, 15));
JLabel lblNewLabel_15 = new JLabel("Country: Bangladesh");
lblNewLabel_15.setFont(new Font("Tahoma", Font.PLAIN, 15));
JLabel lblEducationbscInSoftware = new JLabel("Education:B.Sc in Software Engineering (Continue..)");
lblEducationbscInSoftware.setFont(new Font("Tahoma", Font.PLAIN, 15));
JLabel lblNewLabel_16 = new JLabel("");
lblNewLabel_16.setIcon(new ImageIcon("C:\\Users\\Majed Abdullah\\eclipse-workspace\\Banking_management_system\\src\\Banking_management\\icons\\icons8-developer-mode-100.png"));
GroupLayout gl_about = new GroupLayout(about);
gl_about.setHorizontalGroup(
gl_about.createParallelGroup(Alignment.LEADING)
.addGroup(gl_about.createSequentialGroup()
.addGap(53)
.addGroup(gl_about.createParallelGroup(Alignment.LEADING)
.addGroup(gl_about.createParallelGroup(Alignment.LEADING)
.addComponent(lblNameAbdullaAl)
.addGroup(gl_about.createParallelGroup(Alignment.LEADING)
.addComponent(lblDeveloperInfo)
.addComponent(lblNewLabel_15)))
.addGroup(gl_about.createParallelGroup(Alignment.LEADING)
.addComponent(lblEducationbscInSoftware)
.addComponent(lblUniversityNanjingUniversity)))
.addPreferredGap(ComponentPlacement.RELATED, 259, Short.MAX_VALUE)
.addComponent(lblNewLabel_16, GroupLayout.PREFERRED_SIZE, 116, GroupLayout.PREFERRED_SIZE)
.addGap(125))
);
gl_about.setVerticalGroup(
gl_about.createParallelGroup(Alignment.LEADING)
.addGroup(gl_about.createSequentialGroup()
.addGap(14)
.addGroup(gl_about.createParallelGroup(Alignment.TRAILING)
.addComponent(lblNewLabel_16, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_about.createSequentialGroup()
.addComponent(lblDeveloperInfo)
.addGap(26)
.addComponent(lblNameAbdullaAl)
.addGap(11)
.addComponent(lblNewLabel_15)
.addGap(13)
.addComponent(lblEducationbscInSoftware)
.addGap(13)
.addComponent(lblUniversityNanjingUniversity))))
);
about.setLayout(gl_about);
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(searchUser.getText().isEmpty() || searchUser.getText().matches("[0-9]+")) {
JOptionPane.showMessageDialog(null, "Enter your user name!");
}
else {
loadTransaction();
try {
getBalanceUpdate();
} catch (SQLException e2) {
JOptionPane.showMessageDialog(null, e2);
}
String sql = "select * from account where name=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1,searchUser.getText());
rs = ps.executeQuery();
if(rs.next()) {
String one = rs.getString("name");
name.setText(one);
lblNewLabel_12.setText(one);
Userlabel.setText(one);
lblNewLabel_2.setText(one);
String two = rs.getString("dob");
dob.setText(two);
String three = rs.getString("acc");
accountno.setText(three);
lblNewLabel_14.setText(three);
Accountlabel.setText(three);
lblNewLabel_3.setText(three);
String four = rs.getString("acc_type");
accounttype.setText(four);
String five = rs.getString("nationality");
nationality.setText(five);
String six = rs.getString("balance");
amount.setText(six);
labelBalance.setText(six);
labelBalance_1.setText(six);
lblNewLabel_13.setText(six);
String seven = rs.getString("gender");
gender.setText(seven);
String eight = rs.getString("mobile");
mobile.setText(eight);
String nine = rs.getString("address");
address.setText(nine);
String ten = rs.getString("sec_q");
secq.setText(ten);
updateUserInfo();
}
else {
JOptionPane.showMessageDialog(null, "User doesn't exists!");
}
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1);
}
}
}
});
}
//------------------------------------------------------Get Balance-------------------------------------------------------
public String getBalance() {
String balance = null;
String sql = "select * from account where name=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1, searchUser.getText());
rs = ps.executeQuery();
if(rs.next()) {
balance = rs.getString("balance");
}
else {
JOptionPane.showMessageDialog(null, "Failed to deposit");
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1);
}
return balance;
}
//-----------------------------------------------------------GetPin
public String getPin() {
String pin = null;
String sql = "select * from account where name=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1, searchUser.getText());
rs = ps.executeQuery();
if(rs.next()) {
pin = rs.getString("pin");
}
else {
JOptionPane.showMessageDialog(null, "Failed to retrieve");
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1);
}
return pin;
}
public String getUserBalance() {
return withdrawText.getText();
}
public void setDeposit() throws SQLException {
String sqlDepo="insert into trans(acc,date,deposit) values(?,?,?)";
ps = conn.prepareStatement(sqlDepo);
ps.setString(1, searchUser.getText());
ps.setString(2, String.valueOf(new java.util.Date()));
ps.setString(3, "+"+depositText.getText());
ps.execute();
loadTransaction();
}
// public void refreshTable() throws SQLException {
// //String getDepositCell = transTable.getModel().getValueAt(arg0, arg1)
// String sqlDepo="select * from trans where searchUser=?";
// ps = conn.prepareStatement(sqlDepo);
// ps.setString(1, searchUser.getText());
// rs = ps.executeQuery();
// transTable.getModel().getValueAt(rs);
// ps.execute();
//
// }
public void setWithdraw() throws SQLException {
String sqlDepo="insert into trans(acc,date,withdraw) values(?,?,?)";
ps = conn.prepareStatement(sqlDepo);
ps.setString(1, searchUser.getText());
ps.setString(2, String.valueOf(new java.util.Date()));
ps.setString(3, "-"+withdrawText.getText());
//ps.setString(4, withdrawText.getText());
ps.execute();
loadTransaction();
}
public String getCurrentDate(){
LocalDate date = java.time.LocalDate.now();
String finalDate = date.toString();
System.out.println(finalDate);
return null;
}
//getTransferAmount
public String getTransferAmount() {
String amount = textField_4.getText();
return amount;
}
public int getSubtract() {
int myBalance = Integer.parseInt(getBalance());
int userBalance = Integer.parseInt(getTransferAmount());
int subtractedAmount = myBalance - userBalance;
return subtractedAmount;
}
public String getToAmount() {
String balance = null;
String sql = "select * from account where acc=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1, textField_2.getText());
rs = ps.executeQuery();
if(rs.next()) {
balance = rs.getString("balance");
}
else {
JOptionPane.showMessageDialog(null, "Failed to retreive money");
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, e1);
}
return balance;
}
public int getAdded() {
int getTransferAmount = Integer.parseInt(getTransferAmount());
int getToAmount = Integer.parseInt(getToAmount());
int addAmount = getToAmount + getTransferAmount;
return addAmount;
}
public void getAdditionUpdate() throws SQLException {
int add = getAdded();
String sql = "update account set balance=? where acc=?";
ps = conn.prepareStatement(sql);
ps.setString(2, textField_1.getText());
ps.setString(1, String.valueOf(add));
ps.executeUpdate();
}
public void getSubtractionUpdate() throws SQLException {
int sub = getSubtract();
String val = String.valueOf(sub);
String sql2 = "update account set balance=? where name=?";
ps = conn.prepareStatement(sql2);
ps.setString(2, searchUser.getText());
ps.setString(1, String.valueOf(val));
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Balance Transferred!");
getAdditionUpdate();
}
public void updateUserInfo() {
String sql = "select * from account where name=?";
try {
ps = conn.prepareStatement(sql);
ps.setString(1,searchUser.getText());
rs = ps.executeQuery();
if(rs.next()) {
String one = rs.getString("name");
name.setText(one);
String two = rs.getString("dob");
dob.setText(two);
String three = rs.getString("acc");
accountno.setText(three);
String four = rs.getString("acc_type");
accounttype.setText(four);
String five = rs.getString("nationality");
nationality.setText(five);
String six = rs.getString("balance");
amount.setText(six);
String seven = rs.getString("gender");
gender.setText(seven);
String eight = rs.getString("mobile");
mobile.setText(eight);
String nine = rs.getString("address");
address.setText(nine);
String ten = rs.getString("sec_q");
secq.setText(ten);
}
else {
//JOptionPane.showMessageDialog(null, "User doesn't exists!");
}
} catch (Exception e1) {
JOptionPane.showMessageDialog(null, e1);
}
}
public void getBalanceUpdate() throws SQLException {
String sql = "select balance from account where name=? ";
ps = conn.prepareStatement(sql);
ps.setString(1, searchUser.getText());
rs = ps.executeQuery();
while(rs.next()) {
labelBalance_1.setText(rs.getString("balance"));
labelBalance.setText(rs.getString("balance"));
lblNewLabel_13.setText(rs.getString("balance"));
}
}
public void loadTransaction() {
String sql = "select * from trans where acc=? order by id desc";
try {
ps=conn.prepareStatement(sql);
ps.setString(1,searchUser.getText());
rs = ps.executeQuery();
while(rs.next()) {
transTable.setModel(DbUtils.resultSetToTableModel(rs));
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "Failed to retrieve transaction!");
JOptionPane.showMessageDialog(null, e1);
}
}
}
| [
"[email protected]"
]
| |
1b137f139edf71d03b8334996a5f9b9eeb461381 | 3666fa2b8a1573e9fc6b4cc6aa0aaf9578caf596 | /src/main/java/com/gxcy/utils/HttpRequestUtil.java | 027630dc304ab143d7d632430c2b0c75c9464f54 | []
| no_license | 1779876935/gxcyserver | 1e2835123c26c0402a7628d8c7077aba9022e976 | 507f5146a23805d8da768b608c8ca04a3290751a | refs/heads/master | 2023-01-25T01:25:08.666243 | 2020-12-12T04:17:20 | 2020-12-12T04:17:20 | 318,826,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,379 | java | package com.gxcy.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
public class HttpRequestUtil {
public static void main(String[] args) {
//发送 GET 请求
String s=HttpRequestUtil.sendGet("http://v.qq.com/x/cover/kvehb7okfxqstmc.html?vid=e01957zem6o", "");
System.out.println(s);
// //发送 POST 请求
// String sr=HttpRequest.sendPost("http://www.toutiao.com/stream/widget/local_weather/data/?city=%E4%B8%8A%E6%B5%B7", "");
// JSONObject json = JSONObject.fromObject(sr);
// System.out.println(json.get("data"));
}
/**
* 向指定URL发送GET方法的请求
*
* @param url
* 发送请求的URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url
* 发送请求的 URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!"+e);
e.printStackTrace();
}
//使用finally块来关闭输出流、输入流
finally{
try{
if(out!=null){
out.close();
}
if(in!=null){
in.close();
}
}
catch(IOException ex){
ex.printStackTrace();
}
}
return result;
}
}
| [
"[email protected]"
]
| |
70d6d061d37d847d6c41b081a424e20eb7ec485e | 60f97a17d3abf030212ac0857ffb9d8048addcbb | /src/by/it/group473601/solodkin/lesson05/A_QSort.java | 790c80838f2040f64595ee95dfbd3b3d612582a4 | []
| no_license | Shpilevskiy/PISL2017-01-26 | 80a53a52ac3f9722dba9ce64e8c9002eaee0c7c2 | 44d36b0fe9f7838549ce04be03e71d8e3906569f | refs/heads/master | 2021-01-25T05:57:17.946343 | 2017-05-18T13:58:34 | 2017-05-18T13:58:34 | 80,713,571 | 0 | 0 | null | 2017-02-02T10:11:27 | 2017-02-02T10:11:27 | null | UTF-8 | Java | false | false | 4,196 | java | package by.it.group473601.solodkin.lesson05;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Scanner;
/*
Видеорегистраторы и площадь.
На площади установлена одна или несколько камер.
Известны данные о том, когда каждая из них включалась и выключалась (отрезки работы)
Известен список событий на площади (время начала каждого события).
Вам необходимо определить для каждого события сколько камер его записали.
В первой строке задано два целых числа:
число включений камер (отрезки) 1<=n<=50000
число событий (точки) 1<=m<=50000.
Следующие n строк содержат по два целых числа ai и bi (ai<=bi) -
координаты концов отрезков (время работы одной какой-то камеры).
Последняя строка содержит m целых чисел - координаты точек.
Все координаты не превышают 10E8 по модулю (!).
Точка считается принадлежащей отрезку, если она находится внутри него или на границе.
Для каждой точки в порядке их появления во вводе выведите,
скольким отрезкам она принадлежит.
Sample Input:
2 3
0 5
7 10
1 6 11
Sample Output:
1 0 0
*/
public class A_QSort {
//отрезок
private class Segment implements Comparable{
int start;
int stop;
Segment(int start, int stop){
this.start = start;
this.stop = stop;
//тут вообще-то лучше доделать конструктор на случай если
//концы отрезков придут в обратном порядке
}
@Override
public int compareTo(Object o) {
//подумайте, что должен возвращать компаратор отрезков
return 0;
}
}
int[] getAccessory(InputStream stream) throws FileNotFoundException {
//подготовка к чтению данных
Scanner scanner = new Scanner(stream);
//!!!!!!!!!!!!!!!!!!!!!!!!! НАЧАЛО ЗАДАЧИ !!!!!!!!!!!!!!!!!!!!!!!!!
//число отрезков отсортированного массива
int n = scanner.nextInt();
Segment[] segments=new Segment[n];
//число точек
int m = scanner.nextInt();
int[] points=new int[m];
int[] result=new int[m];
//читаем сами отрезки
for (int i = 0; i < n; i++) {
//читаем начало и конец каждого отрезка
segments[i]=new Segment(scanner.nextInt(),scanner.nextInt());
}
//читаем точки
for (int i = 0; i < n; i++) {
points[i]=scanner.nextInt();
}
//тут реализуйте логику задачи с применением быстрой сортировки
//в классе отрезка Segment реализуйте нужный для этой задачи компаратор
//!!!!!!!!!!!!!!!!!!!!!!!!! КОНЕЦ ЗАДАЧИ !!!!!!!!!!!!!!!!!!!!!!!!!
return result;
}
public static void main(String[] args) throws FileNotFoundException {
String root = System.getProperty("user.dir") + "/src/";
InputStream stream = new FileInputStream(root + "by/it/group473601/solodkin/lesson05/dataA.txt");
A_QSort instance = new A_QSort();
int[] result=instance.getAccessory(stream);
for (int index:result){
System.out.print(index+" ");
}
}
}
| [
"[email protected]"
]
| |
2605b3bf892831e6e0fa8a31f9eaf0a9af8f4552 | 1b0b11e292851c0ad159d05e6d34a49223f501d0 | /NilaiMaxmin.java | aeb0f03c68e9c12f268197612faba5278941f816 | []
| no_license | riniemuhardina/Tugas-Daspro-Semester-1 | 94e585911bb0815caee55b602be9937599a8ba6b | dad01668a8a815f71929dfdd3d3ded33b64158a2 | refs/heads/master | 2021-05-13T21:28:13.791257 | 2018-01-10T21:29:18 | 2018-01-10T21:29:18 | 116,463,618 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 509 | java | import java.util.Scanner;
public class NilaiMaxmin
{
public static void main(String[]args) {
Scanner masuk = new Scanner(System.in);
int data, a=1, min=Integer.MAX_VALUE, max=Integer.MIN_VALUE, b=0;
System.out.print("Banyaknya data: ");
data = masuk.nextInt();
while (a <= data) {
System.out.print("Data ke-"+a+ " : ");
b = masuk.nextInt();
if (b>max) max=b;
if (b<min) min=b;
a++;
}
System.out.println("Min: "+ min);
System.out.println("Max : " + max);
}
} | [
"[email protected]"
]
| |
c75763ca44c18431a12969183dae4e21b2e91e2e | 106be97f3215107077246d937544ba8dc40102b7 | /src/main/java/cc/xuloo/betfair/client/stream/ConnectionMessage.java | f27c99536a1c1eb307e21fa224a448897a994f0d | []
| no_license | thinkmorestupidless/betfair-akka | a7388edb5d87c4d07cf734903a9dcf81a931f6d4 | 5febf5107936a16b4bd48307cb035c37bb77af46 | refs/heads/master | 2021-05-05T22:09:19.924401 | 2018-01-03T05:22:23 | 2018-01-03T05:22:23 | 116,092,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,764 | java | /**
* Betfair: Exchange Streaming API
* API to receive streamed updates. This is an ssl socket connection of CRLF delimited json messages (see RequestMessage & ResponseMessage)
*
* OpenAPI spec version: 1.0.1423
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cc.xuloo.betfair.client.stream;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Value;
/**
* ConnectionMessage
*/
@Value
public class ConnectionMessage implements ResponseMessage {
/**
* The operation type
* @return op
**/
private final String op;
/**
* Client generated unique id to link request with response (like json rpc)
* @return id
**/
private final Integer id;
private final String connectionId;
public ConnectionMessage(@JsonProperty("op") String op,
@JsonProperty("id") Integer id,
@JsonProperty("connectionId") String connectionId) {
this.op = op;
this.id = id;
this.connectionId = connectionId;
}
}
| [
"[email protected]"
]
| |
840d973c6b0c3cdfc198deee102656e0666dfb5a | ded5cdebdd6474e20fb119fb9e45d953bd0a6337 | /Fibonacciseries.java | ecf08b367fc90f48e828abea140dcecef631b82e | []
| no_license | hussain386/gitbash | e43052e624a66ada70844da0fbba765bac354b97 | 14b4310c15a135d32a435fa631c955ab733e37bb | refs/heads/master | 2023-08-02T04:55:59.655423 | 2021-09-01T10:58:04 | 2021-09-01T10:58:04 | 402,027,458 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 295 | java | package com.javainterviewprograms;
public class Fibonacciseries {
public static void main(String[] args) {
// Fibonacci series
int a=0,b=1,c=0,count=2;
System.out.println(a+"\n"+b);
while (count<10) {
c=a+b;
a=b;
b=c;
count++;
System.out.println(c);
}
}
}
| [
"[email protected]"
]
| |
0df1c0a1e64e02b89edd2a6d98b703b04cca1662 | 7d1011c33abb099f010982d5b042a34fb8163180 | /src/main/java/Controller/ChooseGameModeSceneController.java | e2694a769c4b027aeb9610bfc389954e98f89828 | [
"MIT"
]
| permissive | dtomi97/Project_2048 | 58dcb7e9da12175864fe3bfa4b52ab4f246dd339 | 191b8607d3f5afe23ccb80fa67cf2177ffaa77e6 | refs/heads/master | 2021-07-06T05:36:33.835282 | 2019-05-15T14:22:31 | 2019-05-15T14:22:31 | 178,591,270 | 0 | 0 | MIT | 2020-09-05T16:57:59 | 2019-03-30T17:39:26 | Java | UTF-8 | Java | false | false | 2,326 | java | package Controller;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import Model.Game;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Class for controlling the Choose Game Mode Scene's actions.
*/
public class ChooseGameModeSceneController {
/**
* The logger for this class.
*/
private static Logger logger = LoggerFactory.getLogger(ChooseGameModeSceneController.class);
/**
* 3x3 game start button.
*/
@FXML
private Button btn3x3;
/**
* Starts a new game with a 3x3 size board.
* @param actionEvent the event that occurred.
* @see javafx.event.ActionEvent
*/
public void handleGameStartAction3x3(ActionEvent actionEvent) {
Game game = new Game(3, null);
Stage gameStage = (Stage) btn3x3.getScene().getWindow();
gameStage.close();
game.start(gameStage);
logger.info("The user started a 3x3 game.");
}
/**
* Starts a new game with a 4x4 size board.
* @param actionEvent the event that occurred.
* @see javafx.event.ActionEvent
*/
public void handleGameStartAction4x4(ActionEvent actionEvent) {
Game game = new Game(4, null);
Stage gameStage = (Stage) btn3x3.getScene().getWindow();
gameStage.close();
game.start(gameStage);
logger.info("The user started a 4x4 game.");
}
/**
* Starts a new game with a 5x5 size board.
* @param actionEvent the event that occurred.
* @see javafx.event.ActionEvent
*/
public void handleGameStartAction5x5(ActionEvent actionEvent) {
Game game = new Game(5, null);
Stage gameStage = (Stage) btn3x3.getScene().getWindow();
gameStage.close();
game.start(gameStage);
logger.info("User started a 5x5 game.");
}
/**
* Starts a new game with an 8x8 size board.
* @param actionEvent the event that occurred.
* @see javafx.event.ActionEvent
*/
public void handleGameStartAction8x8(ActionEvent actionEvent) {
Game game = new Game(8, null);
Stage gameStage = (Stage) btn3x3.getScene().getWindow();
gameStage.close();
game.start(gameStage);
logger.info("User started a 8x8 game.");
}
}
| [
"[email protected]"
]
| |
4c33b7efe9badb6b4883d5f2d06bd16d55345fcc | 92eae552b92557ac0327bf229e12d6d21bc69399 | /src/com/troi/balloon/panelsystem/Environment.java | 71c376b959952e52a98705b1c650bd71d9b89527 | [
"MIT"
]
| permissive | KyujuuAlpha/Balloon | 4426ff964a47575c7b9e23c7fe9822c07227c4aa | 540c003abbc27db3e6d08e4386c96d562d5ee18d | refs/heads/master | 2021-05-29T15:44:37.363046 | 2015-05-18T08:19:16 | 2015-05-18T08:19:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,866 | java | package com.troi.balloon.panelsystem;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Environment extends JPanel {
private ArrayList<Panel> panelList;
private boolean requestedRepaint;
public Environment() {
panelList = new ArrayList<Panel>();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
this.paint((Graphics2D)g);
}
private void paint(Graphics2D render) {
AffineTransform oldTransform = render.getTransform();
for(Panel panel : panelList) {
panel.paint(render);
render.translate(panel.getDimension().getWidth(), 0);
}
render.setTransform(oldTransform);
}
public void update() {
for(int i = 0; i < panelList.size(); i++) {
Panel panel = panelList.get(i);
if(panel.getDimension().getHeight() != this.getHeight()) {
panel.getDimension().setSize(panel.getDimension().getWidth(), this.getHeight());
panel.requestRepaint();
}
if(i == panelList.size() - 1 && panel.getDimension().getWidth() + (i * 100) != this.getWidth()) {
panel.getDimension().setSize(this.getWidth() - (i * 100), panel.getDimension().getHeight());
panel.requestRepaint();
} else if(i < panelList.size() - 1 && panel.getDimension().getWidth() != 100) {
panel.getDimension().setSize(100, panel.getDimension().getHeight());
panel.requestRepaint();
}
panel.update();
if(panel.checkRepaint()) this.repaint();
}
if(this.checkRepaint()) this.repaint();
}
public void add(Panel panel) {
panelList.add(panel);
this.requestRepaint();
}
public void requestRepaint() {
requestedRepaint = true;
}
public boolean checkRepaint() {
if(requestedRepaint) {
requestedRepaint = false;
return true;
} else return false;
}
} | [
"[email protected]"
]
| |
bd89e06e10299f22d37e9b8c9c91f25cb1f515ec | e36df186546bda56ed895fedc3c551b5008f125e | /src/xml/ContactMain.java | 7c1760f2c101fba5971e6beaa422a65c799b6cd1 | []
| no_license | lvzheng007/contact | b53b8a9bb1b21a32e58c8b0a0f459192f8da5c89 | a7a624c21094715f08a490ceaf65c80c067a5cf7 | refs/heads/master | 2020-04-08T08:30:36.084985 | 2019-09-22T10:20:55 | 2019-09-22T10:20:55 | 159,181,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,323 | java | package xml;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class ContactMain
{
private static BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
private static File file = new File("contact.xml");
public static void main(String[] args) throws IOException
{
ContactOperator operator = new XmlContactOperator(file);
while (true)
{
printTip();
String choose = reader.readLine().trim();
switch (choose)
{
case "a":
Contact contact1 = addContactInfoFromConsole();
if(operator.addContact(contact1))
{
System.out.println("Add successfully!");
}
else
{
System.out.println("Failed to add!");
}
System.out.println();
break;
case "u":
Contact contact2 = updateContactInfoFromConsole();
if (contact2 != null)
{
if(operator.updateContact(contact2))
{
System.out.println("Update successfully!");
}
else
{
System.out.println("Failed to update!");
}
}
System.out.println();
break;
case "d":
Contact contact3 = deleteContactInfoFromConsole();
if (contact3 != null)
{
if(operator.deleteContact(contact3))
{
System.out.println("Delete successfully!");
}
else
{
System.out.println("Failed to delete!");
}
}
System.out.println();
break;
case "l":
operator.listAllContact();
System.out.println();
break;
case "q":
System.out.println("Good Bye!");
System.exit(0);
default:
System.out.println("Illegal input,please re-enter");
}
}
}
/**
* get contact from console, this contact just set id.
*/
private static Contact deleteContactInfoFromConsole()
{
Contact contact = new Contact();
try
{
String id = null;
while (true)
{
System.out.print("The ID of the contact to be deleted([q] quit): ");
id = reader.readLine().trim();
if (id.equals("q"))
{
return null;
}
System.out.println();
if (getContact(id) != null)
{
break;
}
System.out.println("The ID dose not exist!");
}
contact.setId(id);
return contact;
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
private static Contact updateContactInfoFromConsole()
{
try
{
Contact contact = null;
while (true)
{
System.out.print("The ID of contact to be updated([q] quit):");
String id = reader.readLine().trim();
if (id.equals("q"))
{
return null;
}
contact = getContact(id);
if (contact != null)
{
break;
}
System.out.println("This ID does not exist!");
}
while (true)
{
printUpdateTip();
String choose = reader.readLine().trim();
switch (choose)
{
case "n":
System.out.print("NAME: ");
String name = reader.readLine().trim();
contact.setName(name);
return contact;
case "g":
System.out.print("GENDER: ");
String gender = reader.readLine().trim();
contact.setGender(gender);
return contact;
case "p":
System.out.print("PHONE: ");
String phone = reader.readLine().trim();
contact.setPhone(phone);
return contact;
case "a":
System.out.print("ADDRESS: ");
String address = reader.readLine().trim();
contact.setAddress(address);
return contact;
case "e":
System.out.print("EMAIL: ");
String email = reader.readLine().trim();
contact.setEmail(email);
return contact;
default:
System.out.println("Illegal input, please re-enter");
}
}
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
/**
* print tip of menu.
*/
private static void printTip()
{
String tip = "**************************\n"
+ "* MENU *\n"
+ "**************************\n"
+ "* [a] add a contact. *\n"
+ "* [u] update a contact. *\n"
+ "* [d] delete a contact. *\n"
+ "* [l] list all contacts. *\n"
+ "* [q] quit. *\n"
+ "**************************";
System.out.println(tip);
System.out.print("Input: ");
}
private static void printUpdateTip()
{
String tip = "***************\n"
+ "* UPDATE *\n"
+ "***************\n"
+ "* [n] name *\n"
+ "* [g] gender *\n"
+ "* [p] phone *\n"
+ "* [a] address *\n"
+ "* [e] email *\n"
+ "***************";
System.out.println(tip);
System.out.print("Input: ");
}
private static Contact addContactInfoFromConsole()
{
try
{
System.out.print("ID: ");
String id = reader.readLine().trim();
System.out.print("NAME: ");
String name = reader.readLine().trim();
System.out.print("GENDER: ");
String gender = reader.readLine().trim();
System.out.print("PHONE: ");
String phone = reader.readLine().trim();
System.out.print("ADDRESS: ");
String address = reader.readLine().trim();
System.out.print("EMAIL:");
String email = reader.readLine().trim();
System.out.println();
Contact contact = new Contact();
contact.setId(id);
contact.setName(name);
contact.setGender(gender);
contact.setPhone(phone);
contact.setAddress(address);
contact.setEmail(email);
return contact;
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
private static Contact getContact(String id)
{
SAXReader reader = new SAXReader();
try
{
Document document = reader.read(file);
String xpath = "//contact[@id = '" + id + "']";
Element element = (Element) document.selectSingleNode(xpath);
if (element == null)
{
return null;
}
Contact contact = new Contact();
contact.setId(element.attributeValue("id"));
contact.setName(element.elementText("name"));
contact.setGender(element.elementText("gender"));
contact.setPhone(element.elementText("phone"));
contact.setAddress(element.elementText("address"));
contact.setEmail(element.elementText("email"));
return contact;
}
catch (DocumentException e)
{
throw new RuntimeException(e);
}
}
}
| [
"[email protected]"
]
| |
4d1954b021a8624da98ba5884f41595e9ffe705a | e9aa2191392fe002cac6488e6860d2d1b83a95aa | /src/main/java/nl/jk_5/pumpkin/server/mixin/interfaces/text/IMixinChatComponent.java | aca1e103ee4d0ec78e8fba58b54c62f5c7e3f02f | []
| no_license | Pumpkin-Framework/Pumpkin-Vanilla | f8856bedee8f68eb5b781d52c711180516265767 | c568af0e344e1e178286d31eb32a6eb6e5c6e769 | refs/heads/master | 2021-01-14T08:40:37.894277 | 2015-05-14T07:59:05 | 2015-05-14T07:59:05 | 33,073,428 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 437 | java | package nl.jk_5.pumpkin.server.mixin.interfaces.text;
import net.minecraft.util.IChatComponent;
import nl.jk_5.pumpkin.api.text.Text;
import java.util.Iterator;
public interface IMixinChatComponent extends IChatComponent {
Iterator<IChatComponent> childrenIterator();
Iterable<IChatComponent> withChildren();
String toPlain();
String getLegacyFormatting();
String toLegacy(char code);
Text toText();
}
| [
"[email protected]"
]
| |
03798aefd4eda2125c92917622b3a538fd783500 | 0dffea62dd2f6c56fc8858357fd97937ac9fda36 | /SampleWebServiceSpring/src/main/java/com/esb/utility/RabbitMQMessage.java | ea66395237baed0bd5684f9daee70f7044e05feb | []
| no_license | haristanwir/SpringBoot | 9f32032b9ffa6cc778c0d0ba4e8f1454d64cf555 | f0be54fb1ed56516bcc30d87fe76b691e3c008f9 | refs/heads/master | 2023-05-26T11:46:16.036461 | 2023-05-15T13:41:14 | 2023-05-15T13:41:14 | 288,661,703 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | package com.esb.utility;
import com.rabbitmq.client.AMQP.BasicProperties;
import lombok.Data;
@Data
public class RabbitMQMessage {
private String exchange;
private String queueName;
private BasicProperties properties;
private String message;
public RabbitMQMessage(String exchange, String queueName, BasicProperties properties, String message) {
this.exchange = exchange;
this.queueName = queueName;
this.properties = properties;
this.message = message;
}
}
| [
"[email protected]"
]
| |
bdc7d89bb2419710059b16ad1f9e1b3ad79c140e | ed8d929b5a64f4311715eeb30551dd1f42cb8cd8 | /OracleJDBC/src/com/briup/day2/Test/tableTest/Test.java | d44ecd9ea1fe0730c99fd8ca1f80eea727dc7d82 | []
| no_license | gy1772007252/core-Java | 3efc771ba9fd142f412e2e8177e43f3c9e743241 | cec14352c6e8c5daf6cafe2c8a0219f044ebdede | refs/heads/main | 2023-05-28T04:51:56.693677 | 2021-06-04T14:28:13 | 2021-06-04T14:28:13 | 371,268,127 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,102 | java | package com.briup.day2.Test.tableTest;
import com.briup.dom.ConnectionFactoryByPool;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
/**
* 获取数据库的所有表,并对查询的结果进行封装;
*/
public class Test {
private static Connection connection;
static {
try {
connection = ConnectionFactoryByPool.getConnection();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
public static void main(String[] args) {
try {
List<Table> list = getDataBase();
list.forEach(System.out::println);
} catch (Exception e) {
e.printStackTrace();
}
}
private static List<Table> getDataBase() throws Exception{
List<Table> list = new ArrayList<>();
PreparedStatement ps = connection.prepareStatement("select table_name from user_tables");
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()) {
//获取表名
Table table = new Table();
String name = resultSet.getString(1);
table.setName(name);
//获取表信息
PreparedStatement ps1 = connection.prepareStatement("select * " +
"from " + name);
ResultSet resultSet1 = ps1.executeQuery();
//结果集元数据
ResultSetMetaData metaData = resultSet1.getMetaData();
int columnCount = metaData.getColumnCount();
List<Column> columns = new ArrayList<>();
for (int i = 1; i <= columnCount; i++) {
Column column = new Column();
column.setName(metaData.getColumnName(i));
column.setType(metaData.getColumnClassName(i));
//获取列是否为空
column.setRequire(ResultSetMetaData.columnNoNulls == metaData.isNullable(i));
columns.add(column);
}
table.setColumns(columns);
list.add(table);
}
return list;
}
}
| [
"[email protected]"
]
| |
82e1c5f8f69fd8130a00c0bbffb2316353a04ef3 | b60db6d5b65796710ba0e7e3caaec9fed244f4e8 | /OSalesSystem/src/cn/zying/osales/service/baseinfo/units/SelectProductStockPriceUnit.java | 68eaec3f0a37c772c90709607065f0a0c3ec2ad5 | []
| no_license | pzzying20081128/OSales_System | cb5e56ed9d096bfb3f3915bd280732f5f16ffb3b | ed5a1cd53c68460653f82c2c6bdff24bea5db9e4 | refs/heads/master | 2021-01-10T04:47:46.861972 | 2016-01-23T17:33:59 | 2016-01-23T17:33:59 | 50,175,928 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package cn.zying.osales.service.baseinfo.units ;
import org.springframework.stereotype.Component ;
import cn.zying.osales.pojos.ProductInfo ;
import cn.zying.osales.service.ABCommonsService ;
import cn.zying.osales.service.SystemOptServiceException ;
@Component("SelectProductStockPriceUnit")
public class SelectProductStockPriceUnit extends ABCommonsService {
public ProductInfo selectStockPrice(Integer id, Integer providerInfoId) throws SystemOptServiceException {
ProductInfo productInfo = baseService.get(id, ProductInfo.class) ;
productInfo.setStockPrice(productInfo.getMaxStockPrice()) ;
productInfo.setStockTaxRate(productInfo.getStockTaxRate()) ;
productInfo.setStockNoTaxPrice(23456789L) ;
return productInfo ;
}
}
| [
"[email protected]"
]
| |
258cc728c6604d93b3b0e0c7374552821c0200ce | db040743d7e8439e1591e642675d858fe3d8a340 | /src/main/java/uk/nhs/digital/gossmigrator/model/mapping/enums/PublicationSeriesColumns.java | 353608c1165804b2ecf0b39d81316cfa577b73ae | []
| no_license | NHS-digital-website/goss-hippo-migrator | a2cea722db6f76086292d2057aea3e7e060c521c | 5ef14ccb7d2e9747b0824b7c32c75860ed3bfbc5 | refs/heads/master | 2021-05-09T13:38:29.081281 | 2018-05-15T09:15:49 | 2018-05-15T09:15:49 | 119,040,204 | 0 | 0 | null | 2018-02-02T13:40:19 | 2018-01-26T10:43:32 | Java | UTF-8 | Java | false | false | 393 | java | package uk.nhs.digital.gossmigrator.model.mapping.enums;
public enum PublicationSeriesColumns {
PUBLICATION_TITLE(1),
PUBLICATION_KEY(2),
SERIES_TITLE(3),
SERIES_SUMMARY(3)
;
private int columnIndex;
PublicationSeriesColumns(int columnIndex) {
this.columnIndex = columnIndex;
}
public int getColumnIndex() {
return columnIndex;
}
}
| [
"[email protected]"
]
| |
80a0b29e495cad585bbb10face7fe0f58ae0ce47 | 671d0d2c18967df84ddce7231d01268e6f3a0b5d | /java-web-9/src/model/DAO.java | a2b975de21aa327ae937dbfd36549b1ac5a067af | [
"MIT"
]
| permissive | Biz1999/java-web | 255551494615efac9b3acccf9078dd394a930c5c | fd280aa0dd503d69a673906daa97c8d8fd36675a | refs/heads/main | 2023-04-29T12:17:20.043140 | 2021-05-18T02:59:25 | 2021-05-18T02:59:25 | 368,380,925 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,457 | java | package model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
// TODO: Auto-generated Javadoc
/**
* The Class DAO.
*/
public class DAO {
/** Módulo de conexão *. */
// Parametros de conexao
private String driver = "com.mysql.cj.jdbc.Driver";
/** The url. */
private String url = "jdbc:mysql://127.0.0.1:3333/usuarios?useTimezone=true&serverTimezone=UTC";
/** The user. */
private String user = "root";
/** The password. */
private String password = "ale12345";
/**
* Conectar.
*
* @return the connection
*/
// Método de conexao
private Connection conectar() {
Connection con = null;
try {
Class.forName(this.driver);
con = DriverManager.getConnection(this.url, this.user, this.password);
return con;
} catch (Exception e) {
System.out.println(e);
return null;
}
}
/**
* CRUD CREATE *.
*
* @param usuario the usuario
*/
public void inserirUsuario(JavaBeans usuario) {
String create = "insert into contatos (nome,fone,email) values (?,?,?)";
try {
// abrir a conexao
Connection con = conectar();
// Preparar a query para execucao no db
PreparedStatement pst = con.prepareStatement(create);
// Substituir os parametros (?) pelas variaveis
pst.setString(1, usuario.getNome());
pst.setString(2, usuario.getPhone());
pst.setString(3, usuario.getEmail());
// Executar a query
pst.executeUpdate();
// Encerrar a conexao com o banco
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
/**
* CRUD READ *.
*
* @return the array list
*/
public ArrayList<JavaBeans> listarContatos() {
// Criando o ArrayList
ArrayList<JavaBeans> usuarios = new ArrayList<>();
String read = "select * from contatos order by nome";
try {
// Abrir conexao com o db
Connection con = conectar();
PreparedStatement pst = con.prepareStatement(read);
ResultSet rs = pst.executeQuery();
// o laço abaixo será executado enquanto houver contatos
while (rs.next()) {
// variaveis de apoio que recebem os dados do banco
String idcon = rs.getString(1);
String nome = rs.getString(2);
String phone = rs.getString(3);
String email = rs.getString(4);
// populando o ArrayList
usuarios.add(new JavaBeans(idcon, nome, phone, email));
}
con.close();
return usuarios;
} catch (Exception e) {
System.out.println(e);
return null;
}
}
/**
* CRUD UPDATE *.
*
* @param usuario the usuario
*/
public void selecionarUsuario(JavaBeans usuario) {
String read2 = "select * from contatos where idcon = ?";
try {
Connection con = conectar();
PreparedStatement pst = con.prepareStatement(read2);
pst.setString(1, usuario.getIdcon());
ResultSet rs = pst.executeQuery();
while (rs.next()) {
usuario.setIdcon(rs.getString(1));
usuario.setNome(rs.getString(2));
usuario.setPhone(rs.getString(3));
usuario.setEmail(rs.getString(4));
}
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
/**
* Editar usuario.
*
* @param usuario the usuario
*/
// editar o usuario
public void editarUsuario(JavaBeans usuario) {
String update = "update contatos set nome=?, fone=?, email=? where idcon=?";
try {
Connection con = conectar();
PreparedStatement pst = con.prepareStatement(update);
pst.setString(1, usuario.getNome());
pst.setString(2, usuario.getPhone());
pst.setString(3, usuario.getEmail());
pst.setString(4, usuario.getIdcon());
pst.executeUpdate();
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
/**
* CRUD DELETE *.
*
* @param usuario the usuario
*/
public void deletaUsuario(JavaBeans usuario) {
String delete = "delete from contatos where idcon=?";
try {
Connection con = conectar();
PreparedStatement pst = con.prepareStatement(delete);
pst.setString(1, usuario.getIdcon());
pst.executeUpdate();
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
/*
* //teste de conexao public void testeConexao() { try { Connection con =
* conectar(); System.out.println(con); con.close(); } catch (Exception e) {
* System.out.println(e); } }
*/
}
| [
"[email protected]"
]
| |
20098efe9f7232f759b319681fb16051e36a19a6 | e2705a5c69989a6c5d3411f255df5fe59d556b81 | /src/main/java/com/daveclay/processing/gestures/GestureRecognizedHandler.java | 890dac23ce94907cfe5bf136d885e89d5f1e0768 | []
| no_license | daveclay/kinect | 9993ab535baabcf99a1ff8fe9d64c3b4e4dcd061 | c3fb1d649340a8d8db1674aac39f95d39b70fbe0 | refs/heads/master | 2021-04-29T11:15:44.318357 | 2016-10-18T16:10:25 | 2016-10-18T16:10:25 | 77,854,412 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 202 | java | package com.daveclay.processing.gestures;
public interface GestureRecognizedHandler {
public void gestureRecognized(RecognitionResult gesture);
void gestureWasNotRecognized(String message);
}
| [
"[email protected]"
]
| |
409f3daa1d6614f6d5fcd92343db09d30da0eb91 | b458abd5dbdfcda1cd6866d8d58bd81cd1e034e5 | /rxbus/src/test/java/com/hwangjr/rxbus/AnnotatedSubscriberFinderTest.java | f6cb46fe17fa086eccf1dddad994dbedb3c0b23d | [
"Apache-2.0"
]
| permissive | ladingwu/RxBusPlus | 561a73a5cef1e4fcb08e26b300934d19d2a505e9 | 889d8fbcc881831696bb312aad5663b9bdd25078 | refs/heads/master | 2020-03-17T18:15:04.793585 | 2018-05-17T13:47:43 | 2018-05-17T13:47:43 | 133,819,782 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,827 | java | package com.hwangjr.rxbus;
import com.hwangjr.rxbus.annotation.Subscribe;
import com.hwangjr.rxbus.thread.EventThread;
import com.hwangjr.rxbus.thread.ThreadEnforcer;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import static junit.framework.Assert.fail;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test that Bus finds the correct subscribers.
* <p/>
* This test must be outside the c.g.c.rxbus package to test correctly.
*/
@RunWith(Enclosed.class)
@SuppressWarnings("UnusedDeclaration")
public class AnnotatedSubscriberFinderTest {
private static final Object EVENT = new Object();
@Ignore // Tests are in extending classes.
public abstract static class AbstractEventBusTest<S> {
abstract S createSubscriber();
private S subscriber;
S getSubscriber() {
return subscriber;
}
@Before
public void setUp() throws Exception {
subscriber = createSubscriber();
Bus bus = new Bus(ThreadEnforcer.ANY);
bus.register(subscriber);
bus.post(EVENT);
}
@After
public void tearDown() throws Exception {
subscriber = null;
}
}
/*
* We break the tests up based on whether they are annotated or abstract in the superclass.
*/
public static class BaseSubscriberFinderTest
extends AbstractEventBusTest<BaseSubscriberFinderTest.Subscriber> {
static class Subscriber {
final List<Object> nonSubscriberEvents = new ArrayList<Object>();
final List<Object> subscriberEvents = new ArrayList<Object>();
public void notASubscriber(Object o) {
nonSubscriberEvents.add(o);
}
@Subscribe(
thread = EventThread.SINGLE
)
public void subscriber(Object o) {
subscriberEvents.add(o);
}
}
@Test
public void nonSubscriber() {
assertThat(getSubscriber().nonSubscriberEvents).isEmpty();
}
@Test
public void subscriber() {
assertThat(getSubscriber().subscriberEvents).containsExactly(EVENT);
}
@Override
Subscriber createSubscriber() {
return new Subscriber();
}
}
public static class AbstractNotAnnotatedInSuperclassTest
extends AbstractEventBusTest<AbstractNotAnnotatedInSuperclassTest.SubClass> {
abstract static class SuperClass {
public abstract void overriddenInSubclassNowhereAnnotated(Object o);
public abstract void overriddenAndAnnotatedInSubclass(Object o);
}
static class SubClass extends SuperClass {
final List<Object> overriddenInSubclassNowhereAnnotatedEvents = new ArrayList<Object>();
final List<Object> overriddenAndAnnotatedInSubclassEvents = new ArrayList<Object>();
@Override
public void overriddenInSubclassNowhereAnnotated(Object o) {
overriddenInSubclassNowhereAnnotatedEvents.add(o);
}
@Subscribe(
thread = EventThread.SINGLE
)
@Override
public void overriddenAndAnnotatedInSubclass(Object o) {
overriddenAndAnnotatedInSubclassEvents.add(o);
}
}
@Test
public void overriddenAndAnnotatedInSubclass() {
assertThat(getSubscriber().overriddenAndAnnotatedInSubclassEvents).containsExactly(EVENT);
}
@Test
public void overriddenInSubclassNowhereAnnotated() {
assertThat(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents).isEmpty();
}
@Override
SubClass createSubscriber() {
return new SubClass();
}
}
public static class NeitherAbstractNorAnnotatedInSuperclassTest
extends AbstractEventBusTest<NeitherAbstractNorAnnotatedInSuperclassTest.SubClass> {
static class SuperClass {
final List<Object> neitherOverriddenNorAnnotatedEvents = new ArrayList<Object>();
final List<Object> overriddenInSubclassNowhereAnnotatedEvents = new ArrayList<Object>();
final List<Object> overriddenAndAnnotatedInSubclassEvents = new ArrayList<Object>();
public void neitherOverriddenNorAnnotated(Object o) {
neitherOverriddenNorAnnotatedEvents.add(o);
}
public void overriddenInSubclassNowhereAnnotated(Object o) {
overriddenInSubclassNowhereAnnotatedEvents.add(o);
}
public void overriddenAndAnnotatedInSubclass(Object o) {
overriddenAndAnnotatedInSubclassEvents.add(o);
}
}
static class SubClass extends SuperClass {
@Override
public void overriddenInSubclassNowhereAnnotated(Object o) {
super.overriddenInSubclassNowhereAnnotated(o);
}
@Subscribe(
thread = EventThread.SINGLE
)
@Override
public void overriddenAndAnnotatedInSubclass(Object o) {
super.overriddenAndAnnotatedInSubclass(o);
}
}
@Test
public void neitherOverriddenNorAnnotated() {
assertThat(getSubscriber().neitherOverriddenNorAnnotatedEvents).isEmpty();
}
@Test
public void overriddenInSubclassNowhereAnnotated() {
assertThat(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents).isEmpty();
}
@Test
public void overriddenAndAnnotatedInSubclass() {
assertThat(getSubscriber().overriddenAndAnnotatedInSubclassEvents).containsExactly(EVENT);
}
@Override
SubClass createSubscriber() {
return new SubClass();
}
}
public static class FailsOnInterfaceSubscription {
static class InterfaceSubscriber {
@Subscribe(
thread = EventThread.SINGLE
)
public void whatever(Serializable thingy) {
// Do nothing.
}
}
@Test
public void subscribingToInterfacesFails() {
try {
new Bus(ThreadEnforcer.ANY).register(new InterfaceSubscriber());
fail("Annotation finder allowed subscription to illegal interface type.");
} catch (IllegalArgumentException expected) {
// Do nothing.
}
}
}
}
| [
"[email protected]"
]
| |
3944721b41117bd2c2ba736998315e1810fd585d | 46751c17d7503a06eb0d6c5077ba453a3da9f500 | /app/src/main/java/com/ad_sih/Nature.java | e4bf8a4d284d667fc120d3d462624bb12ca2d6fc | []
| no_license | sharmelachandran/Mobile-Game-For-Alzheimers-DIsease-Detection | 4d77719205fade3734bfee642e938b8a7fb2f617 | 071eaba840e1c688a65722048959c969e217dd26 | refs/heads/master | 2022-11-27T01:45:20.697062 | 2020-08-03T10:21:33 | 2020-08-03T10:21:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,139 | java | package com.ad_sih;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.ArrayList;
import java.util.Locale;
import pl.droidsonroids.gif.GifImageView;
import smartdevelop.ir.eram.showcaseviewlib.GuideView;
import smartdevelop.ir.eram.showcaseviewlib.config.DismissType;
import smartdevelop.ir.eram.showcaseviewlib.config.Gravity;
import smartdevelop.ir.eram.showcaseviewlib.listener.GuideListener;
public class Nature extends AppCompatActivity implements ConnectivityRecevier.ConnectivityRecevierListener{
Button T,H,V1,S1;
TextView ins,P,B,M;
GifImageView gf;
int count=0,i=0,l=5,ccount=0;
int f[]={0,0,0};
String str[]={"Parrot","Butterfly","Monkey"},str1;
private static final int REQUEST_CODE_SPEECH_INPUT=1000;
TextToSpeech textToSpeech;
View v1,v2,v3,v4,v5;
private GuideView mGuideView;
private GuideView.Builder builder;
final IntentFilter intentFilter=new IntentFilter();
MediaPlayer m;
ConnectivityRecevier connectivityRecevier=new ConnectivityRecevier();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_nature);
m= MediaPlayer.create(getApplicationContext(),R.raw.m2);
m.start();
checkInternetConnection();
v1=findViewById(R.id.h);
v2=findViewById(R.id.trails);
v3=findViewById(R.id.voice);
v4=findViewById(R.id.speech);
P=findViewById(R.id.par);
B=findViewById(R.id.butterfly);
M=findViewById(R.id.monkey);
ins=findViewById(R.id.ins);
V1=findViewById(R.id.voice);
S1=findViewById(R.id.speech);
T=findViewById(R.id.trails);
T.setText(l+" Trials");
H=findViewById(R.id.h);
gf=findViewById(R.id.gifImageView);
str1=str[0];
//instruction tour
builder = new GuideView.Builder(this)
.setTitle("Home")
.setContentText("It helps you to go back to home page[1/4]")
.setGravity(Gravity.center)
.setDismissType(DismissType.anywhere)
.setTargetView(v1)
.setGuideListener(new GuideListener() {
@Override
public void onDismiss(View view) {
switch (view.getId()) {
case R.id.h:
builder.setTitle("Trials").setContentText("You have 5 trials totally\nfor 3 words[2/4]").setTargetView(v2).build();
break;
case R.id.trails:
builder.setTitle("Speaker").setContentText("By clicking this,\nYou can hear pronunciation of each words[3/4]").setTargetView(v3).build();
break;
case R.id.voice:
builder.setTitle("Mic").setContentText("You have to say each word by clicking this mic[4/4]").setTargetView(v4).build();
break;
case R.id.speech:
gf.setBackgroundResource(R.drawable.ni1);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
gf.setBackgroundResource(R.drawable.ni2);
ins.setBackgroundResource(R.drawable.nwrins);
}
},3000);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ins.setBackgroundResource(R.color.grass);
P.setBackgroundResource(R.drawable.nar);
startFlash(P);
gf.setBackgroundResource(R.drawable.ni1);
}
},7000);
return;
}
mGuideView = builder.build();
mGuideView.show();
}
});
mGuideView = builder.build();
mGuideView.show();
updatingForDynamicLocationViews();
gf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gf.setBackgroundResource(R.drawable.ni2);
ins.setBackgroundResource(R.drawable.nwrins);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ins.setBackgroundResource(R.color.grass);
gf.setBackgroundResource(R.drawable.ni1);
}
},5000);
}
});
H.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {m.stop();
Intent i=new Intent(getApplicationContext(),home.class);
i.putExtra("level",1);
startActivity(i);unregisterReceiver(connectivityRecevier);finish();
}
});
textToSpeech=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status==TextToSpeech.SUCCESS)
{
int lang=textToSpeech.setLanguage(Locale.ENGLISH);
}
}
});
V1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int speech =textToSpeech.speak(str1,TextToSpeech.QUEUE_FLUSH,null);
}
});
S1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
speak();
}
});
}
private void updatingForDynamicLocationViews() {
v4.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
mGuideView.updateGuideViewLocation();
}
});
}
private void checkInternetConnection(){
boolean isConnected=ConnectivityRecevier.isConnected();
if(!isConnected){
changeActivity();
}
}
private void changeActivity(){
Intent i=new Intent(this,OfflineActivity.class);
this.onPause();
i.putExtra("activity","Nature");
startActivity(i);
}
@Override
public void onNetworkConnectionChanged(boolean isConnected) {
if(!isConnected){
changeActivity();
}
}
@Override
protected void onResume() {
super.onResume();
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(connectivityRecevier,intentFilter);
MyApp.getInstance().setConnectivityListner(this);
}
void startFlash(TextView c)
{
Animation animation=new AlphaAnimation(1,0);
animation.setDuration(200);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(2);
animation.setRepeatMode(Animation.INFINITE);
c.startAnimation(animation);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_SPEECH_INPUT: {
if (resultCode == RESULT_OK && null != data) {
ArrayList<String> result1 = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
assert result1 != null;
final String s = result1.get(0);
String u = s.toLowerCase();
String m1=str1.toLowerCase();
count++;
l=5-count;
T.setText(l+" Trials");
if (u.equals(m1)) {
ccount++;
i++;
if(i<3) {
str1=str[i];
Toast.makeText(getApplicationContext(), "SUPER!!!\nTouch mic and say "+str[i], Toast.LENGTH_LONG).show();
}
else {
gotonext();
}
} else {
if(count>=5)
{
gotonext();
}
if(i<3)
f[i]+=1;
if(f[i]>=3&&i<2)
{
i++;
str1=str[i];
}
else if(l==0||i==3)
{
gotonext();
}
else{
Toast.makeText(getApplicationContext(),"Touch mic and say "+m1+"\nYou have "+l+" Trails",Toast.LENGTH_LONG).show();
}
}
if(i==1){
P.setBackgroundResource(R.color.grass);
B.setBackgroundResource(R.drawable.nar);
startFlash(B);
}
else if(i==2) {
B.setBackgroundResource(R.color.grass);
M.setBackgroundResource(R.drawable.nar);
startFlash(M);
}
break;
}
}
}
}
private void gotonext(){
String s ="";
if(ccount==3)
{
s="RESULT\nSUPER!! You done very well";
}else
s="RESULT\nNot Bad\nRemember these words till game ends";
storedata(s);
}
private void storedata(String s){
FirebaseDatabase firebaseDatabase=FirebaseDatabase.getInstance();
DatabaseReference register = firebaseDatabase.getReference().child(FirebaseAuth.getInstance().getUid()).child("Nature");
register.child("MMSE").child("Word_registration").setValue(ccount);
register.child("AD_Finder").child("Word_registration").setValue(ccount);
Intent i = new Intent(getApplicationContext(), home.class);
i.putExtra("level",2);m.stop();
startActivity(i);unregisterReceiver(connectivityRecevier);finish();
//showCustomDialog(s);
}
private void speak(){
Intent i=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
i.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say the word");
try{
startActivityForResult(i,REQUEST_CODE_SPEECH_INPUT);
}catch(Exception e){
Toast.makeText(this,""+e.getMessage(),Toast.LENGTH_LONG).show();
}
}
@Override
public void onBackPressed() {
Toast.makeText(getApplicationContext(),"Press Home to go back",Toast.LENGTH_SHORT).show();
}
/*protected void showCustomDialog(final String s) {
// TODO Auto-generated method stub
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.result_dialog);
GifImageView gf=findViewById(R.id.stargif);
final TextView tv = (TextView) dialog.findViewById(R.id.res);
Button button = (Button)dialog.findViewById(R.id.buttonOk);
if(count==3)
tv.setText(s);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}*/
}
| [
"[email protected]"
]
| |
1114ea522ae3d4a391736ec1b309d3d6e5c66ed5 | fbc40126afb2d020ab0df021b1aea3aec7794c81 | /e3_register/e3_register_service/src/main/java/com/hzm/register/JedisClientCluster.java | feb36f76b1d592a3d5273dc35c9896584f6ab452 | []
| no_license | wenzhoufejichang/e3 | c0bb4b0e1de7fb8ff3cc0a64118313ebf45110e4 | 6a64aad15922777884a6c91f308883d944b33004 | refs/heads/master | 2020-04-26T01:26:30.120112 | 2019-03-01T03:04:38 | 2019-03-01T03:04:38 | 173,204,135 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,277 | java | package com.hzm.register;
import javax.annotation.Resource;
import redis.clients.jedis.JedisCluster;
public class JedisClientCluster implements JedisClient {
@Resource(name = "jedisCluster")
private JedisCluster jedisCluster;
@Override
public String set(String key, String value) {
return jedisCluster.set(key, value);
}
@Override
public String get(String key) {
return jedisCluster.get(key);
}
@Override
public Boolean exists(String key) {
return jedisCluster.exists(key);
}
@Override
public Long expire(String key, int seconds) {
return jedisCluster.expire(key, seconds);
}
@Override
public Long ttl(String key) {
return jedisCluster.ttl(key);
}
@Override
public Long incr(String key) {
return jedisCluster.incr(key);
}
@Override
public Long hset(String key, String field, String value) {
return jedisCluster.hset(key, field, value);
}
@Override
public String hget(String key, String field) {
return jedisCluster.hget(key, field);
}
@Override
public Long hdel(String key, String... field) {
return jedisCluster.hdel(key, field);
}
@Override
public Long delete(String key) {
// TODO Auto-generated method stub
return jedisCluster.del(key);
}
}
| [
"[email protected]"
]
| |
ec7fee838f26ceea72e107039d01986b68477811 | aa3839a4e28bee89b77009f2cda2462fa68bc725 | /src/main/java/com/ibgreg/cursospringboot/services/SmtpEmailService.java | 390b508155110cb302c06d5412d0c1d9ab579fa6 | []
| no_license | ibgreg/cursospringboot | 9dc331b7b8fd79fd509849a2a970a749d77658b5 | cc9384b550db481502f3e948af011f6996560c0b | refs/heads/master | 2021-07-07T05:57:48.139927 | 2020-07-11T20:28:46 | 2020-07-11T20:28:46 | 239,307,591 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 919 | java | package com.ibgreg.cursospringboot.services;
import javax.mail.internet.MimeMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
public class SmtpEmailService extends AbstractEmailService {
private static final Logger LOG = LoggerFactory.getLogger(MockEmailService.class);
@Autowired
private MailSender mailSender;
@Autowired
private JavaMailSender javaMailSender;
@Override
public void sendEmail(SimpleMailMessage msg) {
LOG.info("Enviando email...");
mailSender.send(msg);
LOG.info("Email enviado");
}
@Override
public void sendHtmlEmail(MimeMessage msg) {
LOG.info("Enviando email em HTML...");
javaMailSender.send(msg);
LOG.info("Email enviado");
}
}
| [
"[email protected]"
]
| |
c6f3b8c29d709f6f9142606f85a13164ee20043c | 8d345e38fe76a80b1e7802f9c66c14598742a512 | /app/src/main/java/com/aleksandar69/PMSU2020Tim16/models/Contact.java | d69d12a597e9922faf4e8494e4d1b3011d96bfa7 | []
| no_license | draganpetrovic/Android-Email-App | e57fe8f25e85cd7fe9bcfc62806f01a831683e09 | 27adc25cc433c722fc8fe89a36e218b9311938f5 | refs/heads/main | 2023-03-03T07:09:33.839297 | 2021-02-16T15:40:34 | 2021-02-16T15:40:34 | 339,410,190 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,583 | java | package com.aleksandar69.PMSU2020Tim16.models;
import com.aleksandar69.PMSU2020Tim16.R;
import com.google.gson.annotations.SerializedName;
public class Contact {
private int _id;
private String first;
private String last;
private String display;
private String email;
private Integer imageSourceID;
private String url;
private byte[] image;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Contact(String first){
this.first = first;
}
public void setLast(String last) {
this.last = last;
}
@Override
public String toString() {
return "Contact{" +
"_id=" + _id +
", first='" + first + '\'' +
", last='" + last + '\'' +
", display='" + display + '\'' +
", email='" + email + '\'' +
", imageSourceID=" + imageSourceID +
'}';
}
public void setEmail(String email) {
this.email = email;
}
public void setImageSourceID(Integer imageSourceID) {
this.imageSourceID = imageSourceID;
}
public void setFirst(String first) {
this.first = first;
}
public void setDisplay(String display) {
this.display = display;
}
public int get_id() {
return _id;
}
public void set_id(int _id) {
this._id = _id;
}
public String getLast() {
return last;
}
public Integer getImageSourceID() {
return imageSourceID;
}
public String getFirst() {
return first;
}
public String getEmail() {
return email;
}
public String getDisplay() {
return display;
}
public Contact(String first, String last, String display, String email, Integer imageSourceID) {
this.first = first;
this.last = last;
this.display = display;
this.email = email;
this.imageSourceID = imageSourceID;
}
public Contact(String first, String last, String display, String email, byte[] image) {
this.first = first;
this.last = last;
this.display = display;
this.email = email;
this.image = image;
}
public byte[] getImage() {
return image;
}
public void setImage(byte[] image) {
this.image = image;
}
public Contact(int id, String first, String last, String display, String email, byte[] image) {
_id = id;
this.first = first;
this.last = last;
this.display = display;
this.email = email;
this.image = image;
}
public Contact(int id, String first, String last, String display, String email) {
this._id = id;
this.first = first;
this.last = last;
this.display = display;
this.email = email;
// this.imageSourceID = imageSourceID;
}
public Contact(String first, String last, String display, String email) {
this.first = first;
this.last = last;
this.display = display;
this.email = email;
}
public Contact(){
}
/*
public static final Contact[] contacts = {
new Contact("Elena", "Krunic", "Elena Krunic", "[email protected]", R.mipmap.ic_launcher_round),
new Contact("Vincent", "Andolini", "Vincent Andolini", "[email protected]", R.mipmap.ic_launcher_round),
new Contact("Mico", "Micic", "Mico Micic", "[email protected]", R.mipmap.ic_launcher_round)
};
*/
}
| [
"[email protected]"
]
| |
aab2ce3c36e4bd243b3096ca998644546e101c2e | 4465f98568447abc2566e39194c12afa3a67b65f | /src/main/java/lc/common/impl/registry/ComponentRegistry.java | 419751ace7cf83774f7981d59dbf163671fd086f | []
| no_license | irgusite/LanteaCraft | 1d3b331f832083ed35e27c7b2ec0e8ddee463785 | 596e088dfd759f07c4aee145a676fcb336a60b47 | refs/heads/master | 2020-12-27T08:20:30.487360 | 2014-10-11T03:46:40 | 2014-10-11T03:46:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 497 | java | package lc.common.impl.registry;
import lc.api.components.ComponentType;
import lc.api.components.IComponentRegistry;
/**
* Component registry implementation.
*
* @author AfterLifeLochie
*
*/
public class ComponentRegistry implements IComponentRegistry {
@Override
public boolean isEnabled(ComponentType type) {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isLoaded(ComponentType type) {
// TODO Auto-generated method stub
return false;
}
}
| [
"[email protected]"
]
| |
92a14295d2c44affe6a0b18f98aa5c145ff6d3da | 8ac61d5d6c13b68e5181f4ae5984ef8767051864 | /src/main/java/com/alicjawozniak/ticketbooker/config/DataInitializer.java | d106f798785e03212020e1355dfa737af15bbdbe | []
| no_license | alicja-wozniak/ticket-booker | 2836c562b313518f8a0825eba74fa72283d5ee1e | 17b6abb8e35de4fd0c156f8c76fb71f82fd25d90 | refs/heads/master | 2020-12-23T07:39:34.410512 | 2020-03-15T16:15:18 | 2020-03-15T16:15:18 | 237,086,248 | 0 | 0 | null | 2020-03-15T16:15:20 | 2020-01-29T21:30:13 | Java | UTF-8 | Java | false | false | 4,905 | java | package com.alicjawozniak.ticketbooker.config;
import com.alicjawozniak.ticketbooker.domain.movie.Movie;
import com.alicjawozniak.ticketbooker.domain.room.Room;
import com.alicjawozniak.ticketbooker.domain.room.Seat;
import com.alicjawozniak.ticketbooker.domain.screening.Screening;
import com.alicjawozniak.ticketbooker.domain.ticket.Ticket;
import com.alicjawozniak.ticketbooker.domain.ticket.TicketType;
import com.alicjawozniak.ticketbooker.repository.movie.MovieRepository;
import com.alicjawozniak.ticketbooker.repository.room.RoomRepository;
import com.alicjawozniak.ticketbooker.repository.room.SeatRepository;
import com.alicjawozniak.ticketbooker.repository.screening.ScreeningRepository;
import com.alicjawozniak.ticketbooker.repository.ticket.TicketRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
@Service
@RequiredArgsConstructor
@Profile("!test")
public class DataInitializer {
private final MovieRepository movieRepository;
private final RoomRepository roomRepository;
private final SeatRepository seatRepository;
private final TicketRepository ticketRepository;
private final ScreeningRepository screeningRepository;
private Random random = new Random();
@PostConstruct
public void initialize() {
List<Movie> movies = Stream.of("Cats", "Dogs", "Savannah", "Forest", "Ocean")
.map(this::createMovie)
.collect(Collectors.toList());
List<Room> rooms = Stream.of("Room 1", "Room 2", "Room 3", "Room 4", "Room 5")
.map(this::createRoom)
.collect(Collectors.toList());
rooms.forEach(this::createSeats);
List<String> userSurnames = Arrays.asList("Kowalski", "Nowak", "Smith");
List<Screening> screenings = IntStream.rangeClosed(1, 20)
.mapToObj(i -> createScreening(
getRandomElement(movies),
getRandomElement(rooms)
))
.collect(Collectors.toList());
IntStream.rangeClosed(1, 20)
.forEach(i -> {
Screening screening = getRandomElement(screenings);
createTicket(
screening,
getRandomElement(userSurnames),
getRandomElement(screening.getFreeSeats())
);
});
}
private Screening createScreening(Movie movie, Room room){
int day = random.nextInt(3);
int hour = random.nextInt(22);
int minutes = random.nextInt(59);
return screeningRepository.save(
Screening.builder()
.movie(movie)
.room(room)
.startTime(LocalDateTime.now().plusDays(day).withHour(hour).withMinute(minutes))
.endTime(LocalDateTime.now().plusDays(day).withHour(hour + 2).withMinute(minutes))
.build()
);
}
private Movie createMovie(String title){
return movieRepository.save(
Movie.builder()
.title(title)
.build()
);
}
private Room createRoom(String number){
return roomRepository.save(
Room.builder()
.number(number)
.build()
);
}
private List<Seat> createSeats(Room room){
return seatRepository.saveAll(
LongStream.rangeClosed(1, 10)
.mapToObj(number -> Seat.builder()
.number(number)
.room(room)
.build()
)
.collect(Collectors.toList())
);
}
private void createTicket(Screening screening, String userSurname, Seat seat){
ticketRepository.save(
Ticket.builder()
.screening(screening)
.userName("Adam")
.userSurname(userSurname)
.typeQuantities(Collections.singletonMap(TicketType.ADULT, 1))
.seats(Collections.singletonList(seat))
.build()
);
}
private <T> T getRandomElement(List<T> list) {
int size = list.size();
int randomIndex = random.nextInt(size-1);
return list.get(randomIndex);
}
}
| [
"[email protected]"
]
| |
d364d60eb04cba619428f2e4c3b4c76350b75f2e | cf459d48b4aa8c45cfb127a6eeeec2ac4fd85e45 | /AdminPanel/adminPanel/src/main/java/com/nagarro/adminPanel/services/FilterUsersServicesImpl.java | 8360a371b5209b66cc2e6eb685e788a25c8fd778 | []
| no_license | ANARCYPHER/CasinoGameApplication | f8fc1164473ff422141492695d601ace7be6f127 | 2dcb4f1152b2b003198298c2ecae969033be6f4a | refs/heads/master | 2023-04-26T20:26:25.057922 | 2020-09-27T18:11:26 | 2020-09-27T18:11:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 836 | java | package com.nagarro.adminPanel.services;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nagarro.adminPanel.dao.FilterUsersDao;
import com.nagarro.adminPanel.model.CustomerDetails;
@Service
public class FilterUsersServicesImpl implements FilterUsersServices {
final static Logger LOG = Logger.getLogger(FilterUsersServicesImpl.class);
@Autowired
FilterUsersDao filterUsersDao;
public List<CustomerDetails> filterUsersList(String filterName, String filterContact, String filterEMail) {
LOG.info("Inside service for filtering the users based on the user input.");
List<CustomerDetails> usersList = filterUsersDao.filterList(filterName, filterContact, filterEMail);
return usersList;
}
}
| [
"[email protected]"
]
| |
f79cf7fa414fa1d895d15249537aac7f2c50d70a | 5588490bc1742fd94e2cb357b799f03673b2ba3e | /순차문/등급판별.java | 1da0a3464090963c7745bf9c76b8a4fe667f34bf | []
| no_license | shirleyshallwe/mega_java | 370b79ab2082387c5384ec5dc1a67fcfb667b09a | e5b0af0011dc8d8893ffe1da52966cb4904d71db | refs/heads/master | 2020-06-19T10:54:14.195865 | 2019-08-11T07:32:23 | 2019-08-11T07:32:23 | 196,683,351 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 699 | java | package 순차문;
import java.util.Scanner;
public class 등급판별 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("본인의 사원증 번호를 입력하세요:");
System.out.println("예) C573");
String sn = sc.next();
char staff = sn.charAt(0);
System.out.println(staff);
switch (staff) {
case 'A':
System.out.println("최우수 입니다");
break;
case 'B':
System.out.println("우수 입니다");
break;
case 'C':
System.out.println("보통 입니다");
break;
default:
System.out.println("통과하지 않았습니다.");
break;
}
}
}
| [
"[email protected]"
]
| |
19964ea18de8481fe775e2863b51b95242a62dd8 | 385dbdaa41a6d68c9c2630cc05ca3a08d9f551b6 | /src/main/java/com/ibm/optim/oaas/sample/trucking/rest/TruckingRestResource.java | b21b28c2f1f92991ad952a60be398d9ff8519776 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | nmdoshi/DOcloud-GreenTruck-sample | aaa196002d333088395c67e35d2e3506ac9aa44d | 1ec67bb577fad1919a52a775dd8ca89386d01e48 | refs/heads/master | 2021-01-17T23:04:15.740144 | 2015-09-24T22:54:47 | 2015-09-24T22:54:47 | 43,437,494 | 0 | 1 | null | 2015-09-30T14:23:20 | 2015-09-30T14:23:20 | null | UTF-8 | Java | false | false | 6,739 | java | package com.ibm.optim.oaas.sample.trucking.rest;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import com.ibm.optim.oaas.sample.trucking.ejb.TruckingManager;
import com.ibm.optim.oaas.sample.trucking.model.Hub;
import com.ibm.optim.oaas.sample.trucking.model.Shipment;
import com.ibm.optim.oaas.sample.trucking.model.Spoke;
import com.ibm.optim.oaas.sample.trucking.model.TruckType;
import com.mongodb.DBObject;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
/**
* REST trucking resource.
*/
@Path("trucking")
@Api(value = "/trucking", description = "Trucking sample API")
public class TruckingRestResource {
private static Logger LOG = Logger.getLogger(TruckingRestResource.class
.getName());
TruckingManager manager;
@Context
HttpServletRequest request;
public TruckingRestResource(TruckingManager manager) {
this.manager = manager;
}
@ApiOperation(value = "Initializes the data store with demo data.")
@POST
@Path("/initialize")
public void initialize() {
manager.initialize();
}
@ApiOperation(value = "Initializes the data store with demo data.")
@POST
@Path("/deleteAllJobs")
public void deleteAllJobs() {
manager.deleteAllJobs();
}
@ApiOperation(value = "Returns the input data sent to the engine for optimization.")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/snapshot")
public StreamingOutput snapshot() {
return new StreamingOutput() {
@Override
public void write(OutputStream os) throws IOException {
try {
manager.getSnapshot(os);
} catch (IOException e) {
throw new WebApplicationException(e,
Response.Status.INTERNAL_SERVER_ERROR);
}
}
};
}
@ApiOperation(value = "Returns the list of hubs.", response = Hub.class, responseContainer = "List")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/hubs")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the list of hubs is returned.") })
public List<Hub> getHubs() {
return manager.getHubs();
}
@ApiOperation(value = "Returns the list of spokes.", response = Spoke.class, responseContainer = "List")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/spokes")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the list of spokes is returned.") })
public List<Spoke> getSpokes() {
return manager.getSpokes();
}
@ApiOperation(value = "Returns the list of shipments.", response = Shipment.class, responseContainer = "List")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/shipments")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the list of shipments is returned.") })
public List<Shipment> getShipments() {
return manager.getShipments();
}
@ApiOperation(value = "Adds a new shipment.", response = Shipment.class)
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/shipments")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the added shipment is returned.") })
public Shipment addShitment(Shipment s) {
return manager.addShipment(s);
}
@ApiOperation(value = "Deletes all shipments.")
@DELETE
@Path("/shipments")
@ApiResponses(value = { @ApiResponse(code = 204, message = "The request executed successfully and the shipments have been deleted.") })
public Response deleteShipments() {
manager.deleteShipments();
return Response.status(204).build();
}
@ApiOperation(value = "Returns a shipment.", response = Shipment.class)
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/shipments/{id}")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the shipment is returned.") })
public Response getShipment(@PathParam("id") String id) {
Shipment s = manager.getShipment(id);
if (s != null) {
return Response.status(200).entity(s).build();
} else {
return Response.status(404).build();
}
}
@ApiOperation(value = "Deletes a shipment.")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/shipments/{id}")
@ApiResponses(value = { @ApiResponse(code = 204, message = "The request executed successfully and the shipment has been deleted.") })
public Response deleteShipment(@PathParam("id") String id) {
manager.deleteShipment(id);
return Response.status(204).build();
}
@ApiOperation(value = "Updates a shipment.")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Path("/shipments/{id}")
@ApiResponses(value = { @ApiResponse(code = 204, message = "The request executed successfully and the shipment has been updated.") })
public Response updateShipment(@PathParam("id") String id, Shipment s) {
manager.updateShipment(s);
return Response.status(204).build();
}
@ApiOperation(value = "Returns the list of truck types.", response = TruckType.class, responseContainer = "List")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/truckTypes")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The request executed successfully and the list of truck types is returned.") })
public List<TruckType> getTruckTypes() {
return manager.getTruckTypes();
}
@ApiOperation(value = "Request to optimize the latest data (synchronously).")
@POST
@Path("/solve")
public void solve() {
manager.solve();
}
@ApiOperation(value = "Request to optimize the latest data (asynchronously).")
@POST
@Path("/solveAsync")
public Response solveAsync() {
try {
manager.solveAsync();
return Response.status(204).build();
} catch (Exception e) {
return Response.status(400).entity(new RestStatus(400,e.getLocalizedMessage())).build();
}
}
@ApiOperation(value = "Returns the latest solution if any.")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/solution")
public DBObject solution() {
return manager.getSolution();
}
@ApiOperation(value = "Deletes the latest solution if any.")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/solution")
public void deleteSolution() {
manager.deleteSolution();
}
}
| [
"[email protected]"
]
| |
70dd9e5c9d7e49f3d8134714157cb72bca7b1a23 | 6c029d714b0e81dadbf83937cde0efb37f405e6e | /projects/OG-Bloomberg/src/com/opengamma/bbg/livedata/AbstractBloombergLiveDataServer.java | 4075e09e5a80db08cf266cf4d9bbb2a199fade63 | [
"Apache-2.0"
]
| permissive | martinksmith/OG-Platform | 16b4ecf2579f254deb598d630b11701d29000f1f | 2a322924a692d8db8667f57ef06ef7e00504f44b | refs/heads/master | 2021-01-16T01:23:54.887657 | 2012-04-02T19:54:21 | 2012-04-02T19:54:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,203 | java | /**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.bbg.livedata;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.sf.ehcache.CacheManager;
import org.fudgemsg.FudgeMsg;
import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.bbg.PerSecurityReferenceDataResult;
import com.opengamma.bbg.ReferenceDataProvider;
import com.opengamma.bbg.ReferenceDataResult;
import com.opengamma.bbg.util.BloombergDataUtils;
import com.opengamma.core.security.SecurityUtils;
import com.opengamma.id.ExternalScheme;
import com.opengamma.livedata.normalization.StandardRuleResolver;
import com.opengamma.livedata.resolver.DefaultDistributionSpecificationResolver;
import com.opengamma.livedata.resolver.DistributionSpecificationResolver;
import com.opengamma.livedata.resolver.EHCachingDistributionSpecificationResolver;
import com.opengamma.livedata.resolver.IdResolver;
import com.opengamma.livedata.resolver.NormalizationRuleResolver;
import com.opengamma.livedata.server.AbstractLiveDataServer;
import com.opengamma.livedata.server.Subscription;
import com.opengamma.util.ArgumentChecker;
import com.opengamma.util.ehcache.EHCacheUtils;
/**
* Allows common functionality to be shared between the live and recorded Bloomberg data servers
*/
public abstract class AbstractBloombergLiveDataServer extends AbstractLiveDataServer {
private NormalizationRuleResolver _normalizationRules;
private IdResolver _idResolver;
private DistributionSpecificationResolver _defaultDistributionSpecificationResolver;
/**
* Gets a reference data provider for use when cached results are acceptable, and perhaps preferred.
*
* @return a reference data provider, which might be caching
*/
protected abstract ReferenceDataProvider getCachingReferenceDataProvider();
/**
* Gets a reference data provider for use when cached results are not acceptable.
*
* @return a non-caching reference data provider
*/
protected abstract ReferenceDataProvider getUnderlyingReferenceDataProvider();
@Override
protected ExternalScheme getUniqueIdDomain() {
return SecurityUtils.BLOOMBERG_BUID;
}
@Override
protected boolean snapshotOnSubscriptionStartRequired(Subscription subscription) {
// As per Kirk, it is possible that you don't get all fields initially.
// Should we optimize this by asset type?
return true;
}
@Override
public Map<String, FudgeMsg> doSnapshot(Collection<String> uniqueIds) {
ArgumentChecker.notNull(uniqueIds, "Unique IDs");
if (uniqueIds.isEmpty()) {
return Collections.emptyMap();
}
Set<String> buids = new HashSet<String>();
for (String uniqueId : uniqueIds) {
String buid = "/buid/" + uniqueId;
buids.add(buid);
}
// caching ref data provider must not be used here
ReferenceDataResult referenceData = getUnderlyingReferenceDataProvider().getFields(buids, BloombergDataUtils.STANDARD_FIELDS_SET);
if (referenceData == null) {
throw new OpenGammaRuntimeException("Could not obtain reference data for " + buids);
}
Map<String, FudgeMsg> returnValue = new HashMap<String, FudgeMsg>();
for (String buid : buids) {
PerSecurityReferenceDataResult result = referenceData.getResult(buid);
if (result == null) {
throw new OpenGammaRuntimeException("Result for " + buid + " was not found");
}
String securityUniqueId = buid.substring("/buid/".length());
FudgeMsg fieldData = result.getFieldData();
if (fieldData == null) {
throw new OpenGammaRuntimeException("Reference data provider " + getUnderlyingReferenceDataProvider() + " returned null fieldData for " + buid);
}
returnValue.put(securityUniqueId, fieldData);
}
return returnValue;
}
public synchronized NormalizationRuleResolver getNormalizationRules() {
if (_normalizationRules == null) {
_normalizationRules = new StandardRuleResolver(BloombergDataUtils.getDefaultNormalizationRules(getCachingReferenceDataProvider(), EHCacheUtils.createCacheManager()));
}
return _normalizationRules;
}
public synchronized IdResolver getIdResolver() {
if (_idResolver == null) {
_idResolver = new BloombergIdResolver(getCachingReferenceDataProvider());
}
return _idResolver;
}
public synchronized DistributionSpecificationResolver getDefaultDistributionSpecificationResolver() {
if (_defaultDistributionSpecificationResolver == null) {
CacheManager cacheManager = EHCacheUtils.createCacheManager();
DefaultDistributionSpecificationResolver distributionSpecResolver = new DefaultDistributionSpecificationResolver(getIdResolver(), getNormalizationRules(), new BloombergJmsTopicNameResolver(
getCachingReferenceDataProvider()));
return new EHCachingDistributionSpecificationResolver(distributionSpecResolver, cacheManager, "BBG");
}
return _defaultDistributionSpecificationResolver;
}
}
| [
"[email protected]"
]
| |
6c03bf54521db0873b9c96f658f1c097e1ff7ed8 | 1095a193341fb09b1f2a16f0e4d2fa75eeab46cb | /src/utils/mybatis.java | 765dbc62d93f8484c8433e0549dda83541f612ea | []
| no_license | geekWastelands/FetchNews | 6121604595232f07320b50d2a0870120cae99c94 | 1e31181916091b13e8ece3f90620a28174b4ebf3 | refs/heads/master | 2020-03-16T14:54:23.336289 | 2018-05-09T07:27:43 | 2018-05-09T07:46:29 | 132,716,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,711 | java | package utils;
import Mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.InputStream;
public class mybatis {
private static SqlSessionFactory sqlSessionFactory;
static {
try {
String resource="SqlMapConfig.xml";
//得到配置文件流
InputStream inputStream= Resources.getResourceAsStream(resource);
// 创建会话工厂,传入mybatis的配置文件信息
sqlSessionFactory = new SqlSessionFactoryBuilder()
.build(inputStream);
}catch (Exception e){
e.printStackTrace();
}
//mybatis配置文件
}
public static SqlSessionFactory getSqlSessionFactory() {
return sqlSessionFactory;
}
public void updateUser(User user)throws Exception{
SqlSession sqlSession=sqlSessionFactory.openSession();
UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
// 调用UserMapper的方法
//User user=new User();
userMapper.updateUser(user);
sqlSession.commit();
sqlSession.close();
System.out.println(user);
}
public void insertUser(User user)throws Exception{
SqlSession sqlSession=sqlSessionFactory.openSession();
UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
// 调用UserMapper的方法
//User user=new User();
userMapper.insertUser(user);
sqlSession.commit();
sqlSession.close();
System.out.println(user);
}
}
| [
"[email protected]"
]
| |
c391e14849abab4205f7e438383354b47495ce1c | f74b568af9edbfd14318d6c61baa84059e9408df | /src/main/java/com/kavlord/teacher/model/Group.java | 15a23d2c4abcc30e0d63a289407eb6f3102e092d | []
| no_license | KarolMalinowski22/teacher | 4f8efa2fd423efe70fe54602d05226cbaac2bec4 | f9a32e546c9335ed37a363e214ae1a6f032a0b69 | refs/heads/master | 2020-04-22T11:58:42.234715 | 2019-04-09T15:19:18 | 2019-04-09T15:19:18 | 170,358,843 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 796 | java | package com.kavlord.teacher.model;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Cascade;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Setter
@Getter
@Entity(name = "class")
public class Group {
{
teachers = new ArrayList<>();
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String town;
private String address;
private String description;
@ManyToMany(mappedBy = "groups")
private List<Dancer> dancers;
@ManyToMany
@JoinTable(name = "teacher_class",
joinColumns = @JoinColumn(name = "classId"),
inverseJoinColumns = @JoinColumn(name = "teacherId"))
private List<Teacher> teachers;
}
| [
"[email protected]"
]
| |
1c885ecc3a9667e427e12a3db83c019143eba612 | 660c28c2837ccb8be820626d49c2946cfb3424cf | /server/src/main/java/com/library/server/models/Book.java | 194a44c5e1f0a4318dd585945c32045f1ed76752 | [
"MIT"
]
| permissive | lizebang/library-management-system | f604ccf65d8d12ee1e9349fd1775068407bcabba | 6344309c78b7dd9baa00900cd107a908ba8d99fc | refs/heads/master | 2020-03-17T00:06:41.968115 | 2018-07-03T17:17:55 | 2018-07-03T17:17:55 | 133,104,173 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,093 | java | package com.library.server.models;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Book {
@Id
@GeneratedValue
private Long id;
public final static String BookId = "id";
private String isbn;
public final static String BookIsbn = "isbn";
private String mark;
public final static String BookMark = "mark";
private String name;
public final static String BookName = "name";
private String tag;
public final static String BookTag = "tag";
private String author;
public final static String BookAuthor = "author";
private String introduction;
public final static String BookIntroduction = "introduction";
private Integer amount;
public final static String BookAmount = "amount";
private Integer inventory;
public final static String BookInventory = "inventory";
public Book() {}
public Book(String isbn, String mark, String name, String tag, String author,
String introduction, Integer amount, Integer inventory) {
this.isbn = isbn;
this.mark = mark;
this.name = name;
this.tag = tag;
this.author = author;
this.introduction = introduction;
this.amount = amount;
this.inventory = inventory;
}
public void setId(Long id) {
this.id = id;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getIsbn() {
return isbn;
}
public Long getId() {
return id;
}
public String getMark() {
return mark;
}
public void setMark(String mark) {
this.mark = mark;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getIntroduction() {
return introduction;
}
public void setIntroduction(String introduction) {
this.introduction = introduction;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public Integer getInventory() {
return inventory;
}
public void setInventory(Integer inventory) {
this.inventory = inventory;
}
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put(BookId, id);
map.put(BookIsbn, isbn);
map.put(BookMark, mark);
map.put(BookName, name);
map.put(BookTag, tag);
map.put(BookAuthor, author);
map.put(BookIntroduction, introduction);
map.put(BookAmount, amount);
map.put(BookInventory, inventory);
return map;
}
}
| [
"[email protected]"
]
| |
e6f106425f2dafa0892a17b415ae56800e0df3e4 | a870cf32c9d68d8e4bb65aa6fd4b9177e7db54bf | /src/main/java/ar/edu/unlam/smartshop/modelos/api/Row.java | a9c512794bc64ac411425629af2e8d07b6a49d5c | []
| no_license | lcabre/tallerdedisenio-tp2 | bcaa30c1afd291773818c221b2c07612900d4882 | 2c91fd6a9a242d9ff052263fc7c3fb878cf77227 | refs/heads/master | 2021-05-08T01:34:57.157714 | 2017-11-30T23:36:45 | 2017-11-30T23:36:45 | 107,883,122 | 0 | 3 | null | 2017-11-30T18:08:37 | 2017-10-22T16:29:59 | Java | UTF-8 | Java | false | false | 286 | java | package ar.edu.unlam.smartshop.modelos.api;
import java.util.List;
public class Row {
List<Element> elements;
public List<Element> getElements() {
return elements;
}
public void setElements(List<Element> elements) {
this.elements = elements;
}
}
| [
"[email protected]"
]
| |
33ac44de77a2ac9fa26f6f7346d222a9884f4409 | 165e1a272682483e857669e3a3db27ee4c977d18 | /app/src/main/java/xiaolong/homeaccount/AddInaccountActivity.java | b12db32dfe8dcecf07004757c013097cfd221a5a | []
| no_license | DimoHarkey/HomeAccount | 4d86541c12bdf778aee049989cecbf21acb54ca9 | 5f90f71f769f10c12715905a289e20e921244d3b | refs/heads/master | 2021-01-16T23:16:28.498496 | 2017-02-27T09:40:33 | 2017-02-27T09:40:33 | 82,771,256 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package xiaolong.homeaccount;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class AddInaccountActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_inaccount);
}
}
| [
"[email protected]"
]
| |
e56ffc957aefd7c43a0407fb57777e8f6e8b14bc | e6f71335af3693363ff7649ff7adef00f882a19b | /src/main/java/com/hokage/persistence/dataobject/HokageSupervisorServerDO.java | cac43ec46c795078c6fcc8fd40adfe666a130f92 | []
| no_license | zhengmingliang/hokage | 6eb8be74b2903a522bcf1dea7199d5236a7ef9ea | 0de606bc1cc5312a21910013d7260c1f8dfe4aea | refs/heads/master | 2023-08-25T17:38:20.996308 | 2021-10-30T17:34:28 | 2021-10-30T17:34:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 495 | java | package com.hokage.persistence.dataobject;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author linyimin
* @date 2020/7/26 10:23 pm
* @email [email protected]
* @description supervisor and server relationship
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class HokageSupervisorServerDO extends HokageBaseDO {
private Long id;
/**
* supervisor id
*/
private Long supervisorId;
/**
* server id
*/
private Long serverId;
}
| [
"[email protected]"
]
| |
83aff90fa6978f808d944ec78604bff5ec048456 | a4e17e09b409338c7b36e37335a78467a20d9fe4 | /cadastro-ajs-server/src/main/java/com/cadastro/security/PlainTextBasicAuthenticationEntryPoint.java | f6655241272e9b1e61938188ddedb9f414fcd3aa | []
| no_license | cnbatalha/cadastro_simples_angularjs | 93948f61ffcfc5dedd09500989aae84851497380 | 5c9535d2d0cb7a33aa3e7308332ad16a997d0a47 | refs/heads/master | 2021-01-15T23:11:46.358183 | 2017-04-23T22:42:23 | 2017-04-23T22:42:23 | 30,705,702 | 0 | 0 | null | 2015-03-09T13:54:34 | 2015-02-12T14:19:51 | Java | UTF-8 | Java | false | false | 2,118 | java | package com.cadastro.security;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
import org.springframework.security.web.util.matcher.ELRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
public class PlainTextBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
private static final RequestMatcher requestMatcher = new ELRequestMatcher(
"hasHeader('X-Requested-With','XMLHttpRequest')");
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
throws IOException, ServletException {
response.setHeader("Accept", "application/json");
response.addHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers",
"Origin, x-requested-with, Content-Type, Accept, Authorization, crossdomain");
response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\"");
if (isPreflight(request)) {
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
} else if (isRestRequest(request)) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
PrintWriter writer = response.getWriter();
writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage());
} else {
super.commence(request, response, authException);
}
}
protected boolean isRestRequest(HttpServletRequest request) {
return requestMatcher.matches(request);
}
private boolean isPreflight(HttpServletRequest request) {
return "OPTIONS".equals(request.getMethod());
}
}
| [
"[email protected]"
]
| |
56d5f3c38f5a25a03ed8ddc8a45959c923c626cc | c4d71378e7767cff95b10374f89e8c3642095620 | /src/ru/fizteh/fivt/students/ermolenko/filemap/FileMapState.java | e48a3d1d5a175638b21de5648088f5b50f0f44c2 | []
| no_license | KochetovNicolai/fizteh-java-2013 | 3131cc13add8abcd8801a349127271fd6e3f5387 | 37e12018bd1281437048709ad58edf4df78aa110 | refs/heads/master | 2020-04-06T03:44:10.025788 | 2013-12-26T12:16:49 | 2013-12-26T12:16:49 | 12,932,409 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 588 | java | package ru.fizteh.fivt.students.ermolenko.filemap;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class FileMapState {
private Map<String, String> dataBase;
private File dataFile;
public FileMapState(File currentFile) {
dataBase = new HashMap<String, String>();
dataFile = currentFile;
}
public Map<String, String> getDataBase() {
return dataBase;
}
public File getDataFile() {
return dataFile;
}
public void setDataBase(Map<String, String> map) {
dataBase = map;
}
}
| [
"[email protected]"
]
| |
4ede40f10f2657fed099439633d46b66cc896e2d | 91a5440988ecbc906a0b749941f61be3e6015f90 | /src/main/java/com/diego/dao/ProductosDAOImple.java | 9842a5ca9a42a0a0a5a10c21dcb5bcd26614e2a8 | []
| no_license | DiegoMunnizVelazquez/Prueba | 2904de96c7d2b172f43f50b32867f03d64ad3872 | c420cbe46d6c37fe489a9f1f2ccb243a1dae1019 | refs/heads/master | 2021-01-12T06:51:43.533526 | 2016-12-19T09:48:59 | 2016-12-19T09:48:59 | 76,847,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,747 | java | package com.diego.dao;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.diego.dao.ProductosDAO;
import com.diego.modelo.Producto;
@Repository
public class ProductosDAOImple implements ProductosDAO {
@Autowired
private SessionFactory sessionFactory;
public ProductosDAOImple() {
}
public ProductosDAOImple(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Transactional
public List<Producto> list() {
// TODO Auto-generated method stub
@SuppressWarnings("unchecked")
List<Producto> listProducto = (List<Producto>) sessionFactory.getCurrentSession()
.createCriteria(Producto.class)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
return listProducto;
}
@Transactional
public Producto get(int id) {
String hql = "from Producto where id=" + id;
Query query = sessionFactory.getCurrentSession().createQuery(hql);
@SuppressWarnings("unchecked")
List<Producto> listUser = (List<Producto>) query.list();
if (listUser != null && !listUser.isEmpty()) {
return listUser.get(0);
}
return null;
}
@Transactional
public void saveOrUpdate(Producto producto) {
// TODO Auto-generated method stub
sessionFactory.getCurrentSession().saveOrUpdate(producto);
}
@Transactional
public void delete(int id) {
// TODO Auto-generated method stub
Producto productoToDelete = new Producto();
productoToDelete.setId(id);
sessionFactory.getCurrentSession().delete(productoToDelete);
}
}
| [
"[email protected]"
]
| |
86fa978d4a1bf913e5680c6303b177126deca48c | eb648935d936012781f238edbc1b2d5518673e8d | /src/main/java/com/mycompany/padraoprojetostrategyboletosbancarios/Main.java | cc99ecd8ca64f731d26cf9f3b3c1242ff26ac98a | []
| no_license | LidianeMarques/PadraoProjetoStrategyBoletosBancarios | 04abf8d47d4a3e7ba53f69bb44029f784edfa0f5 | 24b3dd0d498ae62acc51af401b11e508b2e5b98c | refs/heads/master | 2022-12-31T14:00:54.987107 | 2020-10-07T01:27:10 | 2020-10-07T01:27:10 | 301,895,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,368 | java | /*
* Implementação do Retorno Boleto
A seção 1.5.1 do material disponível aqui apresenta o problema de leitura de
arquivos de retorno de boletos bancários, que podemos utilizar o padrão Strategy
para resolver. Lá é descrito o problema e fornecido um diagrama. Relacione este
diagrama concreto com o diagrama teórico do padrão e assim implemente uma aplicação
console em Java que aplica o padrão Strategy e faça a leitura de arquivos para o
Banco do Brasil e Bradesco.
Em anexo são fornecidos dois arquivos de retorno de exemplo para tais bancos,
para utilizar na implementação. A implementação do Banco do Brasil já está pronta no GitHub,
mas se você apenas olhar tal implementação antes de fazer a sua., não aprenderá nada com isso.
*/
package com.mycompany.padraoprojetostrategyboletosbancarios;
/**
*
* @author Lidiane
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ProcessarBoletos processarBoletos = new ProcessarBoletos();
processarBoletos.processar("banco-brasil-1.csv");
System.out.println("===================================================");
processarBoletos.processar("bradesco-1.csv");
}
}
| [
"[email protected]"
]
| |
a01dbad59cfac48d7b37b0536b0c352e29b17df9 | 5fdf9b5fd12613815075da0f260a7c5180dd3eac | /src/com/wei/test/encrypt/EncryptHelper.java | a2afa138fff7fde3eb9512c0845965818d925a3e | []
| no_license | whtmlb/diligence | 3731f2c8300c99fab0b665bcdb351fdc01028e35 | 3c6147a74f863205029364feeb6ffef040cc7524 | refs/heads/master | 2020-06-02T20:17:36.189854 | 2013-06-28T02:08:16 | 2013-06-28T02:08:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,445 | java | package com.wei.test.encrypt;
import java.security.MessageDigest;
import com.google.common.io.BaseEncoding;
/**
* 加密帮助类
* <p>
* 目前支持的编码类型 base64
* <p>
* 目前支持的加密算法类型
* <ul>
* <li>MD5</li>
* <li>SHA-1</li>
* <li>SHA-256</li>
* </ul>
*
* @author weichao
*
*/
public class EncryptHelper {
/**
* BASE64编码
*
* @param key 字节码
* @return 编码后的字符串
*/
public static String base64Encoder(byte[] key) {
return BaseEncoding.base64().encode(key);
}
/**
* BASE64解码
*
* @param key BASE64编码后的字符串
* @return 字节码
*/
public static byte[] base64Decoder(String key) {
return BaseEncoding.base64().decode(key);
}
/**
* MD5加密
*
* @param key 需要加密的字符串,默认用UFT-8编码取其字节码
* @return 加密后的字节码
*/
public static byte[] encryptMD5(String key) {
return encrypt(EncryptType.ENCRYPT_TYPE_MD5, key);
}
/**
* MD5加密后再进行base64编码
*
* @param key 明文
* @return 密文
*/
public static String encryptMD5_BASE64(String key) {
return base64Encoder(encryptMD5(key));
}
/**
* SHA1加密
*
* @param key 需要加密的字符串,默认用UFT-8编码取其字节码
* @return 加密后的字节码
*/
public static byte[] encryptSHA1(String key) {
return encrypt(EncryptType.ENCRYPT_TYPE_SHA1, key);
}
/**
* SHA1加密后再进行base64编码
*
* @param key 明文
* @return 密文
*/
public static String encryptSHA1_BASE64(String key) {
return base64Encoder(encryptSHA1(key));
}
/**
* SHA-256加密
*
* @param key 需要加密的字符串,默认用UFT-8编码取其字节码
* @return 加密后的字节码
*/
public static byte[] encryptSHA256(String key) {
return encrypt(EncryptType.ENCRYPT_TYPE_SHA256, key);
}
/**
* SHA-256加密后再进行base64编码
*
* @param key 明文
* @return 密文
*/
public static String encryptSHA256_BASE64(String key) {
return base64Encoder(encryptSHA256(key));
}
/**
* 按照给定的加密算法来加密明文
*
* @param alogrithm 加密算法
* @param key 明文
* @return 加密后的字节码
*/
public static byte[] encrypt(EncryptType alogrithm, String key) {
try {
MessageDigest sha = MessageDigest.getInstance(alogrithm.algorithm);
sha.update(key.getBytes("UTF-8"));
return sha.digest();
} catch (Exception e) {
throw new RuntimeException("加密出错", e);
}
}
public enum EncryptType {
ENCRYPT_TYPE_SHA1("SHA-1"),
ENCRYPT_TYPE_SHA256("SHA-256"),
ENCRYPT_TYPE_MD5("MD5");
private String algorithm;
private EncryptType(String algorithm) {
this.algorithm = algorithm;
}
public String algorithm() {
return this.algorithm;
}
}
}
| [
"[email protected]"
]
| |
70dab6ff26687b8cd86228d7f1c033da1b1da735 | 24e11886ce3d3b545c78d5a0bc544103e7f0bdef | /ColetorADS-B/app/src/main/java/br/ufc/si/coletor/coletorads_b/dialogs/DialogInfoMensagem.java | 2180ac86dd11b55ec5fbeece2e1b851645a8c22b | []
| no_license | guilhermeestevao/Coletor-MicroADS-B-Android | ce5346d227fbe3af2fec28e94b47f109dba4dd9e | b2e894eea8a1ae901f5fd4132ad3863a564fe789 | refs/heads/master | 2021-01-19T02:15:49.910584 | 2016-07-01T00:46:22 | 2016-07-01T00:46:22 | 34,332,599 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,474 | java | package br.ufc.si.coletor.coletorads_b.dialogs;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import java.util.Map;
import java.util.Set;
import br.ufc.si.coletor.coletorads_b.R;
/**
* Created by guilherme on 02/09/15.
*/
public class DialogInfoMensagem extends DialogFragment {
private Map<String, String> infos;
public static DialogInfoMensagem newInstance(Map<String, String> data){
DialogInfoMensagem frag = new DialogInfoMensagem();
frag.infos = data;
return frag;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.layout_message_decoded, null);
TextView data = (TextView) view.findViewById(R.id.decoded_message);
Set<String> keys = infos.keySet();
StringBuilder string = new StringBuilder();
for (String key : keys){
string.append(infos.get(key)+"\n");
}
data.setText(string);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(view);
return builder.create();
}
}
| [
"[email protected]"
]
| |
068468e0333f7e3c8744eb31759c9ffcab09fa76 | 0e79551282e968131df1e8d763366302a42feef7 | /RockStickLeaf/src/ui/UISymbol.java | 72e146d7ce8d66dbcb1136035b70ea898e8de658 | []
| no_license | Pqvqn/RockStickLeaf | 0da8d156a115794ccc86730f1bfd9296b60de56b | a0d57de961c64669c51fd71879dec54bae3dee64 | refs/heads/master | 2022-12-03T18:51:42.294653 | 2020-08-22T21:49:52 | 2020-08-22T21:49:52 | 281,225,291 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,975 | java | package ui;
import java.awt.*;
import java.awt.geom.*;
import rsl.*;
public class UISymbol extends UIElement{
private String symbol; //text to base symbol off of
private Color color_primary;
private Color color_secondary;
private int size;
public UISymbol(Game frame, int x, int y, int relativesize, String character, Color prim, Color sec) {
super(frame, x, y);
symbol = character;
xPos = x;
yPos = y;
color_primary = prim;
color_secondary = sec;
size = relativesize;
}
public String getSymbol() {return symbol;}
public void setSymbol(String symbol) {this.symbol = symbol;}
//public Color getColor() {return color;}
//public void setColor(Color color) {this.color = color;}
public void paint(Graphics g) {
g.setColor(color_primary);
Graphics2D g2 = (Graphics2D)g;
AffineTransform origt = g2.getTransform(); //transformation to reset to
if(symbol.equals("v") || symbol.equals("<") || symbol.equals(">") || symbol.equals("^") || symbol.equals("_") || symbol.equals("O")){ //for arrows
g.setColor(color_secondary); //draw arrow
g2.rotate(Math.PI/4,xPos,yPos);
g2.drawRect(xPos-size/2, yPos-size/2, size, size); //draw outline behind arrow
g.setColor(color_primary);
switch(symbol) { //rotate depending on arrow needed
case "v":
g2.rotate(Math.PI,xPos,yPos);
break;
case "<":
g2.rotate(3*Math.PI/2,xPos,yPos);
break;
case ">":
g2.rotate(Math.PI/2,xPos,yPos);
break;
case "^":
//g2.rotate(0,xPos,yPos);
break;
case "_":
break;
case "O":
g2.fillRect(xPos-size/2,yPos-size/2,size,size/3); //draw top half
g2.fillRect(xPos-size/2,yPos-size/2,size/3,size); //flip to bottom half
g2.rotate(Math.PI,xPos,yPos);
break;
}
if(!symbol.equals("_")) { //_ for blank
g2.fillRect(xPos-size/2,yPos-size/2,size,size/3); //draw rectangles for arrow
g2.fillRect(xPos-size/2,yPos-size/2,size/3,size);
}
}
g2.setTransform(origt);
}
}
| [
"[email protected]"
]
| |
fe7e2fdbf99fe8e1935f9d0ec4f975471b10ee57 | f3463e2d7e6f01addd7f9bf0070982ed7491f4f4 | /Longest Consecutive Sequence.java | 6672e25aa43b1660d73a9e4496825041dd2725d7 | []
| no_license | abhisahugm007/Competitive-Program | 16673e140d3320640eadf1a6c00e5344014b620c | e24d78d3e7c9cbbf2d704698b5dd806722af14ce | refs/heads/main | 2023-08-18T23:00:13.513046 | 2021-09-25T03:18:15 | 2021-09-25T03:18:15 | 407,128,887 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | class Solution {
public int longestConsecutive(int[] nums) {
if(nums.length==0)
return 0;
Arrays.sort(nums);
int max=1,len=1;
int pre=nums[0];
for(int i=1;i<nums.length;i++)
{
if(pre!=nums[i])
{
if(pre+1==nums[i])
{
len++;
if(max<len)
max=len;
}
else{
len=1;
}
pre=nums[i];
}
}
return max;
}
}
| [
"[email protected]"
]
| |
85aa25505bee0deb609f2e439046092b8521c44b | 2d457458dd264063b5f2d65f05c944fee0f7d4ed | /67.Add Binary/Solution.java | 1d96ca316325504e4924bcb96c2632caa58e829f | []
| no_license | xcool-rabbit/leetcode | 3bf8fa2c2ac25c22a3d459de4ddd5d285337c6ae | c21d182603c30dafa502c13bcdafa237e035be19 | refs/heads/master | 2022-05-28T12:47:36.342744 | 2022-05-27T06:37:43 | 2022-05-27T06:37:43 | 147,366,119 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,084 | java | //67. 二进制求和
/*
题目很简单,倒着一位一位的加,有进位的标记一下,注意最后答案可能会比两个数都长1位,所以不要忘记循环退出之后的进位。
但是很诡异的是,我用时超长,看了一下,不是思维上的问题。别人做这道题用的charAt,倒着遍历。我用的入栈。性能上有一些差距,思路上是没问题的,所以不打算改了,没意义。
执行用时:15 ms 已经战胜 7.39 % 的 java 提交记录
*/
import java.util.Stack;
class Solution {
public String addBinary(String a, String b) {
char[] aChars = a.toCharArray();
char[] bChars = b.toCharArray();
Stack<Integer> aStack = new Stack<>();
for (char c : aChars) {
aStack.push(Integer.parseInt(String.valueOf(c)));
}
Stack<Integer> bStack = new Stack<>();
for (char c : bChars) {
bStack.push(Integer.parseInt(String.valueOf(c)));
}
Stack<Integer> answer = new Stack<>();
Boolean forward = false;
int sum = 0;
while (!(aStack.empty() && bStack.empty())) {
int aPop = 0;
int bPop = 0;
sum = forward ? 1 : 0;
if (!aStack.empty()) {
aPop = aStack.pop();
}
if (!bStack.empty()) {
bPop = bStack.pop();
}
sum = sum + aPop + bPop;
forward = sum > 1;
answer.push(sum % 2);
}
if (forward) {
answer.push(1);
}
StringBuffer answerStr = new StringBuffer();
while (!answer.empty()) {
answerStr.append(answer.pop());
}
return answerStr.toString();
}
}
/*
同LCOFII-2
现在写的那叫一个赏心悦目
看之前写的,是啥啊
执行用时:1 ms, 在所有 Java 提交中击败了99.95%的用户
*/
class Solution {
public String addBinary(String a, String b) {
if (a.length() < b.length()) {
return addBinary(b, a);
}
// a > b
int aLen = a.length();
int bLen = b.length();
char extra = '0';
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= aLen; i++) {
char ac = a.charAt(aLen - i);
char bc = bLen - i >= 0 ? b.charAt(bLen - i) : '0';
int count = 0;
if (ac == '1') {
count++;
}
if (bc == '1') {
count++;
}
if (extra == '1') {
count++;
}
if ((count & 1) == 1) {
sb.insert(0, '1');
} else {
sb.insert(0, '0');
}
if (count >= 2) {
extra = '1';
} else {
extra = '0';
}
}
if (extra == '1') {
sb.insert(0, '1');
}
return sb.toString();
}
}
| [
"[email protected]"
]
| |
bd2d386d75a0ef6a2ddeb93a8597f0b495ccc17c | 22a31925d44c2104fb939d760e444d532a7f5e9c | /listacompras-master/ListaCompras/src/controller/ClienteDAO.java | d5358822b0960d9713fa0b37a486d2647ab28b6f | []
| no_license | LaDeSP/listacompras | 90b12b60ca45953f78988ea010c3bb886044a853 | 40c590dfb332aa667a74b9270830e4f1f9ff7f8c | refs/heads/master | 2021-01-20T07:56:31.571881 | 2017-08-07T19:58:26 | 2017-08-07T19:58:26 | 90,067,476 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,081 | java | package controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import modelo.Cliente;
import view.ViewListarPromocoes;
public class ClienteDAO extends DAO{
private static List<Cliente> listadeclientes = new ArrayList<Cliente>();
Cliente cliente = null; //provavelmente deve ser excluída
static Scanner leitura = new Scanner(System.in);
/**
*
* @param nome Nome do Cliente
* @param email E-mail do Cliente
* @param senha Senha do Cliente
* @return True se cadastro foi realizado, False se cadastro do cliente não foi executado
* @throws Exception
*/
public static boolean criarCliente(String nome, String email, String senha) throws Exception{
//provavelmente deve ter uma validação dos dados
while(!DAO.ValidarEmail(email))
{
System.out.println("Erro no E-mail!!");
System.out.print("Novo email: ");
email = leitura.nextLine();
System.out.print("\n");
}
while(!DAO.ValidarSenha(senha))
{
System.out.println("Senha muito pequena!!");
System.out.print("Novo senha: ");
senha = leitura.nextLine();
System.out.print("\n");
}
senha = MD5.criptografar(senha);
Cliente cliente = new Cliente(nome, senha, email);
ClienteDAO.listadeclientes.add(cliente);
return true;
}
public static void Escrever()
{
DAO.Escrever(Constantes.ClienteDs, listadeclientes);
}
public static boolean lerArquivo() throws ClassNotFoundException
{
listadeclientes = (List<Cliente>) DAO.Ler(Constantes.ClienteDs, listadeclientes);
return true;
}
public static void listar()
{
for(Cliente cliente : listadeclientes)
{
cliente.show();
}
}
public static boolean OKCliente(String Nome)
{
for(Cliente cliente : listadeclientes)
{
if(Nome.equals(cliente.getNome()))
{
return true;
}
}
return false;
}
public static Cliente GetCliente(String Nome)
{
for(Cliente cliente : listadeclientes)
{
if(Nome.equals(cliente.getNome()))
{
return cliente;
}
}
return null;
}
public static Cliente GetCliente(int id)
{
for(Cliente cliente : listadeclientes)
{
if(id == cliente.getId())
{
return cliente;
}
}
return null;
}
public static void RemoverCliente(int id)
{
for(Cliente cliente : listadeclientes)
{
if(id == cliente.getId())
{
ClienteDAO.listadeclientes.remove(cliente);
return ;
}
}
}
public static void InserirNaLista(PromocaoDAO promocaoDAO, int id)
{
ViewListarPromocoes viewlistarpromocoes = new ViewListarPromocoes();
int i;
if(PromocaoDAO.GetPromocaoPorId(1) == null)
{
System.out.print("Não existe nenhuma promoção\n");
return ;
}
System.out.println("Nome: " +GetCliente(id).getNome());
//Listar as Promoções
viewlistarpromocoes.Show(promocaoDAO);
//Escolher a Promoção
i = leitura.nextInt();
//Inserir a promoção no Cliente
System.out.println("Nome: " +GetCliente(id).getNome()+ " Promocao: " +PromocaoDAO.GetPromocao(i).getId());
GetCliente(id).InserirNaLista( PromocaoDAO.GetPromocao(i) , id);
}
} | [
"[email protected]"
]
| |
08b0bbc69eca99450deabea85594918d55746ad1 | 0e556f980279b0beb418a5b08894f19d61d939e0 | /src/main/java/com/ibm/sample/stocktrader/portfolio/repository/PortfolioRepository.java | edfa51d76b03056e81a0342babb8517d6be29ea8 | [
"Apache-2.0"
]
| permissive | AMI-Scenario-Labs/traderlite-portfolio-spring-cp4i | 05887770dd545f4b5db6f3de9768029ab532eb48 | 2e2f717ed8362e55f52ad3f36f924fad478abc0c | refs/heads/main | 2023-01-24T13:01:39.870251 | 2020-12-07T20:44:52 | 2020-12-07T20:44:52 | 319,439,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,352 | java | /*
Copyright 2017-2019 IBM Corp All Rights Reserved
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.ibm.sample.stocktrader.portfolio.repository;
import java.util.List;
import java.util.Optional;
import com.ibm.sample.stocktrader.portfolio.model.Client;
import com.ibm.sample.stocktrader.portfolio.model.Portfolio;
import com.ibm.sample.stocktrader.portfolio.model.PortfolioUpdate;
import com.ibm.sample.stocktrader.portfolio.model.StockQuote;
/* Portfolio Repository interface */
public interface PortfolioRepository {
int save(Portfolio portfolio, Client client);
int update(Portfolio portfolio);
Optional<Portfolio> findById(int id);
Optional<Portfolio> findByClientId(String clientId);
List<Portfolio> findAll();
Optional<Portfolio> tradeEquities(PortfolioUpdate update, List<StockQuote>quotes);
}
| [
"[email protected]"
]
| |
41f4fbed58cd2f3035119017b9a24d5badc2a542 | bb2c828eb21e12d470752ebe174c35f1a34e1c66 | /chuyue-common/src/main/java/com/chuyue/common/enums/UserStatus.java | d534f77e2e8f69a5dcd837b917c1514c85ba4f32 | [
"MIT"
]
| permissive | yujiantong/ChuYue | b3a8821181b4c879ed45627fd574b2d6d86bcae4 | b53d831da5ac8451333044bebd6b3853f9cc3f09 | refs/heads/master | 2022-09-24T20:28:56.952389 | 2020-12-28T05:11:26 | 2020-12-28T05:11:26 | 214,371,898 | 1 | 0 | MIT | 2022-09-01T23:13:56 | 2019-10-11T07:28:27 | HTML | UTF-8 | Java | false | false | 471 | java | package com.chuyue.common.enums;
/**
* 用户状态
*
* @author chuyue
*/
public enum UserStatus
{
OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
private final String code;
private final String info;
UserStatus(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}
| [
"[email protected]"
]
| |
132453833713ec3edbef215a760549ad64c2040a | e2f6149889f2f71f36bd1fa1dd5252ab63ea01b0 | /app/src/main/java/com/example/incomplete/trainingtest/grneric/ChangedParam.java | ade8644fdb10ff336955f4be3d25c502b3d6e75e | []
| no_license | y449756770/TrainTest | b8c69ed4d3b15ef6401047d0acf58dd2b496ba49 | 8f5b0e1adb25bc486d3a33fb593605bd15e91bdd | refs/heads/master | 2021-01-22T10:46:47.577198 | 2018-08-02T01:12:28 | 2018-08-02T01:12:28 | 92,654,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 243 | java | package com.example.incomplete.trainingtest.grneric;
/**
* Created by incomplete on 17/4/26.
* 可变参数的参数列表其实就是数组
*/
public class ChangedParam {
public void change(int... arr) {
arr[0] = 1;
}
}
| [
"[email protected]"
]
| |
e5f3242697f1387ef48e057c6e1a80f02710e686 | dcecbc089153a7bb2b96aebb1867c35474478ece | /app/src/main/java/com/feiyou/headstyle/bean/CollectWrapper.java | c5def736b6c8a4e8e623ce4e50a2ca7cd475eacf | []
| no_license | djp0507/newheadstyle | d77396af1876b617c4722cb588bca7ef43a0ca7f | 4cccf90d2226947e39acf459c3b73ff3681251eb | refs/heads/master | 2020-04-25T03:54:20.668498 | 2019-02-25T10:31:32 | 2019-02-25T10:31:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 486 | java | package com.feiyou.headstyle.bean;
import java.util.List;
/**
* Created by myflying on 2018/12/29.
*/
public class CollectWrapper{
private CollectInfo info;
private List<HeadInfo> list;
public CollectInfo getInfo() {
return info;
}
public void setInfo(CollectInfo info) {
this.info = info;
}
public List<HeadInfo> getList() {
return list;
}
public void setList(List<HeadInfo> list) {
this.list = list;
}
}
| [
"[email protected]"
]
| |
c6067d1cccdbc1174e2d48586a50fd56f26b91b8 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /schedulerx2-20190430/src/main/java/com/aliyun/schedulerx220190430/models/GrantPermissionResponseBody.java | 9d2af82e83e487535a824c3e8ac26d4367c154fb | [
"Apache-2.0"
]
| permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 1,777 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.schedulerx220190430.models;
import com.aliyun.tea.*;
public class GrantPermissionResponseBody extends TeaModel {
/**
* <p>The HTTP status code.</p>
*/
@NameInMap("Code")
public Integer code;
/**
* <p>The error message that is returned only if the corresponding error occurs.</p>
*/
@NameInMap("Message")
public String message;
/**
* <p>The request ID.</p>
*/
@NameInMap("RequestId")
public String requestId;
/**
* <p>Indicates whether the request was successful. Valid values:</p>
* <br>
* <p>* **true**</p>
* <p>* **false**</p>
*/
@NameInMap("Success")
public Boolean success;
public static GrantPermissionResponseBody build(java.util.Map<String, ?> map) throws Exception {
GrantPermissionResponseBody self = new GrantPermissionResponseBody();
return TeaModel.build(map, self);
}
public GrantPermissionResponseBody setCode(Integer code) {
this.code = code;
return this;
}
public Integer getCode() {
return this.code;
}
public GrantPermissionResponseBody setMessage(String message) {
this.message = message;
return this;
}
public String getMessage() {
return this.message;
}
public GrantPermissionResponseBody setRequestId(String requestId) {
this.requestId = requestId;
return this;
}
public String getRequestId() {
return this.requestId;
}
public GrantPermissionResponseBody setSuccess(Boolean success) {
this.success = success;
return this;
}
public Boolean getSuccess() {
return this.success;
}
}
| [
"[email protected]"
]
| |
cf7167c684050be4b2dcd974f6e7e9c3bb4b5da5 | fffa7bfa74d9753b14100173d2093b718ada7a7d | /online-exam-tools/src/main/java/edu/sandau/dao/SysEnumDao.java | 301c785bdeced085172d0e19d7209a66bc766516 | []
| no_license | iiSee/online-exam-backend | dc83f06524ba432d13736e40998181c84a421875 | 3d43f2f86362d204ac12ca3850e2d70019bde39c | refs/heads/master | 2021-01-08T01:55:56.182498 | 2020-02-20T07:38:25 | 2020-02-20T07:38:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,412 | java | package edu.sandau.dao;
import edu.sandau.entity.SysEnum;
import edu.sandau.rest.model.Page;
import edu.sandau.utils.MapUtil;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Repository
public class SysEnumDao {
@Autowired
private JdbcTemplate jdbcTemplate;
public SysEnum save(SysEnum sysEnum) {
String sql = " INSERT INTO sys_enum " +
"( catalog, type, name, value, description ) VALUES " +
"( ?, ?, ?, ?, ? )";
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(conn -> {
PreparedStatement ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, sysEnum.getCatalog());
ps.setString(2, sysEnum.getType());
ps.setString(3, sysEnum.getName());
ps.setInt(4, sysEnum.getValue());
ps.setString(5, sysEnum.getDescription());
return ps;
}, keyHolder);
int keyId = Objects.requireNonNull(keyHolder.getKey()).intValue();
sysEnum.setId(keyId);
return sysEnum;
}
/***
* 通过模块和类型获取所有枚举
* @param catalog
* @param type
* @return
*/
public List<Map<String, Object>> getEnumMap(String catalog, String type) {
String sql = " SELECT name, value FROM sys_enum WHERE catalog = ? AND type = ? ";
return jdbcTemplate.queryForList(sql, new Object[]{catalog, type});
}
public List<SysEnum> getEnums(String catalog, String type) {
List<Map<String, Object>> params = this.getEnumMap(catalog, type);
return (List) MapUtil.mapToObject(params, SysEnum.class);
}
/***
* 通过 模块,类型,整型值 获得枚举
* @param catalog
* @param type
* @param value
* @return
*/
public SysEnum getEnum(String catalog, String type, Integer value) {
String sql = " SELECT * FROM sys_enum WHERE catalog = ? AND type = ? AND value = ? ";
Map<String, Object> param = jdbcTemplate.queryForMap(sql, new Object[]{catalog, type, value});
return (SysEnum) MapUtil.mapToObject(param, SysEnum.class);
}
public Integer getEnumValue(String catalog, String type, String name) {
String sql = " SELECT value FROM sys_enum WHERE catalog = ? AND type = ? AND name = ? ";
Map<String, Object> param = jdbcTemplate.queryForMap(sql, new Object[]{catalog, type, name});
return MapUtils.getInteger(param, "value");
}
public String getEnumName(String catalog, String type, Integer value) {
String sql = " SELECT name FROM sys_enum WHERE catalog = ? AND type = ? AND value = ? ";
Map<String, Object> param = jdbcTemplate.queryForMap(sql, new Object[]{catalog, type, value});
return MapUtils.getString(param, "name");
}
public SysEnum getEnumById(Integer id) {
String sql = " SELECT * FROM sys_enum WHERE id = ? ";
Map<String, Object> param = jdbcTemplate.queryForMap(sql, new Object[]{id});
return (SysEnum) MapUtil.mapToObject(param, SysEnum.class);
}
public Integer updateEnum(SysEnum sysEnum) {
String sql = " UPDATE sys_enum " +
" SET catalog = ?, name = ?, type = ?, value = ?, description = ? " +
" WHERE id = ? ";
Object[] param = new Object[5];
param[0] = sysEnum.getCatalog();
param[1] = sysEnum.getName();
param[2] = sysEnum.getType();
param[3] = sysEnum.getValue();
param[4] = sysEnum.getDescription();
return jdbcTemplate.update(sql, param);
}
public Integer deleteEnum(SysEnum sysEnum) {
String sql = " DELETE FROM sys_enum WHERE catalog = ? AND name = ? AND type = ? AND value = ? ";
Object[] objects = new Object[4];
objects[0] = sysEnum.getCatalog();
objects[1] = sysEnum.getName();
objects[2] = sysEnum.getType();
objects[3] = sysEnum.getValue();
return jdbcTemplate.update(sql, objects);
}
public Integer deleteEnumById(Integer id) {
String sql = " DELETE FROM sys_enum WHERE id = ? ";
return jdbcTemplate.update(sql, new Object[]{id});
}
public List<SysEnum> listAllEnum() {
String sql = " SELECT * FROM sys_enum ORDER by id ASC ";
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
return (List) MapUtil.mapToObject(mapList, SysEnum.class);
}
public List<SysEnum> listEnumByPage(Page page) {
int start = (page.getPageNo() - 1) * page.getPageSize();
String sql = " SELECT * FROM sys_enum ORDER by id ASC limit ? , ? ";
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, new Object[]{start, page.getPageSize()});
return (List) MapUtil.mapToObject(mapList, SysEnum.class);
}
public Integer getCount() {
String sql = " SELECT COUNT(1) FROM sys_enum ";
return jdbcTemplate.queryForObject(sql, Integer.class);
}
}
| [
"[email protected]"
]
| |
731067b12902ade648f7ceeb993274fedd5e31f2 | be8db70111b0ede8c270416b3f271ae9789fc98e | /src/ru/korovko/patterns/behavioral/command/Main.java | 75d5e1ecb65a31da7d9fc85062dac2fe932ecfd9 | []
| no_license | whorules/design-patterns | 7f0a7e91be3cd02137c4216c9be24fc5d57d7d9f | 7fecc4da37b8f0b2060af0819bcf2c7059b584fe | refs/heads/master | 2023-02-14T03:21:59.267181 | 2021-01-08T12:17:45 | 2021-01-08T12:17:45 | 325,996,728 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 968 | java | package ru.korovko.patterns.behavioral.command;
import ru.korovko.patterns.behavioral.command.execution.CancelPaymentCommand;
import ru.korovko.patterns.behavioral.command.execution.Command;
import ru.korovko.patterns.behavioral.command.execution.PayCommand;
import ru.korovko.patterns.behavioral.command.payment.CardPayment;
import ru.korovko.patterns.behavioral.command.payment.CashPayment;
import ru.korovko.patterns.behavioral.command.payment.OnlineWalletPayment;
import ru.korovko.patterns.behavioral.command.payment.Payment;
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Payment> payments = List.of(new CardPayment(), new CashPayment(), new OnlineWalletPayment());
Command paymentCommand = new PayCommand();
payments.forEach(paymentCommand::execute);
Command cancelPaymentsCommand = new CancelPaymentCommand();
payments.forEach(cancelPaymentsCommand::execute);
}
}
| [
"[email protected]"
]
| |
0084baa2b75df7ec1ad0685f9bb9f26227483082 | 46ef30823bcea5e01e26e754ca807ecc350a4dfb | /app/src/main/java/com/example/vegetablesfruit/ContentData.java | 3a3558f2ae0b89d2a7a28528c1b2fe60ec15ed96 | []
| no_license | hema2019-am/VegetableAndFruit | 2290ecdc371aef54fbba440cd087ca8a66ae688f | bbf5773dd9f849d1ae96f4114ff998930ce6a426 | refs/heads/main | 2023-01-12T20:55:47.654926 | 2020-11-11T09:41:25 | 2020-11-11T09:41:25 | 311,310,409 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 913 | java | package com.example.vegetablesfruit;
public class ContentData {
public String Name,image, price, quantity;
public ContentData(){}
public ContentData(String Name, String image, String prices, String quantity) {
this.Name = Name;
this.image = image;
this.price = prices;
this.quantity = quantity;
}
public String getNamess() {
return Name;
}
public void setNames(String name) {
Name = name;
}
public String getImages() {
return image;
}
public void setImages(String image) {
this.image = image;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
}
| [
"[email protected]"
]
| |
d0a8e3e8a33f5585e7f9274cdad1255d706aeb5e | 5cc8267b2603db584b215e62b540bfef451becc7 | /src/BinaryTreeHelper.java | b7ac2dee7afa6ba7417699bea8d7b330904f8596 | []
| no_license | bbishop19/Whackinator | a4a9f7d9e126f76c131a8295f193954c35a99f10 | cf822d0f109265f243e40325a54b05dafd3f232e | refs/heads/master | 2020-04-25T11:59:56.314014 | 2019-03-04T16:30:43 | 2019-03-04T16:30:43 | 172,764,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 715 | java | import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Stack;
public abstract class BinaryTreeHelper {
public static String serialize(BTNode head){
return (head.getData() + ", " +
(head.getLeftChild()==null?"n, ":serialize(head.getLeftChild()))+
(head.getRightChild()==null?"n, ":serialize(head.getRightChild())));
}
public static BTNode deserialize(LinkedList<String> arr){
String s = arr.remove(0);
if(s.equals("n")){
return null;
}
BTNode head = new BTNode(null, null, s);
head.setLeftChild(deserialize(arr));
head.setRightChild(deserialize(arr));
return head;
}
}
| [
"[email protected]"
]
| |
bedb22c8384840ee3d6bece6d07f38f71aa38bf2 | f84bb152cf2147a7261c24ce8dd8361d120fbf18 | /client/src/generated/java/resources/jaxws/searchservice/uniba/de/package-info.java | 544422f92bfae46c3aae9032ef8f10183543e93d | []
| no_license | AzarguNazari/Distributed-Services | f5a90bf9388b912f4a2d9d222dbdfff6bd9bf82b | fdeb8aa65e58f0c8d672239a22c8180cabc1b825 | refs/heads/master | 2022-02-18T20:04:10.163744 | 2019-08-11T13:52:39 | 2019-08-11T13:52:39 | 195,622,278 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 139 | java | @javax.xml.bind.annotation.XmlSchema(namespace = "de.uniba.searchservice.jaxws.resources")
package resources.jaxws.searchservice.uniba.de;
| [
"[email protected]"
]
| |
7092aa5185baabcaa45c2fa49870d19527c2e00b | edee8268c98bc34297a1565d93fb2a0c80e77eb0 | /src/main/java/io/github/talelin/latticy/service/SpuImgService.java | 14569cff958039b5a88088257b544951a3847459 | [
"MIT"
]
| permissive | lhsheild/o-sleeve-backend | 86607eef326a28fbd119285fcb1b82da44bd291f | 634184d9beb5e546ed78691f95542b9bf5ab40e7 | refs/heads/main | 2023-01-25T02:02:59.017134 | 2020-11-09T16:44:32 | 2020-11-09T16:44:32 | 307,233,001 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 307 | java | package io.github.talelin.latticy.service;
import io.github.talelin.latticy.model.SpuImgDO;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author generator@TaleLin
* @since 2020-11-09
*/
public interface SpuImgService extends IService<SpuImgDO> {
}
| [
"[email protected]"
]
| |
a711049e8da2d5cf452e01b5509676c5417868c2 | ca8c7d17c1eaef1d750240f263c24dbde2412f36 | /src/Testfilestring.java | 1ede334266eb9958258e0cfbf08e6552b7b165ef | []
| no_license | catcxx/MyTest | c0695b404dea6858518a2fa3027f39e47111135b | ac36dbac9d0b19817fb971607809c66ec0898125 | refs/heads/master | 2020-12-24T07:18:54.552001 | 2016-08-21T03:45:28 | 2016-08-21T03:45:28 | 56,847,643 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,031 | java |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.LinkedList;
public class Testfilestring {
/*
* public static void read1() { RandomAccessFile r = null; try { r = new
* RandomAccessFile(new File("D:/1.txt"),"r"); byte[] c = new byte[4];
* r.read(c, 2, 4); System.out.println(new String(c)); } catch (Exception e)
* { try { r.close(); } catch (IOException e1) { e1.printStackTrace(); }
* e.printStackTrace(); }
*
* }
*/
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("D:\\test1.txt"));
String line = "";
String str = "";
while (((line = in.readLine()) != null)) {
str += line;
}
String[] list = str.split(" ");
System.out.println("------");
for (String s : list) {
System.out.println(s);
}
System.out.println(list.length);
// System.out.println("str=" + str);
}
}
| [
"[email protected]"
]
| |
e300855c0b62a657d6f837e40e80ba455c820f64 | 0b12e056adc9bd4b143b937e28566d2f340de3c1 | /gauryvg98-ME_BUILDOUT_QA/buildout/src/main/java/com/crio/buildout/services/QuizServiceImpl.java | 849457e3bca676fb1515d4bb8bbef9f3de9ee101 | []
| no_license | gauryvg98/QuizApiForCrio | 01d3b158bf68170d169982c66617c0c28a1c1456 | 4f23f788e69a1259321e07fc3be918aa68413c3e | refs/heads/master | 2022-12-18T01:24:26.157092 | 2020-09-25T17:23:04 | 2020-09-25T17:23:04 | 298,381,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,935 | java | package com.crio.buildout.services;
import com.crio.buildout.dto.Question;
import com.crio.buildout.dto.QuestionAnswer;
import com.crio.buildout.dto.UserResponse;
import com.crio.buildout.exchange.GetQuestionRequest;
import com.crio.buildout.exchange.GetQuestionResponse;
import com.crio.buildout.exchange.PostQuestionRequest;
import com.crio.buildout.exchange.PostQuestionResponse;
import com.crio.buildout.repository.QuizRepositoryService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class QuizServiceImpl implements QuizService {
@Autowired
QuizRepositoryService quizRepositoryService;
@Override
public GetQuestionResponse getQuestions(GetQuestionRequest getRequest) {
System.out.println("GET Service called here! Request : " + getRequest.getModuleId());
List<Question> questionList = quizRepositoryService.getQuestionListFromDb(getRequest.getModuleId());
return (questionList.isEmpty()) ? new GetQuestionResponse() : new GetQuestionResponse(questionList);
}
@Override
public PostQuestionResponse postResponse(PostQuestionRequest postRequest) {
System.out.println("POST Service called here!");
// System.out.println(postRequest.toString());
List<QuestionAnswer> listOfQuestions = quizRepositoryService.getQuestionAnswerListFromDb(
postRequest.getModuleId());
if(listOfQuestions.isEmpty()) {
return new PostQuestionResponse();
}
Integer countOfCorrect = 0;
Map<String,List<String>> userResponseMap = new HashMap<String,List<String>>();
List<UserResponse> listResponse = postRequest.getResponses();
//mapping the userReponses to their corresponding questionIds
listResponse.forEach(resp -> {
userResponseMap.put(resp.getQuestionId(),resp.getUserResponse());
});
//checking whether userResponse is correct and alloting scores and boolean
for (QuestionAnswer question : listOfQuestions) {
//if client mysteriously sends answers for a questionId which doesnt exist in
//the question list, return null and throw bad request in controller
if (!userResponseMap.containsKey(question.getQuestionId())) {
return new PostQuestionResponse();
}
if (userResponseMap.get(question.getQuestionId()).equals(question.getCorrect())) {
countOfCorrect++;
question.setAnswerCorrect(true);
} else {
question.setAnswerCorrect(false);
}
question.setUserAnswer(userResponseMap.get(question.getQuestionId()));
}
Integer totalCount = postRequest.getResponses().size();
Map<String,Integer> mp = new HashMap<String,Integer>();
mp.put("score", countOfCorrect);
mp.put("total", totalCount);
return new PostQuestionResponse(listOfQuestions,mp);
}
} | [
"[email protected]"
]
| |
beae0fc769b6180472b19ebb7bafcc3072dba910 | 0b41ab5815dd677eb661bd8ff3253755d6a87e85 | /src/test/java/gradle_spring_webmvc_study/config/ContextDataSourceTest.java | e3cfaa08119aa7683dd2a9ae1ff91bef637ea8ab | []
| no_license | Yoonwonju/gradle_spring_webmvc_study | 745366577629877dab26fb7beff666d9ac7c5c96 | 5e413011316a548fe96fa4192c53264529a59b62 | refs/heads/master | 2023-01-02T17:10:56.069665 | 2020-10-22T03:16:31 | 2020-10-22T03:16:31 | 305,267,408 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,161 | java | package gradle_spring_webmvc_study.config;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ControllerConfig.class })
public class ContextDataSourceTest {
protected static final Log log = LogFactory.getLog(ContextDataSourceTest.class);
@After
public void tearDown() throws Exception {
System.out.println();
}
@Autowired
private DataSource dataSource;
@Test
public void testDataSource() throws SQLException {
log.debug(Thread.currentThread().getStackTrace()[1].getMethodName() + "()");
log.debug("DataSource " + dataSource);
log.debug("LoginTimeout " + dataSource.getLoginTimeout());
Assert.assertNotNull(dataSource);
}
}
| [
"[email protected]"
]
| |
567b5e2c4c87f0c245cff690f53b86e1e8ae007c | f4af8ae6bfe1269fafdfbea89c6c2a99bc8869c9 | /Exercise_03_06.java | 494ccd354a143b4d7e2972021217c399839c5ff5 | []
| no_license | ceydaucar/Chapter3 | b4024034c43b6cafd56702ea5cec88366b182a03 | c59298b39e21d4c96945d3aad48b97ecd07b8583 | refs/heads/main | 2023-08-26T09:06:35.365511 | 2021-11-08T17:52:55 | 2021-11-08T17:52:55 | 425,899,417 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,055 | java | import java.util.*;
public class Exercise_03_06 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Enter weight in pounds: ");
double weight = sc.nextDouble();
System.out.println("Enter feet: ");
double feet = sc.nextDouble();
System.out.println("Enter inches: ");
double inches = sc.nextDouble();
final double KILOGRAMS_PER_POUND = 0.45359237; // Constant
final double METERS_PER_INCH = 0.0254; // Constant
final double FEET_PER_INCH = 0.0833333; // Constant
weight *= KILOGRAMS_PER_POUND;
double height = (inches += feet / FEET_PER_INCH) * METERS_PER_INCH;
double bmi = weight / (Math.pow(height, 2));
// Display result
System.out.println("BMI is " + bmi);
if (bmi < 18.5)
System.out.println("Underweight");
else if (bmi < 25)
System.out.println("Normal");
else if (bmi < 30)
System.out.println("Overweight");
else
System.out.println("Obese");
}
}
| [
"[email protected]"
]
| |
e77f3d2a48131bf6b230c19c6708548691beb98b | 5f733d648b6b7b5f4fbac9d2f8fab3731e9160b2 | /app/src/main/java/com/github/zlfloatwindowdemo/MainActivity.java | 6633a332ae944af8a5a47c01bc2112c29732cdc2 | [
"Apache-2.0"
]
| permissive | czl0325/ZLFloatWindowDemo | 5f0d0912368f75a0cac3ff2d9d0faae6a3a0ef6a | ba19f37eec02f8349df67b80d2f18e1472f60d39 | refs/heads/master | 2020-04-07T20:00:25.291449 | 2018-11-22T09:16:00 | 2018-11-22T09:16:00 | 158,671,609 | 8 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,999 | java | package com.github.zlfloatwindowdemo;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.github.zlfloatwindow.ZLFloatWindowService;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= 23) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(intent, 10);
} else {
//TODO do something you need
showFloatWindow();
}
}
// if (Build.VERSION.SDK_INT >= 23) {
// if (!Settings.canDrawOverlays(MainActivity.this)) {
// Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
// Uri.parse("package:" + getPackageName()));
// startActivityForResult(intent,10);
// } else {
// showFloatWindow();
// }
// } else {
// showFloatWindow();
// }
}
private void showFloatWindow() {
Intent intent = new Intent(this, ZLFloatWindowService.class);
startService(intent);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 10) {
if (Build.VERSION.SDK_INT >= 23) {
if (!Settings.canDrawOverlays(this)) {
Toast.makeText(MainActivity.this,"已拒绝!",Toast.LENGTH_SHORT);
} else {
showFloatWindow();
}
}
}
}
}
| [
"[email protected]"
]
| |
6be89460dad70c9e615cce58821e1308d5e9cd0b | 4d6d51e17dde771cbcc129c394772d091abab52b | /3190 뱀/Main.java | b0e8106188f97a704899354de9106a663d91caa4 | []
| no_license | aubri61/AlgorithmBOJ | 69fcae36a07cb94f90eb8907528f9d0b5c2eb37b | ca2bbab3701b1761c2e5fd66605b66ba2a9bbb8e | refs/heads/master | 2022-11-24T22:00:38.608438 | 2020-08-04T14:21:17 | 2020-08-04T14:21:17 | null | 0 | 0 | null | null | null | null | UHC | Java | false | false | 5,907 | java | import java.util.*;
import java.io.*;
public class Main {
public static int row=0;
//public static int lastrow=0;
public static int col=0;
//public static int lastcol=0;
static int cnt=0;
//오른쪽 왼쪽 위 아래
static int[][] dir={{0,1},{0,-1},{-1,0},{1,0}};
static int rowdir=dir[0][0];
static int coldir=dir[0][1];
//static int lrowdir=dir[0][0];
//static int lcoldir=dir[0][1];
static ArrayList<int[]> snake=new ArrayList<int[]>();
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
int appleNum=Integer.parseInt(br.readLine());
snake.add(new int[]{0,0});
int[][] board=new int[n][n];
board[0][0]=2;
for (int i=0; i<appleNum; i++) {
StringTokenizer st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken());
int b=Integer.parseInt(st.nextToken());
board[a-1][b-1]=1;
}
int turn=Integer.parseInt(br.readLine());
boolean stuck=false;
//boolean finalnum=false;
for (int i=0; i<turn; i++) {
StringTokenizer st=new StringTokenizer(br.readLine());
int a=Integer.parseInt(st.nextToken());
String b=st.nextToken();
stuck=move(n,a,b,board,stuck);
if (stuck==true) {
break;
}
}
if (!stuck) {
move2(n, board);
}
}
public static void move2(int n,int[][] board) {
while(true) {
int newrow=row+rowdir;
int newcol=col+coldir;
if (0<=newrow && newrow<n && 0<=newcol && newcol<n) {
//사과 먹을 때
if (board[newrow][newcol]==1) {
board[newrow][newcol]=2;
snake.add(new int[]{newrow,newcol});
//System.out.println("to "+newrow+", "+newcol+" eating apple");
row=newrow;
col=newcol;
}
//그냥 일반적인 움직임
else if (board[newrow][newcol]==0) {
board[newrow][newcol]=2;
snake.add(new int[]{newrow,newcol});
board[snake.get(0)[0]][snake.get(0)[1]]=0;
snake.remove(0);
//System.out.println("to "+newrow+", "+newcol+" just moving");
// System.out.println("now last snake is "+snake.get(0)[0]+", "+snake.get(0)[1]+" just moving");
row=newrow;
col=newcol;
}
//내 몸에 부딪힐 때
else if (board[newrow][newcol]==2){
//stuck=true;
System.out.println(cnt+1);
// System.out.println("to "+newrow+", "+newcol+" 몸에 부딪힘");
break;
//return true;
}
cnt++;
//continue;
} else {
//stuck=true;
System.out.println(cnt+1);
//System.out.println("to "+newrow+", "+newcol+" 벽이야");
break;
//return true;
}
}
}
public static boolean move(int n,int num, String stringdir,int[][] board,boolean stuck) {
int re=num-cnt;
while(re>0) {
int newrow=row+rowdir;
int newcol=col+coldir;
if (0<=newrow && newrow<n && 0<=newcol && newcol<n) {
//사과 먹을 때
if (board[newrow][newcol]==1) {
board[newrow][newcol]=2;
snake.add(new int[]{newrow,newcol});
// System.out.println("to "+newrow+", "+newcol+" eating apple");
row=newrow;
col=newcol;
}
//그냥 일반적인 움직임
else if (board[newrow][newcol]==0) {
board[newrow][newcol]=2;
snake.add(new int[]{newrow,newcol});
board[snake.get(0)[0]][snake.get(0)[1]]=0;
snake.remove(0);
// System.out.println("to "+newrow+", "+newcol+" just moving");
// System.out.println("now last snake is "+snake.get(0)[0]+", "+snake.get(0)[1]+" just moving");
row=newrow;
col=newcol;
}
//내 몸에 부딪힐 때
else if (board[newrow][newcol]==2){
stuck=true;
System.out.println(cnt+1);
// System.out.println("to "+newrow+", "+newcol+" 몸에 부딪힘");
return true;
}
re--;
cnt++;
//continue;
} else {
stuck=true;
System.out.println(cnt+1);
// System.out.println("to "+newrow+", "+newcol+" 벽이야");
return true;
}
}
//오른쪽 왼쪽 위 아래
// static int[][] dir={{0,1},{0,-1},{-1,0},{1,0}};
if (stringdir.equals("D")) {
if(rowdir==0 && coldir==1) {rowdir=1; coldir=0;}
else if (rowdir==0 && coldir==-1) {rowdir=-1; coldir=0;}
else if (rowdir==-1 && coldir==0) {rowdir=0; coldir=1;}
else {rowdir=0; coldir=-1;}
} else {
if(rowdir==0 && coldir==1) {rowdir=-1; coldir=0;}
else if (rowdir==0 && coldir==-1) {rowdir=1; coldir=0;}
else if (rowdir==-1 && coldir==0) {rowdir=0; coldir=-1;}
else {rowdir=0; coldir=1;}
}
return false;
}
} | [
"[email protected]"
]
| |
f814a05bff89f608441f714708753eea3964f164 | 5f35305a5d61fa38d8cc089c337c40b0e24f7f58 | /Pyramid.java | 66f80d5e1dc44b5b208d3a17ee42f04cb4d6de4e | []
| no_license | shubhamjuneja11/codes | 9fe84e034d81f90b41a8bc8f378aa20932bf223c | f2c618caed5a377994ef9f0ce388eb741efa2f9c | refs/heads/master | 2020-12-02T01:01:42.601890 | 2017-01-23T17:50:26 | 2017-01-23T17:50:26 | 65,847,810 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,251 | java | import java.util.Scanner;
public class Pyramid{
static int i,j;
static void right(int n){
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
System.out.print("* ");
System.out.println();
}
}
static void right1(int n){
String s="*";
for(i=0;i<n;i++)
{System.out.println(s);s+=" *";}
}
static void pyramid(int n){
for(i=0;i<=n;i++){
for(j=0;j<=n-i-1;j++)
System.out.print(" ");
for(;j<n;j++)
System.out.print("* ");
System.out.println();
}
}
static void left(int n){
int k=2*n-2,p;
for(j=0;j<n;j++){
for(i=0;i<k;i++)
System.out.print(" ");
k-=2;
for(p=0;p<=j;p++)
System.out.print("* ");
System.out.println();
}
}
static void number(int n){
for(i=1;i<=5;i++){
for(j=1;j<=i;j++)
System.out.print(j+" ");
System.out.println();
}
}
static void number2(int n){
int k=1;
for(i=1;i<=5;i++){
for(j=1;j<=i;j++,k++)
System.out.print(k+" ");
System.out.println();
}
}
public static void main(String[] args) {
int n;
Scanner in= new Scanner(System.in);
n=in.nextInt();
left(n);
right(n);
pyramid(n);
number2(n);
}
}
| [
"[email protected]"
]
| |
f76443b7f7a95f5819f1ea2d692100dc9638ea8c | 122d31cb917902f44fceace16ba008f86c25738e | /Avant/src/cl/zpricing/avant/servicios/TimeSpanDao.java | 7c9ebb206fcd016be9812b1329affec4648bff57 | [
"MIT"
]
| permissive | zpricing/AvantPricing | 5df76defbe557751b9b35605d73686ee8506975a | a274f511dd62d06e6abcf60192caf89a4b942f34 | refs/heads/master | 2021-02-11T07:19:02.616013 | 2020-07-14T15:49:46 | 2020-07-14T15:49:46 | 244,467,534 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 710 | java | package cl.zpricing.avant.servicios;
import java.util.List;
import cl.zpricing.avant.model.Complejo;
import cl.zpricing.avant.model.Funcion;
import cl.zpricing.avant.model.loadmanager.TimeSpan;
/**
* Manejo de Objetos de tipo TimeSpan
*
* Registro de versiones:
* <ul>
* <li>1.0 31-01-2009 MARIO: version inicial.</li>
* </ul>
* <P>
* <B>Todos los derechos reservados por ZhetaPricing.</B>
* <P>
*/
public interface TimeSpanDao {
//public List<TimeSpan> obtenerTodos();
public List<TimeSpan> obtenerTodosParaComplejo(Complejo complejo);
public TimeSpan obtenerTimeSpan3d(Complejo complejo);
public TimeSpan obtenerTimeSpan(Complejo complejo, Funcion funcion);
}
| [
"[email protected]"
]
| |
60dd152ab4dddeaeb74c6b26fc6545a873ffa118 | 011e8470e97ff745c07bc679958a3f36fc3e35fc | /gmall-manage-service/src/main/java/com/atguigu/gmall/manage/mapper/PmsBaseAttrValueMapper.java | 3246977a57f14d9c9ec97900a48ad5eeb95a5808 | []
| no_license | cs4224485/onlineShop | 8dff6390893b49bc587b4ddbec77833e36d98686 | 74f04a131f76b61371546051146d31c1ccac5dde | refs/heads/master | 2022-09-16T12:34:44.213062 | 2020-04-27T07:01:12 | 2020-04-27T07:01:12 | 229,855,070 | 0 | 0 | null | 2022-09-01T23:18:58 | 2019-12-24T02:24:28 | CSS | UTF-8 | Java | false | false | 255 | java | package com.atguigu.gmall.manage.mapper;
import com.atguigu.gmall.bean.PmsBaseAttrValue;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Set;
public interface PmsBaseAttrValueMapper extends Mapper<PmsBaseAttrValue> {
}
| [
"[email protected]"
]
| |
cbfd186b7efee4c51793ece4251f0d14955114c6 | 9bf1c86f74de3192b5a8b82f438ced8625b6ca50 | /src/main/java/com/teeny/wms/dto/InventoryAddDTO.java | f861d3e187a72cf2db094d00912f4821eda12b81 | []
| no_license | zp253908058/wms-web | a5349f04bb1557219e0f917c3ca305de8a2a1ca0 | 6e550111daa29a7ff08edd0b8f2413849336b991 | refs/heads/master | 2021-01-01T06:00:47.026453 | 2018-01-14T13:51:54 | 2018-01-14T13:51:54 | 97,326,029 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 672 | java | package com.teeny.wms.dto;
import java.io.Serializable;
/**
* Class description:
*
* @author zp
* @version 1.0
* @see InventoryAddDTO
* @since 2017/9/7
*/
public class InventoryAddDTO implements Serializable {
public int inventoryId; //盘点单id
public int goodsId; //商品id
public String locationCode; //货位码
public String lotNo; //批号
public int amount; //数量
public String validateDate; //有效期
public int locationId; //货位id
public int billState; //初盘1 复盘2
}
| [
"[email protected]"
]
| |
93abb47974886a5adccaef7858f7d31d817d7af8 | d0354ed11486c7b66a3bc649f560e2dadf800174 | /src/main/java/Policy/Handler/PolicyHandle.java | 34e5afa176a04cfaaeda6f5f13d3ce675c40ab71 | []
| no_license | berylyl/HttpServer | 0c9bfe7d0381e09794eae753c6fc6bc6d3d14bc2 | 31eafc75f887a6746a93e9eea7c7a32e61228f74 | refs/heads/master | 2018-12-29T20:11:00.020429 | 2015-09-23T07:10:47 | 2015-09-23T07:10:47 | 42,922,441 | 2 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,806 | java | package Policy.Handler;
import org.apache.log4j.Logger;
import utility.Constant;
import BIOWebServer.ConnectionHandler;
import Policy.*;
/**
* 策略指令字符串操作类,进行策略字符串转化成策略对象并添加到策略队列等操作
*
* @author yinlu
*
*/
public class PolicyHandle {
/**
* 根据http request中的string指令,转化成policy进行处理,如添加或删除策略; policyStr格式为:"1 max 100"
*
* @param value
*/
private static Logger logger = Logger.getLogger(PolicyHandle.class);
public String handlePolicy(String policyStr) {
Policy p = null;
String result = null;
logger.debug("Enter the HttpChannel.handlePolicy method.");
if (policyStr == null || policyStr.equals("")) {
result = "2 Invalid arguments:" + policyStr;
logger.error(result);
} else {
// 分割PolicyStr为多个Policy行
String[] policyRows = policyStr.split("\r\n");
// 分割每个Policy行为PolicyType、PolicyKey、PolicyValue
for (String policyRow : policyRows) {
String[] policyElem = null;
// 解析Policy字符串
try {
policyElem = policyRow.split(" ");
int policyType = Integer.parseInt(policyElem[0]);
String policyKey = policyElem[1];
String policyVal = "";
// 把数据中除了前两个元素以外的所有元素都做为PolicyValue
for (int i = 2; i < policyElem.length; i++) {
policyVal = policyVal + policyElem[i] + " ";
}
policyVal = policyVal.trim();
// 全局策略处理
if (policyType == 1) {
// 如果是service相关的,则返回其Value,即对WebServer的操作命令
if (policyKey.equalsIgnoreCase(PolicyKeys.service)) {
return policyVal;
// 如果是remove_policy策略,就从策略队列中移除该策略
} else if (policyKey
.equalsIgnoreCase(PolicyKeys.remove_policy)) {
String[] policyNames = policyVal.split(" ");
for (String policyName : policyNames) {
PolicyQueue.removePolicy(PolicyType.Global,
policyName);
}
return "1 OK";
// 如果是remove_all策略,清空策略队列
} else if (policyKey
.equalsIgnoreCase(PolicyKeys.remove_all)) {
PolicyQueue.clear(PolicyType.Global);
return "1 OK";
// 如果是应该添加的策略,则封装Policy
} else {
// 如果是connection的conn_close_requests策略,则修改常量reqTimes的值
if (policyKey
.equalsIgnoreCase(PolicyKeys.conn_close_requests)) {
// if (policyVal.equalsIgnoreCase("random")) {
// Constant.reqTimes = (int) (Math.random() * 30
// +
// 1);
// } else {
Constant.reqTimes = Integer.parseInt(policyVal);
// }
}
// 如果是connection的conn_close_timeout策略,则修改常量reqTimeout的值
if (policyKey
.equalsIgnoreCase(PolicyKeys.conn_close_timeout)) {
Constant.reqTimeout = Integer
.parseInt(policyVal);
ConnectionHandler.connCloseTimeout();
}
p = new GlobalPolicy(policyKey, policyVal);
PolicyQueue.addPolicy(p);
result = (result == null ? "1 OK" : result
+ "\r\n1 OK");
}
} else {
result = (result == null ? "2 Invalid arguments:"
+ policyRow : "2 Invalid arguments:"
+ policyRow + "\r\n" + result);
logger.error(result);
}
} catch (NumberFormatException e) {
result = (result == null ? "2 Invalid arguments:"
+ policyRow : "2 Invalid arguments:" + policyRow
+ "\r\n" + result);
logger.error(result, e);
}
}
}
return result;
}
} | [
"[email protected]"
]
| |
6c2d6435e5e05e92d3298f04aa9082106795edf3 | 1b35f18885bee34c05b33cd1aaebfa519ce63a20 | /Ex1/src/ex1/src/WGraph_Algo.java | cb0369f65aaac6c58a0b4f01e63a0c3f7ad5c67b | []
| no_license | MtheEPIC/UniOOP | 5affecd652ca229c27db85dd37abdd84a920f503 | 1a0d6433beee7f5214fa9f14a226593c520c5b64 | refs/heads/main | 2023-01-19T23:21:51.936085 | 2020-11-22T16:39:38 | 2020-11-22T16:39:38 | 305,316,068 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,690 | java | package ex1;
import java.io.*;
import java.util.*;
public class WGraph_Algo implements weighted_graph_algorithms {
WGraph_DS g;
public WGraph_Algo() {
this.g = null;
}
@Override
public void init(weighted_graph g) {
this.g = (WGraph_DS) g;
}
@Override
public weighted_graph getGraph() {
return this.g;
}
@Override
public weighted_graph copy() {
return new WGraph_DS(this.g);
}
@Override
public boolean isConnected() {
// copy of nodes collection to prevent changes in the data of the graph
ArrayList<node_info> nodes = new ArrayList<>((Collection) this.g.getV());
nodes.removeIf(Objects::isNull);
// a graph with 1/0 nodes is connected
if (nodes.size() < 2) {
return true;
}
// check if one node has a path to the rest (+1 to prev because source node is seen as null)
HashMap<node_info, node_info> prev = dijkstra(0, -1);
prev.values().removeIf(Objects::isNull);
if (prev.values().size()+1 != nodes.size()) {
return false;
}
// check for the opposite path
prev = dijkstra(1, -1);
if (prev.size() != nodes.size()) {
return false;
}
return true;
}
@Override
public double shortestPathDist(int src, int dest) {
// check if source and destination exist
if (this.g.getNode(src) == null || this.g.getNode(dest) == null) {
return -1;
}
HashMap<node_info, node_info> prev = dijkstra(src, dest);
node_info node = prev.get(this.g.getNode(dest));
// check if the destination has been reached
if (node == null) {
return -1;
}
return this.g.getNode(dest).getTag();
}
@Override
public List<node_info> shortestPath(int src, int dest) {
ArrayList<node_info> path = new ArrayList<>();
// check if source and destination exist
if (this.g.getNode(src) == null || this.g.getNode(dest) == null) {
return null;
}
HashMap<node_info, node_info> prev = dijkstra(src, dest);
// ArrayList<node_info> prev = dijkstra(src);
node_info node = prev.get(this.g.getNode(dest));
// check if the destination has been reached
if (node == null) {
return null;
}
while (node != null) {
path.add(node);
node = prev.get(node);
}
Collections.reverse(path);
path.add(this.g.getNode(dest));
if (path.get(0).getKey() == src) {
return path;
}
return null;
}
/**
* implementation of dijkstra's search
* @param src
* @return
*/
private HashMap<node_info, node_info> dijkstra(int src, int dest) {
HashMap<node_info, node_info> prevDict = new HashMap<>(); //TODO Pqueue
double w;
for (node_info node : this.g.getV()) {
node.setInfo("white"); // not visited
node.setTag(-1); // no distance from src
prevDict.put(node, null);
}
node_info node = this.g.getNode(src);
if (node == null) {
System.out.println("source node doesn't exist");
return null;
}
PriorityQueue<node_info> pq = new PriorityQueue<>();
pq.add(node);
node.setTag(0);
while (!pq.isEmpty()) {
node = pq.poll();
if (node.getKey() == dest) {
return prevDict;
}
for (node_info neighbor : this.g.getV(node.getKey())) {
if (neighbor.getInfo().equals("white")) {
w = this.g.getEdge(node.getKey(), neighbor.getKey());
// if never visited add first distance
if (neighbor.getTag() == -1) {
neighbor.setTag(node.getTag() + w);
prevDict.replace(neighbor, node);
}
// check if distance can improve
if (neighbor.getTag() > node.getTag()+w) {
neighbor.setTag(node.getTag() + w);
prevDict.replace(neighbor, node);
}
// add node to search queue
// q.add(neighbor);
pq.add(neighbor);
}
}
// mark as visited
node.setInfo("black");
}
return prevDict;
}
@Override
public boolean save(String file) {
// file = "C:/Users/mthee/Desktop/g0.obj"; //check full path
try {
FileOutputStream fOut = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fOut);
oos.writeObject(this.g);
oos.flush();
oos.close();
}
catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
public boolean load(String file) {
WGraph_DS newG;
try {
FileInputStream fIn = new FileInputStream(file);
ObjectInputStream ois = new ObjectInputStream(fIn);
newG = (WGraph_DS) ois.readObject();
ois.close();
}
catch (Exception e) {
e.printStackTrace();
return false;
}
this.g = newG;
// this.g.nodeCount = newG.nodeCount;
// this.g.edgeCount = newG.edgeCount;
// this.g.nodes = newG.nodes;
// this.g.nodesCollection = newG.nodesCollection;
return true; //TODO
}
}
| [
"[email protected]"
]
| |
a77813b9a6ef793b4e0295b9bf4e1d40f36c4d4c | b5524d2fab93eadc75d0533e05db755ce7a69bd3 | /CommnadPattern/Command.java | 2073cb669736884770151bd6b9e313749dc0c309 | []
| no_license | geniein/designPattern | 6f8e65f057acb3830ee79373003cd0a03d27b86c | a3c20276ad207d78087c3bd8273edc6bae9196b0 | refs/heads/master | 2022-11-19T07:16:55.499351 | 2020-07-21T16:32:39 | 2020-07-21T16:32:39 | 280,439,630 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 877 | java | package CommnadPattern;
abstract class Command {
protected Robot robot;
public void setRobot (Robot _robot){
this.robot = _robot;
}
public abstract void execute();
}
class MoveForwardCommand extends Command {
int space;
public MoveForwardCommand(int _space){
space = _space;
}
@Override
public void execute() {
// TODO Auto-generated method stub
robot.moveForward(space);
}
}
class TurnCommand extends Command{
Robot.Direction direction;
public TurnCommand (Robot.Direction _direction){
direction = _direction;
}
@Override
public void execute() {
// TODO Auto-generated method stub
robot.turn(direction);
}
}
class PickUp extends Command{
@Override
public void execute() {
// TODO Auto-generated method stub
robot.pickUp();
}
} | [
"[email protected]"
]
| |
1f8043b0ca928a039bba39d99520b14f9e667494 | a149e9a2d629e98186ca7bdbca19a4f09e44476c | /src/normalizer/AbstractFunctionNormalizer.java | 306d580c6d1051bdaf1345c1f728bb268b9503c1 | []
| no_license | ducanhnguyen/cft4cpp-core | 4d26f1a0ccfdac6f6d9c85461f945f05a6cc0abc | fef3b04d357b6c5f4b1d5d9805a434afe0917c29 | refs/heads/master | 2020-03-07T21:12:17.405005 | 2018-07-25T00:44:53 | 2018-07-25T00:44:53 | 127,720,351 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,039 | java | package normalizer;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import tree.object.IFunctionNode;
import utils.Utils;
/**
* Abstract class for function normalization level
*
* @author ducanhnguyen
*/
public abstract class AbstractFunctionNormalizer extends AbstractNormalizer {
protected IFunctionNode functionNode;
public IFunctionNode getFunctionNode() {
return functionNode;
}
public void setFunctionNode(IFunctionNode functionNode) {
this.functionNode = functionNode;
originalSourcecode = functionNode.getAST().getRawSignature();
}
public IASTFunctionDefinition getNormalizedAST() {
return Utils.getFunctionsinAST(normalizeSourcecode.toCharArray()).get(0);
}
@Override
@Deprecated
public String getOriginalSourcecode() {
return super.getOriginalSourcecode();
}
@Override
@Deprecated
public void setOriginalSourcecode(String originalSourcecode) {
super.setOriginalSourcecode(originalSourcecode);
}
}
| [
"[email protected]"
]
| |
e3de3923d6cfabbbf1ac02264f03aea7f113754f | 50175961679a4c5fa02f180b63c3075d4a528be6 | /src/main/java/com/ty/concurrency/annotation/NotRecommend.java | d332983862a30ad1bff28819a8b70d5e99e451fb | []
| no_license | YuAlfred/concurrency | 5776870818400fa1abeaee6f6f5bcb404a4bad51 | 2cb341929e89a84c9c501674a393bb450ea2fcf5 | refs/heads/master | 2022-11-16T10:43:27.876108 | 2020-07-13T14:00:42 | 2020-07-13T14:00:42 | 277,104,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 542 | java | package com.ty.concurrency.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author : alfredt
* @version : 1.0.0
* @date : Created in 2020/7/4 8:32 下午
* @description : 用来标记不推荐的写法
* @modified By :
*/
//注解可标注位置
@Target(ElementType.TYPE)
//注解存在番位范围
@Retention(RetentionPolicy.SOURCE)
public @interface NotRecommend {
String value() default "";
}
| [
"[email protected]"
]
| |
3a59df63a798a9710f6b591f971dd7fa2c401e97 | bc7d09a090bd4d5600ad99f871da63384075dbed | /java/tenmo-client/src/main/java/com/techelevator/tenmo/services/AccountsService.java | 1daa9ef092dff9e7a5d528d14a1acc43201b3c25 | []
| no_license | adesuwa-osagie/tenmo-payments-software | 66b2e96ff2a8d1856cac20261d4e5b324e797698 | 3b58a331d5ac96267290a65834dd72a250f5b845 | refs/heads/main | 2023-04-19T10:24:17.973101 | 2021-05-11T20:53:27 | 2021-05-11T20:53:27 | 365,627,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,661 | java | package com.techelevator.tenmo.services;
import com.techelevator.tenmo.models.Accounts;
import com.techelevator.view.ConsoleService;
import io.cucumber.core.internal.gherkin.GenerateTokens;
import org.springframework.http.*;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientResponseException;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
public class AccountsService {
private RestTemplate restTemplate = new RestTemplate();// what communicates with the server
private String BASE_URL;
public static String AUTH_TOKEN = "";
private final ConsoleService console = new ConsoleService();
private final String INVALID_ACCOUNT_MSG = "This account is not valid. Please try again";
public AccountsService(String url){
this.BASE_URL = url;
}
public BigDecimal getBalance(Long userId, String AUTH_TOKEN) throws AccountsServiceException {
BigDecimal theBalance = null;
try {
theBalance = restTemplate.exchange(BASE_URL + "accounts/" + userId, HttpMethod.GET,
makeAuthEntity(AUTH_TOKEN), BigDecimal.class).getBody();
} catch (RestClientResponseException ex) {
console.printError("Could not retrieve the balance. Is the server running?");
} catch (ResourceAccessException ex) {
console.printError("A network error occurred.");
}
return theBalance;
}
//A PUT Request with a Request Body
public Accounts updateUserBalance(BigDecimal updatedBalance, Long currentUserId, String AUTH_TOKEN) throws AccountsServiceException {
Accounts accounts = new Accounts();
accounts.setUserId(currentUserId);
accounts.setBalance(updatedBalance);
try {
restTemplate.exchange(BASE_URL + "accounts/" + currentUserId, HttpMethod.PUT,
makeAccountsEntity(accounts, AUTH_TOKEN), Accounts.class);
} catch (RestClientResponseException ex) {
console.printError("Could not update the balance. Is the server running?");
throw new AccountsServiceException(ex.getRawStatusCode() + " : " + ex.getResponseBodyAsString()); // this is above although no other message is also above
} catch (ResourceAccessException ex) {
console.printError("A network error occurred.");
}
return accounts;
}
public Accounts findCurrentUserAccount(Long currentUserId, String AUTH_TOKEN){
Accounts accounts = null;
try{
accounts = restTemplate.exchange(BASE_URL + "accounts/" + currentUserId + "/userAccount",
HttpMethod.GET, makeAuthEntity(AUTH_TOKEN), Accounts.class).getBody();
}catch (RestClientResponseException ex){
console.printError("Could not retrieve the account. Is the server running?");
} catch (ResourceAccessException ex){
console.printError("A network error has occurred.");
}
return accounts;
}
private HttpEntity makeAuthEntity(String token) {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
HttpEntity entity = new HttpEntity<>(headers);
return entity;
}
private HttpEntity<Accounts> makeAccountsEntity(Accounts theAccountWithUpdatedBalance, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(token);
HttpEntity<Accounts> entity = new HttpEntity<>(theAccountWithUpdatedBalance, headers);
return entity;
}
}
| [
"[email protected]"
]
| |
ed8cf3a5f71f91aaf0327fc4cc673fa300d94da9 | 96daf10e975e50700391cb3fcf4746a621530f03 | /pinyougou-parent/pinyougou-manager-web/src/main/java/com/pinyougou/manager/controller/SellerController.java | 19d1eeb7f78822e0c48af21427d9ebaf3029d8e6 | []
| no_license | dadaruyi/pinyougou6 | 926a970c7497fb144300fe1fe0cd19840f75d925 | 67c5e0728146dcade7a723bfe2ec213964f534f0 | refs/heads/master | 2022-12-22T00:13:56.198629 | 2019-06-28T13:23:24 | 2019-06-28T13:23:55 | 194,277,987 | 0 | 0 | null | 2022-12-16T07:14:24 | 2019-06-28T13:24:49 | JavaScript | UTF-8 | Java | false | false | 2,933 | java | package com.pinyougou.manager.controller;
import java.util.List;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.TbSeller;
import com.pinyougou.sellergoods.service.SellerService;
import entity.PageResult;
import entity.Result;
/**
* controller
* @author Administrator
*
*/
@RestController
@RequestMapping("/seller")
public class SellerController {
@Reference
private SellerService sellerService;
/**
* 返回全部列表
* @return
*/
@RequestMapping("/findAll")
public List<TbSeller> findAll(){
return sellerService.findAll();
}
/**
* 返回全部列表
* @return
*/
@RequestMapping("/findPage")
public PageResult findPage(int page,int rows){
return sellerService.findPage(page, rows);
}
/**
* 增加
* @param seller
* @return
*/
@RequestMapping("/add")
public Result add(@RequestBody TbSeller seller){
/* //密码加密
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String password = passwordEncoder.encode(seller.getPassword());
seller.setPassword(password);*/
try {
sellerService.add(seller);
return new Result(true, "增加成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "增加失败");
}
}
/**
* 修改
* @param seller
* @return
*/
@RequestMapping("/update")
public Result update(@RequestBody TbSeller seller){
try {
sellerService.update(seller);
return new Result(true, "修改成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "修改失败");
}
}
/**
* 获取实体
* @param id
* @return
*/
@RequestMapping("/findOne")
public TbSeller findOne(String id){
return sellerService.findOne(id);
}
/**
* 批量删除
* @param ids
* @return
*/
@RequestMapping("/delete")
public Result delete(String [] ids){
try {
sellerService.delete(ids);
return new Result(true, "删除成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "删除失败");
}
}
/**
* 查询+分页
* @param
* @param page
* @param rows
* @return
*/
@RequestMapping("/search")
public PageResult search(@RequestBody TbSeller seller, int page, int rows ){
return sellerService.findPage(seller, page, rows);
}
/**
* 更改状态
* @param sellerId 商家ID
* @param status 状态
*/
@RequestMapping("updateStatus")
public Result updateStatus(String sellerId,String status){
try {
sellerService.updateStatus(sellerId,status);
return new Result(true,"成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false,"失败");
}
}
}
| [
"[email protected]"
]
| |
bef75ceaadb3b929e6e8eda8fbf24165ff2cd659 | 97beafaf6b324ac625d26ff7155859e62cae08d1 | /src/main/java/com/forskills/authentication/service/AuthenticationServiceImpl.java | a6c85322ad2beaa83fba186a9433316ea164b10b | []
| no_license | adil1996/AuthApppSpringBoot | cab7aad82602c87f73039463895c02e1061dc2a3 | 6c5934838326d3d0d7695934023b7ca6d30b3c98 | refs/heads/main | 2023-02-01T09:33:41.192832 | 2020-12-12T10:02:57 | 2020-12-12T10:02:57 | 320,798,890 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,906 | java | package com.forskills.authentication.service;
import com.forskills.authentication.dto.AuthrnticationRequest;
import com.forskills.authentication.dto.TestCreateRequest;
import com.forskills.authentication.model.TestDetails;
import com.forskills.authentication.model.UserDetails;
import com.forskills.authentication.repo.TestDetailsRepo;
import com.forskills.authentication.repo.UserDetailsRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class AuthenticationServiceImpl implements AuthenticationServiceInterface {
@Autowired
UserDetailsRepo userDetailsRepo;
@Autowired
TestDetailsRepo testDetailsRepo;
@Override
public HashMap<String, String> fetchUserDetails(String email) throws Exception {
try{
UserDetails userDetails = userDetailsRepo.findByEmail(email);
List<UserDetails> userDetailsList = userDetailsRepo.findAll();
HashMap<String,String> users = new HashMap<>();
users.put("email",userDetails.getEmail());
users.put("password",userDetails.getPassword());
return users;
}
catch (Exception ex){
throw ex;
}
}
@Override
public HashMap<String, String> SaveUserDeatils(AuthrnticationRequest authrnticationRequest) throws Exception {
try{
UserDetails userDetails = new UserDetails();
userDetails.setEmail(authrnticationRequest.getEmail());
userDetails.setFirstName(authrnticationRequest.getFirstName());
userDetails.setLastName(authrnticationRequest.getLastNamw());
userDetails.setPassword(authrnticationRequest.getPassword());
userDetailsRepo.save(userDetails);
HashMap<String,String> user = new HashMap<>();
user.put("Status","Success");
return user;
}
catch (Exception ex){
throw ex;
}
}
@Override
public HashMap<String, String> createTest(TestCreateRequest testCreateRequest) throws Exception {
try{
TestDetails testDetails = new TestDetails();
testDetails.setTestId(testCreateRequest.getTestId());
testDetails.setTestName(testCreateRequest.getTestName());
testDetails.setAllowedEmail(Arrays.asList(testCreateRequest.getTestAllowedIds()).stream().map( e -> e.trim()).collect(Collectors.joining(",")));
testDetails.setDate(testCreateRequest.getExpirationDate());
testDetailsRepo.save(testDetails);
HashMap<String,String> test = new HashMap<>();
test.put("Status","Success");
return test;
}
catch (Exception ex){
throw ex;
}
}
}
| [
"Sma786@110"
]
| Sma786@110 |
a36981c2f4bef59d2b3b41f208d58b6f722c0553 | 58ecefd9bcb0be78bb4b0c02c2dd3591ea510829 | /src/linkedlist/IsPalindrome.java | 0cfb09dd872b4370d42ffb64ffa9c0c98623d97f | []
| no_license | AndersonAnson/AutumnCoding | fd8bd1091df8a45dc89a9dd6c78d0316ef080bd9 | 00768c6e14cdfce9f5582b1dfa1a96ca4bc9333b | refs/heads/master | 2023-01-04T16:46:24.896559 | 2020-10-28T13:44:30 | 2020-10-28T13:44:30 | 276,402,049 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,261 | java | package linkedlist;
public class IsPalindrome {
public boolean isPalindrome(ListNode head) {
if (head == null || head.next == null) {
return true;
}
ListNode firstHalfEnd = endOfFirstHalf(head);
ListNode secondHalfStart = reverse(firstHalfEnd.next);
ListNode p1 = head;
ListNode p2 = secondHalfStart;
boolean ans = true;
while (ans && p2 != null) {
if (p1.val != p2.val)
ans = false;
p1 = p1.next;
p2 = p2.next;
}
firstHalfEnd.next = reverse(secondHalfStart);
return ans;
}
private ListNode reverse(ListNode head) {
ListNode prev = null;
ListNode curr = head;
while (curr != null) {
ListNode nextTemp = curr.next;
curr.next = prev;
prev = curr;
curr = nextTemp;
}
return prev;
}
private ListNode endOfFirstHalf(ListNode head) {
ListNode fast = head;
ListNode slow = head;
while (fast.next != null && fast.next.next != null) {
fast = fast.next.next;
slow = slow.next;
}
return slow;
}
}
| [
"[email protected]"
]
| |
eb37cfbe11ab847b8fbeebd9321553ef01398603 | 756a9980dff0881d7591119303c3974e966cfc11 | /sample/spring/spring4/Sample9/src/main/java/org/in/prix/sample/spring4/sample9/ClassA.java | 171ddddb41ad6afa52a1163221a07bf34564baf3 | []
| no_license | kannancmohan/priX | 61819106b52ec1f248ed561cc53065e3bb6a7857 | 8acb9fdfa0fab91629eebc9a0999bee27f8d3894 | refs/heads/master | 2016-09-05T18:02:40.249585 | 2014-06-27T20:07:02 | 2014-06-27T20:07:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 142 | java | package org.in.prix.sample.spring4.sample9;
public class ClassA {
public ClassA() {
System.out.println("A intialized");
}
}
| [
"[email protected]"
]
| |
6f75167e651984046242e7cef91712510dbc8b0f | f915d4d30fe9243a9a6aa2f8e54c85737563d1fd | /src/main/java/fivium/pat/graphql/queryfields/patient/RetrieveProviderDataQF.java | 438ab36d5ff890f9cb15c5f366378bdcbd8440eb | []
| no_license | ToukanLabs/pat-server | 8704d18f009d72761a1795c344084752f8c06455 | 745550440fe5165e36329fe2e7d481567d9921f3 | refs/heads/master | 2021-08-31T11:01:06.364736 | 2017-11-27T21:25:16 | 2017-11-27T21:25:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,896 | java | package fivium.pat.graphql.queryfields.patient;
import static graphql.Scalars.GraphQLString;
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition;
import static graphql.schema.GraphQLObjectType.newObject;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.google.gson.Gson;
import fivium.pat.graphql.queryfields.PAT_BaseQF;
import fivium.pat.provider.data.AppData;
import fivium.pat.provider.utils.FitbitDataRetriever;
import fivium.pat.utils.Constants;
import fivium.pat.utils.PatUtils;
import fivium.pat.utils.PAT_DAO;
import graphql.Scalars;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLArgument;
import graphql.schema.GraphQLObjectType;
public class RetrieveProviderDataQF extends PAT_BaseQF {
private static Log logger = LogFactory.getLog(RetrieveProviderDataQF.class);
@Override
protected GraphQLObjectType defineField() {
return newObject().name("RetrieveProviderData").description("Retrieve data from Fitbit when the user loads the dashboard.")
.field(newFieldDefinition().name("response").type(GraphQLString)).build();
}
protected List<GraphQLArgument> defineArguments() {
return Arrays.asList(new GraphQLArgument("provider", Scalars.GraphQLString),
new GraphQLArgument("jwt", Scalars.GraphQLString));
}
protected Object fetchData(DataFetchingEnvironment environment) {
Map<String, String> resultMap = new HashMap<String, String>();
String provider = environment.getArgument("provider");
AppData appData;
if("fitbit".equalsIgnoreCase(provider)) {
String refreshToken = "";
logger.info("Entering Retrieve Data From Fitbit...");
String subject = PatUtils.getUserIdFromJWT(environment.getArgument("jwt").toString());
Collection<Map<String, String>> resultGetUser;
try {
resultGetUser = PAT_DAO.executeStatement(Constants.GET_SINGLE_FITBIT_USER, new Object[] {subject});
if(!resultGetUser.isEmpty()) {
refreshToken = resultGetUser.iterator().next().get("provider_refresh_token");
String accessToken = FitbitDataRetriever.getAccessToken(subject, refreshToken, false);
appData = FitbitDataRetriever.pollFitbitForAUser(subject, accessToken);
} else {
resultMap.put("response", "User is not authorized yet");
return resultMap;
}
} catch (Exception e) {
logger.error("Exception occurred trying to get the provider_refresh_token in the retrive data from fitbit route"+e);
resultMap.put("response", "Unable to get fitbit data, please authorise your FitBit app again");
return resultMap;
}
if(appData != null) {
resultMap.put("response", new Gson().toJson(appData));
} else {
resultMap.put("response", "Error");
}
}
return resultMap;
}
}
| [
"[email protected]"
]
| |
7afa8ee6d82d8e38b5e5407a594a929a7b965e1a | d16f00f37052ba0ee36f6d5d6c6316bc101eff97 | /imm-common/src/main/java/com/imm/common/web/constants/BaseReqConst.java | fb120cb138cdf885fcea5d370a8b8c9c721aa23d | []
| no_license | zhaozhao-ak/immkk | 09690cc3598ddb8ee8de1562a32e8a12ac6b4e9f | 3616ba1f027f10fc1179d76dea46fe6d74958590 | refs/heads/master | 2022-06-30T21:43:29.995745 | 2019-10-08T07:50:03 | 2019-10-08T07:50:03 | 211,826,214 | 0 | 0 | null | 2022-06-17T02:33:45 | 2019-09-30T09:39:41 | Java | UTF-8 | Java | false | false | 1,916 | java | package com.imm.common.web.constants;
/**
* @author rjyx_huxinsheng
*/
public class BaseReqConst {
/**
* 请求url配置块开始
*/
public static final String REQ_INDEX = "/index";
public static final String PARAM_HOST = "host";
public static final String REQ_METHOD_GET = "GET";
public static final String REQ_METHOD_POST = "POST";
public static final String REQ_HEADER = "x-requested-with";
public static final String REQ_XML_HTTP_REQUEST = "XMLHttpRequest";
public static final String REQ_QUERY_PAGE_DATA = "queryPageData";
public static final String REQ_QUERY_DATA_DIALOG = "queryDataDialog";
public static final String REQ_QUERY_LIST_DATA = "queryListData";
public static final String REQ_QUERY_DETAIL_DATA = "queryDetailData";
public static final String REQ_QUERY_DETAIL_PAGE = "queryDetailPage";
public static final String REQ_QUERY_DETAIL_DIALOG = "queryDetailDialog";
public static final String REQ_MODIFY_DATA = "modifyData";
public static final String REQ_MODIFY_SUB_DATA_DIALOG = "modifySubDataDialog";
public static final String REQ_MODIFY_STATUS_DATA = "modifyStatusData";
public static final String REQ_MODIFY_DATA_DIALOG = "modifyDataDialog";
public static final String REQ_MODIFY_DATA_PAGE = "modifyDataPage";
public static final String REQ_ADD_DATA = "addData";
public static final String REQ_ADD_DATA_DIALOG = "addDataDialog";
public static final String REQ_ADD_DATA_PAGE = "addDataPage";
public static final String REQ_DELETE_DATA = "deleteData";
public static final String REQ_DELETE_DATA_BY_ID = "deleteData/{id}";
public static final String REQ_DELETE_DATA_DIALOG = "deleteDataDialog";
public static final String REQ_DELETE_DATA_PAGE = "deleteDataPage";
public static final String REQ_EXPORT_DATA_LIST = "exportListData";
public static final String PARAM_ID = "id";
}
| [
"Rjyx@123"
]
| Rjyx@123 |
b679a5bcbe35aed5de337e5e9d92880a14f77e52 | bc3acfc4f8d08236c00267f912c3478def2f9578 | /src/main/Runner.java | 62c51c386ebbeb3045ac45aecf96c3e117541b2e | []
| no_license | Thi6/Week2 | 6f276b9dfd883dc35a1b3242d99c4616c81df8a3 | 582f91d424302f6bd7ce55379a877d3982ef021a | refs/heads/master | 2020-05-26T14:54:16.852732 | 2019-06-03T16:20:58 | 2019-06-03T16:20:58 | 188,274,910 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,299 | java | package main;
import models.Bus;
import models.Car;
import models.Garage;
import models.Motorcycle;
public class Runner {
public static void main(String[] args) throws CloneNotSupportedException {
// creating vehicle
Car vehicle1 = new Car(1.2, 5, 4, 2);
Motorcycle vehicle2 = new Motorcycle(0.8, 2, 2);
Bus vehicle3 = new Bus(2.8, 100, 4, 110);
Bus vehicle4 = new Bus(2.8, 80, 4, 100);
/* Bus vehicle5 = new Bus(2.8, 80, 4, 100);
Bus vehicle6 = new Bus(2.8, 80, 4, 100);
*/
//cloning
Bus vehicle5 = (Bus) vehicle4.clone();
vehicle5.setCapacity(10);
Bus vehicle6 = (Bus) vehicle3.clone();
vehicle6.setHeight(3);
// create a garage
Garage garage1 = new Garage();
// add vehicle into garage
/*
* garage1.getGarageList().add(vehicle1); garage1.getGarageList().add(vehicle2);
* garage1.getGarageList().add(vehicle3);
*/
garage1.addVehicle(vehicle1);
garage1.addVehicle(vehicle2);
garage1.addVehicle(vehicle3);
garage1.addVehicle(vehicle4);
garage1.addVehicle(vehicle5);
garage1.addVehicle(vehicle6);
System.out.println(garage1.getGarageList());
garage1.calculateBill(garage1.getGarageList());
// garage1.removeAVehicle(vehicle1);
// garage1.removeVehicles("bus");
System.out.println(garage1.getGarageList());
}
}
| [
"[email protected]"
]
| |
cd99cb813c72563d4663cd138f65c93b9bed7e81 | 4268aa9f20db20085bbfe658715509bb9a4c6d5d | /MovieOrder/src/main/java/com/hand/movie/service/MPHService.java | b697ed0875e510c7350ac4742db22da0f8cdb9b1 | []
| no_license | 1198109623/GraduationDesign | f18f79661aa61b25625433abc17aa76681cd5e0f | 52da2ce4d1235fba87c315a0f54962e1c4bd33ea | refs/heads/master | 2021-05-12T18:26:49.962562 | 2018-01-19T01:37:04 | 2018-01-19T01:37:04 | 117,066,639 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 459 | java | package com.hand.movie.service;
import com.hand.movie.bean.Movie;
import com.hand.movie.bean.MovieProjHall;
import java.util.List;
public interface MPHService {
List<MovieProjHall> getAll();
List<MovieProjHall> getMPHBypName(String pName);
int saveMPH(MovieProjHall movieProjHall);
MovieProjHall getMPById(Integer id);
void updateMPH(MovieProjHall mph);
void deleteMPH(Integer id);
void deleteBatch(List<Integer> ids);
}
| [
"[email protected]"
]
| |
29a5bf5a24c4898335b231a6fc444b4d3661d63f | 6e954b23bd08209a65a9be1908aca6a77712a7b9 | /web-test/finalserver/src/catalina/session/StandardManager.java | 0fd19f7f9d3457cbe7cb56815aa35f48ec593199 | []
| no_license | chengliangran/clrserver | 003315315abaa44179e2be030f5a692408a8c742 | 5fa9fd1be4fbc62f76e6482521acb6daca859a13 | refs/heads/master | 2021-01-13T05:24:09.067957 | 2017-04-19T09:59:13 | 2017-04-19T09:59:13 | 81,401,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 25,681 | java | /*
* $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/StandardManager.java,v 1.19 2002/06/09 02:19:43 remm Exp $
* $Revision: 1.19 $
* $Date: 2002/06/09 02:19:43 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [email protected].
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package catalina.session;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.ServletContext;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Loader;
import org.apache.catalina.Session;
import org.apache.catalina.util.CustomObjectInputStream;
import org.apache.catalina.util.LifecycleSupport;
/**
* Standard implementation of the <b>Manager</b> interface that provides
* simple session persistence across restarts of this component (such as
* when the entire server is shut down and restarted, or when a particular
* web application is reloaded.
* <p>
* <b>IMPLEMENTATION NOTE</b>: Correct behavior of session storing and
* reloading depends upon external calls to the <code>start()</code> and
* <code>stop()</code> methods of this class at the correct times.
*
* @author Craig R. McClanahan
* @version $Revision: 1.19 $ $Date: 2002/06/09 02:19:43 $
*/
public class StandardManager
extends ManagerBase
implements Lifecycle, PropertyChangeListener, Runnable {
// ----------------------------------------------------- Instance Variables
/**
* The interval (in seconds) between checks for expired sessions.
*/
private int checkInterval = 60;
/**
* The descriptive information about this implementation.
*/
private static final String info = "StandardManager/1.0";
/**
* The lifecycle event support for this component.
*/
protected LifecycleSupport lifecycle = new LifecycleSupport(this);
/**
* The maximum number of active Sessions allowed, or -1 for no limit.
*/
private int maxActiveSessions = -1;
/**
* The descriptive name of this Manager implementation (for logging).
*/
protected static String name = "StandardManager";
/**
* Path name of the disk file in which active sessions are saved
* when we stop, and from which these sessions are loaded when we start.
* A <code>null</code> value indicates that no persistence is desired.
* If this pathname is relative, it will be resolved against the
* temporary working directory provided by our context, available via
* the <code>javax.servlet.context.tempdir</code> context attribute.
*/
private String pathname = "SESSIONS.ser";
/**
* Has this component been started yet?
*/
private boolean started = false;
/**
* The background thread.
*/
private Thread thread = null;
/**
* The background thread completion semaphore.
*/
private boolean threadDone = false;
/**
* Name to register for the background thread.
*/
private String threadName = "StandardManager";
// ------------------------------------------------------------- Properties
/**
* Return the check interval (in seconds) for this Manager.
*/
public int getCheckInterval() {
return (this.checkInterval);
}
/**
* Set the check interval (in seconds) for this Manager.
*
* @param checkInterval The new check interval
*/
public void setCheckInterval(int checkInterval) {
int oldCheckInterval = this.checkInterval;
this.checkInterval = checkInterval;
support.firePropertyChange("checkInterval",
new Integer(oldCheckInterval),
new Integer(this.checkInterval));
}
/**
* Set the Container with which this Manager has been associated. If
* it is a Context (the usual case), listen for changes to the session
* timeout property.
*
* @param container The associated Container
*/
public void setContainer(Container container) {
// De-register from the old Container (if any)
if ((this.container != null) && (this.container instanceof Context))
((Context) this.container).removePropertyChangeListener(this);
// Default processing provided by our superclass
super.setContainer(container);
// Register with the new Container (if any)
if ((this.container != null) && (this.container instanceof Context)) {
setMaxInactiveInterval
( ((Context) this.container).getSessionTimeout()*60 );
((Context) this.container).addPropertyChangeListener(this);
}
}
/**
* Return descriptive information about this Manager implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
*/
public String getInfo() {
return (this.info);
}
/**
* Return the maximum number of active Sessions allowed, or -1 for
* no limit.
*/
public int getMaxActiveSessions() {
return (this.maxActiveSessions);
}
/**
* Set the maximum number of actives Sessions allowed, or -1 for
* no limit.
*
* @param max The new maximum number of sessions
*/
public void setMaxActiveSessions(int max) {
int oldMaxActiveSessions = this.maxActiveSessions;
this.maxActiveSessions = max;
support.firePropertyChange("maxActiveSessions",
new Integer(oldMaxActiveSessions),
new Integer(this.maxActiveSessions));
}
/**
* Return the descriptive short name of this Manager implementation.
*/
public String getName() {
return (name);
}
/**
* Return the session persistence pathname, if any.
*/
public String getPathname() {
return (this.pathname);
}
/**
* Set the session persistence pathname to the specified value. If no
* persistence support is desired, set the pathname to <code>null</code>.
*
* @param pathname New session persistence pathname
*/
public void setPathname(String pathname) {
String oldPathname = this.pathname;
this.pathname = pathname;
support.firePropertyChange("pathname", oldPathname, this.pathname);
}
// --------------------------------------------------------- Public Methods
/**
* Construct and return a new session object, based on the default
* settings specified by this Manager's properties. The session
* id will be assigned by this method, and available via the getId()
* method of the returned session. If a new session cannot be created
* for any reason, return <code>null</code>.
*
* @exception IllegalStateException if a new session cannot be
* instantiated for any reason
*/
public Session createSession() {
if ((maxActiveSessions >= 0) &&
(sessions.size() >= maxActiveSessions))
throw new IllegalStateException
(sm.getString("standardManager.createSession.ise"));
return (super.createSession());
}
/**
* Load any currently active sessions that were previously unloaded
* to the appropriate persistence mechanism, if any. If persistence is not
* supported, this method returns without doing anything.
*
* @exception ClassNotFoundException if a serialized class cannot be
* found during the reload
* @exception IOException if an input/output error occurs
*/
public void load() throws ClassNotFoundException, IOException {
if (debug >= 1)
log("Start: Loading persisted sessions");
// Initialize our internal data structures
recycled.clear();
sessions.clear();
// Open an input stream to the specified pathname, if any
File file = file();
if (file == null)
return;
if (debug >= 1)
log(sm.getString("standardManager.loading", pathname));
FileInputStream fis = null;
ObjectInputStream ois = null;
Loader loader = null;
ClassLoader classLoader = null;
try {
fis = new FileInputStream(file.getAbsolutePath());
BufferedInputStream bis = new BufferedInputStream(fis);
if (container != null)
loader = container.getLoader();
if (loader != null)
classLoader = loader.getClassLoader();
if (classLoader != null) {
if (debug >= 1)
log("Creating custom object input stream for class loader "
+ classLoader);
ois = new CustomObjectInputStream(bis, classLoader);
} else {
if (debug >= 1)
log("Creating standard object input stream");
ois = new ObjectInputStream(bis);
}
} catch (FileNotFoundException e) {
if (debug >= 1)
log("No persisted data file found");
return;
} catch (IOException e) {
log(sm.getString("standardManager.loading.ioe", e), e);
if (ois != null) {
try {
ois.close();
} catch (IOException f) {
;
}
ois = null;
}
throw e;
}
// Load the previously unloaded active sessions
synchronized (sessions) {
try {
Integer count = (Integer) ois.readObject();
int n = count.intValue();
if (debug >= 1)
log("Loading " + n + " persisted sessions");
for (int i = 0; i < n; i++) {
StandardSession session = new StandardSession(this);
session.readObjectData(ois);
session.setManager(this);
sessions.put(session.getId(), session);
((StandardSession) session).activate();
}
} catch (ClassNotFoundException e) {
log(sm.getString("standardManager.loading.cnfe", e), e);
if (ois != null) {
try {
ois.close();
} catch (IOException f) {
;
}
ois = null;
}
throw e;
} catch (IOException e) {
log(sm.getString("standardManager.loading.ioe", e), e);
if (ois != null) {
try {
ois.close();
} catch (IOException f) {
;
}
ois = null;
}
throw e;
} finally {
// Close the input stream
try {
if (ois != null)
ois.close();
} catch (IOException f) {
// ignored
}
// Delete the persistent storage file
if (file != null && file.exists() )
file.delete();
}
}
if (debug >= 1)
log("Finish: Loading persisted sessions");
}
/**
* Save any currently active sessions in the appropriate persistence
* mechanism, if any. If persistence is not supported, this method
* returns without doing anything.
*
* @exception IOException if an input/output error occurs
*/
public void unload() throws IOException {
if (debug >= 1)
log("Unloading persisted sessions");
// Open an output stream to the specified pathname, if any
File file = file();
if (file == null)
return;
if (debug >= 1)
log(sm.getString("standardManager.unloading", pathname));
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
fos = new FileOutputStream(file.getAbsolutePath());
oos = new ObjectOutputStream(new BufferedOutputStream(fos));
} catch (IOException e) {
log(sm.getString("standardManager.unloading.ioe", e), e);
if (oos != null) {
try {
oos.close();
} catch (IOException f) {
;
}
oos = null;
}
throw e;
}
// Write the number of active sessions, followed by the details
ArrayList list = new ArrayList();
synchronized (sessions) {
if (debug >= 1)
log("Unloading " + sessions.size() + " sessions");
try {
oos.writeObject(new Integer(sessions.size()));
Iterator elements = sessions.values().iterator();
while (elements.hasNext()) {
StandardSession session =
(StandardSession) elements.next();
list.add(session);
((StandardSession) session).passivate();
session.writeObjectData(oos);
}
} catch (IOException e) {
log(sm.getString("standardManager.unloading.ioe", e), e);
if (oos != null) {
try {
oos.close();
} catch (IOException f) {
;
}
oos = null;
}
throw e;
}
}
// Flush and close the output stream
try {
oos.flush();
oos.close();
oos = null;
} catch (IOException e) {
if (oos != null) {
try {
oos.close();
} catch (IOException f) {
;
}
oos = null;
}
throw e;
}
// Expire all the sessions we just wrote
if (debug >= 1)
log("Expiring " + list.size() + " persisted sessions");
Iterator expires = list.iterator();
while (expires.hasNext()) {
StandardSession session = (StandardSession) expires.next();
try {
session.expire(false);
} catch (Throwable t) {
;
}
}
if (debug >= 1)
log("Unloading complete");
}
// ------------------------------------------------------ Lifecycle Methods
/**
* Add a lifecycle event listener to this component.
*
* @param listener The listener to add
*/
public void addLifecycleListener(LifecycleListener listener) {
lifecycle.addLifecycleListener(listener);
}
/**
* Get the lifecycle listeners associated with this lifecycle. If this
* Lifecycle has no listeners registered, a zero-length array is returned.
*/
public LifecycleListener[] findLifecycleListeners() {
return lifecycle.findLifecycleListeners();
}
/**
* Remove a lifecycle event listener from this component.
*
* @param listener The listener to remove
*/
public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
/**
* Prepare for the beginning of active use of the public methods of this
* component. This method should be called after <code>configure()</code>,
* and before any of the public methods of the component are utilized.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
public void start() throws LifecycleException {
if (debug >= 1)
log("Starting");
// Validate and update our current component state
if (started)
throw new LifecycleException
(sm.getString("standardManager.alreadyStarted"));
lifecycle.fireLifecycleEvent(START_EVENT, null);
started = true;
// Force initialization of the random number generator
if (debug >= 1)
log("Force random number initialization starting");
String dummy = generateSessionId();
if (debug >= 1)
log("Force random number initialization completed");
// Load unloaded sessions, if any
try {
load();
} catch (Throwable t) {
log(sm.getString("standardManager.managerLoad"), t);
}
// Start the background reaper thread
threadStart();
}
/**
* Gracefully terminate the active use of the public methods of this
* component. This method should be the last one called on a given
* instance of this component.
*
* @exception LifecycleException if this component detects a fatal error
* that needs to be reported
*/
public void stop() throws LifecycleException {
if (debug >= 1)
log("Stopping");
// Validate and update our current component state
if (!started)
throw new LifecycleException
(sm.getString("standardManager.notStarted"));
lifecycle.fireLifecycleEvent(STOP_EVENT, null);
started = false;
// Stop the background reaper thread
threadStop();
// Write out sessions
try {
unload();
} catch (IOException e) {
log(sm.getString("standardManager.managerUnload"), e);
}
// Expire all active sessions
Session sessions[] = findSessions();
for (int i = 0; i < sessions.length; i++) {
StandardSession session = (StandardSession) sessions[i];
if (!session.isValid())
continue;
try {
session.expire();
} catch (Throwable t) {
;
}
}
// Require a new random number generator if we are restarted
this.random = null;
}
// ----------------------------------------- PropertyChangeListener Methods
/**
* Process property change events from our associated Context.
*
* @param event The property change event that has occurred
*/
public void propertyChange(PropertyChangeEvent event) {
// Validate the source of this event
if (!(event.getSource() instanceof Context))
return;
Context context = (Context) event.getSource();
// Process a relevant property change
if (event.getPropertyName().equals("sessionTimeout")) {
try {
setMaxInactiveInterval
( ((Integer) event.getNewValue()).intValue()*60 );
} catch (NumberFormatException e) {
log(sm.getString("standardManager.sessionTimeout",
event.getNewValue().toString()));
}
}
}
// -------------------------------------------------------- Private Methods
/**
* Return a File object representing the pathname to our
* persistence file, if any.
*/
private File file() {
if (pathname == null)
return (null);
File file = new File(pathname);
if (!file.isAbsolute()) {
if (container instanceof Context) {
ServletContext servletContext =
((Context) container).getServletContext();
File tempdir = (File)
servletContext.getAttribute(Globals.WORK_DIR_ATTR);
if (tempdir != null)
file = new File(tempdir, pathname);
}
}
// if (!file.isAbsolute())
// return (null);
return (file);
}
/**
* Invalidate all sessions that have expired.
*/
private void processExpires() {
long timeNow = System.currentTimeMillis();
Session sessions[] = findSessions();
for (int i = 0; i < sessions.length; i++) {
StandardSession session = (StandardSession) sessions[i];
if (!session.isValid())
continue;
int maxInactiveInterval = session.getMaxInactiveInterval();
if (maxInactiveInterval < 0)
continue;
int timeIdle = // Truncate, do not round up
(int) ((timeNow - session.getLastAccessedTime()) / 1000L);
if (timeIdle >= maxInactiveInterval) {
try {
session.expire();
} catch (Throwable t) {
log(sm.getString("standardManager.expireException"), t);
}
}
}
}
/**
* Sleep for the duration specified by the <code>checkInterval</code>
* property.
*/
private void threadSleep() {
try {
Thread.sleep(checkInterval * 1000L);
} catch (InterruptedException e) {
;
}
}
/**
* Start the background thread that will periodically check for
* session timeouts.
*/
private void threadStart() {
if (thread != null)
return;
threadDone = false;
threadName = "StandardManager[" + container.getName() + "]";
thread = new Thread(this, threadName);
thread.setDaemon(true);
thread.setContextClassLoader(container.getLoader().getClassLoader());
thread.start();
}
/**
* Stop the background thread that is periodically checking for
* session timeouts.
*/
private void threadStop() {
if (thread == null)
return;
threadDone = true;
thread.interrupt();
try {
thread.join();
} catch (InterruptedException e) {
;
}
thread = null;
}
// ------------------------------------------------------ Background Thread
/**
* The background thread that checks for session timeouts and shutdown.
*/
public void run() {
// Loop until the termination semaphore is set
while (!threadDone) {
threadSleep();
processExpires();
}
}
}
| [
"[email protected]"
]
| |
e4e09aea75f7e1c4018df08631bdf8bcc0f868d5 | fa7cfb9a60f93848e2bddb157fefe20e4d807fac | /system_dao/src/main/java/com/htcs/kehaoduo/system/mapper/SysAgentAppidMapper.java | 9355d2d5141e5c4399a693e0f9ff9a7326804db0 | []
| no_license | kuke0932/kehaoduo | a6cf7e5c40851977f4a391983e9eac5812e81c36 | 74261a21d01562e11da0d5d27f8d1ca35808982b | refs/heads/master | 2020-04-10T20:26:48.694382 | 2018-12-11T03:23:32 | 2018-12-11T03:33:18 | 161,268,176 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 652 | java | package com.htcs.kehaoduo.system.mapper;
import com.htcs.kehaoduo.system.bean.SysAgentAppid;
import org.springframework.stereotype.Repository;
@Repository
public interface SysAgentAppidMapper {
SysAgentAppid selectByAppId(String appId);
SysAgentAppid selectBySysUserId(Integer sysUserId);
SysAgentAppid selectByAreaCode(String areaCode);
int deleteByPrimaryKey(Integer id);
int insert(SysAgentAppid record);
int insertSelective(SysAgentAppid record);
SysAgentAppid selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysAgentAppid record);
void updateBySysUserId(SysAgentAppid sysAgentAppid);
}
| [
"[email protected]"
]
| |
eb05461236cca9677c7e9528ee8ae152990cef54 | 422d2fd43542a908fe6431952134241a12626661 | /app/src/main/java/xu/myapplication/Tool/Sp.java | 441a1c1cca0a8cb11f083a1b7d56734dc9366668 | []
| no_license | xiellml/SKinAppDemo | 8ff5bb4b21e91736f34a91f18e117e0315fc92a1 | 7528d518bab5ba878291e5244d5fadfb847238ca | refs/heads/master | 2023-08-01T07:56:35.151899 | 2017-09-10T07:51:24 | 2017-09-10T07:51:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 631 | java | package xu.myapplication.Tool;
import android.content.Context;
import android.content.SharedPreferences;
import xu.myapplication.BaseApplication;
/**
* Created by lovexujh on 2017/9/2
*/
public class Sp {
private SharedPreferences sp;
public Sp() {
sp = BaseApplication.getInstance().getSharedPreferences("AppConfig", Context.MODE_PRIVATE);
}
public String getString(String key, String defaultValue) {
String value = sp.getString(key, defaultValue);
return value;
}
public void setString(String key, String value){
sp.edit().putString(key, value).commit();
}
}
| [
"[email protected]"
]
| |
65661f8fc9b0ed7f004ba5041fe5c0d6de647d35 | eb27fa1a9533519771ed53eae1d07bc098425cf3 | /src/main/java/cn/config/common/KaptchaConfig.java | 257c538d0d453e0e3c5947fabe0032f2bfcf0c4a | []
| no_license | JiancongLee/Anze | 1f0d7875bcfacb493c324b44fec7316f384d0711 | 1d94e7121e07417fce4c04f514d8d54f701c9971 | refs/heads/master | 2022-12-10T18:56:59.706709 | 2019-06-04T06:55:19 | 2019-06-04T06:55:19 | 167,913,424 | 0 | 1 | null | 2022-12-06T00:39:58 | 2019-01-28T06:52:18 | Java | UTF-8 | Java | false | false | 1,214 | java | package cn.config.common;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
/**
* 生成验证码配置
*
* @author chenshun
* @email [email protected]
* @date 2017-04-20 19:22
*/
@Configuration
public class KaptchaConfig {
@Bean
public DefaultKaptcha producer() {
Properties properties = new Properties();
properties.put("kaptcha.border", "no");
properties.put("kaptcha.textproducer.font.color", "black");
properties.put("kaptcha.session.key", "code");
properties.put("kaptcha.textproducer.char.length", "4");
properties.put("kaptcha.image.width", "100");
properties.put("kaptcha.image.height", "36");
properties.put("kaptcha.textproducer.font.size", "30");
properties.put("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
| [
"[email protected]"
]
| |
d489ca95794bd031aafe5be1b0cf201a4a72e4e7 | 9524b96ac77544adce7f944f17a53af534994b56 | /reactive/src/main/java/com/tvd12/example/reactive/service/MemberService.java | d057202232ae48efcbd1a5156d8051d21d1946a3 | []
| no_license | tvd12/java-examples | 9cfa38dc091ef8b78e2d9951fb09165358de673a | 0c28a22c5725cf71f5a6187c80231f7ae3ecf49d | refs/heads/master | 2023-08-13T12:28:17.926814 | 2023-08-13T08:07:33 | 2023-08-13T08:07:33 | 139,684,064 | 6 | 7 | null | 2022-05-15T03:57:53 | 2018-07-04T07:20:17 | Java | UTF-8 | Java | false | false | 391 | java | package com.tvd12.example.reactive.service;
import com.tvd12.example.common.JsonReader;
import com.tvd12.example.reactive.data.Member;
import com.tvd12.ezyfox.bean.annotation.EzySingleton;
import java.util.List;
@EzySingleton
public class MemberService {
public List<Member> getNewPublicMembers() {
return JsonReader.readList("new_public_members.json", Member.class);
}
}
| [
"[email protected]"
]
| |
86f3e6eeaa751a803cac9774e835e289f888c7a9 | e5c429b59c6d2fa8671a420808d76f133860342e | /app/src/androidTest/java/com/jackchen/view_day09_2/ExampleInstrumentedTest.java | 311fc9932aff1c1c8ce857ee662b6dce6d8a5bd8 | []
| no_license | shuai999/View_day9_2 | 30bdae4ddcde77414a830253b2a1efad97ad67d7 | 3cb0f8d1659ae3c0e8db340e05407f93d85ec2d8 | refs/heads/master | 2021-04-15T15:03:59.744167 | 2018-03-26T03:13:43 | 2018-03-26T03:13:43 | 126,767,035 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 754 | java | package com.jackchen.view_day09_2;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.jackchen.view_day09_2", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
6c24ea5964ec245449b8cbc0b90d1997a1c29169 | f9aaf2fbb1f34f1a505e0b2bfcd18b2f5765e935 | /src/main/java/fr/entite/Classe.java | a9a236570dc27c16780cdf073d3c04a281fdb0c8 | []
| no_license | Russki35/jpa | ec352d21f609e2ab795737b11cb49a335f374037 | 8d4fe99184d64cdcb8498f57049bc71071a5311f | refs/heads/master | 2021-05-15T15:39:31.317732 | 2017-10-18T14:34:09 | 2017-10-18T14:34:09 | 107,407,061 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 481 | java | /**
*
*/
package fr.entite;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
* @author ETY8
*
*/
public class Classe {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@Column(name="nom")
private String nom;
public Classe() {
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
}
| [
"[email protected]"
]
| |
af8d891a54e1769a888a8b88135a0c80b23592f4 | 966d7c757e65e2d0e015cd3ecc95aa811103746e | /java/com/cc/accelerator/logging/EntryExitLogger.java | 80308976ff4cf762be4bd6379571cf392e4ef591 | []
| no_license | yashbujji/Java-microservice | 364d3e188a3e09fca69b4144e216b77a902ce570 | 9fc4ef583cc70b548350d12008dbcc361725d3ca | refs/heads/main | 2023-01-18T16:18:58.365711 | 2020-11-25T04:59:25 | 2020-11-25T04:59:25 | 315,832,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 321 | java | package com.cc.accelerator.logging;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target({ METHOD })
public @interface EntryExitLogger {
}
| [
"[email protected]"
]
| |
5de26ea00f77332c5e7e4aa639a71e8ddb6ba093 | e6fef6eb073c08bfcbb3c3df5e48d8889b3ff837 | /src/main/java/com/catt/oauth2authserver/controller/RestfulApiProviderController.java | ef08cce765fb77167f42f52950c28e68e81120a6 | []
| no_license | fishKit/oauth | 198b9900e1e8d99bc87dd944e5f9ea088ff04d9f | 1d749dd4739b0bb82b8627c9fe5677cde6cd3689 | refs/heads/master | 2022-11-20T09:56:52.020507 | 2020-07-25T07:16:46 | 2020-07-25T07:16:46 | 280,235,059 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package com.catt.oauth2authserver.controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @author: Huang Zhi Jie
* @time: 2020/7/23 14:10
*/
@RestController
@RequestMapping("/account")
public class RestfulApiProviderController {
@RequestMapping("/info/{account}")
public String info(@PathVariable("account") String account) {
return "55";
}
@RequestMapping("child/{account}")
public String child(@PathVariable("account") String qq) {
return "56";
}
} | [
"[email protected]"
]
| |
39806d02202a2d693ed2fd7cfe1072560a7e27a9 | 96f8d42c474f8dd42ecc6811b6e555363f168d3e | /baike/sources/qsbk/app/live/ui/dx.java | 59f3a53343e68cdb69d5543093a9cb2a108197a3 | []
| no_license | aheadlcx/analyzeApk | 050b261595cecc85790558a02d79739a789ae3a3 | 25cecc394dde4ed7d4971baf0e9504dcb7fabaca | refs/heads/master | 2020-03-10T10:24:49.773318 | 2018-04-13T09:44:45 | 2018-04-13T09:44:45 | 129,332,351 | 6 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,025 | java | package qsbk.app.live.ui;
import android.graphics.SurfaceTexture;
import android.view.Surface;
import android.view.TextureView.SurfaceTextureListener;
class dx implements SurfaceTextureListener {
final /* synthetic */ LivePullActivity a;
dx(LivePullActivity livePullActivity) {
this.a = livePullActivity;
}
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
this.a.bw = new Surface(surfaceTexture);
this.a.bx = i;
this.a.by = i2;
this.a.j();
this.a.ac();
this.a.J();
}
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
if (this.a.bw != null) {
this.a.bw.release();
this.a.bw = null;
}
this.a.aX = true;
this.a.ad();
return false;
}
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
}
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
}
| [
"[email protected]"
]
| |
7eb4864f226529c0469a523be221aeec2b9dd1a1 | 21cd562a8a6ab0d46c3d4b56afde0434e3a13d58 | /src/test/java/net/sf/json/sample/EmptyBean.java | 47c0178eb40d319e2dc42ac2728648dad7ca07f7 | [
"Apache-2.0"
]
| permissive | thec1024/Json-lib | 1c9734657759558530b78fe4299febe1c1ca3d71 | da0fc3f1dd31896784c289134ff3ceecb216f136 | refs/heads/master | 2020-07-19T17:20:40.093622 | 2019-09-05T06:09:02 | 2019-09-05T06:09:02 | 206,486,084 | 0 | 0 | Apache-2.0 | 2019-09-05T05:58:53 | 2019-09-05T05:58:52 | null | UTF-8 | Java | false | false | 2,354 | java | /*
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sf.json.sample;
import java.util.List;
/**
* @author Andres Almiray <[email protected]>
*/
public class EmptyBean {
private Object[] arrayp;
private Byte bytep;
private Character charp;
private Double doublep;
private Float floatp;
private Integer intp;
private List listp;
private Long longp;
private Short shortp;
private String stringp;
public Object[] getArrayp() {
return arrayp;
}
public Byte getBytep() {
return bytep;
}
public Character getCharp() {
return charp;
}
public Double getDoublep() {
return doublep;
}
public Float getFloatp() {
return floatp;
}
public Integer getIntp() {
return intp;
}
public List getListp() {
return listp;
}
public Long getLongp() {
return longp;
}
public Short getShortp() {
return shortp;
}
public String getStringp() {
return stringp;
}
public void setArrayp( Object[] arrayp ) {
this.arrayp = arrayp;
}
public void setBytep( Byte bytep ) {
this.bytep = bytep;
}
public void setCharp( Character charp ) {
this.charp = charp;
}
public void setDoublep( Double doublep ) {
this.doublep = doublep;
}
public void setFloatp( Float floatp ) {
this.floatp = floatp;
}
public void setIntp( Integer intp ) {
this.intp = intp;
}
public void setListp( List listp ) {
this.listp = listp;
}
public void setLongp( Long longp ) {
this.longp = longp;
}
public void setShortp( Short shortp ) {
this.shortp = shortp;
}
public void setStringp( String stringp ) {
this.stringp = stringp;
}
} | [
"aalmiray"
]
| aalmiray |
01739ec7c33f0b1ed9f378af97b4a0e205c45fe9 | 1c6f76f2347330376cd4440a4cba9c1508ba3d58 | /Java/Collection/ArrayList/MyArrayList.java | a4233df501d4cb3fd27dd5f60036bc52b40584f8 | []
| no_license | aaachuan/Java-Bat | b9d4f4dd1821d6afad55f162a4ac90df41388de5 | 9f9b7806c3e5f06a001afed1a6cd16017e56ebf6 | refs/heads/master | 2023-07-25T17:10:43.429390 | 2022-04-16T10:36:20 | 2022-04-16T10:36:20 | 217,999,530 | 0 | 0 | null | 2023-07-22T19:57:43 | 2019-10-28T08:29:55 | Java | UTF-8 | Java | false | false | 2,625 | java | package com.aaachuan.collection;
import java.util.Arrays;
public class MyArrayList<E> {
private Object[] elementData;
private int size;
private final int DEFAULT_CAPACITY = 10;
private final Object[] emptyArray = {};
public MyArrayList() {
elementData = emptyArray;
}
public MyArrayList(int initsize) {
if (initsize < 0) {
throw new IllegalArgumentException("初始化大小不合法:" + initsize);
} else if (initsize == 0) {
elementData = emptyArray;
} else {
elementData = new Object[initsize];
}
}
public boolean add(E e) {
if (elementData == emptyArray)
elementData = new Object[DEFAULT_CAPACITY];
if (size == elementData.length) {
int oldCapacity = elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
Object[] obj = new Object[newCapacity];
//System.arraycopy(elementData, 0, obj, 0, elementData.length);
for (int i = 0; i < elementData.length; i++) {
obj[i] = elementData[i];
}
elementData = obj;
}
elementData[size++] = e;
return true;
}
public E remove(int index) {
rangeCheck(index);
E value = (E) elementData[index];
for (int i = index+1; i < size; i++) {
elementData[i-1] = elementData[i];
}
elementData[--size] = null;
return value;
}
public E set(int index, E newValue) {
rangeCheck(index);
E value = (E) elementData[index];
elementData[index] = newValue;
return value;
}
public E get(int index) {
rangeCheck(index);
return (E) elementData[index];
}
public void clear() {
for (int i = 0; i < size; i++)
elementData[i] = null;
size = 0;
}
public int getSize() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
private void rangeCheck(int index) {
if (index < 0 || index > size)
throw new ArrayIndexOutOfBoundsException("数组越界");
}
@Override
public String toString() {
if (size == 0)
return "[]";
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < size; i++) {
if (i == size-1) {
sb.append(elementData[i]).append("]");
} else {
sb.append(elementData[i]).append(",");
}
}
return sb.toString();
}
}
| [
"[email protected]"
]
| |
f3907ffcaa69652d7dee4e8427d32dafdfd1dbdb | c537b96fa5713559b8e0bfdb39e8cca734674c40 | /src/typeinfo/pets/Rat.java | 038d45b372f37ec1f586ee9b566d6eb67c5f7088 | []
| no_license | fengwutianya/LearnJava | c211de4dd6112c622216cf5b583efc92167db847 | 015df941eb5a852454238488953930ba857eea5e | refs/heads/master | 2020-05-21T04:39:43.238743 | 2017-09-26T14:57:41 | 2017-09-26T14:57:41 | 55,349,633 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 171 | java | package typeinfo.pets;
/**
* Created by xuan on 2016/8/28.
*/
public class Rat extends Rodent{
public Rat(String name) {super(name);}
public Rat() {super();}
}
| [
"[email protected]"
]
| |
2ddbf7e91d9cdeb8b7641bc4ad95782665f652b2 | 402080a45a6e553362d90d99c98982b9c5deefaf | /src/main/java/com/insurance/dto/Customer.java | 1aa1b3799505629ec2ac3f87633713cbdc71efde | []
| no_license | Neumann1970/demo-insurance | 1fceb310823bd91e1a26a3f3dee22eae263cabe3 | 4744a0625e00359a15d105ce9b9fcecc36b3a7be | refs/heads/master | 2020-04-21T05:01:35.078672 | 2019-02-07T18:11:52 | 2019-02-07T18:11:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 542 | java | package com.insurance.dto;
import org.springframework.data.annotation.Id;
public class Customer {
@Id
public String id;
public String firstName;
public String lastName;
public Customer() {}
public Customer(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public String toString() {
return String.format(
"Customer[id=%s, firstName='%s', lastName='%s']",
id, firstName, lastName);
}
} | [
"[email protected]"
]
| |
2e75bfee5fa3df83bdc1b9b0452ffb958c7dd49d | 4627d514d6664526f58fbe3cac830a54679749cd | /results/evosuite5/mockito-org.mockito.asm.tree.analysis.BasicVerifier-14/org/mockito/asm/tree/analysis/BasicVerifier_ESTest_scaffolding.java | 32c73c276067322bd2aa7f70558281a99a1ca0a9 | []
| no_license | STAMP-project/Cling-application | c624175a4aa24bb9b29b53f9b84c42a0f18631bd | 0ff4d7652b434cbfd9be8d8bb38cfc8d8eaa51b5 | refs/heads/master | 2022-07-27T09:30:16.423362 | 2022-07-19T12:01:46 | 2022-07-19T12:01:46 | 254,310,667 | 2 | 2 | null | 2021-07-12T12:29:50 | 2020-04-09T08:11:35 | null | UTF-8 | Java | false | false | 6,566 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Wed Aug 21 15:38:52 GMT 2019
*/
package org.mockito.asm.tree.analysis;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
import org.junit.AfterClass;
import org.evosuite.runtime.sandbox.Sandbox;
import org.evosuite.runtime.sandbox.Sandbox.SandboxMode;
@EvoSuiteClassExclude
public class BasicVerifier_ESTest_scaffolding {
@org.junit.Rule
public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone();
private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
@BeforeClass
public static void initEvoSuiteFramework() {
org.evosuite.runtime.RuntimeSettings.className = "org.mockito.asm.tree.analysis.BasicVerifier";
org.evosuite.runtime.GuiSupport.initialize();
org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
org.evosuite.runtime.classhandling.JDKClassResetter.init();
setSystemProperties();
initializeClasses();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
}
@AfterClass
public static void clearEvoSuiteFramework(){
Sandbox.resetDefaultSecurityManager();
java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
}
@Before
public void initTestCase(){
threadStopper.storeCurrentThreads();
threadStopper.startRecordingTime();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
setSystemProperties();
org.evosuite.runtime.GuiSupport.setHeadless();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
org.evosuite.runtime.agent.InstrumentingAgent.activate();
}
@After
public void doneWithTestCase(){
threadStopper.killAndJoinClientThreads();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
org.evosuite.runtime.classhandling.JDKClassResetter.reset();
resetClasses();
org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
}
public static void setSystemProperties() {
java.lang.System.setProperties((java.util.Properties) defaultProperties.clone());
java.lang.System.setProperty("user.dir", "/home/pderakhshanfar/rq3/botsing-integration-experiment");
java.lang.System.setProperty("java.io.tmpdir", "/tmp");
}
private static void initializeClasses() {
org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BasicVerifier_ESTest_scaffolding.class.getClassLoader() ,
"org.mockito.asm.tree.LineNumberNode",
"org.mockito.asm.tree.LdcInsnNode",
"org.mockito.asm.tree.analysis.AnalyzerException",
"org.mockito.asm.ClassReader",
"org.mockito.asm.Type",
"org.mockito.asm.tree.IntInsnNode",
"org.mockito.asm.tree.VarInsnNode",
"org.mockito.asm.tree.FrameNode",
"org.mockito.asm.tree.analysis.BasicInterpreter",
"org.mockito.asm.MethodWriter",
"org.mockito.asm.tree.analysis.BasicValue",
"org.mockito.asm.tree.InsnNode",
"org.mockito.asm.tree.analysis.Interpreter",
"org.mockito.asm.Opcodes",
"org.mockito.asm.tree.LabelNode",
"org.mockito.asm.tree.AbstractInsnNode",
"org.mockito.asm.tree.FieldInsnNode",
"org.mockito.asm.Label",
"org.mockito.asm.tree.analysis.SourceValue",
"org.mockito.asm.Attribute",
"org.mockito.asm.AnnotationVisitor",
"org.mockito.asm.tree.MultiANewArrayInsnNode",
"org.mockito.asm.ByteVector",
"org.mockito.asm.tree.IincInsnNode",
"org.mockito.asm.tree.analysis.Value",
"org.mockito.asm.Item",
"org.mockito.asm.tree.analysis.BasicVerifier",
"org.mockito.asm.ClassVisitor",
"org.mockito.asm.FieldVisitor",
"org.mockito.asm.MethodVisitor",
"org.mockito.asm.Frame",
"org.mockito.asm.tree.JumpInsnNode",
"org.mockito.asm.MethodAdapter",
"org.mockito.asm.tree.TableSwitchInsnNode",
"org.mockito.asm.tree.LookupSwitchInsnNode",
"org.mockito.asm.ClassWriter",
"org.mockito.asm.tree.MethodInsnNode",
"org.mockito.asm.tree.TypeInsnNode",
"org.mockito.asm.tree.analysis.SmallSet"
);
}
private static void resetClasses() {
org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(BasicVerifier_ESTest_scaffolding.class.getClassLoader());
org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
"org.mockito.asm.tree.analysis.BasicInterpreter",
"org.mockito.asm.tree.analysis.BasicVerifier",
"org.mockito.asm.Opcodes",
"org.mockito.asm.Type",
"org.mockito.asm.tree.analysis.BasicValue",
"org.mockito.asm.Label",
"org.mockito.asm.tree.AbstractInsnNode",
"org.mockito.asm.tree.LabelNode",
"org.mockito.asm.tree.LineNumberNode",
"org.mockito.asm.tree.FrameNode",
"org.mockito.asm.tree.MethodInsnNode",
"org.mockito.asm.tree.LdcInsnNode",
"org.mockito.asm.tree.IntInsnNode",
"org.mockito.asm.tree.FieldInsnNode",
"org.mockito.asm.tree.analysis.SourceValue",
"org.mockito.asm.tree.InsnNode",
"org.mockito.asm.tree.analysis.SmallSet",
"org.mockito.asm.tree.VarInsnNode",
"org.mockito.asm.tree.TypeInsnNode",
"org.mockito.asm.tree.MultiANewArrayInsnNode",
"org.mockito.asm.tree.analysis.AnalyzerException",
"org.mockito.asm.tree.JumpInsnNode",
"org.mockito.asm.tree.IincInsnNode",
"org.mockito.asm.MethodAdapter",
"org.mockito.asm.tree.TableSwitchInsnNode",
"org.mockito.asm.tree.LookupSwitchInsnNode",
"org.mockito.asm.Attribute"
);
}
}
| [
"[email protected]"
]
| |
91e4576ca756692709af69e855a91933cea74f9c | 7ca791621597a485fc61d0b42f7f985488bd08c5 | /src/main/java/entropy/vjob/builder/ValTree.java | cf9b800b7eea9faca603659757580c44fcb48e10 | []
| no_license | julien-marchand/BestPlace | f15e9a56cbacff3678cd41337b564e57b78cbf33 | 40093829ace24592275984048b9ee9709529aa63 | refs/heads/master | 2020-04-25T21:28:22.503835 | 2014-02-12T15:45:28 | 2014-02-12T15:59:56 | 15,740,832 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,048 | java | /*
* Copyright (c) 2010 Ecole des Mines de Nantes.
*
* This file is part of Entropy.
*
* Entropy is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Entropy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Entropy. If not, see <http://www.gnu.org/licenses/>.
*/
package entropy.vjob.builder;
import org.antlr.runtime.Token;
import entropy.configuration.Node;
import entropy.configuration.VirtualMachine;
/**
* A Tree parser to identify a virtual machine or a node.
*
* @author Fabien Hermenier
*/
public class ValTree extends VJobTree {
/**
* The builder to make the element.
*/
private VJobElementBuilder elemBuilder;
/**
* Make a new parser.
*
* @param t the token to analyze
* @param errs the errors to report
* @param eb the builder to make the element
*/
public ValTree(Token t, SemanticErrors errs, VJobElementBuilder eb) {
super(t, errs);
this.elemBuilder = eb;
}
@Override
public Content go(VJobTree parent) {
String lbl = token.getText();
VirtualMachine vm = elemBuilder.matchAsVirtualMachine(lbl);
if (vm != null) {
return new Content(Content.Type.vm, vm);
}
Node n = elemBuilder.matchAsNode(lbl);
if (n != null) {
return new Content(Content.Type.node, n);
}
return ignoreError("element " + lbl + " is not a virtual machine nor a node");
}
}
| [
"[email protected]"
]
| |
479bcce543fa01f1287293b08691f78427f6daca | 6f250e1a7ddc213aff4ff68558c95d01391365c5 | /BaseStudy_SE/java_Core/src/java_Core3/Map/HasMapDemo1.java | f5f22460f8b9778f09bcc44015375195813fcc0b | []
| no_license | yufeng218/java_code | 16b68b8783efd0fc7cf968750cacd4bb6f9eaf0a | ac96f7a07cbc163cd1e8222403a3919d165574b6 | refs/heads/master | 2021-01-01T05:27:20.737636 | 2017-03-03T18:20:52 | 2017-03-03T18:20:52 | 57,600,160 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 1,692 | java | package java_Core3.Map;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class HasMapDemo1 {
public static void main(String[] args) {
User u1 = new User("001", "zhangsan", 20, "1234");
User u2 = new User("002", "lisi", 21, "6789");
User u3 = new User("003", "wangwu",22,"9876");
HashMap hm = new HashMap();
hm.put(u1.getId(), u1);
hm.put(u2.getId(), u2);
hm.put(u3.getId(), u3);
System.out.println(hm.size());
//直接打印Map对象会打印:key的toString方法 = value的toString方法
System.out.println(hm);
//key,value都是Object; get(key)得到value;
User user1 = (User)hm.get(u1.getId());
System.out.println(user1);
//是否包含某个key, 还有是否包含某个value
System.out.println(hm.containsKey("003"));
System.out.println(hm.containsKey("004"));
System.out.println("========= 遍历方式 ============");
/*
* 遍历方式1:把Map中所有的key放入Set集合中,然后遍历Set集合得到key,
* 通过key获得value;
*/
Set set = hm.keySet();
for(Object x : set) {
String key = (String)x;
User user2 = (User)hm.get(key);
System.out.println(key + "=" + user2);
}
/*
* 遍历方式2:放入HashMap集合中的key和value,
* 其实都被包装成Map.Entry这个内部类的属性;
* 有一个键值对就存在一个Map.Entry的实例对象;
* 通过entrySet()方法就可以把这些实例对象放入Set集合中;
*/
Set s1 = hm.entrySet();
for(Object x : s1) {
Map.Entry me = (Map.Entry)x;
System.out.println(me.getKey() + "=" + me.getValue());
}
}
}
| [
"[email protected]"
]
| |
2c9d187d4737eb994668b396ace56c87786ebe15 | ea0b9a2b67080902239990de15e31dcf6eb9c1ad | /src/main/java/com/smallflyingleg/controller/PageController.java | 8b955224ca590925a923685366c5afa2baa15e20 | []
| no_license | wdx13666/smallflyingleg | af512ceb1156f7504b81a96242e98367605aabbd | 62181eb6173f58c6af2fe5ad0eee7abd552d2d83 | refs/heads/master | 2020-05-07T13:35:13.833497 | 2019-06-23T05:19:36 | 2019-06-23T05:19:36 | 180,555,237 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package com.smallflyingleg.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class PageController {
/**
* 权限列表
* @return
*/
@GetMapping("/permission")
public String permission(){
return "permission/permission-list";
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.