blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
59a1720399be3a161882ebb6d70215f479f85b9f
| 11,089,605,622,561 |
26b9c21869aab522c08aa4a33977e2ec1f421b4f
|
/src/main/java/cz/tomek/fcblesno/repository/LocationRepository.java
|
509b1c74f0ebe9d2e85d2dadb795326220f296d4
|
[] |
no_license
|
tomkre/fcblesno-public
|
https://github.com/tomkre/fcblesno-public
|
a7b45d76b56232f16ada5719bfeaa3d2955b45f3
|
77f10c690326104c7b1cf6cf468e05545514d189
|
refs/heads/master
| 2023-06-17T15:46:29.913000 | 2021-07-07T16:59:03 | 2021-07-07T16:59:03 | 383,860,931 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cz.tomek.fcblesno.repository;
import cz.tomek.fcblesno.model.Location;
/**
* Location repository.
*
* @author tomek
*
*/
public interface LocationRepository extends AppEntityRepository<Location> {
}
|
UTF-8
|
Java
| 210 |
java
|
LocationRepository.java
|
Java
|
[
{
"context": ".Location;\n\n/**\n* Location repository.\n*\n* @author tomek\n*\n*/\npublic interface LocationRepository extends ",
"end": 125,
"score": 0.9987800121307373,
"start": 120,
"tag": "USERNAME",
"value": "tomek"
}
] | null |
[] |
package cz.tomek.fcblesno.repository;
import cz.tomek.fcblesno.model.Location;
/**
* Location repository.
*
* @author tomek
*
*/
public interface LocationRepository extends AppEntityRepository<Location> {
}
| 210 | 0.771429 | 0.771429 | 13 | 15.153846 | 22.072769 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | false | false |
13
|
9820c962983177808277a26e169a43b615f7271b
| 283,467,901,768 |
a8b70bf45293cc0cfeb7272f500606e53b90206c
|
/gitlogtask5/src/main/java/logging/interest.java
|
c9680080048beee34e82ce7a8811bce707f649b3
|
[
"Apache-2.0"
] |
permissive
|
Jyotsnakesiraju/logging
|
https://github.com/Jyotsnakesiraju/logging
|
3dac1b9c1b3b8bbcb328eaa282fdc3f8def2f6c2
|
d2430714a3d678e0f63682fb0df469aede5fb4da
|
refs/heads/master
| 2021-01-26T05:59:22.666000 | 2020-02-26T18:58:33 | 2020-02-26T18:58:33 | 243,337,124 | 0 | 0 |
Apache-2.0
| false | 2020-10-13T19:53:09 | 2020-02-26T18:36:19 | 2020-02-26T18:58:38 | 2020-10-13T19:53:07 | 9 | 0 | 0 | 1 |
Java
| false | false |
package logging;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/*
<applet code=”Interest_Calc” width=450 height=300>
</applet>
*/
public class interest extends Applet implements ActionListener {
/**
*
*/
private static final Logger LOGGER=LogManager.getLogger(interest.class);
private static final long serialVersionUID = 1L;
JButton B_1;
JButton B_2;
JTextField T_1,T_2,T_3,T_4,T_5;
JLabel L_1,L_2,L_3;
JPanel p;
public void init()
{
// TODO start asynchronous download of heavy resources
L_1=new JLabel("principle amount");
L_2=new JLabel("time period");
L_3=new JLabel("rate of interest");
B_1=new JButton("simple interest");
B_2=new JButton("compound interest");
T_1=new JTextField();
T_2=new JTextField();
T_3=new JTextField();
T_4=new JTextField();
T_5=new JTextField();
this.setLayout(new GridLayout(5,2));
this.add(L_1);
this.add(T_1);
this.add(L_2);
this.add(T_2);
this.add(L_3);
this.add(T_3);
this.add(B_1);
this.add(T_4);
this.add(B_2);
this.add(T_5);
B_1.addActionListener(this);
B_2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
double principleamount,timeperiod,rateofinterest,simpleinterest,compoundinterest;
principleamount=Double.parseDouble(T_1.getText());
timeperiod=Double.parseDouble(T_2.getText());
rateofinterest=Double.parseDouble(T_3.getText());
if (ae.getSource()==B_1)
{
simpleinterest=(principleamount*timeperiod*rateofinterest)/100.0;
T_4.setText(String.valueOf(simpleinterest));
}
else if(ae.getSource()==B_2)
{
compoundinterest=(principleamount*(Math.pow((1+(rateofinterest/100.0)),timeperiod)));
T_5.setText(String.valueOf(compoundinterest));
}
LOGGER.info("PRINCIPAL AMOUNT:"+T_1.getText());
LOGGER.info("TIME PERIOD:"+T_2.getText());
LOGGER.info("RATE OF INTERESTS:"+T_3.getText());
LOGGER.info("SIMPLE INTEREST:"+T_4.getText());
LOGGER.info("COMPOUND INTEREST:"+T_5.getText());
}
}
|
WINDOWS-1250
|
Java
| 1,993 |
java
|
interest.java
|
Java
|
[] | null |
[] |
package logging;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/*
<applet code=”Interest_Calc” width=450 height=300>
</applet>
*/
public class interest extends Applet implements ActionListener {
/**
*
*/
private static final Logger LOGGER=LogManager.getLogger(interest.class);
private static final long serialVersionUID = 1L;
JButton B_1;
JButton B_2;
JTextField T_1,T_2,T_3,T_4,T_5;
JLabel L_1,L_2,L_3;
JPanel p;
public void init()
{
// TODO start asynchronous download of heavy resources
L_1=new JLabel("principle amount");
L_2=new JLabel("time period");
L_3=new JLabel("rate of interest");
B_1=new JButton("simple interest");
B_2=new JButton("compound interest");
T_1=new JTextField();
T_2=new JTextField();
T_3=new JTextField();
T_4=new JTextField();
T_5=new JTextField();
this.setLayout(new GridLayout(5,2));
this.add(L_1);
this.add(T_1);
this.add(L_2);
this.add(T_2);
this.add(L_3);
this.add(T_3);
this.add(B_1);
this.add(T_4);
this.add(B_2);
this.add(T_5);
B_1.addActionListener(this);
B_2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
double principleamount,timeperiod,rateofinterest,simpleinterest,compoundinterest;
principleamount=Double.parseDouble(T_1.getText());
timeperiod=Double.parseDouble(T_2.getText());
rateofinterest=Double.parseDouble(T_3.getText());
if (ae.getSource()==B_1)
{
simpleinterest=(principleamount*timeperiod*rateofinterest)/100.0;
T_4.setText(String.valueOf(simpleinterest));
}
else if(ae.getSource()==B_2)
{
compoundinterest=(principleamount*(Math.pow((1+(rateofinterest/100.0)),timeperiod)));
T_5.setText(String.valueOf(compoundinterest));
}
LOGGER.info("PRINCIPAL AMOUNT:"+T_1.getText());
LOGGER.info("TIME PERIOD:"+T_2.getText());
LOGGER.info("RATE OF INTERESTS:"+T_3.getText());
LOGGER.info("SIMPLE INTEREST:"+T_4.getText());
LOGGER.info("COMPOUND INTEREST:"+T_5.getText());
}
}
| 1,993 | 0.733032 | 0.700855 | 83 | 22.963856 | 21.085852 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.795181 | false | false |
13
|
8e3d4bec8bb5239a4d156d11f731ccb551c3ca4b
| 3,195,455,700,001 |
0d0459dc3e37180dcb2e5ff31298877ada6598e1
|
/DanmarWeb/src/main/java/com/facturador/danmar/form/mapper/DocumentoImpuestoMapper.java
|
4bf79668d92bdf7c32feb772a17e40293f7f52eb
|
[] |
no_license
|
kaloyero/Danmar
|
https://github.com/kaloyero/Danmar
|
5c7739bc8ae133d070101d036e8d9e15b3e27271
|
136a110ecaef217aa02bce33a5c61aaf1b080313
|
refs/heads/master
| 2021-01-21T04:47:11.823000 | 2016-06-08T19:39:56 | 2016-06-08T19:39:56 | 45,519,222 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.facturador.danmar.form.mapper;
import com.danmar.utils.ConvertionUtil;
import com.danmar.utils.FormatUtil;
import com.facturador.danmar.form.DocumentoImpuestoForm;
import com.facturador.danmar.model.DocumentoImpuesto;
public class DocumentoImpuestoMapper extends MapperImpl<DocumentoImpuesto,DocumentoImpuestoForm>{
public DocumentoImpuesto getEntidad(DocumentoImpuestoForm form) {
DocumentoImpuesto ent = new DocumentoImpuesto();
if (form != null){
ent.setId(form.getId());
// ent.setDocumentoLineaId(form.get);
ent.setAlicuota(ConvertionUtil.DouValueOf(form.getAlicuota()));
ent.setImporte(ConvertionUtil.DouValueOf(form.getImporte()));
}
return ent;
}
public DocumentoImpuestoForm getForm(DocumentoImpuesto ent) {
DocumentoImpuestoForm form =new DocumentoImpuestoForm();
if (ent != null){
form.setId(ent.getId());
form.setAlicuota(FormatUtil.format4DecimalsStr(ent.getAlicuota()));
form.setAlicuotaNum(ent.getAlicuota());
form.setImporte(FormatUtil.format4DecimalsStr(ent.getImporte()));
}
return form;
}
}
|
UTF-8
|
Java
| 1,079 |
java
|
DocumentoImpuestoMapper.java
|
Java
|
[] | null |
[] |
package com.facturador.danmar.form.mapper;
import com.danmar.utils.ConvertionUtil;
import com.danmar.utils.FormatUtil;
import com.facturador.danmar.form.DocumentoImpuestoForm;
import com.facturador.danmar.model.DocumentoImpuesto;
public class DocumentoImpuestoMapper extends MapperImpl<DocumentoImpuesto,DocumentoImpuestoForm>{
public DocumentoImpuesto getEntidad(DocumentoImpuestoForm form) {
DocumentoImpuesto ent = new DocumentoImpuesto();
if (form != null){
ent.setId(form.getId());
// ent.setDocumentoLineaId(form.get);
ent.setAlicuota(ConvertionUtil.DouValueOf(form.getAlicuota()));
ent.setImporte(ConvertionUtil.DouValueOf(form.getImporte()));
}
return ent;
}
public DocumentoImpuestoForm getForm(DocumentoImpuesto ent) {
DocumentoImpuestoForm form =new DocumentoImpuestoForm();
if (ent != null){
form.setId(ent.getId());
form.setAlicuota(FormatUtil.format4DecimalsStr(ent.getAlicuota()));
form.setAlicuotaNum(ent.getAlicuota());
form.setImporte(FormatUtil.format4DecimalsStr(ent.getImporte()));
}
return form;
}
}
| 1,079 | 0.774791 | 0.772938 | 37 | 28.18919 | 27.749689 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.810811 | false | false |
13
|
96ac501238d05d55786ec14368da7e841f04ff6f
| 16,758,962,449,605 |
c960d90545af4f7747feda69f5b3013f6509eb4b
|
/mainProject/src/main/java/com/six/web/board/AskBoardServiceImpl.java
|
f5419b690793eb60c09ba96734def9b8a5fc3c3b
|
[] |
no_license
|
akffoddl5/test
|
https://github.com/akffoddl5/test
|
82ff6c36b708f75af8607aae9ca87aa29f7858fc
|
e50fb33aa057b78d92337f3e6ecb29dfb23e4af2
|
refs/heads/master
| 2022-12-20T20:50:01.586000 | 2020-02-10T04:18:21 | 2020-02-10T04:18:21 | 228,166,486 | 0 | 0 | null | false | 2022-12-16T15:24:35 | 2019-12-15T10:31:49 | 2020-02-10T04:18:34 | 2022-12-16T15:24:33 | 4,092 | 0 | 0 | 5 |
HTML
| false | false |
package com.six.web.board;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AskBoardServiceImpl implements AskBoardService {
@Autowired
private AskBoardDAO askBoardDAO;
@Override
public void insertBoard(AskBoardVO vo) {
askBoardDAO.insertBoard(vo);
}
@Override
public AskBoardVO getBoard(AskBoardVO vo) {
//
return null;
}
}
|
UTF-8
|
Java
| 430 |
java
|
AskBoardServiceImpl.java
|
Java
|
[] | null |
[] |
package com.six.web.board;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AskBoardServiceImpl implements AskBoardService {
@Autowired
private AskBoardDAO askBoardDAO;
@Override
public void insertBoard(AskBoardVO vo) {
askBoardDAO.insertBoard(vo);
}
@Override
public AskBoardVO getBoard(AskBoardVO vo) {
//
return null;
}
}
| 430 | 0.781395 | 0.781395 | 23 | 17.695652 | 20.182718 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.956522 | false | false |
13
|
ac8ef2e0efd6a0de384ea136af069c7d0daf0b2c
| 17,703,855,250,240 |
5913ccc23b6557c4cfe46be33b0b156943b8f3af
|
/Entropy Simulation v0.03/src/masterPackage/Queues.java
|
dbca3e99433cfb0be9827bf7fe74e87195be1fe8
|
[] |
no_license
|
Sciencegeek123/EntropySimulation
|
https://github.com/Sciencegeek123/EntropySimulation
|
114ed82258dc930e48c6149a02f84ae857975945
|
37ff7aad05c21e70e466dc0406bb5b4ee647eb36
|
refs/heads/master
| 2016-03-28T18:51:23.765000 | 2013-06-22T03:01:36 | 2013-06-22T03:01:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package masterPackage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
public class Queues {
public static LinkedBlockingQueue<ParticleObject> Preprocessing = new LinkedBlockingQueue<ParticleObject>();
public static LinkedBlockingQueue<ParticleObject> Postprocessing = new LinkedBlockingQueue<ParticleObject>();
public static HashMap<Integer , ParticleObject> ParticleMasterList;
public static synchronized void UpdateParticleMap()
{
}
}
|
UTF-8
|
Java
| 585 |
java
|
Queues.java
|
Java
|
[] | null |
[] |
package masterPackage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
public class Queues {
public static LinkedBlockingQueue<ParticleObject> Preprocessing = new LinkedBlockingQueue<ParticleObject>();
public static LinkedBlockingQueue<ParticleObject> Postprocessing = new LinkedBlockingQueue<ParticleObject>();
public static HashMap<Integer , ParticleObject> ParticleMasterList;
public static synchronized void UpdateParticleMap()
{
}
}
| 585 | 0.818803 | 0.818803 | 21 | 26.857143 | 33.625793 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false |
13
|
1d6e87d65b63e4944b5a3c0a2373bc70bb7aa4c2
| 16,080,357,613,695 |
b240532b7bde3b044ee715c587048cf402a7dd9f
|
/MuleVersion/zabbixapi.java
|
c46ae1268b2f1e20346bddde509f1d97eee4fd9b
|
[] |
no_license
|
goncaezgicakir/CSE343Monitoring
|
https://github.com/goncaezgicakir/CSE343Monitoring
|
251402d0b7403be7b1e984a4005577cee7d077ea
|
2522f89e5f01801ff74147fd0f0b789189659634
|
refs/heads/master
| 2021-01-08T22:19:30.295000 | 2020-01-13T13:14:26 | 2020-01-13T13:14:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package MonitoringPackage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
public class zabbixapi {
public static InputStream login(String username,String password){
String login = "{\"jsonrpc\":\"2.0\",\"method\":\"user.login\",\"params\":{\"user\":\""+username+"\",\"password\":\""+password+"\"},\"id\":1}";
//return login;
return fromString(login);
}
public static InputStream get_host(String host , String auth){
String gethost = "{ \"jsonrpc\" : \"2.0\" , \"method\" : \"host.get\", \"params\" : { \"filter\" : { \"host\" : [ \""+host+"\"]}},\"auth\": \""+auth+"\",\"id\" : 1}";
return fromString(gethost);
}
public static InputStream create_item(String app , String key , String hostid , String interfaceid , String[] application , String delay , String auth){
String createitem = "{\"jsonrpc\" : \"2.0\" , \"method\" : \"item.create\",\"params\": { \"name\": \""+app+"\",";
createitem += "\"key_\": \""+key+"\", \"hostid\" : \""+hostid+"\", \"type\": 0 ,\"value_type\": 3,\"interfaceid\": \""+interfaceid+"\", ";
if(application != null){
createitem += "\"applications\": [ " ;
for (int i = 0 ; i < application.length ; i++){
if((application.length - i ) > 1){
createitem += "\""+application[i]+"\" ," ;
}
else{
createitem += "\""+application[i]+"\"]," ;
}
}
}
createitem += "\"delay\": 30 },";
createitem += "\"auth\": \""+auth+"\",\"id\": 1}";
return fromString(createitem);
}
public static InputStream create_item_cpu(String app , String hostid , String interfaceid , String[] application , String delay , String auth ){
return create_item(app+" CPU Usage" , "proc.cpu.util["+app+"]" , hostid , interfaceid , application , delay ,auth);
}
public static InputStream create_item_mem(String app , String hostid , String interfaceid , String[] application , String delay , String auth ){
return create_item(app+" Memory Usage" , "proc.mem["+app+"]" , hostid , interfaceid , application , delay ,auth);
}
public static InputStream get_interfaceid (String hostid , String auth){
String getinterface = "{ \"jsonrpc\": \"2.0\" , \"method\" : \"hostinterface.get\", \"params\": { \"output\": \"extend\", \"hostids\": \""+hostid+"\"},";
getinterface += "\"auth\": \""+auth+"\",\"id\": 1} ";
return fromString(getinterface);
}
public static InputStream create_graph(String name , String auth , String itemid){
String creategraph = "{ \"jsonrpc\": \"2.0\", \"method\": \"graph.create\",\"params\": {\"name\": \""+name+"\",\"gitems\":";
creategraph += "[ {\"itemid\": \""+itemid+"\",\"color\": \"00AA00\" }]},\"auth\": \""+auth+"\",\"id\": 1 }";
return fromString(creategraph);
}
public static InputStream creeate_host(String ip , String name, String auth){ // the ip represents the host name here
// return create_host(ip,auth,name ,groups("1"),interfaces("127.0.0.1","10050"));
return fromString(create_host(ip,auth, name, groups("1"),interfaces("127.0.0.1","10050")));
}
private static String create_host( String IP , String auth ,String host, String group , String interfaces ){
String create_host = "{ \"jsonrpc\": \"2.0\", \"method\": \"host.create\", \"params\": { \"host\": \""+host+"\",";
create_host += interfaces + "," + group + "},";
create_host += "\"auth\": \""+auth+"\",\"id\":\"1\"}";
return create_host ;
}
private static String interfaces(String ip , String port){
String interfaces = "\"interfaces\":[{ \"type\" : 1 , \"main\" : 1 , \"useip\" : 1 , \"ip\" : \""+ip+"\" , \"dns\" : \"\" , \"port\" : \""+port+"\" }]";
return interfaces;
}
private static String groups (String groupid){
String groups = "\"groups\": [{ \"groupid\" : \""+groupid+"\" }]";
return groups ;
}
public static InputStream delete_host(String hostid , String auth){
String deletehost = " { \"jsonrpc\": \"2.0\",\"method\": \"host.delete\",\"params\": [\""+hostid+"\"],\"auth\": \""+auth+"\",\"id\": 1 } ";
//return deletehost ;
return fromString(deletehost);
}
private static InputStream fromString(String str){
byte[] bytes ;
try {
bytes = str.getBytes("UTF-8");
return new ByteArrayInputStream(bytes);
}catch (UnsupportedEncodingException e){
System.out.println(e);
}
return null;
}
}
|
UTF-8
|
Java
| 4,738 |
java
|
zabbixapi.java
|
Java
|
[
{
"context": "ams\\\":{\\\"user\\\":\\\"\"+username+\"\\\",\\\"password\\\":\\\"\"+password+\"\\\"},\\\"id\\\":1}\";\n //return login;\n ",
"end": 369,
"score": 0.7278339862823486,
"start": 361,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "create_host(ip,auth,name ,groups(\"1\"),interfaces(\"127.0.0.1\",\"10050\"));\n return fromString(create_host",
"end": 3207,
"score": 0.9996997117996216,
"start": 3198,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
},
{
"context": "reate_host(ip,auth, name, groups(\"1\"),interfaces(\"127.0.0.1\",\"10050\")));\n }\n\n private static String cre",
"end": 3306,
"score": 0.9996986389160156,
"start": 3297,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
}
] | null |
[] |
package MonitoringPackage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
public class zabbixapi {
public static InputStream login(String username,String password){
String login = "{\"jsonrpc\":\"2.0\",\"method\":\"user.login\",\"params\":{\"user\":\""+username+"\",\"password\":\""+<PASSWORD>+"\"},\"id\":1}";
//return login;
return fromString(login);
}
public static InputStream get_host(String host , String auth){
String gethost = "{ \"jsonrpc\" : \"2.0\" , \"method\" : \"host.get\", \"params\" : { \"filter\" : { \"host\" : [ \""+host+"\"]}},\"auth\": \""+auth+"\",\"id\" : 1}";
return fromString(gethost);
}
public static InputStream create_item(String app , String key , String hostid , String interfaceid , String[] application , String delay , String auth){
String createitem = "{\"jsonrpc\" : \"2.0\" , \"method\" : \"item.create\",\"params\": { \"name\": \""+app+"\",";
createitem += "\"key_\": \""+key+"\", \"hostid\" : \""+hostid+"\", \"type\": 0 ,\"value_type\": 3,\"interfaceid\": \""+interfaceid+"\", ";
if(application != null){
createitem += "\"applications\": [ " ;
for (int i = 0 ; i < application.length ; i++){
if((application.length - i ) > 1){
createitem += "\""+application[i]+"\" ," ;
}
else{
createitem += "\""+application[i]+"\"]," ;
}
}
}
createitem += "\"delay\": 30 },";
createitem += "\"auth\": \""+auth+"\",\"id\": 1}";
return fromString(createitem);
}
public static InputStream create_item_cpu(String app , String hostid , String interfaceid , String[] application , String delay , String auth ){
return create_item(app+" CPU Usage" , "proc.cpu.util["+app+"]" , hostid , interfaceid , application , delay ,auth);
}
public static InputStream create_item_mem(String app , String hostid , String interfaceid , String[] application , String delay , String auth ){
return create_item(app+" Memory Usage" , "proc.mem["+app+"]" , hostid , interfaceid , application , delay ,auth);
}
public static InputStream get_interfaceid (String hostid , String auth){
String getinterface = "{ \"jsonrpc\": \"2.0\" , \"method\" : \"hostinterface.get\", \"params\": { \"output\": \"extend\", \"hostids\": \""+hostid+"\"},";
getinterface += "\"auth\": \""+auth+"\",\"id\": 1} ";
return fromString(getinterface);
}
public static InputStream create_graph(String name , String auth , String itemid){
String creategraph = "{ \"jsonrpc\": \"2.0\", \"method\": \"graph.create\",\"params\": {\"name\": \""+name+"\",\"gitems\":";
creategraph += "[ {\"itemid\": \""+itemid+"\",\"color\": \"00AA00\" }]},\"auth\": \""+auth+"\",\"id\": 1 }";
return fromString(creategraph);
}
public static InputStream creeate_host(String ip , String name, String auth){ // the ip represents the host name here
// return create_host(ip,auth,name ,groups("1"),interfaces("127.0.0.1","10050"));
return fromString(create_host(ip,auth, name, groups("1"),interfaces("127.0.0.1","10050")));
}
private static String create_host( String IP , String auth ,String host, String group , String interfaces ){
String create_host = "{ \"jsonrpc\": \"2.0\", \"method\": \"host.create\", \"params\": { \"host\": \""+host+"\",";
create_host += interfaces + "," + group + "},";
create_host += "\"auth\": \""+auth+"\",\"id\":\"1\"}";
return create_host ;
}
private static String interfaces(String ip , String port){
String interfaces = "\"interfaces\":[{ \"type\" : 1 , \"main\" : 1 , \"useip\" : 1 , \"ip\" : \""+ip+"\" , \"dns\" : \"\" , \"port\" : \""+port+"\" }]";
return interfaces;
}
private static String groups (String groupid){
String groups = "\"groups\": [{ \"groupid\" : \""+groupid+"\" }]";
return groups ;
}
public static InputStream delete_host(String hostid , String auth){
String deletehost = " { \"jsonrpc\": \"2.0\",\"method\": \"host.delete\",\"params\": [\""+hostid+"\"],\"auth\": \""+auth+"\",\"id\": 1 } ";
//return deletehost ;
return fromString(deletehost);
}
private static InputStream fromString(String str){
byte[] bytes ;
try {
bytes = str.getBytes("UTF-8");
return new ByteArrayInputStream(bytes);
}catch (UnsupportedEncodingException e){
System.out.println(e);
}
return null;
}
}
| 4,740 | 0.546222 | 0.53377 | 95 | 48.873684 | 48.958897 | 174 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.494737 | false | false |
13
|
e1c5cdbe45c5f6910364bc09dc31acd684bd22b7
| 37,641,093,396,563 |
399aaaa1c8019e487f760a89aade1e6d5dade1e1
|
/src/main/java/cz/linksoft/hr/java/ip2location/rest/CityRestController.java
|
124242c27885d77a395444e10b2da21e4e22588a
|
[] |
no_license
|
svobodaroman/linksoft
|
https://github.com/svobodaroman/linksoft
|
d0f87f7e4badaca3b0442847efc252673f1e3f10
|
420f4864441abb04bdc2cc35b20c9a4cc3a22481
|
refs/heads/master
| 2020-04-20T12:17:47.745000 | 2019-02-02T14:30:31 | 2019-02-02T14:30:31 | 168,839,462 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package cz.linksoft.hr.java.ip2location.rest;
import java.util.Collection;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cz.linksoft.hr.java.ip2location.model.City;
import cz.linksoft.hr.java.ip2location.model.IPAddressRange;
/**
* REST endpoint related to {@link City}.
*/
@RestController
@RequestMapping("city")
public class CityRestController {
/**
* Provides all registered object IDs.
* @return All registered IDs
*/
@GetMapping
public Collection<Object> getAllIds() {
//TODO implement me
return null;
}
/**
* Provides detail info about object with specified identification.
* @param id Identification of object
* @return Detail info about object if it's found
*/
@GetMapping("{id}")
public City getOne(@PathVariable("id") Object id) {
//TODO implement me
return null;
}
/**
* Provides all IP address ranges registered for specified city.
* @param cityId Identification of city
* @return All IP address ranges for the city if it's found
*/
@GetMapping("{id}/ip")
public Collection<IPAddressRange> getAllIpAddressRangesForCity(@PathVariable("id") Object cityId) {
//TODO implement me
return null;
}
}
|
UTF-8
|
Java
| 1,369 |
java
|
CityRestController.java
|
Java
|
[] | null |
[] |
package cz.linksoft.hr.java.ip2location.rest;
import java.util.Collection;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cz.linksoft.hr.java.ip2location.model.City;
import cz.linksoft.hr.java.ip2location.model.IPAddressRange;
/**
* REST endpoint related to {@link City}.
*/
@RestController
@RequestMapping("city")
public class CityRestController {
/**
* Provides all registered object IDs.
* @return All registered IDs
*/
@GetMapping
public Collection<Object> getAllIds() {
//TODO implement me
return null;
}
/**
* Provides detail info about object with specified identification.
* @param id Identification of object
* @return Detail info about object if it's found
*/
@GetMapping("{id}")
public City getOne(@PathVariable("id") Object id) {
//TODO implement me
return null;
}
/**
* Provides all IP address ranges registered for specified city.
* @param cityId Identification of city
* @return All IP address ranges for the city if it's found
*/
@GetMapping("{id}/ip")
public Collection<IPAddressRange> getAllIpAddressRangesForCity(@PathVariable("id") Object cityId) {
//TODO implement me
return null;
}
}
| 1,369 | 0.748722 | 0.74653 | 53 | 24.830189 | 24.662809 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.867925 | false | false |
13
|
9c8db350b1c1585b2a034e85972a1722123f6bc1
| 35,390,530,542,076 |
33b75e41dd583706eaed6716c84bb7282f3906e2
|
/browser/src/com/blink/browser/download/DownloadActivity.java
|
bdc30a8fbe007165ca66e1d0d64f37717c988975
|
[] |
no_license
|
chenshige/blink
|
https://github.com/chenshige/blink
|
2319887245002810835d9260c457c2c98f4471a4
|
09660605bfdeefa00c8829eba71b4197f32d422a
|
refs/heads/master
| 2020-03-10T10:48:14.739000 | 2017-10-08T10:50:35 | 2017-10-08T10:50:35 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.blink.browser.download;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.blink.browser.BrowserSettings;
import com.blink.browser.R;
import com.blink.browser.provider.BrowserContract;
import com.blink.browser.util.DisplayUtil;
import com.blink.browser.util.StorageUtils;
import com.blink.browser.util.SystemTintBarUtils;
import com.blink.browser.widget.PagerSlidingTabStrip;
import java.util.ArrayList;
import java.util.List;
public class DownloadActivity extends FragmentActivity implements View.OnClickListener {
public static final int DOWNLOAD_RENAME = 1;
public static final int DOWNLOADING = 2;
public static final int DOWNLOADED = 3;
private List<Fragment> mList = new ArrayList<>();
private TextView mActionBarTitle;
private String[] mTitles;
private ImageView mActionBarLeftIcon;
private ViewPager mViewPager;
private TextView mStorage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_download);
initActionBar();
initView();
DisplayUtil.changeScreenBrightnessIfNightMode(this);
SystemTintBarUtils.setSystemBarColor(this);
}
@Override
protected void onResume() {
super.onResume();
if (!BrowserSettings.getInstance().getShowStatusBar()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams
.FLAG_FULLSCREEN);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
private void initActionBar() {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.layout_custom_actionbar);
View actionbarView = actionBar.getCustomView();
mActionBarLeftIcon = (ImageView) actionbarView.findViewById(R.id.actionbar_left_icon);
mActionBarLeftIcon.setOnClickListener(this);
mActionBarTitle = (TextView) actionbarView.findViewById(R.id.actionbar_title);
mActionBarTitle.setText(R.string.downloading);
}
}
private void initView() {
mStorage = (TextView) findViewById(R.id.storage_space);
mList.add(new DownloadingFragment());
mList.add(new DownloadedFragment());
mStorage.setText(StorageUtils.getAllSDSpace(this));
initTabs();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
swtichDownloaded(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
swtichDownloaded(intent);
}
private void initTabs() {
PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.pager_tabs);
mViewPager = (ViewPager) findViewById(R.id.pager_view);
mTitles = new String[]{getResources().getString(R.string.downloading), getResources().getString(R
.string.downloaded)};
mViewPager.setOffscreenPageLimit(mTitles.length);
mViewPager.setAdapter(new BasePagerAdapter(getSupportFragmentManager(), mTitles));
tabs.setViewPager(mViewPager);
tabs.setOnPageChangeListener(mOnPageChangeListener);
}
class BasePagerAdapter extends FragmentPagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
String[] mTitles;
int[] mIcon;
int[] mIconSelect;
public BasePagerAdapter(FragmentManager fm, String[] titles) {
super(fm);
this.mTitles = titles;
mIcon = new int[]{R.drawable.ic_browser_tab_download, R.drawable.ic_browser_menu_downloaded};
mIconSelect = new int[]{R.drawable.ic_browser_tab_download_seleted, R.drawable
.ic_browser_menu_downloaded_avtived};
}
@Override
public Fragment getItem(int position) {
return mList.get(position);
}
@Override
public int getCount() {
return mTitles.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mTitles[position];
}
@Override
public int getPageIconResId(int position) {
return mIcon[position];
}
@Override
public int getPageSelectIconResId(int position) {
return mIconSelect[position];
}
}
@Override
public void onClick(View v) {
if (R.id.actionbar_left_icon == v.getId()) {
this.finish();
}
}
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);
}
private ViewPager.OnPageChangeListener mOnPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mActionBarTitle.setText(mTitles[position]);
if (position == 1) {
((DownloadedFragment) mList.get(position)).refresh();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
};
private void swtichDownloaded(Intent intent) {
if (intent != null && intent.getExtras() != null) {
int state = intent.getExtras().getInt(BrowserContract.DOWNLOAD_STATE);
if (state == DOWNLOADED) {
mViewPager.setCurrentItem(1);
}
}
}
}
|
UTF-8
|
Java
| 6,270 |
java
|
DownloadActivity.java
|
Java
|
[] | null |
[] |
package com.blink.browser.download;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.blink.browser.BrowserSettings;
import com.blink.browser.R;
import com.blink.browser.provider.BrowserContract;
import com.blink.browser.util.DisplayUtil;
import com.blink.browser.util.StorageUtils;
import com.blink.browser.util.SystemTintBarUtils;
import com.blink.browser.widget.PagerSlidingTabStrip;
import java.util.ArrayList;
import java.util.List;
public class DownloadActivity extends FragmentActivity implements View.OnClickListener {
public static final int DOWNLOAD_RENAME = 1;
public static final int DOWNLOADING = 2;
public static final int DOWNLOADED = 3;
private List<Fragment> mList = new ArrayList<>();
private TextView mActionBarTitle;
private String[] mTitles;
private ImageView mActionBarLeftIcon;
private ViewPager mViewPager;
private TextView mStorage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_download);
initActionBar();
initView();
DisplayUtil.changeScreenBrightnessIfNightMode(this);
SystemTintBarUtils.setSystemBarColor(this);
}
@Override
protected void onResume() {
super.onResume();
if (!BrowserSettings.getInstance().getShowStatusBar()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams
.FLAG_FULLSCREEN);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
private void initActionBar() {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.layout_custom_actionbar);
View actionbarView = actionBar.getCustomView();
mActionBarLeftIcon = (ImageView) actionbarView.findViewById(R.id.actionbar_left_icon);
mActionBarLeftIcon.setOnClickListener(this);
mActionBarTitle = (TextView) actionbarView.findViewById(R.id.actionbar_title);
mActionBarTitle.setText(R.string.downloading);
}
}
private void initView() {
mStorage = (TextView) findViewById(R.id.storage_space);
mList.add(new DownloadingFragment());
mList.add(new DownloadedFragment());
mStorage.setText(StorageUtils.getAllSDSpace(this));
initTabs();
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
swtichDownloaded(getIntent());
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
swtichDownloaded(intent);
}
private void initTabs() {
PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.pager_tabs);
mViewPager = (ViewPager) findViewById(R.id.pager_view);
mTitles = new String[]{getResources().getString(R.string.downloading), getResources().getString(R
.string.downloaded)};
mViewPager.setOffscreenPageLimit(mTitles.length);
mViewPager.setAdapter(new BasePagerAdapter(getSupportFragmentManager(), mTitles));
tabs.setViewPager(mViewPager);
tabs.setOnPageChangeListener(mOnPageChangeListener);
}
class BasePagerAdapter extends FragmentPagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
String[] mTitles;
int[] mIcon;
int[] mIconSelect;
public BasePagerAdapter(FragmentManager fm, String[] titles) {
super(fm);
this.mTitles = titles;
mIcon = new int[]{R.drawable.ic_browser_tab_download, R.drawable.ic_browser_menu_downloaded};
mIconSelect = new int[]{R.drawable.ic_browser_tab_download_seleted, R.drawable
.ic_browser_menu_downloaded_avtived};
}
@Override
public Fragment getItem(int position) {
return mList.get(position);
}
@Override
public int getCount() {
return mTitles.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mTitles[position];
}
@Override
public int getPageIconResId(int position) {
return mIcon[position];
}
@Override
public int getPageSelectIconResId(int position) {
return mIconSelect[position];
}
}
@Override
public void onClick(View v) {
if (R.id.actionbar_left_icon == v.getId()) {
this.finish();
}
}
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);
}
private ViewPager.OnPageChangeListener mOnPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mActionBarTitle.setText(mTitles[position]);
if (position == 1) {
((DownloadedFragment) mList.get(position)).refresh();
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
};
private void swtichDownloaded(Intent intent) {
if (intent != null && intent.getExtras() != null) {
int state = intent.getExtras().getInt(BrowserContract.DOWNLOAD_STATE);
if (state == DOWNLOADED) {
mViewPager.setCurrentItem(1);
}
}
}
}
| 6,270 | 0.664912 | 0.663317 | 190 | 32 | 27.02533 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
13
|
48ec65aaecd9cd0637bdeef9523a66b4e13c9c79
| 37,331,855,745,231 |
9db9d4241eec01f2aecd40e6ed822c41998be7c9
|
/src/com/sinosoft/picc/report/jaxb/complexrelation/impl/ItemSourImpl.java
|
1fbc25330e28beac592bd9ef4d264fa920e1558a
|
[] |
no_license
|
moutainhigh/acc2
|
https://github.com/moutainhigh/acc2
|
41bf7edce155cc81763d3756a2ae939d7eaed24e
|
08fbcf9e7a42e45dc042949401e301690d2170aa
|
refs/heads/master
| 2023-01-23T00:19:25.522000 | 2019-12-26T15:44:25 | 2019-12-26T15:44:25 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.2-b15-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2005.03.16 at 08:55:33 CST
//
package com.sinosoft.picc.report.jaxb.complexrelation.impl;
public class ItemSourImpl implements com.sinosoft.picc.report.jaxb.complexrelation.ItemSour, com.sun.xml.bind.JAXBObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallableObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializable, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.ValidatableObject
{
protected java.lang.String _ItemCodeSour;
protected java.lang.String _SumTypeSour;
protected java.lang.String _ItemFlag;
protected com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType _Details;
public final static java.lang.Class version = (com.sinosoft.picc.report.jaxb.complexrelation.impl.JAXBVersion.class);
private static com.sun.msv.grammar.Grammar schemaFragment;
private final static java.lang.Class PRIMARY_INTERFACE_CLASS() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.class);
}
public java.lang.String getItemCodeSour() {
return _ItemCodeSour;
}
public void setItemCodeSour(java.lang.String value) {
_ItemCodeSour = value;
}
public java.lang.String getSumTypeSour() {
return _SumTypeSour;
}
public void setSumTypeSour(java.lang.String value) {
_SumTypeSour = value;
}
public java.lang.String getItemFlag() {
return _ItemFlag;
}
public void setItemFlag(java.lang.String value) {
_ItemFlag = value;
}
public com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType getDetails() {
return _Details;
}
public void setDetails(com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType value) {
_Details = value;
}
public com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingEventHandler createUnmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
return new com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.Unmarshaller(context);
}
public void serializeBody(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
context.startElement("", "ItemCodeSour");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _ItemCodeSour), "ItemCodeSour");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
context.startElement("", "ItemFlag");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _ItemFlag), "ItemFlag");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
if (_SumTypeSour!= null) {
context.startElement("", "SumTypeSour");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _SumTypeSour), "SumTypeSour");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
}
if (_Details!= null) {
context.startElement("", "Details");
context.childAsURIs(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endNamespaceDecls();
context.childAsAttributes(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endAttributes();
context.childAsBody(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endElement();
}
}
public void serializeAttributes(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
}
public void serializeURIs(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
}
public java.lang.Class getPrimaryInterface() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.class);
}
public com.sun.msv.verifier.DocumentDeclaration createRawValidator() {
if (schemaFragment == null) {
schemaFragment = com.sun.xml.bind.validator.SchemaDeserializer.deserialize((
"\u00ac\u00ed\u0000\u0005sr\u0000\u001fcom.sun.msv.grammar.SequenceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.su"
+"n.msv.grammar.BinaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0004exp1t\u0000 Lcom/sun/msv/gra"
+"mmar/Expression;L\u0000\u0004exp2q\u0000~\u0000\u0002xr\u0000\u001ecom.sun.msv.grammar.Expressi"
+"on\u00f8\u0018\u0082\u00e8N5~O\u0002\u0000\u0003I\u0000\u000ecachedHashCodeL\u0000\u0013epsilonReducibilityt\u0000\u0013Ljava"
+"/lang/Boolean;L\u0000\u000bexpandedExpq\u0000~\u0000\u0002xp\n\u0094(\u00a6ppsq\u0000~\u0000\u0000\u0007y4\u00adppsq\u0000~\u0000\u0000\u0004"
+"\u0089#\u00b6ppsr\u0000\'com.sun.msv.grammar.trex.ElementPattern\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L"
+"\u0000\tnameClasst\u0000\u001fLcom/sun/msv/grammar/NameClass;xr\u0000\u001ecom.sun.msv"
+".grammar.ElementExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002Z\u0000\u001aignoreUndeclaredAttributesL"
+"\u0000\fcontentModelq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00af\u00f1\u00b9pp\u0000sq\u0000~\u0000\u0000\u0002\u00af\u00f1\u00aeppsr\u0000\u001bcom.sun.msv."
+"grammar.DataExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\u0002dtt\u0000\u001fLorg/relaxng/datatype/Data"
+"type;L\u0000\u0006exceptq\u0000~\u0000\u0002L\u0000\u0004namet\u0000\u001dLcom/sun/msv/util/StringPair;xq"
+"\u0000~\u0000\u0003\u0001h~\u008cppsr\u0000#com.sun.msv.datatype.xsd.StringType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001"
+"Z\u0000\risAlwaysValidxr\u0000*com.sun.msv.datatype.xsd.BuiltinAtomicTy"
+"pe\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000%com.sun.msv.datatype.xsd.ConcreteType\u0000\u0000\u0000\u0000\u0000\u0000"
+"\u0000\u0001\u0002\u0000\u0000xr\u0000\'com.sun.msv.datatype.xsd.XSDatatypeImpl\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L"
+"\u0000\fnamespaceUrit\u0000\u0012Ljava/lang/String;L\u0000\btypeNameq\u0000~\u0000\u0015L\u0000\nwhiteS"
+"pacet\u0000.Lcom/sun/msv/datatype/xsd/WhiteSpaceProcessor;xpt\u0000 ht"
+"tp://www.w3.org/2001/XMLSchemat\u0000\u0006stringsr\u00005com.sun.msv.datat"
+"ype.xsd.WhiteSpaceProcessor$Preserve\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000,com.sun.m"
+"sv.datatype.xsd.WhiteSpaceProcessor\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xp\u0001sr\u00000com.sun"
+".msv.grammar.Expression$NullSetExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000"
+"\u0000\nppsr\u0000\u001bcom.sun.msv.util.StringPair\u00d0t\u001ejB\u008f\u008d\u00a0\u0002\u0000\u0002L\u0000\tlocalNameq\u0000"
+"~\u0000\u0015L\u0000\fnamespaceURIq\u0000~\u0000\u0015xpq\u0000~\u0000\u0019q\u0000~\u0000\u0018sr\u0000\u001dcom.sun.msv.grammar.C"
+"hoiceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0001\u0001Gs\u001dppsr\u0000 com.sun.msv.grammar.Attri"
+"buteExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0003expq\u0000~\u0000\u0002L\u0000\tnameClassq\u0000~\u0000\txq\u0000~\u0000\u0003\u0001Gs\u0012sr\u0000\u0011"
+"java.lang.Boolean\u00cd r\u0080\u00d5\u009c\u00fa\u00ee\u0002\u0000\u0001Z\u0000\u0005valuexp\u0000psq\u0000~\u0000\r\u0000<\u00c2rppsr\u0000\"com."
+"sun.msv.datatype.xsd.QnameType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0012q\u0000~\u0000\u0018t\u0000\u0005QName"
+"sr\u00005com.sun.msv.datatype.xsd.WhiteSpaceProcessor$Collapse\u0000\u0000\u0000"
+"\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u001bq\u0000~\u0000\u001esq\u0000~\u0000\u001fq\u0000~\u0000*q\u0000~\u0000\u0018sr\u0000#com.sun.msv.grammar.S"
+"impleNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\tlocalNameq\u0000~\u0000\u0015L\u0000\fnamespaceURIq\u0000~"
+"\u0000\u0015xr\u0000\u001dcom.sun.msv.grammar.NameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpt\u0000\u0004typet\u0000)ht"
+"tp://www.w3.org/2001/XMLSchema-instancesr\u00000com.sun.msv.gramm"
+"ar.Expression$EpsilonExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\tsq\u0000~\u0000%\u0001p"
+"sq\u0000~\u0000.t\u0000\fItemCodeSourt\u0000\u0000sq\u0000~\u0000\b\u0001\u00d91\u00f8pp\u0000sq\u0000~\u0000\u0000\u0001\u00d91\u00edppq\u0000~\u0000\u0010sq\u0000~\u0000!"
+"\u0000p\u00b3\\ppsq\u0000~\u0000#\u0000p\u00b3Qq\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t\u0000\bIte"
+"mFlagq\u0000~\u00008sq\u0000~\u0000!\u0002\u00f0\u0010\u00f2ppsq\u0000~\u0000\b\u0002\u00f0\u0010\u00e7q\u0000~\u0000&p\u0000sq\u0000~\u0000\u0000\u0002\u00f0\u0010\u00dcppq\u0000~\u0000\u0010sq\u0000~"
+"\u0000!\u0001\u0087\u0092Kppsq\u0000~\u0000#\u0001\u0087\u0092@q\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t\u0000\u000bS"
+"umTypeSourq\u0000~\u00008q\u0000~\u00004sq\u0000~\u0000!\u0003\u001a\u00f3\u00f4ppsq\u0000~\u0000\b\u0003\u001a\u00f3\u00e9q\u0000~\u0000&p\u0000sq\u0000~\u0000\u0000\u0003\u001a\u00f3\u00dep"
+"psq\u0000~\u0000\b\u0001M\u001dcpp\u0000sq\u0000~\u0000!\u0001M\u001dXppsr\u0000 com.sun.msv.grammar.OneOrMoreE"
+"xp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001ccom.sun.msv.grammar.UnaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\u0003e"
+"xpq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0001M\u001dMq\u0000~\u0000&psq\u0000~\u0000#\u0001M\u001dJq\u0000~\u0000&psr\u00002com.sun.msv.gramm"
+"ar.Expression$AnyStringExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\bq\u0000~\u00005p"
+"sr\u0000 com.sun.msv.grammar.AnyNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000/q\u0000~\u00004sq"
+"\u0000~\u0000.t\u0000Bcom.sinosoft.picc.report.jaxb.complexrelation.ItemSou"
+"r.DetailsTypet\u0000+http://java.sun.com/jaxb/xjc/dummy-elementss"
+"q\u0000~\u0000!\u0001\u00cd\u00d6vppsq\u0000~\u0000#\u0001\u00cd\u00d6kq\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t"
+"\u0000\u0007Detailsq\u0000~\u00008q\u0000~\u00004sr\u0000\"com.sun.msv.grammar.ExpressionPool\u0000\u0000\u0000"
+"\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\bexpTablet\u0000/Lcom/sun/msv/grammar/ExpressionPool$Cl"
+"osedHash;xpsr\u0000-com.sun.msv.grammar.ExpressionPool$ClosedHash"
+"\u00d7j\u00d0N\u00ef\u00e8\u00ed\u001c\u0002\u0000\u0004I\u0000\u0005countI\u0000\tthresholdL\u0000\u0006parentq\u0000~\u0000^[\u0000\u0005tablet\u0000![Lco"
+"m/sun/msv/grammar/Expression;xp\u0000\u0000\u0000\u000f\u0000\u0000\u00009pur\u0000![Lcom.sun.msv.gr"
+"ammar.Expression;\u00d68D\u00c3]\u00ad\u00a7\n\u0002\u0000\u0000xp\u0000\u0000\u0000\u00bfpppppppppppppppppppppppppp"
+"pppq\u0000~\u0000Bpq\u0000~\u0000Cpppppppppppppppppppq\u0000~\u0000@pppppppppppppppppppq\u0000~"
+"\u0000Oppppppppppq\u0000~\u0000Lpppppppq\u0000~\u0000Jpppppppppppppppppppq\u0000~\u0000\u0005pq\u0000~\u0000Hp"
+"pppppppppppq\u0000~\u0000\fpq\u0000~\u0000\"q\u0000~\u0000\u0007ppppppppppppppppppppppppppppppppp"
+"pppppq\u0000~\u0000:pq\u0000~\u0000;pppppppppppppq\u0000~\u0000Xq\u0000~\u0000\u0006pppppp"));
}
return new com.sun.msv.verifier.regexp.REDocumentDeclaration(schemaFragment);
}
public static class DetailsTypeImpl implements com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType, com.sun.xml.bind.JAXBObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallableObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializable, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.ValidatableObject
{
protected com.sun.xml.bind.util.ListImpl _Detail = new com.sun.xml.bind.util.ListImpl(new java.util.ArrayList());
public final static java.lang.Class version = (com.sinosoft.picc.report.jaxb.complexrelation.impl.JAXBVersion.class);
private static com.sun.msv.grammar.Grammar schemaFragment;
private final static java.lang.Class PRIMARY_INTERFACE_CLASS() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType.class);
}
public java.util.List getDetail() {
return _Detail;
}
public com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingEventHandler createUnmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
return new com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.Unmarshaller(context);
}
public void serializeBody(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
context.startElement("", "Detail");
int idx_0 = idx1;
context.childAsURIs(((com.sun.xml.bind.JAXBObject) _Detail.get(idx_0 ++)), "Detail");
context.endNamespaceDecls();
int idx_1 = idx1;
context.childAsAttributes(((com.sun.xml.bind.JAXBObject) _Detail.get(idx_1 ++)), "Detail");
context.endAttributes();
context.childAsBody(((com.sun.xml.bind.JAXBObject) _Detail.get(idx1 ++)), "Detail");
context.endElement();
}
}
public void serializeAttributes(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
idx1 += 1;
}
}
public void serializeURIs(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
idx1 += 1;
}
}
public java.lang.Class getPrimaryInterface() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType.class);
}
public com.sun.msv.verifier.DocumentDeclaration createRawValidator() {
if (schemaFragment == null) {
schemaFragment = com.sun.xml.bind.validator.SchemaDeserializer.deserialize((
"\u00ac\u00ed\u0000\u0005sr\u0000 com.sun.msv.grammar.OneOrMoreExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001ccom.s"
+"un.msv.grammar.UnaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\u0003expt\u0000 Lcom/sun/msv/gram"
+"mar/Expression;xr\u0000\u001ecom.sun.msv.grammar.Expression\u00f8\u0018\u0082\u00e8N5~O\u0002\u0000\u0003"
+"I\u0000\u000ecachedHashCodeL\u0000\u0013epsilonReducibilityt\u0000\u0013Ljava/lang/Boolean"
+";L\u0000\u000bexpandedExpq\u0000~\u0000\u0002xp\u0002\u00d7W9ppsr\u0000\'com.sun.msv.grammar.trex.Ele"
+"mentPattern\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\tnameClasst\u0000\u001fLcom/sun/msv/grammar/Na"
+"meClass;xr\u0000\u001ecom.sun.msv.grammar.ElementExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002Z\u0000\u001aigno"
+"reUndeclaredAttributesL\u0000\fcontentModelq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00d7W6pp\u0000sr\u0000\u001fc"
+"om.sun.msv.grammar.SequenceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.sun.msv.gra"
+"mmar.BinaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0004exp1q\u0000~\u0000\u0002L\u0000\u0004exp2q\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00d7W+p"
+"psq\u0000~\u0000\u0006\u0001M\u001dcpp\u0000sr\u0000\u001dcom.sun.msv.grammar.ChoiceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq"
+"\u0000~\u0000\u000b\u0001M\u001dXppsq\u0000~\u0000\u0000\u0001M\u001dMsr\u0000\u0011java.lang.Boolean\u00cd r\u0080\u00d5\u009c\u00fa\u00ee\u0002\u0000\u0001Z\u0000\u0005value"
+"xp\u0000psr\u0000 com.sun.msv.grammar.AttributeExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0003expq\u0000~"
+"\u0000\u0002L\u0000\tnameClassq\u0000~\u0000\u0007xq\u0000~\u0000\u0003\u0001M\u001dJq\u0000~\u0000\u0012psr\u00002com.sun.msv.grammar.E"
+"xpression$AnyStringExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\bsq\u0000~\u0000\u0011\u0001psr"
+"\u0000 com.sun.msv.grammar.AnyNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.sun.msv"
+".grammar.NameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpsr\u00000com.sun.msv.grammar.Expre"
+"ssion$EpsilonExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\tq\u0000~\u0000\u0017psr\u0000#com.su"
+"n.msv.grammar.SimpleNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\tlocalNamet\u0000\u0012Ljava"
+"/lang/String;L\u0000\fnamespaceURIq\u0000~\u0000\u001exq\u0000~\u0000\u0019t\u00004com.sinosoft.picc."
+"report.jaxb.complexrelation.Detailt\u0000+http://java.sun.com/jax"
+"b/xjc/dummy-elementssq\u0000~\u0000\u000e\u0001\u008a9\u00c3ppsq\u0000~\u0000\u0013\u0001\u008a9\u00b8q\u0000~\u0000\u0012psr\u0000\u001bcom.sun."
+"msv.grammar.DataExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\u0002dtt\u0000\u001fLorg/relaxng/datatype/"
+"Datatype;L\u0000\u0006exceptq\u0000~\u0000\u0002L\u0000\u0004namet\u0000\u001dLcom/sun/msv/util/StringPai"
+"r;xq\u0000~\u0000\u0003\u0000<\u00c2rppsr\u0000\"com.sun.msv.datatype.xsd.QnameType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001"
+"\u0002\u0000\u0000xr\u0000*com.sun.msv.datatype.xsd.BuiltinAtomicType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000"
+"xr\u0000%com.sun.msv.datatype.xsd.ConcreteType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\'com."
+"sun.msv.datatype.xsd.XSDatatypeImpl\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\fnamespaceUr"
+"iq\u0000~\u0000\u001eL\u0000\btypeNameq\u0000~\u0000\u001eL\u0000\nwhiteSpacet\u0000.Lcom/sun/msv/datatype/"
+"xsd/WhiteSpaceProcessor;xpt\u0000 http://www.w3.org/2001/XMLSchem"
+"at\u0000\u0005QNamesr\u00005com.sun.msv.datatype.xsd.WhiteSpaceProcessor$Co"
+"llapse\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000,com.sun.msv.datatype.xsd.WhiteSpaceProc"
+"essor\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpsr\u00000com.sun.msv.grammar.Expression$NullSet"
+"Expression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\nppsr\u0000\u001bcom.sun.msv.util.String"
+"Pair\u00d0t\u001ejB\u008f\u008d\u00a0\u0002\u0000\u0002L\u0000\tlocalNameq\u0000~\u0000\u001eL\u0000\fnamespaceURIq\u0000~\u0000\u001expq\u0000~\u0000/q"
+"\u0000~\u0000.sq\u0000~\u0000\u001dt\u0000\u0004typet\u0000)http://www.w3.org/2001/XMLSchema-instanc"
+"eq\u0000~\u0000\u001csq\u0000~\u0000\u001dt\u0000\u0006Detailt\u0000\u0000sr\u0000\"com.sun.msv.grammar.ExpressionPo"
+"ol\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\bexpTablet\u0000/Lcom/sun/msv/grammar/ExpressionPo"
+"ol$ClosedHash;xpsr\u0000-com.sun.msv.grammar.ExpressionPool$Close"
+"dHash\u00d7j\u00d0N\u00ef\u00e8\u00ed\u001c\u0002\u0000\u0004I\u0000\u0005countI\u0000\tthresholdL\u0000\u0006parentq\u0000~\u0000>[\u0000\u0005tablet\u0000"
+"![Lcom/sun/msv/grammar/Expression;xp\u0000\u0000\u0000\u0005\u0000\u0000\u00009pur\u0000![Lcom.sun.m"
+"sv.grammar.Expression;\u00d68D\u00c3]\u00ad\u00a7\n\u0002\u0000\u0000xp\u0000\u0000\u0000\u00bfppppppppppppppppppppp"
+"ppppppppppppppppppppppppppppppppppppppppppppppppppq\u0000~\u0000\u0010q\u0000~\u0000\f"
+"pppppppppq\u0000~\u0000\u000fpppq\u0000~\u0000\u0005pppppppppppppppppppppppppppppppppppppp"
+"ppppppppppppppppppppppppppppppppppppppppq\u0000~\u0000\"ppppppppppppppp"
+"pppppppppp"));
}
return new com.sun.msv.verifier.regexp.REDocumentDeclaration(schemaFragment);
}
public class Unmarshaller
extends com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.AbstractUnmarshallingEventHandlerImpl
{
public Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
super(context, "----");
}
protected Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context, int startState) {
this(context);
state = startState;
}
public java.lang.Object owner() {
return com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.this;
}
public void enterElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname, org.xml.sax.Attributes __atts)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 1 :
if (("DetailCode" == ___local)&&("" == ___uri)) {
_Detail.add(((com.sinosoft.picc.report.jaxb.complexrelation.impl.DetailImpl) spawnChildFromEnterElement((com.sinosoft.picc.report.jaxb.complexrelation.impl.DetailImpl.class), 2, ___uri, ___local, ___qname, __atts)));
return ;
}
break;
case 3 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 1;
return ;
}
revertToParentFromEnterElement(___uri, ___local, ___qname, __atts);
return ;
case 0 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 1;
return ;
}
break;
}
super.enterElement(___uri, ___local, ___qname, __atts);
break;
}
}
public void leaveElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromLeaveElement(___uri, ___local, ___qname);
return ;
case 2 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 3;
return ;
}
break;
}
super.leaveElement(___uri, ___local, ___qname);
break;
}
}
public void enterAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromEnterAttribute(___uri, ___local, ___qname);
return ;
}
super.enterAttribute(___uri, ___local, ___qname);
break;
}
}
public void leaveAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromLeaveAttribute(___uri, ___local, ___qname);
return ;
}
super.leaveAttribute(___uri, ___local, ___qname);
break;
}
}
public void handleText(final java.lang.String value)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
try {
switch (state) {
case 3 :
revertToParentFromText(value);
return ;
}
} catch (java.lang.RuntimeException e) {
handleUnexpectedTextException(value, e);
}
break;
}
}
}
}
public class Unmarshaller
extends com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.AbstractUnmarshallingEventHandlerImpl
{
public Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
super(context, "-------------");
}
protected Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context, int startState) {
this(context);
state = startState;
}
public java.lang.Object owner() {
return com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.this;
}
public void enterElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname, org.xml.sax.Attributes __atts)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
if (("ItemFlag" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 4;
return ;
}
break;
case 9 :
if (("Details" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 10;
return ;
}
state = 12;
continue outer;
case 0 :
if (("ItemCodeSour" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 1;
return ;
}
break;
case 10 :
if (("Detail" == ___local)&&("" == ___uri)) {
_Details = ((com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl) spawnChildFromEnterElement((com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.class), 11, ___uri, ___local, ___qname, __atts));
return ;
}
break;
case 12 :
revertToParentFromEnterElement(___uri, ___local, ___qname, __atts);
return ;
case 6 :
if (("SumTypeSour" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 7;
return ;
}
state = 9;
continue outer;
}
super.enterElement(___uri, ___local, ___qname, __atts);
break;
}
}
public void leaveElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 8 :
if (("SumTypeSour" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 9;
return ;
}
break;
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromLeaveElement(___uri, ___local, ___qname);
return ;
case 2 :
if (("ItemCodeSour" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 3;
return ;
}
break;
case 5 :
if (("ItemFlag" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 6;
return ;
}
break;
case 6 :
state = 9;
continue outer;
case 11 :
if (("Details" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 12;
return ;
}
break;
}
super.leaveElement(___uri, ___local, ___qname);
break;
}
}
public void enterAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromEnterAttribute(___uri, ___local, ___qname);
return ;
case 6 :
state = 9;
continue outer;
}
super.enterAttribute(___uri, ___local, ___qname);
break;
}
}
public void leaveAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromLeaveAttribute(___uri, ___local, ___qname);
return ;
case 6 :
state = 9;
continue outer;
}
super.leaveAttribute(___uri, ___local, ___qname);
break;
}
}
public void handleText(final java.lang.String value)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
try {
switch (state) {
case 1 :
eatText1(value);
state = 2;
return ;
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromText(value);
return ;
case 4 :
eatText2(value);
state = 5;
return ;
case 7 :
eatText3(value);
state = 8;
return ;
case 6 :
state = 9;
continue outer;
}
} catch (java.lang.RuntimeException e) {
handleUnexpectedTextException(value, e);
}
break;
}
}
private void eatText1(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_ItemCodeSour = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
private void eatText2(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_ItemFlag = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
private void eatText3(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_SumTypeSour = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
}
}
|
UTF-8
|
Java
| 35,549 |
java
|
ItemSourImpl.java
|
Java
|
[] | null |
[] |
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.2-b15-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2005.03.16 at 08:55:33 CST
//
package com.sinosoft.picc.report.jaxb.complexrelation.impl;
public class ItemSourImpl implements com.sinosoft.picc.report.jaxb.complexrelation.ItemSour, com.sun.xml.bind.JAXBObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallableObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializable, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.ValidatableObject
{
protected java.lang.String _ItemCodeSour;
protected java.lang.String _SumTypeSour;
protected java.lang.String _ItemFlag;
protected com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType _Details;
public final static java.lang.Class version = (com.sinosoft.picc.report.jaxb.complexrelation.impl.JAXBVersion.class);
private static com.sun.msv.grammar.Grammar schemaFragment;
private final static java.lang.Class PRIMARY_INTERFACE_CLASS() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.class);
}
public java.lang.String getItemCodeSour() {
return _ItemCodeSour;
}
public void setItemCodeSour(java.lang.String value) {
_ItemCodeSour = value;
}
public java.lang.String getSumTypeSour() {
return _SumTypeSour;
}
public void setSumTypeSour(java.lang.String value) {
_SumTypeSour = value;
}
public java.lang.String getItemFlag() {
return _ItemFlag;
}
public void setItemFlag(java.lang.String value) {
_ItemFlag = value;
}
public com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType getDetails() {
return _Details;
}
public void setDetails(com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType value) {
_Details = value;
}
public com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingEventHandler createUnmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
return new com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.Unmarshaller(context);
}
public void serializeBody(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
context.startElement("", "ItemCodeSour");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _ItemCodeSour), "ItemCodeSour");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
context.startElement("", "ItemFlag");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _ItemFlag), "ItemFlag");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
if (_SumTypeSour!= null) {
context.startElement("", "SumTypeSour");
context.endNamespaceDecls();
context.endAttributes();
try {
context.text(((java.lang.String) _SumTypeSour), "SumTypeSour");
} catch (java.lang.Exception e) {
com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.Util.handlePrintConversionException(this, e, context);
}
context.endElement();
}
if (_Details!= null) {
context.startElement("", "Details");
context.childAsURIs(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endNamespaceDecls();
context.childAsAttributes(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endAttributes();
context.childAsBody(((com.sun.xml.bind.JAXBObject) _Details), "Details");
context.endElement();
}
}
public void serializeAttributes(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
}
public void serializeURIs(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
}
public java.lang.Class getPrimaryInterface() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.class);
}
public com.sun.msv.verifier.DocumentDeclaration createRawValidator() {
if (schemaFragment == null) {
schemaFragment = com.sun.xml.bind.validator.SchemaDeserializer.deserialize((
"\u00ac\u00ed\u0000\u0005sr\u0000\u001fcom.sun.msv.grammar.SequenceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.su"
+"n.msv.grammar.BinaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0004exp1t\u0000 Lcom/sun/msv/gra"
+"mmar/Expression;L\u0000\u0004exp2q\u0000~\u0000\u0002xr\u0000\u001ecom.sun.msv.grammar.Expressi"
+"on\u00f8\u0018\u0082\u00e8N5~O\u0002\u0000\u0003I\u0000\u000ecachedHashCodeL\u0000\u0013epsilonReducibilityt\u0000\u0013Ljava"
+"/lang/Boolean;L\u0000\u000bexpandedExpq\u0000~\u0000\u0002xp\n\u0094(\u00a6ppsq\u0000~\u0000\u0000\u0007y4\u00adppsq\u0000~\u0000\u0000\u0004"
+"\u0089#\u00b6ppsr\u0000\'com.sun.msv.grammar.trex.ElementPattern\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L"
+"\u0000\tnameClasst\u0000\u001fLcom/sun/msv/grammar/NameClass;xr\u0000\u001ecom.sun.msv"
+".grammar.ElementExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002Z\u0000\u001aignoreUndeclaredAttributesL"
+"\u0000\fcontentModelq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00af\u00f1\u00b9pp\u0000sq\u0000~\u0000\u0000\u0002\u00af\u00f1\u00aeppsr\u0000\u001bcom.sun.msv."
+"grammar.DataExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\u0002dtt\u0000\u001fLorg/relaxng/datatype/Data"
+"type;L\u0000\u0006exceptq\u0000~\u0000\u0002L\u0000\u0004namet\u0000\u001dLcom/sun/msv/util/StringPair;xq"
+"\u0000~\u0000\u0003\u0001h~\u008cppsr\u0000#com.sun.msv.datatype.xsd.StringType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001"
+"Z\u0000\risAlwaysValidxr\u0000*com.sun.msv.datatype.xsd.BuiltinAtomicTy"
+"pe\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000%com.sun.msv.datatype.xsd.ConcreteType\u0000\u0000\u0000\u0000\u0000\u0000"
+"\u0000\u0001\u0002\u0000\u0000xr\u0000\'com.sun.msv.datatype.xsd.XSDatatypeImpl\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L"
+"\u0000\fnamespaceUrit\u0000\u0012Ljava/lang/String;L\u0000\btypeNameq\u0000~\u0000\u0015L\u0000\nwhiteS"
+"pacet\u0000.Lcom/sun/msv/datatype/xsd/WhiteSpaceProcessor;xpt\u0000 ht"
+"tp://www.w3.org/2001/XMLSchemat\u0000\u0006stringsr\u00005com.sun.msv.datat"
+"ype.xsd.WhiteSpaceProcessor$Preserve\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000,com.sun.m"
+"sv.datatype.xsd.WhiteSpaceProcessor\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xp\u0001sr\u00000com.sun"
+".msv.grammar.Expression$NullSetExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000"
+"\u0000\nppsr\u0000\u001bcom.sun.msv.util.StringPair\u00d0t\u001ejB\u008f\u008d\u00a0\u0002\u0000\u0002L\u0000\tlocalNameq\u0000"
+"~\u0000\u0015L\u0000\fnamespaceURIq\u0000~\u0000\u0015xpq\u0000~\u0000\u0019q\u0000~\u0000\u0018sr\u0000\u001dcom.sun.msv.grammar.C"
+"hoiceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0001\u0001Gs\u001dppsr\u0000 com.sun.msv.grammar.Attri"
+"buteExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0003expq\u0000~\u0000\u0002L\u0000\tnameClassq\u0000~\u0000\txq\u0000~\u0000\u0003\u0001Gs\u0012sr\u0000\u0011"
+"java.lang.Boolean\u00cd r\u0080\u00d5\u009c\u00fa\u00ee\u0002\u0000\u0001Z\u0000\u0005valuexp\u0000psq\u0000~\u0000\r\u0000<\u00c2rppsr\u0000\"com."
+"sun.msv.datatype.xsd.QnameType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0012q\u0000~\u0000\u0018t\u0000\u0005QName"
+"sr\u00005com.sun.msv.datatype.xsd.WhiteSpaceProcessor$Collapse\u0000\u0000\u0000"
+"\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u001bq\u0000~\u0000\u001esq\u0000~\u0000\u001fq\u0000~\u0000*q\u0000~\u0000\u0018sr\u0000#com.sun.msv.grammar.S"
+"impleNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\tlocalNameq\u0000~\u0000\u0015L\u0000\fnamespaceURIq\u0000~"
+"\u0000\u0015xr\u0000\u001dcom.sun.msv.grammar.NameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpt\u0000\u0004typet\u0000)ht"
+"tp://www.w3.org/2001/XMLSchema-instancesr\u00000com.sun.msv.gramm"
+"ar.Expression$EpsilonExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\tsq\u0000~\u0000%\u0001p"
+"sq\u0000~\u0000.t\u0000\fItemCodeSourt\u0000\u0000sq\u0000~\u0000\b\u0001\u00d91\u00f8pp\u0000sq\u0000~\u0000\u0000\u0001\u00d91\u00edppq\u0000~\u0000\u0010sq\u0000~\u0000!"
+"\u0000p\u00b3\\ppsq\u0000~\u0000#\u0000p\u00b3Qq\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t\u0000\bIte"
+"mFlagq\u0000~\u00008sq\u0000~\u0000!\u0002\u00f0\u0010\u00f2ppsq\u0000~\u0000\b\u0002\u00f0\u0010\u00e7q\u0000~\u0000&p\u0000sq\u0000~\u0000\u0000\u0002\u00f0\u0010\u00dcppq\u0000~\u0000\u0010sq\u0000~"
+"\u0000!\u0001\u0087\u0092Kppsq\u0000~\u0000#\u0001\u0087\u0092@q\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t\u0000\u000bS"
+"umTypeSourq\u0000~\u00008q\u0000~\u00004sq\u0000~\u0000!\u0003\u001a\u00f3\u00f4ppsq\u0000~\u0000\b\u0003\u001a\u00f3\u00e9q\u0000~\u0000&p\u0000sq\u0000~\u0000\u0000\u0003\u001a\u00f3\u00dep"
+"psq\u0000~\u0000\b\u0001M\u001dcpp\u0000sq\u0000~\u0000!\u0001M\u001dXppsr\u0000 com.sun.msv.grammar.OneOrMoreE"
+"xp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001ccom.sun.msv.grammar.UnaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\u0003e"
+"xpq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0001M\u001dMq\u0000~\u0000&psq\u0000~\u0000#\u0001M\u001dJq\u0000~\u0000&psr\u00002com.sun.msv.gramm"
+"ar.Expression$AnyStringExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\bq\u0000~\u00005p"
+"sr\u0000 com.sun.msv.grammar.AnyNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000/q\u0000~\u00004sq"
+"\u0000~\u0000.t\u0000Bcom.sinosoft.picc.report.jaxb.complexrelation.ItemSou"
+"r.DetailsTypet\u0000+http://java.sun.com/jaxb/xjc/dummy-elementss"
+"q\u0000~\u0000!\u0001\u00cd\u00d6vppsq\u0000~\u0000#\u0001\u00cd\u00d6kq\u0000~\u0000&pq\u0000~\u0000\'sq\u0000~\u0000.q\u0000~\u00001q\u0000~\u00002q\u0000~\u00004sq\u0000~\u0000.t"
+"\u0000\u0007Detailsq\u0000~\u00008q\u0000~\u00004sr\u0000\"com.sun.msv.grammar.ExpressionPool\u0000\u0000\u0000"
+"\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\bexpTablet\u0000/Lcom/sun/msv/grammar/ExpressionPool$Cl"
+"osedHash;xpsr\u0000-com.sun.msv.grammar.ExpressionPool$ClosedHash"
+"\u00d7j\u00d0N\u00ef\u00e8\u00ed\u001c\u0002\u0000\u0004I\u0000\u0005countI\u0000\tthresholdL\u0000\u0006parentq\u0000~\u0000^[\u0000\u0005tablet\u0000![Lco"
+"m/sun/msv/grammar/Expression;xp\u0000\u0000\u0000\u000f\u0000\u0000\u00009pur\u0000![Lcom.sun.msv.gr"
+"ammar.Expression;\u00d68D\u00c3]\u00ad\u00a7\n\u0002\u0000\u0000xp\u0000\u0000\u0000\u00bfpppppppppppppppppppppppppp"
+"pppq\u0000~\u0000Bpq\u0000~\u0000Cpppppppppppppppppppq\u0000~\u0000@pppppppppppppppppppq\u0000~"
+"\u0000Oppppppppppq\u0000~\u0000Lpppppppq\u0000~\u0000Jpppppppppppppppppppq\u0000~\u0000\u0005pq\u0000~\u0000Hp"
+"pppppppppppq\u0000~\u0000\fpq\u0000~\u0000\"q\u0000~\u0000\u0007ppppppppppppppppppppppppppppppppp"
+"pppppq\u0000~\u0000:pq\u0000~\u0000;pppppppppppppq\u0000~\u0000Xq\u0000~\u0000\u0006pppppp"));
}
return new com.sun.msv.verifier.regexp.REDocumentDeclaration(schemaFragment);
}
public static class DetailsTypeImpl implements com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType, com.sun.xml.bind.JAXBObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallableObject, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializable, com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.ValidatableObject
{
protected com.sun.xml.bind.util.ListImpl _Detail = new com.sun.xml.bind.util.ListImpl(new java.util.ArrayList());
public final static java.lang.Class version = (com.sinosoft.picc.report.jaxb.complexrelation.impl.JAXBVersion.class);
private static com.sun.msv.grammar.Grammar schemaFragment;
private final static java.lang.Class PRIMARY_INTERFACE_CLASS() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType.class);
}
public java.util.List getDetail() {
return _Detail;
}
public com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingEventHandler createUnmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
return new com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.Unmarshaller(context);
}
public void serializeBody(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
context.startElement("", "Detail");
int idx_0 = idx1;
context.childAsURIs(((com.sun.xml.bind.JAXBObject) _Detail.get(idx_0 ++)), "Detail");
context.endNamespaceDecls();
int idx_1 = idx1;
context.childAsAttributes(((com.sun.xml.bind.JAXBObject) _Detail.get(idx_1 ++)), "Detail");
context.endAttributes();
context.childAsBody(((com.sun.xml.bind.JAXBObject) _Detail.get(idx1 ++)), "Detail");
context.endElement();
}
}
public void serializeAttributes(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
idx1 += 1;
}
}
public void serializeURIs(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx1 = 0;
final int len1 = _Detail.size();
while (idx1 != len1) {
idx1 += 1;
}
}
public java.lang.Class getPrimaryInterface() {
return (com.sinosoft.picc.report.jaxb.complexrelation.ItemSour.DetailsType.class);
}
public com.sun.msv.verifier.DocumentDeclaration createRawValidator() {
if (schemaFragment == null) {
schemaFragment = com.sun.xml.bind.validator.SchemaDeserializer.deserialize((
"\u00ac\u00ed\u0000\u0005sr\u0000 com.sun.msv.grammar.OneOrMoreExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001ccom.s"
+"un.msv.grammar.UnaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\u0003expt\u0000 Lcom/sun/msv/gram"
+"mar/Expression;xr\u0000\u001ecom.sun.msv.grammar.Expression\u00f8\u0018\u0082\u00e8N5~O\u0002\u0000\u0003"
+"I\u0000\u000ecachedHashCodeL\u0000\u0013epsilonReducibilityt\u0000\u0013Ljava/lang/Boolean"
+";L\u0000\u000bexpandedExpq\u0000~\u0000\u0002xp\u0002\u00d7W9ppsr\u0000\'com.sun.msv.grammar.trex.Ele"
+"mentPattern\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\tnameClasst\u0000\u001fLcom/sun/msv/grammar/Na"
+"meClass;xr\u0000\u001ecom.sun.msv.grammar.ElementExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002Z\u0000\u001aigno"
+"reUndeclaredAttributesL\u0000\fcontentModelq\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00d7W6pp\u0000sr\u0000\u001fc"
+"om.sun.msv.grammar.SequenceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.sun.msv.gra"
+"mmar.BinaryExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0004exp1q\u0000~\u0000\u0002L\u0000\u0004exp2q\u0000~\u0000\u0002xq\u0000~\u0000\u0003\u0002\u00d7W+p"
+"psq\u0000~\u0000\u0006\u0001M\u001dcpp\u0000sr\u0000\u001dcom.sun.msv.grammar.ChoiceExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq"
+"\u0000~\u0000\u000b\u0001M\u001dXppsq\u0000~\u0000\u0000\u0001M\u001dMsr\u0000\u0011java.lang.Boolean\u00cd r\u0080\u00d5\u009c\u00fa\u00ee\u0002\u0000\u0001Z\u0000\u0005value"
+"xp\u0000psr\u0000 com.sun.msv.grammar.AttributeExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\u0003expq\u0000~"
+"\u0000\u0002L\u0000\tnameClassq\u0000~\u0000\u0007xq\u0000~\u0000\u0003\u0001M\u001dJq\u0000~\u0000\u0012psr\u00002com.sun.msv.grammar.E"
+"xpression$AnyStringExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\bsq\u0000~\u0000\u0011\u0001psr"
+"\u0000 com.sun.msv.grammar.AnyNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\u001dcom.sun.msv"
+".grammar.NameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpsr\u00000com.sun.msv.grammar.Expre"
+"ssion$EpsilonExpression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\tq\u0000~\u0000\u0017psr\u0000#com.su"
+"n.msv.grammar.SimpleNameClass\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0002L\u0000\tlocalNamet\u0000\u0012Ljava"
+"/lang/String;L\u0000\fnamespaceURIq\u0000~\u0000\u001exq\u0000~\u0000\u0019t\u00004com.sinosoft.picc."
+"report.jaxb.complexrelation.Detailt\u0000+http://java.sun.com/jax"
+"b/xjc/dummy-elementssq\u0000~\u0000\u000e\u0001\u008a9\u00c3ppsq\u0000~\u0000\u0013\u0001\u008a9\u00b8q\u0000~\u0000\u0012psr\u0000\u001bcom.sun."
+"msv.grammar.DataExp\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\u0002dtt\u0000\u001fLorg/relaxng/datatype/"
+"Datatype;L\u0000\u0006exceptq\u0000~\u0000\u0002L\u0000\u0004namet\u0000\u001dLcom/sun/msv/util/StringPai"
+"r;xq\u0000~\u0000\u0003\u0000<\u00c2rppsr\u0000\"com.sun.msv.datatype.xsd.QnameType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001"
+"\u0002\u0000\u0000xr\u0000*com.sun.msv.datatype.xsd.BuiltinAtomicType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000"
+"xr\u0000%com.sun.msv.datatype.xsd.ConcreteType\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000\'com."
+"sun.msv.datatype.xsd.XSDatatypeImpl\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0003L\u0000\fnamespaceUr"
+"iq\u0000~\u0000\u001eL\u0000\btypeNameq\u0000~\u0000\u001eL\u0000\nwhiteSpacet\u0000.Lcom/sun/msv/datatype/"
+"xsd/WhiteSpaceProcessor;xpt\u0000 http://www.w3.org/2001/XMLSchem"
+"at\u0000\u0005QNamesr\u00005com.sun.msv.datatype.xsd.WhiteSpaceProcessor$Co"
+"llapse\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xr\u0000,com.sun.msv.datatype.xsd.WhiteSpaceProc"
+"essor\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xpsr\u00000com.sun.msv.grammar.Expression$NullSet"
+"Expression\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0000xq\u0000~\u0000\u0003\u0000\u0000\u0000\nppsr\u0000\u001bcom.sun.msv.util.String"
+"Pair\u00d0t\u001ejB\u008f\u008d\u00a0\u0002\u0000\u0002L\u0000\tlocalNameq\u0000~\u0000\u001eL\u0000\fnamespaceURIq\u0000~\u0000\u001expq\u0000~\u0000/q"
+"\u0000~\u0000.sq\u0000~\u0000\u001dt\u0000\u0004typet\u0000)http://www.w3.org/2001/XMLSchema-instanc"
+"eq\u0000~\u0000\u001csq\u0000~\u0000\u001dt\u0000\u0006Detailt\u0000\u0000sr\u0000\"com.sun.msv.grammar.ExpressionPo"
+"ol\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0002\u0000\u0001L\u0000\bexpTablet\u0000/Lcom/sun/msv/grammar/ExpressionPo"
+"ol$ClosedHash;xpsr\u0000-com.sun.msv.grammar.ExpressionPool$Close"
+"dHash\u00d7j\u00d0N\u00ef\u00e8\u00ed\u001c\u0002\u0000\u0004I\u0000\u0005countI\u0000\tthresholdL\u0000\u0006parentq\u0000~\u0000>[\u0000\u0005tablet\u0000"
+"![Lcom/sun/msv/grammar/Expression;xp\u0000\u0000\u0000\u0005\u0000\u0000\u00009pur\u0000![Lcom.sun.m"
+"sv.grammar.Expression;\u00d68D\u00c3]\u00ad\u00a7\n\u0002\u0000\u0000xp\u0000\u0000\u0000\u00bfppppppppppppppppppppp"
+"ppppppppppppppppppppppppppppppppppppppppppppppppppq\u0000~\u0000\u0010q\u0000~\u0000\f"
+"pppppppppq\u0000~\u0000\u000fpppq\u0000~\u0000\u0005pppppppppppppppppppppppppppppppppppppp"
+"ppppppppppppppppppppppppppppppppppppppppq\u0000~\u0000\"ppppppppppppppp"
+"pppppppppp"));
}
return new com.sun.msv.verifier.regexp.REDocumentDeclaration(schemaFragment);
}
public class Unmarshaller
extends com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.AbstractUnmarshallingEventHandlerImpl
{
public Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
super(context, "----");
}
protected Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context, int startState) {
this(context);
state = startState;
}
public java.lang.Object owner() {
return com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.this;
}
public void enterElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname, org.xml.sax.Attributes __atts)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 1 :
if (("DetailCode" == ___local)&&("" == ___uri)) {
_Detail.add(((com.sinosoft.picc.report.jaxb.complexrelation.impl.DetailImpl) spawnChildFromEnterElement((com.sinosoft.picc.report.jaxb.complexrelation.impl.DetailImpl.class), 2, ___uri, ___local, ___qname, __atts)));
return ;
}
break;
case 3 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 1;
return ;
}
revertToParentFromEnterElement(___uri, ___local, ___qname, __atts);
return ;
case 0 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 1;
return ;
}
break;
}
super.enterElement(___uri, ___local, ___qname, __atts);
break;
}
}
public void leaveElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromLeaveElement(___uri, ___local, ___qname);
return ;
case 2 :
if (("Detail" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 3;
return ;
}
break;
}
super.leaveElement(___uri, ___local, ___qname);
break;
}
}
public void enterAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromEnterAttribute(___uri, ___local, ___qname);
return ;
}
super.enterAttribute(___uri, ___local, ___qname);
break;
}
}
public void leaveAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
revertToParentFromLeaveAttribute(___uri, ___local, ___qname);
return ;
}
super.leaveAttribute(___uri, ___local, ___qname);
break;
}
}
public void handleText(final java.lang.String value)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
try {
switch (state) {
case 3 :
revertToParentFromText(value);
return ;
}
} catch (java.lang.RuntimeException e) {
handleUnexpectedTextException(value, e);
}
break;
}
}
}
}
public class Unmarshaller
extends com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.AbstractUnmarshallingEventHandlerImpl
{
public Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context) {
super(context, "-------------");
}
protected Unmarshaller(com.sinosoft.picc.report.jaxb.complexrelation.impl.runtime.UnmarshallingContext context, int startState) {
this(context);
state = startState;
}
public java.lang.Object owner() {
return com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.this;
}
public void enterElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname, org.xml.sax.Attributes __atts)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 3 :
if (("ItemFlag" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 4;
return ;
}
break;
case 9 :
if (("Details" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, false);
state = 10;
return ;
}
state = 12;
continue outer;
case 0 :
if (("ItemCodeSour" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 1;
return ;
}
break;
case 10 :
if (("Detail" == ___local)&&("" == ___uri)) {
_Details = ((com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl) spawnChildFromEnterElement((com.sinosoft.picc.report.jaxb.complexrelation.impl.ItemSourImpl.DetailsTypeImpl.class), 11, ___uri, ___local, ___qname, __atts));
return ;
}
break;
case 12 :
revertToParentFromEnterElement(___uri, ___local, ___qname, __atts);
return ;
case 6 :
if (("SumTypeSour" == ___local)&&("" == ___uri)) {
context.pushAttributes(__atts, true);
state = 7;
return ;
}
state = 9;
continue outer;
}
super.enterElement(___uri, ___local, ___qname, __atts);
break;
}
}
public void leaveElement(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 8 :
if (("SumTypeSour" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 9;
return ;
}
break;
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromLeaveElement(___uri, ___local, ___qname);
return ;
case 2 :
if (("ItemCodeSour" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 3;
return ;
}
break;
case 5 :
if (("ItemFlag" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 6;
return ;
}
break;
case 6 :
state = 9;
continue outer;
case 11 :
if (("Details" == ___local)&&("" == ___uri)) {
context.popAttributes();
state = 12;
return ;
}
break;
}
super.leaveElement(___uri, ___local, ___qname);
break;
}
}
public void enterAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromEnterAttribute(___uri, ___local, ___qname);
return ;
case 6 :
state = 9;
continue outer;
}
super.enterAttribute(___uri, ___local, ___qname);
break;
}
}
public void leaveAttribute(java.lang.String ___uri, java.lang.String ___local, java.lang.String ___qname)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
switch (state) {
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromLeaveAttribute(___uri, ___local, ___qname);
return ;
case 6 :
state = 9;
continue outer;
}
super.leaveAttribute(___uri, ___local, ___qname);
break;
}
}
public void handleText(final java.lang.String value)
throws org.xml.sax.SAXException
{
int attIdx;
outer:
while (true) {
try {
switch (state) {
case 1 :
eatText1(value);
state = 2;
return ;
case 9 :
state = 12;
continue outer;
case 12 :
revertToParentFromText(value);
return ;
case 4 :
eatText2(value);
state = 5;
return ;
case 7 :
eatText3(value);
state = 8;
return ;
case 6 :
state = 9;
continue outer;
}
} catch (java.lang.RuntimeException e) {
handleUnexpectedTextException(value, e);
}
break;
}
}
private void eatText1(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_ItemCodeSour = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
private void eatText2(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_ItemFlag = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
private void eatText3(final java.lang.String value)
throws org.xml.sax.SAXException
{
try {
_SumTypeSour = value;
} catch (java.lang.Exception e) {
handleParseConversionException(e);
}
}
}
}
| 35,549 | 0.606037 | 0.456609 | 658 | 53.025837 | 50.767075 | 381 | false | false | 0 | 0 | 66 | 0.112408 | 0 | 0 | 0.515198 | false | false |
13
|
d8f9b8d70de79c1eb6c58a3e8a9d03fa41ef6109
| 27,487,790,752,697 |
d641d77d9c48dbb6e29139cbae8fc5555b5ecee0
|
/src/com/offer/线性表/Queue.java
|
e882831ff1eb1b119d65eff4d1b35312a0b65f8e
|
[] |
no_license
|
lixuehan1129/algorithm
|
https://github.com/lixuehan1129/algorithm
|
8dbbd68b6b2161ac71ea1297c4600e3fcf7d5e9d
|
40f1c14b64b239e809f31c228df9b0702e2d7f07
|
refs/heads/master
| 2023-01-05T07:08:19.383000 | 2020-11-09T00:48:18 | 2020-11-09T00:48:18 | 294,684,418 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.offer.线性表;
import java.util.Iterator;
/**
* 老爹说过要用魔法打败魔法
* *
*
* @ClassName: Queue
* @Author 李学翰
* @Description: TODO
* @Data: Create in 15:31 2020/7/27
* @Version: *
* <p>
* 你只管开车办法由老爹来想
*/
public class Queue<T> implements Iterable<T>{
//记录首结点
private Node head;
//记录当前队列的元素个数
private int N;
//记录最后一个结点
private Node last;
//结点类
private class Node{
//存储数据
T item;
//下一个结点
Node next;
public Node(T item, Node next) {
this.item = item;
this.next = next;
}
}
public Queue(){
this.head = new Node(null, null);
this.last = null;
this.N = 0;
}
//判断队列是否为空
public boolean isEmpty(){
return this.N == 0;
}
//获取队列中元素的个数
public int size(){
return this.N;
}
//从队列中拿出一个元素
public T dequeue(){
if(isEmpty()){
return null;
}
Node oldNode = head.next;
head.next = oldNode.next;
this.N--;
//因为出队列其实是在删除元素,如果队列中的元素被删除了,需要重置last=null
if(isEmpty()){
last = null;
}
return oldNode.item;
}
//往队列中插入一个元素
public void enqueue(T t){
if(last == null){
//当前尾结点last为null
last = new Node(t, null);
this.head.next = last;
}else {
//当前尾结点last不为null
Node lastNode = last;
last = new Node(t, null);
lastNode.next = last;
}
this.N++;
}
@Override
public Iterator<T> iterator() {
return new StIterator();
}
private class StIterator implements Iterator{
private Node node;
public StIterator(){
this.node = head;
}
@Override
public boolean hasNext() {
return node.next != null;
}
@Override
public Object next() {
node = node.next;
return node.item;
}
}
}
|
UTF-8
|
Java
| 2,310 |
java
|
Queue.java
|
Java
|
[
{
"context": "过要用魔法打败魔法\n * *\n *\n * @ClassName: Queue\n * @Author 李学翰\n * @Description: TODO\n * @Data: Create in 15:31 2",
"end": 115,
"score": 0.9974864721298218,
"start": 112,
"tag": "NAME",
"value": "李学翰"
}
] | null |
[] |
package com.offer.线性表;
import java.util.Iterator;
/**
* 老爹说过要用魔法打败魔法
* *
*
* @ClassName: Queue
* @Author 李学翰
* @Description: TODO
* @Data: Create in 15:31 2020/7/27
* @Version: *
* <p>
* 你只管开车办法由老爹来想
*/
public class Queue<T> implements Iterable<T>{
//记录首结点
private Node head;
//记录当前队列的元素个数
private int N;
//记录最后一个结点
private Node last;
//结点类
private class Node{
//存储数据
T item;
//下一个结点
Node next;
public Node(T item, Node next) {
this.item = item;
this.next = next;
}
}
public Queue(){
this.head = new Node(null, null);
this.last = null;
this.N = 0;
}
//判断队列是否为空
public boolean isEmpty(){
return this.N == 0;
}
//获取队列中元素的个数
public int size(){
return this.N;
}
//从队列中拿出一个元素
public T dequeue(){
if(isEmpty()){
return null;
}
Node oldNode = head.next;
head.next = oldNode.next;
this.N--;
//因为出队列其实是在删除元素,如果队列中的元素被删除了,需要重置last=null
if(isEmpty()){
last = null;
}
return oldNode.item;
}
//往队列中插入一个元素
public void enqueue(T t){
if(last == null){
//当前尾结点last为null
last = new Node(t, null);
this.head.next = last;
}else {
//当前尾结点last不为null
Node lastNode = last;
last = new Node(t, null);
lastNode.next = last;
}
this.N++;
}
@Override
public Iterator<T> iterator() {
return new StIterator();
}
private class StIterator implements Iterator{
private Node node;
public StIterator(){
this.node = head;
}
@Override
public boolean hasNext() {
return node.next != null;
}
@Override
public Object next() {
node = node.next;
return node.item;
}
}
}
| 2,310 | 0.492056 | 0.485601 | 105 | 18.180952 | 12.497452 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342857 | false | false |
13
|
17f84ff610f0e4cf33e858a7b29d950878b417ba
| 28,690,381,559,097 |
c7877c8eb9f27b408cdf1685082f9303e63829a7
|
/java_multithreading/src/main/java/org/emil/completablefuture/demo_02/future/FutureTest.java
|
e3f07f7e2fd7d235e74e9a44e131816c99798a75
|
[] |
no_license
|
EmilXMG/JavaStudy
|
https://github.com/EmilXMG/JavaStudy
|
b34a15c14a8daa3a8c40750354073909265bfce2
|
ea1406a6e879cdf9fa9266795ba65200faa61edf
|
refs/heads/master
| 2023-07-25T01:50:05.474000 | 2023-07-07T08:01:22 | 2023-07-07T08:01:22 | 242,535,346 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.emil.completablefuture.demo_02.future;
import org.emil.completablefuture.demo_02.entity.MedalInfo;
import org.emil.completablefuture.demo_02.entity.UserInfo;
import org.emil.completablefuture.demo_02.service.MedalService;
import org.emil.completablefuture.demo_02.service.UserInfoService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
/**
* @Author: emil
* @Date: 2023/6/8 14:21
* @Version: v1.0.0
* @Description: TODO
**/
public class FutureTest {
public static void main(String[] args) throws InterruptedException, ExecutionException {
ExecutorService executorService = Executors.newFixedThreadPool(10);
UserInfoService userInfoService = new UserInfoService();
MedalService medalService = new MedalService();
long userId = 666L;
long startTime = System.currentTimeMillis();
//调用用户服务获取用户基本信息
FutureTask<UserInfo> userInfoFutureTask = new FutureTask<>(() -> userInfoService.getUserInfo(userId));
executorService.submit(userInfoFutureTask);
// 模拟其他线程耗时
Thread.sleep(300);
FutureTask<MedalInfo> medalInfoFutureTask = new FutureTask<>(() -> medalService.getMedalInfo(userId));
executorService.submit(medalInfoFutureTask);
//获取个人信息结果
UserInfo userInfo = userInfoFutureTask.get();
//获取勋章信息结果
MedalInfo medalInfo = medalInfoFutureTask.get();
System.out.println("共用时:" + (System.currentTimeMillis() - startTime) + "ms");
}
}
|
UTF-8
|
Java
| 1,703 |
java
|
FutureTest.java
|
Java
|
[
{
"context": " java.util.concurrent.FutureTask;\n\n/**\n * @Author: emil\n * @Date: 2023/6/8 14:21\n * @Version: v1.0.0\n * @",
"end": 496,
"score": 0.9996066689491272,
"start": 492,
"tag": "USERNAME",
"value": "emil"
}
] | null |
[] |
package org.emil.completablefuture.demo_02.future;
import org.emil.completablefuture.demo_02.entity.MedalInfo;
import org.emil.completablefuture.demo_02.entity.UserInfo;
import org.emil.completablefuture.demo_02.service.MedalService;
import org.emil.completablefuture.demo_02.service.UserInfoService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
/**
* @Author: emil
* @Date: 2023/6/8 14:21
* @Version: v1.0.0
* @Description: TODO
**/
public class FutureTest {
public static void main(String[] args) throws InterruptedException, ExecutionException {
ExecutorService executorService = Executors.newFixedThreadPool(10);
UserInfoService userInfoService = new UserInfoService();
MedalService medalService = new MedalService();
long userId = 666L;
long startTime = System.currentTimeMillis();
//调用用户服务获取用户基本信息
FutureTask<UserInfo> userInfoFutureTask = new FutureTask<>(() -> userInfoService.getUserInfo(userId));
executorService.submit(userInfoFutureTask);
// 模拟其他线程耗时
Thread.sleep(300);
FutureTask<MedalInfo> medalInfoFutureTask = new FutureTask<>(() -> medalService.getMedalInfo(userId));
executorService.submit(medalInfoFutureTask);
//获取个人信息结果
UserInfo userInfo = userInfoFutureTask.get();
//获取勋章信息结果
MedalInfo medalInfo = medalInfoFutureTask.get();
System.out.println("共用时:" + (System.currentTimeMillis() - startTime) + "ms");
}
}
| 1,703 | 0.722051 | 0.702903 | 50 | 31.379999 | 30.800577 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.46 | false | false |
13
|
9417fd8a174cc36e3bb4193159c33d1ebf9ba3ee
| 16,080,357,587,492 |
471f7552f5fdc89fb29271ce4a45dffeb28b96fa
|
/sell/src/main/java/com/imooc/utils/KeyUtil.java
|
b08c3f5ce765ae6954aef79a6380208eefcce8d4
|
[] |
no_license
|
sgwe/WechatOrder
|
https://github.com/sgwe/WechatOrder
|
7bec0e24fe3f83ffbb9b20954118ea1bf804b321
|
041a613170091291d64b7c870776dc08f1a19846
|
refs/heads/master
| 2020-08-03T05:23:15.488000 | 2019-09-29T13:30:20 | 2019-09-29T13:30:20 | 211,636,923 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.imooc.utils;
import java.util.Random;
/**
* @Author yangxi
* @Date 2019/7/22 16:00
*/
public class KeyUtil {
/**
* 功能描述: 自动生成订单id(生成唯一主键)
* 格式:时间+随机数
*/
public static synchronized String genUniqueKey() {
Random random = new Random();
Integer number = random.nextInt(900000) + 100000;
return System.currentTimeMillis() + String.valueOf(number);
}
}
|
UTF-8
|
Java
| 470 |
java
|
KeyUtil.java
|
Java
|
[
{
"context": "c.utils;\n\nimport java.util.Random;\n\n/**\n * @Author yangxi\n * @Date 2019/7/22 16:00\n */\npublic class KeyUtil",
"end": 73,
"score": 0.9995813369750977,
"start": 67,
"tag": "USERNAME",
"value": "yangxi"
}
] | null |
[] |
package com.imooc.utils;
import java.util.Random;
/**
* @Author yangxi
* @Date 2019/7/22 16:00
*/
public class KeyUtil {
/**
* 功能描述: 自动生成订单id(生成唯一主键)
* 格式:时间+随机数
*/
public static synchronized String genUniqueKey() {
Random random = new Random();
Integer number = random.nextInt(900000) + 100000;
return System.currentTimeMillis() + String.valueOf(number);
}
}
| 470 | 0.619617 | 0.564593 | 21 | 18.904762 | 19.830004 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.238095 | false | false |
13
|
2448b5fdbbfef4c8d0652e62d4491a0f9daf87e9
| 31,267,361,926,275 |
551a6099a3c91da61970eaf37d8951056b0cbbef
|
/src/main/java/com/joseluisgs/productosapirest/dto/GetPedidoDTO.java
|
899cc92903ba31e850aa227501c9742884f0e040
|
[] |
no_license
|
CIFP-Virgen-de-Gracia/productosapirest-sec
|
https://github.com/CIFP-Virgen-de-Gracia/productosapirest-sec
|
1fe357b411d85ffad2e449be4aa2066fc719b096
|
4dae3ac8939f30f481b4743b0db5d90466e008dc
|
refs/heads/master
| 2021-05-24T07:59:43.276000 | 2020-03-30T12:28:06 | 2020-03-30T12:28:06 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.joseluisgs.productosapirest.dto;
import java.time.LocalDateTime;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class GetPedidoDTO {
private String fullName;
private String email;
private String avatar;
@JsonFormat(shape = Shape.STRING, pattern = "dd/MM/yyyy HH:mm:ss")
private LocalDateTime fecha;
private Set<GetLineaPedidoDTO> lineas;
private float total;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class GetLineaPedidoDTO {
private String productoNombre;
private int cantidad;
private float precioUnitario;
private float subTotal;
}
}
|
UTF-8
|
Java
| 977 |
java
|
GetPedidoDTO.java
|
Java
|
[] | null |
[] |
package com.joseluisgs.productosapirest.dto;
import java.time.LocalDateTime;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class GetPedidoDTO {
private String fullName;
private String email;
private String avatar;
@JsonFormat(shape = Shape.STRING, pattern = "dd/MM/yyyy HH:mm:ss")
private LocalDateTime fecha;
private Set<GetLineaPedidoDTO> lineas;
private float total;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public static class GetLineaPedidoDTO {
private String productoNombre;
private int cantidad;
private float precioUnitario;
private float subTotal;
}
}
| 977 | 0.745138 | 0.745138 | 48 | 19.354166 | 17.381132 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4375 | false | false |
13
|
817400025a302918d1f275f2fc867b0868bf085c
| 34,763,465,299,007 |
22d12450ae61ec47b7614347ccf16dfe89bf946e
|
/xbase-web/src/main/java/com/apollo/xbase/web/spring/SpringDataSourceConfig.java
|
72bebaaee28d4270bc46e74e7be41afbb9e28f68
|
[] |
no_license
|
ChawinTyan/xbase
|
https://github.com/ChawinTyan/xbase
|
eda9d75a045e81804792c8d4a4741d1e457fe56d
|
f4863a8490380fce70d959e70175944214cf84f8
|
refs/heads/master
| 2020-03-29T09:11:20.378000 | 2019-08-27T15:16:43 | 2019-08-27T15:16:43 | 149,745,274 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.apollo.xbase.web.spring;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class SpringDataSourceConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource(){
return new DruidDataSource();
}
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception{
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
return sessionFactoryBean.getObject();
}
}
|
UTF-8
|
Java
| 879 |
java
|
SpringDataSourceConfig.java
|
Java
|
[] | null |
[] |
package com.apollo.xbase.web.spring;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class SpringDataSourceConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource(){
return new DruidDataSource();
}
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception{
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
return sessionFactoryBean.getObject();
}
}
| 879 | 0.784983 | 0.784983 | 28 | 30.392857 | 25.729832 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false |
13
|
c09a25b2b65af5fe9c267bcd957bfd26eb4764bd
| 7,301,444,466,135 |
fb007f8e23684621ff271a20f45e83eda9c3448f
|
/app/src/main/java/example/codeclan/com/blackjack/Runner.java
|
87cb473294f218c3d6ab6fa38c3d2c4c694430e8
|
[] |
no_license
|
goobering/Blackjack
|
https://github.com/goobering/Blackjack
|
6e159469f69cb6cafa1048a7b71560f7018a915d
|
34aee78d3c1cace273429a4d4b761af46892f948
|
refs/heads/master
| 2021-01-21T23:16:32.103000 | 2017-06-25T21:20:16 | 2017-06-25T21:20:16 | 95,386,411 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package example.codeclan.com.blackjack;
import java.util.ArrayList;
import java.util.List;
/**
* Created by user on 23/06/2017.
*/
public class Runner
{
public static void main(String[] args)
{
Viewer viewer = new Viewer();
//Set up deck
Deck deck = new Deck();
deck.makeDeck();
deck.shuffle();
//Create game with deck
Game game = new Game(deck);
//Get the user to input how many players
int numPlayers = viewer.getNumPlayers();
//Create [x] players and add to game
for(int i = 0; i < numPlayers; i++)
{
Player player = new Player(viewer.getPlayerName(i+1));
game.addPlayer(player);
}
//Deal 2 cards to dealer
game.dealNumCardsTo(game.getDealer(), 2);
//Deal 2 cards to each player
game.dealNumCardsToAllPlayers(2);
//Show the dealer's first card
viewer.showDealerFirstCardScript();
viewer.showCardAtPosition(game.getDealer(), 0);
//Loop around every player once
while(game.getPlayers().size() > 0)
{
Player player = game.getPlayers().get(0);
//Show player their cards
viewer.showPlayerCards(player);
//Check for natural
if(player.hasNatural())
{
viewer.showNaturalWin(player);
//Shunt player into relevant category
game.movePlayerFromTo(player, game.getPlayers(), game.getNaturals());
//Move on to next player
continue;
}
//Stick user in infinite loop till they're done twisting or bust.
char playerChoice = 'Z';
while(playerChoice != 'S')
{
//Player chooses stick or twist
playerChoice = viewer.getPlayerChoice();
//If T(wist) then deal another card and loop
if(playerChoice == 'T')
{
game.dealNumCardsTo(player, 1);
viewer.showPlayerCards(player);
//If hand is over 21, try swapping a high ace for low until not bust or no more aces
player.convertBustedAces();
}
//If player's bust, shunt them into Losers category and leave input loop
if(player.isBusted())
{
viewer.showBusted(player);
game.movePlayerFromTo(player, game.getPlayers(), game.getLosers());
break;
}
}
//If done twisting and not bust, move into Limbo category
if(!player.isBusted())
{
game.movePlayerFromTo(player, game.getPlayers(), game.getLimboPlayers());
}
}
//Show dealer's second card
viewer.showPlayerCards(game.getDealer());
//If dealer has natural, everyone who doesn't loses:
if(game.getDealer().hasNatural())
{
viewer.showNaturalWin(game.getDealer());
//Move non-natural winners and limbo players to losers category:
game.moveAllFromTo(game.getWinners(), game.getLosers());
game.moveAllFromTo(game.getLimboPlayers(), game.getLosers());
viewer.showEnd(game);
return;
}
//Dealer draws till they hit 17 or go bust
while(game.getDealer().sumCardValue() < 17)
{
game.dealCardTo(game.getDealer());
viewer.showPlayerCards(game.getDealer());
//If hand is over 21, try swapping a high ace for low until no more aces
game.getDealer().convertBustedAces();
}
//Set dealer's score to 0 if busted
if(game.getDealer().isBusted())
{
viewer.showBusted(game.getDealer());
game.getDealer().dropCards();
}
//If not busted, dealer sticks
else
{
viewer.showDealerStickScript();
}
//Loop around players in limbo (no naturals, not bust)
while(game.getLimboPlayers().size() > 0)
{
Player player = game.getLimboPlayers().get(0);
//If player score beats dealer score move player into winners category
if(player.sumCardValue() > game.getDealer().sumCardValue())
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getWinners());
}
//If player score loses to dealer score move player into losers category
else if(player.sumCardValue() < game.getDealer().sumCardValue())
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getLosers());
}
//If tied with dealer score move player into tied category
else
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getTiedPlayers());
}
}
//Display final scores
viewer.showEnd(game);
}
}
|
UTF-8
|
Java
| 5,099 |
java
|
Runner.java
|
Java
|
[
{
"context": "rayList;\nimport java.util.List;\n\n/**\n * Created by user on 23/06/2017.\n */\n\npublic class Runner\n{\n pub",
"end": 115,
"score": 0.9494905471801758,
"start": 111,
"tag": "USERNAME",
"value": "user"
}
] | null |
[] |
package example.codeclan.com.blackjack;
import java.util.ArrayList;
import java.util.List;
/**
* Created by user on 23/06/2017.
*/
public class Runner
{
public static void main(String[] args)
{
Viewer viewer = new Viewer();
//Set up deck
Deck deck = new Deck();
deck.makeDeck();
deck.shuffle();
//Create game with deck
Game game = new Game(deck);
//Get the user to input how many players
int numPlayers = viewer.getNumPlayers();
//Create [x] players and add to game
for(int i = 0; i < numPlayers; i++)
{
Player player = new Player(viewer.getPlayerName(i+1));
game.addPlayer(player);
}
//Deal 2 cards to dealer
game.dealNumCardsTo(game.getDealer(), 2);
//Deal 2 cards to each player
game.dealNumCardsToAllPlayers(2);
//Show the dealer's first card
viewer.showDealerFirstCardScript();
viewer.showCardAtPosition(game.getDealer(), 0);
//Loop around every player once
while(game.getPlayers().size() > 0)
{
Player player = game.getPlayers().get(0);
//Show player their cards
viewer.showPlayerCards(player);
//Check for natural
if(player.hasNatural())
{
viewer.showNaturalWin(player);
//Shunt player into relevant category
game.movePlayerFromTo(player, game.getPlayers(), game.getNaturals());
//Move on to next player
continue;
}
//Stick user in infinite loop till they're done twisting or bust.
char playerChoice = 'Z';
while(playerChoice != 'S')
{
//Player chooses stick or twist
playerChoice = viewer.getPlayerChoice();
//If T(wist) then deal another card and loop
if(playerChoice == 'T')
{
game.dealNumCardsTo(player, 1);
viewer.showPlayerCards(player);
//If hand is over 21, try swapping a high ace for low until not bust or no more aces
player.convertBustedAces();
}
//If player's bust, shunt them into Losers category and leave input loop
if(player.isBusted())
{
viewer.showBusted(player);
game.movePlayerFromTo(player, game.getPlayers(), game.getLosers());
break;
}
}
//If done twisting and not bust, move into Limbo category
if(!player.isBusted())
{
game.movePlayerFromTo(player, game.getPlayers(), game.getLimboPlayers());
}
}
//Show dealer's second card
viewer.showPlayerCards(game.getDealer());
//If dealer has natural, everyone who doesn't loses:
if(game.getDealer().hasNatural())
{
viewer.showNaturalWin(game.getDealer());
//Move non-natural winners and limbo players to losers category:
game.moveAllFromTo(game.getWinners(), game.getLosers());
game.moveAllFromTo(game.getLimboPlayers(), game.getLosers());
viewer.showEnd(game);
return;
}
//Dealer draws till they hit 17 or go bust
while(game.getDealer().sumCardValue() < 17)
{
game.dealCardTo(game.getDealer());
viewer.showPlayerCards(game.getDealer());
//If hand is over 21, try swapping a high ace for low until no more aces
game.getDealer().convertBustedAces();
}
//Set dealer's score to 0 if busted
if(game.getDealer().isBusted())
{
viewer.showBusted(game.getDealer());
game.getDealer().dropCards();
}
//If not busted, dealer sticks
else
{
viewer.showDealerStickScript();
}
//Loop around players in limbo (no naturals, not bust)
while(game.getLimboPlayers().size() > 0)
{
Player player = game.getLimboPlayers().get(0);
//If player score beats dealer score move player into winners category
if(player.sumCardValue() > game.getDealer().sumCardValue())
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getWinners());
}
//If player score loses to dealer score move player into losers category
else if(player.sumCardValue() < game.getDealer().sumCardValue())
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getLosers());
}
//If tied with dealer score move player into tied category
else
{
game.movePlayerFromTo(player, game.getLimboPlayers(), game.getTiedPlayers());
}
}
//Display final scores
viewer.showEnd(game);
}
}
| 5,099 | 0.545009 | 0.539321 | 157 | 31.477707 | 26.302887 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.458599 | false | false |
13
|
b4518d42645138099dbf2e9132ab0efcaf69c727
| 27,771,258,604,083 |
760f285eabf015b7906229697302305fb1d0bd5c
|
/src/br/com/softgraf/model/dao/DAOImpl.java
|
9147b5cebe24e3adfed7af0d2686dd92b3928055
|
[] |
no_license
|
rafareypy/Correcao
|
https://github.com/rafareypy/Correcao
|
2d38add615716d0ddf5a2020cdef897ad533ab65
|
71f270fbb090e92ffff4155ccf379b65005e72a9
|
refs/heads/master
| 2021-01-22T04:57:24.646000 | 2014-11-25T23:10:47 | 2014-11-25T23:10:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package br.com.softgraf.model.dao;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import br.com.softgraf.model.bean.Funcionario;
import br.com.softgraf.model.bean.Unidade;
import br.com.softgraf.util.HibernateUtil;
public class DAOImpl<T> implements DAO<T> {
private Class<T> classe;
private Session session;
public DAOImpl(Class<T> classe,Session session)
{
super();
this.classe = classe;
this.session = session;
}
@Override
public void salvar(T bean) {
session.save(bean);
}
@Override
public void atualizar(T bean) {
session.update(bean);
// TODO Auto-generated method stub
}
@Override
public void excluir(T bean) {
session.delete(bean);
// TODO Auto-generated method stub
}
@Override
public T getBean(Serializable codigo) {
T bean = (T)session.get(classe, codigo);
return bean;
}
@Override
public List<T> getBeans() {
List<T> beansT = (List<T>)session.createCriteria(classe).list();
return beansT;
}
public Funcionario getFuncionario(String login, String senha){
Session session = HibernateUtil.getSessionfactory().getCurrentSession();
session.beginTransaction();
return getFuncionarioToCriteria(login, senha);
}
public Funcionario getFuncionarioToCriteria(String login, String senha)
{
Criteria criteria = session.createCriteria(Funcionario.class);
criteria.add(Restrictions.eq("login", login));
criteria.add(Restrictions.eq("senha", senha));
List<Funcionario> lista = (List<Funcionario>)criteria.list();
for (Funcionario funcionario : lista) {
System.out.println("Funcionario encontrado");
System.out.println(funcionario.toString());
}
if (lista == null || lista.size() <= 0){
return null;
}else {
return lista.get(0);
}
}
}
|
UTF-8
|
Java
| 1,933 |
java
|
DAOImpl.java
|
Java
|
[] | null |
[] |
package br.com.softgraf.model.dao;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import br.com.softgraf.model.bean.Funcionario;
import br.com.softgraf.model.bean.Unidade;
import br.com.softgraf.util.HibernateUtil;
public class DAOImpl<T> implements DAO<T> {
private Class<T> classe;
private Session session;
public DAOImpl(Class<T> classe,Session session)
{
super();
this.classe = classe;
this.session = session;
}
@Override
public void salvar(T bean) {
session.save(bean);
}
@Override
public void atualizar(T bean) {
session.update(bean);
// TODO Auto-generated method stub
}
@Override
public void excluir(T bean) {
session.delete(bean);
// TODO Auto-generated method stub
}
@Override
public T getBean(Serializable codigo) {
T bean = (T)session.get(classe, codigo);
return bean;
}
@Override
public List<T> getBeans() {
List<T> beansT = (List<T>)session.createCriteria(classe).list();
return beansT;
}
public Funcionario getFuncionario(String login, String senha){
Session session = HibernateUtil.getSessionfactory().getCurrentSession();
session.beginTransaction();
return getFuncionarioToCriteria(login, senha);
}
public Funcionario getFuncionarioToCriteria(String login, String senha)
{
Criteria criteria = session.createCriteria(Funcionario.class);
criteria.add(Restrictions.eq("login", login));
criteria.add(Restrictions.eq("senha", senha));
List<Funcionario> lista = (List<Funcionario>)criteria.list();
for (Funcionario funcionario : lista) {
System.out.println("Funcionario encontrado");
System.out.println(funcionario.toString());
}
if (lista == null || lista.size() <= 0){
return null;
}else {
return lista.get(0);
}
}
}
| 1,933 | 0.69374 | 0.692706 | 106 | 17.235849 | 20.043139 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.801887 | false | false |
13
|
ee4297ce7d4abe2a93b788351c0e74dd5f835222
| 455,266,533,757 |
4b00fb3dc3162ef46aae9f5bf340effbb7c42ba5
|
/ch5/Solution1.java
|
f9393199093b81eb8de3b97e74248c75042e9356
|
[] |
no_license
|
polydier/CCAssignment
|
https://github.com/polydier/CCAssignment
|
bfc3a3deabf693faa0f19393d1de3e80b2019d2c
|
11214941efb5b9d55e93cf11ed11755b68c3ed21
|
refs/heads/master
| 2021-01-17T06:48:44.713000 | 2015-10-08T05:46:22 | 2015-10-08T05:46:22 | 42,411,562 | 0 | 0 | null | true | 2015-09-13T20:24:52 | 2015-09-13T20:24:52 | 2015-09-10T16:11:57 | 2015-09-12T22:54:45 | 108 | 0 | 0 | 0 | null | null | null |
package ch5;
//andrew ID:dzhu1
//import java.io.*;
import java.util.Scanner;
// given two 32-bit numbers, N and M, and two bit positions.
public class Solution1 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String[] input = (s.split(" "));
int newinput[] = new int[4];
for(int i=0;i<4;i++){
newinput[i]=Integer.parseInt(input[i]);
}
System.out.println(insert(newinput[0],newinput[1],newinput[2],newinput[3]));
in.close();
}
public static int insert(int N, int M, int j, int i){
int mask = (~(-1>>>(31-j)))|((1<<i)-1);
System.out.println("mask+"+mask);
int tmpN=N&mask;
System.out.println("tmpN+"+tmpN);
int tmpM=M<<i;
System.out.println("tmpM+"+tmpM);
return tmpN|tmpM;
}
}
|
UTF-8
|
Java
| 772 |
java
|
Solution1.java
|
Java
|
[
{
"context": "package ch5;\n//andrew ID:dzhu1\n//import java.io.*;\nimport java.util.Sca",
"end": 21,
"score": 0.9987841844558716,
"start": 15,
"tag": "NAME",
"value": "andrew"
},
{
"context": "package ch5;\n//andrew ID:dzhu1\n//import java.io.*;\nimport java.util.Scanner;\n// ",
"end": 30,
"score": 0.9988611340522766,
"start": 25,
"tag": "USERNAME",
"value": "dzhu1"
}
] | null |
[] |
package ch5;
//andrew ID:dzhu1
//import java.io.*;
import java.util.Scanner;
// given two 32-bit numbers, N and M, and two bit positions.
public class Solution1 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String[] input = (s.split(" "));
int newinput[] = new int[4];
for(int i=0;i<4;i++){
newinput[i]=Integer.parseInt(input[i]);
}
System.out.println(insert(newinput[0],newinput[1],newinput[2],newinput[3]));
in.close();
}
public static int insert(int N, int M, int j, int i){
int mask = (~(-1>>>(31-j)))|((1<<i)-1);
System.out.println("mask+"+mask);
int tmpN=N&mask;
System.out.println("tmpN+"+tmpN);
int tmpM=M<<i;
System.out.println("tmpM+"+tmpM);
return tmpN|tmpM;
}
}
| 772 | 0.637306 | 0.615285 | 28 | 26.571428 | 18.354502 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.392857 | false | false |
13
|
f676755553175cee94517d0a5f2b21819e20a0f3
| 31,748,398,265,031 |
b2de3f27d9db367c00c516c49fef9fae92cf78b2
|
/src/Teacher.java
|
230363e48265896065778be0baab2a9627730bb4
|
[] |
no_license
|
Spengit/ViceLibrary
|
https://github.com/Spengit/ViceLibrary
|
87275cb159edacae81eda2c0268ce85ba4d97cf6
|
905770756de771a815da43845536b2c6d8c56229
|
refs/heads/master
| 2020-08-29T01:26:02.459000 | 2019-11-20T20:27:54 | 2019-11-20T20:27:54 | 217,879,689 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Teacher extends User {
public Teacher(String name, String lastName,
String address, String email, String phoneNumber, double fines) {
super(name, lastName, address, email, phoneNumber, fines);
// TODO Auto-generated constructor stub
}
private static final int MAX_CHECKOUT = 50;
private static int checkouts;
private String type;
public String getType() {
return type;
}
public void setType() {
this.type = "T";
}
public int checkoutLimit() {
// TODO Auto-generated method stub
return MAX_CHECKOUT;
}
public String toString() {
return super.toString() + "\nAccount Type: Teacher ";
}
@Override
public void checkout(Media m) {
// TODO Auto-generated method stub
m.checkoutMedia();
checkouts+=1;
}
public static int getCheckouts() {
return checkouts;
}
public void rateMedia(Media m, double rating) {
// TODO Auto-generated method stub
}
public double payFine(double fine) {
return super.payFine(fine);
}
}
|
UTF-8
|
Java
| 992 |
java
|
Teacher.java
|
Java
|
[
{
"context": "xtends User {\n\n\tpublic Teacher(String name, String lastName,\n\t\t\tString address, String email, String phoneNum",
"end": 82,
"score": 0.6814884543418884,
"start": 74,
"tag": "NAME",
"value": "lastName"
},
{
"context": " String phoneNumber, double fines) {\n\t\tsuper(name, lastName, address, email, phoneNumber, fines);\n\t\t// TODO A",
"end": 175,
"score": 0.989436149597168,
"start": 167,
"tag": "NAME",
"value": "lastName"
}
] | null |
[] |
public class Teacher extends User {
public Teacher(String name, String lastName,
String address, String email, String phoneNumber, double fines) {
super(name, lastName, address, email, phoneNumber, fines);
// TODO Auto-generated constructor stub
}
private static final int MAX_CHECKOUT = 50;
private static int checkouts;
private String type;
public String getType() {
return type;
}
public void setType() {
this.type = "T";
}
public int checkoutLimit() {
// TODO Auto-generated method stub
return MAX_CHECKOUT;
}
public String toString() {
return super.toString() + "\nAccount Type: Teacher ";
}
@Override
public void checkout(Media m) {
// TODO Auto-generated method stub
m.checkoutMedia();
checkouts+=1;
}
public static int getCheckouts() {
return checkouts;
}
public void rateMedia(Media m, double rating) {
// TODO Auto-generated method stub
}
public double payFine(double fine) {
return super.payFine(fine);
}
}
| 992 | 0.695565 | 0.69254 | 54 | 17.351852 | 18.662853 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.481481 | false | false |
13
|
12b99c363339df710ae04e162341b97df64b5f8d
| 29,695,403,891,797 |
9af4e63ea990926a713e0a17c6748eea33a7ca82
|
/src/main/java/com/westbank/domain/MaritalStatus.java
|
71dd9e805a62c66f194fa2375216ea75b1fec74b
|
[
"MIT"
] |
permissive
|
greetsubbu/loan-approval-portal
|
https://github.com/greetsubbu/loan-approval-portal
|
fd8c1d0b7da9da4c48c9b1e28607f47defbf3f55
|
ec7fa146bc2fa298fa1c3c2f824f7f92df1466b9
|
refs/heads/master
| 2022-11-25T01:20:44.462000 | 2020-07-28T22:36:39 | 2020-07-28T22:36:39 | 283,342,080 | 0 | 0 |
MIT
| true | 2020-07-28T22:32:31 | 2020-07-28T22:32:30 | 2020-07-14T02:34:22 | 2020-01-27T08:26:28 | 820 | 0 | 0 | 0 | null | false | false |
package com.westbank.domain;
public enum MaritalStatus {
MARRIED, NOT_MARRIED, OTHER
}
|
UTF-8
|
Java
| 89 |
java
|
MaritalStatus.java
|
Java
|
[] | null |
[] |
package com.westbank.domain;
public enum MaritalStatus {
MARRIED, NOT_MARRIED, OTHER
}
| 89 | 0.775281 | 0.775281 | 5 | 16.799999 | 13.317657 | 28 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false |
13
|
b769d97d8b54a7f28a4504f48d8762bc04e54aea
| 26,216,480,441,166 |
6ef4869c6bc2ce2e77b422242e347819f6a5f665
|
/devices/google/Pixel 2/29/QPP6.190730.005/src/framework/android/service/print/InstalledPrintServiceProto.java
|
27bbd7f5170ad42333179c7b0b05afd07f7282c4
|
[] |
no_license
|
hacking-android/frameworks
|
https://github.com/hacking-android/frameworks
|
40e40396bb2edacccabf8a920fa5722b021fb060
|
943f0b4d46f72532a419fb6171e40d1c93984c8e
|
refs/heads/master
| 2020-07-03T19:32:28.876000 | 2019-08-13T03:31:06 | 2019-08-13T03:31:06 | 202,017,534 | 2 | 0 | null | false | 2019-08-13T03:33:19 | 2019-08-12T22:19:30 | 2019-08-13T03:31:53 | 2019-08-13T03:33:18 | 63,898 | 0 | 0 | 0 |
Java
| false | false |
/*
* Decompiled with CFR 0.145.
*/
package android.service.print;
public final class InstalledPrintServiceProto {
public static final long ADD_PRINTERS_ACTIVITY = 1138166333443L;
public static final long ADVANCED_OPTIONS_ACTIVITY = 1138166333444L;
public static final long COMPONENT_NAME = 1146756268033L;
public static final long SETTINGS_ACTIVITY = 1138166333442L;
}
|
UTF-8
|
Java
| 389 |
java
|
InstalledPrintServiceProto.java
|
Java
|
[] | null |
[] |
/*
* Decompiled with CFR 0.145.
*/
package android.service.print;
public final class InstalledPrintServiceProto {
public static final long ADD_PRINTERS_ACTIVITY = 1138166333443L;
public static final long ADVANCED_OPTIONS_ACTIVITY = 1138166333444L;
public static final long COMPONENT_NAME = 1146756268033L;
public static final long SETTINGS_ACTIVITY = 1138166333442L;
}
| 389 | 0.771208 | 0.627249 | 11 | 34.272728 | 28.071632 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false |
13
|
836c7d1c41d7045948435449f9e4b3a443f30302
| 23,510,651,000,416 |
e8dbe93906e6b2d4335ec4911aaed5a321953338
|
/sisvia-project/sisvia-util/src/main/java/com/pe/sisvia/util/TemplateConverter.java
|
726d082ea602fdbc5b55ced978ced676ed822468
|
[] |
no_license
|
asanchez1610/sisvia
|
https://github.com/asanchez1610/sisvia
|
b1a5a70297b9a4580fffed5bd19d7544c17e25d0
|
26e31a0ec46b4c335676cfa7dd551395044873d6
|
refs/heads/master
| 2020-03-21T19:15:03.354000 | 2018-12-07T08:46:35 | 2018-12-07T08:46:35 | 138,937,695 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.pe.sisvia.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import com.itextpdf.html2pdf.HtmlConverter;
import freemarker.cache.FileTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
public class TemplateConverter {
private static final String ENCODING = "UTF-8";
public static void main(String[] args) {
TemplateConverter t = new TemplateConverter();
Map<String, Object> input = new HashMap<String, Object>();
input.put("textoSubtitulo", "<span>Este textto</span><br /><span>Este textto</span>");
input.put("montoAlimentacion", "S/. 100");
input.put("filasAlimentacion", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
input.put("montoAlojamiento", "S/. 100");
input.put("filasAojamiento", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
input.put("montoMovilidad", "S/. 100");
input.put("filasMovilidad", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
t.converterTemplateDocumentoPDF("C:/templates/", "rep_movimientos_pdf.tpl", input,
"C:/templates/rep_movimientos.pdf");
}
public File converterTemplateDocumentoPDF(String basePathTemplate, String nameTemplate, Map<String, Object> input,
String outputFile) {
try {
Configuration cfg = new Configuration();
cfg.setDefaultEncoding(ENCODING);
FileTemplateLoader loader;
loader = new FileTemplateLoader(new File(basePathTemplate));
cfg.setTemplateLoader(loader);
StringWriter stringWriter = new StringWriter();
Template template = cfg.getTemplate(nameTemplate);
template.process(input, stringWriter);
HtmlConverter.convertToPdf(stringWriter.toString(), new FileOutputStream(outputFile));
return new File(outputFile);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
|
UTF-8
|
Java
| 2,454 |
java
|
TemplateConverter.java
|
Java
|
[] | null |
[] |
package com.pe.sisvia.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import com.itextpdf.html2pdf.HtmlConverter;
import freemarker.cache.FileTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
public class TemplateConverter {
private static final String ENCODING = "UTF-8";
public static void main(String[] args) {
TemplateConverter t = new TemplateConverter();
Map<String, Object> input = new HashMap<String, Object>();
input.put("textoSubtitulo", "<span>Este textto</span><br /><span>Este textto</span>");
input.put("montoAlimentacion", "S/. 100");
input.put("filasAlimentacion", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
input.put("montoAlojamiento", "S/. 100");
input.put("filasAojamiento", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
input.put("montoMovilidad", "S/. 100");
input.put("filasMovilidad", " <tr>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" <td>aa</td>\r\n" +
" </tr>");
t.converterTemplateDocumentoPDF("C:/templates/", "rep_movimientos_pdf.tpl", input,
"C:/templates/rep_movimientos.pdf");
}
public File converterTemplateDocumentoPDF(String basePathTemplate, String nameTemplate, Map<String, Object> input,
String outputFile) {
try {
Configuration cfg = new Configuration();
cfg.setDefaultEncoding(ENCODING);
FileTemplateLoader loader;
loader = new FileTemplateLoader(new File(basePathTemplate));
cfg.setTemplateLoader(loader);
StringWriter stringWriter = new StringWriter();
Template template = cfg.getTemplate(nameTemplate);
template.process(input, stringWriter);
HtmlConverter.convertToPdf(stringWriter.toString(), new FileOutputStream(outputFile));
return new File(outputFile);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
| 2,454 | 0.579055 | 0.574572 | 72 | 32.083332 | 22.558413 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.722222 | false | false |
13
|
a16fa957182aa0a62f26b96f9d5a9b50354fd80a
| 2,121,713,849,804 |
13bbb102202d1e04a20331805527fd81db308a2f
|
/app/src/main/java/com/example/testing/HomePage.java
|
69e20acc87138f7705d28bdfad479259b49badfa
|
[] |
no_license
|
cguo9/techacks
|
https://github.com/cguo9/techacks
|
c273c2cccdcb5c2ff52cec8c3094b7132548c1a3
|
23cf6370c34b23fe3ade7266032c7b962ee2a921
|
refs/heads/master
| 2022-12-04T17:00:32.413000 | 2020-08-16T14:32:49 | 2020-08-16T14:32:49 | 287,689,359 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.testing;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.auth.FirebaseAuth;
public class HomePage extends AppCompatActivity {
Button logout;
FirebaseAuth mFirebaseAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homepage);
ImageButton imgbtn_s3;
imgbtn_s3 = (ImageButton) findViewById(R.id.imgbtn_study3);
imgbtn_s3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(HomePage.this, MainActivity.class);
startActivity(intent);
}
});
ImageButton imgbtn_c3;
imgbtn_c3 = (ImageButton) findViewById(R.id.imgbtn_collections3);
imgbtn_c3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(HomePage.this, Collections.class);
startActivity(intent);
}
});
logout = findViewById(R.id.logout);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FirebaseAuth.getInstance().signOut();
Intent toSignup = new Intent(HomePage.this, SignupActivity.class);
startActivity(toSignup);
}
});
}
}
|
UTF-8
|
Java
| 1,751 |
java
|
HomePage.java
|
Java
|
[] | null |
[] |
package com.example.testing;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.auth.FirebaseAuth;
public class HomePage extends AppCompatActivity {
Button logout;
FirebaseAuth mFirebaseAuth;
private FirebaseAuth.AuthStateListener mAuthStateListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homepage);
ImageButton imgbtn_s3;
imgbtn_s3 = (ImageButton) findViewById(R.id.imgbtn_study3);
imgbtn_s3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(HomePage.this, MainActivity.class);
startActivity(intent);
}
});
ImageButton imgbtn_c3;
imgbtn_c3 = (ImageButton) findViewById(R.id.imgbtn_collections3);
imgbtn_c3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent = new Intent(HomePage.this, Collections.class);
startActivity(intent);
}
});
logout = findViewById(R.id.logout);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FirebaseAuth.getInstance().signOut();
Intent toSignup = new Intent(HomePage.this, SignupActivity.class);
startActivity(toSignup);
}
});
}
}
| 1,751 | 0.645346 | 0.640777 | 52 | 32.673077 | 23.451031 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.596154 | false | false |
13
|
bc2e29955353c3a6815f2f51c32873304c18434b
| 2,723,009,319,830 |
7bd54424caff38ff4ff431d1a55cd51b3172210b
|
/test/org/tdl/vireo/model/MockDocumentType.java
|
2c68e1371ed0df1c263d2bbf225044612639930e
|
[] |
no_license
|
TAMULib/Vireo
|
https://github.com/TAMULib/Vireo
|
8c5d8138189a034e8b8a9d23685fbb97bae39ba2
|
45965f11cb859ef4395cc5216121c12fb64d3be5
|
refs/heads/tamu_production
| 2023-08-31T04:08:45.524000 | 2014-12-05T19:50:22 | 2014-12-05T19:50:22 | 12,141,038 | 0 | 1 | null | true | 2019-07-03T15:14:49 | 2013-08-15T18:46:03 | 2019-06-19T19:07:52 | 2019-07-03T15:14:49 | 18,162 | 1 | 0 | 6 |
Java
| false | false |
package org.tdl.vireo.model;
/**
* This is a simple mock document type class that may be useful for testing.
* Feel free to extend this to add in extra parameters that you feel
* appropriate.
*
* The basic concept is all properties are public so you can create the mock
* object and then set whatever relevant properties are needed for your
* particular test.
*
* @author <a href="http://www.scottphillips.com">Scott Phillips</a>
*/
public class MockDocumentType extends AbstractMock implements DocumentType {
/* Document Type Properties */
public int displayOrder;
public String name;
public DegreeLevel level;
@Override
public MockDocumentType save() {
return this;
}
@Override
public MockDocumentType delete() {
return this;
}
@Override
public MockDocumentType refresh() {
return this;
}
@Override
public MockDocumentType merge() {
return this;
}
@Override
public MockDocumentType detach() {
return this;
}
@Override
public int getDisplayOrder() {
return displayOrder;
}
@Override
public void setDisplayOrder(int displayOrder) {
this.displayOrder = displayOrder;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public DegreeLevel getLevel() {
return level;
}
@Override
public void setLevel(DegreeLevel level) {
this.level = level;
}
}
|
UTF-8
|
Java
| 1,404 |
java
|
MockDocumentType.java
|
Java
|
[
{
"context": " * @author <a href=\"http://www.scottphillips.com\">Scott Phillips</a>\n */\npublic class MockDocumentType extends Abs",
"end": 437,
"score": 0.9997631907463074,
"start": 423,
"tag": "NAME",
"value": "Scott Phillips"
}
] | null |
[] |
package org.tdl.vireo.model;
/**
* This is a simple mock document type class that may be useful for testing.
* Feel free to extend this to add in extra parameters that you feel
* appropriate.
*
* The basic concept is all properties are public so you can create the mock
* object and then set whatever relevant properties are needed for your
* particular test.
*
* @author <a href="http://www.scottphillips.com"><NAME></a>
*/
public class MockDocumentType extends AbstractMock implements DocumentType {
/* Document Type Properties */
public int displayOrder;
public String name;
public DegreeLevel level;
@Override
public MockDocumentType save() {
return this;
}
@Override
public MockDocumentType delete() {
return this;
}
@Override
public MockDocumentType refresh() {
return this;
}
@Override
public MockDocumentType merge() {
return this;
}
@Override
public MockDocumentType detach() {
return this;
}
@Override
public int getDisplayOrder() {
return displayOrder;
}
@Override
public void setDisplayOrder(int displayOrder) {
this.displayOrder = displayOrder;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public DegreeLevel getLevel() {
return level;
}
@Override
public void setLevel(DegreeLevel level) {
this.level = level;
}
}
| 1,396 | 0.72151 | 0.72151 | 76 | 17.473684 | 20.353115 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.986842 | false | false |
13
|
8de019e16bf0d0936c4fe289b87eed8393f53882
| 10,591,389,392,105 |
d73d5d59ea0866e39e39aeb08f1a326e45b1e5e6
|
/pro-spring-5-master/chapter18/webflux/src/test/java/com/apress/prospring5/ch18/web/SingerHandlerTest.java
|
fb2623c12d050f7ff158a16f600da16a433106f8
|
[
"LicenseRef-scancode-proprietary-license",
"MIT"
] |
permissive
|
dhanu10896/tech-notes
|
https://github.com/dhanu10896/tech-notes
|
1194a54c3b6e4d3db49aacf49af4521581db8e75
|
fd64525e587172e8c80c1764117c6b15b5da30b5
|
refs/heads/master
| 2022-02-06T14:59:39.541000 | 2019-11-16T15:25:23 | 2019-11-30T16:28:54 | 225,039,136 | 0 | 0 |
MIT
| false | 2022-01-21T23:34:38 | 2019-11-30T16:26:13 | 2019-11-30T16:30:46 | 2022-01-21T23:34:37 | 77,109 | 0 | 0 | 17 |
JavaScript
| false | false |
package com.apress.prospring5.ch18.web;
import com.apress.prospring5.ch18.ServerConfig;
import com.apress.prospring5.ch18.config.TestConfig;
import com.apress.prospring5.ch18.entities.Singer;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
import reactor.core.publisher.Mono;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* Created by iuliana.cosmina on 8/6/17.
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {ServerConfig.class, TestConfig.class})
public class SingerHandlerTest {
@Autowired
WebTestClient testClient;
@Test
public void getSinger() throws Exception {
List<Singer> result = this.testClient.get()
.uri("/1")
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBodyList(Singer.class).hasSize(1).returnResult().getResponseBody();
Singer singer = result.get(0);
assertAll("singer", () ->
{
assertNotNull(singer);
assertAll("singer",
() -> assertEquals("John", singer.getFirstName()),
() -> assertEquals("Mayer", singer.getLastName()));
});
}
@Test
public void getSingerNotFound() throws Exception {
this.testClient.get()
.uri("/99")
.exchange()
.expectStatus().isNotFound();
}
@Test
public void getAll() throws Exception {
this.testClient.get().uri("/").accept(MediaType.TEXT_EVENT_STREAM)
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBodyList(Singer.class).hasSize(14).consumeWith(Assertions::assertNotNull);
}
@Ignore
@Test
public void create() throws Exception {
Singer singer = new Singer();
singer.setFirstName("Ed");
singer.setLastName("Sheeran");
singer.setBirthDate(new Date(
(new GregorianCalendar(1991, 2, 17)).getTime().getTime()));
this.testClient.post().uri("/").body(Mono.just(singer) , Singer.class).exchange().expectStatus().isOk();
}
}
|
UTF-8
|
Java
| 2,362 |
java
|
SingerHandlerTest.java
|
Java
|
[
{
"context": "junit.jupiter.api.Assertions.*;\n\n/**\n * Created by iuliana.cosmina on 8/6/17.\n */\n@RunWith(SpringRunner.class)\n@Cont",
"end": 815,
"score": 0.9479473829269409,
"start": 800,
"tag": "USERNAME",
"value": "iuliana.cosmina"
},
{
"context": ";\n\t\t\tassertAll(\"singer\",\n\t\t\t\t\t() -> assertEquals(\"John\", singer.getFirstName()),\n\t\t\t\t\t() -> assertEquals",
"end": 1443,
"score": 0.999272882938385,
"start": 1439,
"tag": "NAME",
"value": "John"
},
{
"context": " singer.getFirstName()),\n\t\t\t\t\t() -> assertEquals(\"Mayer\", singer.getLastName()));\n\t\t});\n\t}\n\n\t@Test\n\tpubli",
"end": 1500,
"score": 0.9985212087631226,
"start": 1495,
"tag": "NAME",
"value": "Mayer"
},
{
"context": "ger singer = new Singer();\n\t\tsinger.setFirstName(\"Ed\");\n\t\tsinger.setLastName(\"Sheeran\");\n\t\tsinger.setB",
"end": 2114,
"score": 0.9998207092285156,
"start": 2112,
"tag": "NAME",
"value": "Ed"
},
{
"context": "\tsinger.setFirstName(\"Ed\");\n\t\tsinger.setLastName(\"Sheeran\");\n\t\tsinger.setBirthDate(new Date(\n\t\t\t\t(new Grego",
"end": 2147,
"score": 0.9998109340667725,
"start": 2140,
"tag": "NAME",
"value": "Sheeran"
}
] | null |
[] |
package com.apress.prospring5.ch18.web;
import com.apress.prospring5.ch18.ServerConfig;
import com.apress.prospring5.ch18.config.TestConfig;
import com.apress.prospring5.ch18.entities.Singer;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
import reactor.core.publisher.Mono;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* Created by iuliana.cosmina on 8/6/17.
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {ServerConfig.class, TestConfig.class})
public class SingerHandlerTest {
@Autowired
WebTestClient testClient;
@Test
public void getSinger() throws Exception {
List<Singer> result = this.testClient.get()
.uri("/1")
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBodyList(Singer.class).hasSize(1).returnResult().getResponseBody();
Singer singer = result.get(0);
assertAll("singer", () ->
{
assertNotNull(singer);
assertAll("singer",
() -> assertEquals("John", singer.getFirstName()),
() -> assertEquals("Mayer", singer.getLastName()));
});
}
@Test
public void getSingerNotFound() throws Exception {
this.testClient.get()
.uri("/99")
.exchange()
.expectStatus().isNotFound();
}
@Test
public void getAll() throws Exception {
this.testClient.get().uri("/").accept(MediaType.TEXT_EVENT_STREAM)
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBodyList(Singer.class).hasSize(14).consumeWith(Assertions::assertNotNull);
}
@Ignore
@Test
public void create() throws Exception {
Singer singer = new Singer();
singer.setFirstName("Ed");
singer.setLastName("Sheeran");
singer.setBirthDate(new Date(
(new GregorianCalendar(1991, 2, 17)).getTime().getTime()));
this.testClient.post().uri("/").body(Mono.just(singer) , Singer.class).exchange().expectStatus().isOk();
}
}
| 2,362 | 0.737087 | 0.723963 | 79 | 28.873417 | 24.124868 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.860759 | false | false |
13
|
1f96a968609f5d414f00e3895e1820874207a1ca
| 3,401,614,103,318 |
a8a40972162fdff7683ae4d251b02fe0cccf6b0a
|
/projects/maven-hotdeploy-plugin/src/test/java/com/ctp/seam/maven/packaging/HotClassesPackagingTaskTest.java
|
a36d40ac4ebde256cb16d37becd2f0d1f7ea848b
|
[] |
no_license
|
ggam/ctpjava
|
https://github.com/ggam/ctpjava
|
4927182c41ffae89061b3233bf6536202e42b784
|
07a30364359517b5a5276c519d745ec644e8f14d
|
refs/heads/master
| 2016-09-12T18:21:38.452000 | 2010-08-12T13:15:35 | 2010-08-12T13:15:35 | 58,070,795 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ctp.seam.maven.packaging;
import java.io.File;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugin.war.packaging.WarPackagingContext;
import org.apache.maven.plugin.war.util.PathSet;
public class HotClassesPackagingTaskTest extends TestCase {
private HotClassesPackagingTask task;
public void testPrepareExcludes() {
// given
SeamWarPackagingContext context = prepareContext();
String[] contains = new String[] {
"common/A.class",
"common/excludeall/**",
"common/lvl1/**"
};
// when
String[] result = task.prepareExcludes(context);
// then
Assert.assertNotNull(result);
for (int i = 0; i < result.length; i++)
System.out.println(result[i]);
Assert.assertEquals(3, result.length);
for (int i = 0; i < contains.length; i++)
Assert.assertTrue(contains(result, contains[i]));
}
public void testPathSet() {
// given
SeamWarPackagingContext context = prepareContext();
File baseDir = new File("target/test-classes/testdata/compiler");
// when
String[] result = task.prepareExcludes(context);
PathSet set = task.getFilesToIncludes(baseDir, null, result);
// then
Assert.assertEquals(1, set.size());
}
protected void setUp() throws Exception {
super.setUp();
task = new HotClassesPackagingTask();
}
private boolean contains(String[] arr, String key) {
for (int i = 0; i < arr.length; i++)
if (arr[i] != null && arr[i].equals(key))
return true;
return false;
}
private SeamWarPackagingContext prepareContext() {
WarPackagingContext wrapped = new WarPackagingContextAdapter() {
public File getClassesDirectory() {
return new File("target/test-classes/testdata/compiler");
}
public Log getLog() {
return new SystemStreamLog();
}
};
File hot = new File("target/test-classes/testdata/hot");
SeamWarPackagingContext result = new SeamWarPackagingContext(wrapped, hot, true);
return result;
}
}
|
UTF-8
|
Java
| 2,516 |
java
|
HotClassesPackagingTaskTest.java
|
Java
|
[] | null |
[] |
package com.ctp.seam.maven.packaging;
import java.io.File;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugin.war.packaging.WarPackagingContext;
import org.apache.maven.plugin.war.util.PathSet;
public class HotClassesPackagingTaskTest extends TestCase {
private HotClassesPackagingTask task;
public void testPrepareExcludes() {
// given
SeamWarPackagingContext context = prepareContext();
String[] contains = new String[] {
"common/A.class",
"common/excludeall/**",
"common/lvl1/**"
};
// when
String[] result = task.prepareExcludes(context);
// then
Assert.assertNotNull(result);
for (int i = 0; i < result.length; i++)
System.out.println(result[i]);
Assert.assertEquals(3, result.length);
for (int i = 0; i < contains.length; i++)
Assert.assertTrue(contains(result, contains[i]));
}
public void testPathSet() {
// given
SeamWarPackagingContext context = prepareContext();
File baseDir = new File("target/test-classes/testdata/compiler");
// when
String[] result = task.prepareExcludes(context);
PathSet set = task.getFilesToIncludes(baseDir, null, result);
// then
Assert.assertEquals(1, set.size());
}
protected void setUp() throws Exception {
super.setUp();
task = new HotClassesPackagingTask();
}
private boolean contains(String[] arr, String key) {
for (int i = 0; i < arr.length; i++)
if (arr[i] != null && arr[i].equals(key))
return true;
return false;
}
private SeamWarPackagingContext prepareContext() {
WarPackagingContext wrapped = new WarPackagingContextAdapter() {
public File getClassesDirectory() {
return new File("target/test-classes/testdata/compiler");
}
public Log getLog() {
return new SystemStreamLog();
}
};
File hot = new File("target/test-classes/testdata/hot");
SeamWarPackagingContext result = new SeamWarPackagingContext(wrapped, hot, true);
return result;
}
}
| 2,516 | 0.585056 | 0.582671 | 76 | 31.105263 | 23.121862 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.618421 | false | false |
13
|
1f618531e82578957ea5c1ed6e17a46600628f2f
| 5,007,931,867,768 |
32fb9e6ec1cafbc0dc5ef3363fcb28dcc7c7c7d1
|
/MusicMadeEazy/src/main/data/java/com/dgs/data/dao/MmeAlbumArtistSongMappingDao.java
|
db25673c7659dae1ed6d338059229f21bc6108e6
|
[] |
no_license
|
Akhila2992/Music-Made-Eazy
|
https://github.com/Akhila2992/Music-Made-Eazy
|
3c0581897ef2690bfacf5b302ab9752e4e44322f
|
76898583bee62da1b89473dc4f7a4072e22d2ebb
|
refs/heads/master
| 2021-05-03T11:46:43.530000 | 2016-09-28T15:30:31 | 2016-09-28T15:30:31 | 69,476,479 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.dgs.data.dao;
// default package
// Generated 25 Aug, 2016 2:06:53 PM by Hibernate Tools 5.0.0.Alpha3
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dgs.data.domain.MmeAlbumArtistSongMapping;
import com.dgs.data.domain.MmeAlbumArtistSongMappingId;
/**
* Home object for domain model class MmeAlbumArtistSongMapping.
* @see .MmeAlbumArtistSongMapping
* @author Hibernate Tools
*/
@Stateless
public class MmeAlbumArtistSongMappingDao {
private static final Log log = LogFactory.getLog(MmeAlbumArtistSongMappingDao.class);
@PersistenceContext
private EntityManager entityManager;
public void persist(MmeAlbumArtistSongMapping transientInstance) {
log.debug("persisting MmeAlbumArtistSongMapping instance");
try {
entityManager.persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void remove(MmeAlbumArtistSongMapping persistentInstance) {
log.debug("removing MmeAlbumArtistSongMapping instance");
try {
entityManager.remove(persistentInstance);
log.debug("remove successful");
} catch (RuntimeException re) {
log.error("remove failed", re);
throw re;
}
}
public MmeAlbumArtistSongMapping merge(MmeAlbumArtistSongMapping detachedInstance) {
log.debug("merging MmeAlbumArtistSongMapping instance");
try {
MmeAlbumArtistSongMapping result = entityManager.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public MmeAlbumArtistSongMapping findById(MmeAlbumArtistSongMappingId id) {
log.debug("getting MmeAlbumArtistSongMapping instance with id: " + id);
try {
MmeAlbumArtistSongMapping instance = entityManager.find(MmeAlbumArtistSongMapping.class, id);
log.debug("get successful");
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
}
|
UTF-8
|
Java
| 2,148 |
java
|
MmeAlbumArtistSongMappingDao.java
|
Java
|
[
{
"context": "ing.\n * @see .MmeAlbumArtistSongMapping\n * @author Hibernate Tools\n */\n@Stateless\npublic class MmeAlbumArtistS",
"end": 550,
"score": 0.7848846316337585,
"start": 541,
"tag": "NAME",
"value": "Hibernate"
},
{
"context": "ee .MmeAlbumArtistSongMapping\n * @author Hibernate Tools\n */\n@Stateless\npublic class MmeAlbumArtistSongMap",
"end": 556,
"score": 0.4953010082244873,
"start": 551,
"tag": "USERNAME",
"value": "Tools"
}
] | null |
[] |
package com.dgs.data.dao;
// default package
// Generated 25 Aug, 2016 2:06:53 PM by Hibernate Tools 5.0.0.Alpha3
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.dgs.data.domain.MmeAlbumArtistSongMapping;
import com.dgs.data.domain.MmeAlbumArtistSongMappingId;
/**
* Home object for domain model class MmeAlbumArtistSongMapping.
* @see .MmeAlbumArtistSongMapping
* @author Hibernate Tools
*/
@Stateless
public class MmeAlbumArtistSongMappingDao {
private static final Log log = LogFactory.getLog(MmeAlbumArtistSongMappingDao.class);
@PersistenceContext
private EntityManager entityManager;
public void persist(MmeAlbumArtistSongMapping transientInstance) {
log.debug("persisting MmeAlbumArtistSongMapping instance");
try {
entityManager.persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void remove(MmeAlbumArtistSongMapping persistentInstance) {
log.debug("removing MmeAlbumArtistSongMapping instance");
try {
entityManager.remove(persistentInstance);
log.debug("remove successful");
} catch (RuntimeException re) {
log.error("remove failed", re);
throw re;
}
}
public MmeAlbumArtistSongMapping merge(MmeAlbumArtistSongMapping detachedInstance) {
log.debug("merging MmeAlbumArtistSongMapping instance");
try {
MmeAlbumArtistSongMapping result = entityManager.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public MmeAlbumArtistSongMapping findById(MmeAlbumArtistSongMappingId id) {
log.debug("getting MmeAlbumArtistSongMapping instance with id: " + id);
try {
MmeAlbumArtistSongMapping instance = entityManager.find(MmeAlbumArtistSongMapping.class, id);
log.debug("get successful");
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
}
| 2,148 | 0.76676 | 0.759777 | 73 | 28.424658 | 25.79472 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.849315 | false | false |
13
|
3d0497d7c5ea4f54b377183fd58cf2d1bc64e547
| 11,802,570,197,924 |
a3b29bfd456def13e48c6f6c161b8292684394fc
|
/src/test/java/org/katas/tennis/TenisTest.java
|
f2bab589b2d749188d21699495222408978f253c
|
[] |
no_license
|
rroldan/tennis-kata
|
https://github.com/rroldan/tennis-kata
|
777b8d4ad714d63ea4665ddb27075229713b98c8
|
3255816016aea9610d38dee353953d23e87929e7
|
refs/heads/master
| 2020-06-01T04:15:42.254000 | 2014-06-01T12:07:27 | 2014-06-01T12:07:27 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.katas.tennis;
import static org.junit.Assert.*;
import org.junit.Test;
import org.katas.tennis.Tenis;
public class TenisTest {
@Test
public void gana15PuntosJugador1(){
Tenis tenis = new Tenis();
int puntosJugador0 = tenis.puntos(0);
tenis.sumaPuntos(0);
assertEquals("Valor no esperado",puntosJugador0+Tenis.TANTEO_15, tenis.puntos(0));
}
@Test
public void gana30PuntosJugador1(){
Tenis tenis = new Tenis();
int puntosJugador0 = tenis.puntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertEquals("Valor no esperado", puntosJugador0+Tenis.TANTEO_30, tenis.puntos(0));
}
@Test
public void terminaJuegoGanaJugador1(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertEquals(0,tenis.ganadorJuego());
}
@Test
public void terminaJuegoGanaJugador2(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
assertEquals(1,tenis.ganadorJuego());
}
@Test
public void finalizadoJuego(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertTrue(tenis.finalizadoJuego());
}
@Test
public void NoIguales(){
Tenis tenis = new Tenis();
assertFalse(tenis.iguales());
}
@Test
public void iguales(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
assertTrue(tenis.iguales());
}
@Test
public void TratarVentajaJugador1(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(0);
assertTrue(tenis.ventaja(0));
}
@Test
public void TratarVentajaJugador1YGana(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertTrue(tenis.finalizadoJuego());
}
}
|
UTF-8
|
Java
| 2,187 |
java
|
TenisTest.java
|
Java
|
[] | null |
[] |
package org.katas.tennis;
import static org.junit.Assert.*;
import org.junit.Test;
import org.katas.tennis.Tenis;
public class TenisTest {
@Test
public void gana15PuntosJugador1(){
Tenis tenis = new Tenis();
int puntosJugador0 = tenis.puntos(0);
tenis.sumaPuntos(0);
assertEquals("Valor no esperado",puntosJugador0+Tenis.TANTEO_15, tenis.puntos(0));
}
@Test
public void gana30PuntosJugador1(){
Tenis tenis = new Tenis();
int puntosJugador0 = tenis.puntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertEquals("Valor no esperado", puntosJugador0+Tenis.TANTEO_30, tenis.puntos(0));
}
@Test
public void terminaJuegoGanaJugador1(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertEquals(0,tenis.ganadorJuego());
}
@Test
public void terminaJuegoGanaJugador2(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
assertEquals(1,tenis.ganadorJuego());
}
@Test
public void finalizadoJuego(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertTrue(tenis.finalizadoJuego());
}
@Test
public void NoIguales(){
Tenis tenis = new Tenis();
assertFalse(tenis.iguales());
}
@Test
public void iguales(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
assertTrue(tenis.iguales());
}
@Test
public void TratarVentajaJugador1(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(0);
assertTrue(tenis.ventaja(0));
}
@Test
public void TratarVentajaJugador1YGana(){
Tenis tenis = new Tenis();
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(1);
tenis.sumaPuntos(0);
tenis.sumaPuntos(0);
assertTrue(tenis.finalizadoJuego());
}
}
| 2,187 | 0.694102 | 0.666209 | 112 | 18.526785 | 15.609612 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.017857 | false | false |
13
|
f1c5b8dbe4deb3587893b2928fb2ac1381e2d9df
| 12,481,175,031,741 |
64d6f6f0e31f27679f3623a5f80496ac372f9f28
|
/domain/src/main/java/be/pekket/ucll/ip/domain/db/ChiroDB/ChiroMap.java
|
e25617981fb2f275a4830a9011915b08bbcadc8a
|
[] |
no_license
|
Pekket/UCLL-IP
|
https://github.com/Pekket/UCLL-IP
|
3788a7b5cd23365845ff040cade3a551aeb483c4
|
c0886426208b660edb6ef24525e58cb83e5a6db9
|
refs/heads/master
| 2018-02-09T07:57:23.688000 | 2016-10-07T11:52:29 | 2016-10-07T11:52:29 | 70,241,971 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package be.pekket.ucll.ip.domain.db.ChiroDB;
import be.pekket.ucll.ip.domain.db.DbException;
import be.pekket.ucll.ip.domain.model.Chiro;
import be.pekket.ucll.ip.domain.model.Member;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ChiroMap implements IChiroDB{
private Map<Long, Chiro> chiros;
private int entityID;
public ChiroMap(){
chiros = new HashMap<Long, Chiro>();
entityID = 0;
}
@Override
public Chiro getChiro( long id ) throws DbException{
if( id <= 0 || !chiros.containsKey( id ) )
throw new DbException( "Invalid id : Cannot get Chiro" );
return this.chiros.get( id );
}
@Override
public List<Chiro> getAll(){
return new ArrayList(chiros.values());
}
@Override
public void addChiro( Chiro chiro ) throws DbException{
if( chiro == null )
throw new DbException( "Cannot add empty Chiro" );
if(chiro.getId() == 0)
chiro.setId(++entityID );
chiros.put( chiro.getId(), chiro );
}
@Override
public void updateChiro(Chiro c) throws DbException {
if( c == null )
throw new DbException( "Cannot update empty Chiro" );
Chiro chiro = getChiro(c.getId());
chiro.setName(c.getName());
chiro.setEmail(c.getEmail());
chiro.setCity(c.getCity());
}
@Override
public void deleteChiro( long id ) throws DbException{
if( id <= 0 || !chiros.containsKey( id ) )
throw new DbException( "Invalid id : Cannot delete Chiro" );
this.chiros.remove( id );
}
public void addMemberToChiro( Member member ){
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot add empty Member or member already in db " );
getChiro( member.getChiroID() ).addMember( member );
}
@Override
public void deleteMemberFromChiro( Member member ) throws DbException{
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot delete member from chiro" );
chiros.get( member.getChiroID() ).deleteMember( member );
}
@Override
public void updateMemberFromChiro(Member member) throws DbException {
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot update member from chiro" );
for(Member m : chiros.get(member.getChiroID()).getMembers()){
if(m.getID() == member.getID()) {
deleteMemberFromChiro( m );
break;
}
}
addMemberToChiro( member );
}
}
|
UTF-8
|
Java
| 2,797 |
java
|
ChiroMap.java
|
Java
|
[] | null |
[] |
package be.pekket.ucll.ip.domain.db.ChiroDB;
import be.pekket.ucll.ip.domain.db.DbException;
import be.pekket.ucll.ip.domain.model.Chiro;
import be.pekket.ucll.ip.domain.model.Member;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ChiroMap implements IChiroDB{
private Map<Long, Chiro> chiros;
private int entityID;
public ChiroMap(){
chiros = new HashMap<Long, Chiro>();
entityID = 0;
}
@Override
public Chiro getChiro( long id ) throws DbException{
if( id <= 0 || !chiros.containsKey( id ) )
throw new DbException( "Invalid id : Cannot get Chiro" );
return this.chiros.get( id );
}
@Override
public List<Chiro> getAll(){
return new ArrayList(chiros.values());
}
@Override
public void addChiro( Chiro chiro ) throws DbException{
if( chiro == null )
throw new DbException( "Cannot add empty Chiro" );
if(chiro.getId() == 0)
chiro.setId(++entityID );
chiros.put( chiro.getId(), chiro );
}
@Override
public void updateChiro(Chiro c) throws DbException {
if( c == null )
throw new DbException( "Cannot update empty Chiro" );
Chiro chiro = getChiro(c.getId());
chiro.setName(c.getName());
chiro.setEmail(c.getEmail());
chiro.setCity(c.getCity());
}
@Override
public void deleteChiro( long id ) throws DbException{
if( id <= 0 || !chiros.containsKey( id ) )
throw new DbException( "Invalid id : Cannot delete Chiro" );
this.chiros.remove( id );
}
public void addMemberToChiro( Member member ){
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot add empty Member or member already in db " );
getChiro( member.getChiroID() ).addMember( member );
}
@Override
public void deleteMemberFromChiro( Member member ) throws DbException{
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot delete member from chiro" );
chiros.get( member.getChiroID() ).deleteMember( member );
}
@Override
public void updateMemberFromChiro(Member member) throws DbException {
if( member == null || !chiros.containsKey( member.getChiroID()) )
throw new DbException( "Cannot update member from chiro" );
for(Member m : chiros.get(member.getChiroID()).getMembers()){
if(m.getID() == member.getID()) {
deleteMemberFromChiro( m );
break;
}
}
addMemberToChiro( member );
}
}
| 2,797 | 0.603146 | 0.601716 | 93 | 29.07527 | 25.240877 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.494624 | false | false |
13
|
d70b0758502b61a7b4d21b279b32de9e83e02ebe
| 15,728,170,265,905 |
421ab47aca53d9cb60e24ac7d0888242df494952
|
/liquibase-ext/src/main/java/liquibase/database/ext/MySQLDatabase.java
|
e4e44abba6134e756d0e581d2bf243a4d366440a
|
[
"Apache-2.0"
] |
permissive
|
jcaddel/liquibase
|
https://github.com/jcaddel/liquibase
|
742bf76a205194ba0689eb284d5e6fd91d270e80
|
2beef81e4c532a9ce4603784fe541b272e66b8be
|
refs/heads/master
| 2021-01-16T20:32:38.481000 | 2012-08-20T22:35:29 | 2012-08-20T22:35:29 | 2,140,989 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package liquibase.database.ext;
import liquibase.Constants;
import liquibase.database.DelimiterStyle;
import liquibase.database.structure.ForeignKeyConstraintType;
public class MySQLDatabase extends liquibase.database.core.MySQLDatabase {
public static final DelimiterStyle DEFAULT_DELIMITER_STYLE = DelimiterStyle.NORMAL;
CommonDefaultRuleHandler foreignKeyHandler = new CommonDefaultRuleHandler();
public MySQLDatabase() {
super();
setDelimiterStyle(DEFAULT_DELIMITER_STYLE);
}
@Override
public int getPriority() {
return Constants.DEFAULT_EXT_PRIORITY;
}
@Override
public boolean supportsSequences() {
return true;
}
@Override
public boolean isDefaultUpdateRule(ForeignKeyConstraintType rule) {
return foreignKeyHandler.isDefaultUpdateRule(rule);
}
@Override
public boolean isDefaultDeleteRule(ForeignKeyConstraintType rule) {
return foreignKeyHandler.isDefaultDeleteRule(rule);
}
@Override
public ForeignKeyConstraintType getDefaultUpdateRule() {
/**
* This is a mini-hack to workaround a subtle difference between how Oracle and MySQL return information about a
* JDBC constraint via JDBC. With Oracle if you don't specify an update rule it defaults to "ON UPDATE RESTRICT"
* but this behavior is not returned via JDBC. Since MySQL also defaults to "ON UPDATE RESTRICT" we can safely
* just omit this information from the foreign key description, yet retain the same behavior on both sides
*/
return null;
// return foreignKeyHandler.getDefaultUpdateRule();
}
@Override
public ForeignKeyConstraintType getDefaultDeleteRule() {
return foreignKeyHandler.getDefaultDeleteRule();
}
}
|
UTF-8
|
Java
| 1,808 |
java
|
MySQLDatabase.java
|
Java
|
[] | null |
[] |
package liquibase.database.ext;
import liquibase.Constants;
import liquibase.database.DelimiterStyle;
import liquibase.database.structure.ForeignKeyConstraintType;
public class MySQLDatabase extends liquibase.database.core.MySQLDatabase {
public static final DelimiterStyle DEFAULT_DELIMITER_STYLE = DelimiterStyle.NORMAL;
CommonDefaultRuleHandler foreignKeyHandler = new CommonDefaultRuleHandler();
public MySQLDatabase() {
super();
setDelimiterStyle(DEFAULT_DELIMITER_STYLE);
}
@Override
public int getPriority() {
return Constants.DEFAULT_EXT_PRIORITY;
}
@Override
public boolean supportsSequences() {
return true;
}
@Override
public boolean isDefaultUpdateRule(ForeignKeyConstraintType rule) {
return foreignKeyHandler.isDefaultUpdateRule(rule);
}
@Override
public boolean isDefaultDeleteRule(ForeignKeyConstraintType rule) {
return foreignKeyHandler.isDefaultDeleteRule(rule);
}
@Override
public ForeignKeyConstraintType getDefaultUpdateRule() {
/**
* This is a mini-hack to workaround a subtle difference between how Oracle and MySQL return information about a
* JDBC constraint via JDBC. With Oracle if you don't specify an update rule it defaults to "ON UPDATE RESTRICT"
* but this behavior is not returned via JDBC. Since MySQL also defaults to "ON UPDATE RESTRICT" we can safely
* just omit this information from the foreign key description, yet retain the same behavior on both sides
*/
return null;
// return foreignKeyHandler.getDefaultUpdateRule();
}
@Override
public ForeignKeyConstraintType getDefaultDeleteRule() {
return foreignKeyHandler.getDefaultDeleteRule();
}
}
| 1,808 | 0.724558 | 0.724558 | 53 | 33.113209 | 35.152851 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.301887 | false | false |
13
|
66f1d3274bf2d59d88c1353c8ac03e5e058bf6b2
| 8,658,654,136,024 |
e06d005d0bad5473467fba1fca48c2757f14bf7c
|
/euler2.java
|
024bcfebdc53f68653f59966624ba5fe8e779eeb
|
[] |
no_license
|
smutchek/projectEuler
|
https://github.com/smutchek/projectEuler
|
59abe2a16b4def67a3a2d82aaa689000e159327c
|
bd1febd7497d05b06229face944e778b3ba0856a
|
refs/heads/master
| 2020-06-26T19:23:26.620000 | 2019-08-10T18:22:07 | 2019-08-10T18:22:07 | 199,730,067 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.ArrayList;
public class euler2{
public static void main(String[] args) {
ArrayList<Integer> fibonacci = new ArrayList<Integer>();
fibonacci.add(1);
fibonacci.add(2);
int lastNum = 0;
int counter = 1;
while(lastNum <= 4000000){
lastNum = fibonacci.get(counter-1) + fibonacci.get(counter);
fibonacci.add(lastNum);
counter++;
}
ArrayList<Integer> evenFibonacci = new ArrayList<Integer>();
for(int i = 0; i<fibonacci.size(); i++){
if(fibonacci.get(i)%2 == 0){
evenFibonacci.add(fibonacci.get(i));
}
}
int sum = 0;
for(int j = 0; j<evenFibonacci.size(); j++){
sum += evenFibonacci.get(j);
}
System.out.println(sum);
}
}
|
UTF-8
|
Java
| 851 |
java
|
euler2.java
|
Java
|
[] | null |
[] |
import java.util.ArrayList;
public class euler2{
public static void main(String[] args) {
ArrayList<Integer> fibonacci = new ArrayList<Integer>();
fibonacci.add(1);
fibonacci.add(2);
int lastNum = 0;
int counter = 1;
while(lastNum <= 4000000){
lastNum = fibonacci.get(counter-1) + fibonacci.get(counter);
fibonacci.add(lastNum);
counter++;
}
ArrayList<Integer> evenFibonacci = new ArrayList<Integer>();
for(int i = 0; i<fibonacci.size(); i++){
if(fibonacci.get(i)%2 == 0){
evenFibonacci.add(fibonacci.get(i));
}
}
int sum = 0;
for(int j = 0; j<evenFibonacci.size(); j++){
sum += evenFibonacci.get(j);
}
System.out.println(sum);
}
}
| 851 | 0.520564 | 0.499412 | 26 | 31.76923 | 19.462603 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false |
13
|
db8c7c8fb9ff73a95cfdf6c1428e548790716e17
| 28,887,950,103,751 |
ab3eaee1c61711338a47039461b9c4ac72ace89d
|
/login/src/main/java/com/programem/login/SecurityWebConfig.java
|
3eb00f759436b58b4ea77876dd41394342cd7e01
|
[] |
no_license
|
eduarda-moreira/login
|
https://github.com/eduarda-moreira/login
|
557fd211951309edd4fef96baab8f02aa3a85985
|
121ed0e85b825e3203b5dc658b7c3ebc8f53ee6c
|
refs/heads/master
| 2022-11-17T14:47:59.891000 | 2020-07-18T02:41:00 | 2020-07-18T02:41:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.programem.login;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder builder) throws Exception {
builder
.inMemoryAuthentication()
.withUser("duda").password("{noop}duda")
.roles("USER")
.and()
.withUser("eduarda").password("{noop}eduarda")
.roles("USER")
.and()
.withUser("moreira").password("{noop}moreira")
.roles("USER");
}
}
|
UTF-8
|
Java
| 855 |
java
|
SecurityWebConfig.java
|
Java
|
[
{
"context": " .inMemoryAuthentication()\n .withUser(\"duda\").password(\"{noop}duda\")\n .roles(\"USER",
"end": 595,
"score": 0.9993007183074951,
"start": 591,
"tag": "USERNAME",
"value": "duda"
},
{
"context": "entication()\n .withUser(\"duda\").password(\"{noop}duda\")\n .roles(\"USER\")\n .and()\n ",
"end": 618,
"score": 0.9945363998413086,
"start": 609,
"tag": "PASSWORD",
"value": "noop}duda"
},
{
"context": " .roles(\"USER\")\n .and()\n .withUser(\"eduarda\").password(\"{noop}eduarda\")\n .roles(\"USER\"",
"end": 689,
"score": 0.9987771511077881,
"start": 682,
"tag": "USERNAME",
"value": "eduarda"
},
{
"context": " .and()\n .withUser(\"eduarda\").password(\"{noop}eduarda\")\n .roles(\"USER\") \n .and()\n ",
"end": 715,
"score": 0.9947664141654968,
"start": 703,
"tag": "PASSWORD",
"value": "noop}eduarda"
},
{
"context": ".roles(\"USER\") \n .and()\n .withUser(\"moreira\").password(\"{noop}moreira\")\n .roles(\"USER\"",
"end": 783,
"score": 0.9993744492530823,
"start": 776,
"tag": "USERNAME",
"value": "moreira"
},
{
"context": " .and()\n .withUser(\"moreira\").password(\"{noop}moreira\")\n .roles(\"USER\");\n\n \n }\n\n}\n",
"end": 809,
"score": 0.9954639673233032,
"start": 797,
"tag": "PASSWORD",
"value": "noop}moreira"
}
] | null |
[] |
package com.programem.login;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder builder) throws Exception {
builder
.inMemoryAuthentication()
.withUser("duda").password("{<PASSWORD>")
.roles("USER")
.and()
.withUser("eduarda").password("{<PASSWORD>")
.roles("USER")
.and()
.withUser("moreira").password("{<PASSWORD>")
.roles("USER");
}
}
| 852 | 0.716959 | 0.716959 | 27 | 30.666666 | 32.684803 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.185185 | false | false |
13
|
0f312068f60642654a5d57f0cebf4d1d189a998f
| 17,085,379,966,719 |
f05cdd2465d1afc39f26032dc4900ec9b7b14f51
|
/core/src/com/mygdx/game/interfaces/PlayerNpcBase.java
|
27b1eec1518f4526a26277ab7089fa345cce22db
|
[] |
no_license
|
Camargod/RabbitHut
|
https://github.com/Camargod/RabbitHut
|
eccef9125a12a03d23e354f17c66aeac31bc59f4
|
ce1286e349f4bdffb59e4b77e81fd5f39fd62b96
|
refs/heads/master
| 2021-04-18T14:31:53.623000 | 2020-07-25T00:15:50 | 2020-07-25T00:15:50 | 249,553,278 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mygdx.game.interfaces;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.utils.Array;
import com.mygdx.game.MyGdxGame;
public class PlayerNpcBase
{
private Array<TextureRegion> idleSprite;
private Array<TextureRegion> upSprite;
private Array<TextureRegion> downSprite;
private Array<TextureRegion> leftSprite;
private Array<TextureRegion> rightSprite;
public Animation<TextureRegion> playerAnim;
public Texture playerSprite;
private float animationSpeed = 0.2f;
protected boolean isRunning = false;
private float spriteWidth = 34f;
private float spriteHeight = 64f;
protected String playerDirection = "idle";
public PlayerNpcBase()
{
playerSprite = new Texture(Gdx.files.internal("player/knight.png"));
idleSprite = new Array<TextureRegion>();
upSprite = new Array<TextureRegion>();
downSprite = new Array<TextureRegion>();
leftSprite = new Array<TextureRegion>();
rightSprite = new Array<TextureRegion>();
for(int i = 0; i <=3; i++)
{
idleSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),0,34,82));
}
for(int i = 4; i <=7; i++)
{
downSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),0,34,82));
}
for(int i = 1; i <=5; i++)
{
upSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),98,34,82));
}
for(int i = 6; i <=7; i++)
{
rightSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),98,34,82));
}
for(int i = 0; i <=3; i++)
{
rightSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),178,34,82));
}
for(int i = 4; i <=7; i++)
{
leftSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),178,34,82));
}
for(int i = 0; i <=1; i++)
{
leftSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),262,34,82));
}
}
public void setRunningState(boolean param)
{
isRunning = param;
animationSpeed = param ? 0.2f : 0.4f;
}
public void update (SpriteBatch batch, float elapsedTime,Body b2Body)
{
switchDraw(playerDirection, batch, elapsedTime,b2Body);
}
public void switchDraw(String state, SpriteBatch batch, float elapsedTime,Body b2Body)
{
switch(state)
{
case "idle":
playerAnim = new Animation<TextureRegion>(0.1f,idleSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "UP":
playerAnim = new Animation<TextureRegion>(animationSpeed,upSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "DOWN":
playerAnim = new Animation<TextureRegion>(animationSpeed,downSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "LEFT":
playerAnim = new Animation<TextureRegion>(animationSpeed,leftSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "RIGHT":
playerAnim = new Animation<TextureRegion>(animationSpeed,rightSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
}
}
private float drawPosX(Body b2Body)
{
return b2Body.getPosition().x - (spriteWidth / 2 / 3 / MyGdxGame.PPM);
}
private float drawPosY(Body b2Body)
{
return b2Body.getPosition().y - (spriteHeight / 2 / 10f / MyGdxGame.PPM);
}
private float drawValueWidth()
{
return spriteWidth / MyGdxGame.PPM / 2.5f;
}
private float drawValueHeight()
{
return spriteHeight / MyGdxGame.PPM / 2;
}
}
|
UTF-8
|
Java
| 4,002 |
java
|
PlayerNpcBase.java
|
Java
|
[] | null |
[] |
package com.mygdx.game.interfaces;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.Box2D;
import com.badlogic.gdx.utils.Array;
import com.mygdx.game.MyGdxGame;
public class PlayerNpcBase
{
private Array<TextureRegion> idleSprite;
private Array<TextureRegion> upSprite;
private Array<TextureRegion> downSprite;
private Array<TextureRegion> leftSprite;
private Array<TextureRegion> rightSprite;
public Animation<TextureRegion> playerAnim;
public Texture playerSprite;
private float animationSpeed = 0.2f;
protected boolean isRunning = false;
private float spriteWidth = 34f;
private float spriteHeight = 64f;
protected String playerDirection = "idle";
public PlayerNpcBase()
{
playerSprite = new Texture(Gdx.files.internal("player/knight.png"));
idleSprite = new Array<TextureRegion>();
upSprite = new Array<TextureRegion>();
downSprite = new Array<TextureRegion>();
leftSprite = new Array<TextureRegion>();
rightSprite = new Array<TextureRegion>();
for(int i = 0; i <=3; i++)
{
idleSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),0,34,82));
}
for(int i = 4; i <=7; i++)
{
downSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),0,34,82));
}
for(int i = 1; i <=5; i++)
{
upSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),98,34,82));
}
for(int i = 6; i <=7; i++)
{
rightSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),98,34,82));
}
for(int i = 0; i <=3; i++)
{
rightSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),178,34,82));
}
for(int i = 4; i <=7; i++)
{
leftSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),178,34,82));
}
for(int i = 0; i <=1; i++)
{
leftSprite.add(new TextureRegion(playerSprite,24 +((34 * i) + (50 * i)),262,34,82));
}
}
public void setRunningState(boolean param)
{
isRunning = param;
animationSpeed = param ? 0.2f : 0.4f;
}
public void update (SpriteBatch batch, float elapsedTime,Body b2Body)
{
switchDraw(playerDirection, batch, elapsedTime,b2Body);
}
public void switchDraw(String state, SpriteBatch batch, float elapsedTime,Body b2Body)
{
switch(state)
{
case "idle":
playerAnim = new Animation<TextureRegion>(0.1f,idleSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "UP":
playerAnim = new Animation<TextureRegion>(animationSpeed,upSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "DOWN":
playerAnim = new Animation<TextureRegion>(animationSpeed,downSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "LEFT":
playerAnim = new Animation<TextureRegion>(animationSpeed,leftSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
case "RIGHT":
playerAnim = new Animation<TextureRegion>(animationSpeed,rightSprite);
batch.draw(playerAnim.getKeyFrame(elapsedTime,true), drawPosX(b2Body), drawPosY(b2Body), drawValueWidth(), drawValueHeight());
break;
}
}
private float drawPosX(Body b2Body)
{
return b2Body.getPosition().x - (spriteWidth / 2 / 3 / MyGdxGame.PPM);
}
private float drawPosY(Body b2Body)
{
return b2Body.getPosition().y - (spriteHeight / 2 / 10f / MyGdxGame.PPM);
}
private float drawValueWidth()
{
return spriteWidth / MyGdxGame.PPM / 2.5f;
}
private float drawValueHeight()
{
return spriteHeight / MyGdxGame.PPM / 2;
}
}
| 4,002 | 0.685407 | 0.650425 | 129 | 30.031008 | 33.005505 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.55814 | false | false |
13
|
a387fb99c478aab8eb48f97577176adb38271f4b
| 6,914,897,399,901 |
47df535cef3253ce788eb0ee17db3ded112647dc
|
/app/src/main/java/com/example/jaishree/attendance/StudentSubjectAttendance.java
|
fd7572ffcecef7efc4b939738fd32f656dd52cc0
|
[] |
no_license
|
Jaishreeagarwal48/Smart_Attendance_System
|
https://github.com/Jaishreeagarwal48/Smart_Attendance_System
|
e8d868906ebf87f31e7681bfe5dcb4c79386b161
|
d4d4793adda6c6ce715e5c0f3affb47cba90a2de
|
refs/heads/master
| 2020-09-16T08:15:19.847000 | 2019-11-24T07:44:19 | 2019-11-24T07:44:39 | 223,709,033 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.jaishree.attendance;
import android.app.DatePickerDialog;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.DatePicker;
import android.widget.ListView;
import com.example.jaishree.attendance.Adapter.SubjectAttendanceAdapter;
import com.example.jaishree.attendance.Pojo.TakeAttendancePojo;
import com.example.jaishree.attendance.database.MySqliteOpenHelper;
import com.example.jaishree.attendance.table.Attendance;
import java.util.ArrayList;
import java.util.Calendar;
public class StudentSubjectAttendance extends AppCompatActivity {
int sub_id,studentId;
String sub_name="";
SubjectAttendanceAdapter subjectAttendanceAdapter;
ArrayList<TakeAttendancePojo> arrayListAttendance=new ArrayList<>();
ListView subjectAttendanceListView;
String status = "", selectedDate = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_subject_attendance);
sub_id=getIntent().getIntExtra("subId",0);
sub_name=getIntent().getStringExtra("subName");
Log.d("123", "onCreate: "+sub_id);
Log.d("123", "onCreate: "+sub_name);
init();
subjectAttendanceAdapter=new SubjectAttendanceAdapter(this,R.layout.subject_attendance_list_item,arrayListAttendance);
subjectAttendanceListView.setAdapter(subjectAttendanceAdapter);
getId();
methodListener();
}
private void getId() {
SharedPreferences pref = getSharedPreferences("myFile",MODE_PRIVATE);
studentId = pref.getInt("studentId", 0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.viewattendance_menu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id=item.getItemId();
if(id==R.id.attendanceFilter){
selectDate();
}
return super.onOptionsItemSelected(item);
}
private void selectDate() {
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
if ((month + 1) < 10) {
selectedDate = "" + day + "-0" + (month + 1) + "-" + year;
} else {
selectedDate = "" + day + "-" + (month + 1) + "-" + year;
}
String selection = Attendance.DATE + " = '" + selectedDate + "' AND " + Attendance.SUBJECT_ID + "='" + sub_id + "' AND " + Attendance.STUDENT_ID + "='" + studentId + "'";
showList(selection);
}
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.show();
}
private void showList(String selection) {
arrayListAttendance.clear();
MySqliteOpenHelper mySqliteOpenHelper = new MySqliteOpenHelper(this);
SQLiteDatabase db = mySqliteOpenHelper.getReadableDatabase();
Cursor cursor = Attendance.select(db, selection);
if (cursor != null) {
while (cursor.moveToNext()) {
TakeAttendancePojo pojo = new TakeAttendancePojo();
pojo.setSubject_name(sub_name);
status = cursor.getString(4);
pojo.setStatus(status);
pojo.setDate(cursor.getString(5));
arrayListAttendance.add(pojo);
}
subjectAttendanceAdapter.notifyDataSetChanged();
}
}
private void init() {
subjectAttendanceListView= (ListView) findViewById(R.id.subjectAttendanceListView);
}
private void methodListener() {
String selection = Attendance.SUBJECT_ID + "='" + sub_id + "' AND " + Attendance.STUDENT_ID + "='" + studentId + "'";
showList(selection);
}
}
|
UTF-8
|
Java
| 4,291 |
java
|
StudentSubjectAttendance.java
|
Java
|
[] | null |
[] |
package com.example.jaishree.attendance;
import android.app.DatePickerDialog;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.DatePicker;
import android.widget.ListView;
import com.example.jaishree.attendance.Adapter.SubjectAttendanceAdapter;
import com.example.jaishree.attendance.Pojo.TakeAttendancePojo;
import com.example.jaishree.attendance.database.MySqliteOpenHelper;
import com.example.jaishree.attendance.table.Attendance;
import java.util.ArrayList;
import java.util.Calendar;
public class StudentSubjectAttendance extends AppCompatActivity {
int sub_id,studentId;
String sub_name="";
SubjectAttendanceAdapter subjectAttendanceAdapter;
ArrayList<TakeAttendancePojo> arrayListAttendance=new ArrayList<>();
ListView subjectAttendanceListView;
String status = "", selectedDate = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_subject_attendance);
sub_id=getIntent().getIntExtra("subId",0);
sub_name=getIntent().getStringExtra("subName");
Log.d("123", "onCreate: "+sub_id);
Log.d("123", "onCreate: "+sub_name);
init();
subjectAttendanceAdapter=new SubjectAttendanceAdapter(this,R.layout.subject_attendance_list_item,arrayListAttendance);
subjectAttendanceListView.setAdapter(subjectAttendanceAdapter);
getId();
methodListener();
}
private void getId() {
SharedPreferences pref = getSharedPreferences("myFile",MODE_PRIVATE);
studentId = pref.getInt("studentId", 0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.viewattendance_menu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id=item.getItemId();
if(id==R.id.attendanceFilter){
selectDate();
}
return super.onOptionsItemSelected(item);
}
private void selectDate() {
Calendar calendar = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datePicker, int year, int month, int day) {
if ((month + 1) < 10) {
selectedDate = "" + day + "-0" + (month + 1) + "-" + year;
} else {
selectedDate = "" + day + "-" + (month + 1) + "-" + year;
}
String selection = Attendance.DATE + " = '" + selectedDate + "' AND " + Attendance.SUBJECT_ID + "='" + sub_id + "' AND " + Attendance.STUDENT_ID + "='" + studentId + "'";
showList(selection);
}
}, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.show();
}
private void showList(String selection) {
arrayListAttendance.clear();
MySqliteOpenHelper mySqliteOpenHelper = new MySqliteOpenHelper(this);
SQLiteDatabase db = mySqliteOpenHelper.getReadableDatabase();
Cursor cursor = Attendance.select(db, selection);
if (cursor != null) {
while (cursor.moveToNext()) {
TakeAttendancePojo pojo = new TakeAttendancePojo();
pojo.setSubject_name(sub_name);
status = cursor.getString(4);
pojo.setStatus(status);
pojo.setDate(cursor.getString(5));
arrayListAttendance.add(pojo);
}
subjectAttendanceAdapter.notifyDataSetChanged();
}
}
private void init() {
subjectAttendanceListView= (ListView) findViewById(R.id.subjectAttendanceListView);
}
private void methodListener() {
String selection = Attendance.SUBJECT_ID + "='" + sub_id + "' AND " + Attendance.STUDENT_ID + "='" + studentId + "'";
showList(selection);
}
}
| 4,291 | 0.655325 | 0.651363 | 113 | 36.97345 | 31.839325 | 186 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.716814 | false | false |
13
|
26ae32d9d35bdbc4d9313bc42548a9d1dcbfffa0
| 27,805,618,277,720 |
a9c947bada3737df5a236260d24d9b50fde18a0b
|
/app/src/main/java/com/gavin/redagger/base/App.java
|
4c351943f3db56de116844f8a64c5ecad1922180
|
[] |
no_license
|
gavinxxxxxx/ReDagger
|
https://github.com/gavinxxxxxx/ReDagger
|
41cfdd9ef07b7d59c3fb64f5f5e503354e8cdafd
|
65642e77b27e763a530a2a6802ed2e646e3a3cf3
|
refs/heads/master
| 2021-01-20T02:54:57.198000 | 2017-04-26T10:17:53 | 2017-04-26T10:17:53 | 89,467,744 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.gavin.redagger.base;
import android.app.Application;
import com.gavin.redagger.inject.component.ApplicationComponent;
import com.gavin.redagger.inject.component.DaggerApplicationComponent;
import com.gavin.redagger.inject.module.ApplicationModule;
/**
* 自定义Application
*
* @author gavin.xiong 2016/5/18
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
initDagger();
}
private void initDagger() {
ApplicationComponent.Instance.init(DaggerApplicationComponent
.builder()
.applicationModule(new ApplicationModule(this))
.build());
}
}
|
UTF-8
|
Java
| 697 |
java
|
App.java
|
Java
|
[
{
"context": "cationModule;\n\n/**\n * 自定义Application\n *\n * @author gavin.xiong 2016/5/18\n */\npublic class App extends Applicatio",
"end": 310,
"score": 0.9525824189186096,
"start": 299,
"tag": "USERNAME",
"value": "gavin.xiong"
}
] | null |
[] |
package com.gavin.redagger.base;
import android.app.Application;
import com.gavin.redagger.inject.component.ApplicationComponent;
import com.gavin.redagger.inject.component.DaggerApplicationComponent;
import com.gavin.redagger.inject.module.ApplicationModule;
/**
* 自定义Application
*
* @author gavin.xiong 2016/5/18
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
initDagger();
}
private void initDagger() {
ApplicationComponent.Instance.init(DaggerApplicationComponent
.builder()
.applicationModule(new ApplicationModule(this))
.build());
}
}
| 697 | 0.68741 | 0.677279 | 28 | 23.678572 | 22.786358 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false |
13
|
00bcadbab02345578490265d5e03a837dafd051d
| 23,768,349,068,798 |
4099fb95bb56c0a1416478914224f5becfb654f5
|
/server/src/main/java/com/huake/saas/weixin/model/BindWeixinMessage.java
|
8a48933c2d103a7208be38b883f24b4aae1d250e
|
[] |
no_license
|
tyxing007/AppPortal
|
https://github.com/tyxing007/AppPortal
|
9c43b90c7ac4bb2920c5cb830e9d43bfa3b58bc7
|
5c12486d1f2d99fceb0875608818e8dcadf7282b
|
refs/heads/master
| 2020-12-25T09:46:56.418000 | 2015-02-12T09:13:10 | 2015-02-12T09:13:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.huake.saas.weixin.model;
import java.math.BigDecimal;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class BindWeixinMessage {
@XmlElement(name = "ToUserName")
private String toUserName;
@XmlElement(name = "FromUserName")
private String fromUserName;
@XmlElement(name = "CreateTime")
private Date createTime;
@XmlElement(name = "MsgType")
private String messageType;
@XmlElement(name = "Event")
private String event;
@XmlElement(name = "EventKey")
private String eventKey;
@XmlElement(name = "PicUrl")
private String picUrl;
@XmlElement(name = "Title")
private String title;
@XmlElement(name = "Description")
private String description;
@XmlElement(name = "Url")
private String url;
@XmlElement(name = "Location_X")
private BigDecimal longitude;
@XmlElement(name = "Location_Y")
private BigDecimal latitude;
@XmlElement(name = "Scale")
private BigDecimal scale;
@XmlElement(name = "Label")
private String label;
@XmlElement(name = "Content")
private String content;
@XmlElement(name = "MsgId")
private String messageId;
public String getToUserName() {
return toUserName;
}
public void setToUserName(String toUserName) {
this.toUserName = toUserName;
}
public String getFromUserName() {
return fromUserName;
}
public void setFromUserName(String fromUserName) {
this.fromUserName = fromUserName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getMessageType() {
return messageType;
}
public void setMessageType(String messageType) {
this.messageType = messageType;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getEventKey() {
return eventKey;
}
public void setEventKey(String eventKey) {
this.eventKey = eventKey;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public BigDecimal getScale() {
return scale;
}
public void setScale(BigDecimal scale) {
this.scale = scale;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
}
|
UTF-8
|
Java
| 3,614 |
java
|
BindWeixinMessage.java
|
Java
|
[] | null |
[] |
package com.huake.saas.weixin.model;
import java.math.BigDecimal;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class BindWeixinMessage {
@XmlElement(name = "ToUserName")
private String toUserName;
@XmlElement(name = "FromUserName")
private String fromUserName;
@XmlElement(name = "CreateTime")
private Date createTime;
@XmlElement(name = "MsgType")
private String messageType;
@XmlElement(name = "Event")
private String event;
@XmlElement(name = "EventKey")
private String eventKey;
@XmlElement(name = "PicUrl")
private String picUrl;
@XmlElement(name = "Title")
private String title;
@XmlElement(name = "Description")
private String description;
@XmlElement(name = "Url")
private String url;
@XmlElement(name = "Location_X")
private BigDecimal longitude;
@XmlElement(name = "Location_Y")
private BigDecimal latitude;
@XmlElement(name = "Scale")
private BigDecimal scale;
@XmlElement(name = "Label")
private String label;
@XmlElement(name = "Content")
private String content;
@XmlElement(name = "MsgId")
private String messageId;
public String getToUserName() {
return toUserName;
}
public void setToUserName(String toUserName) {
this.toUserName = toUserName;
}
public String getFromUserName() {
return fromUserName;
}
public void setFromUserName(String fromUserName) {
this.fromUserName = fromUserName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getMessageType() {
return messageType;
}
public void setMessageType(String messageType) {
this.messageType = messageType;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getEventKey() {
return eventKey;
}
public void setEventKey(String eventKey) {
this.eventKey = eventKey;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public BigDecimal getLongitude() {
return longitude;
}
public void setLongitude(BigDecimal longitude) {
this.longitude = longitude;
}
public BigDecimal getLatitude() {
return latitude;
}
public void setLatitude(BigDecimal latitude) {
this.latitude = latitude;
}
public BigDecimal getScale() {
return scale;
}
public void setScale(BigDecimal scale) {
this.scale = scale;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getMessageId() {
return messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
}
| 3,614 | 0.683177 | 0.683177 | 191 | 16.921467 | 15.765265 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.21466 | false | false |
13
|
26a43e1ad65438375bee5a1ee8fc43e4420c794d
| 17,884,243,886,791 |
8fe60ac9f24c90797221276bfbca5708049b8cd6
|
/chess-game/src/main/java/com/nadeem/app/kata/Command.java
|
d8039b894f79f737f13fe40eae30a90b65f7e7c2
|
[
"Apache-2.0"
] |
permissive
|
AlexRogalskiy/katas
|
https://github.com/AlexRogalskiy/katas
|
398030cd961261db149ee2a594efa46fa4aace59
|
41533353c5479ed593fdac56d4b21a5d26bebdde
|
refs/heads/master
| 2021-12-12T08:08:25.773000 | 2016-12-24T04:01:17 | 2016-12-24T04:01:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.nadeem.app.kata;
/**
* @author Nadeem Mohammad
*
*/
public class Command {
private Piece piece;
private Position destination;
public Command(final Piece piece, final Position destination) {
this.piece = piece;
this.destination = destination;
}
public Piece getPiece() {
return piece;
}
public Position getDestination() {
return destination;
}
}
|
UTF-8
|
Java
| 405 |
java
|
Command.java
|
Java
|
[
{
"context": "package com.nadeem.app.kata;\r\n\r\n/**\r\n * @author Nadeem Mohammad\r\n *\r\n */\r\npublic class Command {\r\n\r\n\tprivate Piec",
"end": 63,
"score": 0.9998766183853149,
"start": 48,
"tag": "NAME",
"value": "Nadeem Mohammad"
}
] | null |
[] |
package com.nadeem.app.kata;
/**
* @author <NAME>
*
*/
public class Command {
private Piece piece;
private Position destination;
public Command(final Piece piece, final Position destination) {
this.piece = piece;
this.destination = destination;
}
public Piece getPiece() {
return piece;
}
public Position getDestination() {
return destination;
}
}
| 396 | 0.669136 | 0.669136 | 24 | 14.875 | 16.076153 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false |
13
|
5e3c738923144d90860cd999839364366318ec21
| 35,785,667,532,487 |
b13d1f04427215f278fd391448af8aef05a45099
|
/src/org/hollowcraft/server/model/World.java
|
5acbacb1fabea98cba598d487d63e72a2c016288
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
Mediator/HollowCraft
|
https://github.com/Mediator/HollowCraft
|
991655dd71d753c95787f5e7878eaa24f867b24b
|
ecb62018dfe1b86e1ec17996e4a00a6d06c764dc
|
refs/heads/master
| 2016-09-09T23:57:42.340000 | 2010-10-07T03:26:34 | 2010-10-07T03:26:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.hollowcraft.server.model;
/*
* HollowCraft License
* Copyright (c) 2010 Caleb Champlin.
* All rights reserved
* This license must be include in all copied, cloned and derived works
*/
import java.util.*;
import java.io.IOException;
import org.hollowcraft.model.BlockDefinition;
import org.hollowcraft.model.BlockManager;
import org.hollowcraft.model.Entity;
import org.hollowcraft.model.Environment;
import org.hollowcraft.model.Level;
import org.hollowcraft.model.Position;
import org.hollowcraft.model.Rotation;
import org.hollowcraft.server.Configuration;
import org.hollowcraft.server.game.GameMode;
import org.hollowcraft.server.game.impl.SandboxGameMode;
import org.hollowcraft.server.io.WorldManager;
import org.hollowcraft.server.model.Builder;
import org.hollowcraft.server.model.OnBlockChangeHandler;
import org.hollowcraft.server.model.Player;
import org.hollowcraft.server.model.impl.builders.*;
import org.hollowcraft.server.net.MinecraftSession;
import org.hollowcraft.server.security.Policy;
import org.hollowcraft.server.task.TaskQueue;
import org.hollowcraft.server.util.NPEList;
import org.hollowcraft.server.util.PlayerList;
import org.slf4j.*;
/**
* Manages the in-game world.
* @author Caleb Champlin
*/
public interface World extends Level {
public Policy getPolicy();
public void setPolicy(Policy p);
public void finalize();
/**
* Gets the current game mode.
* @return The current game mode.
*/
public GameMode<Player> getGameMode();
/**
* Gets the player list.
* @return The player list.
*/
public PlayerList getPlayerList();
public NPEList getEntityList();
public void removePlayer(Player p);
public void addPlayer(Player p);
public void removeEntity(NPEntity ent);
public void addEntity(NPEntity ent);
/**
* Completes registration of a session.
* @param session The session.
*/
public void completeRegistration(MinecraftSession session);
/**
* Broadcasts a chat message.
* @param player The source player.
* @param message The message.
*/
public void broadcast(Player player, String message);
/**
* Broadcasts a server message.
* @param message The message.
*/
public void broadcast(String message);
}
|
UTF-8
|
Java
| 2,231 |
java
|
World.java
|
Java
|
[
{
"context": "\n\n/*\n * HollowCraft License\n * Copyright (c) 2010 Caleb Champlin.\n * All rights reserved\n * This license must be",
"end": 102,
"score": 0.9998748898506165,
"start": 88,
"tag": "NAME",
"value": "Caleb Champlin"
},
{
"context": "j.*;\n\n/**\n * Manages the in-game world.\n * @author Caleb Champlin\n */\npublic interface World extends Level {\n\t\n\n\tpu",
"end": 1249,
"score": 0.9998669028282166,
"start": 1235,
"tag": "NAME",
"value": "Caleb Champlin"
}
] | null |
[] |
package org.hollowcraft.server.model;
/*
* HollowCraft License
* Copyright (c) 2010 <NAME>.
* All rights reserved
* This license must be include in all copied, cloned and derived works
*/
import java.util.*;
import java.io.IOException;
import org.hollowcraft.model.BlockDefinition;
import org.hollowcraft.model.BlockManager;
import org.hollowcraft.model.Entity;
import org.hollowcraft.model.Environment;
import org.hollowcraft.model.Level;
import org.hollowcraft.model.Position;
import org.hollowcraft.model.Rotation;
import org.hollowcraft.server.Configuration;
import org.hollowcraft.server.game.GameMode;
import org.hollowcraft.server.game.impl.SandboxGameMode;
import org.hollowcraft.server.io.WorldManager;
import org.hollowcraft.server.model.Builder;
import org.hollowcraft.server.model.OnBlockChangeHandler;
import org.hollowcraft.server.model.Player;
import org.hollowcraft.server.model.impl.builders.*;
import org.hollowcraft.server.net.MinecraftSession;
import org.hollowcraft.server.security.Policy;
import org.hollowcraft.server.task.TaskQueue;
import org.hollowcraft.server.util.NPEList;
import org.hollowcraft.server.util.PlayerList;
import org.slf4j.*;
/**
* Manages the in-game world.
* @author <NAME>
*/
public interface World extends Level {
public Policy getPolicy();
public void setPolicy(Policy p);
public void finalize();
/**
* Gets the current game mode.
* @return The current game mode.
*/
public GameMode<Player> getGameMode();
/**
* Gets the player list.
* @return The player list.
*/
public PlayerList getPlayerList();
public NPEList getEntityList();
public void removePlayer(Player p);
public void addPlayer(Player p);
public void removeEntity(NPEntity ent);
public void addEntity(NPEntity ent);
/**
* Completes registration of a session.
* @param session The session.
*/
public void completeRegistration(MinecraftSession session);
/**
* Broadcasts a chat message.
* @param player The source player.
* @param message The message.
*/
public void broadcast(Player player, String message);
/**
* Broadcasts a server message.
* @param message The message.
*/
public void broadcast(String message);
}
| 2,215 | 0.761094 | 0.758853 | 90 | 23.788889 | 19.441362 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.911111 | false | false |
13
|
5c12b69eab7ae96c03964385adff53fa34a570c3
| 12,747,462,994,097 |
efa45b76e1431d63c02ffb1a86f5a748938b663e
|
/src/com/main/baofang/DishOrderActivity.java
|
ffcadc91ea9cd9a2c08ef8484dd1020e31ae8b5d
|
[] |
no_license
|
wooof21/Serious-Creator_Project1
|
https://github.com/wooof21/Serious-Creator_Project1
|
8668dfcdd042fcac7abcc7822c57e4cd28711dd7
|
87bff0846c8add981432f05faa8c2c335917fe0a
|
refs/heads/master
| 2020-06-19T04:43:40.764000 | 2016-11-27T23:14:16 | 2016-11-27T23:14:16 | 74,920,037 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package com.main.baofang;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.chihuoshijian.R;
import com.chihuoshijian.view.DragSupportView;
import com.chihuoshijian.view.DragView;
import com.chihuoshijian.view.DragView.DragListener;
import com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter;
import com.chihuoshijian.view.PinnedHeaderListView;
import com.main.canting.CanTingDetailActivity;
import com.main.meishi.MeiShiCommentMain;
import com.model.ItemEntity;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.utils.StorageUtils;
import com.tools.Config;
import com.tools.Tools;
import android.R.integer;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.AbsListView.LayoutParams;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
/**
* @author Liming Chu
*
* @param
* @return
*/
public class DishOrderActivity extends Activity implements OnClickListener{
private ProgressDialog progressDialog;
private ArrayList<ItemEntity> list;
private ArrayList<ItemEntity> sortList;
private PinnedHeaderListView listView;
private ImageView slide;
private LinearLayout ll;
private TextView count;
private DragView dView;
private DragSupportView dsView;
private RelativeLayout midRL;
private RelativeLayout dsoMain;
private RelativeLayout leftMenu;
private ListView leftLV;
// 生成测试菜单选项数据
private List<Map<String, String>> leftData;
private String uid;
private ViewGroup anim_mask_layout; // 动画层
private ImageView buyImg; // 这是在界面上跑的小图片
private int buyNum = 0; // 购买数量
private ArrayList<ItemEntity> cartList;
private String title;
/*
* (non-Javadoc)
*
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState){
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.dish_order_slding_menu_main);
prepareView();
/**
* 如果需要在别的Activity界面中也实现侧滑菜单效果,需要在布局中引入DragLayout(同本Activity方式),
* 然后在onCreate中声明使用; Activity界面部分,需要包裹在MyRelativeLayout中.
*/
dView.setDragListener(new DragListener(){// 动作监听
@Override
public void onOpen(){
}
@Override
public void onClose(){
}
@Override
public void onDrag(float percent){
}
});
uid = getIntent().getStringExtra("uid");
title = getIntent().getExtras().getString("title");
new ListAsync().execute(uid);
cartList = new ArrayList<ItemEntity>();
}
private void prepareView(){
dView =
(DragView) findViewById(R.id.dish_order_dragview);
dsView =
(DragSupportView) findViewById(R.id.dish_order_dragsupport);
midRL =
(RelativeLayout) findViewById(R.id.dish_order_middle);
dsoMain =
(RelativeLayout) midRL
.findViewById(R.id.dish_order_main);
listView =
(PinnedHeaderListView) dsoMain
.findViewById(R.id.dish_order_pinned_list_view);
slide =
(ImageView) dsoMain
.findViewById(R.id.dish_order_main_slide_button);
ll =
(LinearLayout) dsoMain
.findViewById(R.id.dish_order_shopping_cart_ll);
count =
(TextView) dsoMain
.findViewById(R.id.dish_order_shopping_cart_count);
leftMenu =
(RelativeLayout) findViewById(R.id.dish_order_left);
leftLV =
(ListView) leftMenu
.findViewById(R.id.sliding_menu_leftmenu_lv);
LinearLayout _ll = new LinearLayout(this);
LayoutParams lp =
new LayoutParams(LayoutParams.MATCH_PARENT,
180);
_ll.setLayoutParams(lp);
listView.addFooterView(_ll);
slide.setOnClickListener(this);
ll.setOnClickListener(this);
}
private Handler handler = new Handler(){
@Override
public
void
handleMessage(
Message msg){
// TODO Auto-generated method stub
super.handleMessage(msg);
Log.e("handler",
"handl msg");
// * 创建新的HeaderView,即置顶的HeaderView
View HeaderView =
getLayoutInflater()
.inflate(
R.layout.pinned_list_view_header,
listView,
false);
listView.setPinnedHeader(HeaderView);
PinnedListAdapter adapter =
new PinnedListAdapter(
DishOrderActivity.this,
list);
listView.setAdapter(adapter);
listView.setOnScrollListener(adapter);
listView.setOnItemClickListener(new OnItemClickListener(){
@Override
public
void
onItemClick(
AdapterView<?> parent,
View view,
int position,
long id){
// TODO Auto-generated method
// stub
Intent intent =
new Intent(
DishOrderActivity.this,
MeiShiCommentMain.class);
intent.putExtra(
"id",
list.get(
position)
.getId());
intent.putExtra(
"uid",
uid);
startActivity(intent);
}
});
}
};
class ListAsync extends AsyncTask<Object, Void, String>{
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPreExecute()
*/
@Override
protected void onPreExecute(){
// TODO Auto-generated method stub
super.onPreExecute();
progressDialog =
ProgressDialog.show(
DishOrderActivity.this, null,
null);
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#doInBackground(Params[])
*/
@Override
protected String doInBackground(Object... params){
// TODO Auto-generated method stub
Log.e("url", Config.DISH_ORDER_LIST_URL
+ params[0]);
String data =
new Tools()
.getURL(Config.DISH_ORDER_LIST_URL
+ params[0]);
String code = "";
list = new ArrayList<ItemEntity>();
leftData = new ArrayList<Map<String, String>>();
try{
JSONObject job = new JSONObject(data);
code = job.getString("code");
if(code.equals("1")){
JSONArray jArray =
job.getJSONArray("result1");
for(int i = 0,j = jArray.length();i < j;i++){
JSONObject job1 =
jArray.optJSONObject(i);
String classname =
job1.getString("classname");
JSONArray jArray2 =
job1.getJSONArray("next");
HashMap<String, String> nameMap =
new HashMap<String, String>();
nameMap.put("item", classname);
leftData.add(nameMap);
for(int m = 0,n = jArray2.length();m < n;m++){
JSONObject job2 =
jArray2.optJSONObject(m);
String pf =
job2.getString("pf");
float rate = 0;
if(pf.equals("false")){
rate = 0;
Log.e("pf", pf);
}else{
rate = Float.valueOf(pf);
}
ItemEntity item =
new ItemEntity(
classname,
job2.getString("id"),
job2.getString("n_title"),
job2.getString("n_dj"),
rate,
job2.getString("n_pic"),
1);
list.add(item);
}
}
}
}catch(JSONException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
return code;
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPostExecute(java.lang.Object)
*/
@Override
protected void onPostExecute(String result){
// TODO Auto-generated method stub
super.onPostExecute(result);
progressDialog.dismiss();
if(result.equals("1")){
Message msg = handler.obtainMessage();
handler.sendMessage(msg);
}
leftLV.setAdapter(new SimpleAdapter(
DishOrderActivity.this,
leftData,
R.layout.sliding_menu_menulist_item_text,
new String[] { "item" },
new int[] { R.id.menu_text }));
leftLV.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(
AdapterView<?> parent, View view,
int position, long id){
// TODO Auto-generated method stub
String classname =
leftData.get(position).get(
"item");
sortList = new ArrayList<ItemEntity>();
for(int i = 0,j = list.size();i < j;i++){
if(!(list.get(i).getClassname()
.equals(classname))){
sortList.add(list.get(i));
}else{
sortList.add(0, list.get(i));
}
}
for(int i = 0,j = sortList.size();i < j;i++){
System.out.println(sortList.get(i)
.getClassname());
}
dView.close();
PinnedListAdapter adapter =
new PinnedListAdapter(
DishOrderActivity.this,
sortList);
listView.setAdapter(adapter);
listView.setOnScrollListener(adapter);
}
});
}
}
class PinnedListAdapter extends BaseAdapter implements
OnScrollListener, PinnedHeaderAdapter{
private ViewHolder vHolder = null;
private Context context;
private ArrayList<ItemEntity> list;
private LayoutInflater lInflater;
private DisplayImageOptions options;
public PinnedListAdapter(Context context,
ArrayList<ItemEntity> list){
super();
this.context = context;
this.list = list;
this.lInflater = LayoutInflater.from(context);
preperImageLoader();
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getCount()
*/
@Override
public int getCount(){
// TODO Auto-generated method stub
Log.e("size", "" + list.size());
return list.size();
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItem(int)
*/
@Override
public Object getItem(int position){
// TODO Auto-generated method stub
return list.get(position);
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItemId(int)
*/
@Override
public long getItemId(int position){
// TODO Auto-generated method stub
return position;
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@Override
public View getView(final int position, View convertView,
ViewGroup parent){
// TODO Auto-generated method stub
if(convertView == null){
convertView =
lInflater.inflate(
R.layout.pinned_listview_item,
null);
}
vHolder = new ViewHolder();
vHolder.pic =
(ImageView) convertView
.findViewById(R.id.pinned_list_item_pic);
vHolder.title =
(TextView) convertView
.findViewById(R.id.title);
vHolder.name =
(TextView) convertView
.findViewById(R.id.pinned_list_item_name);
vHolder.price =
(TextView) convertView
.findViewById(R.id.pinned_list_item_price);
vHolder.rb =
(RatingBar) convertView
.findViewById(R.id.pinned_list_item_ratingbar);
vHolder.rating =
(TextView) convertView
.findViewById(R.id.pinned_list_item_rating);
vHolder.order =
(TextView) convertView
.findViewById(R.id.pinned_list_item_order);
vHolder.rb.setClickable(false);
// 获取数据
final ItemEntity item = (ItemEntity) list.get(position);
ImageLoader.getInstance().displayImage(
Config.DOMAIN + item.getPicAddr(),
vHolder.pic);
vHolder.rb.setRating(item.getRate());
vHolder.title.setText(item.getClassname());
vHolder.name.setText(item.getTitle());
vHolder.price.setText(item.getPrice());
vHolder.rating.setText("" + item.getRate());
final String url =
Config.DOMAIN + item.getPicAddr();
vHolder.order
.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
// TODO Auto-generated method stub
int[] start_location =
new int[2];// 一个整型数组,用来存储按钮的在屏幕的X、Y坐标
v.getLocationInWindow(start_location);// 这是获取购买按钮的在屏幕的X、Y坐标(这也是动画开始的坐标)
buyImg = new ImageView(context);
ImageLoader
.getInstance()
.displayImage(url,
buyImg, options);
start_location[0] = 40;
start_location[1] -= 80;
setAnim(buyImg, start_location);// 开始执行动画
Log.e("position", ""+position);
Log.e("click", item.getTitle());
if(getCartList().contains(item)){
System.out
.println("contains");
getCartList().get(getCartList().indexOf(item)).setItemCount(getCartList().get(getCartList().indexOf(item)).getItemCount() + 1);
//item.setItemCount(item.getItemCount() + 1);
}else{
System.out
.println("not contains");
getCartList().add(item);
}
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("3 " + getCartList().get(i).getTitle());
System.out.println("3 " + getCartList().get(i).getItemCount());
}
}
});
if(needTitle(position)){
// 显示标题并设置内容
vHolder.title.setText(item.getClassname());
vHolder.title.setVisibility(View.VISIBLE);
}else{
// 内容项隐藏标题
vHolder.title.setVisibility(View.GONE);
}
return convertView;
}
/*
* (non-Javadoc)
*
* @see com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter#
* getPinnedHeaderState(int)
*/
@Override
public int getPinnedHeaderState(int position){
// TODO Auto-generated method stub
if(getCount() == 0 || position < 0){
return PinnedHeaderAdapter.PINNED_HEADER_GONE;
}
if(isMove(position) == true){
return PinnedHeaderAdapter.PINNED_HEADER_PUSHED_UP;
}
return PinnedHeaderAdapter.PINNED_HEADER_VISIBLE;
}
/*
* (non-Javadoc)
*
* @see com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter#
* configurePinnedHeader(android.view.View, int, int)
*/
@Override
public void configurePinnedHeader(View headerView,
int position, int alpaha){
// TODO Auto-generated method stub
// 设置标题的内容
ItemEntity itemEntity =
(ItemEntity) getItem(position);
String headerValue = itemEntity.getClassname();
Log.e("", "header = " + headerValue);
if(!TextUtils.isEmpty(headerValue)){
TextView headerTextView =
(TextView) headerView
.findViewById(R.id.header);
headerTextView.setText(headerValue);
}
}
/*
* (non-Javadoc)
*
* @see
* android.widget.AbsListView.OnScrollListener#onScrollStateChanged(
* android .widget.AbsListView, int)
*/
@Override
public void onScrollStateChanged(AbsListView view,
int scrollState){
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* android.widget.AbsListView.OnScrollListener#onScroll(android.widget.
* AbsListView, int, int, int)
*/
@Override
public void onScroll(AbsListView view,
int firstVisibleItem, int visibleItemCount,
int totalItemCount){
// TODO Auto-generated method stub
if(view instanceof PinnedHeaderListView){
((PinnedHeaderListView) view)
.controlPinnedHeader(firstVisibleItem);
}
}
// ===========================================================
// Methods
// ===========================================================
/**
* 判断是否需要显示标题
*
* @param position
* @return
*/
private boolean needTitle(int position){
// 第一个肯定是分类
if(position == 0){
return true;
}
// 异常处理
if(position < 0){
return false;
}
// 当前 // 上一个
ItemEntity currentEntity =
(ItemEntity) getItem(position);
ItemEntity previousEntity =
(ItemEntity) getItem(position - 1);
if(null == currentEntity
|| null == previousEntity){
return false;
}
String currentTitle =
currentEntity.getClassname();
String previousTitle =
previousEntity.getClassname();
if(null == previousTitle
|| null == currentTitle){
return false;
}
// 当前item分类名和上一个item分类名不同,则表示两item属于不同分类
if(currentTitle.equals(previousTitle)){
return false;
}
return true;
}
private boolean isMove(int position){
// 获取当前与下一项
ItemEntity currentEntity =
(ItemEntity) getItem(position);
ItemEntity nextEntity =
(ItemEntity) getItem(position + 1);
if(null == currentEntity || null == nextEntity){
return false;
}
// 获取两项header内容
String currentTitle =
currentEntity.getClassname();
String nextTitle = nextEntity.getClassname();
if(null == currentTitle || null == nextTitle){
return false;
}
// 当前不等于下一项header,当前项需要移动了
if(!currentTitle.equals(nextTitle)){
return true;
}
return false;
}
private void preperImageLoader(){
/******************* 配置ImageLoder ***********************************************/
File cacheDir =
StorageUtils.getOwnCacheDirectory(
context, "imageloader/Cache");
ImageLoaderConfiguration config =
new ImageLoaderConfiguration.Builder(
context)
.denyCacheImageMultipleSizesInMemory()
.discCache(
new UnlimitedDiscCache(
cacheDir))// 自定义缓存路径
.build();// 开始构建
options =
new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.imageScaleType(
ImageScaleType.IN_SAMPLE_INT)
.showImageForEmptyUri(
R.drawable.imageloader_default)
.showImageOnFail(R.drawable.imageloader_default)
.build();
ImageLoader.getInstance().init(config);// 全局初始化此配置
/*********************************************************************************/
}
class ViewHolder{
ImageView pic;
TextView title;
TextView name;
TextView price;
RatingBar rb;
TextView rating;
TextView order;
}
}
/**
* @Description: 创建动画层
* @param
* @return void
* @throws
*/
private ViewGroup createAnimLayout(){
ViewGroup rootView =
(ViewGroup) this.getWindow().getDecorView();
LinearLayout animLayout = new LinearLayout(this);
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
animLayout.setLayoutParams(lp);
animLayout.setId(Integer.MAX_VALUE);
animLayout
.setBackgroundResource(android.R.color.transparent);
rootView.addView(animLayout);
return animLayout;
}
private View addViewToAnimLayout(final ViewGroup vg,
final View view, int[] location){
int x = location[0];
int y = location[1];
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.leftMargin = x;
lp.topMargin = y;
view.setLayoutParams(lp);
return view;
}
private void
setAnim(final View v, int[] start_location){
anim_mask_layout = null;
anim_mask_layout = createAnimLayout();
anim_mask_layout.addView(v);// 把动画小球添加到动画层
final View view =
addViewToAnimLayout(anim_mask_layout, v,
start_location);
int[] end_location = new int[2];// 这是用来存储动画结束位置的X、Y坐标
ll.getLocationInWindow(end_location);// shopCart是那个购物车
// 缩放
Animation scaleAnimation =
new ScaleAnimation(0.3f, 0.1f, 0.6f, 0.1f);
// 设置动画时间
scaleAnimation.setDuration(10);
scaleAnimation
.setInterpolator(new LinearInterpolator());
scaleAnimation.setRepeatCount(0);// 动画重复执行的次数
scaleAnimation.setFillAfter(true);
// 旋转
Animation rotateAnimation =
new RotateAnimation(0f, 360f);
rotateAnimation.setRepeatCount(0);// 动画重复执行的次数
// 计算位移
int endX =
end_location[0] + 100 - start_location[0];// 动画位移的X坐标
int endY = end_location[1] - start_location[1];// 动画位移的y坐标
TranslateAnimation translateAnimationX =
new TranslateAnimation(0, endX, 0, 0);
translateAnimationX
.setInterpolator(new LinearInterpolator());
translateAnimationX.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);
TranslateAnimation translateAnimationY =
new TranslateAnimation(0, 0, 0, endY);
translateAnimationY
.setInterpolator(new AccelerateInterpolator());
translateAnimationY.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);
AnimationSet set = new AnimationSet(false);
set.setFillAfter(false);
set.addAnimation(scaleAnimation);
set.addAnimation(rotateAnimation);
set.addAnimation(translateAnimationY);
set.addAnimation(translateAnimationX);
set.setDuration(1000);// 动画的执行时间
view.startAnimation(set);
// 动画监听事件
set.setAnimationListener(new AnimationListener(){
// 动画的开始
@Override
public void
onAnimationStart(Animation animation){
v.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(
Animation animation){
// TODO Auto-generated method stub
}
// 动画的结束
@Override
public void onAnimationEnd(Animation animation){
v.setVisibility(View.GONE);
buyNum++;// 让购买数量加1
count.setText(buyNum + "");//
}
});
}
/* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
@Override
public void onClick(View v){
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.dish_order_main_slide_button:
dView.open();
break;
case R.id.dish_order_shopping_cart_ll:
double totalPrice = 0;
int totalCount = 0;
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("1 " + getCartList().get(i).getTitle());
System.out.println("1 " + getCartList().get(i).getItemCount());
double price = Double.valueOf(getCartList().get(i).getPrice());
totalPrice += price * getCartList().get(i).getItemCount();
totalCount += getCartList().get(i).getItemCount();
}
Intent intent = new Intent(DishOrderActivity.this, AddMenuActivity.class);
intent.putExtra("cartList", getCartList());
intent.putExtra("totalPrice", totalPrice);
intent.putExtra("totalCount", totalCount);
intent.putExtra("uid", uid);
intent.putExtra("title", title);
startActivityForResult(intent, 100);
break;
default:
break;
}
}
public ArrayList<ItemEntity> getCartList(){
return cartList;
}
public void setCartList(ArrayList<ItemEntity> cartList){
this.cartList = cartList;
}
private boolean isContains(String title){
boolean isIn = false;
if(getCartList().size() == 0){
isIn = false;
}else{
for(int i=0,j=getCartList().size();i<j;i++){
if(getCartList().get(i).getTitle().equals(title)){
isIn = true;
}else{
isIn = false;
}
}
}
return isIn;
}
/* (non-Javadoc)
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
*/
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data){
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch(resultCode){
case 1000:
setCartList((ArrayList<ItemEntity>) data.getExtras().getSerializable("cartList"));
buyNum = 0;
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("2 " + getCartList().get(i).getTitle());
System.out.println("2 " + getCartList().get(i).getItemCount());
buyNum += getCartList().get(i).getItemCount();
}
count.setText(buyNum + "");//
break;
default:
break;
}
}
}
|
GB18030
|
Java
| 25,831 |
java
|
DishOrderActivity.java
|
Java
|
[
{
"context": "r;\nimport android.widget.TextView;\n\n/**\n * @author Liming Chu\n * \n * @param\n * @return\n */\npublic class DishOrd",
"end": 2831,
"score": 0.9993768930435181,
"start": 2821,
"tag": "NAME",
"value": "Liming Chu"
}
] | null |
[] |
/**
*
*/
package com.main.baofang;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.chihuoshijian.R;
import com.chihuoshijian.view.DragSupportView;
import com.chihuoshijian.view.DragView;
import com.chihuoshijian.view.DragView.DragListener;
import com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter;
import com.chihuoshijian.view.PinnedHeaderListView;
import com.main.canting.CanTingDetailActivity;
import com.main.meishi.MeiShiCommentMain;
import com.model.ItemEntity;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.utils.StorageUtils;
import com.tools.Config;
import com.tools.Tools;
import android.R.integer;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.AbsListView.LayoutParams;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
/**
* @author <NAME>
*
* @param
* @return
*/
public class DishOrderActivity extends Activity implements OnClickListener{
private ProgressDialog progressDialog;
private ArrayList<ItemEntity> list;
private ArrayList<ItemEntity> sortList;
private PinnedHeaderListView listView;
private ImageView slide;
private LinearLayout ll;
private TextView count;
private DragView dView;
private DragSupportView dsView;
private RelativeLayout midRL;
private RelativeLayout dsoMain;
private RelativeLayout leftMenu;
private ListView leftLV;
// 生成测试菜单选项数据
private List<Map<String, String>> leftData;
private String uid;
private ViewGroup anim_mask_layout; // 动画层
private ImageView buyImg; // 这是在界面上跑的小图片
private int buyNum = 0; // 购买数量
private ArrayList<ItemEntity> cartList;
private String title;
/*
* (non-Javadoc)
*
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState){
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.dish_order_slding_menu_main);
prepareView();
/**
* 如果需要在别的Activity界面中也实现侧滑菜单效果,需要在布局中引入DragLayout(同本Activity方式),
* 然后在onCreate中声明使用; Activity界面部分,需要包裹在MyRelativeLayout中.
*/
dView.setDragListener(new DragListener(){// 动作监听
@Override
public void onOpen(){
}
@Override
public void onClose(){
}
@Override
public void onDrag(float percent){
}
});
uid = getIntent().getStringExtra("uid");
title = getIntent().getExtras().getString("title");
new ListAsync().execute(uid);
cartList = new ArrayList<ItemEntity>();
}
private void prepareView(){
dView =
(DragView) findViewById(R.id.dish_order_dragview);
dsView =
(DragSupportView) findViewById(R.id.dish_order_dragsupport);
midRL =
(RelativeLayout) findViewById(R.id.dish_order_middle);
dsoMain =
(RelativeLayout) midRL
.findViewById(R.id.dish_order_main);
listView =
(PinnedHeaderListView) dsoMain
.findViewById(R.id.dish_order_pinned_list_view);
slide =
(ImageView) dsoMain
.findViewById(R.id.dish_order_main_slide_button);
ll =
(LinearLayout) dsoMain
.findViewById(R.id.dish_order_shopping_cart_ll);
count =
(TextView) dsoMain
.findViewById(R.id.dish_order_shopping_cart_count);
leftMenu =
(RelativeLayout) findViewById(R.id.dish_order_left);
leftLV =
(ListView) leftMenu
.findViewById(R.id.sliding_menu_leftmenu_lv);
LinearLayout _ll = new LinearLayout(this);
LayoutParams lp =
new LayoutParams(LayoutParams.MATCH_PARENT,
180);
_ll.setLayoutParams(lp);
listView.addFooterView(_ll);
slide.setOnClickListener(this);
ll.setOnClickListener(this);
}
private Handler handler = new Handler(){
@Override
public
void
handleMessage(
Message msg){
// TODO Auto-generated method stub
super.handleMessage(msg);
Log.e("handler",
"handl msg");
// * 创建新的HeaderView,即置顶的HeaderView
View HeaderView =
getLayoutInflater()
.inflate(
R.layout.pinned_list_view_header,
listView,
false);
listView.setPinnedHeader(HeaderView);
PinnedListAdapter adapter =
new PinnedListAdapter(
DishOrderActivity.this,
list);
listView.setAdapter(adapter);
listView.setOnScrollListener(adapter);
listView.setOnItemClickListener(new OnItemClickListener(){
@Override
public
void
onItemClick(
AdapterView<?> parent,
View view,
int position,
long id){
// TODO Auto-generated method
// stub
Intent intent =
new Intent(
DishOrderActivity.this,
MeiShiCommentMain.class);
intent.putExtra(
"id",
list.get(
position)
.getId());
intent.putExtra(
"uid",
uid);
startActivity(intent);
}
});
}
};
class ListAsync extends AsyncTask<Object, Void, String>{
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPreExecute()
*/
@Override
protected void onPreExecute(){
// TODO Auto-generated method stub
super.onPreExecute();
progressDialog =
ProgressDialog.show(
DishOrderActivity.this, null,
null);
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#doInBackground(Params[])
*/
@Override
protected String doInBackground(Object... params){
// TODO Auto-generated method stub
Log.e("url", Config.DISH_ORDER_LIST_URL
+ params[0]);
String data =
new Tools()
.getURL(Config.DISH_ORDER_LIST_URL
+ params[0]);
String code = "";
list = new ArrayList<ItemEntity>();
leftData = new ArrayList<Map<String, String>>();
try{
JSONObject job = new JSONObject(data);
code = job.getString("code");
if(code.equals("1")){
JSONArray jArray =
job.getJSONArray("result1");
for(int i = 0,j = jArray.length();i < j;i++){
JSONObject job1 =
jArray.optJSONObject(i);
String classname =
job1.getString("classname");
JSONArray jArray2 =
job1.getJSONArray("next");
HashMap<String, String> nameMap =
new HashMap<String, String>();
nameMap.put("item", classname);
leftData.add(nameMap);
for(int m = 0,n = jArray2.length();m < n;m++){
JSONObject job2 =
jArray2.optJSONObject(m);
String pf =
job2.getString("pf");
float rate = 0;
if(pf.equals("false")){
rate = 0;
Log.e("pf", pf);
}else{
rate = Float.valueOf(pf);
}
ItemEntity item =
new ItemEntity(
classname,
job2.getString("id"),
job2.getString("n_title"),
job2.getString("n_dj"),
rate,
job2.getString("n_pic"),
1);
list.add(item);
}
}
}
}catch(JSONException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
return code;
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPostExecute(java.lang.Object)
*/
@Override
protected void onPostExecute(String result){
// TODO Auto-generated method stub
super.onPostExecute(result);
progressDialog.dismiss();
if(result.equals("1")){
Message msg = handler.obtainMessage();
handler.sendMessage(msg);
}
leftLV.setAdapter(new SimpleAdapter(
DishOrderActivity.this,
leftData,
R.layout.sliding_menu_menulist_item_text,
new String[] { "item" },
new int[] { R.id.menu_text }));
leftLV.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(
AdapterView<?> parent, View view,
int position, long id){
// TODO Auto-generated method stub
String classname =
leftData.get(position).get(
"item");
sortList = new ArrayList<ItemEntity>();
for(int i = 0,j = list.size();i < j;i++){
if(!(list.get(i).getClassname()
.equals(classname))){
sortList.add(list.get(i));
}else{
sortList.add(0, list.get(i));
}
}
for(int i = 0,j = sortList.size();i < j;i++){
System.out.println(sortList.get(i)
.getClassname());
}
dView.close();
PinnedListAdapter adapter =
new PinnedListAdapter(
DishOrderActivity.this,
sortList);
listView.setAdapter(adapter);
listView.setOnScrollListener(adapter);
}
});
}
}
class PinnedListAdapter extends BaseAdapter implements
OnScrollListener, PinnedHeaderAdapter{
private ViewHolder vHolder = null;
private Context context;
private ArrayList<ItemEntity> list;
private LayoutInflater lInflater;
private DisplayImageOptions options;
public PinnedListAdapter(Context context,
ArrayList<ItemEntity> list){
super();
this.context = context;
this.list = list;
this.lInflater = LayoutInflater.from(context);
preperImageLoader();
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getCount()
*/
@Override
public int getCount(){
// TODO Auto-generated method stub
Log.e("size", "" + list.size());
return list.size();
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItem(int)
*/
@Override
public Object getItem(int position){
// TODO Auto-generated method stub
return list.get(position);
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItemId(int)
*/
@Override
public long getItemId(int position){
// TODO Auto-generated method stub
return position;
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@Override
public View getView(final int position, View convertView,
ViewGroup parent){
// TODO Auto-generated method stub
if(convertView == null){
convertView =
lInflater.inflate(
R.layout.pinned_listview_item,
null);
}
vHolder = new ViewHolder();
vHolder.pic =
(ImageView) convertView
.findViewById(R.id.pinned_list_item_pic);
vHolder.title =
(TextView) convertView
.findViewById(R.id.title);
vHolder.name =
(TextView) convertView
.findViewById(R.id.pinned_list_item_name);
vHolder.price =
(TextView) convertView
.findViewById(R.id.pinned_list_item_price);
vHolder.rb =
(RatingBar) convertView
.findViewById(R.id.pinned_list_item_ratingbar);
vHolder.rating =
(TextView) convertView
.findViewById(R.id.pinned_list_item_rating);
vHolder.order =
(TextView) convertView
.findViewById(R.id.pinned_list_item_order);
vHolder.rb.setClickable(false);
// 获取数据
final ItemEntity item = (ItemEntity) list.get(position);
ImageLoader.getInstance().displayImage(
Config.DOMAIN + item.getPicAddr(),
vHolder.pic);
vHolder.rb.setRating(item.getRate());
vHolder.title.setText(item.getClassname());
vHolder.name.setText(item.getTitle());
vHolder.price.setText(item.getPrice());
vHolder.rating.setText("" + item.getRate());
final String url =
Config.DOMAIN + item.getPicAddr();
vHolder.order
.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
// TODO Auto-generated method stub
int[] start_location =
new int[2];// 一个整型数组,用来存储按钮的在屏幕的X、Y坐标
v.getLocationInWindow(start_location);// 这是获取购买按钮的在屏幕的X、Y坐标(这也是动画开始的坐标)
buyImg = new ImageView(context);
ImageLoader
.getInstance()
.displayImage(url,
buyImg, options);
start_location[0] = 40;
start_location[1] -= 80;
setAnim(buyImg, start_location);// 开始执行动画
Log.e("position", ""+position);
Log.e("click", item.getTitle());
if(getCartList().contains(item)){
System.out
.println("contains");
getCartList().get(getCartList().indexOf(item)).setItemCount(getCartList().get(getCartList().indexOf(item)).getItemCount() + 1);
//item.setItemCount(item.getItemCount() + 1);
}else{
System.out
.println("not contains");
getCartList().add(item);
}
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("3 " + getCartList().get(i).getTitle());
System.out.println("3 " + getCartList().get(i).getItemCount());
}
}
});
if(needTitle(position)){
// 显示标题并设置内容
vHolder.title.setText(item.getClassname());
vHolder.title.setVisibility(View.VISIBLE);
}else{
// 内容项隐藏标题
vHolder.title.setVisibility(View.GONE);
}
return convertView;
}
/*
* (non-Javadoc)
*
* @see com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter#
* getPinnedHeaderState(int)
*/
@Override
public int getPinnedHeaderState(int position){
// TODO Auto-generated method stub
if(getCount() == 0 || position < 0){
return PinnedHeaderAdapter.PINNED_HEADER_GONE;
}
if(isMove(position) == true){
return PinnedHeaderAdapter.PINNED_HEADER_PUSHED_UP;
}
return PinnedHeaderAdapter.PINNED_HEADER_VISIBLE;
}
/*
* (non-Javadoc)
*
* @see com.chihuoshijian.view.PinnedHeaderListView.PinnedHeaderAdapter#
* configurePinnedHeader(android.view.View, int, int)
*/
@Override
public void configurePinnedHeader(View headerView,
int position, int alpaha){
// TODO Auto-generated method stub
// 设置标题的内容
ItemEntity itemEntity =
(ItemEntity) getItem(position);
String headerValue = itemEntity.getClassname();
Log.e("", "header = " + headerValue);
if(!TextUtils.isEmpty(headerValue)){
TextView headerTextView =
(TextView) headerView
.findViewById(R.id.header);
headerTextView.setText(headerValue);
}
}
/*
* (non-Javadoc)
*
* @see
* android.widget.AbsListView.OnScrollListener#onScrollStateChanged(
* android .widget.AbsListView, int)
*/
@Override
public void onScrollStateChanged(AbsListView view,
int scrollState){
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* android.widget.AbsListView.OnScrollListener#onScroll(android.widget.
* AbsListView, int, int, int)
*/
@Override
public void onScroll(AbsListView view,
int firstVisibleItem, int visibleItemCount,
int totalItemCount){
// TODO Auto-generated method stub
if(view instanceof PinnedHeaderListView){
((PinnedHeaderListView) view)
.controlPinnedHeader(firstVisibleItem);
}
}
// ===========================================================
// Methods
// ===========================================================
/**
* 判断是否需要显示标题
*
* @param position
* @return
*/
private boolean needTitle(int position){
// 第一个肯定是分类
if(position == 0){
return true;
}
// 异常处理
if(position < 0){
return false;
}
// 当前 // 上一个
ItemEntity currentEntity =
(ItemEntity) getItem(position);
ItemEntity previousEntity =
(ItemEntity) getItem(position - 1);
if(null == currentEntity
|| null == previousEntity){
return false;
}
String currentTitle =
currentEntity.getClassname();
String previousTitle =
previousEntity.getClassname();
if(null == previousTitle
|| null == currentTitle){
return false;
}
// 当前item分类名和上一个item分类名不同,则表示两item属于不同分类
if(currentTitle.equals(previousTitle)){
return false;
}
return true;
}
private boolean isMove(int position){
// 获取当前与下一项
ItemEntity currentEntity =
(ItemEntity) getItem(position);
ItemEntity nextEntity =
(ItemEntity) getItem(position + 1);
if(null == currentEntity || null == nextEntity){
return false;
}
// 获取两项header内容
String currentTitle =
currentEntity.getClassname();
String nextTitle = nextEntity.getClassname();
if(null == currentTitle || null == nextTitle){
return false;
}
// 当前不等于下一项header,当前项需要移动了
if(!currentTitle.equals(nextTitle)){
return true;
}
return false;
}
private void preperImageLoader(){
/******************* 配置ImageLoder ***********************************************/
File cacheDir =
StorageUtils.getOwnCacheDirectory(
context, "imageloader/Cache");
ImageLoaderConfiguration config =
new ImageLoaderConfiguration.Builder(
context)
.denyCacheImageMultipleSizesInMemory()
.discCache(
new UnlimitedDiscCache(
cacheDir))// 自定义缓存路径
.build();// 开始构建
options =
new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.imageScaleType(
ImageScaleType.IN_SAMPLE_INT)
.showImageForEmptyUri(
R.drawable.imageloader_default)
.showImageOnFail(R.drawable.imageloader_default)
.build();
ImageLoader.getInstance().init(config);// 全局初始化此配置
/*********************************************************************************/
}
class ViewHolder{
ImageView pic;
TextView title;
TextView name;
TextView price;
RatingBar rb;
TextView rating;
TextView order;
}
}
/**
* @Description: 创建动画层
* @param
* @return void
* @throws
*/
private ViewGroup createAnimLayout(){
ViewGroup rootView =
(ViewGroup) this.getWindow().getDecorView();
LinearLayout animLayout = new LinearLayout(this);
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
animLayout.setLayoutParams(lp);
animLayout.setId(Integer.MAX_VALUE);
animLayout
.setBackgroundResource(android.R.color.transparent);
rootView.addView(animLayout);
return animLayout;
}
private View addViewToAnimLayout(final ViewGroup vg,
final View view, int[] location){
int x = location[0];
int y = location[1];
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.leftMargin = x;
lp.topMargin = y;
view.setLayoutParams(lp);
return view;
}
private void
setAnim(final View v, int[] start_location){
anim_mask_layout = null;
anim_mask_layout = createAnimLayout();
anim_mask_layout.addView(v);// 把动画小球添加到动画层
final View view =
addViewToAnimLayout(anim_mask_layout, v,
start_location);
int[] end_location = new int[2];// 这是用来存储动画结束位置的X、Y坐标
ll.getLocationInWindow(end_location);// shopCart是那个购物车
// 缩放
Animation scaleAnimation =
new ScaleAnimation(0.3f, 0.1f, 0.6f, 0.1f);
// 设置动画时间
scaleAnimation.setDuration(10);
scaleAnimation
.setInterpolator(new LinearInterpolator());
scaleAnimation.setRepeatCount(0);// 动画重复执行的次数
scaleAnimation.setFillAfter(true);
// 旋转
Animation rotateAnimation =
new RotateAnimation(0f, 360f);
rotateAnimation.setRepeatCount(0);// 动画重复执行的次数
// 计算位移
int endX =
end_location[0] + 100 - start_location[0];// 动画位移的X坐标
int endY = end_location[1] - start_location[1];// 动画位移的y坐标
TranslateAnimation translateAnimationX =
new TranslateAnimation(0, endX, 0, 0);
translateAnimationX
.setInterpolator(new LinearInterpolator());
translateAnimationX.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);
TranslateAnimation translateAnimationY =
new TranslateAnimation(0, 0, 0, endY);
translateAnimationY
.setInterpolator(new AccelerateInterpolator());
translateAnimationY.setRepeatCount(0);// 动画重复执行的次数
translateAnimationX.setFillAfter(true);
AnimationSet set = new AnimationSet(false);
set.setFillAfter(false);
set.addAnimation(scaleAnimation);
set.addAnimation(rotateAnimation);
set.addAnimation(translateAnimationY);
set.addAnimation(translateAnimationX);
set.setDuration(1000);// 动画的执行时间
view.startAnimation(set);
// 动画监听事件
set.setAnimationListener(new AnimationListener(){
// 动画的开始
@Override
public void
onAnimationStart(Animation animation){
v.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(
Animation animation){
// TODO Auto-generated method stub
}
// 动画的结束
@Override
public void onAnimationEnd(Animation animation){
v.setVisibility(View.GONE);
buyNum++;// 让购买数量加1
count.setText(buyNum + "");//
}
});
}
/* (non-Javadoc)
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
@Override
public void onClick(View v){
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.dish_order_main_slide_button:
dView.open();
break;
case R.id.dish_order_shopping_cart_ll:
double totalPrice = 0;
int totalCount = 0;
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("1 " + getCartList().get(i).getTitle());
System.out.println("1 " + getCartList().get(i).getItemCount());
double price = Double.valueOf(getCartList().get(i).getPrice());
totalPrice += price * getCartList().get(i).getItemCount();
totalCount += getCartList().get(i).getItemCount();
}
Intent intent = new Intent(DishOrderActivity.this, AddMenuActivity.class);
intent.putExtra("cartList", getCartList());
intent.putExtra("totalPrice", totalPrice);
intent.putExtra("totalCount", totalCount);
intent.putExtra("uid", uid);
intent.putExtra("title", title);
startActivityForResult(intent, 100);
break;
default:
break;
}
}
public ArrayList<ItemEntity> getCartList(){
return cartList;
}
public void setCartList(ArrayList<ItemEntity> cartList){
this.cartList = cartList;
}
private boolean isContains(String title){
boolean isIn = false;
if(getCartList().size() == 0){
isIn = false;
}else{
for(int i=0,j=getCartList().size();i<j;i++){
if(getCartList().get(i).getTitle().equals(title)){
isIn = true;
}else{
isIn = false;
}
}
}
return isIn;
}
/* (non-Javadoc)
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
*/
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data){
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch(resultCode){
case 1000:
setCartList((ArrayList<ItemEntity>) data.getExtras().getSerializable("cartList"));
buyNum = 0;
for(int i=0,j=getCartList().size();i<j;i++){
System.out.println("2 " + getCartList().get(i).getTitle());
System.out.println("2 " + getCartList().get(i).getItemCount());
buyNum += getCartList().get(i).getItemCount();
}
count.setText(buyNum + "");//
break;
default:
break;
}
}
}
| 25,827 | 0.656856 | 0.652217 | 955 | 25.185341 | 18.941248 | 135 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.969634 | false | false |
13
|
3d00b36c119aeb4f265795847d155389d536248d
| 27,530,740,424,429 |
efe3be5bfdb14c2a742d8083d1aed2eac1946984
|
/al0ne/src/com/al0ne/Engine/Utility/GameChanges.java
|
4a9f0da0c011640ff55e5ae6f7309a34092e6a31
|
[] |
no_license
|
teh-BMW/al0ne
|
https://github.com/teh-BMW/al0ne
|
d77c578885f2c687a1620e588fbdcdb906b51561
|
4e327c5f3bf411eb0001ac9e14fed17a6c0e0b3e
|
refs/heads/master
| 2021-01-19T08:11:30.276000 | 2018-04-29T16:19:02 | 2018-04-29T16:19:02 | 56,603,377 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.al0ne.Engine.Utility;
import com.al0ne.AbstractEntities.*;
import com.al0ne.AbstractEntities.Pairs.Pair;
import com.al0ne.AbstractEntities.Player.Player;
import com.al0ne.AbstractEntities.Abstract.Enemy;
import com.al0ne.AbstractEntities.Abstract.Item;
import com.al0ne.ConcreteEntities.Items.ConcreteItems.Coin.MoneyContainer;
import com.al0ne.Engine.Editing.EditorInfo;
import com.al0ne.Engine.Game.Game;
import com.al0ne.Engine.Main;
import com.al0ne.Engine.UI.SimpleItem;
import com.al0ne.Engine.Game.WarpGame;
import com.al0ne.ConcreteEntities.Items.Types.Protective;
import com.al0ne.ConcreteEntities.Items.Types.Wearable.Weapon;
import com.al0ne.ConcreteEntities.Items.ConcreteItems.LightItem;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import static com.al0ne.Engine.Main.player;
import static com.al0ne.Engine.Main.printToLog;
/**
* Created by BMW on 13/04/2017.
*/
public class GameChanges {
public static void save(String s, String path, Object g, boolean game){
FileOutputStream fop = null;
ObjectOutputStream oos = null;
File file;
if(g instanceof Game){
((Game) g).setNotes(Main.notes.getText());
}
try {
if (path != null && game){
file = new File(path+".save");
} else if (game) {
file = new File("./"+s+".save");
} else if(path != null){
file = new File(path+".edtr");
} else{
file = new File("./"+s+".edtr");
}
fop = new FileOutputStream(file);
ByteArrayOutputStream arrayOut = new ByteArrayOutputStream();
oos = new ObjectOutputStream(arrayOut);
oos.writeObject(g);
fop.write(Base64.getEncoder().encode(arrayOut.toByteArray()));
// if file doesnt exists, then create it
if (!file.exists()) {
printToLog("File already exists. Specify a non existing file name.");
return;
}
oos.flush();
oos.close();
printToLog("Saving successful");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fop != null) {
try {
fop.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static boolean load(String s, String path, boolean game){
Object loaded = deserializeGame(s, path);
if (loaded == null){
printToLog("Failed to load the game.");
return false;
} else if(loaded instanceof Game && game){
Game loadedGame = (Game) loaded;
Main.game = loadedGame;
Main.player = loadedGame.getPlayer();
Main.turnCounter = loadedGame.getTurnCount();
Main.notes.setText(loadedGame.getNotes());
printToLog("Game loaded successfully.");
printToLog();
Room currentRoom = player.getCurrentRoom();
currentRoom.printRoom();
currentRoom.printName();
return true;
} else if(loaded instanceof EditorInfo && !game){
Main.edit = (EditorInfo) loaded;
return true;
} else {
System.out.println("error: file loaded not recognised");
return false;
}
}
public static Game loadAndGetGame(String s, String path){
Object loaded = deserializeGame(s, path);
if (loaded == null){
return null;
} else if(loaded instanceof Game){
return (Game) loaded;
} else {
return null;
}
}
private static Object deserializeGame(String filename, String path) {
Object read;
FileInputStream fin = null;
ObjectInputStream ois = null;
try {
String toUse;
if (path != null){
fin = new FileInputStream(path);
toUse = path;
} else{
fin = new FileInputStream(filename);
toUse = filename;
}
ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64.getDecoder().decode(
Files.readAllBytes(Paths.get(toUse))));
ois = new ObjectInputStream(arrayIn);
read = ois.readObject();
} catch (Exception ex) {
printToLog("File not found");
return null;
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if(read instanceof Game || read instanceof EditorInfo){
return read;
} else{
System.out.println("error loading file");
return null;
}
}
public static ObservableList<SimpleItem> getInventoryData(){
ObservableList<SimpleItem> data = FXCollections.observableArrayList();
if (Main.player.getInventory().size()==0){}
else {
for (Pair pair : Main.player.getInventory().values()) {
Item currentItem = (Item) pair.getEntity();
double weight = Utility.twoDecimals(currentItem.getWeight()*pair.getCount());
String id = currentItem.getID();
String name = currentItem.getName();
int damage = 0;
int defense = 0;
// if(Main.game.isInDebugMode()){
if (currentItem instanceof Protective){
defense = ((Protective) currentItem).getArmor();
damage = ((Protective) currentItem).getEncumberment();
// name=" ("+((Protective)currentItem).getArmor()+" DEF) "+"$"+currentItem.getPrice()+" "+name;
} else if (currentItem instanceof Weapon){
damage = ((Weapon) currentItem).getDamage();
defense = ((Weapon) currentItem).getArmorPenetration();
// name=" ("+((Weapon)currentItem).getDamage()+"DMG/ "+
// ((Weapon)currentItem).getArmorPenetration()+"AP) "+"$"+currentItem.getPrice()+" "+name;
}
// }
SimpleItem s = new SimpleItem(id, name, pair.getCount(), weight, currentItem.getPrice(),defense, damage);
data.add(s);
}
}
return data;
}
public static void restartGame(){
GameChanges.changeWorld(Main.game.getStartingWorld());
Main.input.setDisable(false);
Main.game = new WarpGame();
Main.player = Main.game.getPlayer();
// Main.currentRoom = Main.game.getRoom();
Main.log.setText("");
printToLog("Game restarted.");
printToLog();
Main.player.getCurrentRoom().printName();
Main.player.getCurrentRoom().printRoom();
}
public static Game copyGame(Game g){
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
ByteArrayOutputStream bos;
ByteArrayInputStream bis;
Game copy = null;
try {
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
oos.writeObject(g);
byte temp[] = bos.toByteArray();
bos.close();
oos.flush();
oos.close();
bis = new ByteArrayInputStream(temp);
ois = new ObjectInputStream(bis);
try{
copy = (Game) ois.readObject();
} catch (Exception ex){
System.out.println("CopyGame: object is not a game");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return copy;
}
// save("temp123", null, g, true);
// Game game = loadAndGetGame("temp123.save", null);
// Utility.removeFile("temp123.save");
//
// return game;
}
public static void changeWorld(int i){
//save old state
World oldWorld = Main.game.getCurrentWorld();
oldWorld.setPlayer(Main.player);
Main.game.setCurrentWorld(i);
Main.player = Main.game.getPlayer();
Main.clearScreen();
printToLog("Your see black and feel very cold for a moment, and suddenly you are somewhere else.");
printToLog();
player.getCurrentRoom().printRoom();
player.getCurrentRoom().visit();
}
public static void attackIfAggro(Player player){
Room currentRoom = player.getCurrentRoom();
if(currentRoom.hasEnemies()){
for (Enemy e : currentRoom.getEnemyList()){
if(e.isAggro() && !e.isSnooze()){
System.out.println(e.getName()+" attacks");
e.isAttacked(player, currentRoom);
} else{
if (e.isSnooze()){
e.setSnooze(false);
}
}
}
}
}
public static void consumeItems(Player player){
for(Item i: player.getWornItems().values()){
if(i instanceof LightItem && ((LightItem) i).isLit()){
if(Utility.randomGreaterThan(70)){
i.modifyIntegrity(-1);
}
if(((LightItem) i).removeOneCharge()){
((LightItem) i).setLit(false);
printToLog("The "+i.getName()+" stops emitting light.");
}
}
}
}
//we check if the player has at least amt money
public static boolean hasEnoughMoney(Player p, int amt){
return getMoney(p) >= amt;
}
//we return the money of the player
public static int getMoney(Player player){
MoneyContainer mc = player.getMoneyContainer();
if(mc != null){
return mc.getItems().get(0).getCount();
}
return 0;
}
//we remove amt money from the player
public static boolean removeAmountMoney(Player player, int amt){
if(!hasEnoughMoney(player, amt)){
return false;
}
MoneyContainer mc = player.getMoneyContainer();
if(mc != null){
if(mc.getItems().size() > 0){
mc.getItems().get(0).modifyCount(-amt);
return true;
}
}
return false;
}
}
|
UTF-8
|
Java
| 11,593 |
java
|
GameChanges.java
|
Java
|
[
{
"context": "m.al0ne.Engine.Main.printToLog;\n\n/**\n * Created by BMW on 13/04/2017.\n */\npublic class GameChanges {\n\n ",
"end": 1066,
"score": 0.998816967010498,
"start": 1063,
"tag": "USERNAME",
"value": "BMW"
}
] | null |
[] |
package com.al0ne.Engine.Utility;
import com.al0ne.AbstractEntities.*;
import com.al0ne.AbstractEntities.Pairs.Pair;
import com.al0ne.AbstractEntities.Player.Player;
import com.al0ne.AbstractEntities.Abstract.Enemy;
import com.al0ne.AbstractEntities.Abstract.Item;
import com.al0ne.ConcreteEntities.Items.ConcreteItems.Coin.MoneyContainer;
import com.al0ne.Engine.Editing.EditorInfo;
import com.al0ne.Engine.Game.Game;
import com.al0ne.Engine.Main;
import com.al0ne.Engine.UI.SimpleItem;
import com.al0ne.Engine.Game.WarpGame;
import com.al0ne.ConcreteEntities.Items.Types.Protective;
import com.al0ne.ConcreteEntities.Items.Types.Wearable.Weapon;
import com.al0ne.ConcreteEntities.Items.ConcreteItems.LightItem;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import static com.al0ne.Engine.Main.player;
import static com.al0ne.Engine.Main.printToLog;
/**
* Created by BMW on 13/04/2017.
*/
public class GameChanges {
public static void save(String s, String path, Object g, boolean game){
FileOutputStream fop = null;
ObjectOutputStream oos = null;
File file;
if(g instanceof Game){
((Game) g).setNotes(Main.notes.getText());
}
try {
if (path != null && game){
file = new File(path+".save");
} else if (game) {
file = new File("./"+s+".save");
} else if(path != null){
file = new File(path+".edtr");
} else{
file = new File("./"+s+".edtr");
}
fop = new FileOutputStream(file);
ByteArrayOutputStream arrayOut = new ByteArrayOutputStream();
oos = new ObjectOutputStream(arrayOut);
oos.writeObject(g);
fop.write(Base64.getEncoder().encode(arrayOut.toByteArray()));
// if file doesnt exists, then create it
if (!file.exists()) {
printToLog("File already exists. Specify a non existing file name.");
return;
}
oos.flush();
oos.close();
printToLog("Saving successful");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fop != null) {
try {
fop.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static boolean load(String s, String path, boolean game){
Object loaded = deserializeGame(s, path);
if (loaded == null){
printToLog("Failed to load the game.");
return false;
} else if(loaded instanceof Game && game){
Game loadedGame = (Game) loaded;
Main.game = loadedGame;
Main.player = loadedGame.getPlayer();
Main.turnCounter = loadedGame.getTurnCount();
Main.notes.setText(loadedGame.getNotes());
printToLog("Game loaded successfully.");
printToLog();
Room currentRoom = player.getCurrentRoom();
currentRoom.printRoom();
currentRoom.printName();
return true;
} else if(loaded instanceof EditorInfo && !game){
Main.edit = (EditorInfo) loaded;
return true;
} else {
System.out.println("error: file loaded not recognised");
return false;
}
}
public static Game loadAndGetGame(String s, String path){
Object loaded = deserializeGame(s, path);
if (loaded == null){
return null;
} else if(loaded instanceof Game){
return (Game) loaded;
} else {
return null;
}
}
private static Object deserializeGame(String filename, String path) {
Object read;
FileInputStream fin = null;
ObjectInputStream ois = null;
try {
String toUse;
if (path != null){
fin = new FileInputStream(path);
toUse = path;
} else{
fin = new FileInputStream(filename);
toUse = filename;
}
ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64.getDecoder().decode(
Files.readAllBytes(Paths.get(toUse))));
ois = new ObjectInputStream(arrayIn);
read = ois.readObject();
} catch (Exception ex) {
printToLog("File not found");
return null;
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if(read instanceof Game || read instanceof EditorInfo){
return read;
} else{
System.out.println("error loading file");
return null;
}
}
public static ObservableList<SimpleItem> getInventoryData(){
ObservableList<SimpleItem> data = FXCollections.observableArrayList();
if (Main.player.getInventory().size()==0){}
else {
for (Pair pair : Main.player.getInventory().values()) {
Item currentItem = (Item) pair.getEntity();
double weight = Utility.twoDecimals(currentItem.getWeight()*pair.getCount());
String id = currentItem.getID();
String name = currentItem.getName();
int damage = 0;
int defense = 0;
// if(Main.game.isInDebugMode()){
if (currentItem instanceof Protective){
defense = ((Protective) currentItem).getArmor();
damage = ((Protective) currentItem).getEncumberment();
// name=" ("+((Protective)currentItem).getArmor()+" DEF) "+"$"+currentItem.getPrice()+" "+name;
} else if (currentItem instanceof Weapon){
damage = ((Weapon) currentItem).getDamage();
defense = ((Weapon) currentItem).getArmorPenetration();
// name=" ("+((Weapon)currentItem).getDamage()+"DMG/ "+
// ((Weapon)currentItem).getArmorPenetration()+"AP) "+"$"+currentItem.getPrice()+" "+name;
}
// }
SimpleItem s = new SimpleItem(id, name, pair.getCount(), weight, currentItem.getPrice(),defense, damage);
data.add(s);
}
}
return data;
}
public static void restartGame(){
GameChanges.changeWorld(Main.game.getStartingWorld());
Main.input.setDisable(false);
Main.game = new WarpGame();
Main.player = Main.game.getPlayer();
// Main.currentRoom = Main.game.getRoom();
Main.log.setText("");
printToLog("Game restarted.");
printToLog();
Main.player.getCurrentRoom().printName();
Main.player.getCurrentRoom().printRoom();
}
public static Game copyGame(Game g){
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
ByteArrayOutputStream bos;
ByteArrayInputStream bis;
Game copy = null;
try {
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
oos.writeObject(g);
byte temp[] = bos.toByteArray();
bos.close();
oos.flush();
oos.close();
bis = new ByteArrayInputStream(temp);
ois = new ObjectInputStream(bis);
try{
copy = (Game) ois.readObject();
} catch (Exception ex){
System.out.println("CopyGame: object is not a game");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (oos != null) {
try {
oos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return copy;
}
// save("temp123", null, g, true);
// Game game = loadAndGetGame("temp123.save", null);
// Utility.removeFile("temp123.save");
//
// return game;
}
public static void changeWorld(int i){
//save old state
World oldWorld = Main.game.getCurrentWorld();
oldWorld.setPlayer(Main.player);
Main.game.setCurrentWorld(i);
Main.player = Main.game.getPlayer();
Main.clearScreen();
printToLog("Your see black and feel very cold for a moment, and suddenly you are somewhere else.");
printToLog();
player.getCurrentRoom().printRoom();
player.getCurrentRoom().visit();
}
public static void attackIfAggro(Player player){
Room currentRoom = player.getCurrentRoom();
if(currentRoom.hasEnemies()){
for (Enemy e : currentRoom.getEnemyList()){
if(e.isAggro() && !e.isSnooze()){
System.out.println(e.getName()+" attacks");
e.isAttacked(player, currentRoom);
} else{
if (e.isSnooze()){
e.setSnooze(false);
}
}
}
}
}
public static void consumeItems(Player player){
for(Item i: player.getWornItems().values()){
if(i instanceof LightItem && ((LightItem) i).isLit()){
if(Utility.randomGreaterThan(70)){
i.modifyIntegrity(-1);
}
if(((LightItem) i).removeOneCharge()){
((LightItem) i).setLit(false);
printToLog("The "+i.getName()+" stops emitting light.");
}
}
}
}
//we check if the player has at least amt money
public static boolean hasEnoughMoney(Player p, int amt){
return getMoney(p) >= amt;
}
//we return the money of the player
public static int getMoney(Player player){
MoneyContainer mc = player.getMoneyContainer();
if(mc != null){
return mc.getItems().get(0).getCount();
}
return 0;
}
//we remove amt money from the player
public static boolean removeAmountMoney(Player player, int amt){
if(!hasEnoughMoney(player, amt)){
return false;
}
MoneyContainer mc = player.getMoneyContainer();
if(mc != null){
if(mc.getItems().size() > 0){
mc.getItems().get(0).modifyCount(-amt);
return true;
}
}
return false;
}
}
| 11,593 | 0.521263 | 0.51695 | 388 | 28.878866 | 23.542751 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false |
13
|
f957cadb6221b58cd7bdefd417f6e44862bd085a
| 37,177,236,935,230 |
1bcc50283f96c98ddb684856d2d9abfd5860c54e
|
/src/controlador/ControladorMenu.java
|
0e182f0db9003e38e6c51b03bffbdd013c2d7753
|
[] |
no_license
|
key0202/integrador_proyecto1
|
https://github.com/key0202/integrador_proyecto1
|
d2690aa444eeaae62595800a12394a5b365ddec4
|
fd77b3a56d0d029c4b07755ccb9fee2417be2748
|
refs/heads/master
| 2022-11-01T15:07:11.520000 | 2020-06-13T17:03:27 | 2020-06-13T17:03:27 | 268,121,304 | 0 | 0 | null | false | 2020-06-13T17:03:29 | 2020-05-30T16:48:31 | 2020-06-13T08:43:39 | 2020-06-13T17:03:28 | 392 | 0 | 0 | 0 |
Java
| false | false |
package controlador;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.JOptionPane;
import modelo.dao.DaoAlumno;
import modelo.dao.DaoAsistencia;
import modelo.dao.DaoMateria;
import modelo.dao.DaoNotas;
import modelo.dao.impl.DaoAlumnoImpl;
import modelo.dao.impl.DaoAsistenciaImpl;
import modelo.dao.impl.DaoMateriaImpl;
import modelo.dao.impl.DaoNotasImpl;
import vista.Login;
import vista.MenuPrincipal;
import vista.Registro_Alumno;
import vista.Registro_Asistencia;
import vista.Registro_Materia;
import vista.Registro_Nota;
public class ControladorMenu implements ActionListener {
//jframe de este controlador
MenuPrincipal menuPrincipal = new MenuPrincipal();
//jframes a los que se dirigira
Registro_Materia registroMateria = new Registro_Materia();
Registro_Alumno registroAlumno = new Registro_Alumno();
Registro_Asistencia registroAsistencia = new Registro_Asistencia();
Registro_Nota registroNota = new Registro_Nota();
//Dao de los jframes
DaoMateria daoMateria = new DaoMateriaImpl();
DaoAlumno daoAlumno = new DaoAlumnoImpl();
DaoAsistencia daoAsistencia = new DaoAsistenciaImpl();
DaoNotas daoNota = new DaoNotasImpl();
//obtenemos nombre de usuario del logins
String docente = Controlador.docente;
//direccion donde se crearan los archivos txt
public static String username = "DAVID";
public static String destino = "Desktop"; // Desktop, Documents, etc
public static String direccion = "C:/Users/" + username + "/" + destino + "/TeachTools_";
public ControladorMenu(MenuPrincipal menuPrincipal) {
this.menuPrincipal = menuPrincipal;
eventos();
datosDocente();
}
//Eventos de los botones del frame Menu Principal
public void eventos(){
this.menuPrincipal.btnRegistrarMateria.addActionListener(this);
this.menuPrincipal.btnRegistrarAlumno.addActionListener(this);
this.menuPrincipal.btnRegistrarAsistencia.addActionListener(this);
this.menuPrincipal.btnRegistrarNotas.addActionListener(this);
//Evento MouseClick
this.menuPrincipal.menuItemCerrarSesion.addActionListener(this);
}
//datos del docente
public void datosDocente() {
menuPrincipal.txtNombreProfesor.setText(Controlador.docente);
menuPrincipal.txtNombreProfesor1.setText(Controlador.apellido);
menuPrincipal.txtdniProfesor.setText(Controlador.DNI);
menuPrincipal.txtUsuario.setText(Controlador.user);
}
@Override
public void actionPerformed(ActionEvent e) {
//Boton Registrar MATERIA del Menu Principal
if (e.getSource() == menuPrincipal.btnRegistrarMateria) {
//llamamos al controlador del jframe al que nos dirigimos
ControladorMateria ctrlMateria = new ControladorMateria(registroMateria, daoMateria);
ctrlMateria.iniciar();
menuPrincipal.dispose();
}
//Boton Registrar ALUMNO del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarAlumno) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
//llamamos al controlador del jframe al que nos dirigimos
//JOptionPane.showMessageDialog(null, "Registrar alumno");
ControladorAlumno ctrlAlumno = new ControladorAlumno(registroAlumno, daoAlumno);
ctrlAlumno.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//Boton Registrar ASISTENCIA del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarAsistencia) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
//llamamos al controlador del jframe al que nos dirigimos
ControladorAsistencia ctrlAsistencia = new ControladorAsistencia(daoAsistencia, registroAsistencia);
ctrlAsistencia.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//Boton Registrar NOTAS del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarNotas) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
ControladorNotas ctrlNotas = new ControladorNotas(daoNota, registroNota);
ctrlNotas.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//BOTON PARA CERRAR SESIÓN Y VISUALIZAR EL LOGIN
if(e.getSource()== menuPrincipal.menuItemCerrarSesion){
//menuPrincipal.dispose();
System.exit(0);
// Login login = new Login();
//login.setVisible(true);
}
}
/*
@Override
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()==1){
menuPrincipal.dispose();
System.out.println("menu");
}
}
@Override
public void mousePressed(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseReleased(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseEntered(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseExited(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}*/
}
|
UTF-8
|
Java
| 6,088 |
java
|
ControladorMenu.java
|
Java
|
[
{
"context": "archivos txt\n public static String username = \"DAVID\";\n public static String destino = \"Desktop\"; /",
"end": 1511,
"score": 0.9996030926704407,
"start": 1506,
"tag": "USERNAME",
"value": "DAVID"
}
] | null |
[] |
package controlador;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import javax.swing.JOptionPane;
import modelo.dao.DaoAlumno;
import modelo.dao.DaoAsistencia;
import modelo.dao.DaoMateria;
import modelo.dao.DaoNotas;
import modelo.dao.impl.DaoAlumnoImpl;
import modelo.dao.impl.DaoAsistenciaImpl;
import modelo.dao.impl.DaoMateriaImpl;
import modelo.dao.impl.DaoNotasImpl;
import vista.Login;
import vista.MenuPrincipal;
import vista.Registro_Alumno;
import vista.Registro_Asistencia;
import vista.Registro_Materia;
import vista.Registro_Nota;
public class ControladorMenu implements ActionListener {
//jframe de este controlador
MenuPrincipal menuPrincipal = new MenuPrincipal();
//jframes a los que se dirigira
Registro_Materia registroMateria = new Registro_Materia();
Registro_Alumno registroAlumno = new Registro_Alumno();
Registro_Asistencia registroAsistencia = new Registro_Asistencia();
Registro_Nota registroNota = new Registro_Nota();
//Dao de los jframes
DaoMateria daoMateria = new DaoMateriaImpl();
DaoAlumno daoAlumno = new DaoAlumnoImpl();
DaoAsistencia daoAsistencia = new DaoAsistenciaImpl();
DaoNotas daoNota = new DaoNotasImpl();
//obtenemos nombre de usuario del logins
String docente = Controlador.docente;
//direccion donde se crearan los archivos txt
public static String username = "DAVID";
public static String destino = "Desktop"; // Desktop, Documents, etc
public static String direccion = "C:/Users/" + username + "/" + destino + "/TeachTools_";
public ControladorMenu(MenuPrincipal menuPrincipal) {
this.menuPrincipal = menuPrincipal;
eventos();
datosDocente();
}
//Eventos de los botones del frame Menu Principal
public void eventos(){
this.menuPrincipal.btnRegistrarMateria.addActionListener(this);
this.menuPrincipal.btnRegistrarAlumno.addActionListener(this);
this.menuPrincipal.btnRegistrarAsistencia.addActionListener(this);
this.menuPrincipal.btnRegistrarNotas.addActionListener(this);
//Evento MouseClick
this.menuPrincipal.menuItemCerrarSesion.addActionListener(this);
}
//datos del docente
public void datosDocente() {
menuPrincipal.txtNombreProfesor.setText(Controlador.docente);
menuPrincipal.txtNombreProfesor1.setText(Controlador.apellido);
menuPrincipal.txtdniProfesor.setText(Controlador.DNI);
menuPrincipal.txtUsuario.setText(Controlador.user);
}
@Override
public void actionPerformed(ActionEvent e) {
//Boton Registrar MATERIA del Menu Principal
if (e.getSource() == menuPrincipal.btnRegistrarMateria) {
//llamamos al controlador del jframe al que nos dirigimos
ControladorMateria ctrlMateria = new ControladorMateria(registroMateria, daoMateria);
ctrlMateria.iniciar();
menuPrincipal.dispose();
}
//Boton Registrar ALUMNO del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarAlumno) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
//llamamos al controlador del jframe al que nos dirigimos
//JOptionPane.showMessageDialog(null, "Registrar alumno");
ControladorAlumno ctrlAlumno = new ControladorAlumno(registroAlumno, daoAlumno);
ctrlAlumno.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//Boton Registrar ASISTENCIA del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarAsistencia) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
//llamamos al controlador del jframe al que nos dirigimos
ControladorAsistencia ctrlAsistencia = new ControladorAsistencia(daoAsistencia, registroAsistencia);
ctrlAsistencia.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//Boton Registrar NOTAS del Menu principal
if (e.getSource() == menuPrincipal.btnRegistrarNotas) {
File directorio = new File(direccion + docente);
if (directorio.exists()) {
ControladorNotas ctrlNotas = new ControladorNotas(daoNota, registroNota);
ctrlNotas.iniciar();
menuPrincipal.dispose();
} else {
JOptionPane.showMessageDialog(null, "Primero se debe registrar las materias " + docente);
}
}
//BOTON PARA CERRAR SESIÓN Y VISUALIZAR EL LOGIN
if(e.getSource()== menuPrincipal.menuItemCerrarSesion){
//menuPrincipal.dispose();
System.exit(0);
// Login login = new Login();
//login.setVisible(true);
}
}
/*
@Override
public void mouseClicked(MouseEvent e) {
if(e.getClickCount()==1){
menuPrincipal.dispose();
System.out.println("menu");
}
}
@Override
public void mousePressed(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseReleased(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseEntered(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
@Override
public void mouseExited(MouseEvent e) {
//To change body of generated methods, choose Tools | Templates.
}*/
}
| 6,088 | 0.65681 | 0.656317 | 168 | 35.232143 | 27.248411 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529762 | false | false |
13
|
e356209c6f4d5592af9556660cdd930d3a9e3639
| 25,761,213,893,856 |
e10bbfc26434d3aeea13890bca20d2fe3cfbba29
|
/app/src/main/java/com/horen/horenbase/bean/NavigationTag.java
|
fd4c9b6fdced172ee06671f0f991ffdb4ced9ace
|
[] |
no_license
|
barry-ran/Live-1
|
https://github.com/barry-ran/Live-1
|
b7c723a6fbea79adbdfe9ba45d762f55e412343b
|
fc30bda5f1f592ee027920ceb2bb663bef8e7bab
|
refs/heads/master
| 2021-10-08T05:08:06.498000 | 2018-07-17T03:58:33 | 2018-07-17T03:58:33 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.horen.horenbase.bean;
import com.mcxtzhang.indexlib.IndexBar.bean.BaseIndexPinyinBean;
import java.util.List;
/**
* @author :ChenYangYi
* @date :2018/07/04/16:56
* @description :
* @github :https://github.com/chenyy0708
*/
public class NavigationTag extends BaseIndexPinyinBean {
/**
* count : 1
* items : [{"id":176,"name":"asia pacific","type":0}]
*/
private String tagName;
private int count;
private List<ItemsBean> items;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public List<ItemsBean> getItems() {
return items;
}
public void setItems(List<ItemsBean> items) {
this.items = items;
}
public String getTagName() {
return tagName;
}
public NavigationTag setTagName(String tagName) {
this.tagName = tagName;
return this;
}
@Override
public String getTarget() {
return tagName;
}
public static class ItemsBean {
/**
* id : 176
* name : asia pacific
* type : 0
*/
private int id;
private String name;
private int type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
}
|
UTF-8
|
Java
| 1,677 |
java
|
NavigationTag.java
|
Java
|
[
{
"context": "yinBean;\n\nimport java.util.List;\n\n/**\n * @author :ChenYangYi\n * @date :2018/07/04/16:56\n * @description :\n * @",
"end": 151,
"score": 0.9998550415039062,
"start": 141,
"tag": "NAME",
"value": "ChenYangYi"
},
{
"context": "\n * @description :\n * @github :https://github.com/chenyy0708\n */\npublic class NavigationTag extends BaseIndexP",
"end": 238,
"score": 0.9993098378181458,
"start": 228,
"tag": "USERNAME",
"value": "chenyy0708"
}
] | null |
[] |
package com.horen.horenbase.bean;
import com.mcxtzhang.indexlib.IndexBar.bean.BaseIndexPinyinBean;
import java.util.List;
/**
* @author :ChenYangYi
* @date :2018/07/04/16:56
* @description :
* @github :https://github.com/chenyy0708
*/
public class NavigationTag extends BaseIndexPinyinBean {
/**
* count : 1
* items : [{"id":176,"name":"asia pacific","type":0}]
*/
private String tagName;
private int count;
private List<ItemsBean> items;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public List<ItemsBean> getItems() {
return items;
}
public void setItems(List<ItemsBean> items) {
this.items = items;
}
public String getTagName() {
return tagName;
}
public NavigationTag setTagName(String tagName) {
this.tagName = tagName;
return this;
}
@Override
public String getTarget() {
return tagName;
}
public static class ItemsBean {
/**
* id : 176
* name : asia pacific
* type : 0
*/
private int id;
private String name;
private int type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}
}
| 1,677 | 0.536076 | 0.521169 | 89 | 17.842697 | 15.860274 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.280899 | false | false |
13
|
b448483ec73787068ea1d60be58f35f3f83e96cd
| 38,250,978,750,565 |
18bd0c0edc7fff52c614a2d30688a05bbbfcd2f8
|
/src/humanResources/LinkedList.java
|
38d4e23ba4a985dae2caf9abb6486e98bed0f8fe
|
[] |
no_license
|
DrewTrue/Lab5
|
https://github.com/DrewTrue/Lab5
|
eae746a18c48be074636fe7da726907463dd93d7
|
b52f9f4e99d15ed504e1792dd79896dd566ea501
|
refs/heads/master
| 2020-03-16T09:11:41.402000 | 2018-05-09T14:55:31 | 2018-05-09T14:55:31 | 132,610,907 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package humanResources;
import java.util.*;
public class LinkedList<T>{
private Node<T> head;
private Node<T> tail;
private int size;
public Node<T> getHead(){
return head;
}
public Node<T> getTail(){
return tail;
}
public boolean addNodeList(T value){
Node<T> node = new Node<>(value);
if(head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
return true;
}
//bullshit method
public boolean addNodeList(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if(!isEmpty()) {
if (index == 0) { // if node is in the beginning
currentNode = head;
head = nodeValue;
head.setNext(currentNode);
size++;
return true;
}
if (index == size - 1) { // if node is in the end
currentNode = tail;
tail = nodeValue;
return addNodeList(value);
}
} else {
return addNodeList(value);
}
while(node != null) {
if(counter == index){ // if node is in the middle
currentNode = node;
node = nodeValue;
node.setNext(currentNode);
}
counter++;
node = node.getNext();
}
if(counter > size){
size = counter;
return true;
}
return false;
}
public boolean addAllEmployees(Collection<? extends Employee> c) {
Employee[] employeesCollection = (Employee[]) c.toArray();
Node<T> node;
Employee[] employees = getEmployees();
int counter = 0;
for (int j = 0; j < employeesCollection.length; j++) {
node = new Node<>((T) employeesCollection[j]);
if (head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
counter++;
}
return counter > 0;
}
public boolean addAllGroups(Collection<? extends EmployeeGroup> c) {
EmployeeGroup[] groupsCollection = (EmployeeGroup[]) c.toArray();
Node<T> node;
EmployeeGroup[] groups = getGroups();
int counter = 0;
for (int j = 0; j < groupsCollection.length; j++) {
node = new Node<>((T) groupsCollection[j]);
if (head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
counter++;
}
return counter > 0;
}
//bullshit method x2
public boolean addAllEmployees(int index, Collection<? extends Employee> c) {
Employee[] employeesCollection = (Employee[]) c.toArray();
Employee[] employees = getEmployees();
boolean isAddAll1 = false;
boolean isAddAll2 = false;
boolean isAddAll3 = false;
clearList();
for(int i = 0; i < index; i++){
isAddAll1 = addNodeList((T) employees[i]);
}
for (Employee anEmployeesCollection : employeesCollection) {
isAddAll2 = addNodeList((T) anEmployeesCollection);
}
for(int i = index; i < employees.length; i++){
isAddAll3 = addNodeList((T)employees[i]);
}
return isAddAll1 && isAddAll2 && isAddAll3;
}
public boolean addAllGroups(int index, Collection<? extends EmployeeGroup> c) {
EmployeeGroup[] groupsCollection = (EmployeeGroup[]) c.toArray();
EmployeeGroup[] groups = getGroups();
boolean isAddAll1 = false;
boolean isAddAll2 = false;
boolean isAddAll3 = false;
clearList();
for(int i = 0; i < index; i++){
isAddAll1 = addNodeList((T) groups[i]);
}
for (EmployeeGroup group : groupsCollection) {
isAddAll2 = addNodeList((T) group);
}
for(int i = index; i < groups.length; i++){
isAddAll3 = addNodeList((T)groups[i]);
}
return isAddAll1 && isAddAll2 && isAddAll3;
}
public EmployeeGroup setGroup(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if (index == 0) { // if node is in the beginning
head = nodeValue;
return (EmployeeGroup) head.getValue();
}
if(index == size - 1){ // if node is in the end
tail = nodeValue;
return (EmployeeGroup) tail.getValue();
}
while(node != null) {
if(counter == index){ // if node is in the middle
node = nodeValue;
return (EmployeeGroup) node.getValue();
}
counter++;
node = node.getNext();
}
return null;
}
public Employee setEmployee(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if (index == 0) { // if node is in the beginning
head = nodeValue;
return (Employee) head.getValue();
}
if(index == size - 1){ // if node is in the end
tail = nodeValue;
return (Employee) tail.getValue();
}
while(node != null) {
if(counter == index){ // if node is in the middle
node = nodeValue;
return (Employee) node.getValue();
}
counter++;
node = node.getNext();
}
return null;
}
public boolean retainAllEmployees(Collection<?> c) {
Employee[] retainEmployees = (Employee[]) c.toArray();
Employee[] currentEmployees = getEmployees();
int counter = 0;
clearList();
for(int i = 0; i < currentEmployees.length; i++) {
for (int j = 0; j < retainEmployees.length; j++) {
if (currentEmployees[i].equals(retainEmployees[j])) {
addNodeList((T) retainEmployees[j]);
counter++;
}
}
}
return counter <= 0;
}
public boolean retainAllGroups(Collection<?> c) {
EmployeeGroup[] retainGroups = (EmployeeGroup[]) c.toArray();
EmployeeGroup[] currentGroups = getGroups();
int counter = 0;
clearList();
for(int i = 0; i < currentGroups.length; i++) {
for (int j = 0; j < retainGroups.length; j++) {
if (currentGroups[i].equals(retainGroups[j])) {
addNodeList((T) retainGroups[j]);
counter++;
}
}
}
return counter <= 0;
}
public boolean removeNode(T value){
Node<T> current = head;
Node<T> previous = null;
while(current != null){
if(current.getValue().equals(value)){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
return true;
}
previous = current;
current = current.getNext();
}
return false;
}
public EmployeeGroup removeGroup(int index){
EmployeeGroup[] employeeGroups = getGroups();
for(int i = 0; i < size; i++){
if(index == i){
removeNode((T) employeeGroups[i]);
return employeeGroups[i];
}
}
return null;
}
public Employee removeEmployee(int index){
Employee[] employees = getEmployees();
for(int i = 0; i < size; i++){
if(index == i){
removeNode((T) employees[i]);
return employees[i];
}
}
return null;
}
public boolean removeAllEmployees(Collection<?> c) {
Node<T> current = head;
Node<T> previous = null;
int counter = 0;
Employee[] employeesCollection = (Employee[]) c.toArray();
for(int i = 0; i < employeesCollection.length; i++){
while(current != null){
if(current.getValue().equals(employeesCollection[i])){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
counter++;
break;
}
previous = current;
current = current.getNext();
}
}
return counter > 0;
}
public boolean removeAllGroups(Collection<?> c) {
Node<T> current = head;
Node<T> previous = null;
int counter = 0;
EmployeeGroup[] groups = (EmployeeGroup[]) c.toArray();
for(int i = 0; i < groups.length; i++){
while(current != null){
if(current.getValue().equals(groups[i])){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
counter++;
break;
}
previous = current;
current = current.getNext();
}
}
return counter > 0;
}
public int getSize() {
return size;
}
public boolean isEmpty(){
return size == 0;
}
public void clearList(){
head = null;
tail = null;
size = 0;
}
public boolean contains(T value){
Node<T> current = head;
while(current != null){
if(current.getValue().equals(value))
return true;
current = current.getNext();
}
return false;
}
public boolean containsAllEmployees(Collection<?> c){
Employee[] employeesCollection = (Employee[]) c.toArray();
Node<T> current = head;
int counter = 0;
for(int i = 0; i < employeesCollection.length; i++) {
while (current != null) {
if (current.getValue().equals(employeesCollection[i])){
counter++;
break;
}
current = current.getNext();
}
}
return counter == employeesCollection.length;
}
public boolean containsAllGroups(Collection<?> c){
EmployeeGroup[] groups = (EmployeeGroup[]) c.toArray();
Node<T> current = head;
int counter = 0;
for(int i = 0; i < groups.length; i++) {
while (current != null) {
if (current.getValue().equals(groups[i])){
counter++;
break;
}
current = current.getNext();
}
}
return counter == groups.length;
}
public Employee[] getEmployees(){
Employee[] employee = new Employee[size];
Node node = head;
int counter = 0;
while(node != null){
employee[counter] = (Employee) node.getValue();
node = node.getNext();
counter++;
}
return employee;
}
public EmployeeGroup[] getGroups(){
EmployeeGroup[] employeeGroups = new EmployeeGroup[size];
Node node = head;
int counter = 0;
while(node != null){
employeeGroups[counter] = (EmployeeGroup) node.getValue();
node = node.getNext();
counter++;
}
return employeeGroups;
}
public BusinessTravel[] getTravels(){
BusinessTravel[] businessTravels = new BusinessTravel[size];
Node node = head;
int counter = 0;
while(node != null) {
businessTravels[counter] = (BusinessTravel) node.getValue();
node = node.getNext();
counter++;
}
return businessTravels;
}
public Iterator<T> iteratorEmployees(){
ListIterator<T> iterator = new ListIterator<>((T[])getEmployees());
return iterator.iterator();
}
public ListIterator<T> listIteratorEmployees(){
ListIterator<T> listIterator = new ListIterator<>((T[])getEmployees());
return (ListIterator<T>) listIterator.iterator();
}
public Iterator<T> iteratorGroups(){
ListIterator<T> iterator = new ListIterator<>((T[])getGroups());
return iterator.iterator();
}
public ListIterator<T> listIteratorGroups(){
ListIterator<T> listIterator = new ListIterator<>((T[])getGroups());
return (ListIterator<T>) listIterator.iterator();
}
}
|
UTF-8
|
Java
| 13,704 |
java
|
LinkedList.java
|
Java
|
[] | null |
[] |
package humanResources;
import java.util.*;
public class LinkedList<T>{
private Node<T> head;
private Node<T> tail;
private int size;
public Node<T> getHead(){
return head;
}
public Node<T> getTail(){
return tail;
}
public boolean addNodeList(T value){
Node<T> node = new Node<>(value);
if(head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
return true;
}
//bullshit method
public boolean addNodeList(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if(!isEmpty()) {
if (index == 0) { // if node is in the beginning
currentNode = head;
head = nodeValue;
head.setNext(currentNode);
size++;
return true;
}
if (index == size - 1) { // if node is in the end
currentNode = tail;
tail = nodeValue;
return addNodeList(value);
}
} else {
return addNodeList(value);
}
while(node != null) {
if(counter == index){ // if node is in the middle
currentNode = node;
node = nodeValue;
node.setNext(currentNode);
}
counter++;
node = node.getNext();
}
if(counter > size){
size = counter;
return true;
}
return false;
}
public boolean addAllEmployees(Collection<? extends Employee> c) {
Employee[] employeesCollection = (Employee[]) c.toArray();
Node<T> node;
Employee[] employees = getEmployees();
int counter = 0;
for (int j = 0; j < employeesCollection.length; j++) {
node = new Node<>((T) employeesCollection[j]);
if (head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
counter++;
}
return counter > 0;
}
public boolean addAllGroups(Collection<? extends EmployeeGroup> c) {
EmployeeGroup[] groupsCollection = (EmployeeGroup[]) c.toArray();
Node<T> node;
EmployeeGroup[] groups = getGroups();
int counter = 0;
for (int j = 0; j < groupsCollection.length; j++) {
node = new Node<>((T) groupsCollection[j]);
if (head == null)
head = node;
else
tail.setNext(node);
tail = node;
size++;
counter++;
}
return counter > 0;
}
//bullshit method x2
public boolean addAllEmployees(int index, Collection<? extends Employee> c) {
Employee[] employeesCollection = (Employee[]) c.toArray();
Employee[] employees = getEmployees();
boolean isAddAll1 = false;
boolean isAddAll2 = false;
boolean isAddAll3 = false;
clearList();
for(int i = 0; i < index; i++){
isAddAll1 = addNodeList((T) employees[i]);
}
for (Employee anEmployeesCollection : employeesCollection) {
isAddAll2 = addNodeList((T) anEmployeesCollection);
}
for(int i = index; i < employees.length; i++){
isAddAll3 = addNodeList((T)employees[i]);
}
return isAddAll1 && isAddAll2 && isAddAll3;
}
public boolean addAllGroups(int index, Collection<? extends EmployeeGroup> c) {
EmployeeGroup[] groupsCollection = (EmployeeGroup[]) c.toArray();
EmployeeGroup[] groups = getGroups();
boolean isAddAll1 = false;
boolean isAddAll2 = false;
boolean isAddAll3 = false;
clearList();
for(int i = 0; i < index; i++){
isAddAll1 = addNodeList((T) groups[i]);
}
for (EmployeeGroup group : groupsCollection) {
isAddAll2 = addNodeList((T) group);
}
for(int i = index; i < groups.length; i++){
isAddAll3 = addNodeList((T)groups[i]);
}
return isAddAll1 && isAddAll2 && isAddAll3;
}
public EmployeeGroup setGroup(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if (index == 0) { // if node is in the beginning
head = nodeValue;
return (EmployeeGroup) head.getValue();
}
if(index == size - 1){ // if node is in the end
tail = nodeValue;
return (EmployeeGroup) tail.getValue();
}
while(node != null) {
if(counter == index){ // if node is in the middle
node = nodeValue;
return (EmployeeGroup) node.getValue();
}
counter++;
node = node.getNext();
}
return null;
}
public Employee setEmployee(int index, T value){
Node<T> nodeValue = new Node<T>(value);
Node<T> node = head;
Node<T> currentNode;
int counter = 0;
if (index == 0) { // if node is in the beginning
head = nodeValue;
return (Employee) head.getValue();
}
if(index == size - 1){ // if node is in the end
tail = nodeValue;
return (Employee) tail.getValue();
}
while(node != null) {
if(counter == index){ // if node is in the middle
node = nodeValue;
return (Employee) node.getValue();
}
counter++;
node = node.getNext();
}
return null;
}
public boolean retainAllEmployees(Collection<?> c) {
Employee[] retainEmployees = (Employee[]) c.toArray();
Employee[] currentEmployees = getEmployees();
int counter = 0;
clearList();
for(int i = 0; i < currentEmployees.length; i++) {
for (int j = 0; j < retainEmployees.length; j++) {
if (currentEmployees[i].equals(retainEmployees[j])) {
addNodeList((T) retainEmployees[j]);
counter++;
}
}
}
return counter <= 0;
}
public boolean retainAllGroups(Collection<?> c) {
EmployeeGroup[] retainGroups = (EmployeeGroup[]) c.toArray();
EmployeeGroup[] currentGroups = getGroups();
int counter = 0;
clearList();
for(int i = 0; i < currentGroups.length; i++) {
for (int j = 0; j < retainGroups.length; j++) {
if (currentGroups[i].equals(retainGroups[j])) {
addNodeList((T) retainGroups[j]);
counter++;
}
}
}
return counter <= 0;
}
public boolean removeNode(T value){
Node<T> current = head;
Node<T> previous = null;
while(current != null){
if(current.getValue().equals(value)){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
return true;
}
previous = current;
current = current.getNext();
}
return false;
}
public EmployeeGroup removeGroup(int index){
EmployeeGroup[] employeeGroups = getGroups();
for(int i = 0; i < size; i++){
if(index == i){
removeNode((T) employeeGroups[i]);
return employeeGroups[i];
}
}
return null;
}
public Employee removeEmployee(int index){
Employee[] employees = getEmployees();
for(int i = 0; i < size; i++){
if(index == i){
removeNode((T) employees[i]);
return employees[i];
}
}
return null;
}
public boolean removeAllEmployees(Collection<?> c) {
Node<T> current = head;
Node<T> previous = null;
int counter = 0;
Employee[] employeesCollection = (Employee[]) c.toArray();
for(int i = 0; i < employeesCollection.length; i++){
while(current != null){
if(current.getValue().equals(employeesCollection[i])){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
counter++;
break;
}
previous = current;
current = current.getNext();
}
}
return counter > 0;
}
public boolean removeAllGroups(Collection<?> c) {
Node<T> current = head;
Node<T> previous = null;
int counter = 0;
EmployeeGroup[] groups = (EmployeeGroup[]) c.toArray();
for(int i = 0; i < groups.length; i++){
while(current != null){
if(current.getValue().equals(groups[i])){
if(previous != null){
previous.setNext(current.getNext());
if(current.getNext() == null)
tail = previous;
}
else{
head = head.getNext();
if(head == null)
tail = null;
}
size--;
counter++;
break;
}
previous = current;
current = current.getNext();
}
}
return counter > 0;
}
public int getSize() {
return size;
}
public boolean isEmpty(){
return size == 0;
}
public void clearList(){
head = null;
tail = null;
size = 0;
}
public boolean contains(T value){
Node<T> current = head;
while(current != null){
if(current.getValue().equals(value))
return true;
current = current.getNext();
}
return false;
}
public boolean containsAllEmployees(Collection<?> c){
Employee[] employeesCollection = (Employee[]) c.toArray();
Node<T> current = head;
int counter = 0;
for(int i = 0; i < employeesCollection.length; i++) {
while (current != null) {
if (current.getValue().equals(employeesCollection[i])){
counter++;
break;
}
current = current.getNext();
}
}
return counter == employeesCollection.length;
}
public boolean containsAllGroups(Collection<?> c){
EmployeeGroup[] groups = (EmployeeGroup[]) c.toArray();
Node<T> current = head;
int counter = 0;
for(int i = 0; i < groups.length; i++) {
while (current != null) {
if (current.getValue().equals(groups[i])){
counter++;
break;
}
current = current.getNext();
}
}
return counter == groups.length;
}
public Employee[] getEmployees(){
Employee[] employee = new Employee[size];
Node node = head;
int counter = 0;
while(node != null){
employee[counter] = (Employee) node.getValue();
node = node.getNext();
counter++;
}
return employee;
}
public EmployeeGroup[] getGroups(){
EmployeeGroup[] employeeGroups = new EmployeeGroup[size];
Node node = head;
int counter = 0;
while(node != null){
employeeGroups[counter] = (EmployeeGroup) node.getValue();
node = node.getNext();
counter++;
}
return employeeGroups;
}
public BusinessTravel[] getTravels(){
BusinessTravel[] businessTravels = new BusinessTravel[size];
Node node = head;
int counter = 0;
while(node != null) {
businessTravels[counter] = (BusinessTravel) node.getValue();
node = node.getNext();
counter++;
}
return businessTravels;
}
public Iterator<T> iteratorEmployees(){
ListIterator<T> iterator = new ListIterator<>((T[])getEmployees());
return iterator.iterator();
}
public ListIterator<T> listIteratorEmployees(){
ListIterator<T> listIterator = new ListIterator<>((T[])getEmployees());
return (ListIterator<T>) listIterator.iterator();
}
public Iterator<T> iteratorGroups(){
ListIterator<T> iterator = new ListIterator<>((T[])getGroups());
return iterator.iterator();
}
public ListIterator<T> listIteratorGroups(){
ListIterator<T> listIterator = new ListIterator<>((T[])getGroups());
return (ListIterator<T>) listIterator.iterator();
}
}
| 13,704 | 0.4811 | 0.476649 | 491 | 26.910387 | 20.795584 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.513238 | false | false |
13
|
800f628e092106dde98d3e8532fe2fc7507b8de3
| 26,431,228,799,373 |
29817a12757c9b5953fe6ff4a4d5f3af991d826b
|
/No 3/GFC.java
|
d7368550cc81b2e797d36babfcff10abfff85c3a
|
[] |
no_license
|
Dini274/UAS-SMT-2
|
https://github.com/Dini274/UAS-SMT-2
|
137966fb9019bb566a19588cc0a07004ff42dbe7
|
d7f22c4bd005e83509eba3b48df43b52c2d4cdab
|
refs/heads/main
| 2023-06-23T09:01:10.228000 | 2021-07-11T15:07:32 | 2021-07-11T15:07:32 | 384,947,547 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Dini Aryani
*/
// Java program to insert a string into another string
// without using any pre-defined method
import java.lang.*;
class GFG {
// Function to insert string
public static String insertString(
String originalString,
String stringToBeInserted,
int index)
{
// Create a new string
String newString = new String();
for (int i = 0; i < originalString.length(); i++) {
// Insert the original string character
// into the new string
newString += originalString.charAt(i);
if (i == index) {
// Insert the string to be inserted
// into the new string
newString += stringToBeInserted;
}
}
// return the modified String
return newString;
}
// Driver code
public static void main(String[] args)
{
// Get the Strings
String originalString = "Nama Dini";
String stringToBeInserted = "Saya ";
int index = 4;
System.out.println("Original String: "
+ originalString);
System.out.println("String to be inserted: "
+ stringToBeInserted);
System.out.println("String to be inserted at index: "
+ index);
// Insert the String
System.out.println("Modified String: "
+ insertString(originalString,
stringToBeInserted,
index));
}
}
|
UTF-8
|
Java
| 1,909 |
java
|
GFC.java
|
Java
|
[
{
"context": "emplate in the editor.\r\n */\r\n\r\n/**\r\n *\r\n * @author Dini Aryani\r\n */\r\n// Java program to insert a string into ano",
"end": 223,
"score": 0.9998400807380676,
"start": 212,
"tag": "NAME",
"value": "Dini Aryani"
},
{
"context": "Get the Strings\r\n String originalString = \"Nama Dini\";\r\n String stringToBeInserted = \"Saya \";\r\n",
"end": 1264,
"score": 0.6702451705932617,
"start": 1255,
"tag": "NAME",
"value": "Nama Dini"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author <NAME>
*/
// Java program to insert a string into another string
// without using any pre-defined method
import java.lang.*;
class GFG {
// Function to insert string
public static String insertString(
String originalString,
String stringToBeInserted,
int index)
{
// Create a new string
String newString = new String();
for (int i = 0; i < originalString.length(); i++) {
// Insert the original string character
// into the new string
newString += originalString.charAt(i);
if (i == index) {
// Insert the string to be inserted
// into the new string
newString += stringToBeInserted;
}
}
// return the modified String
return newString;
}
// Driver code
public static void main(String[] args)
{
// Get the Strings
String originalString = "<NAME>";
String stringToBeInserted = "Saya ";
int index = 4;
System.out.println("Original String: "
+ originalString);
System.out.println("String to be inserted: "
+ stringToBeInserted);
System.out.println("String to be inserted at index: "
+ index);
// Insert the String
System.out.println("Modified String: "
+ insertString(originalString,
stringToBeInserted,
index));
}
}
| 1,901 | 0.508643 | 0.507596 | 68 | 26.07353 | 21.229361 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.308824 | false | false |
13
|
320d6d7fcb7a1256b7f06780eadbd92439d7e581
| 10,179,072,492,366 |
3eed3dcf0de427eb7925d8758b516bc5eecb6031
|
/common-util/src/main/java/com/zgl/common/util/ExecutorUtils.java
|
343bc8e210b736b69fb92a7bfb9e67bb91f44fc4
|
[] |
no_license
|
zgl-dlut/common-utils
|
https://github.com/zgl-dlut/common-utils
|
2e55a04bbbf7a0fff3277aae1d4973e2e8cf1e85
|
53733b5bfa86c3e5a678d5eec3a9ab4d0c999699
|
refs/heads/master
| 2022-07-04T05:07:04.635000 | 2020-03-22T03:49:05 | 2020-03-22T03:49:05 | 177,900,483 | 0 | 0 | null | false | 2022-06-17T02:06:41 | 2019-03-27T02:03:53 | 2020-03-22T03:49:21 | 2022-06-17T02:06:40 | 66 | 0 | 0 | 1 |
Java
| false | false |
package com.zgl.common.util;
import com.alibaba.ttl.threadpool.TtlExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.lang.Nullable;
import java.util.concurrent.*;
/**
* @author zgl
* @date 2019/8/20 下午5:39
*/
public class ExecutorUtils {
private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat("zgl-pool-%d").build();
public static final ExecutorService EXECUTOR = getTtlThreadPool(16, 16, 60L);
/**
*线程池包装
* @param corePoolSize
* @param maxPoolSize
* @param keepAliveTime
* @return
*/
public static ExecutorService getTtlThreadPool(int corePoolSize, int maxPoolSize, long keepAliveTime) {
ExecutorService fixThreadPool = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(200), THREAD_FACTORY);
return TtlExecutors.getTtlExecutorService(fixThreadPool);
}
/**
* 线程池包装
* @param executorService
* @return
*/
public static ExecutorService getTtlThreadPool(@Nullable ExecutorService executorService) {
return TtlExecutors.getTtlExecutorService(executorService);
}
}
|
UTF-8
|
Java
| 1,187 |
java
|
ExecutorUtils.java
|
Java
|
[
{
"context": "e;\n\nimport java.util.concurrent.*;\n\n/**\n * @author zgl\n * @date 2019/8/20 下午5:39\n */\npublic class Execut",
"end": 234,
"score": 0.9996354579925537,
"start": 231,
"tag": "USERNAME",
"value": "zgl"
}
] | null |
[] |
package com.zgl.common.util;
import com.alibaba.ttl.threadpool.TtlExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.lang.Nullable;
import java.util.concurrent.*;
/**
* @author zgl
* @date 2019/8/20 下午5:39
*/
public class ExecutorUtils {
private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat("zgl-pool-%d").build();
public static final ExecutorService EXECUTOR = getTtlThreadPool(16, 16, 60L);
/**
*线程池包装
* @param corePoolSize
* @param maxPoolSize
* @param keepAliveTime
* @return
*/
public static ExecutorService getTtlThreadPool(int corePoolSize, int maxPoolSize, long keepAliveTime) {
ExecutorService fixThreadPool = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(200), THREAD_FACTORY);
return TtlExecutors.getTtlExecutorService(fixThreadPool);
}
/**
* 线程池包装
* @param executorService
* @return
*/
public static ExecutorService getTtlThreadPool(@Nullable ExecutorService executorService) {
return TtlExecutors.getTtlExecutorService(executorService);
}
}
| 1,187 | 0.7773 | 0.760963 | 39 | 28.846153 | 38.978325 | 178 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.102564 | false | false |
13
|
cd2ab1ea176ce0696e59d398b0903a750c276469
| 36,386,962,955,369 |
5b5b0ee91677524292b69cfc8cde227fdf7ba7f9
|
/A2Prj/src/com/mycompany/a2/ICollection.java
|
0dcb7464b323c9fb253be9350626aa4901033330
|
[] |
no_license
|
nihito/CSC-134
|
https://github.com/nihito/CSC-134
|
a6e87e234e4452f6030a5e379b87cd11e0488a94
|
f116bb0505313ba38e45b438797cb7d9b91b5817
|
refs/heads/master
| 2023-04-24T15:27:18.496000 | 2019-06-01T07:20:19 | 2019-06-01T07:20:19 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mycompany.a2;
public interface ICollection {
public void add(Object object);
public IIterator getIterator();
}
|
UTF-8
|
Java
| 143 |
java
|
ICollection.java
|
Java
|
[] | null |
[] |
package com.mycompany.a2;
public interface ICollection {
public void add(Object object);
public IIterator getIterator();
}
| 143 | 0.685315 | 0.678322 | 10 | 12.3 | 14.366976 | 32 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false |
13
|
e774f29d778164906e6395ce592ab165c29a265a
| 27,719,718,942,430 |
a0e6582789547592521227cc4ba7e8d4e1e64f1d
|
/src/model/services/DepartamentoServices.java
|
64f25cda316c7b6f0380ba209b1da7b3a3775c83
|
[] |
no_license
|
MatheusPedroSS/workshop-javafx-jdbc
|
https://github.com/MatheusPedroSS/workshop-javafx-jdbc
|
9c3508e52a85f4f24de09095ce922c76fd45879e
|
1749ecbe4fdec23dea2161d7a060ae8775675323
|
refs/heads/master
| 2020-05-01T02:58:07.263000 | 2019-03-23T08:05:29 | 2019-03-23T08:05:29 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package model.services;
import java.util.List;
import model.dao.DaoFactory;
import model.dao.DepartamentoDao;
import model.entities.Departamento;
public class DepartamentoServices {
private DepartamentoDao dao = DaoFactory.criarDepartamentoDao();
public List<Departamento> findAll(){
return dao.buscarTodos();
}
public void saveOrUpdate(Departamento obj) {
if (obj.getId() == null) {
dao.inserir(obj);
}
else {
dao.atualizar(obj);
}
}
public void remove(Departamento obj) {
dao.deleteId(obj.getId());
}
}
|
UTF-8
|
Java
| 541 |
java
|
DepartamentoServices.java
|
Java
|
[] | null |
[] |
package model.services;
import java.util.List;
import model.dao.DaoFactory;
import model.dao.DepartamentoDao;
import model.entities.Departamento;
public class DepartamentoServices {
private DepartamentoDao dao = DaoFactory.criarDepartamentoDao();
public List<Departamento> findAll(){
return dao.buscarTodos();
}
public void saveOrUpdate(Departamento obj) {
if (obj.getId() == null) {
dao.inserir(obj);
}
else {
dao.atualizar(obj);
}
}
public void remove(Departamento obj) {
dao.deleteId(obj.getId());
}
}
| 541 | 0.720887 | 0.720887 | 29 | 17.655172 | 17.336977 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.344828 | false | false |
13
|
6c71574f3dcf940da2b24b46bcdd7644e012ccd5
| 11,098,195,529,151 |
174c982382d832cb4f444e8534ea3f6d69f3cc77
|
/src/main/java/com/mobileshop/dto/ProductDTO.java
|
2cc38378ee2e22c60b57b7ca99619ee63932a3b7
|
[] |
no_license
|
phamdatDeveloper/mobilestore2021
|
https://github.com/phamdatDeveloper/mobilestore2021
|
d094037ee889ef57836fb98139558509fe8b2ad0
|
155cb5de0b042f26787b23bd97c3fe922b4075cc
|
refs/heads/main
| 2023-06-27T16:30:56.182000 | 2021-07-23T15:34:26 | 2021-07-23T15:34:26 | 356,815,067 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mobileshop.dto;
import java.util.List;
import org.hibernate.validator.constraints.NotEmpty;
public class ProductDTO extends BaseDTO {
@NotEmpty(message="Không được để trống trường này")
private String productName;
@NotEmpty(message="Không được để trống trường này")
private int price;
private int priceSale;
@NotEmpty(message="Không được để trống trường này")
private String description;
private String specification;
private String mainImage;
private List<String> secondaryImage;
private int quantity;
private String status;
private boolean isSale;
private boolean isNew;
private boolean active;
private int categoryId;
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getPriceSale() {
return priceSale;
}
public void setPriceSale(int priceSale) {
this.priceSale = priceSale;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
public String getMainImage() {
return mainImage;
}
public void setMainImage(String mainImage) {
this.mainImage = mainImage;
}
public List<String> getSecondaryImage() {
return secondaryImage;
}
public void setSecondaryImage(List<String> secondaryImage) {
this.secondaryImage = secondaryImage;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public boolean getIsSale() {
return isSale;
}
public void setIsSale(boolean isSale) {
this.isSale = isSale;
}
public boolean getIsNew() {
return isNew;
}
public void setIsNew(boolean isNew) {
this.isNew = isNew;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
}
|
UTF-8
|
Java
| 2,450 |
java
|
ProductDTO.java
|
Java
|
[] | null |
[] |
package com.mobileshop.dto;
import java.util.List;
import org.hibernate.validator.constraints.NotEmpty;
public class ProductDTO extends BaseDTO {
@NotEmpty(message="Không được để trống trường này")
private String productName;
@NotEmpty(message="Không được để trống trường này")
private int price;
private int priceSale;
@NotEmpty(message="Không được để trống trường này")
private String description;
private String specification;
private String mainImage;
private List<String> secondaryImage;
private int quantity;
private String status;
private boolean isSale;
private boolean isNew;
private boolean active;
private int categoryId;
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getPriceSale() {
return priceSale;
}
public void setPriceSale(int priceSale) {
this.priceSale = priceSale;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
public String getMainImage() {
return mainImage;
}
public void setMainImage(String mainImage) {
this.mainImage = mainImage;
}
public List<String> getSecondaryImage() {
return secondaryImage;
}
public void setSecondaryImage(List<String> secondaryImage) {
this.secondaryImage = secondaryImage;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public boolean getIsSale() {
return isSale;
}
public void setIsSale(boolean isSale) {
this.isSale = isSale;
}
public boolean getIsNew() {
return isNew;
}
public void setIsNew(boolean isNew) {
this.isNew = isNew;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public int getCategoryId() {
return categoryId;
}
public void setCategoryId(int categoryId) {
this.categoryId = categoryId;
}
}
| 2,450 | 0.730066 | 0.730066 | 143 | 15.839161 | 16.808943 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.146853 | false | false |
13
|
a0bb52046315f009d6f45b1642950dd4095c8fdb
| 28,673,201,730,958 |
561caee0c767ff6b49db6ec1e16fddfbba5396c4
|
/DataStructures/Graph/CheckCycleDirectedGraph.java
|
0519d78e099a4a82186f60c6bb1bcfff4f72146e
|
[] |
no_license
|
ranjithkumarshetty/practiceProblems
|
https://github.com/ranjithkumarshetty/practiceProblems
|
b025238571a06bb9bf8353d523393f06b36e8824
|
17b3e5304bd767793e7ffbe25e33d8cb0a21d6d9
|
refs/heads/master
| 2016-09-07T18:51:32.610000 | 2016-02-29T18:17:07 | 2016-02-29T18:17:07 | 24,291,557 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.util.Iterator;
import java.util.LinkedList;
public class CheckCycleDirectedGraph {
private int v; // |V|
private LinkedList<Integer> adj[]; // Adjacency list
CheckCycleDirectedGraph(int v) {
this.v = v;
adj = new LinkedList[v];
for (int i = 0; i < v; i++) {
adj[i] = new LinkedList();
}
}
void addEdge(int v, int w) {
adj[v].add(w);
}
private Boolean isCyclic(int u, Boolean[] visited, Boolean[] recStack) {
if (visited[u] == false) {
visited[u] = true;
recStack[u] = true;
for (int v : adj[u]) {
if (!visited[v]) {
if (isCyclic(v, visited, recStack)) {
return true;
}
} else if (recStack[v]) { // Found a back-edge
return true;
}
}
}
recStack[u] = false;
return false;
}
public Boolean isCyclic() {
Boolean[] visited = new Boolean[this.v];
Boolean[] recStack = new Boolean[this.v];
for (int i = 0; i < this.v; i++) {
visited[i] = false;
recStack[i] = false;
}
for (int i = 0; i < this.v; i++) {
if (!visited[i]) {
if (isCyclic(i, visited, recStack)) {
return true;
}
}
}
return false;
}
public static void main(String[] args) {
CheckCycleDirectedGraph g = new CheckCycleDirectedGraph(4);
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(2, 3);
if (g.isCyclic()) {
System.out.println("Graph contains cycle");
} else {
System.out.println("Graph doesn't contain cycle");
}
}
}
|
UTF-8
|
Java
| 1,842 |
java
|
CheckCycleDirectedGraph.java
|
Java
|
[] | null |
[] |
import java.util.Iterator;
import java.util.LinkedList;
public class CheckCycleDirectedGraph {
private int v; // |V|
private LinkedList<Integer> adj[]; // Adjacency list
CheckCycleDirectedGraph(int v) {
this.v = v;
adj = new LinkedList[v];
for (int i = 0; i < v; i++) {
adj[i] = new LinkedList();
}
}
void addEdge(int v, int w) {
adj[v].add(w);
}
private Boolean isCyclic(int u, Boolean[] visited, Boolean[] recStack) {
if (visited[u] == false) {
visited[u] = true;
recStack[u] = true;
for (int v : adj[u]) {
if (!visited[v]) {
if (isCyclic(v, visited, recStack)) {
return true;
}
} else if (recStack[v]) { // Found a back-edge
return true;
}
}
}
recStack[u] = false;
return false;
}
public Boolean isCyclic() {
Boolean[] visited = new Boolean[this.v];
Boolean[] recStack = new Boolean[this.v];
for (int i = 0; i < this.v; i++) {
visited[i] = false;
recStack[i] = false;
}
for (int i = 0; i < this.v; i++) {
if (!visited[i]) {
if (isCyclic(i, visited, recStack)) {
return true;
}
}
}
return false;
}
public static void main(String[] args) {
CheckCycleDirectedGraph g = new CheckCycleDirectedGraph(4);
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(2, 3);
if (g.isCyclic()) {
System.out.println("Graph contains cycle");
} else {
System.out.println("Graph doesn't contain cycle");
}
}
}
| 1,842 | 0.459283 | 0.453855 | 68 | 26.088236 | 18.547819 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.647059 | false | false |
13
|
7af15d7fd7843bd84b5e94593f795ca3ab1af644
| 27,410,481,284,811 |
df4aabc07017ee607cfdff26b900acd59e91db36
|
/DS0/src/Client.java
|
ce0e9b7a6ebc1f8ab37b52df651d525d8bc71fc1
|
[] |
no_license
|
StephenPWalker/Java
|
https://github.com/StephenPWalker/Java
|
5d2185a5d78cdaa2c47c338c280f240fd8b88cfb
|
f073d349dd8128bc036da91872d341838a90e6df
|
refs/heads/master
| 2020-08-31T23:21:00.202000 | 2020-05-10T17:53:44 | 2020-05-10T17:53:44 | 218,811,812 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.net.*;
import java.io.*;
public class Client{
public Client(String server_host, int server_port) {
try {
while(true)
{
Socket s = new Socket(server_host, server_port);
InputStream in = s.getInputStream();
BufferedReader bin = new BufferedReader (new InputStreamReader(in));
System.out.println(bin.readLine());
s.close();
Thread.sleep(1000);
}
}
catch (java.io.IOException e)
{System.out.println(e); System.exit(1);}
catch (InterruptedException e)
{e.printStackTrace();}
}
public static void main(String argv[])
{
if ((argv.length < 1) || (argv.length > 2))
{
System.out.println("Usage: [host] <port>") ;
System.exit (1) ;
}
String server_host = argv[0] ;
int server_port = 5155;
if (argv.length == 2)
server_port = Integer.parseInt (argv[1]) ;
Client client = new Client(server_host, server_port);
} // end of main
}
|
UTF-8
|
Java
| 988 |
java
|
Client.java
|
Java
|
[] | null |
[] |
import java.net.*;
import java.io.*;
public class Client{
public Client(String server_host, int server_port) {
try {
while(true)
{
Socket s = new Socket(server_host, server_port);
InputStream in = s.getInputStream();
BufferedReader bin = new BufferedReader (new InputStreamReader(in));
System.out.println(bin.readLine());
s.close();
Thread.sleep(1000);
}
}
catch (java.io.IOException e)
{System.out.println(e); System.exit(1);}
catch (InterruptedException e)
{e.printStackTrace();}
}
public static void main(String argv[])
{
if ((argv.length < 1) || (argv.length > 2))
{
System.out.println("Usage: [host] <port>") ;
System.exit (1) ;
}
String server_host = argv[0] ;
int server_port = 5155;
if (argv.length == 2)
server_port = Integer.parseInt (argv[1]) ;
Client client = new Client(server_host, server_port);
} // end of main
}
| 988 | 0.588057 | 0.572874 | 44 | 21.363636 | 21.0865 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.181818 | false | false |
13
|
26eafc65d2b98a4ffb2a6c76354485fa48b14b7f
| 24,541,443,163,412 |
b0da683af639f8c08f6e8216d6360fa9891d4053
|
/FoodOrderingApp-service/src/main/java/com/upgrad/FoodOrderingApp/service/business/CategoryService.java
|
9416e5299df5a1fc3a6b9837df0eb970ea2ac87d
|
[] |
no_license
|
pavankarthiktanikanti/FoodOrderingAppBackend
|
https://github.com/pavankarthiktanikanti/FoodOrderingAppBackend
|
61b3bafecafe5ff24ffba95e5314fd035d31b8f4
|
c636325aa9009eac438280f41accf4c0cdd84332
|
refs/heads/master
| 2021-01-08T23:41:32.268000 | 2020-03-01T13:09:17 | 2020-03-01T13:09:17 | 242,177,857 | 0 | 0 | null | false | 2020-03-01T13:09:19 | 2020-02-21T16:03:03 | 2020-03-01T12:50:52 | 2020-03-01T13:09:18 | 229 | 0 | 0 | 0 |
Java
| false | false |
package com.upgrad.FoodOrderingApp.service.business;
import com.upgrad.FoodOrderingApp.service.dao.CategoryDao;
import com.upgrad.FoodOrderingApp.service.dao.RestaurantCategoryDao;
import com.upgrad.FoodOrderingApp.service.entity.CategoryEntity;
import com.upgrad.FoodOrderingApp.service.entity.RestaurantCategoryEntity;
import com.upgrad.FoodOrderingApp.service.exception.CategoryNotFoundException;
import com.upgrad.FoodOrderingApp.service.util.FoodOrderingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class CategoryService {
@Autowired
private CategoryDao categoryDao;
@Autowired
private RestaurantCategoryDao restaurantCategoryDao;
/**
* Retrieves the List of Categories from the Database order by name
*
* @return The list of categories with uuid and name of each category
*/
public List<CategoryEntity> getAllCategoriesOrderedByName() {
return categoryDao.getAllCategoriesOrderedByName();
}
/**
* This method fetches the list of all categories based on the restaurant uuid
*
* @param restaurantUUID The uuid of the restaurant to search for categories in Database
* @return The list of categories matched with the restaurant uuid
*/
public List<CategoryEntity> getCategoriesByRestaurant(String restaurantUUID) {
List<RestaurantCategoryEntity> restaurantCategories = restaurantCategoryDao.getRestaurantCategoriesByRestaurantUUID(restaurantUUID);
List<CategoryEntity> categories = new ArrayList<CategoryEntity>();
if (restaurantCategories != null) {
restaurantCategories.forEach(restaurantCategory -> {
categories.add(restaurantCategory.getCategory());
});
}
return categories;
}
/**
* Retrieves the Category details based on the category uuid
* Throws error message if in case there is no match found with the uuid in Database
*
* @param categoryUUID The uuid of the category to be retrieved
* @return The Category with all item details under it from the Database
* @throws CategoryNotFoundException If the uuid passed is empty or not found in Database
*/
public CategoryEntity getCategoryById(String categoryUUID) throws CategoryNotFoundException {
// If uuid passed is empty or null
if (FoodOrderingUtil.isInValid(categoryUUID)) {
throw new CategoryNotFoundException("CNF-001", "Category id field should not be empty");
}
CategoryEntity category = categoryDao.getCategoryByUUID(categoryUUID);
// No match found in the Database for the uuid
if (category == null) {
throw new CategoryNotFoundException("CNF-002", "No category by this id");
}
return category;
}
}
|
UTF-8
|
Java
| 2,921 |
java
|
CategoryService.java
|
Java
|
[] | null |
[] |
package com.upgrad.FoodOrderingApp.service.business;
import com.upgrad.FoodOrderingApp.service.dao.CategoryDao;
import com.upgrad.FoodOrderingApp.service.dao.RestaurantCategoryDao;
import com.upgrad.FoodOrderingApp.service.entity.CategoryEntity;
import com.upgrad.FoodOrderingApp.service.entity.RestaurantCategoryEntity;
import com.upgrad.FoodOrderingApp.service.exception.CategoryNotFoundException;
import com.upgrad.FoodOrderingApp.service.util.FoodOrderingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class CategoryService {
@Autowired
private CategoryDao categoryDao;
@Autowired
private RestaurantCategoryDao restaurantCategoryDao;
/**
* Retrieves the List of Categories from the Database order by name
*
* @return The list of categories with uuid and name of each category
*/
public List<CategoryEntity> getAllCategoriesOrderedByName() {
return categoryDao.getAllCategoriesOrderedByName();
}
/**
* This method fetches the list of all categories based on the restaurant uuid
*
* @param restaurantUUID The uuid of the restaurant to search for categories in Database
* @return The list of categories matched with the restaurant uuid
*/
public List<CategoryEntity> getCategoriesByRestaurant(String restaurantUUID) {
List<RestaurantCategoryEntity> restaurantCategories = restaurantCategoryDao.getRestaurantCategoriesByRestaurantUUID(restaurantUUID);
List<CategoryEntity> categories = new ArrayList<CategoryEntity>();
if (restaurantCategories != null) {
restaurantCategories.forEach(restaurantCategory -> {
categories.add(restaurantCategory.getCategory());
});
}
return categories;
}
/**
* Retrieves the Category details based on the category uuid
* Throws error message if in case there is no match found with the uuid in Database
*
* @param categoryUUID The uuid of the category to be retrieved
* @return The Category with all item details under it from the Database
* @throws CategoryNotFoundException If the uuid passed is empty or not found in Database
*/
public CategoryEntity getCategoryById(String categoryUUID) throws CategoryNotFoundException {
// If uuid passed is empty or null
if (FoodOrderingUtil.isInValid(categoryUUID)) {
throw new CategoryNotFoundException("CNF-001", "Category id field should not be empty");
}
CategoryEntity category = categoryDao.getCategoryByUUID(categoryUUID);
// No match found in the Database for the uuid
if (category == null) {
throw new CategoryNotFoundException("CNF-002", "No category by this id");
}
return category;
}
}
| 2,921 | 0.732626 | 0.730572 | 70 | 40.728573 | 34.175564 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.357143 | false | false |
13
|
70dee779c2070e43877af533f95aabfebbae20de
| 32,590,211,855,303 |
37e169f38662f8dfc7bea2f276428afb6a8975c3
|
/src/test/java/habrBdd/pagesHabr/HabrUsersPage.java
|
154ba029e20c31b4ee4b0d25a97ba120fc28570a
|
[] |
no_license
|
mari-kamar/homework_6-1
|
https://github.com/mari-kamar/homework_6-1
|
4dcd96375259787d9426c943f3de8f1d720c411a
|
01717d551a375ce273a5133b0ceaf227efcfc109
|
refs/heads/master
| 2022-12-04T13:28:43.290000 | 2020-08-13T15:32:59 | 2020-08-13T15:32:59 | 287,316,702 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package habrBdd.pagesHabr;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest()
public class HabrUsersPage extends HabrBasePage {
private Actions actions = new Actions(driver);
private By searchUserField = By.xpath("//*[@id=\"people_suggest\"]");
//private WebElement firstUserInList = driver.findElements(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a")).get(0);
//private WebElement firstUserInListLink = driver.findElement(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]"));
public HabrUsersPage(WebDriver driver) {
super(driver);
}
public HabrUsersPage search(String myUserSearch) {
driver.findElement(searchUserField).sendKeys(myUserSearch);
logger.info("Search page HABR is open");
return this;
}
public HabrUsersPage openPersonalInfoFirstUser() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]")));
WebElement firstUserInListLink = driver.findElement(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]"));
actions.click(firstUserInListLink).build().perform();
//actions.click(firstUserInList).build().perform();
return this;
}
public HabrUsersPage checkRateForUser() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//li[@class='defination-list__item defination-list__item_profile-summary'])[1]//a")));
WebElement firstRate = driver.findElement(By.xpath("(//li[@class='defination-list__item defination-list__item_profile-summary'])[1]//a"));
String firstRateText = firstRate.getText();
Assert.assertEquals(firstRateText, "1–й");
return this;
}
public HabrUsersPage checkRateStatus() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[contains(@class, 'user-info__stats-item stacked-counter') and (@title='Рейтинг пользователя')]")));
WebElement userRate = driver.findElement(By.xpath("//a[contains(@class, 'user-info__stats-item stacked-counter') and (@title='Рейтинг пользователя')]"));
Assert.assertTrue(userRate.isDisplayed());
return this;
}
}
|
UTF-8
|
Java
| 2,784 |
java
|
HabrUsersPage.java
|
Java
|
[] | null |
[] |
package habrBdd.pagesHabr;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest()
public class HabrUsersPage extends HabrBasePage {
private Actions actions = new Actions(driver);
private By searchUserField = By.xpath("//*[@id=\"people_suggest\"]");
//private WebElement firstUserInList = driver.findElements(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a")).get(0);
//private WebElement firstUserInListLink = driver.findElement(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]"));
public HabrUsersPage(WebDriver driver) {
super(driver);
}
public HabrUsersPage search(String myUserSearch) {
driver.findElement(searchUserField).sendKeys(myUserSearch);
logger.info("Search page HABR is open");
return this;
}
public HabrUsersPage openPersonalInfoFirstUser() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]")));
WebElement firstUserInListLink = driver.findElement(By.xpath("//ul[@id='peoples']/li[contains(@class, 'content-list__item_users')]/div/div/div/a[1]"));
actions.click(firstUserInListLink).build().perform();
//actions.click(firstUserInList).build().perform();
return this;
}
public HabrUsersPage checkRateForUser() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//li[@class='defination-list__item defination-list__item_profile-summary'])[1]//a")));
WebElement firstRate = driver.findElement(By.xpath("(//li[@class='defination-list__item defination-list__item_profile-summary'])[1]//a"));
String firstRateText = firstRate.getText();
Assert.assertEquals(firstRateText, "1–й");
return this;
}
public HabrUsersPage checkRateStatus() {
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[contains(@class, 'user-info__stats-item stacked-counter') and (@title='Рейтинг пользователя')]")));
WebElement userRate = driver.findElement(By.xpath("//a[contains(@class, 'user-info__stats-item stacked-counter') and (@title='Рейтинг пользователя')]"));
Assert.assertTrue(userRate.isDisplayed());
return this;
}
}
| 2,784 | 0.714182 | 0.709442 | 53 | 50.754719 | 55.756516 | 202 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.773585 | false | false |
13
|
cdd1f27a0da61e8928178ed1beb66a76a2d2a7c3
| 31,310,311,591,613 |
4bcc89e01b62f8a2a47451bb2079709f17acc920
|
/framework/src/main/java/com/wkz/framework/widgets/recycleradapter/FRCommonRecyclerAdapter.java
|
09707b5c2e2867ef074ed41ea6f07f99e20e5091
|
[] |
no_license
|
FPhoenixCorneaE/PleasedReading
|
https://github.com/FPhoenixCorneaE/PleasedReading
|
004fe6a01c6f8718ee3bdbd15188e991a9661648
|
6e78c18e21686aebb26e81b8d2dc0a0bc04d7036
|
refs/heads/master
| 2021-06-11T15:30:07.323000 | 2021-05-21T09:32:57 | 2021-05-21T09:32:57 | 151,233,219 | 4 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.wkz.framework.widgets.recycleradapter;
import android.content.Context;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public abstract class FRCommonRecyclerAdapter<T> extends FRBaseRecyclerAdapter<T> {
protected OnItemClickListener<T> mItemClickListener;
private ArrayList<Integer> mItemChildIds = new ArrayList<>();
private ArrayList<OnItemChildClickListener<T>> mItemChildListeners = new ArrayList<>();
public FRCommonRecyclerAdapter(Context context, List<T> datas, boolean isOpenLoadMore) {
super(context, datas, isOpenLoadMore);
}
protected abstract void convert(FRRecyclerViewHolder holder, T data, int position);
protected abstract int getItemLayoutId();
@NonNull
@Override
public FRRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (isCommonItemView(viewType)) {
return FRRecyclerViewHolder.create(mContext, getItemLayoutId(), parent);
}
return super.onCreateViewHolder(parent, viewType);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
int viewType = holder.getItemViewType();
if (isCommonItemView(viewType)) {
bindCommonItem(holder, position - getHeaderCount());
}
}
private void bindCommonItem(RecyclerView.ViewHolder holder, final int position) {
final FRRecyclerViewHolder fRRecyclerViewHolder = (FRRecyclerViewHolder) holder;
convert(fRRecyclerViewHolder, getAllData().get(position), position);
fRRecyclerViewHolder.getConvertView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mItemClickListener != null) {
mItemClickListener.onItemClick(fRRecyclerViewHolder, getAllData().get(position), position);
}
}
});
for (int i = 0; i < mItemChildIds.size(); i++) {
final int tempI = i;
if (fRRecyclerViewHolder.getConvertView().findViewById(mItemChildIds.get(i)) != null) {
fRRecyclerViewHolder.getConvertView().findViewById(mItemChildIds.get(i)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItemChildListeners.get(tempI).onItemChildClick(fRRecyclerViewHolder, getAllData().get(position), position);
}
});
}
}
}
@Override
protected int getViewType(int position, T data) {
return TYPE_COMMON_VIEW;
}
/**
* item点击事件
*
* @param itemClickListener
*/
public FRCommonRecyclerAdapter<T> setOnItemClickListener(OnItemClickListener<T> itemClickListener) {
mItemClickListener = itemClickListener;
return this;
}
/**
* item子view点击事件
*
* @param viewId
* @param itemChildClickListener
*/
public FRCommonRecyclerAdapter<T> setOnItemChildClickListener(@IdRes int viewId, OnItemChildClickListener<T> itemChildClickListener) {
mItemChildIds.add(viewId);
mItemChildListeners.add(itemChildClickListener);
return this;
}
}
|
UTF-8
|
Java
| 3,474 |
java
|
FRCommonRecyclerAdapter.java
|
Java
|
[] | null |
[] |
package com.wkz.framework.widgets.recycleradapter;
import android.content.Context;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public abstract class FRCommonRecyclerAdapter<T> extends FRBaseRecyclerAdapter<T> {
protected OnItemClickListener<T> mItemClickListener;
private ArrayList<Integer> mItemChildIds = new ArrayList<>();
private ArrayList<OnItemChildClickListener<T>> mItemChildListeners = new ArrayList<>();
public FRCommonRecyclerAdapter(Context context, List<T> datas, boolean isOpenLoadMore) {
super(context, datas, isOpenLoadMore);
}
protected abstract void convert(FRRecyclerViewHolder holder, T data, int position);
protected abstract int getItemLayoutId();
@NonNull
@Override
public FRRecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (isCommonItemView(viewType)) {
return FRRecyclerViewHolder.create(mContext, getItemLayoutId(), parent);
}
return super.onCreateViewHolder(parent, viewType);
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
int viewType = holder.getItemViewType();
if (isCommonItemView(viewType)) {
bindCommonItem(holder, position - getHeaderCount());
}
}
private void bindCommonItem(RecyclerView.ViewHolder holder, final int position) {
final FRRecyclerViewHolder fRRecyclerViewHolder = (FRRecyclerViewHolder) holder;
convert(fRRecyclerViewHolder, getAllData().get(position), position);
fRRecyclerViewHolder.getConvertView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mItemClickListener != null) {
mItemClickListener.onItemClick(fRRecyclerViewHolder, getAllData().get(position), position);
}
}
});
for (int i = 0; i < mItemChildIds.size(); i++) {
final int tempI = i;
if (fRRecyclerViewHolder.getConvertView().findViewById(mItemChildIds.get(i)) != null) {
fRRecyclerViewHolder.getConvertView().findViewById(mItemChildIds.get(i)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItemChildListeners.get(tempI).onItemChildClick(fRRecyclerViewHolder, getAllData().get(position), position);
}
});
}
}
}
@Override
protected int getViewType(int position, T data) {
return TYPE_COMMON_VIEW;
}
/**
* item点击事件
*
* @param itemClickListener
*/
public FRCommonRecyclerAdapter<T> setOnItemClickListener(OnItemClickListener<T> itemClickListener) {
mItemClickListener = itemClickListener;
return this;
}
/**
* item子view点击事件
*
* @param viewId
* @param itemChildClickListener
*/
public FRCommonRecyclerAdapter<T> setOnItemChildClickListener(@IdRes int viewId, OnItemChildClickListener<T> itemChildClickListener) {
mItemChildIds.add(viewId);
mItemChildListeners.add(itemChildClickListener);
return this;
}
}
| 3,474 | 0.67419 | 0.6739 | 97 | 34.628864 | 35.294437 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56701 | false | false |
13
|
d61b491521e61d441d72e9474c9481aeb62ae05e
| 13,580,686,626,374 |
f64e5d5f55719ea7f8ec64cefc17315858f3978c
|
/Assignment4_31-10-2020/Assignment4/src/UserInterface/CustomerRole/BookTickets.java
|
3cf1715f121005b5dffca1039ef8a8e4111c0200
|
[] |
no_license
|
NEU-AED-Assignment-Group-PSA/Team-SAP
|
https://github.com/NEU-AED-Assignment-Group-PSA/Team-SAP
|
e762901fa6464f7cbab4d89fef2284cc19ccbcce
|
57bc2add0215d5cfa95f36da385cca79238b267b
|
refs/heads/main
| 2023-07-19T06:51:36.719000 | 2021-09-15T00:25:45 | 2021-09-15T00:25:45 | 304,469,488 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package UserInterface.CustomerRole;
import Business.Airliner;
import Business.AirlinerDirectory;
import Business.Customer;
import Business.CustomerDirectory;
import Business.Flight;
import Business.FlightSchedule;
import Business.Ticket;
import UserInterface.ManageAirliner.ManageAirlinersJPanel;
import java.awt.CardLayout;
import java.awt.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
/**
*
* @author aditi
*/
public class BookTickets extends javax.swing.JPanel {
/**
* Creates new form BookTickets
*/
JPanel UserProcessContainer;
AirlinerDirectory airlinerDir;
CustomerDirectory custDir;
Customer customer;
List<FlightSchedule> flightSchList;
List<Flight> flightList;
Flight flight;
List<Ticket> ticketList;
public BookTickets(JPanel UserProcessContainer, AirlinerDirectory airlinerDir, CustomerDirectory custDir, Customer c, List<FlightSchedule> flightSchList, List<Flight> flightList, List<Ticket> ticketList) {
initComponents();
this.UserProcessContainer = UserProcessContainer;
this.airlinerDir= airlinerDir;
this.custDir=custDir;
this.flightList=flightList;
this.customer=c;
this.flightSchList = flightSchList;
this.ticketList=ticketList;
// populateCustomer();
populateSource();
populateDest();
cmbCustomerID.setVisible(false);
txtSrc.setVisible(false);
txtDestination.setVisible(false);
lblCustomerID.setText(customer.getfName()+" "+ customer.getlName() + " (" + customer.getCustomerID() + ")");
}
public void populateSource(){
//String[] array = new String[arrayList.size()];
List<String> al= new ArrayList<>();//.toArray(new String[custDir.getCustomerList().size()]);
for(FlightSchedule fs: flightSchList)
{
if(! al.contains(fs.getSrc()))
{
al.add(fs.getSrc());
}
}
cmbSrc.setModel(new DefaultComboBoxModel(al.toArray()));
}
public void populateDest(){
List<String> al= new ArrayList<>();//.toArray(new String[custDir.getCustomerList().size()]);
String source = cmbSrc.getItemAt(cmbSrc.getSelectedIndex());
for(FlightSchedule fs: flightSchList)
{
// if(fs.getSrc().equals(source) && (! al.contains(fs.getDestination())))
if(! al.contains(fs.getDestination()))
{
al.add(fs.getDestination());
}
}
cmbDest.setModel(new DefaultComboBoxModel(al.toArray()));
}
public void populateCustomer(){
//String[] array = new String[arrayList.size()];
List<Customer> al= custDir.getCustomerList();//.toArray(new String[custDir.getCustomerList().size()]);
cmbCustomerID.setModel(new DefaultComboBoxModel(al.toArray()));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
cmbTime = new javax.swing.JComboBox<>();
txtDate = new javax.swing.JTextField();
btnSearch = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tblFlightSchedule = new javax.swing.JTable();
jLabel6 = new javax.swing.JLabel();
btnBook = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
cmbSeatType = new javax.swing.JComboBox<>();
btnBack = new javax.swing.JButton();
lblCustomerID = new javax.swing.JLabel();
txtDestination = new javax.swing.JTextField();
txtSrc = new javax.swing.JTextField();
cmbCustomerID = new javax.swing.JComboBox<>();
cmbSrc = new javax.swing.JComboBox<>();
cmbDest = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
setBackground(new java.awt.Color(0, 102, 102));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Book Ticket");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel3.setText("Source:");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel4.setText("Destination:");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Date:");
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Time:");
cmbTime.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbTime.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Morning", "Evening", "Night" }));
txtDate.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
btnSearch.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnSearch.setText("Search");
btnSearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSearchActionPerformed(evt);
}
});
tblFlightSchedule.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Flight Name", "Source", "Destination", "Date", "Time", "Airliner", "FlightNum", "Available Seat"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(tblFlightSchedule);
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Customer ID:");
btnBook.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnBook.setText("Book");
btnBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBookActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Seat Type:");
cmbSeatType.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbSeatType.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Middle", "Window", "Aisle" }));
btnBack.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnBack.setText("<Back");
btnBack.setToolTipText("");
btnBack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackActionPerformed(evt);
}
});
lblCustomerID.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblCustomerID.setText("jLabel2");
txtDestination.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
txtSrc.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
cmbCustomerID.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbCustomerID.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Customerid1", "CustomerID2" }));
cmbSrc.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbSrc.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cmbSrc.setMinimumSize(new java.awt.Dimension(108, 28));
cmbDest.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbDest.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cmbDest.setMinimumSize(new java.awt.Dimension(108, 28));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("(mm/dd/yyyy)");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(btnBack)
.addGap(253, 253, 253)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(256, 256, 256)
.addComponent(txtDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 709, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmbCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmbSeatType, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))))))
.addGroup(layout.createSequentialGroup()
.addGap(354, 354, 354)
.addComponent(btnSearch))
.addGroup(layout.createSequentialGroup()
.addGap(358, 358, 358)
.addComponent(btnBook, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cmbTime, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmbSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtDate)
.addComponent(cmbDest, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap(506, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(22, 22, 22)
.addComponent(txtSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnBack)
.addGap(61, 61, 61)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbDest, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)))
.addGap(18, 18, 18)
.addComponent(btnSearch)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbSeatType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnBook)))
.addContainerGap(93, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackActionPerformed
// TODO add your handling code here:
backAction();
}
private void backAction(){
UserProcessContainer.remove(this);
//Component [] componentArray = UserProcessContainer.getComponents();
//Component c = componentArray[componentArray.length-1];
//ManageAirlinersJPanel ms = (ManageAirlinersJPanel) c;
// ms.populateAirlinerList();
CardLayout layout = (CardLayout) UserProcessContainer.getLayout();
layout.previous(UserProcessContainer);
}//GEN-LAST:event_btnBackActionPerformed
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed
// TODO add your handling code here:
populateSearchResults();
}
void populateSearchResults(){
try{
/*if(txtSrc.getText() == null || txtSrc.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Source");
return;
}
if(txtDestination.getText() == null || txtDestination.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Destination");
return;
}
*/
java.util.Date date=null;
SimpleDateFormat sdfrmt;
if(!txtDate.getText().isEmpty()){
sdfrmt= new SimpleDateFormat("MM/dd/yyyy");
sdfrmt.setLenient(false);
date = sdfrmt.parse(txtDate.getText());
}
String source = cmbSrc.getItemAt(cmbSrc.getSelectedIndex());//txtSrc.getText();
String dest= cmbDest.getItemAt(cmbDest.getSelectedIndex());//txtDestination.getText();
String time = cmbTime.getItemAt(cmbTime.getSelectedIndex());
if(date==null)
{
searchFlights(source, dest, time);
}
else{
searchFlights(source, dest,date, time);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Date format mm/dd/yyyy like 12/12/2020 !");
System.out.println(Arrays.toString(e.getStackTrace()));
}
}//GEN-LAST:event_btnSearchActionPerformed
private void btnBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBookActionPerformed
// TODO add your handling code here:
int row = tblFlightSchedule.getSelectedRow();
if(row<0){
JOptionPane.showMessageDialog(null, "Please select a row!!", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
FlightSchedule fsch= (FlightSchedule) tblFlightSchedule.getValueAt(row,6);
//check seat
String seatType= cmbSeatType.getItemAt(cmbSeatType.getSelectedIndex());
String seatNumber=fsch.bookTicket(seatType);
if(seatNumber.equals("Not Available"))
{
JOptionPane.showMessageDialog(null, "Not Available, please select other", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
//create ticket
Ticket t = new Ticket();
ticketList.add(t);
t.setCustomerID(customer.getCustomerID());
t.setDate(fsch.getDate().toString());
t.setSource(fsch.getSrc());
t.setDestination(fsch.getDestination());
t.setFlightNum(fsch.getFlightNum());
t.setPrice(fsch.getPrice());
t.setTime(fsch.getTime());
t.setStatus("Booked");
t.setSeatNumber(seatNumber);
t.setFlightID(fsch.getFsID());
//t.setFlight(flight);
JOptionPane.showMessageDialog(null, "Booked with Seat "+seatNumber );
populateSearchResults();
}//GEN-LAST:event_btnBookActionPerformed
public void searchFlights(String source, String dest, Date date, String time)
{
// String tableDateExpired = "2012-03-18";
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
DefaultTableModel model = (DefaultTableModel) tblFlightSchedule.getModel();
model.setRowCount(0);
for(FlightSchedule fs : flightSchList)
{
String fDate ;//= fs.getDate();
fDate = sdf.format(fs.getDate());
String dateS= sdf.format(date);
if(fs.getSrc().equals(source)
&&
fs.getDestination().equals(dest)&&
(fDate.equals(dateS) )&&
fs.getTime().equals(time) && fs.getFlightSeatCount()>0 )
{
for(Flight f: flightList)
{
if(f.getFlightNum().equals(fs.getFlightNum()))
{
flight=f;
break;
}
}
//List<FlightSchedule> flightSchList = flight.getFlightSchedule();
Object row[] = new Object[8];
row[0] = flight.getFlightName();
row[1] = source;
row[2] = dest;
row[3] = fs.getDate();
row[4] = fs.getTime();
//row[5] = fs.getPrice();//flight.getFlightNum();
row[5]= flight.getAirlinerName();
row[6] = fs;
row[7] = fs.getFlightSeatCount();
model.addRow(row);
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void searchFlights(String source, String dest, String time)
{
// String tableDateExpired = "2012-03-18";
try{
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
boolean flag=false;
DefaultTableModel model = (DefaultTableModel) tblFlightSchedule.getModel();
model.setRowCount(0);
for(FlightSchedule fs : flightSchList)
{
// String fDate ;//= fs.getDate();
// fDate = sdf.format(fs.getDate());
// String dateS= sdf.format(date);
if(fs.getSrc().equals(source)
&&
fs.getDestination().equals(dest)&&
// (fDate.equals(dateS) )&&
fs.getTime().equals(time) && fs.getFlightSeatCount()>0 )
{
for(Flight f: flightList)
{
if(f.getFlightNum().equals(fs.getFlightNum()))
{
flight=f;
// break;
}
}
String date = "";
try{
SimpleDateFormat sdfrmt = new SimpleDateFormat("MM/dd/yyyy");
sdfrmt.setLenient(false);
date = sdfrmt.format(fs.getDate());
}catch(Exception e){
date = fs.getDate().toString();
}
//List<FlightSchedule> flightSchList = flight.getFlightSchedule();
Object row[] = new Object[8];
row[0] = flight.getFlightName();
row[1] = source;
row[2] = dest;
row[3] = date;
row[4] = fs.getTime();
//row[5] = fs.getPrice();//flight.getFlightNum();
row[5]= flight.getAirlinerName();
row[6]=fs;
row[7] = fs.getFlightSeatCount();
model.addRow(row);
flag=true;
}
}
// }
// }
if(flag==false)
{
JOptionPane.showMessageDialog(null, "Refine search criteria");
return;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnBack;
private javax.swing.JButton btnBook;
private javax.swing.JButton btnSearch;
private javax.swing.JComboBox<String> cmbCustomerID;
private javax.swing.JComboBox<String> cmbDest;
private javax.swing.JComboBox<String> cmbSeatType;
private javax.swing.JComboBox<String> cmbSrc;
private javax.swing.JComboBox<String> cmbTime;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblCustomerID;
private javax.swing.JTable tblFlightSchedule;
private javax.swing.JTextField txtDate;
private javax.swing.JTextField txtDestination;
private javax.swing.JTextField txtSrc;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 29,549 |
java
|
BookTickets.java
|
Java
|
[
{
"context": ".swing.table.DefaultTableModel;\n\n/**\n *\n * @author aditi\n */\npublic class BookTickets extends javax.swing.",
"end": 907,
"score": 0.9980139136314392,
"start": 902,
"tag": "USERNAME",
"value": "aditi"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package UserInterface.CustomerRole;
import Business.Airliner;
import Business.AirlinerDirectory;
import Business.Customer;
import Business.CustomerDirectory;
import Business.Flight;
import Business.FlightSchedule;
import Business.Ticket;
import UserInterface.ManageAirliner.ManageAirlinersJPanel;
import java.awt.CardLayout;
import java.awt.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
/**
*
* @author aditi
*/
public class BookTickets extends javax.swing.JPanel {
/**
* Creates new form BookTickets
*/
JPanel UserProcessContainer;
AirlinerDirectory airlinerDir;
CustomerDirectory custDir;
Customer customer;
List<FlightSchedule> flightSchList;
List<Flight> flightList;
Flight flight;
List<Ticket> ticketList;
public BookTickets(JPanel UserProcessContainer, AirlinerDirectory airlinerDir, CustomerDirectory custDir, Customer c, List<FlightSchedule> flightSchList, List<Flight> flightList, List<Ticket> ticketList) {
initComponents();
this.UserProcessContainer = UserProcessContainer;
this.airlinerDir= airlinerDir;
this.custDir=custDir;
this.flightList=flightList;
this.customer=c;
this.flightSchList = flightSchList;
this.ticketList=ticketList;
// populateCustomer();
populateSource();
populateDest();
cmbCustomerID.setVisible(false);
txtSrc.setVisible(false);
txtDestination.setVisible(false);
lblCustomerID.setText(customer.getfName()+" "+ customer.getlName() + " (" + customer.getCustomerID() + ")");
}
public void populateSource(){
//String[] array = new String[arrayList.size()];
List<String> al= new ArrayList<>();//.toArray(new String[custDir.getCustomerList().size()]);
for(FlightSchedule fs: flightSchList)
{
if(! al.contains(fs.getSrc()))
{
al.add(fs.getSrc());
}
}
cmbSrc.setModel(new DefaultComboBoxModel(al.toArray()));
}
public void populateDest(){
List<String> al= new ArrayList<>();//.toArray(new String[custDir.getCustomerList().size()]);
String source = cmbSrc.getItemAt(cmbSrc.getSelectedIndex());
for(FlightSchedule fs: flightSchList)
{
// if(fs.getSrc().equals(source) && (! al.contains(fs.getDestination())))
if(! al.contains(fs.getDestination()))
{
al.add(fs.getDestination());
}
}
cmbDest.setModel(new DefaultComboBoxModel(al.toArray()));
}
public void populateCustomer(){
//String[] array = new String[arrayList.size()];
List<Customer> al= custDir.getCustomerList();//.toArray(new String[custDir.getCustomerList().size()]);
cmbCustomerID.setModel(new DefaultComboBoxModel(al.toArray()));
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
cmbTime = new javax.swing.JComboBox<>();
txtDate = new javax.swing.JTextField();
btnSearch = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tblFlightSchedule = new javax.swing.JTable();
jLabel6 = new javax.swing.JLabel();
btnBook = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
cmbSeatType = new javax.swing.JComboBox<>();
btnBack = new javax.swing.JButton();
lblCustomerID = new javax.swing.JLabel();
txtDestination = new javax.swing.JTextField();
txtSrc = new javax.swing.JTextField();
cmbCustomerID = new javax.swing.JComboBox<>();
cmbSrc = new javax.swing.JComboBox<>();
cmbDest = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
setBackground(new java.awt.Color(0, 102, 102));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Book Ticket");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel3.setText("Source:");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel4.setText("Destination:");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Date:");
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Time:");
cmbTime.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbTime.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Morning", "Evening", "Night" }));
txtDate.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
btnSearch.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnSearch.setText("Search");
btnSearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSearchActionPerformed(evt);
}
});
tblFlightSchedule.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Flight Name", "Source", "Destination", "Date", "Time", "Airliner", "FlightNum", "Available Seat"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(tblFlightSchedule);
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Customer ID:");
btnBook.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnBook.setText("Book");
btnBook.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBookActionPerformed(evt);
}
});
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Seat Type:");
cmbSeatType.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbSeatType.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Middle", "Window", "Aisle" }));
btnBack.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
btnBack.setText("<Back");
btnBack.setToolTipText("");
btnBack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackActionPerformed(evt);
}
});
lblCustomerID.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
lblCustomerID.setText("jLabel2");
txtDestination.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
txtSrc.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
cmbCustomerID.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbCustomerID.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Customerid1", "CustomerID2" }));
cmbSrc.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbSrc.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cmbSrc.setMinimumSize(new java.awt.Dimension(108, 28));
cmbDest.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
cmbDest.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cmbDest.setMinimumSize(new java.awt.Dimension(108, 28));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setText("(mm/dd/yyyy)");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(btnBack)
.addGap(253, 253, 253)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(256, 256, 256)
.addComponent(txtDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 709, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmbCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(cmbSeatType, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))))))
.addGroup(layout.createSequentialGroup()
.addGap(354, 354, 354)
.addComponent(btnSearch))
.addGroup(layout.createSequentialGroup()
.addGap(358, 358, 358)
.addComponent(btnBook, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cmbTime, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cmbSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtDate)
.addComponent(cmbDest, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap(506, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(22, 22, 22)
.addComponent(txtSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnBack)
.addGap(61, 61, 61)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbSrc, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbDest, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)))
.addGap(18, 18, 18)
.addComponent(btnSearch)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbCustomerID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbSeatType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(btnBook)))
.addContainerGap(93, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackActionPerformed
// TODO add your handling code here:
backAction();
}
private void backAction(){
UserProcessContainer.remove(this);
//Component [] componentArray = UserProcessContainer.getComponents();
//Component c = componentArray[componentArray.length-1];
//ManageAirlinersJPanel ms = (ManageAirlinersJPanel) c;
// ms.populateAirlinerList();
CardLayout layout = (CardLayout) UserProcessContainer.getLayout();
layout.previous(UserProcessContainer);
}//GEN-LAST:event_btnBackActionPerformed
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchActionPerformed
// TODO add your handling code here:
populateSearchResults();
}
void populateSearchResults(){
try{
/*if(txtSrc.getText() == null || txtSrc.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Source");
return;
}
if(txtDestination.getText() == null || txtDestination.getText().equals(""))
{
JOptionPane.showMessageDialog(null,"Enter Destination");
return;
}
*/
java.util.Date date=null;
SimpleDateFormat sdfrmt;
if(!txtDate.getText().isEmpty()){
sdfrmt= new SimpleDateFormat("MM/dd/yyyy");
sdfrmt.setLenient(false);
date = sdfrmt.parse(txtDate.getText());
}
String source = cmbSrc.getItemAt(cmbSrc.getSelectedIndex());//txtSrc.getText();
String dest= cmbDest.getItemAt(cmbDest.getSelectedIndex());//txtDestination.getText();
String time = cmbTime.getItemAt(cmbTime.getSelectedIndex());
if(date==null)
{
searchFlights(source, dest, time);
}
else{
searchFlights(source, dest,date, time);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Date format mm/dd/yyyy like 12/12/2020 !");
System.out.println(Arrays.toString(e.getStackTrace()));
}
}//GEN-LAST:event_btnSearchActionPerformed
private void btnBookActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBookActionPerformed
// TODO add your handling code here:
int row = tblFlightSchedule.getSelectedRow();
if(row<0){
JOptionPane.showMessageDialog(null, "Please select a row!!", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
FlightSchedule fsch= (FlightSchedule) tblFlightSchedule.getValueAt(row,6);
//check seat
String seatType= cmbSeatType.getItemAt(cmbSeatType.getSelectedIndex());
String seatNumber=fsch.bookTicket(seatType);
if(seatNumber.equals("Not Available"))
{
JOptionPane.showMessageDialog(null, "Not Available, please select other", "Warning", JOptionPane.WARNING_MESSAGE);
return;
}
//create ticket
Ticket t = new Ticket();
ticketList.add(t);
t.setCustomerID(customer.getCustomerID());
t.setDate(fsch.getDate().toString());
t.setSource(fsch.getSrc());
t.setDestination(fsch.getDestination());
t.setFlightNum(fsch.getFlightNum());
t.setPrice(fsch.getPrice());
t.setTime(fsch.getTime());
t.setStatus("Booked");
t.setSeatNumber(seatNumber);
t.setFlightID(fsch.getFsID());
//t.setFlight(flight);
JOptionPane.showMessageDialog(null, "Booked with Seat "+seatNumber );
populateSearchResults();
}//GEN-LAST:event_btnBookActionPerformed
public void searchFlights(String source, String dest, Date date, String time)
{
// String tableDateExpired = "2012-03-18";
try{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
DefaultTableModel model = (DefaultTableModel) tblFlightSchedule.getModel();
model.setRowCount(0);
for(FlightSchedule fs : flightSchList)
{
String fDate ;//= fs.getDate();
fDate = sdf.format(fs.getDate());
String dateS= sdf.format(date);
if(fs.getSrc().equals(source)
&&
fs.getDestination().equals(dest)&&
(fDate.equals(dateS) )&&
fs.getTime().equals(time) && fs.getFlightSeatCount()>0 )
{
for(Flight f: flightList)
{
if(f.getFlightNum().equals(fs.getFlightNum()))
{
flight=f;
break;
}
}
//List<FlightSchedule> flightSchList = flight.getFlightSchedule();
Object row[] = new Object[8];
row[0] = flight.getFlightName();
row[1] = source;
row[2] = dest;
row[3] = fs.getDate();
row[4] = fs.getTime();
//row[5] = fs.getPrice();//flight.getFlightNum();
row[5]= flight.getAirlinerName();
row[6] = fs;
row[7] = fs.getFlightSeatCount();
model.addRow(row);
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void searchFlights(String source, String dest, String time)
{
// String tableDateExpired = "2012-03-18";
try{
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
boolean flag=false;
DefaultTableModel model = (DefaultTableModel) tblFlightSchedule.getModel();
model.setRowCount(0);
for(FlightSchedule fs : flightSchList)
{
// String fDate ;//= fs.getDate();
// fDate = sdf.format(fs.getDate());
// String dateS= sdf.format(date);
if(fs.getSrc().equals(source)
&&
fs.getDestination().equals(dest)&&
// (fDate.equals(dateS) )&&
fs.getTime().equals(time) && fs.getFlightSeatCount()>0 )
{
for(Flight f: flightList)
{
if(f.getFlightNum().equals(fs.getFlightNum()))
{
flight=f;
// break;
}
}
String date = "";
try{
SimpleDateFormat sdfrmt = new SimpleDateFormat("MM/dd/yyyy");
sdfrmt.setLenient(false);
date = sdfrmt.format(fs.getDate());
}catch(Exception e){
date = fs.getDate().toString();
}
//List<FlightSchedule> flightSchList = flight.getFlightSchedule();
Object row[] = new Object[8];
row[0] = flight.getFlightName();
row[1] = source;
row[2] = dest;
row[3] = date;
row[4] = fs.getTime();
//row[5] = fs.getPrice();//flight.getFlightNum();
row[5]= flight.getAirlinerName();
row[6]=fs;
row[7] = fs.getFlightSeatCount();
model.addRow(row);
flag=true;
}
}
// }
// }
if(flag==false)
{
JOptionPane.showMessageDialog(null, "Refine search criteria");
return;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnBack;
private javax.swing.JButton btnBook;
private javax.swing.JButton btnSearch;
private javax.swing.JComboBox<String> cmbCustomerID;
private javax.swing.JComboBox<String> cmbDest;
private javax.swing.JComboBox<String> cmbSeatType;
private javax.swing.JComboBox<String> cmbSrc;
private javax.swing.JComboBox<String> cmbTime;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblCustomerID;
private javax.swing.JTable tblFlightSchedule;
private javax.swing.JTextField txtDate;
private javax.swing.JTextField txtDestination;
private javax.swing.JTextField txtSrc;
// End of variables declaration//GEN-END:variables
}
| 29,549 | 0.583607 | 0.568615 | 618 | 46.813915 | 39.274399 | 210 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.855987 | false | false |
13
|
953b1987c9ffb497ed3e958e5d1b1b68adedb000
| 4,784,593,584,821 |
c714a05756c0b68b1449449f2ce07600d4f19fde
|
/.svn/pristine/95/953b1987c9ffb497ed3e958e5d1b1b68adedb000.svn-base
|
4434c6f4966f027299c83905a8ab13d84b4eb7e6
|
[] |
no_license
|
viking-man/bugfix
|
https://github.com/viking-man/bugfix
|
a5553c5249a142085b8454bb3d9052a1f2049a11
|
66975b370c2190651f24d0844ae94372a00353da
|
refs/heads/master
| 2020-03-02T15:01:37.792000 | 2017-09-06T12:07:15 | 2017-09-06T12:07:15 | 101,290,980 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package wbcloud.water.spring.dao;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
/**
* 根据service包名来动态设置是否选择只读数据源aop
* @author liao.yiying
*
*/
@Component
@Aspect
public class DataSourceReadOnlyAspect implements Ordered{
@Override
public int getOrder() {
return 1;
}
@Pointcut("execution(public * wbcloud.water..service.*ServiceRO.*(..))")
private void anyReadonlyServiceMethod(){
}
@Around("anyReadonlyServiceMethod()")
private Object anyReadonlyServiceMethod(ProceedingJoinPoint pjp) throws Throwable {
try{
DataSourceReadOnlyHolder.setReadOnly(true);
return pjp.proceed();
}finally {
DataSourceReadOnlyHolder.clearSetting();
}
}
@Pointcut("execution(public * wbcloud.water..service.*Service.*(..)) && !execution(public * wbcloud.water..service.*Service.getServiceRO(..))")
private void anyWriteableServiceMethod(){
}
@Around("anyWriteableServiceMethod()")
private Object anyWriteableServiceMethod(ProceedingJoinPoint pjp) throws Throwable {
try{
DataSourceReadOnlyHolder.setReadOnly(false);
return pjp.proceed();
}finally {
DataSourceReadOnlyHolder.clearSetting();
}
}
}
|
UTF-8
|
Java
| 1,397 |
953b1987c9ffb497ed3e958e5d1b1b68adedb000.svn-base
|
Java
|
[
{
"context": ";\n\n\n/**\n * 根据service包名来动态设置是否选择只读数据源aop\n * @author liao.yiying\n *\n */\n@Component\n@Aspect\npublic class Dat",
"end": 354,
"score": 0.6976439952850342,
"start": 350,
"tag": "NAME",
"value": "liao"
},
{
"context": "**\n * 根据service包名来动态设置是否选择只读数据源aop\n * @author liao.yiying\n *\n */\n@Component\n@Aspect\npublic class Data",
"end": 354,
"score": 0.5136749744415283,
"start": 354,
"tag": "USERNAME",
"value": ""
},
{
"context": "*\n * 根据service包名来动态设置是否选择只读数据源aop\n * @author liao.yiying\n *\n */\n@Component\n@Aspect\npublic class DataSource",
"end": 361,
"score": 0.6697512865066528,
"start": 355,
"tag": "NAME",
"value": "yiying"
}
] | null |
[] |
package wbcloud.water.spring.dao;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
/**
* 根据service包名来动态设置是否选择只读数据源aop
* @author liao.yiying
*
*/
@Component
@Aspect
public class DataSourceReadOnlyAspect implements Ordered{
@Override
public int getOrder() {
return 1;
}
@Pointcut("execution(public * wbcloud.water..service.*ServiceRO.*(..))")
private void anyReadonlyServiceMethod(){
}
@Around("anyReadonlyServiceMethod()")
private Object anyReadonlyServiceMethod(ProceedingJoinPoint pjp) throws Throwable {
try{
DataSourceReadOnlyHolder.setReadOnly(true);
return pjp.proceed();
}finally {
DataSourceReadOnlyHolder.clearSetting();
}
}
@Pointcut("execution(public * wbcloud.water..service.*Service.*(..)) && !execution(public * wbcloud.water..service.*Service.getServiceRO(..))")
private void anyWriteableServiceMethod(){
}
@Around("anyWriteableServiceMethod()")
private Object anyWriteableServiceMethod(ProceedingJoinPoint pjp) throws Throwable {
try{
DataSourceReadOnlyHolder.setReadOnly(false);
return pjp.proceed();
}finally {
DataSourceReadOnlyHolder.clearSetting();
}
}
}
| 1,397 | 0.76047 | 0.759735 | 54 | 24.203703 | 28.195993 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.259259 | false | false |
13
|
|
09c3cbfbb8dff2645b1b9e574ef3fdc70907ccce
| 1,065,151,906,555 |
c929618c3ca6c12f02c40f47e9dbce40b529f5fb
|
/java/arrayOfProducts.java
|
3603799313e7422adb0846dd5888097cc9aa6a99
|
[] |
no_license
|
TanisTanis/leetcode
|
https://github.com/TanisTanis/leetcode
|
1674840814f9ab49c8b351f94f7d71b8a8acea6e
|
84dee8e0984f25769ab50084b9b5f1430def0ad7
|
refs/heads/main
| 2023-08-01T11:15:42.825000 | 2021-09-09T18:30:40 | 2021-09-09T18:30:40 | 348,529,567 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
class ArrayOfProducts {
public int[] arrayOfProducts(int[] array) {
int[] results = new int[array.length];
for (int i = 0; i < array.length; i++) {
int product = 1;
for (int j = 0; j < array.length; j++) {
if (i == j) {
continue;
}
product *= array[j];
}
results[i] = product;
}
return results;
}
}
|
UTF-8
|
Java
| 377 |
java
|
arrayOfProducts.java
|
Java
|
[] | null |
[] |
class ArrayOfProducts {
public int[] arrayOfProducts(int[] array) {
int[] results = new int[array.length];
for (int i = 0; i < array.length; i++) {
int product = 1;
for (int j = 0; j < array.length; j++) {
if (i == j) {
continue;
}
product *= array[j];
}
results[i] = product;
}
return results;
}
}
| 377 | 0.490716 | 0.482759 | 17 | 21.235294 | 15.394917 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.588235 | false | false |
13
|
46aa535a2dd2aec4c0435e3dccff013f1c5bb8b9
| 292,057,807,175 |
c1c36f58a53778d9471cfa75830ca916410292d6
|
/SistemasDistribuidos/src/exercicio1/Main.java
|
723cc16b4ee46345fcda9c84cca1f0d956f1f558
|
[] |
no_license
|
karencj/git
|
https://github.com/karencj/git
|
6ca2ccdb822bfa87c4b20001994b5c4cd657407b
|
d3603ecc48fd34d37ba850b31d0eb4b8118f689f
|
refs/heads/master
| 2018-04-07T02:21:45.126000 | 2017-05-21T15:12:31 | 2017-05-21T15:12:31 | 89,524,174 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package exercicio1;
public class Main {
public static void main( String args []) {
ThreadTeste t = new ThreadTeste("hello from multiples threads transforming lowercase to uppercase with 80 characters");
ThreadTeste.lista.add(t);
for(int i =0; i<29; i++)
{
t = new ThreadTeste("");
ThreadTeste.lista.add(t);
//System.out.println(lista.size());
}
ThreadTeste.lista.get(0).start();
System.out.println("END");
}
}
|
UTF-8
|
Java
| 460 |
java
|
Main.java
|
Java
|
[] | null |
[] |
package exercicio1;
public class Main {
public static void main( String args []) {
ThreadTeste t = new ThreadTeste("hello from multiples threads transforming lowercase to uppercase with 80 characters");
ThreadTeste.lista.add(t);
for(int i =0; i<29; i++)
{
t = new ThreadTeste("");
ThreadTeste.lista.add(t);
//System.out.println(lista.size());
}
ThreadTeste.lista.get(0).start();
System.out.println("END");
}
}
| 460 | 0.645652 | 0.630435 | 19 | 23.210526 | 27.2292 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.947368 | false | false |
13
|
c0e760444c74a453ae2a50e2d83e1ffaacd1e5d3
| 5,944,234,769,662 |
eebcb4e2ffce5343d9a3aeeea71c8c9967cf1501
|
/src/main/java/run/halo/app/model/properties/OtherProperties.java
|
8d19597e6e97a1f0ec983b9788ebbe5fa9aea603
|
[
"MIT",
"GPL-3.0-only"
] |
permissive
|
shaungao94/halo-master
|
https://github.com/shaungao94/halo-master
|
b91d74ec8d8a1a9c18a43a769535002181d09a87
|
617b447eda1f90909b193fcccbcdc00139733021
|
refs/heads/main
| 2023-06-19T17:40:53.315000 | 2021-07-05T20:10:54 | 2021-07-05T20:10:54 | 383,250,492 | 0 | 1 |
MIT
| false | 2021-07-05T20:10:54 | 2021-07-05T19:54:50 | 2021-07-05T19:54:57 | 2021-07-05T20:10:54 | 0 | 0 | 1 | 0 |
Java
| false | false |
package run.halo.app.model.properties;
import run.halo.app.model.enums.PostEditorType;
/**
* Other properties.
*
* @author johnniang
* @author ryanwang
* @date 2019-04-01
*/
public enum OtherProperties implements PropertyEnum {
/**
* Global custom head.
*/
CUSTOM_HEAD("blog_custom_head", String.class, ""),
/**
* Content page(post,sheet) custom head.
*/
CUSTOM_CONTENT_HEAD("blog_custom_content_head", String.class, ""),
/**
* Statistics platform code,such as Google Analytics.
*/
STATISTICS_CODE("blog_statistics_code", String.class, ""),
/**
* Global absolute path enabled.
*/
GLOBAL_ABSOLUTE_PATH_ENABLED("global_absolute_path_enabled", Boolean.class, "true"),
/**
* Default post editor.
*/
DEFAULT_EDITOR("default_editor", PostEditorType.class, PostEditorType.MARKDOWN.name());
private final String value;
private final Class<?> type;
private final String defaultValue;
OtherProperties(String value, Class<?> type, String defaultValue) {
this.value = value;
this.type = type;
this.defaultValue = defaultValue;
}
@Override
public Class<?> getType() {
return type;
}
@Override
public String defaultValue() {
return defaultValue;
}
@Override
public String getValue() {
return value;
}
}
|
UTF-8
|
Java
| 1,403 |
java
|
OtherProperties.java
|
Java
|
[
{
"context": "ditorType;\n\n/**\n * Other properties.\n *\n * @author johnniang\n * @author ryanwang\n * @date 2019-04-01\n */\npubli",
"end": 137,
"score": 0.9995050430297852,
"start": 128,
"tag": "USERNAME",
"value": "johnniang"
},
{
"context": "her properties.\n *\n * @author johnniang\n * @author ryanwang\n * @date 2019-04-01\n */\npublic enum OtherProperti",
"end": 157,
"score": 0.9989175200462341,
"start": 149,
"tag": "USERNAME",
"value": "ryanwang"
}
] | null |
[] |
package run.halo.app.model.properties;
import run.halo.app.model.enums.PostEditorType;
/**
* Other properties.
*
* @author johnniang
* @author ryanwang
* @date 2019-04-01
*/
public enum OtherProperties implements PropertyEnum {
/**
* Global custom head.
*/
CUSTOM_HEAD("blog_custom_head", String.class, ""),
/**
* Content page(post,sheet) custom head.
*/
CUSTOM_CONTENT_HEAD("blog_custom_content_head", String.class, ""),
/**
* Statistics platform code,such as Google Analytics.
*/
STATISTICS_CODE("blog_statistics_code", String.class, ""),
/**
* Global absolute path enabled.
*/
GLOBAL_ABSOLUTE_PATH_ENABLED("global_absolute_path_enabled", Boolean.class, "true"),
/**
* Default post editor.
*/
DEFAULT_EDITOR("default_editor", PostEditorType.class, PostEditorType.MARKDOWN.name());
private final String value;
private final Class<?> type;
private final String defaultValue;
OtherProperties(String value, Class<?> type, String defaultValue) {
this.value = value;
this.type = type;
this.defaultValue = defaultValue;
}
@Override
public Class<?> getType() {
return type;
}
@Override
public String defaultValue() {
return defaultValue;
}
@Override
public String getValue() {
return value;
}
}
| 1,403 | 0.624376 | 0.618674 | 65 | 20.584616 | 22.627344 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false |
13
|
be11e4cf4544f8b6476d5e50d7994de4fc128cf5
| 4,105,988,780,046 |
a666f5dde73ea4f249a2583bb553aad8e326c5d3
|
/SMSViewer/src/blu/model/Contact.java
|
6054a77de1dcee7cdab4aaf623146789ad2a09e3
|
[] |
no_license
|
blu2lz/SMSViewer
|
https://github.com/blu2lz/SMSViewer
|
c5e9a59c8c6fab7e61a7c6a711612b53008e842a
|
c6e82dba1077a81ea9dfc69dddcf5f5c89e7cd46
|
refs/heads/master
| 2021-01-16T18:40:04.571000 | 2013-11-25T21:28:25 | 2013-11-25T21:28:25 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package blu.model;
import java.util.List;
import ezvcard.types.TelephoneType;
/**
* This class represents a contact with its properties (first name, last name, number).
*
* @author Torsten Casselt
*/
public class Contact {
private String firstName, lastName, displayString;
private List<TelephoneType> numbers;
/**
* Creates a contact.
*
* @param firstName
* @param lastName
* @param list phone numbers of this contact
*/
public Contact(String firstName, String lastName, List<TelephoneType> list) {
this.firstName = firstName;
this.lastName = lastName;
this.numbers = list;
displayString = (lastName != null ? lastName : "") + (lastName != null && firstName != null ? ", " : "") + (firstName != null ? firstName : "");
}
public String getLastName() {
return lastName;
}
public String getFirstName() {
return firstName;
}
public List<TelephoneType> getNumbers() {
return numbers;
}
public int getNumberCount() {
return numbers.size();
}
/**
* Sets the displayed string in the contact list to a new value.
*
* @param d
*/
public void setDisplayString(String d) {
displayString = d;
}
public String toString() {
return displayString;
}
}
|
UTF-8
|
Java
| 1,221 |
java
|
Contact.java
|
Java
|
[
{
"context": "es (first name, last name, number).\n * \n * @author Torsten Casselt\n */\npublic class Contact {\n\n\tprivate String first",
"end": 203,
"score": 0.9997528195381165,
"start": 188,
"tag": "NAME",
"value": "Torsten Casselt"
},
{
"context": "asselt\n */\npublic class Contact {\n\n\tprivate String firstName, lastName, displayString;\n\tprivate List<Telephone",
"end": 257,
"score": 0.6328086256980896,
"start": 248,
"tag": "NAME",
"value": "firstName"
},
{
"context": "public class Contact {\n\n\tprivate String firstName, lastName, displayString;\n\tprivate List<TelephoneType> numb",
"end": 267,
"score": 0.8889516592025757,
"start": 259,
"tag": "NAME",
"value": "lastName"
},
{
"context": "ers;\n\t\n\t/**\n\t * Creates a contact.\n\t * \n\t * @param firstName\n\t * @param lastName\n\t * @param list\t\tphone number",
"end": 377,
"score": 0.9684797525405884,
"start": 368,
"tag": "NAME",
"value": "firstName"
},
{
"context": "es a contact.\n\t * \n\t * @param firstName\n\t * @param lastName\n\t * @param list\t\tphone numbers of this contact\n\t ",
"end": 397,
"score": 0.9725111722946167,
"start": 389,
"tag": "NAME",
"value": "lastName"
},
{
"context": "umbers of this contact\n\t */\n\tpublic Contact(String firstName, String lastName, List<TelephoneType> list) {\n\t\tt",
"end": 482,
"score": 0.7921453714370728,
"start": 473,
"tag": "NAME",
"value": "firstName"
},
{
"context": "tact\n\t */\n\tpublic Contact(String firstName, String lastName, List<TelephoneType> list) {\n\t\tthis.firstName = f",
"end": 499,
"score": 0.8551101088523865,
"start": 491,
"tag": "NAME",
"value": "lastName"
},
{
"context": "me, List<TelephoneType> list) {\n\t\tthis.firstName = firstName;\n\t\tthis.lastName = lastName;\n\t\tthis.numbers = lis",
"end": 557,
"score": 0.9956173896789551,
"start": 548,
"tag": "NAME",
"value": "firstName"
},
{
"context": " {\n\t\tthis.firstName = firstName;\n\t\tthis.lastName = lastName;\n\t\tthis.numbers = list;\n\t\tdisplayString = (lastNa",
"end": 585,
"score": 0.9950984120368958,
"start": 577,
"tag": "NAME",
"value": "lastName"
},
{
"context": " \"\");\n\t}\n\t\n\tpublic String getLastName() {\n\t\treturn lastName;\n\t}\n\t\n\tpublic String getFirstName() {\n\t\treturn fi",
"end": 810,
"score": 0.5054669380187988,
"start": 802,
"tag": "NAME",
"value": "lastName"
}
] | null |
[] |
package blu.model;
import java.util.List;
import ezvcard.types.TelephoneType;
/**
* This class represents a contact with its properties (first name, last name, number).
*
* @author <NAME>
*/
public class Contact {
private String firstName, lastName, displayString;
private List<TelephoneType> numbers;
/**
* Creates a contact.
*
* @param firstName
* @param lastName
* @param list phone numbers of this contact
*/
public Contact(String firstName, String lastName, List<TelephoneType> list) {
this.firstName = firstName;
this.lastName = lastName;
this.numbers = list;
displayString = (lastName != null ? lastName : "") + (lastName != null && firstName != null ? ", " : "") + (firstName != null ? firstName : "");
}
public String getLastName() {
return lastName;
}
public String getFirstName() {
return firstName;
}
public List<TelephoneType> getNumbers() {
return numbers;
}
public int getNumberCount() {
return numbers.size();
}
/**
* Sets the displayed string in the contact list to a new value.
*
* @param d
*/
public void setDisplayString(String d) {
displayString = d;
}
public String toString() {
return displayString;
}
}
| 1,212 | 0.673219 | 0.673219 | 59 | 19.694916 | 25.587507 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.355932 | false | false |
13
|
f965d719618edbba9bb6be443de8b54bab482d64
| 28,673,201,690,112 |
399e0c9be4d631812f25f92370270f9c971674fe
|
/src/main/java/org/diplomatiq/diplomatiqbackend/filters/JsonResponseWritingFilter.java
|
e8553ea3132f10e4a19ffe4244b3019a0c5d47cb
|
[
"MIT"
] |
permissive
|
Diplomatiq/diplomatiq-backend
|
https://github.com/Diplomatiq/diplomatiq-backend
|
a89bd2baf3d533612f8f51ee36bd3c94d50a1995
|
97ed829e42f6bfaa48607b33e1e7543b3aec061c
|
refs/heads/develop
| 2021-05-23T14:18:53.161000 | 2020-05-10T23:47:08 | 2020-05-10T23:47:08 | 253,334,403 | 0 | 0 |
MIT
| false | 2021-02-27T08:01:24 | 2020-04-05T21:20:40 | 2020-05-10T23:51:28 | 2021-02-27T08:01:20 | 449 | 0 | 0 | 2 |
Java
| false | false |
package org.diplomatiq.diplomatiqbackend.filters;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public abstract class JsonResponseWritingFilter extends GenericFilterBean {
private ObjectMapper objectMapper;
public JsonResponseWritingFilter(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
public void writeJsonResponse(HttpServletResponse response, ResponseEntity<Object> responseEntity) throws IOException {
response.setStatus(responseEntity.getStatusCodeValue());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
for (Map.Entry<String, List<String>> headerEntry : responseEntity.getHeaders().entrySet()) {
String headerName = headerEntry.getKey();
List<String> headerValues = headerEntry.getValue();
for (String headerValue : headerValues) {
response.setHeader(headerName, headerValue);
}
}
Object responseBody = Optional.ofNullable(responseEntity.getBody()).orElse(new Object());
objectMapper.writeValue(response.getWriter(), responseBody);
}
}
|
UTF-8
|
Java
| 1,535 |
java
|
JsonResponseWritingFilter.java
|
Java
|
[] | null |
[] |
package org.diplomatiq.diplomatiqbackend.filters;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public abstract class JsonResponseWritingFilter extends GenericFilterBean {
private ObjectMapper objectMapper;
public JsonResponseWritingFilter(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
public void writeJsonResponse(HttpServletResponse response, ResponseEntity<Object> responseEntity) throws IOException {
response.setStatus(responseEntity.getStatusCodeValue());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
for (Map.Entry<String, List<String>> headerEntry : responseEntity.getHeaders().entrySet()) {
String headerName = headerEntry.getKey();
List<String> headerValues = headerEntry.getValue();
for (String headerValue : headerValues) {
response.setHeader(headerName, headerValue);
}
}
Object responseBody = Optional.ofNullable(responseEntity.getBody()).orElse(new Object());
objectMapper.writeValue(response.getWriter(), responseBody);
}
}
| 1,535 | 0.749837 | 0.749186 | 39 | 38.358974 | 31.901682 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.641026 | false | false |
13
|
0928473a5f7b0a11836fcefa7ffef6b461a689ca
| 31,507,880,143,944 |
1e9792d7fb8cbd3e916f16d29018fe4899cac3b5
|
/src/main/java/com/ainur/models/Teachers.java
|
4ec0876602274cd05e5e059661c5f1a645b008bc
|
[] |
no_license
|
ceasar13m/Schoolv1
|
https://github.com/ceasar13m/Schoolv1
|
5bbc531adad29fec6182c1f4fa6458f62d8f5eed
|
03ac399ccdc2f9f6718eacdf5a0d24d7837e9084
|
refs/heads/master
| 2022-08-14T22:19:01.160000 | 2019-10-21T18:02:25 | 2019-10-21T18:02:25 | 180,863,773 | 0 | 0 | null | false | 2022-07-07T22:09:24 | 2019-04-11T19:29:50 | 2019-10-21T18:02:39 | 2022-07-07T22:09:21 | 66 | 0 | 0 | 4 |
Java
| false | false |
package com.ainur.models;
import java.util.ArrayList;
public class Teachers {
private ArrayList<Teacher> arrayList = new ArrayList<>();
public ArrayList<Teacher> getArrayList() {
return arrayList;
}
public void setArrayList(ArrayList<Teacher> arrayList) {
this.arrayList = arrayList;
}
}
|
UTF-8
|
Java
| 328 |
java
|
Teachers.java
|
Java
|
[] | null |
[] |
package com.ainur.models;
import java.util.ArrayList;
public class Teachers {
private ArrayList<Teacher> arrayList = new ArrayList<>();
public ArrayList<Teacher> getArrayList() {
return arrayList;
}
public void setArrayList(ArrayList<Teacher> arrayList) {
this.arrayList = arrayList;
}
}
| 328 | 0.685976 | 0.685976 | 15 | 20.866667 | 21.118292 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
13
|
0f9b83b31242e4095f196fc24cfae889207b6090
| 10,788,957,904,505 |
d613574d9b823d52a5c99302124a49104b2bf112
|
/src/main/java/io/choerodon/base/api/validator/PasswordPolicyValidator.java
|
783c1d71bf9ae5368a88edc0e7f2dda083b6e7b2
|
[
"Apache-2.0"
] |
permissive
|
zhoushiqiang222/base-service
|
https://github.com/zhoushiqiang222/base-service
|
20cdc60c3350678561eb9cd392c850ddee95b2ba
|
af621601f53efdefef44bce83ab0b1bef0813778
|
refs/heads/master
| 2022-12-19T15:10:42.624000 | 2020-09-25T03:05:34 | 2020-09-25T03:05:34 | 298,939,185 | 0 | 0 |
Apache-2.0
| true | 2020-09-27T02:43:39 | 2020-09-27T02:43:38 | 2020-09-25T03:19:51 | 2020-09-25T03:19:49 | 3,359 | 0 | 0 | 0 | null | false | false |
package io.choerodon.base.api.validator;
import io.choerodon.core.exception.CommonException;
import io.choerodon.base.infra.dto.PasswordPolicyDTO;
import io.choerodon.base.infra.mapper.PasswordPolicyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wuguokai
*/
@Component
public class PasswordPolicyValidator {
@Autowired
private PasswordPolicyMapper passwordPolicyMapper;
public void create(Long orgId, PasswordPolicyDTO passwordPolicyDTO) {
PasswordPolicyDTO dto = new PasswordPolicyDTO();
dto.setOrganizationId(orgId);
if (!passwordPolicyMapper.select(dto).isEmpty()) {
throw new CommonException("error.passwordPolicy.organizationId.exist");
}
dto.setOrganizationId(null);
dto.setCode(passwordPolicyDTO.getCode());
if (!passwordPolicyMapper.select(dto).isEmpty()) {
throw new CommonException("error.passwordPolicy.code.exist");
}
}
public void update(Long orgId, Long passwordPolicyId, PasswordPolicyDTO passwordPolicyDTO) {
PasswordPolicyDTO dto = passwordPolicyMapper.selectByPrimaryKey(passwordPolicyId);
if (dto == null) {
throw new CommonException("error.passwordPolicy.not.exist");
}
if (!orgId.equals(dto.getOrganizationId())) {
throw new CommonException("error.passwordPolicy.organizationId.not.same");
}
// the sum of all the fields with least length requirement is greater than maxLength
int allLeastRequiredLength = passwordPolicyDTO.getDigitsCount() +
passwordPolicyDTO.getSpecialCharCount() +
passwordPolicyDTO.getLowercaseCount() +
passwordPolicyDTO.getUppercaseCount();
if (allLeastRequiredLength > passwordPolicyDTO.getMaxLength()) {
throw new CommonException("error.allLeastRequiredLength.greaterThan.maxLength");
}
if (passwordPolicyDTO.getMinLength() > passwordPolicyDTO.getMaxLength()) {
throw new CommonException("error.maxLength.lessThan.minLength");
}
passwordPolicyDTO.setCode(null);
passwordPolicyDTO.setOrganizationId(null);
}
}
|
UTF-8
|
Java
| 2,265 |
java
|
PasswordPolicyValidator.java
|
Java
|
[
{
"context": "ingframework.stereotype.Component;\n\n/**\n * @author wuguokai\n */\n@Component\npublic class PasswordPolicyValidat",
"end": 345,
"score": 0.9995759725570679,
"start": 337,
"tag": "USERNAME",
"value": "wuguokai"
}
] | null |
[] |
package io.choerodon.base.api.validator;
import io.choerodon.core.exception.CommonException;
import io.choerodon.base.infra.dto.PasswordPolicyDTO;
import io.choerodon.base.infra.mapper.PasswordPolicyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wuguokai
*/
@Component
public class PasswordPolicyValidator {
@Autowired
private PasswordPolicyMapper passwordPolicyMapper;
public void create(Long orgId, PasswordPolicyDTO passwordPolicyDTO) {
PasswordPolicyDTO dto = new PasswordPolicyDTO();
dto.setOrganizationId(orgId);
if (!passwordPolicyMapper.select(dto).isEmpty()) {
throw new CommonException("error.passwordPolicy.organizationId.exist");
}
dto.setOrganizationId(null);
dto.setCode(passwordPolicyDTO.getCode());
if (!passwordPolicyMapper.select(dto).isEmpty()) {
throw new CommonException("error.passwordPolicy.code.exist");
}
}
public void update(Long orgId, Long passwordPolicyId, PasswordPolicyDTO passwordPolicyDTO) {
PasswordPolicyDTO dto = passwordPolicyMapper.selectByPrimaryKey(passwordPolicyId);
if (dto == null) {
throw new CommonException("error.passwordPolicy.not.exist");
}
if (!orgId.equals(dto.getOrganizationId())) {
throw new CommonException("error.passwordPolicy.organizationId.not.same");
}
// the sum of all the fields with least length requirement is greater than maxLength
int allLeastRequiredLength = passwordPolicyDTO.getDigitsCount() +
passwordPolicyDTO.getSpecialCharCount() +
passwordPolicyDTO.getLowercaseCount() +
passwordPolicyDTO.getUppercaseCount();
if (allLeastRequiredLength > passwordPolicyDTO.getMaxLength()) {
throw new CommonException("error.allLeastRequiredLength.greaterThan.maxLength");
}
if (passwordPolicyDTO.getMinLength() > passwordPolicyDTO.getMaxLength()) {
throw new CommonException("error.maxLength.lessThan.minLength");
}
passwordPolicyDTO.setCode(null);
passwordPolicyDTO.setOrganizationId(null);
}
}
| 2,265 | 0.705077 | 0.705077 | 57 | 38.736843 | 31.279457 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false |
13
|
80f85c1c794131696735d2780b3f41cbbcfd564c
| 6,081,673,693,710 |
96e00d7b1eb8703a1668de56f73dac92cf24a651
|
/src/main/java/uesocc/edu/sv/ingenieria/tpi135_rutasbuses/controlers/ParadasFacade.java
|
998eac6118cbbc0e6432aa99faba3bfdf8a74426
|
[] |
no_license
|
javierbl30/TPI135-RutasBuses
|
https://github.com/javierbl30/TPI135-RutasBuses
|
ab710d295a34b2321fdefa871d93ae7a1490cf15
|
fb93d4eff398814d7dec7b9ad8054f1e1bc521ae
|
refs/heads/master
| 2022-07-08T10:29:28.649000 | 2019-06-06T18:13:02 | 2019-06-06T18:13:02 | 182,018,427 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package uesocc.edu.sv.ingenieria.tpi135_rutasbuses.controlers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import uesocc.edu.sv.ingenieria.tpi135_rutasbuses.entitys.Paradas;
/**
*
* @author pedrojv
*/
@LocalBean
@Stateless
public class ParadasFacade extends AbstractFacade<Paradas> {
@PersistenceContext(unitName = "uesocc.edu.sv.ingenieria_TPI135_RutasBuses_war_1.0-SNAPSHOTPU")
protected EntityManager em;
@Override
public EntityManager getEntityManager() {
return em;
}
public ParadasFacade() {
super(Paradas.class);
}
public List<Paradas> paradasPorRuta(String idRuta){
List<Paradas> lista = new ArrayList<>();
try{
if(idRuta!=null){
Query query = em.createQuery("SELECT p FROM Paradas p JOIN p.recorridoRutasList rr WHERE rr.rutas.idRuta = "+idRuta);
lista = query.getResultList();
return lista;
}else{
return Collections.EMPTY_LIST;
}
}catch(Exception e){
return Collections.EMPTY_LIST;
}
}
}
|
UTF-8
|
Java
| 1,503 |
java
|
ParadasFacade.java
|
Java
|
[
{
"context": "135_rutasbuses.entitys.Paradas;\n\n/**\n *\n * @author pedrojv\n */\n@LocalBean\n@Stateless\npublic class ParadasFac",
"end": 596,
"score": 0.9995644688606262,
"start": 589,
"tag": "USERNAME",
"value": "pedrojv"
}
] | null |
[] |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package uesocc.edu.sv.ingenieria.tpi135_rutasbuses.controlers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import uesocc.edu.sv.ingenieria.tpi135_rutasbuses.entitys.Paradas;
/**
*
* @author pedrojv
*/
@LocalBean
@Stateless
public class ParadasFacade extends AbstractFacade<Paradas> {
@PersistenceContext(unitName = "uesocc.edu.sv.ingenieria_TPI135_RutasBuses_war_1.0-SNAPSHOTPU")
protected EntityManager em;
@Override
public EntityManager getEntityManager() {
return em;
}
public ParadasFacade() {
super(Paradas.class);
}
public List<Paradas> paradasPorRuta(String idRuta){
List<Paradas> lista = new ArrayList<>();
try{
if(idRuta!=null){
Query query = em.createQuery("SELECT p FROM Paradas p JOIN p.recorridoRutasList rr WHERE rr.rutas.idRuta = "+idRuta);
lista = query.getResultList();
return lista;
}else{
return Collections.EMPTY_LIST;
}
}catch(Exception e){
return Collections.EMPTY_LIST;
}
}
}
| 1,503 | 0.675981 | 0.668663 | 52 | 27.903847 | 27.035063 | 133 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.423077 | false | false |
13
|
097f9f2606b7714221e215f007e475bb5a48bc47
| 33,397,665,745,702 |
416ce226649437dc700a497b3be56d0e8c6fcdd6
|
/SpotCounter.java
|
3027e6028bcda35f8df026cfc2604cbda27d1b6f
|
[] |
no_license
|
nrhawkins/javaeli
|
https://github.com/nrhawkins/javaeli
|
1b265a8519b0e2472055d904f4166aede8b2ae78
|
9a8a9fa892f9856728d9a748511162e21d513253
|
refs/heads/master
| 2016-09-06T12:09:32.598000 | 2015-03-12T03:57:04 | 2015-03-12T03:57:04 | 32,055,613 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.*;
public class SpotCounter
{
boolean DISPLAY = false;
//boolean DISPLAY = false;
public SpotCounter(File[] files)
{
//System.out.println("Displaying the image file");
if(DISPLAY)
{
new ImageViewer(files[0]);
}
//System.out.println("Creating the EliFile");
//Create globPixelCount report
//new ReportPixelCounts(files);
//new ReportGlobCounts(files);
new ReportPixels(files);
//new ReportImagePixels(files);
}
}
|
UTF-8
|
Java
| 519 |
java
|
SpotCounter.java
|
Java
|
[] | null |
[] |
import java.io.*;
public class SpotCounter
{
boolean DISPLAY = false;
//boolean DISPLAY = false;
public SpotCounter(File[] files)
{
//System.out.println("Displaying the image file");
if(DISPLAY)
{
new ImageViewer(files[0]);
}
//System.out.println("Creating the EliFile");
//Create globPixelCount report
//new ReportPixelCounts(files);
//new ReportGlobCounts(files);
new ReportPixels(files);
//new ReportImagePixels(files);
}
}
| 519 | 0.614644 | 0.612717 | 24 | 20.5 | 17.363756 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false |
13
|
018a9a268188d02f3495d4f748012fa38ed6f502
| 21,105,469,349,390 |
6a6b6f05f0d8e4b79ed959cc30d2520dc49c57d4
|
/src/main/java/com/xysd/internal_wf/domain/impl/StrTypeProcessVariable.java
|
486575076c16ad7a8da1da7e827ae8d90854af59
|
[] |
no_license
|
wyx6fox/shrimp
|
https://github.com/wyx6fox/shrimp
|
f5de0a798011b413230db241e49be7d9bc93f080
|
7ff2d335eadb248ea7f0713cd922a1f240806d36
|
refs/heads/master
| 2021-01-23T11:54:48.955000 | 2010-11-01T03:09:24 | 2010-11-01T03:09:24 | 971,767 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.xysd.internal_wf.domain.impl;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.xysd.internal_wf.domain.ProcessVariable;
@Entity
@Table(name = "wf_procvar")
public class StrTypeProcessVariable extends ProcessVariable {
private String id;
@Id
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Transient
public Serializable getId_Internal() {
return id;
}
@Transient
public void setId_Internal(Serializable id) {
this.id = id+"";
}
}
|
UTF-8
|
Java
| 629 |
java
|
StrTypeProcessVariable.java
|
Java
|
[] | null |
[] |
package com.xysd.internal_wf.domain.impl;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.xysd.internal_wf.domain.ProcessVariable;
@Entity
@Table(name = "wf_procvar")
public class StrTypeProcessVariable extends ProcessVariable {
private String id;
@Id
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Transient
public Serializable getId_Internal() {
return id;
}
@Transient
public void setId_Internal(Serializable id) {
this.id = id+"";
}
}
| 629 | 0.740858 | 0.740858 | 36 | 16.472221 | 17.028547 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.916667 | false | false |
13
|
a0e3b1027a0ad49b314e282cd46c8c688a93a84f
| 2,757,369,062,426 |
cc6f4ef611129fd2b86ce4db56a9faa7b4bebaee
|
/mps1/src/main/java/com/bigcho/mps/repository/AlbumRepository.java
|
78b08eddb539efd4fcd99f4fb0fd612a55f90d25
|
[] |
no_license
|
hycho/nahonza
|
https://github.com/hycho/nahonza
|
5397ccb2ada32e0454cd5a537ac402574639dac4
|
52779e3ab7812fb7cef89d9ba43f798eddcf7d3d
|
refs/heads/master
| 2021-01-23T20:46:29.076000 | 2015-03-05T04:51:49 | 2015-03-05T04:51:49 | 33,249,800 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.bigcho.mps.repository;
import java.util.Collection;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.bigcho.mps.entity.Album;
import com.bigcho.mps.entity.User;
@Repository
public interface AlbumRepository extends JpaRepository<Album, Long> {
Album findByAlbumId(String albumId);
}
|
UTF-8
|
Java
| 507 |
java
|
AlbumRepository.java
|
Java
|
[] | null |
[] |
package com.bigcho.mps.repository;
import java.util.Collection;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.bigcho.mps.entity.Album;
import com.bigcho.mps.entity.User;
@Repository
public interface AlbumRepository extends JpaRepository<Album, Long> {
Album findByAlbumId(String albumId);
}
| 507 | 0.828402 | 0.828402 | 18 | 27.166666 | 23.248058 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false |
13
|
408ee9d6c4fc2c31503c34cc6830badc8dccce4c
| 31,413,390,837,694 |
d6416d7c97ff4421077b62a26074c6cebab8ae87
|
/commonlib/src/main/java/com/wwzl/commonlib/arouter/RouterManager.java
|
b56036e3659e7b4f1d0ee7a3be832097db67239b
|
[] |
no_license
|
zhangcongmin/Android_Common
|
https://github.com/zhangcongmin/Android_Common
|
c22fc25e337c370d35daf6e677f98f34c4e264e8
|
e7bcfd7107876ad8c35a3e45047c2da1d6339542
|
refs/heads/master
| 2021-01-03T05:17:12.592000 | 2020-02-18T10:01:37 | 2020-02-18T10:01:37 | 239,937,880 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.wwzl.commonlib.arouter;
import android.content.Context;
import androidx.core.app.ActivityOptionsCompat;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.wwzl.commonlib.R;
/**
* 作者: created by zcm on 2018/11/22
* 修改: modified by zcm on 2018/11/22
* desc(给页面跳转增加左右专场动画)
*/
public class RouterManager {
public static Postcard getPostcard(String url){
Postcard postcard = ARouter.getInstance().build(url);
// postcard.navigation();
return postcard;
}
/**
* 添加无转场动画
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithNoneTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.none_animation,R.anim.none_animation));
return postcard;
}
/**
* 添加左右滑动转场动画
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithLRTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.slide_in_right,R.anim.slide_out_left));
return postcard;
}
/**
* 添加上下滑动转场动画 从顶部进入 主要用于HomeActivity 跳TopActivity
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithTBTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.enter_top,R.anim.exit_bottom));
return postcard;
}
/**
* 添加下上滑动转场动画 从底部进入 主要用于TopActivity 跳其他5个主模块
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithBTTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.enter_bottom,R.anim.exit_top));
return postcard;
}
}
|
UTF-8
|
Java
| 2,383 |
java
|
RouterManager.java
|
Java
|
[
{
"context": "mport com.wwzl.commonlib.R;\n\n/**\n * 作者: created by zcm on 2018/11/22\n * 修改: modified by zcm on 2018/11/2",
"end": 279,
"score": 0.9995383024215698,
"start": 276,
"tag": "USERNAME",
"value": "zcm"
},
{
"context": "者: created by zcm on 2018/11/22\n * 修改: modified by zcm on 2018/11/22\n * desc(给页面跳转增加左右专场动画)\n */\npublic c",
"end": 316,
"score": 0.9996107816696167,
"start": 313,
"tag": "USERNAME",
"value": "zcm"
}
] | null |
[] |
package com.wwzl.commonlib.arouter;
import android.content.Context;
import androidx.core.app.ActivityOptionsCompat;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.wwzl.commonlib.R;
/**
* 作者: created by zcm on 2018/11/22
* 修改: modified by zcm on 2018/11/22
* desc(给页面跳转增加左右专场动画)
*/
public class RouterManager {
public static Postcard getPostcard(String url){
Postcard postcard = ARouter.getInstance().build(url);
// postcard.navigation();
return postcard;
}
/**
* 添加无转场动画
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithNoneTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.none_animation,R.anim.none_animation));
return postcard;
}
/**
* 添加左右滑动转场动画
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithLRTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.slide_in_right,R.anim.slide_out_left));
return postcard;
}
/**
* 添加上下滑动转场动画 从顶部进入 主要用于HomeActivity 跳TopActivity
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithTBTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.enter_top,R.anim.exit_bottom));
return postcard;
}
/**
* 添加下上滑动转场动画 从底部进入 主要用于TopActivity 跳其他5个主模块
* @param context
* @param url
* @return
*/
public static Postcard getPostcardWithBTTransition(Context context, String url){
Postcard postcard = ARouter.getInstance().build(url).withOptionsCompat(ActivityOptionsCompat
.makeCustomAnimation(context, R.anim.enter_bottom,R.anim.exit_top));
return postcard;
}
}
| 2,383 | 0.677013 | 0.669366 | 72 | 29.875 | 31.200933 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.402778 | false | false |
13
|
c76ebda183de9a77792b3bab6888a9e5177d7ab1
| 2,911,987,835,793 |
353985f1a8ce2561acc86d76929ba649f21989d5
|
/src/main/java/io/pivotal/foodclient/controller/FoodClientController.java
|
27266a57e1d0b97d940bda717b3c5f325b835682
|
[] |
no_license
|
eggboy/foodclient-sleuth
|
https://github.com/eggboy/foodclient-sleuth
|
b04ba5227934aa82a31413a76046b0e3356d0f85
|
7fb4919bce9c4e41a9fc8324997c173fe2a81477
|
refs/heads/master
| 2020-04-22T03:12:15.608000 | 2019-02-11T06:14:11 | 2019-02-11T06:14:11 | 170,077,571 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package io.pivotal.foodclient.controller;
import io.pivotal.foodclient.domain.Food;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
public class FoodClientController {
@Value("${foodservice.url}")
private String URL;
@Autowired
RestTemplate restTemplate;
@GetMapping("/food/{id}")
public Food getFood(@PathVariable Integer id) {
return restTemplate.getForObject(URL + id, Food.class);
}
}
|
UTF-8
|
Java
| 754 |
java
|
FoodClientController.java
|
Java
|
[] | null |
[] |
package io.pivotal.foodclient.controller;
import io.pivotal.foodclient.domain.Food;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
public class FoodClientController {
@Value("${foodservice.url}")
private String URL;
@Autowired
RestTemplate restTemplate;
@GetMapping("/food/{id}")
public Food getFood(@PathVariable Integer id) {
return restTemplate.getForObject(URL + id, Food.class);
}
}
| 754 | 0.785146 | 0.785146 | 23 | 31.782608 | 23.108358 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.521739 | false | false |
13
|
48d8c0f3819f6c207dfc1d1c9cbde255186c25a8
| 10,677,288,704,867 |
fd6bdbac45ba54460de9460f0deab908ae80963f
|
/src/main/java/pack/admin/controller/MovieBean.java
|
9830f16f648a9e9ab04b583eae4f9f73859cfb85
|
[] |
no_license
|
lcg0826/spring_web_project
|
https://github.com/lcg0826/spring_web_project
|
c65b62c04407ae24d27199b3c90484595b284141
|
6a23387825e27a46ce5c0fec2e72c10418a6ca16
|
refs/heads/master
| 2023-01-23T02:45:27.787000 | 2020-12-06T08:07:46 | 2020-12-06T08:07:46 | 318,982,279 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package pack.admin.controller;
import org.springframework.web.multipart.MultipartFile;
public class MovieBean {
//영화 자료를 sql에 넣기 위한 bean 영화자료 생성, 수정시 필요
private String no,name,date,country,content,genre,director,preview,time,actor_name,image2,common;
private MultipartFile image; //파일 업로드를 위한 MultipartFile setter
public String getCommon() {
return common;
}
public void setCommon(String common) {
this.common = common;
}
public String getImage2() {
return image2;
}
public void setImage2(String image2) {
this.image2 = image2;
}
public MultipartFile getImage() {
return image;
}
public void setImage(MultipartFile image) {
this.image = image;
}
public void setActor_name(String actor_name) {
this.actor_name = actor_name;
}
public String getActor_name() {
return actor_name;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getPreview() {
return preview;
}
public void setPreview(String preview) {
this.preview = preview;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}
|
UTF-8
|
Java
| 1,933 |
java
|
MovieBean.java
|
Java
|
[] | null |
[] |
package pack.admin.controller;
import org.springframework.web.multipart.MultipartFile;
public class MovieBean {
//영화 자료를 sql에 넣기 위한 bean 영화자료 생성, 수정시 필요
private String no,name,date,country,content,genre,director,preview,time,actor_name,image2,common;
private MultipartFile image; //파일 업로드를 위한 MultipartFile setter
public String getCommon() {
return common;
}
public void setCommon(String common) {
this.common = common;
}
public String getImage2() {
return image2;
}
public void setImage2(String image2) {
this.image2 = image2;
}
public MultipartFile getImage() {
return image;
}
public void setImage(MultipartFile image) {
this.image = image;
}
public void setActor_name(String actor_name) {
this.actor_name = actor_name;
}
public String getActor_name() {
return actor_name;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getPreview() {
return preview;
}
public void setPreview(String preview) {
this.preview = preview;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}
| 1,933 | 0.6864 | 0.682667 | 125 | 14 | 16.984228 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.296 | false | false |
13
|
5b1186f52329543211f56a35b891eda26a55f73f
| 14,061,722,942,960 |
6f3634019562ce6f48b04537a5d188c6c9f022de
|
/Java/Projekt_IT_03/src/com/company/Main.java
|
52c86be3001197f8c07f7a6c8471f4e484ebe53f
|
[] |
no_license
|
mariajanzen/Java_Course_Advanced
|
https://github.com/mariajanzen/Java_Course_Advanced
|
7e7cc1c0fa833b3191739af68d78174b6b3c074c
|
3c76fd8c69df104790fb1348c53b14680eea1c61
|
refs/heads/master
| 2023-02-19T12:06:45.657000 | 2021-01-12T17:22:00 | 2021-01-12T17:22:00 | 297,412,567 | 0 | 2 | null | false | 2021-01-19T08:55:36 | 2020-09-21T17:29:29 | 2021-01-12T17:22:03 | 2021-01-19T08:54:58 | 3,259 | 0 | 1 | 2 |
Java
| false | false |
package com.company;
public class Main {
public static void main(String[] args) {
printHello( "Andrey");
printHello( "Irina");
printHello( "Maria");
String n="Jack";
printHello(n);
int z=mult(minus(100, 20),10);
System.out.println(z);
minus(1000, 120);
System.out.println(getHello() + " Jack");
if(n=="Jack"){
System.out.println("Jack the best");
} else{
System.out.println("Where is Jack");
};
}
public static void printHello(String name){
System.out.println("Hello " + name );
}
public static int minus(int a, int b) {
/*
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("a-b="+(a-b));
*/
return a-b;
}
public static int mult(int a, int b) {
return a*b;
}
public static String getHello(){
return "Привет!";
}
}
|
UTF-8
|
Java
| 986 |
java
|
Main.java
|
Java
|
[
{
"context": "c void main(String[] args) {\n printHello( \"Andrey\");\n printHello( \"Irina\");\n printHel",
"end": 115,
"score": 0.999788761138916,
"start": 109,
"tag": "NAME",
"value": "Andrey"
},
{
"context": " printHello( \"Andrey\");\n printHello( \"Irina\");\n printHello( \"Maria\");\n String n",
"end": 145,
"score": 0.9998325109481812,
"start": 140,
"tag": "NAME",
"value": "Irina"
},
{
"context": " printHello( \"Irina\");\n printHello( \"Maria\");\n String n=\"Jack\";\n printHello(n)",
"end": 175,
"score": 0.9998342394828796,
"start": 170,
"tag": "NAME",
"value": "Maria"
},
{
"context": ";\n printHello( \"Maria\");\n String n=\"Jack\";\n printHello(n);\n int z=mult(minus(",
"end": 201,
"score": 0.9137444496154785,
"start": 197,
"tag": "NAME",
"value": "Jack"
},
{
"context": " public static String getHello(){\n return \"Привет!\";\n }\n\n}\n",
"end": 967,
"score": 0.6962568163871765,
"start": 961,
"tag": "NAME",
"value": "Привет"
}
] | null |
[] |
package com.company;
public class Main {
public static void main(String[] args) {
printHello( "Andrey");
printHello( "Irina");
printHello( "Maria");
String n="Jack";
printHello(n);
int z=mult(minus(100, 20),10);
System.out.println(z);
minus(1000, 120);
System.out.println(getHello() + " Jack");
if(n=="Jack"){
System.out.println("Jack the best");
} else{
System.out.println("Where is Jack");
};
}
public static void printHello(String name){
System.out.println("Hello " + name );
}
public static int minus(int a, int b) {
/*
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("a-b="+(a-b));
*/
return a-b;
}
public static int mult(int a, int b) {
return a*b;
}
public static String getHello(){
return "Привет!";
}
}
| 986 | 0.508163 | 0.493878 | 45 | 20.777779 | 16.709131 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false |
13
|
1b92da2342edf92bae096623fbe1a9e80d1344b8
| 11,811,160,074,518 |
11968abfbfe936770c0e811f525bdff36f77d397
|
/x.SelfTasks/src/examplesCheck/L001_Serialize.java
|
2e0258d8c2cdd3298fe47eff5c31c902e78664c5
|
[] |
no_license
|
sunsey/JavaRush
|
https://github.com/sunsey/JavaRush
|
92f2e2bdc9029a694ba3ed957dc3dd377a67b05e
|
247fb80d0d82e6a3b585f7abac7cdee5317c44c1
|
refs/heads/master
| 2020-12-13T19:24:45.684000 | 2017-09-02T14:47:09 | 2017-09-02T14:47:09 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright (c) 2017. Код создан Д.Кляусом. Для использования кода в коммерческих продуктах - свяжитесь @ : deadlords@mail.ru
*/
package examplesCheck;
import java.io.*;
import static java.lang.System.out;
/**
* Работа с интерфейсами Serializable и Externazible
*
* в классе всякие пробы работ с интерфейсами сведены в методы, которые работают с различными внутренними классами.
* Например, startExternalizable - работа с Externalizable, который используется в классе SchemeExternalizable
*
* свод заметок вызывается методом help();
*
* todo: 1. в дальнейшем разгрести эту простыню и вынести в отдельные файлы все внутренние классы
* todo: 2. разобраться с кастом классов при загрузке. Пока каст потомка в родителя не работает, получаем потомка
* todo: 3. поработать с enum
*/
public class L001_Serialize {
public static void main(String[] args) throws Exception{
L001_Serialize srlz = new L001_Serialize();
//srlz.startSerializationTypicalScheme();
//srlz.startSerializationSingletonAndReadResolveMethod();
//srlz.startSerializationWithClassChanged();
//srlz.startSerializationNewClass(); //не пашет, потому что каст разных классов, сделать в отдельных классах реализацию обновлённого TestHuman
//srlz.startSerializationUsingSpecialHandling();
//srlz.startExternalizable();
//srlz.startSerializationCacheProblem();
help();
}
private void startSerializationCacheProblem() throws Exception{
String fileName = "cache_pr.slz";
CacheProblem cacheProblem = new CacheProblem();
FileOutputStream fos = new FileOutputStream(fileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
cacheProblem.setPriority(100);
oos.writeObject(cacheProblem);
cacheProblem.setPriority(200);
oos.writeObject(cacheProblem);
oos.flush();
{
oos.close();
fos.close(); //если я закрываю oos, то автоматически закрывается и fos (?) почему?
}
out.println(cacheProblem.getPriority());
FileInputStream fis = new FileInputStream(fileName);
ObjectInputStream ois = new ObjectInputStream(fis);
CacheProblem cacheProblemLoaded = (CacheProblem)ois.readObject();
CacheProblem cacheProblem1 = (CacheProblem)ois.readObject();
{
ois.close();
fis.close();
}
out.println(cacheProblemLoaded.getPriority());
out.println(cacheProblem1.getPriority());
}
private void startExternalizable() throws Exception{
out.println("======================================");
out.println("Реализация Externalizable");
out.println("======================================");
out.println("");
out.println("init...");
SchemeExternalizable extern = new SchemeExternalizable();
extern.setValue("save by Externalizable");
out.printf("Value == [%s]%n",extern.getValue());
out.println("saving...");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(baos);
oo.writeObject(extern);
{
oo.close();
baos.close(); //можно не делать, не имеет эффекта. https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html
}
out.println("loading...");
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream oi = new ObjectInputStream(bais);
out.println("init new...");
SchemeExternalizable externLoaded = (SchemeExternalizable)oi.readObject();
out.printf("Value == [%s]%n",extern.getValue());
{
oi.close();
bais.close(); //можно не делать, не имеет эффекта. https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html
}
}
private void startSerializationUsingSpecialHandling() throws Exception{
out.println("======================================");
out.println("Доп.настройки сериализации, определение");
out.println("методов readObject и writeObject в классе");
out.println("======================================");
out.println("");
out.println("creating objects...");
ChildDefault child1 = new ChildDefault(" :child without methods");
ChildWithSerializationMethods child2 = new ChildWithSerializationMethods(" :child with methods");
out.println("saving...");
out.printf("Child value == [%s]%n", child1.value);
out.printf("Child value == [%s]%n", child2.value);
FileOutputStream fileOutputStream = new FileOutputStream("special.slz");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(child1);
objectOutputStream.writeObject(child2);
objectOutputStream.flush();
{
objectOutputStream.close();
fileOutputStream.close();
}
FileInputStream fileInputStream = new FileInputStream("special.slz");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
out.println("creating new objects...");
ChildDefault child1Loaded = (ChildDefault)objectInputStream.readObject();
ChildWithSerializationMethods child2Loaded = (ChildWithSerializationMethods)objectInputStream.readObject();
out.println("loading...");
out.printf("Child value == [%s]%n", child1Loaded.value);
out.printf("Child value == [%s]%n", child2Loaded.value);
{
objectInputStream.close();
fileInputStream.close();
}
}
private void startSerializationNewClass() throws Exception{
out.println("======================================");
out.println("Сериализация потомков/родителей, проба в потомка передать родителя");
out.println("======================================");
out.println("");
String fileName = "method3.slz";
TestHuman human = new TestHuman("Odin", 1000f);
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(human);
{
objectOutputStream.close();
fileOutputStream.close();
}
FileInputStream fileInputStream = new FileInputStream(fileName);
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
TestHumanNew humanNew = (TestHumanNew)object;
{
objectInputStream.close();
fileInputStream.close();
}
out.println(human.equals(humanNew));
human.printAllGetMethodsAndStaticValues();
humanNew.printAllGetMethodsAndStaticValues();
}
private void startSerializationWithClassChanged() throws Exception {
out.println("======================================");
out.println("Сериализация потомков/родителей");
out.println("======================================");
out.println("");
TestHuman human = new TestHumanChanged("Vasilisa", 10f, false);
FileOutputStream fileOutputStream = new FileOutputStream("method2.slz");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(human);
{
objectOutputStream.close();
fileOutputStream.close();
}
human.printAllGetMethodsAndStaticValues();
FileInputStream fileInputStream = new FileInputStream("method2.slz");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
{
objectInputStream.close();
fileInputStream.close();
}
out.println(object.getClass().getCanonicalName());
out.println();
TestHuman humanC = (TestHuman)object; //в итоге всё равно класс TestHumanChanged
humanC.printAllGetMethodsAndStaticValues();
out.println(humanC.getClass().getCanonicalName());
out.println();
out.println(human.equals(humanC));
}
private void startSerializationTypicalScheme() throws Exception {
out.println("======================================");
out.println("Шаблон использования сериализации");
out.println("======================================");
out.println("");
TestHuman human = new TestHuman("Vasya", 10f);
human.printAllGetMethodsAndStaticValues(); //вывод всех значений объекта
//save
FileOutputStream fileOutput = new FileOutputStream("test.dat");
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
outputStream.writeObject(human);
fileOutput.close();
outputStream.close();
TestHuman.check = "changed";
//restore
FileInputStream fileInputStream = new FileInputStream("test.dat");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
fileInputStream.close();
objectInputStream.close();
TestHuman human1 = (TestHuman)object;
human1.printAllGetMethodsAndStaticValues();
out.println(human.equals(human1));
}
private void startSerializationSingletonAndReadResolveMethod() throws Exception {
out.println("======================================");
out.println("Шаблон использования синглтона,\n" +
"с перезаписью объекта (сохранением\n" +
"ссылки в памяти).");
out.println("======================================");
out.println("");
Singleton singleton = Singleton.getInstance();
FileOutputStream fileOutput = new FileOutputStream("singleton.dat");
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
outputStream.writeObject(singleton);
{
outputStream.close();
fileOutput.close();
}
FileInputStream fileInputStream = new FileInputStream("singleton.dat");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
{
objectInputStream.close();
fileInputStream.close();
}
Singleton singletonRestored = (Singleton)object;
singleton.printHashCodeAndInstanceRef();
singletonRestored.printHashCodeAndInstanceRef();
/*
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInputStream objectInputStream1 = new ObjectInputStream(byteArrayInputStream);
// Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
// https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html
*/
}
static class Singleton implements Serializable{
private static Singleton singletonInstance;
public static Singleton getInstance() {
if(singletonInstance==null) singletonInstance = new Singleton();
return singletonInstance;
}
private Singleton(){}
public Object readResolve() throws ObjectStreamException{return singletonInstance;}
public void printHashCodeAndInstanceRef(){
out.println(hashCode());
out.println(this);
}
}
static class TestHuman implements Serializable {
private static final long SerialVersionUID = 1000L;
private String name = "";
private float age = 0.1f;
private static String check = "original";
transient private PrintStream stream = System.out; //not serializableS
private TestHuman(){}
public TestHuman(String name){ this.name = name;}
public TestHuman(String name, float age){ this.name = name;this.age = age; }
public String getName(){ return this.name; }
public float getAge(){
return this.age;
}
public void setName(String name){this.name=name;}
public void setAge(float age){this.age = age;}
public void printAllGetMethodsAndStaticValues(){
out.println("Hash: \t" + hashCode());
out.println("Name: \t" + getName());
out.println("Age: \t" + getAge());
out.println("Static:\t" + check);
}
public boolean equals(Object o){
System.out.printf("Сохранённый класс %s равен загруженному %s: ", this.getClass().getSimpleName(), o.getClass().getSimpleName());
if(this == o) return true;
if(o==null||getClass()!=getClass()) return false;
TestHuman human = (TestHuman)o;
if(name!=null? !name.equals(human.name):name!=null) return false;
return age!=0?age==human.age:age!=0;
}
}
static class TestHumanChanged extends TestHuman {
private static final long SerialVersionUID = 1001L;
private boolean sexMale = true;
TestHumanChanged(String name){super(name);}
TestHumanChanged(String name, float age){super(name, age);}
TestHumanChanged(String name, float age, boolean sexMale){super(name, age); this.sexMale = sexMale;}
public boolean getSexMale(){return sexMale;}
public void setSexMale(boolean sexMale){this.sexMale = sexMale;}
@Override
public void printAllGetMethodsAndStaticValues() {
super.printAllGetMethodsAndStaticValues();
out.println("Male: \t" + sexMale);
}
@Override
public boolean equals(Object o) {
TestHumanChanged thc = (TestHumanChanged)o;
return super.equals(o)?sexMale==thc.sexMale:false;
}
}
static class TestHumanNew implements Serializable {
private static final long SerialVersionUID = 1000L;
private String name = "";
private float age = 0.1f;
private static String check = "original";
transient private PrintStream stream = System.out; //not serializableS
private boolean sexMale = true;
private TestHumanNew(){}
public TestHumanNew(String name){ this.name = name;}
public TestHumanNew(String name, float age){ this.name = name;this.age = age; }
public TestHumanNew(String name, float age, boolean sexMale){this.name = name;this.age = age; this.sexMale = sexMale;}
public String getName(){ return this.name; }
public float getAge(){
return this.age;
}
public boolean getSexMale(){return sexMale;}
public void setName(String name){this.name=name;}
public void setAge(float age){this.age = age;}
public void setSexMale(boolean sexMale){this.sexMale = sexMale;}
public void printAllGetMethodsAndStaticValues(){
out.println("Hash: \t" + hashCode());
out.println("Name: \t" + getName());
out.println("Age: \t" + getAge());
out.println("Static:\t" + check);
out.println("Male: \t" + sexMale);
}
}
//реализация своих подходов при Сериализации
//
//При стандартной сериализации изменённое значение не сохраняется, поскольку
//у потомков value наследуется из Parent (Parent не сериализуется).
//В расширенной сериализации - сохраняем состояние value класса потомка и возвращаем обратно(?)
//родительский класс с одной переменной, её значение изменяется потомками.
static class Parent {
protected String value = "\"parent string value\"";
public Parent(){
out.printf("Parent value == [%s]. Class: [%s]%n" , this.value ,this.getClass().getSimpleName());
}
}
//стандартная сериализация класса
static class ChildDefault extends Parent implements Serializable{
public ChildDefault(String value){
this.value +=value;
}
}
//сериализация с дополнительной реализацией методов writeObject и readObject
static class ChildWithSerializationMethods extends Parent implements Serializable{
public ChildWithSerializationMethods(String value){
this.value +=value;
}
private void writeObject(ObjectOutputStream oos) throws IOException{
oos.defaultWriteObject();
oos.writeObject(this.value);
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException{
ois.defaultReadObject();
this.value = (String)ois.readObject();
}
}
//Шаблон экстернализации
static class SchemeExternalizable implements Externalizable{
private String value = "";
//конструктор без параметров обязателен при экстернализации
//при десериализации он запускается первым, а потом загружаются сохранённые объекты
public SchemeExternalizable(){
out.println("..basic constructor..");
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
public void writeExternal(ObjectOutput oo)
throws IOException{
oo.writeObject(this.value);
}
public void readExternal(ObjectInput oi)
throws IOException, ClassNotFoundException{
this.value = oi.readLine(); //метод readLine в ObjectInputStream явялется устаревшим, тут нет. Возможно в дальнейшем.
}
}
static class CacheProblem implements Serializable{
private int priority;
public void setPriority(int priority){
this.priority = priority;
}
public int getPriority(){
return priority;
}
}
static void help(){
out.println("=============================================================");
out.println("(De)Serializable / Externalizable learning");
out.println();
out.println("URL to Oracle Doc: ");
out.println("Serializable: \thttps://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html");
out.println("Externalizable: \thttps://docs.oracle.com/javase/7/docs/api/java/io/Externalizable.html");
out.println("ObjectOutputStream:\thttps://docs.oracle.com/javase/8/docs/platform/serialization/spec/output.html");
out.println();
out.println("0. Необходимо подключить интерфейс Serializable");
out.println("1. Cтат. переменные не сохраняются");
out.println("2. Потоки и объекты которые их содержат вызовут ошибку NotSerializableException,");
out.println(" нужно использовать модификатор transient");
out.println("3. Для замены объекта (сохранение ссылки в памяти) при десериализации, в сериализуемый класс должен быть добавлен");
out.println(" метод \"Object readResolve()\". Пока видел реализацию через Singleton, метод private; возвращается ссылка на Singleton ");
out.println("4. Класс-потомок наследует интерфейс Serializable");
out.println("5. Можно сохранить класс-потомок и загрузить как родительский класс");
out.println("6. При десериализации потомка вызывается конструктор без параметров Род.класса (если он не сериализован), если такого конструкта нет - ошибка сериализации ");
out.println("7. При экстернализации сначала вызывается конструктор без параметров сериализуемого класса, а потом подгружаются данные. ");
out.println("8. Компилятор формирует значение serialVersionUID в зависимости от структуры сериализуемого объекта, есть вероятность изменения значения в зависимости от версии компилятора.\n" +
" Рекомендуется сериализованному классу добавлять private static final long serialVersionUID. В SDK есть утилита serialver, которая поможет сформировать реальный svUID.\n" +
" http://skipy.ru/technics/serialization.html");
out.println("9. Если необходимы особые подходы при обычной сериализации, то должны быть реализованы методы: \n" +
" - private void readObject() throws IOException, ClassNotFoundException, \n" +
" - private void writeObject() throws IOException, \n" +
" - private void readObjectNoData() throws ObjectStreamException\n" +
" с другими модификаторами доступа (default, protected, public) методы не работают (не выбрасывают ошибку, просто не вызываются).");
out.println("10. Интерфейс Externalizable - потомок Serializable. Для экстернализации в классе реализуются public методы writeExternal(ObjectOutput o) и readExternal(ObjectInput i)");
out.println("11. Если класс реализует два интерфейса Externalizable и Serializable, то приоритетным является Externalizable");
out.println("12. Вариант запрета сериализации - реализовать методы readObject и writeObject c выбросом ошибки NotSerializableException");
}
}
|
UTF-8
|
Java
| 24,196 |
java
|
L001_Serialize.java
|
Java
|
[
{
"context": "/*\n * Copyright (c) 2017. Код создан Д.Кляусом. Для использования кода в коммерческих продуктах ",
"end": 46,
"score": 0.6986117362976074,
"start": 39,
"tag": "NAME",
"value": "Кляусом"
},
{
"context": "ания кода в коммерческих продуктах - свяжитесь @ : deadlords@mail.ru\n */\n\npackage examplesCheck;\n\nimport java.io.*;\nim",
"end": 129,
"score": 0.9999314546585083,
"start": 112,
"tag": "EMAIL",
"value": "deadlords@mail.ru"
},
{
"context": "3.slz\";\n\n TestHuman human = new TestHuman(\"Odin\", 1000f);\n FileOutputStream fileOutputStre",
"end": 6145,
"score": 0.9984586238861084,
"start": 6141,
"tag": "NAME",
"value": "Odin"
},
{
"context": "\n\n TestHuman human = new TestHumanChanged(\"Vasilisa\", 10f, false);\n\n FileOutputStream fileOutp",
"end": 7332,
"score": 0.9997178912162781,
"start": 7324,
"tag": "NAME",
"value": "Vasilisa"
},
{
"context": "(\"\");\n\n TestHuman human = new TestHuman(\"Vasya\", 10f);\n human.printAllGetMethodsAndStatic",
"end": 8723,
"score": 0.9995908737182617,
"start": 8718,
"tag": "NAME",
"value": "Vasya"
}
] | null |
[] |
/*
* Copyright (c) 2017. Код создан Д.Кляусом. Для использования кода в коммерческих продуктах - свяжитесь @ : <EMAIL>
*/
package examplesCheck;
import java.io.*;
import static java.lang.System.out;
/**
* Работа с интерфейсами Serializable и Externazible
*
* в классе всякие пробы работ с интерфейсами сведены в методы, которые работают с различными внутренними классами.
* Например, startExternalizable - работа с Externalizable, который используется в классе SchemeExternalizable
*
* свод заметок вызывается методом help();
*
* todo: 1. в дальнейшем разгрести эту простыню и вынести в отдельные файлы все внутренние классы
* todo: 2. разобраться с кастом классов при загрузке. Пока каст потомка в родителя не работает, получаем потомка
* todo: 3. поработать с enum
*/
public class L001_Serialize {
public static void main(String[] args) throws Exception{
L001_Serialize srlz = new L001_Serialize();
//srlz.startSerializationTypicalScheme();
//srlz.startSerializationSingletonAndReadResolveMethod();
//srlz.startSerializationWithClassChanged();
//srlz.startSerializationNewClass(); //не пашет, потому что каст разных классов, сделать в отдельных классах реализацию обновлённого TestHuman
//srlz.startSerializationUsingSpecialHandling();
//srlz.startExternalizable();
//srlz.startSerializationCacheProblem();
help();
}
private void startSerializationCacheProblem() throws Exception{
String fileName = "cache_pr.slz";
CacheProblem cacheProblem = new CacheProblem();
FileOutputStream fos = new FileOutputStream(fileName);
ObjectOutputStream oos = new ObjectOutputStream(fos);
cacheProblem.setPriority(100);
oos.writeObject(cacheProblem);
cacheProblem.setPriority(200);
oos.writeObject(cacheProblem);
oos.flush();
{
oos.close();
fos.close(); //если я закрываю oos, то автоматически закрывается и fos (?) почему?
}
out.println(cacheProblem.getPriority());
FileInputStream fis = new FileInputStream(fileName);
ObjectInputStream ois = new ObjectInputStream(fis);
CacheProblem cacheProblemLoaded = (CacheProblem)ois.readObject();
CacheProblem cacheProblem1 = (CacheProblem)ois.readObject();
{
ois.close();
fis.close();
}
out.println(cacheProblemLoaded.getPriority());
out.println(cacheProblem1.getPriority());
}
private void startExternalizable() throws Exception{
out.println("======================================");
out.println("Реализация Externalizable");
out.println("======================================");
out.println("");
out.println("init...");
SchemeExternalizable extern = new SchemeExternalizable();
extern.setValue("save by Externalizable");
out.printf("Value == [%s]%n",extern.getValue());
out.println("saving...");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(baos);
oo.writeObject(extern);
{
oo.close();
baos.close(); //можно не делать, не имеет эффекта. https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html
}
out.println("loading...");
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream oi = new ObjectInputStream(bais);
out.println("init new...");
SchemeExternalizable externLoaded = (SchemeExternalizable)oi.readObject();
out.printf("Value == [%s]%n",extern.getValue());
{
oi.close();
bais.close(); //можно не делать, не имеет эффекта. https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayInputStream.html
}
}
private void startSerializationUsingSpecialHandling() throws Exception{
out.println("======================================");
out.println("Доп.настройки сериализации, определение");
out.println("методов readObject и writeObject в классе");
out.println("======================================");
out.println("");
out.println("creating objects...");
ChildDefault child1 = new ChildDefault(" :child without methods");
ChildWithSerializationMethods child2 = new ChildWithSerializationMethods(" :child with methods");
out.println("saving...");
out.printf("Child value == [%s]%n", child1.value);
out.printf("Child value == [%s]%n", child2.value);
FileOutputStream fileOutputStream = new FileOutputStream("special.slz");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(child1);
objectOutputStream.writeObject(child2);
objectOutputStream.flush();
{
objectOutputStream.close();
fileOutputStream.close();
}
FileInputStream fileInputStream = new FileInputStream("special.slz");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
out.println("creating new objects...");
ChildDefault child1Loaded = (ChildDefault)objectInputStream.readObject();
ChildWithSerializationMethods child2Loaded = (ChildWithSerializationMethods)objectInputStream.readObject();
out.println("loading...");
out.printf("Child value == [%s]%n", child1Loaded.value);
out.printf("Child value == [%s]%n", child2Loaded.value);
{
objectInputStream.close();
fileInputStream.close();
}
}
private void startSerializationNewClass() throws Exception{
out.println("======================================");
out.println("Сериализация потомков/родителей, проба в потомка передать родителя");
out.println("======================================");
out.println("");
String fileName = "method3.slz";
TestHuman human = new TestHuman("Odin", 1000f);
FileOutputStream fileOutputStream = new FileOutputStream(fileName);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(human);
{
objectOutputStream.close();
fileOutputStream.close();
}
FileInputStream fileInputStream = new FileInputStream(fileName);
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
TestHumanNew humanNew = (TestHumanNew)object;
{
objectInputStream.close();
fileInputStream.close();
}
out.println(human.equals(humanNew));
human.printAllGetMethodsAndStaticValues();
humanNew.printAllGetMethodsAndStaticValues();
}
private void startSerializationWithClassChanged() throws Exception {
out.println("======================================");
out.println("Сериализация потомков/родителей");
out.println("======================================");
out.println("");
TestHuman human = new TestHumanChanged("Vasilisa", 10f, false);
FileOutputStream fileOutputStream = new FileOutputStream("method2.slz");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
objectOutputStream.writeObject(human);
{
objectOutputStream.close();
fileOutputStream.close();
}
human.printAllGetMethodsAndStaticValues();
FileInputStream fileInputStream = new FileInputStream("method2.slz");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
{
objectInputStream.close();
fileInputStream.close();
}
out.println(object.getClass().getCanonicalName());
out.println();
TestHuman humanC = (TestHuman)object; //в итоге всё равно класс TestHumanChanged
humanC.printAllGetMethodsAndStaticValues();
out.println(humanC.getClass().getCanonicalName());
out.println();
out.println(human.equals(humanC));
}
private void startSerializationTypicalScheme() throws Exception {
out.println("======================================");
out.println("Шаблон использования сериализации");
out.println("======================================");
out.println("");
TestHuman human = new TestHuman("Vasya", 10f);
human.printAllGetMethodsAndStaticValues(); //вывод всех значений объекта
//save
FileOutputStream fileOutput = new FileOutputStream("test.dat");
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
outputStream.writeObject(human);
fileOutput.close();
outputStream.close();
TestHuman.check = "changed";
//restore
FileInputStream fileInputStream = new FileInputStream("test.dat");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
fileInputStream.close();
objectInputStream.close();
TestHuman human1 = (TestHuman)object;
human1.printAllGetMethodsAndStaticValues();
out.println(human.equals(human1));
}
private void startSerializationSingletonAndReadResolveMethod() throws Exception {
out.println("======================================");
out.println("Шаблон использования синглтона,\n" +
"с перезаписью объекта (сохранением\n" +
"ссылки в памяти).");
out.println("======================================");
out.println("");
Singleton singleton = Singleton.getInstance();
FileOutputStream fileOutput = new FileOutputStream("singleton.dat");
ObjectOutputStream outputStream = new ObjectOutputStream(fileOutput);
outputStream.writeObject(singleton);
{
outputStream.close();
fileOutput.close();
}
FileInputStream fileInputStream = new FileInputStream("singleton.dat");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Object object = objectInputStream.readObject();
{
objectInputStream.close();
fileInputStream.close();
}
Singleton singletonRestored = (Singleton)object;
singleton.printHashCodeAndInstanceRef();
singletonRestored.printHashCodeAndInstanceRef();
/*
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
ObjectInputStream objectInputStream1 = new ObjectInputStream(byteArrayInputStream);
// Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
// https://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html
*/
}
static class Singleton implements Serializable{
private static Singleton singletonInstance;
public static Singleton getInstance() {
if(singletonInstance==null) singletonInstance = new Singleton();
return singletonInstance;
}
private Singleton(){}
public Object readResolve() throws ObjectStreamException{return singletonInstance;}
public void printHashCodeAndInstanceRef(){
out.println(hashCode());
out.println(this);
}
}
static class TestHuman implements Serializable {
private static final long SerialVersionUID = 1000L;
private String name = "";
private float age = 0.1f;
private static String check = "original";
transient private PrintStream stream = System.out; //not serializableS
private TestHuman(){}
public TestHuman(String name){ this.name = name;}
public TestHuman(String name, float age){ this.name = name;this.age = age; }
public String getName(){ return this.name; }
public float getAge(){
return this.age;
}
public void setName(String name){this.name=name;}
public void setAge(float age){this.age = age;}
public void printAllGetMethodsAndStaticValues(){
out.println("Hash: \t" + hashCode());
out.println("Name: \t" + getName());
out.println("Age: \t" + getAge());
out.println("Static:\t" + check);
}
public boolean equals(Object o){
System.out.printf("Сохранённый класс %s равен загруженному %s: ", this.getClass().getSimpleName(), o.getClass().getSimpleName());
if(this == o) return true;
if(o==null||getClass()!=getClass()) return false;
TestHuman human = (TestHuman)o;
if(name!=null? !name.equals(human.name):name!=null) return false;
return age!=0?age==human.age:age!=0;
}
}
static class TestHumanChanged extends TestHuman {
private static final long SerialVersionUID = 1001L;
private boolean sexMale = true;
TestHumanChanged(String name){super(name);}
TestHumanChanged(String name, float age){super(name, age);}
TestHumanChanged(String name, float age, boolean sexMale){super(name, age); this.sexMale = sexMale;}
public boolean getSexMale(){return sexMale;}
public void setSexMale(boolean sexMale){this.sexMale = sexMale;}
@Override
public void printAllGetMethodsAndStaticValues() {
super.printAllGetMethodsAndStaticValues();
out.println("Male: \t" + sexMale);
}
@Override
public boolean equals(Object o) {
TestHumanChanged thc = (TestHumanChanged)o;
return super.equals(o)?sexMale==thc.sexMale:false;
}
}
static class TestHumanNew implements Serializable {
private static final long SerialVersionUID = 1000L;
private String name = "";
private float age = 0.1f;
private static String check = "original";
transient private PrintStream stream = System.out; //not serializableS
private boolean sexMale = true;
private TestHumanNew(){}
public TestHumanNew(String name){ this.name = name;}
public TestHumanNew(String name, float age){ this.name = name;this.age = age; }
public TestHumanNew(String name, float age, boolean sexMale){this.name = name;this.age = age; this.sexMale = sexMale;}
public String getName(){ return this.name; }
public float getAge(){
return this.age;
}
public boolean getSexMale(){return sexMale;}
public void setName(String name){this.name=name;}
public void setAge(float age){this.age = age;}
public void setSexMale(boolean sexMale){this.sexMale = sexMale;}
public void printAllGetMethodsAndStaticValues(){
out.println("Hash: \t" + hashCode());
out.println("Name: \t" + getName());
out.println("Age: \t" + getAge());
out.println("Static:\t" + check);
out.println("Male: \t" + sexMale);
}
}
//реализация своих подходов при Сериализации
//
//При стандартной сериализации изменённое значение не сохраняется, поскольку
//у потомков value наследуется из Parent (Parent не сериализуется).
//В расширенной сериализации - сохраняем состояние value класса потомка и возвращаем обратно(?)
//родительский класс с одной переменной, её значение изменяется потомками.
static class Parent {
protected String value = "\"parent string value\"";
public Parent(){
out.printf("Parent value == [%s]. Class: [%s]%n" , this.value ,this.getClass().getSimpleName());
}
}
//стандартная сериализация класса
static class ChildDefault extends Parent implements Serializable{
public ChildDefault(String value){
this.value +=value;
}
}
//сериализация с дополнительной реализацией методов writeObject и readObject
static class ChildWithSerializationMethods extends Parent implements Serializable{
public ChildWithSerializationMethods(String value){
this.value +=value;
}
private void writeObject(ObjectOutputStream oos) throws IOException{
oos.defaultWriteObject();
oos.writeObject(this.value);
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException{
ois.defaultReadObject();
this.value = (String)ois.readObject();
}
}
//Шаблон экстернализации
static class SchemeExternalizable implements Externalizable{
private String value = "";
//конструктор без параметров обязателен при экстернализации
//при десериализации он запускается первым, а потом загружаются сохранённые объекты
public SchemeExternalizable(){
out.println("..basic constructor..");
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
public void writeExternal(ObjectOutput oo)
throws IOException{
oo.writeObject(this.value);
}
public void readExternal(ObjectInput oi)
throws IOException, ClassNotFoundException{
this.value = oi.readLine(); //метод readLine в ObjectInputStream явялется устаревшим, тут нет. Возможно в дальнейшем.
}
}
static class CacheProblem implements Serializable{
private int priority;
public void setPriority(int priority){
this.priority = priority;
}
public int getPriority(){
return priority;
}
}
static void help(){
out.println("=============================================================");
out.println("(De)Serializable / Externalizable learning");
out.println();
out.println("URL to Oracle Doc: ");
out.println("Serializable: \thttps://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html");
out.println("Externalizable: \thttps://docs.oracle.com/javase/7/docs/api/java/io/Externalizable.html");
out.println("ObjectOutputStream:\thttps://docs.oracle.com/javase/8/docs/platform/serialization/spec/output.html");
out.println();
out.println("0. Необходимо подключить интерфейс Serializable");
out.println("1. Cтат. переменные не сохраняются");
out.println("2. Потоки и объекты которые их содержат вызовут ошибку NotSerializableException,");
out.println(" нужно использовать модификатор transient");
out.println("3. Для замены объекта (сохранение ссылки в памяти) при десериализации, в сериализуемый класс должен быть добавлен");
out.println(" метод \"Object readResolve()\". Пока видел реализацию через Singleton, метод private; возвращается ссылка на Singleton ");
out.println("4. Класс-потомок наследует интерфейс Serializable");
out.println("5. Можно сохранить класс-потомок и загрузить как родительский класс");
out.println("6. При десериализации потомка вызывается конструктор без параметров Род.класса (если он не сериализован), если такого конструкта нет - ошибка сериализации ");
out.println("7. При экстернализации сначала вызывается конструктор без параметров сериализуемого класса, а потом подгружаются данные. ");
out.println("8. Компилятор формирует значение serialVersionUID в зависимости от структуры сериализуемого объекта, есть вероятность изменения значения в зависимости от версии компилятора.\n" +
" Рекомендуется сериализованному классу добавлять private static final long serialVersionUID. В SDK есть утилита serialver, которая поможет сформировать реальный svUID.\n" +
" http://skipy.ru/technics/serialization.html");
out.println("9. Если необходимы особые подходы при обычной сериализации, то должны быть реализованы методы: \n" +
" - private void readObject() throws IOException, ClassNotFoundException, \n" +
" - private void writeObject() throws IOException, \n" +
" - private void readObjectNoData() throws ObjectStreamException\n" +
" с другими модификаторами доступа (default, protected, public) методы не работают (не выбрасывают ошибку, просто не вызываются).");
out.println("10. Интерфейс Externalizable - потомок Serializable. Для экстернализации в классе реализуются public методы writeExternal(ObjectOutput o) и readExternal(ObjectInput i)");
out.println("11. Если класс реализует два интерфейса Externalizable и Serializable, то приоритетным является Externalizable");
out.println("12. Вариант запрета сериализации - реализовать методы readObject и writeObject c выбросом ошибки NotSerializableException");
}
}
| 24,186 | 0.643668 | 0.639544 | 519 | 40.58189 | 37.125168 | 199 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.635838 | false | false |
13
|
df19fc820607105b9c0d7af12ad7268a35963ac1
| 9,079,560,916,218 |
9eab523f2019a5cee0a01aca8fa294c87307f994
|
/BigDataProject/src/main/java/ar/bigdata/analisis/dao/mongo/TwitterDaoMongo.java
|
390e206301e2a9539dccd23a5e15de2da7141497
|
[] |
no_license
|
gustavobustos/bigdata-utn
|
https://github.com/gustavobustos/bigdata-utn
|
7abaa016540bfbcae8c405251b8bfa40de8cf1a9
|
064573da4a847c74f29cef75762f080f243d2edb
|
refs/heads/master
| 2021-01-19T22:21:35.957000 | 2017-06-25T23:22:34 | 2017-06-25T23:22:34 | 88,799,767 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package ar.bigdata.analisis.dao.mongo;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ar.bigdata.analisis.dao.TwitterDao;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Projections;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.result.UpdateResult;
public class TwitterDaoMongo implements TwitterDao {
private final Logger log = LoggerFactory.getLogger(TwitterDaoMongo.class);
private String dbName;
private MongoClient mongoClient;
public TwitterDaoMongo (String dbName, String host, int port) {
this.dbName = dbName;
this.mongoClient = new MongoClient(host, port);
}
public MongoDatabase getDatabase() {
MongoDatabase mongoDb = mongoClient.getDatabase(dbName);
return mongoDb;
}
public void findAll(String dbCollectionName) {
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = collection.find().iterator();
try {
while (cursor.hasNext()) {
log.info(cursor.next().toJson());
}
} finally {
cursor.close();
}
}
public Set<String> projectionByAttribute(String dbCollectionName, String attribute) {
Set<String> set = new HashSet<String>();
MongoCursor<Document> cursor = projectionByAttributes(dbCollectionName, null,attribute);
try {
while (cursor.hasNext()) {
String jsonField = cursor.next().get(attribute).toString();
set.add(jsonField);
}
} finally {
cursor.close();
}
if(log.isDebugEnabled()) {
log.info("fetching: " + set);
}
return set;
}
public List<String> getSingleProjectionByFilterKeyValue(String dbCollectionName, String projectionFieldKey, String filterKey, String filterValue ) {
List<String> list = new ArrayList<String>();
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = collection.find(Filters.eq(filterKey, filterValue)).iterator();
try {
while (cursor.hasNext()) {
String jsonField = cursor.next().get(projectionFieldKey).toString();
list.add(jsonField);
}
} finally {
cursor.close();
}
if(log.isDebugEnabled()) {
log.info("fetching: " + list);
}
return list;
}
public MongoCursor<Document> projectionByAttributes(String dbCollectionName, Map<String, Object> filter, String... attributes) {
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = null;
if (filter != null) {
Bson bsonFilter = new Document(filter);
cursor = collection.find(bsonFilter).projection(Projections.include(attributes)).iterator();
} else {
cursor = collection.find().projection(Projections.include(attributes)).iterator();
}
return cursor;
}
public MongoCollection<Document> getDBCollection(String dbCollectionName) {
MongoDatabase mongoDb = getDatabase();
MongoCollection<Document> collection = mongoDb.getCollection(dbCollectionName);
return collection;
}
public static void main(String[] args) {
TwitterDaoMongo test = new TwitterDaoMongo("testdb","localhost", 27017);
//test.getConnection();
}
public void insertTweet(String collectionName, Document document) {
MongoCollection<Document> collection = getDBCollection(collectionName);
collection.insertOne(document);
}
public void insertManyTweets(String collectionName, List<Document> documents) {
MongoCollection<Document> collection = getDBCollection(collectionName);
collection.insertMany(documents);
}
public UpdateResult updateCollectionTweets(String collectionName, Bson bsonFilter, Document document) {
MongoCollection<Document> collection = getDBCollection(collectionName);
UpdateResult result = collection.updateOne(bsonFilter, document);
return result;
}
public UpdateResult updateCollectionTweets(String collectionName, Bson bsonFilter, Document document, UpdateOptions updateOptions) {
MongoCollection<Document> collection = getDBCollection(collectionName);
UpdateResult result = collection.updateOne(bsonFilter, document, updateOptions);
return result;
}
}
|
UTF-8
|
Java
| 4,456 |
java
|
TwitterDaoMongo.java
|
Java
|
[] | null |
[] |
package ar.bigdata.analisis.dao.mongo;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ar.bigdata.analisis.dao.TwitterDao;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Projections;
import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.result.UpdateResult;
public class TwitterDaoMongo implements TwitterDao {
private final Logger log = LoggerFactory.getLogger(TwitterDaoMongo.class);
private String dbName;
private MongoClient mongoClient;
public TwitterDaoMongo (String dbName, String host, int port) {
this.dbName = dbName;
this.mongoClient = new MongoClient(host, port);
}
public MongoDatabase getDatabase() {
MongoDatabase mongoDb = mongoClient.getDatabase(dbName);
return mongoDb;
}
public void findAll(String dbCollectionName) {
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = collection.find().iterator();
try {
while (cursor.hasNext()) {
log.info(cursor.next().toJson());
}
} finally {
cursor.close();
}
}
public Set<String> projectionByAttribute(String dbCollectionName, String attribute) {
Set<String> set = new HashSet<String>();
MongoCursor<Document> cursor = projectionByAttributes(dbCollectionName, null,attribute);
try {
while (cursor.hasNext()) {
String jsonField = cursor.next().get(attribute).toString();
set.add(jsonField);
}
} finally {
cursor.close();
}
if(log.isDebugEnabled()) {
log.info("fetching: " + set);
}
return set;
}
public List<String> getSingleProjectionByFilterKeyValue(String dbCollectionName, String projectionFieldKey, String filterKey, String filterValue ) {
List<String> list = new ArrayList<String>();
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = collection.find(Filters.eq(filterKey, filterValue)).iterator();
try {
while (cursor.hasNext()) {
String jsonField = cursor.next().get(projectionFieldKey).toString();
list.add(jsonField);
}
} finally {
cursor.close();
}
if(log.isDebugEnabled()) {
log.info("fetching: " + list);
}
return list;
}
public MongoCursor<Document> projectionByAttributes(String dbCollectionName, Map<String, Object> filter, String... attributes) {
MongoCollection<Document> collection = getDBCollection(dbCollectionName);
MongoCursor<Document> cursor = null;
if (filter != null) {
Bson bsonFilter = new Document(filter);
cursor = collection.find(bsonFilter).projection(Projections.include(attributes)).iterator();
} else {
cursor = collection.find().projection(Projections.include(attributes)).iterator();
}
return cursor;
}
public MongoCollection<Document> getDBCollection(String dbCollectionName) {
MongoDatabase mongoDb = getDatabase();
MongoCollection<Document> collection = mongoDb.getCollection(dbCollectionName);
return collection;
}
public static void main(String[] args) {
TwitterDaoMongo test = new TwitterDaoMongo("testdb","localhost", 27017);
//test.getConnection();
}
public void insertTweet(String collectionName, Document document) {
MongoCollection<Document> collection = getDBCollection(collectionName);
collection.insertOne(document);
}
public void insertManyTweets(String collectionName, List<Document> documents) {
MongoCollection<Document> collection = getDBCollection(collectionName);
collection.insertMany(documents);
}
public UpdateResult updateCollectionTweets(String collectionName, Bson bsonFilter, Document document) {
MongoCollection<Document> collection = getDBCollection(collectionName);
UpdateResult result = collection.updateOne(bsonFilter, document);
return result;
}
public UpdateResult updateCollectionTweets(String collectionName, Bson bsonFilter, Document document, UpdateOptions updateOptions) {
MongoCollection<Document> collection = getDBCollection(collectionName);
UpdateResult result = collection.updateOne(bsonFilter, document, updateOptions);
return result;
}
}
| 4,456 | 0.752693 | 0.751122 | 155 | 27.748386 | 31.430946 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.070968 | false | false |
13
|
dc8ffd44b6be1d297d634cda71417b9fe93b6eff
| 14,448,270,034,772 |
c98559715fe149d832d63fad20cce55fdd49ad19
|
/app/src/it/java/com/springapp/mvc/DAO/OrganizationIntegrationTest.java
|
dab223b3d1331797ed93c3166a6bd18cf54c81a7
|
[] |
no_license
|
alexlivenson/spring-ex
|
https://github.com/alexlivenson/spring-ex
|
01bbd8fc44ed92bebb3930da6e89dd355aaa2cb6
|
8608b4a71f5914a63e1708c49f43e3fbec8d745f
|
refs/heads/master
| 2021-01-18T11:07:48.151000 | 2015-01-27T19:17:19 | 2015-01-27T19:18:28 | 29,640,137 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.springapp.mvc.DAO;
import com.springapp.config.TestAppConfig;
import com.springapp.mvc.dao.IOrganizationCustomRepository;
import com.springapp.mvc.dao.IOrganizationRepository;
import com.springapp.mvc.model.Organization;
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;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = TestAppConfig.class)
public class OrganizationIntegrationTest {
// EnableJpaRepositories("com.springapp.mvc.dao") helps find the repo
@Autowired
IOrganizationRepository repository;
// Have to create a custom repository that will implement custom finders (or use @Query)
@Autowired
IOrganizationCustomRepository customRepository;
@Test
public void sampleTestCase() {
Organization test = customRepository.find(Long.valueOf(1));
System.out.println(test);
Organization org = new Organization("samsung", "1956");
org = repository.save(org);
Organization org2 = new Organization("rei", "2000");
org2 = repository.save(org2);
List<Organization> result = repository.findByName("samsung");
assert result.size() == 1;
assert result.contains(org);
}
}
|
UTF-8
|
Java
| 1,439 |
java
|
OrganizationIntegrationTest.java
|
Java
|
[] | null |
[] |
package com.springapp.mvc.DAO;
import com.springapp.config.TestAppConfig;
import com.springapp.mvc.dao.IOrganizationCustomRepository;
import com.springapp.mvc.dao.IOrganizationRepository;
import com.springapp.mvc.model.Organization;
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;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = TestAppConfig.class)
public class OrganizationIntegrationTest {
// EnableJpaRepositories("com.springapp.mvc.dao") helps find the repo
@Autowired
IOrganizationRepository repository;
// Have to create a custom repository that will implement custom finders (or use @Query)
@Autowired
IOrganizationCustomRepository customRepository;
@Test
public void sampleTestCase() {
Organization test = customRepository.find(Long.valueOf(1));
System.out.println(test);
Organization org = new Organization("samsung", "1956");
org = repository.save(org);
Organization org2 = new Organization("rei", "2000");
org2 = repository.save(org2);
List<Organization> result = repository.findByName("samsung");
assert result.size() == 1;
assert result.contains(org);
}
}
| 1,439 | 0.751216 | 0.740097 | 43 | 32.488373 | 25.796495 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.55814 | false | false |
13
|
04a91f7e9e27b94bf7a1dbd76aea37b12248a755
| 2,972,117,415,528 |
c22e314eb8b33bb7823f72653e931f82e5ac4175
|
/org.dbdoclet.tag/src/main/java/org/dbdoclet/tag/dbd/Return.java
|
b07ab73943415dce4cb45fed0739731d2592c1a1
|
[] |
no_license
|
mfuchs23/markup
|
https://github.com/mfuchs23/markup
|
5239a0448ef07deb8df5751d1e2e9666cdf1501e
|
af0d1610a1be93c4f1f3bda8ee1e6d9e66cbeaa2
|
refs/heads/master
| 2023-06-24T15:50:15.997000 | 2023-06-07T10:45:48 | 2023-06-07T10:45:48 | 22,429,612 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* $Id$
*
* ### Copyright (C) 2005 Michael Fuchs ###
* ### All Rights Reserved. ###
*
* Author: Michael Fuchs
* E-Mail: michael.fuchs@unico-group.com
* URL: http://www.michael-a-fuchs.de
*
* RCS Information
* Author..........: $Author$
* Date............: $Date$
* Revision........: $Revision$
* State...........: $State$
*/
package org.dbdoclet.tag.dbd;
import org.dbdoclet.xiphias.dom.TextImpl;
public class Return extends DbdElement {
public Return() {
super("return");
}
public Return(String description) {
super("return");
appendChild(new TextImpl(description));
}
}
/*
* $Log$
*/
|
UTF-8
|
Java
| 666 |
java
|
Return.java
|
Java
|
[
{
"context": "/* \n * $Id$\n *\n * ### Copyright (C) 2005 Michael Fuchs ###\n * ### All Rights Reserved. ###\n ",
"end": 54,
"score": 0.9998425245285034,
"start": 41,
"tag": "NAME",
"value": "Michael Fuchs"
},
{
"context": "All Rights Reserved. ###\n *\n * Author: Michael Fuchs\n * E-Mail: michael.fuchs@unico-group.com\n * URL: ",
"end": 130,
"score": 0.9998706579208374,
"start": 117,
"tag": "NAME",
"value": "Michael Fuchs"
},
{
"context": " ###\n *\n * Author: Michael Fuchs\n * E-Mail: michael.fuchs@unico-group.com\n * URL: http://www.michael-a-fuchs.de\n *\n * RC",
"end": 171,
"score": 0.9999319911003113,
"start": 142,
"tag": "EMAIL",
"value": "michael.fuchs@unico-group.com"
}
] | null |
[] |
/*
* $Id$
*
* ### Copyright (C) 2005 <NAME> ###
* ### All Rights Reserved. ###
*
* Author: <NAME>
* E-Mail: <EMAIL>
* URL: http://www.michael-a-fuchs.de
*
* RCS Information
* Author..........: $Author$
* Date............: $Date$
* Revision........: $Revision$
* State...........: $State$
*/
package org.dbdoclet.tag.dbd;
import org.dbdoclet.xiphias.dom.TextImpl;
public class Return extends DbdElement {
public Return() {
super("return");
}
public Return(String description) {
super("return");
appendChild(new TextImpl(description));
}
}
/*
* $Log$
*/
| 630 | 0.555556 | 0.54955 | 35 | 18.028572 | 16.378532 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | false | false |
13
|
0711abbc498f502c5440845e5340362b5af86e15
| 25,512,105,743,311 |
bcd8df9eea1f9750d082090e6a198e87ade62a2f
|
/src/HBF/User.java
|
94c92861afb7cc72c15ba66588bbf2e2c1e5cf21
|
[] |
no_license
|
BjarkeHou/DM-HBF
|
https://github.com/BjarkeHou/DM-HBF
|
7d1fc81b10da214e2d0907a753949914c6deddaf
|
78a1fee5c010e44f49040f89fa5b0b659a0a1a2a
|
refs/heads/master
| 2021-01-17T07:02:14.388000 | 2016-05-30T06:37:05 | 2016-05-30T06:37:05 | 55,604,900 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package HBF;
import java.util.Comparator;
public class User implements Comparator<User>, Comparable<User>{
private int MMR = 1200;
private int id;
private String name;
public User(int id) {
this.id = id;
}
public User(int id, String name) {
this.id = id;
this.name = name;
}
public int id() {
return id;
}
public String getName() {
return name;
}
public int getMMR() {
return MMR;
}
public void adjustMMR(int change) {
MMR += change;
}
@Override
public int compareTo(User o) {
if(o.getMMR() > this.MMR) return 1;
if(o.getMMR() < this.MMR) return -1;
return 0;
}
@Override
public int compare(User o1, User o2) {
if(o1.getMMR() > o2.getMMR()) return -1;
if(o1.getMMR() < o2.getMMR()) return 1;
return 0;
}
}
|
UTF-8
|
Java
| 769 |
java
|
User.java
|
Java
|
[] | null |
[] |
package HBF;
import java.util.Comparator;
public class User implements Comparator<User>, Comparable<User>{
private int MMR = 1200;
private int id;
private String name;
public User(int id) {
this.id = id;
}
public User(int id, String name) {
this.id = id;
this.name = name;
}
public int id() {
return id;
}
public String getName() {
return name;
}
public int getMMR() {
return MMR;
}
public void adjustMMR(int change) {
MMR += change;
}
@Override
public int compareTo(User o) {
if(o.getMMR() > this.MMR) return 1;
if(o.getMMR() < this.MMR) return -1;
return 0;
}
@Override
public int compare(User o1, User o2) {
if(o1.getMMR() > o2.getMMR()) return -1;
if(o1.getMMR() < o2.getMMR()) return 1;
return 0;
}
}
| 769 | 0.63329 | 0.612484 | 48 | 15.020833 | 14.967311 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.541667 | false | false |
13
|
62c5c9d1181c21f134dff7f49d3cd664a68b0598
| 18,399,639,904,055 |
e14933120b5ca277eae449c718b64db27e750337
|
/src/jekks/Car.java
|
fc29f259c15362e90c7af27c338f98188537d574
|
[] |
no_license
|
scottkildall/JEKKS
|
https://github.com/scottkildall/JEKKS
|
eb6de291001140ffd04e4bb357b5473312c22ce3
|
5ed8574df02befb041af9eedeaca3d4c99d182ae
|
refs/heads/master
| 2020-06-04T17:57:54.787000 | 2014-02-27T06:46:11 | 2014-02-27T06:46:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package jekks;
import processing.core.PApplet;
public class Car extends Vehicle {
public Car( PApplet _p, String imageFilename, String exhastFilename ) {
super(_p, imageFilename, exhastFilename);
advanceY = r.nextFloatRange(2f,4f);
advanceX = r.nextFloatRange(-9f,-6f);
startY = 350;
y = startY;
}
void drawCloud() {
if( cloudMover != null ) {
cloudMover.advanceFrame();
cloudMover.draw(x-(img.width/4) -5, y + 20);
}
}
}
|
UTF-8
|
Java
| 463 |
java
|
Car.java
|
Java
|
[] | null |
[] |
package jekks;
import processing.core.PApplet;
public class Car extends Vehicle {
public Car( PApplet _p, String imageFilename, String exhastFilename ) {
super(_p, imageFilename, exhastFilename);
advanceY = r.nextFloatRange(2f,4f);
advanceX = r.nextFloatRange(-9f,-6f);
startY = 350;
y = startY;
}
void drawCloud() {
if( cloudMover != null ) {
cloudMover.advanceFrame();
cloudMover.draw(x-(img.width/4) -5, y + 20);
}
}
}
| 463 | 0.658747 | 0.634989 | 24 | 18.291666 | 19.262396 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.041667 | false | false |
13
|
0dae4ae6c10da65ece97ec1a04b94bc1f1db48d3
| 4,329,327,046,738 |
26b7f30c6640b8017a06786e4a2414ad8a4d71dd
|
/src/number_of_direct_superinterfaces/i59619.java
|
de6d27a7ad942a78cd33f67708da599da04ce4c6
|
[] |
no_license
|
vincentclee/jvm-limits
|
https://github.com/vincentclee/jvm-limits
|
b72a2f2dcc18caa458f1e77924221d585f23316b
|
2fd1c26d1f7984ea8163bc103ad14b6d72282281
|
refs/heads/master
| 2020-05-18T11:18:41.711000 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package number_of_direct_superinterfaces;
public interface i59619 {}
|
UTF-8
|
Java
| 69 |
java
|
i59619.java
|
Java
|
[] | null |
[] |
package number_of_direct_superinterfaces;
public interface i59619 {}
| 69 | 0.826087 | 0.753623 | 3 | 22.333334 | 16.937796 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false |
13
|
54224e9f035998f0f07284fe2e40a25e3e79b329
| 2,826,088,506,553 |
847fb0bb54e3494785ab8edccb120a79e5934b79
|
/src/main/java/cc/lzy/sb/query/Conditions.java
|
88bdff635a076c2a230d29a298b326d5c968bf01
|
[] |
no_license
|
litbai/spring-boot-demo
|
https://github.com/litbai/spring-boot-demo
|
e97b4bb603c270f97d166a6bd8dfbdc8f5eaec6f
|
a05275423a0a854ade121fb34724ae3cb835a23e
|
refs/heads/master
| 2020-04-18T21:22:54.739000 | 2019-05-12T01:32:36 | 2019-05-12T01:32:36 | 167,763,788 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package cc.lzy.sb.query;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* 条件查询
* reference from xiaoyao@item-center
*/
public class Conditions {
private List<Condition> andConditionList;
private List<Condition> orConditionList;
private List<Order> orderList;
private Paginator paginator;
private Group group;
/**
* 分页
*/
private String conditions;
/**
* limit 分页优先级高于limit,如果有分页,则不需要limit
*/
private Integer limit;
public Conditions() {
andConditionList = new ArrayList<Condition>();
orConditionList = new ArrayList<Condition>();
orderList = new ArrayList<Order>();
}
public Conditions and(Condition condition) {
this.andConditionList.add(condition);
return this;
}
public Conditions or(Condition condition) {
this.orConditionList.add(condition);
return this;
}
public Conditions paginator(Paginator paginator) {
this.paginator = paginator;
return this;
}
public Conditions order(Order order) {
this.orderList.add(order);
return this;
}
public Conditions group(Group group){
this.group = group;
return this;
}
public Conditions limit(Integer limit) {
this.limit = limit;
return this;
}
public String getConditions() {
return this.conditions;
}
public Conditions build() {
StringBuilder sqlBuilder = new StringBuilder();
if (!andConditionList.isEmpty()) {
Collections.sort(andConditionList);
sqlBuilder.append(StringUtils.join(andConditionList, " AND "));
}
if (!orConditionList.isEmpty()) {
if (sqlBuilder.length() > 0) {
sqlBuilder.append(" OR ");
}
sqlBuilder.append(StringUtils.join(orConditionList, " OR "));
}
if(null != group){
sqlBuilder.append(" GROUP BY ");
sqlBuilder.append(group);
}
if (!orderList.isEmpty()) {
sqlBuilder.append(" ORDER BY ");
sqlBuilder.append(StringUtils.join(orderList, ", "));
}
if (null != paginator) {
sqlBuilder.append(" LIMIT ");
sqlBuilder.append(paginator);
} else if (null != limit) {
sqlBuilder.append(" LIMIT ");
sqlBuilder.append(limit);
} else {
sqlBuilder.append(" LIMIT 5000");
}
this.conditions = sqlBuilder.toString();
return this;
}
@Override
public String toString() {
this.build();
return conditions;
}
}
|
UTF-8
|
Java
| 2,814 |
java
|
Conditions.java
|
Java
|
[
{
"context": "ort java.util.List;\n\n/**\n * 条件查询\n * reference from xiaoyao@item-center\n */\npublic class Conditions {\n\n private List<C",
"end": 214,
"score": 0.9998823404312134,
"start": 195,
"tag": "EMAIL",
"value": "xiaoyao@item-center"
}
] | null |
[] |
/**
*
*/
package cc.lzy.sb.query;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* 条件查询
* reference from <EMAIL>
*/
public class Conditions {
private List<Condition> andConditionList;
private List<Condition> orConditionList;
private List<Order> orderList;
private Paginator paginator;
private Group group;
/**
* 分页
*/
private String conditions;
/**
* limit 分页优先级高于limit,如果有分页,则不需要limit
*/
private Integer limit;
public Conditions() {
andConditionList = new ArrayList<Condition>();
orConditionList = new ArrayList<Condition>();
orderList = new ArrayList<Order>();
}
public Conditions and(Condition condition) {
this.andConditionList.add(condition);
return this;
}
public Conditions or(Condition condition) {
this.orConditionList.add(condition);
return this;
}
public Conditions paginator(Paginator paginator) {
this.paginator = paginator;
return this;
}
public Conditions order(Order order) {
this.orderList.add(order);
return this;
}
public Conditions group(Group group){
this.group = group;
return this;
}
public Conditions limit(Integer limit) {
this.limit = limit;
return this;
}
public String getConditions() {
return this.conditions;
}
public Conditions build() {
StringBuilder sqlBuilder = new StringBuilder();
if (!andConditionList.isEmpty()) {
Collections.sort(andConditionList);
sqlBuilder.append(StringUtils.join(andConditionList, " AND "));
}
if (!orConditionList.isEmpty()) {
if (sqlBuilder.length() > 0) {
sqlBuilder.append(" OR ");
}
sqlBuilder.append(StringUtils.join(orConditionList, " OR "));
}
if(null != group){
sqlBuilder.append(" GROUP BY ");
sqlBuilder.append(group);
}
if (!orderList.isEmpty()) {
sqlBuilder.append(" ORDER BY ");
sqlBuilder.append(StringUtils.join(orderList, ", "));
}
if (null != paginator) {
sqlBuilder.append(" LIMIT ");
sqlBuilder.append(paginator);
} else if (null != limit) {
sqlBuilder.append(" LIMIT ");
sqlBuilder.append(limit);
} else {
sqlBuilder.append(" LIMIT 5000");
}
this.conditions = sqlBuilder.toString();
return this;
}
@Override
public String toString() {
this.build();
return conditions;
}
}
| 2,802 | 0.581706 | 0.579537 | 121 | 21.859505 | 19.203695 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413223 | false | false |
13
|
f4e56df23763a00ac69c4d7d4c7d24901d9698d4
| 31,147,102,863,012 |
6e9d66bf42023251280f174305d55ad3ae49a2e0
|
/src/main/java/org/py/html/AbstractHtmlBase.java
|
7330f5505273af6316b4dae8ee7b4ae45f75a537
|
[] |
no_license
|
Chauuuuu/cms2018
|
https://github.com/Chauuuuu/cms2018
|
59dcb437a2495045f42ae60006b17536cd3f8eaf
|
fcb6c34369f22c993047463dbee7cc555ad5c616
|
refs/heads/master
| 2022-09-22T00:04:36.841000 | 2020-05-31T15:05:30 | 2020-05-31T15:05:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.py.html;
import org.jsoup.nodes.Document;
public abstract class AbstractHtmlBase {
protected Document document;
public static final String WWW = "www.";
public static final String HTTP = "http://";
public static final String HTTPS = "https://";
public static final String HOSTSEPARATOR = "//";
public static final String SEPARATOR = "/";
public AbstractHtmlBase() {
}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
}
|
UTF-8
|
Java
| 576 |
java
|
AbstractHtmlBase.java
|
Java
|
[] | null |
[] |
package org.py.html;
import org.jsoup.nodes.Document;
public abstract class AbstractHtmlBase {
protected Document document;
public static final String WWW = "www.";
public static final String HTTP = "http://";
public static final String HTTPS = "https://";
public static final String HOSTSEPARATOR = "//";
public static final String SEPARATOR = "/";
public AbstractHtmlBase() {
}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
}
| 576 | 0.663194 | 0.663194 | 24 | 23 | 19.617168 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false |
13
|
a9a23d6bee1154adb91b18b5c00011c22d40d04a
| 781,684,093,667 |
20a6b649e6821122d9616d26c8de83f0af14cb6d
|
/src/main/java/com/niyazieren/sslchecklib/SslInfoFetcher.java
|
b045c45d3ebeb1ff15f606fc2c3553aa0bb8e885
|
[] |
no_license
|
niyazieren/SSLcheckLib
|
https://github.com/niyazieren/SSLcheckLib
|
3c7bd5ba668411da1bf62e4a67babbf5c0c36807
|
2265237188857f9a56d4ca92d97784e8bd231bbe
|
refs/heads/master
| 2020-04-25T21:07:13.885000 | 2019-03-26T08:55:42 | 2019-03-26T08:55:42 | 173,070,926 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.niyazieren.sslchecklib;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.TrustManager;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Date;
public class SslInfoFetcher {
static {
init();
}
public static void init(){
MyManager trm = new MyManager();
SSLContext sc = null;
try {
sc = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
try {
sc.init(null, new TrustManager[] { trm }, null);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
public SslInfo fetchInfo(String url) throws SslInfoFetchException {
URL destinationURL = null;
try {
destinationURL = new URL(url);
} catch (MalformedURLException e) {
throw new SslInfoFetchException("Bad URL", e);
}
HttpsURLConnection conn = null;
try {
URLConnection urlConnection = destinationURL.openConnection();
if(!(urlConnection instanceof HttpsURLConnection)){
throw new SslInfoFetchException("Connectıon ıs not HTTPS");
}
conn = (HttpsURLConnection) urlConnection;
} catch (IOException e) {
throw new SslInfoFetchException("Unable to open connection to URL", e);
}
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
try {
conn.connect();
} catch (IOException e) {
throw new SslInfoFetchException("Unable to connect to URL", e);
}
Certificate[] certs;
try {
certs = conn.getServerCertificates();
} catch (SSLPeerUnverifiedException e) {
throw new SslInfoFetchException("Unable to verify peer", e);
}
if (certs == null || certs.length == 0) {
throw new SslInfoFetchException("No certs reeceived");
}
X509Certificate firstCert = (X509Certificate) certs[0];
boolean valid = false;
try {
firstCert.checkValidity();
valid = true;
} catch (Exception e) {
}
Date startDate = firstCert.getNotBefore();
Date endDate = firstCert.getNotAfter();
return new SslInfo(valid, startDate, endDate);
}
}
|
UTF-8
|
Java
| 2,823 |
java
|
SslInfoFetcher.java
|
Java
|
[] | null |
[] |
package com.niyazieren.sslchecklib;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.TrustManager;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Date;
public class SslInfoFetcher {
static {
init();
}
public static void init(){
MyManager trm = new MyManager();
SSLContext sc = null;
try {
sc = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
try {
sc.init(null, new TrustManager[] { trm }, null);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
public SslInfo fetchInfo(String url) throws SslInfoFetchException {
URL destinationURL = null;
try {
destinationURL = new URL(url);
} catch (MalformedURLException e) {
throw new SslInfoFetchException("Bad URL", e);
}
HttpsURLConnection conn = null;
try {
URLConnection urlConnection = destinationURL.openConnection();
if(!(urlConnection instanceof HttpsURLConnection)){
throw new SslInfoFetchException("Connectıon ıs not HTTPS");
}
conn = (HttpsURLConnection) urlConnection;
} catch (IOException e) {
throw new SslInfoFetchException("Unable to open connection to URL", e);
}
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
try {
conn.connect();
} catch (IOException e) {
throw new SslInfoFetchException("Unable to connect to URL", e);
}
Certificate[] certs;
try {
certs = conn.getServerCertificates();
} catch (SSLPeerUnverifiedException e) {
throw new SslInfoFetchException("Unable to verify peer", e);
}
if (certs == null || certs.length == 0) {
throw new SslInfoFetchException("No certs reeceived");
}
X509Certificate firstCert = (X509Certificate) certs[0];
boolean valid = false;
try {
firstCert.checkValidity();
valid = true;
} catch (Exception e) {
}
Date startDate = firstCert.getNotBefore();
Date endDate = firstCert.getNotAfter();
return new SslInfo(valid, startDate, endDate);
}
}
| 2,823 | 0.621411 | 0.614676 | 95 | 28.694736 | 22.902573 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.578947 | false | false |
13
|
7cdd6ffd4b4b984939652093882538e73174af65
| 7,662,221,704,364 |
69201a77492822beaddac179f9aee005ae86840d
|
/kuo-auth/src/main/java/im/kuo/auth/config/SocialConfig.java
|
6697acd4429aa6de100b5ad71a9fe767e39c56eb
|
[] |
no_license
|
softlight0629/kuo
|
https://github.com/softlight0629/kuo
|
a2274be3b6e5a22669a2323f62f165969b5f1a66
|
d44f2f9ea3786c97e12279cc5643dd598b46a035
|
refs/heads/master
| 2021-01-24T01:28:02.651000 | 2018-11-06T01:59:21 | 2018-11-06T01:59:21 | 122,807,289 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package im.kuo.auth.config;
import im.kuo.auth.social.ProviderConnectionSignup;
import im.kuo.auth.social.RedirectSocialSignInAdapter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.env.Environment;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.connect.*;
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
import org.springframework.social.connect.support.ConnectionFactoryRegistry;
import org.springframework.social.connect.web.ConnectController;
import org.springframework.social.connect.web.ConnectInterceptor;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.github.api.GitHub;
import org.springframework.social.github.connect.GitHubConnectionFactory;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.request.WebRequest;
import javax.inject.Inject;
import javax.sql.DataSource;
@Configuration
@EnableSocial
public class SocialConfig {
@Inject
private Environment environment;
@Inject
private DataSource dataSource;
@Inject
private TextEncryptor textEncryptor;
@Inject
private ProviderConnectionSignup providerConnectionSignup;
@Inject
private RedirectSocialSignInAdapter redirectSocialSignInAdapter;
@Bean
public ProviderSignInController providerSignInController() {
ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(), redirectSocialSignInAdapter);
controller.setApplicationUrl("http://100.72.192.136/auth");
return controller;
}
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new GitHubConnectionFactory(
environment.getProperty("github.client.clientId"),
environment.getProperty("github.client.clientSecret")
));
return registry;
}
@Bean
@Scope(value="request", proxyMode= ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
}
return usersConnectionRepository().createConnectionRepository(authentication.getName());
}
@Bean
public UsersConnectionRepository usersConnectionRepository() {
JdbcUsersConnectionRepository repository =
new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator(), textEncryptor);
repository.setConnectionSignUp(providerConnectionSignup);
return repository;
}
@Bean
public ConnectController connectController() {
ConnectController controller = new ConnectController(connectionFactoryLocator(), connectionRepository());
controller.addInterceptor(new GithubConnectInterceptor());
return controller;
}
public class GithubConnectInterceptor implements ConnectInterceptor<GitHub> {
@Override
public void preConnect(ConnectionFactory<GitHub> connectionFactory, MultiValueMap<String, String> parameters, WebRequest request) {
}
@Override
public void postConnect(Connection<GitHub> connection, WebRequest request) {
System.out.println("I'm connecting......");
}
}
}
|
UTF-8
|
Java
| 4,014 |
java
|
SocialConfig.java
|
Java
|
[
{
"context": "er);\n controller.setApplicationUrl(\"http://100.72.192.136/auth\");\n\n return controller;\n }\n\n @B",
"end": 2035,
"score": 0.905218780040741,
"start": 2021,
"tag": "IP_ADDRESS",
"value": "100.72.192.136"
}
] | null |
[] |
package im.kuo.auth.config;
import im.kuo.auth.social.ProviderConnectionSignup;
import im.kuo.auth.social.RedirectSocialSignInAdapter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.env.Environment;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.social.config.annotation.EnableSocial;
import org.springframework.social.connect.*;
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
import org.springframework.social.connect.support.ConnectionFactoryRegistry;
import org.springframework.social.connect.web.ConnectController;
import org.springframework.social.connect.web.ConnectInterceptor;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.github.api.GitHub;
import org.springframework.social.github.connect.GitHubConnectionFactory;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.request.WebRequest;
import javax.inject.Inject;
import javax.sql.DataSource;
@Configuration
@EnableSocial
public class SocialConfig {
@Inject
private Environment environment;
@Inject
private DataSource dataSource;
@Inject
private TextEncryptor textEncryptor;
@Inject
private ProviderConnectionSignup providerConnectionSignup;
@Inject
private RedirectSocialSignInAdapter redirectSocialSignInAdapter;
@Bean
public ProviderSignInController providerSignInController() {
ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(), redirectSocialSignInAdapter);
controller.setApplicationUrl("http://172.16.31.10/auth");
return controller;
}
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new GitHubConnectionFactory(
environment.getProperty("github.client.clientId"),
environment.getProperty("github.client.clientSecret")
));
return registry;
}
@Bean
@Scope(value="request", proxyMode= ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
}
return usersConnectionRepository().createConnectionRepository(authentication.getName());
}
@Bean
public UsersConnectionRepository usersConnectionRepository() {
JdbcUsersConnectionRepository repository =
new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator(), textEncryptor);
repository.setConnectionSignUp(providerConnectionSignup);
return repository;
}
@Bean
public ConnectController connectController() {
ConnectController controller = new ConnectController(connectionFactoryLocator(), connectionRepository());
controller.addInterceptor(new GithubConnectInterceptor());
return controller;
}
public class GithubConnectInterceptor implements ConnectInterceptor<GitHub> {
@Override
public void preConnect(ConnectionFactory<GitHub> connectionFactory, MultiValueMap<String, String> parameters, WebRequest request) {
}
@Override
public void postConnect(Connection<GitHub> connection, WebRequest request) {
System.out.println("I'm connecting......");
}
}
}
| 4,012 | 0.7713 | 0.76856 | 109 | 35.825687 | 34.843777 | 162 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.513761 | false | false |
13
|
7acdad723cc3fca854a994a2df0e6dff62f4922e
| 14,645,838,500,527 |
7b5530d74ff2c86356dd963f49d26e4482c95a76
|
/01.30/src/main/java/com/nakamura/controller/MyController.java
|
2b85c85f79e25c3f359ebe9c6907dad70b54d242
|
[] |
no_license
|
syoushibi/test
|
https://github.com/syoushibi/test
|
a91032a7644f86993d4f55c7e58506db8ee4635a
|
8c25aa3cca0714c82bd0352bd516091c91cf4457
|
refs/heads/master
| 2023-02-28T19:07:58.992000 | 2021-02-04T09:36:50 | 2021-02-04T09:36:50 | 333,007,573 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.nakamura.controller;
import java.util.List;
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;
import com.nakamura.bean.Student;
import com.nakamura.service.StudentService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class MyController {
@Autowired
private StudentService service;
@Test
public void demo() {
List<Student> findStudent = service.findStudent();
for(Student stu:findStudent) {
System.out.println(stu);
}
}
}
|
UTF-8
|
Java
| 729 |
java
|
MyController.java
|
Java
|
[] | null |
[] |
package com.nakamura.controller;
import java.util.List;
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;
import com.nakamura.bean.Student;
import com.nakamura.service.StudentService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class MyController {
@Autowired
private StudentService service;
@Test
public void demo() {
List<Student> findStudent = service.findStudent();
for(Student stu:findStudent) {
System.out.println(stu);
}
}
}
| 729 | 0.803841 | 0.799726 | 27 | 26 | 22.519127 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.962963 | false | false |
13
|
baf0231f79016cbf755a5a7e8be150e9adab4868
| 14,645,838,501,765 |
bfd505990092b2b952321191f7286b3fa79a841d
|
/src/test/java/man/kuke/AppTest5.java
|
3b200233234a463e808136746c5c7bdb3a0f9ba9
|
[] |
no_license
|
China-YunSu/MultiFileCloudTransmission
|
https://github.com/China-YunSu/MultiFileCloudTransmission
|
16a2378898a51bb52c4e915c32e1a7135537fe00
|
f2cae7c34d49d92695b4b67918218aaac0204c1e
|
refs/heads/master
| 2023-03-14T12:07:46.919000 | 2021-03-05T10:12:00 | 2021-03-05T10:12:00 | 344,770,197 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package man.kuke;
import man.kuke.core.NetNode;
import man.kuke.core.Resource;
import man.kuke.registry.mapper.ConsumerService;
import man.kuke.rmi.core.RMIClient;
import man.kuke.rmi.core.RMIServer;
import man.kuke.sender.mapper.ResourcesServices;
import java.util.Set;
/**
* @author: kuke
* @date: 2021/2/3 - 13:47
* @description:
*/
public class AppTest5 {
public static void main(String[] args) {
RMIClient registry = new RMIClient();
registry.setPort(54100);
registry.setIp("127.0.0.1");
ConsumerService registryProxy = (ConsumerService) registry.getProxy(ConsumerService.class);
Set<NetNode> kuke = registryProxy.getServiceAddress("kuke");
System.out.println(kuke);
RMIClient serviceServer = new RMIClient();
serviceServer.setPort(50000);
serviceServer.setIp("127.0.0.1");
ResourcesServices resources = (ResourcesServices) serviceServer.getProxy(ResourcesServices.class);
Resource res = resources.getResource("kuke");
System.out.println(res);
}
}
|
UTF-8
|
Java
| 1,065 |
java
|
AppTest5.java
|
Java
|
[
{
"context": "sServices;\n\nimport java.util.Set;\n\n/**\n * @author: kuke\n * @date: 2021/2/3 - 13:47\n * @description:\n */\np",
"end": 294,
"score": 0.9995589256286621,
"start": 290,
"tag": "USERNAME",
"value": "kuke"
},
{
"context": " registry.setPort(54100);\n registry.setIp(\"127.0.0.1\");\n ConsumerService registryProxy = (Consu",
"end": 524,
"score": 0.9997918605804443,
"start": 515,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
},
{
"context": "rver.setPort(50000);\n serviceServer.setIp(\"127.0.0.1\");\n ResourcesServices resources = (Resourc",
"end": 859,
"score": 0.9997885227203369,
"start": 850,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
}
] | null |
[] |
package man.kuke;
import man.kuke.core.NetNode;
import man.kuke.core.Resource;
import man.kuke.registry.mapper.ConsumerService;
import man.kuke.rmi.core.RMIClient;
import man.kuke.rmi.core.RMIServer;
import man.kuke.sender.mapper.ResourcesServices;
import java.util.Set;
/**
* @author: kuke
* @date: 2021/2/3 - 13:47
* @description:
*/
public class AppTest5 {
public static void main(String[] args) {
RMIClient registry = new RMIClient();
registry.setPort(54100);
registry.setIp("127.0.0.1");
ConsumerService registryProxy = (ConsumerService) registry.getProxy(ConsumerService.class);
Set<NetNode> kuke = registryProxy.getServiceAddress("kuke");
System.out.println(kuke);
RMIClient serviceServer = new RMIClient();
serviceServer.setPort(50000);
serviceServer.setIp("127.0.0.1");
ResourcesServices resources = (ResourcesServices) serviceServer.getProxy(ResourcesServices.class);
Resource res = resources.getResource("kuke");
System.out.println(res);
}
}
| 1,065 | 0.698592 | 0.667606 | 33 | 31.272728 | 25.483534 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606061 | false | false |
13
|
2aef61458150d802d74919e33db7d7e60f97b7aa
| 7,550,552,506,894 |
e30e7f556ed64b94b80787b12b831d3059bce4ac
|
/strings/Duplicates_in_a_string.java
|
4669569b7ecf4b4f010f88f8926de886b9616480
|
[] |
no_license
|
Junaid-Mohamed/DS_Algo
|
https://github.com/Junaid-Mohamed/DS_Algo
|
a0189193130fdc3862b28f27884687ea0b0c4bfe
|
6bc0a714b9301953a061b2ae7623891140f3b00e
|
refs/heads/master
| 2023-01-10T04:09:29.376000 | 2020-11-13T16:35:34 | 2020-11-13T16:35:34 | 308,299,256 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package strings;
public class Duplicates_in_a_string {
static void findDuplicates(String s) {
int c[] = new int[256];
for(int i=0;i<s.length();i++) {
c[s.charAt(i)]++;
}
for(int i=0;i<256;i++) {
if(c[i]>1 && (char)i != ' ') {
System.out.println((char)i +"-> has count of ->"+c[i]);
}
}
}
public static void main(String[] args) {
String s = "geeks for geeks";
findDuplicates(s);
}
}
|
UTF-8
|
Java
| 432 |
java
|
Duplicates_in_a_string.java
|
Java
|
[] | null |
[] |
package strings;
public class Duplicates_in_a_string {
static void findDuplicates(String s) {
int c[] = new int[256];
for(int i=0;i<s.length();i++) {
c[s.charAt(i)]++;
}
for(int i=0;i<256;i++) {
if(c[i]>1 && (char)i != ' ') {
System.out.println((char)i +"-> has count of ->"+c[i]);
}
}
}
public static void main(String[] args) {
String s = "geeks for geeks";
findDuplicates(s);
}
}
| 432 | 0.543981 | 0.523148 | 28 | 14.428572 | 16.708485 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.75 | false | false |
13
|
94e72c711dd639aedaccd29a361c012d3bcb6785
| 7,550,552,508,856 |
aa04074ff0b5b637ef223364a4bc9c6381346bc7
|
/prj/src/subpackage/Encrypt/test2.java
|
ba6240d7fe7d08aab19eb44b74bfbcc7b820a35a
|
[] |
no_license
|
DestroySera/Javaschool-coding
|
https://github.com/DestroySera/Javaschool-coding
|
07205e1c0d5d0267ad0e003553f86b9851742520
|
92c138b1b5d26abc83c99f7097979489955b00dd
|
refs/heads/main
| 2023-09-01T04:52:33.645000 | 2021-11-02T01:37:10 | 2021-11-02T01:37:10 | 366,551,841 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package subpackage.Encrypt;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
public class test2 {
public static void main(String[] args) throws Exception {
String plainText = "Hello, MadPlay!";
SecretKey key = AESCryptoUtil.getKey();
IvParameterSpec ivParameterSpec = AESCryptoUtil.getIv();
String specName = "AES/CBC/PKCS5Padding";
String encryptedText = AESCryptoUtil.encrypt(specName, key, ivParameterSpec, plainText);
String decryptedText = AESCryptoUtil.decrypt(specName, key, ivParameterSpec, encryptedText);
System.out.println("cipherText: " + encryptedText);
System.out.println("plainText: " + decryptedText);
}
}
|
UTF-8
|
Java
| 851 |
java
|
test2.java
|
Java
|
[
{
"context": ") throws Exception {\r\n\t\tString plainText = \"Hello, MadPlay!\";\r\n\r\n\t\tSecretKey key = AESCryptoUtil.getKey();\r\n",
"end": 388,
"score": 0.9367518424987793,
"start": 381,
"tag": "USERNAME",
"value": "MadPlay"
}
] | null |
[] |
package subpackage.Encrypt;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Collectors;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
public class test2 {
public static void main(String[] args) throws Exception {
String plainText = "Hello, MadPlay!";
SecretKey key = AESCryptoUtil.getKey();
IvParameterSpec ivParameterSpec = AESCryptoUtil.getIv();
String specName = "AES/CBC/PKCS5Padding";
String encryptedText = AESCryptoUtil.encrypt(specName, key, ivParameterSpec, plainText);
String decryptedText = AESCryptoUtil.decrypt(specName, key, ivParameterSpec, encryptedText);
System.out.println("cipherText: " + encryptedText);
System.out.println("plainText: " + decryptedText);
}
}
| 851 | 0.752056 | 0.749706 | 26 | 30.73077 | 26.423412 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.576923 | false | false |
13
|
b0bb72a59a349a3f30324517e46d7d0d3a7ae924
| 1,829,656,122,103 |
b8f41a2a1516fb62d623598374021d07988348b8
|
/src/main/java/org/lostfan/ktv/utils/RenderedServicesLoader.java
|
974588b303c7904d293564cea4b4e0b5e672ced0
|
[] |
no_license
|
LostFan/KTVI
|
https://github.com/LostFan/KTVI
|
13dbf4dbeaa31488d252558b044612f7c46ffe6e
|
f810fffa740eda26412a7d2ed252c3f924078a38
|
refs/heads/master
| 2022-02-01T18:56:52.914000 | 2020-12-15T05:15:46 | 2020-12-15T05:15:46 | 88,361,436 | 0 | 0 | null | false | 2022-01-21T23:16:12 | 2017-04-15T17:00:20 | 2020-12-15T05:15:58 | 2022-01-21T23:16:10 | 794 | 0 | 0 | 2 |
Java
| false | false |
package org.lostfan.ktv.utils;
import org.lostfan.ktv.domain.RenderedService;
import org.lostfan.ktv.model.FixedServices;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
public class RenderedServicesLoader {
public RenderedServicesLoader() {
}
public List<RenderedService> load(File file) {
List<RenderedService> renderedServices = new ArrayList<>();
if(file.getName().endsWith(".txt")) {
renderedServices = loadTXT(file);
}
return renderedServices;
}
private List<RenderedService> loadTXT(File file) {
List<RenderedService> renderedServices = new ArrayList<>();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
String str[] = sCurrentLine.split(";");
try {
RenderedService renderedService = new RenderedService();
renderedService.setSubscriberAccount(Integer.parseInt(str[0]));
renderedService.setDate(createDate(str[1]));
// renderedService.setBankFileName(file.getName());
// renderedService.setPrice(Integer.parseInt(str[6].split("\\.")[0]));
renderedService.setPrice(new BigDecimal(str[3]));
renderedService.setServiceId(FixedServices.SUBSCRIPTION_FEE.getId());
renderedServices.add(renderedService);
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (IOException e1) {
e1.printStackTrace();
}
return renderedServices;
}
private LocalDate createDate(String s) {
return LocalDate.of(Integer.parseInt(s.substring(4, 8)), Integer.parseInt(s.substring(2, 4)), Integer.parseInt(s.substring(0, 2)));
}
}
|
UTF-8
|
Java
| 2,104 |
java
|
RenderedServicesLoader.java
|
Java
|
[] | null |
[] |
package org.lostfan.ktv.utils;
import org.lostfan.ktv.domain.RenderedService;
import org.lostfan.ktv.model.FixedServices;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
public class RenderedServicesLoader {
public RenderedServicesLoader() {
}
public List<RenderedService> load(File file) {
List<RenderedService> renderedServices = new ArrayList<>();
if(file.getName().endsWith(".txt")) {
renderedServices = loadTXT(file);
}
return renderedServices;
}
private List<RenderedService> loadTXT(File file) {
List<RenderedService> renderedServices = new ArrayList<>();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
String str[] = sCurrentLine.split(";");
try {
RenderedService renderedService = new RenderedService();
renderedService.setSubscriberAccount(Integer.parseInt(str[0]));
renderedService.setDate(createDate(str[1]));
// renderedService.setBankFileName(file.getName());
// renderedService.setPrice(Integer.parseInt(str[6].split("\\.")[0]));
renderedService.setPrice(new BigDecimal(str[3]));
renderedService.setServiceId(FixedServices.SUBSCRIPTION_FEE.getId());
renderedServices.add(renderedService);
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (IOException e1) {
e1.printStackTrace();
}
return renderedServices;
}
private LocalDate createDate(String s) {
return LocalDate.of(Integer.parseInt(s.substring(4, 8)), Integer.parseInt(s.substring(2, 4)), Integer.parseInt(s.substring(0, 2)));
}
}
| 2,104 | 0.61597 | 0.609791 | 60 | 34.066666 | 29.044142 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false |
13
|
4ea78d3fcc9a1432f37ac54fff3a8595d133c7bb
| 14,276,471,334,400 |
5dbeea2cf2be5b81b6129626e6f8f3d369c391b4
|
/app/src/main/java/com/ruobilin/basf/basfchemical/presenter/SearchChemicalPresenter.java
|
1c81b0607d523579046d49753ae7afff79e0e446
|
[] |
no_license
|
strivecheng/chemistry
|
https://github.com/strivecheng/chemistry
|
6fd5154c63d58e915e9b0879c2281191dce8af1a
|
47ab2980b525686d8644ded30a3491e4c1264d29
|
refs/heads/master
| 2020-04-13T08:03:56.317000 | 2018-12-29T13:44:12 | 2018-12-29T13:44:12 | 163,070,856 | 6 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ruobilin.basf.basfchemical.presenter;
import com.ruobilin.basf.basfchemical.base.BasePresenterImpl;
import com.ruobilin.basf.basfchemical.base.BaseShowView;
import com.ruobilin.basf.basfchemical.bean.ChemicalInfo;
import com.ruobilin.basf.basfchemical.contract.SearchChemicalContract;
import com.ruobilin.basf.basfchemical.model.ChemicalModel;
import java.util.ArrayList;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Created by strive on 2018/12/26.
*/
public class SearchChemicalPresenter extends BasePresenterImpl implements SearchChemicalContract.Presenter,ChemicalModel.GetChemicalListCallback {
private ChemicalModel mChemicalModel;
private SearchChemicalContract.View mChemicalListView;
public SearchChemicalPresenter(ChemicalModel chemicalModel,SearchChemicalContract.View chemicalListView) {
super(chemicalListView);
checkNotNull(chemicalModel,"chemicalModel cannot be null");
checkNotNull(chemicalListView,"chemicalListView cannot be null");
this.mChemicalListView = chemicalListView;
this.mChemicalModel = chemicalModel;
}
@Override
public void subscribe() {
}
@Override
public void unSubscribe() {
}
@Override
public void getChemicalListSuccess(ArrayList<ChemicalInfo> chemicalInfos) {
mChemicalListView.showChemicalList(chemicalInfos);
}
@Override
public void searchChemicalByKeyword(String keyword) {
mChemicalModel.searchChemicalList(keyword,this);
}
}
|
UTF-8
|
Java
| 1,540 |
java
|
SearchChemicalPresenter.java
|
Java
|
[
{
"context": "ase.Preconditions.checkNotNull;\n\n/**\n * Created by strive on 2018/12/26.\n */\n\npublic class SearchChemicalPr",
"end": 477,
"score": 0.9996296167373657,
"start": 471,
"tag": "USERNAME",
"value": "strive"
}
] | null |
[] |
package com.ruobilin.basf.basfchemical.presenter;
import com.ruobilin.basf.basfchemical.base.BasePresenterImpl;
import com.ruobilin.basf.basfchemical.base.BaseShowView;
import com.ruobilin.basf.basfchemical.bean.ChemicalInfo;
import com.ruobilin.basf.basfchemical.contract.SearchChemicalContract;
import com.ruobilin.basf.basfchemical.model.ChemicalModel;
import java.util.ArrayList;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Created by strive on 2018/12/26.
*/
public class SearchChemicalPresenter extends BasePresenterImpl implements SearchChemicalContract.Presenter,ChemicalModel.GetChemicalListCallback {
private ChemicalModel mChemicalModel;
private SearchChemicalContract.View mChemicalListView;
public SearchChemicalPresenter(ChemicalModel chemicalModel,SearchChemicalContract.View chemicalListView) {
super(chemicalListView);
checkNotNull(chemicalModel,"chemicalModel cannot be null");
checkNotNull(chemicalListView,"chemicalListView cannot be null");
this.mChemicalListView = chemicalListView;
this.mChemicalModel = chemicalModel;
}
@Override
public void subscribe() {
}
@Override
public void unSubscribe() {
}
@Override
public void getChemicalListSuccess(ArrayList<ChemicalInfo> chemicalInfos) {
mChemicalListView.showChemicalList(chemicalInfos);
}
@Override
public void searchChemicalByKeyword(String keyword) {
mChemicalModel.searchChemicalList(keyword,this);
}
}
| 1,540 | 0.777273 | 0.772078 | 49 | 30.428572 | 33.101574 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44898 | false | false |
13
|
19e54c492ee6a65fdc50a8b15e1700ec4751cafd
| 23,132,693,912,802 |
c62cdd12fb181972e8a5218242c68f5691d88389
|
/sportjumpPOM/sportjumpDAO/src/test/java/es/uma/sportjump/sjs/dao/test/impl/mock/ExerciseBlockDaoMockTest.java
|
2548e526732ecefb56f7d2ce129535d71ee30dfb
|
[] |
no_license
|
juanminet/SportJump_Server
|
https://github.com/juanminet/SportJump_Server
|
078e8026c53c974abe2265d0205e575ae14bd43e
|
f1b9417910f32e13a1b2d42a85f5d9242c8e7699
|
refs/heads/master
| 2021-03-27T16:56:36.070000 | 2014-03-23T01:04:17 | 2014-03-23T01:04:17 | 5,387,623 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package es.uma.sportjump.sjs.dao.test.impl.mock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import es.uma.sportjump.sjs.dao.test.ExerciseBlockDaoTest;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:test-mock-application-dao.xml")
public class ExerciseBlockDaoMockTest extends ExerciseBlockDaoTest{
@Test
public void testExerciseBlockCRUD(){
super.testExerciseBlockCRUD();
}
@Test
public void testExercises(){
super.testExercises();
}
@Test
public void testAllExerciseBlocks(){
super.testAllExerciseBlocks();
}
@Test
public void testExerciseBlockByNameAndCoach(){
super.testExerciseBlockByNameAndCoach();
}
}
|
UTF-8
|
Java
| 828 |
java
|
ExerciseBlockDaoMockTest.java
|
Java
|
[] | null |
[] |
package es.uma.sportjump.sjs.dao.test.impl.mock;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import es.uma.sportjump.sjs.dao.test.ExerciseBlockDaoTest;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:test-mock-application-dao.xml")
public class ExerciseBlockDaoMockTest extends ExerciseBlockDaoTest{
@Test
public void testExerciseBlockCRUD(){
super.testExerciseBlockCRUD();
}
@Test
public void testExercises(){
super.testExercises();
}
@Test
public void testAllExerciseBlocks(){
super.testAllExerciseBlocks();
}
@Test
public void testExerciseBlockByNameAndCoach(){
super.testExerciseBlockByNameAndCoach();
}
}
| 828 | 0.798309 | 0.794686 | 33 | 24.09091 | 24.226662 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.030303 | false | false |
13
|
f44759e8d496169062cc6a1c59bcf9996be746a8
| 154,618,841,185 |
b6e0ead88e885c2c9a3bc0c364f415f928d476ab
|
/src/main/java/com/george/math/LinkedList.java
|
ed6f7db0c2671d77ac7c4d181bc88898a84d8ea8
|
[] |
no_license
|
MrGeroge/Algorithm
|
https://github.com/MrGeroge/Algorithm
|
eba30a1f2227366d59e6e92ab4c0879cb069a049
|
eb1bd15191fb0ae4c8211aa37f89351270d1a256
|
refs/heads/master
| 2021-04-30T15:52:36.471000 | 2018-02-12T13:40:44 | 2018-02-12T13:40:44 | 121,250,947 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.george.math;
/**
* Created by George on 2017/6/14.
*/
public class LinkedList {//双端链表
class Node{
public Node next;//后节点
public Object data;//数据
}
private Node head;
public LinkedList(){
head=new Node();
head.data=-1;
head.next=null;
}
public boolean isEmpty(){
if(head.next==null){
return true;
}
else{
return false;
}
}
public int length(){//链表长度
Node p=head;
int j=0;
while(p.next!=null){
p=p.next;
j++;
}
return j;
}
public void insert(int i,int element){//在链表中第i个位置之前插入元素element
Node p=head;
int j=0;//寻找第i-1个节点位置
while(p!=null&&j<i-1){//p最终指向第i-1个节点,当i-1可取得链表尾元素
p=p.next;
j++;
}
if(p==null||j>i-1){//到达链表尾
return;
}
else{
Node node=new Node();
node.data=element;
node.next=p.next;
p.next=node;
return;
}
}
public Object delete(int i){//删除第i个元素
Node p=head;
int j=0;
while(p.next!=null&&j<i-1){//i-1不能取链表尾元素
p=p.next;
j++;
}
if(p.next==null||j>i-1){
return -1;
}
else{
Object result=p.next.data;
p.next=p.next.next;
return result;
}
}
public Node search(Object key){//查找链表中是否有data=key的元素
Node p=head.next;
while(p!=null){
if(p.data==key){
return p;
}
else{
p=p.next;
}
}
return null;
}
public static void main(String[] args){
LinkedList list=new LinkedList();
for(int i=1;i<=10;i++){
list.insert(i,i);
}
Node node=list.search(11);
if(node==null){
System.out.print("null");
}
else {
System.out.print(node.data);
}
}
}
|
UTF-8
|
Java
| 2,240 |
java
|
LinkedList.java
|
Java
|
[
{
"context": "package com.george.math;\n\n/**\n * Created by George on 2017/6/14.\n */\npublic class LinkedList {//双端链表",
"end": 50,
"score": 0.5844559669494629,
"start": 44,
"tag": "USERNAME",
"value": "George"
}
] | null |
[] |
package com.george.math;
/**
* Created by George on 2017/6/14.
*/
public class LinkedList {//双端链表
class Node{
public Node next;//后节点
public Object data;//数据
}
private Node head;
public LinkedList(){
head=new Node();
head.data=-1;
head.next=null;
}
public boolean isEmpty(){
if(head.next==null){
return true;
}
else{
return false;
}
}
public int length(){//链表长度
Node p=head;
int j=0;
while(p.next!=null){
p=p.next;
j++;
}
return j;
}
public void insert(int i,int element){//在链表中第i个位置之前插入元素element
Node p=head;
int j=0;//寻找第i-1个节点位置
while(p!=null&&j<i-1){//p最终指向第i-1个节点,当i-1可取得链表尾元素
p=p.next;
j++;
}
if(p==null||j>i-1){//到达链表尾
return;
}
else{
Node node=new Node();
node.data=element;
node.next=p.next;
p.next=node;
return;
}
}
public Object delete(int i){//删除第i个元素
Node p=head;
int j=0;
while(p.next!=null&&j<i-1){//i-1不能取链表尾元素
p=p.next;
j++;
}
if(p.next==null||j>i-1){
return -1;
}
else{
Object result=p.next.data;
p.next=p.next.next;
return result;
}
}
public Node search(Object key){//查找链表中是否有data=key的元素
Node p=head.next;
while(p!=null){
if(p.data==key){
return p;
}
else{
p=p.next;
}
}
return null;
}
public static void main(String[] args){
LinkedList list=new LinkedList();
for(int i=1;i<=10;i++){
list.insert(i,i);
}
Node node=list.search(11);
if(node==null){
System.out.print("null");
}
else {
System.out.print(node.data);
}
}
}
| 2,240 | 0.435453 | 0.42341 | 95 | 20.852633 | 13.096378 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.526316 | false | false |
13
|
987918201c6617e7f7047ed00fddeffbeb26a260
| 23,433,341,617,146 |
692ac36a1fce277b92bb4ae3c60728c46b260066
|
/app/src/main/java/com/example/sviostali/sk_dnevnik/Activities/StudentReview.java
|
580d08f8a369118ee50abaa8ee08c75313f53167
|
[] |
no_license
|
makaMusa/Skolski-Dnevnik
|
https://github.com/makaMusa/Skolski-Dnevnik
|
327e002c5f0fa443754895ecb66a26e5cff673eb
|
83900cdbfc95836ae5307907232b9ab33da0f599
|
refs/heads/master
| 2020-08-08T19:04:08.497000 | 2019-10-28T20:49:51 | 2019-10-28T20:49:51 | 213,895,528 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.sviostali.sk_dnevnik.Activities;
import android.app.AlertDialog;
import android.content.DialogInterface;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.sviostali.sk_dnevnik.ListViews.MarksListView.MarksAdapter;
import com.example.sviostali.sk_dnevnik.R;
import com.example.sviostali.sk_dnevnik.sugarclasses.marks;
import com.example.sviostali.sk_dnevnik.sugarclasses.studentsubject;
import com.orm.SugarContext;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
public class StudentReview extends AppCompatActivity {
public TextView tvName, tvAverage, tvFinalMark, tvBirthDate, tvAbsence;
public Button btnSetMark, btnSetFinalMark, btnAutoSetFinalMark, btnRmvAbsence,btnAddAbsence;
public ImageView ivAvatar;
public long id;
public float avg, sum=0;
public studentsubject stud_sub;
public marks mark;
public int setMark;
public ListView lvMarks;
public MarksAdapter MAdapter;
private AlertDialog.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SugarContext.init(this);
setContentView(R.layout.activity_student_review);
tvName = findViewById(R.id.tvURname);
tvAverage = findViewById(R.id.tvURaverage);
tvFinalMark = findViewById(R.id.tvURFinalMark);
tvBirthDate = findViewById(R.id.tvURbirthdate);
tvAbsence = findViewById(R.id.tvSRabsence);
btnSetMark = findViewById(R.id.btnURsetMark);
btnSetFinalMark = findViewById(R.id.btnURsetFinalMark);
btnAutoSetFinalMark = findViewById(R.id.btnURautosetFinalMark);
btnRmvAbsence = findViewById(R.id.btnSRremoveAbsence);
btnAddAbsence = findViewById(R.id.btnSRaddAbsence);
ivAvatar = findViewById(R.id.ivSRavatar);
Bundle s = getIntent().getExtras();
id = s.getLong("id");
stud_sub = studentsubject.findById(studentsubject.class, id);
tvAbsence.setText(stud_sub.getAbsence()+"");
MAdapter = new MarksAdapter(StudentReview.this, id);
lvMarks = findViewById(R.id.lvSRmarks);
lvMarks.setAdapter(MAdapter);
tvName.setText(stud_sub.getUser().getLogin());
tvBirthDate.setText(stud_sub.getUser().getBirthdate());
Glide.with(this)
.load(stud_sub.getUser().getAvatar())
.into(ivAvatar);
if(stud_sub.getFinalmark()>0){
tvFinalMark.setText("Zaključna ocjena je: "+stud_sub.getFinalmark()+"");
}
getAverage();
//unos ocijene
btnSetMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
builder = new AlertDialog.Builder(StudentReview.this);
builder.setTitle("Ocjena:");
final EditText input = new EditText(StudentReview.this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
builder.setView(input);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setMark = Integer.parseInt(input.getText().toString());
if(setMark<1||setMark>5){
Toast.makeText(StudentReview.this, "Unesite ocjenu u rasponu 1-5", Toast.LENGTH_SHORT).show();
}else{
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
String strDate = sdf.format(c.getTime());
Toast.makeText(StudentReview.this, "Ocjenili ste s ocjenom: "+setMark, Toast.LENGTH_SHORT).show();
mark = new marks(stud_sub, setMark, strDate, 0);
mark.save();
getAverage();
MAdapter = new MarksAdapter(StudentReview.this, id);
lvMarks = findViewById(R.id.lvSRmarks);
lvMarks.setAdapter(MAdapter);
}
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
dialog.dismiss();
}
});
builder.show();
}
});
//zakljucivanje
btnSetFinalMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(StudentReview.this);
builder2.setTitle("Zakljucna ocjena:");
final EditText input2 = new EditText(StudentReview.this);
input2.setInputType(InputType.TYPE_CLASS_NUMBER);
builder2.setView(input2);
builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setMark = Integer.parseInt(input2.getText().toString());
if(setMark<0||setMark>5){
Toast.makeText(StudentReview.this, "Unesite ocjenu u rasponu 1-5", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(StudentReview.this, "Zakljucili ste ocjenu: "+setMark, Toast.LENGTH_SHORT).show();
stud_sub.setFinalmark(setMark);
stud_sub.save();
tvFinalMark.setText("Zaključna ocjena je: "+setMark);
}
dialog.dismiss();
}
});
builder2.setNegativeButton("Odustani", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
dialog.dismiss();
}
});
builder2.show();
}
});
btnAutoSetFinalMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = Math.round(avg);
Toast.makeText(StudentReview.this, "Automatski zaključena ocjena je: "+tmp, Toast.LENGTH_SHORT).show();
stud_sub.setFinalmark(tmp);
stud_sub.save();
tvFinalMark.setText("Zaključna ocjena je: "+tmp);
}
});
btnAddAbsence.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = stud_sub.getAbsence();
tmp = tmp+1;
stud_sub.setAbsence(tmp);
stud_sub.save();
tvAbsence.setText(tmp+"");
}
});
btnRmvAbsence.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = stud_sub.getAbsence();
tmp = tmp-1;
if(tmp>=0) {
stud_sub.setAbsence(tmp);
stud_sub.save();
tvAbsence.setText(tmp + "");
}
}
});
}
private void getAverage() {
List<marks> list = stud_sub.getMarks();
sum=0;
if(list.isEmpty()){
tvAverage.setText("Trebate više ocjena za računanje prosjeka.");
}else{
for(int i = 0;i<list.size();i++){
sum+=list.get(i).getMark();
}
avg = sum/list.size();
tvAverage.setText("Vaš prosjek je: " + avg);
}
}
}
|
UTF-8
|
Java
| 8,522 |
java
|
StudentReview.java
|
Java
|
[] | null |
[] |
package com.example.sviostali.sk_dnevnik.Activities;
import android.app.AlertDialog;
import android.content.DialogInterface;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.example.sviostali.sk_dnevnik.ListViews.MarksListView.MarksAdapter;
import com.example.sviostali.sk_dnevnik.R;
import com.example.sviostali.sk_dnevnik.sugarclasses.marks;
import com.example.sviostali.sk_dnevnik.sugarclasses.studentsubject;
import com.orm.SugarContext;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
public class StudentReview extends AppCompatActivity {
public TextView tvName, tvAverage, tvFinalMark, tvBirthDate, tvAbsence;
public Button btnSetMark, btnSetFinalMark, btnAutoSetFinalMark, btnRmvAbsence,btnAddAbsence;
public ImageView ivAvatar;
public long id;
public float avg, sum=0;
public studentsubject stud_sub;
public marks mark;
public int setMark;
public ListView lvMarks;
public MarksAdapter MAdapter;
private AlertDialog.Builder builder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SugarContext.init(this);
setContentView(R.layout.activity_student_review);
tvName = findViewById(R.id.tvURname);
tvAverage = findViewById(R.id.tvURaverage);
tvFinalMark = findViewById(R.id.tvURFinalMark);
tvBirthDate = findViewById(R.id.tvURbirthdate);
tvAbsence = findViewById(R.id.tvSRabsence);
btnSetMark = findViewById(R.id.btnURsetMark);
btnSetFinalMark = findViewById(R.id.btnURsetFinalMark);
btnAutoSetFinalMark = findViewById(R.id.btnURautosetFinalMark);
btnRmvAbsence = findViewById(R.id.btnSRremoveAbsence);
btnAddAbsence = findViewById(R.id.btnSRaddAbsence);
ivAvatar = findViewById(R.id.ivSRavatar);
Bundle s = getIntent().getExtras();
id = s.getLong("id");
stud_sub = studentsubject.findById(studentsubject.class, id);
tvAbsence.setText(stud_sub.getAbsence()+"");
MAdapter = new MarksAdapter(StudentReview.this, id);
lvMarks = findViewById(R.id.lvSRmarks);
lvMarks.setAdapter(MAdapter);
tvName.setText(stud_sub.getUser().getLogin());
tvBirthDate.setText(stud_sub.getUser().getBirthdate());
Glide.with(this)
.load(stud_sub.getUser().getAvatar())
.into(ivAvatar);
if(stud_sub.getFinalmark()>0){
tvFinalMark.setText("Zaključna ocjena je: "+stud_sub.getFinalmark()+"");
}
getAverage();
//unos ocijene
btnSetMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
builder = new AlertDialog.Builder(StudentReview.this);
builder.setTitle("Ocjena:");
final EditText input = new EditText(StudentReview.this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);
builder.setView(input);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setMark = Integer.parseInt(input.getText().toString());
if(setMark<1||setMark>5){
Toast.makeText(StudentReview.this, "Unesite ocjenu u rasponu 1-5", Toast.LENGTH_SHORT).show();
}else{
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
String strDate = sdf.format(c.getTime());
Toast.makeText(StudentReview.this, "Ocjenili ste s ocjenom: "+setMark, Toast.LENGTH_SHORT).show();
mark = new marks(stud_sub, setMark, strDate, 0);
mark.save();
getAverage();
MAdapter = new MarksAdapter(StudentReview.this, id);
lvMarks = findViewById(R.id.lvSRmarks);
lvMarks.setAdapter(MAdapter);
}
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
dialog.dismiss();
}
});
builder.show();
}
});
//zakljucivanje
btnSetFinalMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder2 = new AlertDialog.Builder(StudentReview.this);
builder2.setTitle("Zakljucna ocjena:");
final EditText input2 = new EditText(StudentReview.this);
input2.setInputType(InputType.TYPE_CLASS_NUMBER);
builder2.setView(input2);
builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
setMark = Integer.parseInt(input2.getText().toString());
if(setMark<0||setMark>5){
Toast.makeText(StudentReview.this, "Unesite ocjenu u rasponu 1-5", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(StudentReview.this, "Zakljucili ste ocjenu: "+setMark, Toast.LENGTH_SHORT).show();
stud_sub.setFinalmark(setMark);
stud_sub.save();
tvFinalMark.setText("Zaključna ocjena je: "+setMark);
}
dialog.dismiss();
}
});
builder2.setNegativeButton("Odustani", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
dialog.dismiss();
}
});
builder2.show();
}
});
btnAutoSetFinalMark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = Math.round(avg);
Toast.makeText(StudentReview.this, "Automatski zaključena ocjena je: "+tmp, Toast.LENGTH_SHORT).show();
stud_sub.setFinalmark(tmp);
stud_sub.save();
tvFinalMark.setText("Zaključna ocjena je: "+tmp);
}
});
btnAddAbsence.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = stud_sub.getAbsence();
tmp = tmp+1;
stud_sub.setAbsence(tmp);
stud_sub.save();
tvAbsence.setText(tmp+"");
}
});
btnRmvAbsence.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int tmp = stud_sub.getAbsence();
tmp = tmp-1;
if(tmp>=0) {
stud_sub.setAbsence(tmp);
stud_sub.save();
tvAbsence.setText(tmp + "");
}
}
});
}
private void getAverage() {
List<marks> list = stud_sub.getMarks();
sum=0;
if(list.isEmpty()){
tvAverage.setText("Trebate više ocjena za računanje prosjeka.");
}else{
for(int i = 0;i<list.size();i++){
sum+=list.get(i).getMark();
}
avg = sum/list.size();
tvAverage.setText("Vaš prosjek je: " + avg);
}
}
}
| 8,522 | 0.562889 | 0.559836 | 207 | 40.135265 | 27.191769 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.792271 | false | false |
13
|
228bb4f50ca969dc7ce0a18b00cf7b3ee6759546
| 2,860,448,278,416 |
fe52998b23fbd57bfad48c5e97448cf3f4347e11
|
/src/main/java/io/github/syst3ms/skriptparser/types/changers/Arithmetic.java
|
df14d1cdd569b64fcca805ad8566e0ebf7cc92f7
|
[
"MIT"
] |
permissive
|
Olyno/skript-parser
|
https://github.com/Olyno/skript-parser
|
46eb944ccf098a8691ac98893f3c42cb4ab6bf1c
|
8a5e504b9bee37b7954b22468b9790f2e0ac5787
|
refs/heads/master
| 2021-11-27T08:26:14.914000 | 2021-10-16T16:13:48 | 2021-10-16T16:13:48 | 252,204,193 | 0 | 0 |
MIT
| true | 2020-04-01T14:49:34 | 2020-04-01T14:49:33 | 2020-03-31T18:25:05 | 2020-03-31T18:25:02 | 732 | 0 | 0 | 0 | null | false | false |
package io.github.syst3ms.skriptparser.types.changers;
/**
* An interface describing arithmetic operations between two types
* @param <A> the first type
* @param <R> the second type
*/
public interface Arithmetic<A, R> {
R difference(A first, A second);
A add(A value, R difference);
A subtract(A value, R difference);
Class<? extends R> getRelativeType();
}
|
UTF-8
|
Java
| 384 |
java
|
Arithmetic.java
|
Java
|
[
{
"context": "package io.github.syst3ms.skriptparser.types.changers;\n\n/**\n * An interface",
"end": 25,
"score": 0.9965373873710632,
"start": 18,
"tag": "USERNAME",
"value": "syst3ms"
}
] | null |
[] |
package io.github.syst3ms.skriptparser.types.changers;
/**
* An interface describing arithmetic operations between two types
* @param <A> the first type
* @param <R> the second type
*/
public interface Arithmetic<A, R> {
R difference(A first, A second);
A add(A value, R difference);
A subtract(A value, R difference);
Class<? extends R> getRelativeType();
}
| 384 | 0.692708 | 0.690104 | 17 | 21.588236 | 21.321238 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false |
13
|
57b36e003168e61a814b32e045ce60d9e6dbadd7
| 33,913,061,774,181 |
4358cdc53143ac6bedc25cca926a9ce6a954e021
|
/env2/env/Cell.java
|
e46ccca49c268687a81d1356d9494749ff5e7f3c
|
[] |
no_license
|
belkacemlahouel/WorldsWar
|
https://github.com/belkacemlahouel/WorldsWar
|
2dc6d2457ce12fab9bcbfaf897a5beafdf9b7251
|
c839821b1a49a9284a794e72c0f1a87b981c2862
|
refs/heads/master
| 2021-01-22T20:39:44.268000 | 2016-02-11T18:11:02 | 2016-02-11T18:11:02 | 33,307,920 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package env2.env;
import java.util.ArrayList;
import java.util.List;
import env2.api.AbstractCell;
import env2.api.AbstractWorldObject;
public class Cell extends AbstractCell {
private List<AbstractWorldObject> objects;
public Cell() {
objects = new ArrayList<AbstractWorldObject>();
}
public List<AbstractWorldObject> getObjects() {
return objects;
}
public boolean removeObject(AbstractWorldObject o) {
return objects.remove(o);
}
public void addObject(AbstractWorldObject o) {
objects.add(o);
}
public boolean isPortal() {
return false;
}
}
|
UTF-8
|
Java
| 577 |
java
|
Cell.java
|
Java
|
[] | null |
[] |
package env2.env;
import java.util.ArrayList;
import java.util.List;
import env2.api.AbstractCell;
import env2.api.AbstractWorldObject;
public class Cell extends AbstractCell {
private List<AbstractWorldObject> objects;
public Cell() {
objects = new ArrayList<AbstractWorldObject>();
}
public List<AbstractWorldObject> getObjects() {
return objects;
}
public boolean removeObject(AbstractWorldObject o) {
return objects.remove(o);
}
public void addObject(AbstractWorldObject o) {
objects.add(o);
}
public boolean isPortal() {
return false;
}
}
| 577 | 0.745234 | 0.740035 | 32 | 17.03125 | 17.787785 | 53 | true | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.09375 | false | false |
13
|
4c9f4aac0efb9ce61214773ff8e939372b72ab1b
| 11,493,332,504,322 |
4126f4ea904a0aad10f6ca67c71c8e2759862197
|
/Kattis/src/trivial/StackingCups.java
|
93461e62d7bc2ad504aa6ff474ab3604f23bbc29
|
[] |
no_license
|
Sargot15/Kattis
|
https://github.com/Sargot15/Kattis
|
e1b7fb85c8d5fb5cf0a6313f4481298d91f2bb0c
|
c1aca6397841c4fd32b7224e6c3bb3b13f8646e3
|
refs/heads/master
| 2020-06-30T17:53:50.071000 | 2019-08-14T18:46:24 | 2019-08-14T18:46:24 | 200,901,484 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package trivial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class StackingCups {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Cup> cups = new ArrayList<Cup>();
String lines = sc.nextLine();
for (int i = 0; i < Integer.parseInt(lines); i++){
String[] line = sc.nextLine().split(" ");
if (isInteger(line[0])){
Cup c = new Cup(Integer.parseInt(line[0]) / 2, line[1]);
cups.add(c);
} else {
Cup c = new Cup(Integer.parseInt(line[1]), line[0]);
cups.add(c);
}
}
Collections.sort(cups);
for (Cup c : cups){
System.out.println(c.color);
}
sc.close();
}
public static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch(NumberFormatException e) {
return false;
} catch(NullPointerException e) {
return false;
}
return true;
}
}
class Cup implements Comparable<Cup>{
int size;
String color;
public Cup(int size, String color) {
this.size = size;
this.color = color;
}
@Override
public int compareTo(Cup arg0) {
return this.size - arg0.size;
}
}
|
UTF-8
|
Java
| 1,237 |
java
|
StackingCups.java
|
Java
|
[] | null |
[] |
package trivial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class StackingCups {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Cup> cups = new ArrayList<Cup>();
String lines = sc.nextLine();
for (int i = 0; i < Integer.parseInt(lines); i++){
String[] line = sc.nextLine().split(" ");
if (isInteger(line[0])){
Cup c = new Cup(Integer.parseInt(line[0]) / 2, line[1]);
cups.add(c);
} else {
Cup c = new Cup(Integer.parseInt(line[1]), line[0]);
cups.add(c);
}
}
Collections.sort(cups);
for (Cup c : cups){
System.out.println(c.color);
}
sc.close();
}
public static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch(NumberFormatException e) {
return false;
} catch(NullPointerException e) {
return false;
}
return true;
}
}
class Cup implements Comparable<Cup>{
int size;
String color;
public Cup(int size, String color) {
this.size = size;
this.color = color;
}
@Override
public int compareTo(Cup arg0) {
return this.size - arg0.size;
}
}
| 1,237 | 0.602264 | 0.594988 | 53 | 21.377359 | 15.928172 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false |
13
|
d0533f5e1048084f1cfafc4ad9fa40a2411db02c
| 8,340,826,512,137 |
a8c524e30540909c7ce1ab99b681e56c0c0d62cd
|
/src/idao/BloodIDao.java
|
19177a1a8f5ba1be38216d8f2d51483e737ca27d
|
[] |
no_license
|
skyofme/TankGame
|
https://github.com/skyofme/TankGame
|
c63cc96770c21c7a669b540319fd83f79e78d2a4
|
a3b0b86095f18eb6b446c2d26f68a2e2acf4383f
|
refs/heads/master
| 2020-04-26T01:57:05.719000 | 2019-03-01T02:17:09 | 2019-03-01T02:17:09 | 173,220,195 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package idao;
import java.awt.Graphics;
import java.awt.Rectangle;
/**
* 这是一个BloodIDao类接口
* @author 刘小燕
*
*/
public interface BloodIDao {
/**
* draw方法 用于画出血块
* @param Graphics 类的画笔
*/
public void draw(Graphics g);
/**
* getRect方法用于获取该血块的面积
* @return 返回Rectangle类型的值
*/
public Rectangle getRect();
}
|
GB18030
|
Java
| 401 |
java
|
BloodIDao.java
|
Java
|
[
{
"context": "wt.Rectangle;\n\n/**\n * 这是一个BloodIDao类接口\n * @author 刘小燕\n *\n */\npublic interface BloodIDao {\n\t/**\n\t * draw",
"end": 107,
"score": 0.9997726082801819,
"start": 104,
"tag": "NAME",
"value": "刘小燕"
}
] | null |
[] |
package idao;
import java.awt.Graphics;
import java.awt.Rectangle;
/**
* 这是一个BloodIDao类接口
* @author 刘小燕
*
*/
public interface BloodIDao {
/**
* draw方法 用于画出血块
* @param Graphics 类的画笔
*/
public void draw(Graphics g);
/**
* getRect方法用于获取该血块的面积
* @return 返回Rectangle类型的值
*/
public Rectangle getRect();
}
| 401 | 0.676012 | 0.676012 | 22 | 13.590909 | 10.957186 | 30 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.681818 | false | false |
13
|
61dbd8b61426533c1a96e7566728b2eda1355769
| 20,555,713,487,277 |
4f17301d9d8cfdb77bcbc8fae81991bb101a21fc
|
/rpc-framework-common/src/main/java/com/csu/rpc/coder/NettyDecoder.java
|
ac724b9640077e871f70f7e20ab2c12b8a95c987
|
[] |
no_license
|
cgb-netty/Simple-RPC2
|
https://github.com/cgb-netty/Simple-RPC2
|
cc641f6b021000a23e1a582352413e73759d7659
|
11d392f2ba6b01df366400fc4f45fe5b2a2e141d
|
refs/heads/main
| 2023-05-12T09:20:40.468000 | 2021-05-29T14:43:20 | 2021-05-29T14:43:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.csu.rpc.coder;
import com.csu.rpc.dto.Packet;
import com.csu.rpc.dto.PacketCodeC;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class NettyDecoder extends ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
Packet decode = PacketCodeC.PACKETCODEC.decode(in);
out.add(decode);
}
}
|
UTF-8
|
Java
| 518 |
java
|
NettyDecoder.java
|
Java
|
[] | null |
[] |
package com.csu.rpc.coder;
import com.csu.rpc.dto.Packet;
import com.csu.rpc.dto.PacketCodeC;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class NettyDecoder extends ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
Packet decode = PacketCodeC.PACKETCODEC.decode(in);
out.add(decode);
}
}
| 518 | 0.764479 | 0.764479 | 18 | 27.777779 | 26.523691 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.611111 | false | false |
13
|
68fa8dcf36e3208cefd237cd586f0d7fe25219ff
| 32,839,319,949,680 |
d89f547715d7dde43bbca624d81e8fea57c5c39b
|
/code2/剑指Offer_58-2_左旋转字符串.java
|
6c2518bacf9cef8d1b1f02dd1bf87cd892176c97
|
[] |
no_license
|
renanxin/leetcode
|
https://github.com/renanxin/leetcode
|
e18617c2d7468a49eb28348f1d44defe2a2f1990
|
f6e5c78e6b9ec0d8598ef333b94bac7e9eb4a331
|
refs/heads/master
| 2021-06-24T06:18:14.132000 | 2021-02-15T14:29:31 | 2021-02-15T14:29:31 | 193,859,773 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import leetcode.ListNode;
import leetcode.Node;
import leetcode.SwordTowardOffer;
import leetcode.TreeNode;
import java.util.*;
import java.util.stream.Stream;
class Solution{
// 58-2 左旋转字符串
public String reverseLeftWords(String s, int n) {
StringBuilder builder = new StringBuilder();
builder.append(s.substring(n));
builder.append(s.substring(0,n));
return builder.toString();
}
}
|
UTF-8
|
Java
| 443 |
java
|
剑指Offer_58-2_左旋转字符串.java
|
Java
|
[] | null |
[] |
import leetcode.ListNode;
import leetcode.Node;
import leetcode.SwordTowardOffer;
import leetcode.TreeNode;
import java.util.*;
import java.util.stream.Stream;
class Solution{
// 58-2 左旋转字符串
public String reverseLeftWords(String s, int n) {
StringBuilder builder = new StringBuilder();
builder.append(s.substring(n));
builder.append(s.substring(0,n));
return builder.toString();
}
}
| 443 | 0.693735 | 0.684455 | 19 | 21.68421 | 17.189508 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.631579 | false | false |
13
|
311cae0617dc08dea03a5b8d4b759757cc116f04
| 6,244,882,514,987 |
d16b4588f2fb0a44c3343095f5e0dbe32a242f69
|
/java-ws-template/src/main/java/com/example/myapp/crud/GridManager.java
|
79b4c438aff6d685f54bd6df0b4d39025f8b160c
|
[
"MIT"
] |
permissive
|
luca-vercelli/java-web-template
|
https://github.com/luca-vercelli/java-web-template
|
c46df7e35cb80f725c2830104827b215b1a9e22a
|
e3cdc6d91cf41b7b5fcbbc1f5a17092c9b859510
|
refs/heads/master
| 2022-11-27T01:43:39.418000 | 2021-07-23T17:24:02 | 2021-07-23T17:24:02 | 85,752,303 | 1 | 5 |
MIT
| false | 2022-11-16T12:34:22 | 2017-03-21T20:54:17 | 2021-07-23T17:38:35 | 2022-11-16T12:34:19 | 18,130 | 0 | 5 | 8 |
Java
| false | false |
package com.example.myapp.crud;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType;
import org.slf4j.Logger;
import com.example.myapp.crud.entity.Grid;
import com.example.myapp.crud.entity.GridColumn;
import com.example.myapp.main.enums.BooleanYN;
import com.example.myapp.main.util.Exporter;
@Stateless
public class GridManager {
@PersistenceContext(unitName = "MyPersistenceUnit")
private EntityManager em;
@Inject
DataManager genericManager;
@Inject
Exporter exporter;
@Inject
Logger LOG;
/**
* For a given grid (and entity), extract only the columns specified in the
* Grid.
*
* @param grid
* @return
*/
public List<Object[]> find(Grid grid) {
String query = "SELECT ";
String comma = "";
for (GridColumn c : grid.getColumns()) {
if (c.getOrdering() == null)
continue; // not needed
query += comma;
query += c.getColumnDefinition();
comma = ",";
}
query += " FROM " + grid.getEntity();
// TODO order by? filters?
@SuppressWarnings("unchecked")
List<Object[]> items = em.createQuery(query).getResultList();
return items;
}
public List<Grid> findGridsForEntity(String entity) {
List<Grid> grids = genericManager.findByProperty(Grid.class, "entity", entity);
return grids;
}
/**
* Return a Grid for given entity, and create it if neededd.
*
* @param entity
* @return null if entity does not exist
*/
public Grid getGrid(String entity) {
Class<?> clazz = genericManager.getEntityClass(entity);
if (clazz == null)
return null;
List<Grid> grids = findGridsForEntity(entity);
Grid grid = null;
if (grids.isEmpty())
grid = createDefaultGrid(entity);
else {
if (grids.size() > 1)
LOG.warn("More grids found for entity " + entity
+ ". This is not supported yet. We take the first one.");
grid = grids.get(0);
}
return grid;
}
/**
* Create default Grid. There is no check if Grid already existed or not.
*
* @param entity
* @return
*/
protected Grid createDefaultGrid(String entity) {
Grid grid = new Grid();
grid.setEntity(entity);
grid.setDescription(entity);
// guess there is a better solution
EntityType<?> et = getEntity(entity);
Set<?> attrs = et.getAttributes();
int colnum = 0;
for (Object x : attrs) {
if (x instanceof Attribute) {
Attribute<?, ?> a = (Attribute<?, ?>) x;
grid.getColumns().add(new GridColumn(grid, a.getName(), a.getName(), colnum++, BooleanYN.N));
}
}
grid = genericManager.merge(grid); // FIXME check if columns are saved
return grid;
}
private EntityType<?> getEntity(String entity) {
for (EntityType<?> entityType : em.getMetamodel().getEntities()) {
if (entityType.getName().equals(entity)) {
return entityType;
}
}
return null;
}
/**
* Export grid in XLSX format.
*
* @param grid @return @throws IOException @throws
*/
public File exportXLSX(Grid grid) throws IOException {
List<Object[]> items = find(grid);
// FIXME lambda?
String[] headers = new String[grid.getColumns().size()];
int colnum = 0;
for (GridColumn gc : grid.getColumns()) {
if (gc.getOrdering() == null)
continue; // this means not needed in view
headers[colnum++] = gc.getDescription(); // TODO i18n
}
return exporter.exportXLSX(headers, items);
}
/**
* Export grid in CSV format.
*
* @param grid
* @return
* @throws IOException
*/
public File exportCSV(Grid grid) throws IOException {
List<Object[]> items = find(grid);
// FIXME lambda?
String[] headers = new String[grid.getColumns().size()];
int colnum = 0;
for (GridColumn gc : grid.getColumns()) {
if (gc.getOrdering() == null)
continue; // this means not needed in view
headers[colnum++] = gc.getDescription(); // TODO i18n
}
return exporter.exportCSV(headers, items);
}
}
|
UTF-8
|
Java
| 4,271 |
java
|
GridManager.java
|
Java
|
[] | null |
[] |
package com.example.myapp.crud;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType;
import org.slf4j.Logger;
import com.example.myapp.crud.entity.Grid;
import com.example.myapp.crud.entity.GridColumn;
import com.example.myapp.main.enums.BooleanYN;
import com.example.myapp.main.util.Exporter;
@Stateless
public class GridManager {
@PersistenceContext(unitName = "MyPersistenceUnit")
private EntityManager em;
@Inject
DataManager genericManager;
@Inject
Exporter exporter;
@Inject
Logger LOG;
/**
* For a given grid (and entity), extract only the columns specified in the
* Grid.
*
* @param grid
* @return
*/
public List<Object[]> find(Grid grid) {
String query = "SELECT ";
String comma = "";
for (GridColumn c : grid.getColumns()) {
if (c.getOrdering() == null)
continue; // not needed
query += comma;
query += c.getColumnDefinition();
comma = ",";
}
query += " FROM " + grid.getEntity();
// TODO order by? filters?
@SuppressWarnings("unchecked")
List<Object[]> items = em.createQuery(query).getResultList();
return items;
}
public List<Grid> findGridsForEntity(String entity) {
List<Grid> grids = genericManager.findByProperty(Grid.class, "entity", entity);
return grids;
}
/**
* Return a Grid for given entity, and create it if neededd.
*
* @param entity
* @return null if entity does not exist
*/
public Grid getGrid(String entity) {
Class<?> clazz = genericManager.getEntityClass(entity);
if (clazz == null)
return null;
List<Grid> grids = findGridsForEntity(entity);
Grid grid = null;
if (grids.isEmpty())
grid = createDefaultGrid(entity);
else {
if (grids.size() > 1)
LOG.warn("More grids found for entity " + entity
+ ". This is not supported yet. We take the first one.");
grid = grids.get(0);
}
return grid;
}
/**
* Create default Grid. There is no check if Grid already existed or not.
*
* @param entity
* @return
*/
protected Grid createDefaultGrid(String entity) {
Grid grid = new Grid();
grid.setEntity(entity);
grid.setDescription(entity);
// guess there is a better solution
EntityType<?> et = getEntity(entity);
Set<?> attrs = et.getAttributes();
int colnum = 0;
for (Object x : attrs) {
if (x instanceof Attribute) {
Attribute<?, ?> a = (Attribute<?, ?>) x;
grid.getColumns().add(new GridColumn(grid, a.getName(), a.getName(), colnum++, BooleanYN.N));
}
}
grid = genericManager.merge(grid); // FIXME check if columns are saved
return grid;
}
private EntityType<?> getEntity(String entity) {
for (EntityType<?> entityType : em.getMetamodel().getEntities()) {
if (entityType.getName().equals(entity)) {
return entityType;
}
}
return null;
}
/**
* Export grid in XLSX format.
*
* @param grid @return @throws IOException @throws
*/
public File exportXLSX(Grid grid) throws IOException {
List<Object[]> items = find(grid);
// FIXME lambda?
String[] headers = new String[grid.getColumns().size()];
int colnum = 0;
for (GridColumn gc : grid.getColumns()) {
if (gc.getOrdering() == null)
continue; // this means not needed in view
headers[colnum++] = gc.getDescription(); // TODO i18n
}
return exporter.exportXLSX(headers, items);
}
/**
* Export grid in CSV format.
*
* @param grid
* @return
* @throws IOException
*/
public File exportCSV(Grid grid) throws IOException {
List<Object[]> items = find(grid);
// FIXME lambda?
String[] headers = new String[grid.getColumns().size()];
int colnum = 0;
for (GridColumn gc : grid.getColumns()) {
if (gc.getOrdering() == null)
continue; // this means not needed in view
headers[colnum++] = gc.getDescription(); // TODO i18n
}
return exporter.exportCSV(headers, items);
}
}
| 4,271 | 0.646219 | 0.643877 | 177 | 22.129944 | 21.279684 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.723164 | false | false |
13
|
3187e22c01af12d0722a55fd45ea6ef1655011ac
| 38,749,194,999,434 |
3c67de51a9577128221c19dccf9d220b68762a43
|
/sdk/src/main/java/BEC/NewsRsp.java
|
0b59d53e09e53a5adf44f47fdf9532db19a2751d
|
[] |
no_license
|
w296365959/NF_Project02
|
https://github.com/w296365959/NF_Project02
|
670152a485e75fafbc340cbc6487edef03c8e840
|
a2b6f5a4dbb239891994c8f0895275d8dcd5330b
|
refs/heads/master
| 2020-03-17T03:28:45.510000 | 2019-04-23T16:28:41 | 2019-04-23T16:28:41 | 133,237,038 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package BEC;
public final class NewsRsp extends com.dengtacj.thoth.Message implements java.lang.Cloneable, java.io.Serializable
{
private static final long serialVersionUID = 1L;
public BEC.NewsList stNewsList = null;
public int iStatus = 0;
public String sNextNewsID = "";
public BEC.NewsList getStNewsList()
{
return stNewsList;
}
public void setStNewsList(BEC.NewsList stNewsList)
{
this.stNewsList = stNewsList;
}
public int getIStatus()
{
return iStatus;
}
public void setIStatus(int iStatus)
{
this.iStatus = iStatus;
}
public String getSNextNewsID()
{
return sNextNewsID;
}
public void setSNextNewsID(String sNextNewsID)
{
this.sNextNewsID = sNextNewsID;
}
public NewsRsp()
{
}
public NewsRsp(BEC.NewsList stNewsList, int iStatus, String sNextNewsID)
{
this.stNewsList = stNewsList;
this.iStatus = iStatus;
this.sNextNewsID = sNextNewsID;
}
public void write(com.dengtacj.thoth.BaseEncodeStream eos)
{
com.dengtacj.thoth.BaseEncodeStream ostream = new com.dengtacj.thoth.BaseEncodeStream(eos);
ostream.setCharset(eos.getCharset());
if (null != stNewsList) {
ostream.writeMessage(0, stNewsList);
}
ostream.writeInt32(1, iStatus);
if (null != sNextNewsID) {
ostream.writeString(2, sNextNewsID);
}
}
static BEC.NewsList VAR_TYPE_4_STNEWSLIST = new BEC.NewsList();
public void read(com.dengtacj.thoth.BaseDecodeStream dos)
{
com.dengtacj.thoth.BaseDecodeStream istream = new com.dengtacj.thoth.BaseDecodeStream(dos);
istream.setCharset(dos.getCharset());
this.stNewsList = (BEC.NewsList)istream.readMessage(0, false, VAR_TYPE_4_STNEWSLIST);
this.iStatus = (int)istream.readInt32(1, false, this.iStatus);
this.sNextNewsID = (String)istream.readString(2, false, this.sNextNewsID);
}
}
|
UTF-8
|
Java
| 2,041 |
java
|
NewsRsp.java
|
Java
|
[] | null |
[] |
package BEC;
public final class NewsRsp extends com.dengtacj.thoth.Message implements java.lang.Cloneable, java.io.Serializable
{
private static final long serialVersionUID = 1L;
public BEC.NewsList stNewsList = null;
public int iStatus = 0;
public String sNextNewsID = "";
public BEC.NewsList getStNewsList()
{
return stNewsList;
}
public void setStNewsList(BEC.NewsList stNewsList)
{
this.stNewsList = stNewsList;
}
public int getIStatus()
{
return iStatus;
}
public void setIStatus(int iStatus)
{
this.iStatus = iStatus;
}
public String getSNextNewsID()
{
return sNextNewsID;
}
public void setSNextNewsID(String sNextNewsID)
{
this.sNextNewsID = sNextNewsID;
}
public NewsRsp()
{
}
public NewsRsp(BEC.NewsList stNewsList, int iStatus, String sNextNewsID)
{
this.stNewsList = stNewsList;
this.iStatus = iStatus;
this.sNextNewsID = sNextNewsID;
}
public void write(com.dengtacj.thoth.BaseEncodeStream eos)
{
com.dengtacj.thoth.BaseEncodeStream ostream = new com.dengtacj.thoth.BaseEncodeStream(eos);
ostream.setCharset(eos.getCharset());
if (null != stNewsList) {
ostream.writeMessage(0, stNewsList);
}
ostream.writeInt32(1, iStatus);
if (null != sNextNewsID) {
ostream.writeString(2, sNextNewsID);
}
}
static BEC.NewsList VAR_TYPE_4_STNEWSLIST = new BEC.NewsList();
public void read(com.dengtacj.thoth.BaseDecodeStream dos)
{
com.dengtacj.thoth.BaseDecodeStream istream = new com.dengtacj.thoth.BaseDecodeStream(dos);
istream.setCharset(dos.getCharset());
this.stNewsList = (BEC.NewsList)istream.readMessage(0, false, VAR_TYPE_4_STNEWSLIST);
this.iStatus = (int)istream.readInt32(1, false, this.iStatus);
this.sNextNewsID = (String)istream.readString(2, false, this.sNextNewsID);
}
}
| 2,041 | 0.645762 | 0.638902 | 81 | 24.185184 | 28.030895 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45679 | false | false |
13
|
a34a5486564febccdc54ffd6506c1ee0220f884d
| 38,646,115,757,287 |
a84f9e443ef6214714e9b948b1141a4f2b170961
|
/src/net/athenamc/spigot/core/staff/StaffModule.java
|
1e862c02399983f226ccfcf5559036aa81cd5220
|
[] |
no_license
|
ZarpaoMC/AthenaCore
|
https://github.com/ZarpaoMC/AthenaCore
|
d930dda0ebff90f7fd352fe72fec9d4d35d1a699
|
96264a132ba9107312d70f0db319a1031d8ba36c
|
refs/heads/master
| 2021-06-22T06:57:56.751000 | 2017-06-13T21:44:43 | 2017-06-13T21:44:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package net.athenamc.spigot.core.staff;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.messaging.PluginMessageListener;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import net.athenamc.core.exceptions.PermissionRequiredException;
import net.athenamc.core.ranks.RankAPI;
import net.athenamc.spigot.core.SpigotCore;
public class StaffModule implements CommandExecutor, Listener, PluginMessageListener {
private SpigotCore plugin;
private HashSet<UUID> staffChat, hidden;
private boolean muted = false;
private HashMap<UUID, Long> cooldown;
public StaffModule(SpigotCore plugin) {
this.plugin = plugin;
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", this);
staffChat = new HashSet<UUID>();
hidden = new HashSet<UUID>();
cooldown = new HashMap<UUID, Long>();
plugin.getCommand("staffchat").setExecutor(this);
plugin.getCommand("chatmute").setExecutor(this);
plugin.getCommand("chatunmute").setExecutor(this);
plugin.getCommand("chatclear").setExecutor(this);
plugin.getCommand("show").setExecutor(this);
plugin.getCommand("hide").setExecutor(this);
plugin.getCommand("fly").setExecutor(this);
plugin.getCommand("flyspeed").setExecutor(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void onDisable() {
for (UUID uuid : hidden) {
Player hiddenplayer = Bukkit.getPlayer(uuid);
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(hiddenplayer);
}
}
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
if (cmd.getName().equalsIgnoreCase("staffchat")) {
plugin.checkPerm(sender, "core.staff.chat");
if (args.length > 0) {
StringBuilder sb = new StringBuilder();
for (String s : args)
sb.append(s).append(" ");
sendMessage(sender, sb.toString().trim());
} else if (sender instanceof Player) {
toggleStaffChat((Player) sender);
} else
return false;
} else if (cmd.getName().equalsIgnoreCase("chatclear")) {
plugin.checkPerm(sender, "core.staff.chat.clear");
String s = " ";
for (int i = 0; i < 100; i++)
Bukkit.broadcastMessage(s += " ");
Bukkit.broadcastMessage(ChatColor.RED + "Chat was cleared by " + ChatColor.DARK_RED + sender.getName());
} else if (cmd.getName().equalsIgnoreCase("chatmute")) {
plugin.checkPerm(sender, "core.staff.chat.mute");
if (!muted)
Bukkit.broadcastMessage(
ChatColor.RED + "Chat was muted by " + ChatColor.DARK_RED + sender.getName());
muted = true;
} else if (cmd.getName().equalsIgnoreCase("chatunmute")) {
plugin.checkPerm(sender, "core.staff.chat.unmute");
if (muted)
Bukkit.broadcastMessage(
ChatColor.RED + "Chat was unmuted by " + ChatColor.DARK_RED + sender.getName());
muted = false;
} else if (sender instanceof Player) {
Player send = (Player) sender;
if (cmd.getName().equalsIgnoreCase("hide")) {
plugin.checkPerm(sender, "core.staff.hide");
if (!hidden.contains(send.getUniqueId())) {
hidden.add(send.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
if (!player.hasPermission("core.staff.seehidden"))
player.hidePlayer(send);
}
sender.sendMessage(ChatColor.GREEN + "You are now hidden from non staff members!");
}
} else if (cmd.getName().equalsIgnoreCase("show")) {
plugin.checkPerm(sender, "core.staff.hide");
if (hidden.contains(send.getUniqueId())) {
hidden.remove(send.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(send);
}
sender.sendMessage(ChatColor.RED + "You are now visible to all members!");
}
} else if (cmd.getName().equalsIgnoreCase("fly")) {
plugin.checkPerm(sender, "core.staff.fly");
if (send.getAllowFlight())
send.setFlying(false);
send.setAllowFlight(!send.getAllowFlight());
sender.sendMessage(ChatColor.GOLD + "You have "
+ (send.getAllowFlight() ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
+ ChatColor.GOLD + " Flight mode!");
} else if (cmd.getName().equalsIgnoreCase("flyspeed")) {
plugin.checkPerm(sender, "core.staff.flyspeed");
if (args.length > 0) {
Float speed = Float.parseFloat(args[0]);
if (speed >= 0.01 && speed <= 1) {
send.setFlySpeed(speed);
sender.sendMessage(ChatColor.GOLD + "Flight speed set to " + ChatColor.GREEN + speed);
} else
sender.sendMessage(ChatColor.RED + "Fly speed must be between 0.01 and 1.0");
} else
return false;
}
} else
return false;
} catch (PermissionRequiredException e) {
sender.sendMessage(
ChatColor.RED + "You must have the permission " + e.getPermission() + " to perform that command");
} catch (NumberFormatException nfe) {
sender.sendMessage(ChatColor.RED + "You entered an invalid number");
}
return true;
}
private void sendMessage(CommandSender sender, String message) {
Player player = Iterables.getFirst(Bukkit.getOnlinePlayers(), null);
if (player != null) {
String msg = ChatColor.GRAY.toString() + ChatColor.BOLD + "[" + ChatColor.GREEN + ChatColor.BOLD + "STAFF"
+ ChatColor.GRAY + ChatColor.BOLD + "]: "
+ (sender instanceof Player
? plugin.getRankApi().getRank(((Player) sender).getUniqueId()).getPrefix() + " " : "")
+ ChatColor.WHITE + sender.getName() + ChatColor.GRAY + ": " + ChatColor.GREEN + message;
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission("core.staff.chat"))
p.sendMessage(msg);
Bukkit.getLogger().info(msg);
try {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ONLINE");
out.writeUTF("BungeeCord");
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF("StaffChat");
msgout.writeUTF(msg);
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
} else {
sender.sendMessage(ChatColor.RED + "Chat message unable to send");
}
}
public void sendReport(Player player, OfflinePlayer reportee) {
String msg = ChatColor.GRAY + "" + ChatColor.BOLD + "[" + ChatColor.GREEN + ChatColor.BOLD + "STAFF"
+ ChatColor.GRAY + ChatColor.BOLD + "]: " + ChatColor.GRAY + "Report on " + ChatColor.RED
+ reportee.getName() + ChatColor.GRAY + " by " + ChatColor.GREEN + player.getName() + ChatColor.GRAY
+ " on server " + ChatColor.DARK_PURPLE + plugin.getBungeeName();
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission("core.staff.report"))
p.sendMessage(msg);
Bukkit.getLogger().info(msg);
try {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ONLINE");
out.writeUTF("BungeeCord");
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF("Report");
msgout.writeUTF(msg);
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
}
public void toggleStaffChat(Player player) {
if (staffChat.contains(player.getUniqueId())) {
staffChat.remove(player.getUniqueId());
player.sendMessage(ChatColor.RED + "You have left staffchat");
} else {
staffChat.add(player.getUniqueId());
player.sendMessage(ChatColor.GREEN + "You have entered staffchat");
}
}
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
try {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(data);
String subchannel = in.readUTF();
if (subchannel.equals("Forward")) {
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
String messageType = msgin.readUTF();
String perm = "";
if (messageType.equalsIgnoreCase("StaffChat"))
perm = "core.staff.chat";
else if (messageType.equalsIgnoreCase("Report"))
perm = "core.staff.report";
String msg = msgin.readUTF();
Bukkit.getLogger().info(msg);
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission(perm))
p.sendMessage(msg);
}
} catch (IOException e) {
e.printStackTrace();
}
}
@EventHandler
private void chatEvent(AsyncPlayerChatEvent e) {
if (staffChat.contains(e.getPlayer().getUniqueId())) {
e.setCancelled(true);
sendMessage(e.getPlayer(), e.getMessage());
}
if (muted && !e.getPlayer().hasPermission("core.staff.chatmute.bypass"))
e.setCancelled(true);
}
@EventHandler
private void join(PlayerJoinEvent e) {
if (!e.getPlayer().hasPermission("core.staff.seehidden"))
for (UUID uuid : hidden)
e.getPlayer().hidePlayer(Bukkit.getPlayer(uuid));
}
@EventHandler
private void quit(PlayerQuitEvent e) {
if (hidden.contains(e.getPlayer())) {
hidden.remove(e.getPlayer().getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(e.getPlayer());
}
}
}
}
|
UTF-8
|
Java
| 10,577 |
java
|
StaffModule.java
|
Java
|
[] | null |
[] |
package net.athenamc.spigot.core.staff;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.messaging.PluginMessageListener;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import net.athenamc.core.exceptions.PermissionRequiredException;
import net.athenamc.core.ranks.RankAPI;
import net.athenamc.spigot.core.SpigotCore;
public class StaffModule implements CommandExecutor, Listener, PluginMessageListener {
private SpigotCore plugin;
private HashSet<UUID> staffChat, hidden;
private boolean muted = false;
private HashMap<UUID, Long> cooldown;
public StaffModule(SpigotCore plugin) {
this.plugin = plugin;
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", this);
staffChat = new HashSet<UUID>();
hidden = new HashSet<UUID>();
cooldown = new HashMap<UUID, Long>();
plugin.getCommand("staffchat").setExecutor(this);
plugin.getCommand("chatmute").setExecutor(this);
plugin.getCommand("chatunmute").setExecutor(this);
plugin.getCommand("chatclear").setExecutor(this);
plugin.getCommand("show").setExecutor(this);
plugin.getCommand("hide").setExecutor(this);
plugin.getCommand("fly").setExecutor(this);
plugin.getCommand("flyspeed").setExecutor(this);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void onDisable() {
for (UUID uuid : hidden) {
Player hiddenplayer = Bukkit.getPlayer(uuid);
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(hiddenplayer);
}
}
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
if (cmd.getName().equalsIgnoreCase("staffchat")) {
plugin.checkPerm(sender, "core.staff.chat");
if (args.length > 0) {
StringBuilder sb = new StringBuilder();
for (String s : args)
sb.append(s).append(" ");
sendMessage(sender, sb.toString().trim());
} else if (sender instanceof Player) {
toggleStaffChat((Player) sender);
} else
return false;
} else if (cmd.getName().equalsIgnoreCase("chatclear")) {
plugin.checkPerm(sender, "core.staff.chat.clear");
String s = " ";
for (int i = 0; i < 100; i++)
Bukkit.broadcastMessage(s += " ");
Bukkit.broadcastMessage(ChatColor.RED + "Chat was cleared by " + ChatColor.DARK_RED + sender.getName());
} else if (cmd.getName().equalsIgnoreCase("chatmute")) {
plugin.checkPerm(sender, "core.staff.chat.mute");
if (!muted)
Bukkit.broadcastMessage(
ChatColor.RED + "Chat was muted by " + ChatColor.DARK_RED + sender.getName());
muted = true;
} else if (cmd.getName().equalsIgnoreCase("chatunmute")) {
plugin.checkPerm(sender, "core.staff.chat.unmute");
if (muted)
Bukkit.broadcastMessage(
ChatColor.RED + "Chat was unmuted by " + ChatColor.DARK_RED + sender.getName());
muted = false;
} else if (sender instanceof Player) {
Player send = (Player) sender;
if (cmd.getName().equalsIgnoreCase("hide")) {
plugin.checkPerm(sender, "core.staff.hide");
if (!hidden.contains(send.getUniqueId())) {
hidden.add(send.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
if (!player.hasPermission("core.staff.seehidden"))
player.hidePlayer(send);
}
sender.sendMessage(ChatColor.GREEN + "You are now hidden from non staff members!");
}
} else if (cmd.getName().equalsIgnoreCase("show")) {
plugin.checkPerm(sender, "core.staff.hide");
if (hidden.contains(send.getUniqueId())) {
hidden.remove(send.getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(send);
}
sender.sendMessage(ChatColor.RED + "You are now visible to all members!");
}
} else if (cmd.getName().equalsIgnoreCase("fly")) {
plugin.checkPerm(sender, "core.staff.fly");
if (send.getAllowFlight())
send.setFlying(false);
send.setAllowFlight(!send.getAllowFlight());
sender.sendMessage(ChatColor.GOLD + "You have "
+ (send.getAllowFlight() ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
+ ChatColor.GOLD + " Flight mode!");
} else if (cmd.getName().equalsIgnoreCase("flyspeed")) {
plugin.checkPerm(sender, "core.staff.flyspeed");
if (args.length > 0) {
Float speed = Float.parseFloat(args[0]);
if (speed >= 0.01 && speed <= 1) {
send.setFlySpeed(speed);
sender.sendMessage(ChatColor.GOLD + "Flight speed set to " + ChatColor.GREEN + speed);
} else
sender.sendMessage(ChatColor.RED + "Fly speed must be between 0.01 and 1.0");
} else
return false;
}
} else
return false;
} catch (PermissionRequiredException e) {
sender.sendMessage(
ChatColor.RED + "You must have the permission " + e.getPermission() + " to perform that command");
} catch (NumberFormatException nfe) {
sender.sendMessage(ChatColor.RED + "You entered an invalid number");
}
return true;
}
private void sendMessage(CommandSender sender, String message) {
Player player = Iterables.getFirst(Bukkit.getOnlinePlayers(), null);
if (player != null) {
String msg = ChatColor.GRAY.toString() + ChatColor.BOLD + "[" + ChatColor.GREEN + ChatColor.BOLD + "STAFF"
+ ChatColor.GRAY + ChatColor.BOLD + "]: "
+ (sender instanceof Player
? plugin.getRankApi().getRank(((Player) sender).getUniqueId()).getPrefix() + " " : "")
+ ChatColor.WHITE + sender.getName() + ChatColor.GRAY + ": " + ChatColor.GREEN + message;
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission("core.staff.chat"))
p.sendMessage(msg);
Bukkit.getLogger().info(msg);
try {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ONLINE");
out.writeUTF("BungeeCord");
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF("StaffChat");
msgout.writeUTF(msg);
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
} else {
sender.sendMessage(ChatColor.RED + "Chat message unable to send");
}
}
public void sendReport(Player player, OfflinePlayer reportee) {
String msg = ChatColor.GRAY + "" + ChatColor.BOLD + "[" + ChatColor.GREEN + ChatColor.BOLD + "STAFF"
+ ChatColor.GRAY + ChatColor.BOLD + "]: " + ChatColor.GRAY + "Report on " + ChatColor.RED
+ reportee.getName() + ChatColor.GRAY + " by " + ChatColor.GREEN + player.getName() + ChatColor.GRAY
+ " on server " + ChatColor.DARK_PURPLE + plugin.getBungeeName();
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission("core.staff.report"))
p.sendMessage(msg);
Bukkit.getLogger().info(msg);
try {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF("ONLINE");
out.writeUTF("BungeeCord");
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF("Report");
msgout.writeUTF(msg);
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
}
public void toggleStaffChat(Player player) {
if (staffChat.contains(player.getUniqueId())) {
staffChat.remove(player.getUniqueId());
player.sendMessage(ChatColor.RED + "You have left staffchat");
} else {
staffChat.add(player.getUniqueId());
player.sendMessage(ChatColor.GREEN + "You have entered staffchat");
}
}
public void onPluginMessageReceived(String channel, Player player, byte[] data) {
try {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(data);
String subchannel = in.readUTF();
if (subchannel.equals("Forward")) {
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
String messageType = msgin.readUTF();
String perm = "";
if (messageType.equalsIgnoreCase("StaffChat"))
perm = "core.staff.chat";
else if (messageType.equalsIgnoreCase("Report"))
perm = "core.staff.report";
String msg = msgin.readUTF();
Bukkit.getLogger().info(msg);
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission(perm))
p.sendMessage(msg);
}
} catch (IOException e) {
e.printStackTrace();
}
}
@EventHandler
private void chatEvent(AsyncPlayerChatEvent e) {
if (staffChat.contains(e.getPlayer().getUniqueId())) {
e.setCancelled(true);
sendMessage(e.getPlayer(), e.getMessage());
}
if (muted && !e.getPlayer().hasPermission("core.staff.chatmute.bypass"))
e.setCancelled(true);
}
@EventHandler
private void join(PlayerJoinEvent e) {
if (!e.getPlayer().hasPermission("core.staff.seehidden"))
for (UUID uuid : hidden)
e.getPlayer().hidePlayer(Bukkit.getPlayer(uuid));
}
@EventHandler
private void quit(PlayerQuitEvent e) {
if (hidden.contains(e.getPlayer())) {
hidden.remove(e.getPlayer().getUniqueId());
for (Player player : Bukkit.getOnlinePlayers()) {
player.showPlayer(e.getPlayer());
}
}
}
}
| 10,577 | 0.675144 | 0.673631 | 288 | 34.725693 | 25.259165 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.340278 | false | false |
13
|
a122d4ab72a9208ca971f1d0fc6233d220f99584
| 35,287,451,359,961 |
f0edbe898b6b81c2c6fa721bb5142715a96abb20
|
/library/src/main/java/com/jack/library/camera/CameraStorage.java
|
acdbca3f1cd836aaaa0e2f4b635743d32bb58e34
|
[] |
no_license
|
jack21024/FloatCamera
|
https://github.com/jack21024/FloatCamera
|
d30de889e9e81df9aa4b7988b6d829289cc280f7
|
03482624c73a7f42dd11b93cc03ae4d11abc699f
|
refs/heads/master
| 2021-01-17T07:42:24.816000 | 2016-07-05T06:59:48 | 2016-07-05T06:59:48 | 38,156,611 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.jack.library.camera;
import java.util.List;
/**
* This class is used to help accessing camera record (image, video) to storage which may a external
* storage or a web service.
* <p/>
* Author: Jack Tseng (jack21024@gmail.com)
*/
public interface CameraStorage {
/**
* Lists all of support storage's type
*/
public static enum STORAGE_TYPE {
LOCAL_DEFAULT,
REMOTE_DEFAULT //not implemented
}
/**
* Sets the root path which can be a file description, uri, url for storage accessing
*
* @param root
*/
public void setRoot(String root);
/**
* Gets the root path which is a file path, uri, url etc.
*
* @return
*/
public String getRoot();
/**
* Saves a record to storage
*
* @param record
* @return
*/
public boolean save(CameraRecord record);
/**
* Gets a list of thumbnails which are used to represent the record that accessing from storage
*
* @return
*/
public List<CameraRecord> loadThumbnail();
/**
* Loads a resource of record which can be a image or video
*
* @param record
* @return
*/
public Object loadResource(CameraRecord record);
}
|
UTF-8
|
Java
| 1,255 |
java
|
CameraStorage.java
|
Java
|
[
{
"context": "al\n * storage or a web service.\n * <p/>\n * Author: Jack Tseng (jack21024@gmail.com)\n */\npublic interface Camera",
"end": 221,
"score": 0.9998757243156433,
"start": 211,
"tag": "NAME",
"value": "Jack Tseng"
},
{
"context": " or a web service.\n * <p/>\n * Author: Jack Tseng (jack21024@gmail.com)\n */\npublic interface CameraStorage {\n\n /**\n ",
"end": 242,
"score": 0.9999234080314636,
"start": 223,
"tag": "EMAIL",
"value": "jack21024@gmail.com"
}
] | null |
[] |
package com.jack.library.camera;
import java.util.List;
/**
* This class is used to help accessing camera record (image, video) to storage which may a external
* storage or a web service.
* <p/>
* Author: <NAME> (<EMAIL>)
*/
public interface CameraStorage {
/**
* Lists all of support storage's type
*/
public static enum STORAGE_TYPE {
LOCAL_DEFAULT,
REMOTE_DEFAULT //not implemented
}
/**
* Sets the root path which can be a file description, uri, url for storage accessing
*
* @param root
*/
public void setRoot(String root);
/**
* Gets the root path which is a file path, uri, url etc.
*
* @return
*/
public String getRoot();
/**
* Saves a record to storage
*
* @param record
* @return
*/
public boolean save(CameraRecord record);
/**
* Gets a list of thumbnails which are used to represent the record that accessing from storage
*
* @return
*/
public List<CameraRecord> loadThumbnail();
/**
* Loads a resource of record which can be a image or video
*
* @param record
* @return
*/
public Object loadResource(CameraRecord record);
}
| 1,239 | 0.606375 | 0.60239 | 58 | 20.637932 | 24.169443 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.224138 | false | false |
13
|
2c6ba1bdeeeb86086fb3fd1384a75299c36f9d97
| 35,192,962,074,913 |
213bd12729cc67ec9b6fcc5a857fd7ab3fc01b6d
|
/src/test/java/com/morley/betfair/compression/HistoricDataUtilsTest.java
|
d86467edcf17ae19c66ce36c692f97d4dc7d6b48
|
[] |
no_license
|
enrobsop/bf-compression
|
https://github.com/enrobsop/bf-compression
|
d03f57247ea3f20f04b066a2c87e9b50cabd9f3c
|
bbb41cb47a6d045e4eea18cafcb81ab2cb992343
|
refs/heads/master
| 2016-09-05T13:02:48.139000 | 2014-07-15T13:08:12 | 2014-07-15T13:08:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
* File: HistoricDataUtilsTest.java
* Project: BetfairOptimisation
* Created By: Paul Osborne, Morley Computing Limited.
* Created On: 23 Jul 2009, 16:32:21
* Copyright: Paul Osborne and Morley Computing Limited.
* Contact: www.morley-computing.co.uk, info@morley-computing.co.uk
*
* This code is not to be used without permission of the author.
*/
package com.morley.betfair.compression;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.morley.betfair.compression.HistoricDataFilter;
import com.morley.betfair.compression.HistoricDataUtils;
import com.morley.betfair.compression.RawData;
/**
* Tests {@link com.morley.betfair.compression.HistoricDataUtils}.s
*
* @author Paul Osborne, Morley Computing Ltd. www.morley-computing.co.uk
*/
@RunWith (JMock.class)
public class HistoricDataUtilsTest {
private Mockery context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
private int n = 20;
private List<RawData> unfilteredData;
@Before
public void setUp() throws Exception {
unfilteredData = new ArrayList<RawData>();
RawData d;
for (int i = 0; i < 20; i++) {
d = context.mock(RawData.class, "historicdata" + i);
unfilteredData.add(d);
}
}
@After
public void tearDown() throws Exception {
}
@Test
public void filterListHistoricData() {
// Test null data.
List<RawData> filtered = HistoricDataUtils.filter(null, null);
assertNotNull(filtered);
assertEquals(0, filtered.size());
// Test null filter.
filtered = HistoricDataUtils.filter(unfilteredData, null);
assertNotNull(filtered);
assertEquals(n, filtered.size());
// Test valid filter.
filtered = HistoricDataUtils.filter(unfilteredData, new HistoricDataFilter<RawData>() {
boolean isOkay = true;
@Override
public boolean accept(RawData data) {
isOkay = !isOkay;
return isOkay;
}
});
assertNotNull(filtered);
assertEquals(n/2, filtered.size());
}
}
|
UTF-8
|
Java
| 2,420 |
java
|
HistoricDataUtilsTest.java
|
Java
|
[
{
"context": " * Project: BetfairOptimisation\r\n * Created By: Paul Osborne, Morley Computing Limited.\r\n * Created On: 23 Jul",
"end": 111,
"score": 0.9998999834060669,
"start": 99,
"tag": "NAME",
"value": "Paul Osborne"
},
{
"context": " Created On: 23 Jul 2009, 16:32:21\r\n * Copyright: Paul Osborne and Morley Computing Limited.\r\n * Contact: www",
"end": 205,
"score": 0.9999015927314758,
"start": 193,
"tag": "NAME",
"value": "Paul Osborne"
},
{
"context": "mited.\r\n * Contact: www.morley-computing.co.uk, info@morley-computing.co.uk\r\n *\r\n * This code is not to be used without permi",
"end": 307,
"score": 0.9999284744262695,
"start": 280,
"tag": "EMAIL",
"value": "info@morley-computing.co.uk"
},
{
"context": "r.compression.HistoricDataUtils}.s\r\n *\r\n * @author Paul Osborne, Morley Computing Ltd. www.morley-computing.co.uk",
"end": 1127,
"score": 0.9999006390571594,
"start": 1115,
"tag": "NAME",
"value": "Paul Osborne"
}
] | null |
[] |
/**
* File: HistoricDataUtilsTest.java
* Project: BetfairOptimisation
* Created By: <NAME>, Morley Computing Limited.
* Created On: 23 Jul 2009, 16:32:21
* Copyright: <NAME> and Morley Computing Limited.
* Contact: www.morley-computing.co.uk, <EMAIL>
*
* This code is not to be used without permission of the author.
*/
package com.morley.betfair.compression;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.List;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.morley.betfair.compression.HistoricDataFilter;
import com.morley.betfair.compression.HistoricDataUtils;
import com.morley.betfair.compression.RawData;
/**
* Tests {@link com.morley.betfair.compression.HistoricDataUtils}.s
*
* @author <NAME>, Morley Computing Ltd. www.morley-computing.co.uk
*/
@RunWith (JMock.class)
public class HistoricDataUtilsTest {
private Mockery context = new JUnit4Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
private int n = 20;
private List<RawData> unfilteredData;
@Before
public void setUp() throws Exception {
unfilteredData = new ArrayList<RawData>();
RawData d;
for (int i = 0; i < 20; i++) {
d = context.mock(RawData.class, "historicdata" + i);
unfilteredData.add(d);
}
}
@After
public void tearDown() throws Exception {
}
@Test
public void filterListHistoricData() {
// Test null data.
List<RawData> filtered = HistoricDataUtils.filter(null, null);
assertNotNull(filtered);
assertEquals(0, filtered.size());
// Test null filter.
filtered = HistoricDataUtils.filter(unfilteredData, null);
assertNotNull(filtered);
assertEquals(n, filtered.size());
// Test valid filter.
filtered = HistoricDataUtils.filter(unfilteredData, new HistoricDataFilter<RawData>() {
boolean isOkay = true;
@Override
public boolean accept(RawData data) {
isOkay = !isOkay;
return isOkay;
}
});
assertNotNull(filtered);
assertEquals(n/2, filtered.size());
}
}
| 2,382 | 0.709091 | 0.699587 | 87 | 25.816092 | 22.176165 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.37931 | false | false |
13
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.