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
sequence | 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
sequence | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cfe17a74276a4ec407a0efce901f942ed7252e84 | 15,238,544,012,454 | 7a60f17b1fe7798eadc93bc6dd54b81befed499c | /src/main/java/com/tb24/blenderumap/Config.java | 9b48232a088829b5a59b427dad8c149a22fec36d | [] | no_license | Julian0555/BlenderUmap | https://github.com/Julian0555/BlenderUmap | 322c614b2424112e546851d83633715fc6213ace | b1d5c76b8dea0b741782cc048929dde45eb67596 | refs/heads/master | 2023-07-13T12:22:20.940000 | 2021-08-24T16:28:38 | 2021-08-24T16:28:38 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tb24.blenderumap;
import me.fungames.jfortniteparse.ue4.versions.Ue4Version;
import java.util.Collections;
import java.util.List;
public class Config {
public String PaksDirectory = "C:\\Program Files\\Epic Games\\Fortnite\\FortniteGame\\Content\\Paks";
public Ue4Version UEVersion = Ue4Version.GAME_UE4_LATEST;
public List<MyFileProvider.EncryptionKey> EncryptionKeys = Collections.emptyList();
public boolean bDumpAssets = false;
public int ObjectCacheSize = 100;
public boolean bReadMaterials = true;
public boolean bExportToDDSWhenPossible = true;
public boolean bExportBuildingFoundations = true;
public String ExportPackage;
} | UTF-8 | Java | 683 | java | Config.java | Java | [
{
"context": "package com.tb24.blenderumap;\n\nimport me.fungames.jfortniteparse.ue4.versions.Ue4Version;\n\nimport j",
"end": 49,
"score": 0.7747933268547058,
"start": 45,
"tag": "USERNAME",
"value": "ames"
}
] | null | [] | package com.tb24.blenderumap;
import me.fungames.jfortniteparse.ue4.versions.Ue4Version;
import java.util.Collections;
import java.util.List;
public class Config {
public String PaksDirectory = "C:\\Program Files\\Epic Games\\Fortnite\\FortniteGame\\Content\\Paks";
public Ue4Version UEVersion = Ue4Version.GAME_UE4_LATEST;
public List<MyFileProvider.EncryptionKey> EncryptionKeys = Collections.emptyList();
public boolean bDumpAssets = false;
public int ObjectCacheSize = 100;
public boolean bReadMaterials = true;
public boolean bExportToDDSWhenPossible = true;
public boolean bExportBuildingFoundations = true;
public String ExportPackage;
} | 683 | 0.774524 | 0.759883 | 18 | 37 | 28.528738 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.722222 | false | false | 2 |
b58bbadd2fec9ea246938c5734440ee4f1e1464e | 27,058,294,005,569 | bccd2b03d4ffeca8da8852ed906f70b2f409b4a2 | /src/dazecore/commands/DeleteGroupCommand.java | 59ba44922a7a8208f76295547d4a4e22416db2f6 | [] | no_license | Devenu/DzzeCore | https://github.com/Devenu/DzzeCore | faedbb8a3bbf00c95992b5fc8d244447578c3478 | 9e7855df53fa18a4b45d51a1756f841e47c636da | refs/heads/main | 2023-04-05T19:38:26.591000 | 2021-04-29T20:46:49 | 2021-04-29T20:46:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dazecore.commands;
import dazecore.main.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
public class DeleteGroupCommand implements CommandExecutor {
Main main;
public DeleteGroupCommand(Main main) {
this.main = main;
}
PermissionAttachment attachment;
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
if(cmd.getLabel().equalsIgnoreCase("deletegroup")){
if(!p.hasPermission("core.deletegroup")){
p.sendMessage(checkCC("&5[Permissions]&8: &cInvalid permissions."));
} else {
if(args.length == 0){
return false;
}
if(args.length == 1){
String group = args[0];
if(!main.fm.getGroups().contains("groups." + group)){
p.sendMessage(checkCC("&5[Permissions]&8: &cThat group does not exist."));
} else {
main.getConfig().set("groups." + group, null);
main.fm.saveGroups();
p.sendMessage(checkCC("&5[Permissions]&8: &aSuccessfully deleted group &b" + group));
}
}
}
}
return true;
}
public String checkCC(String string){
return ChatColor.translateAlternateColorCodes('&', string);
}
}
| UTF-8 | Java | 1,783 | java | DeleteGroupCommand.java | Java | [] | null | [] | package dazecore.commands;
import dazecore.main.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
public class DeleteGroupCommand implements CommandExecutor {
Main main;
public DeleteGroupCommand(Main main) {
this.main = main;
}
PermissionAttachment attachment;
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
if(cmd.getLabel().equalsIgnoreCase("deletegroup")){
if(!p.hasPermission("core.deletegroup")){
p.sendMessage(checkCC("&5[Permissions]&8: &cInvalid permissions."));
} else {
if(args.length == 0){
return false;
}
if(args.length == 1){
String group = args[0];
if(!main.fm.getGroups().contains("groups." + group)){
p.sendMessage(checkCC("&5[Permissions]&8: &cThat group does not exist."));
} else {
main.getConfig().set("groups." + group, null);
main.fm.saveGroups();
p.sendMessage(checkCC("&5[Permissions]&8: &aSuccessfully deleted group &b" + group));
}
}
}
}
return true;
}
public String checkCC(String string){
return ChatColor.translateAlternateColorCodes('&', string);
}
}
| 1,783 | 0.563096 | 0.557487 | 50 | 33.66 | 26.954487 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56 | false | false | 2 |
e224cd358802987b2b16278d7e1d61fcd988f4de | 33,011,118,688,283 | 40620e23fe016fe52c0b5ac065a3d9fa412511ce | /src/com/company/lw02/entry/Entry.java | 3634fe1fb2e1e9cf00c50d68161b6f6b82e6314a | [] | no_license | GenesisFoxtrot1972/Lab2 | https://github.com/GenesisFoxtrot1972/Lab2 | 55f71de1060681d35a6ce2c36ad9d06c527183f7 | 22980373f0d6fff208566e2d44de434c3c15f084 | refs/heads/master | 2021-01-25T12:08:35.763000 | 2014-04-11T13:30:32 | 2014-04-11T13:30:32 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company.lw02.entry;
import com.company.lw02.controller.*;
import com.company.lw02.view.*;
/**
* Created by Pyzhic Valeriy on 8/04/2014;
*/
public class Entry {
public static void main(String args[]){
Controller cont = new Controller();
View view = new View();
cont.setView(view);
cont.run();
}
}
| UTF-8 | Java | 338 | java | Entry.java | Java | [
{
"context": "import com.company.lw02.view.*;\n\n/**\n * Created by Pyzhic Valeriy on 8/04/2014;\n */\npublic class Entry {\n public ",
"end": 136,
"score": 0.9998847842216492,
"start": 122,
"tag": "NAME",
"value": "Pyzhic Valeriy"
}
] | null | [] | package com.company.lw02.entry;
import com.company.lw02.controller.*;
import com.company.lw02.view.*;
/**
* Created by <NAME> on 8/04/2014;
*/
public class Entry {
public static void main(String args[]){
Controller cont = new Controller();
View view = new View();
cont.setView(view);
cont.run();
}
}
| 330 | 0.653846 | 0.615385 | 16 | 20.125 | 15.591965 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 2 |
5345f53bfb1853007761e85eacc758db929883ec | 9,036,611,230,145 | e1edf6b215243f30b21ffc2df0c9d1b6c8068938 | /src/SelectConfirm.java | 6b6b1bdef07a49a17203e9743e5de34b06cfb8eb | [] | no_license | Sidney-L/self-service-ticketing-kiosk | https://github.com/Sidney-L/self-service-ticketing-kiosk | 3f85ab08bee14a30320eee2caaed1e9356446a8f | 6314d860fcb53c4cdba7d3d7e0c929c876cfe241 | refs/heads/master | 2020-03-20T21:55:31.256000 | 2018-06-18T15:25:16 | 2018-06-18T15:25:16 | 137,768,504 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
* This is the frame to confirm the select information
* @author Fan
*
*/
public class SelectConfirm extends JDialog implements ActionListener {
private final JPanel contentPanel = new JPanel();
private String[] tickettime;
private int ticketnumber;
private String tickettype;
private String moviename;
private String screen;
private String choosetime;
private String seat;
private JButton cancelButton;
private JButton okButton;
private String stunum;
/**
* Create the dialog.
*/
public SelectConfirm(String moviename,String screen, String[] tickettime,String choosetime,String tickettype,int ticketnumber,String seat,String stunum) {
setTitle("Confirm");
this.moviename=moviename;
this.screen=screen;
this.tickettime=tickettime;
this.choosetime=choosetime;
this.stunum=stunum;
this.tickettype=tickettype;
this.ticketnumber=ticketnumber;
this.seat=seat;
setBounds(100, 100, 705, 413);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setText("Moviename: "+moviename+" "+"Choosetime: "+choosetime+" "+"Ticket Type: "+tickettype+" "+"Number: "+ticketnumber);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(47, 73, 542, 150);
contentPanel.add(lblNewLabel);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
okButton = new JButton("OK");
okButton.setActionCommand("OK");
okButton.addActionListener(this);
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
cancelButton= new JButton("Cancel");
cancelButton.addActionListener(this);
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
public void actionPerformed(ActionEvent e) {
JButton jb=(JButton) e.getSource();
if(jb==okButton){
int valid=validSeats(screen,choosetime,moviename);
if(ticketnumber>valid){
Dialog dialog=new Dialog("You want to buy "+ticketnumber+" ticket(s),but there are only "+valid+" seat(s)!");
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
return;
}
dispose();
switch(screen){
case "screen1":
screen1frame framea=new screen1frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
framea.setLocationRelativeTo(null);
framea.setVisible(true);
break;
case "screen2":
screen2frame frameb=new screen2frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
frameb.setLocationRelativeTo(null);
frameb.setVisible(true);
break;
case "screen3":
screen3frame framec=new screen3frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
framec.setLocationRelativeTo(null);
framec.setVisible(true);
break;
}
}
else{
dispose();
Select frame=new Select(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
/**
* This is the function to return the number of valid seats
* @param screen the screen of the movie
* @param choosetime the choose time of the movie
* @param moviename the name of movie
* @return the number of the seats
*/
public int validSeats(String screen,String choosetime,String moviename){
int usedseats=0;
int size=0;
switch(screen){
case "screen1":
size=32;
break;
case "screen2":
size=26;
break;
case "screen3":
size=32;
break;
}
/*The funciton will open the data.txt to count the number of used seats*/
try{
File myFile=new File(System.getProperty("user.dir")+"\\"+"data.txt");
FileReader fr=new FileReader(myFile);
BufferedReader reader=new BufferedReader(fr);
String line=null;
while((line=reader.readLine())!=null){
String []list=line.split("@");
if(list[0].equals(moviename)&&list[1].equals(screen)&&list[2].equals(choosetime)) usedseats++;
}
reader.close();
}
catch(Exception ex){
ex.printStackTrace();
}
return size-usedseats;
}
}
| UTF-8 | Java | 4,851 | java | SelectConfirm.java | Java | [
{
"context": "ame to confirm the select information \r\n * @author Fan\r\n *\r\n */\r\npublic class SelectConfirm extends JDia",
"end": 489,
"score": 0.7458574175834656,
"start": 486,
"tag": "NAME",
"value": "Fan"
}
] | null | [] | import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
* This is the frame to confirm the select information
* @author Fan
*
*/
public class SelectConfirm extends JDialog implements ActionListener {
private final JPanel contentPanel = new JPanel();
private String[] tickettime;
private int ticketnumber;
private String tickettype;
private String moviename;
private String screen;
private String choosetime;
private String seat;
private JButton cancelButton;
private JButton okButton;
private String stunum;
/**
* Create the dialog.
*/
public SelectConfirm(String moviename,String screen, String[] tickettime,String choosetime,String tickettype,int ticketnumber,String seat,String stunum) {
setTitle("Confirm");
this.moviename=moviename;
this.screen=screen;
this.tickettime=tickettime;
this.choosetime=choosetime;
this.stunum=stunum;
this.tickettype=tickettype;
this.ticketnumber=ticketnumber;
this.seat=seat;
setBounds(100, 100, 705, 413);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setText("Moviename: "+moviename+" "+"Choosetime: "+choosetime+" "+"Ticket Type: "+tickettype+" "+"Number: "+ticketnumber);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setBounds(47, 73, 542, 150);
contentPanel.add(lblNewLabel);
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
okButton = new JButton("OK");
okButton.setActionCommand("OK");
okButton.addActionListener(this);
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
cancelButton= new JButton("Cancel");
cancelButton.addActionListener(this);
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
public void actionPerformed(ActionEvent e) {
JButton jb=(JButton) e.getSource();
if(jb==okButton){
int valid=validSeats(screen,choosetime,moviename);
if(ticketnumber>valid){
Dialog dialog=new Dialog("You want to buy "+ticketnumber+" ticket(s),but there are only "+valid+" seat(s)!");
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
return;
}
dispose();
switch(screen){
case "screen1":
screen1frame framea=new screen1frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
framea.setLocationRelativeTo(null);
framea.setVisible(true);
break;
case "screen2":
screen2frame frameb=new screen2frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
frameb.setLocationRelativeTo(null);
frameb.setVisible(true);
break;
case "screen3":
screen3frame framec=new screen3frame(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
framec.setLocationRelativeTo(null);
framec.setVisible(true);
break;
}
}
else{
dispose();
Select frame=new Select(moviename,screen,tickettime,choosetime,tickettype,ticketnumber,seat,stunum);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
/**
* This is the function to return the number of valid seats
* @param screen the screen of the movie
* @param choosetime the choose time of the movie
* @param moviename the name of movie
* @return the number of the seats
*/
public int validSeats(String screen,String choosetime,String moviename){
int usedseats=0;
int size=0;
switch(screen){
case "screen1":
size=32;
break;
case "screen2":
size=26;
break;
case "screen3":
size=32;
break;
}
/*The funciton will open the data.txt to count the number of used seats*/
try{
File myFile=new File(System.getProperty("user.dir")+"\\"+"data.txt");
FileReader fr=new FileReader(myFile);
BufferedReader reader=new BufferedReader(fr);
String line=null;
while((line=reader.readLine())!=null){
String []list=line.split("@");
if(list[0].equals(moviename)&&list[1].equals(screen)&&list[2].equals(choosetime)) usedseats++;
}
reader.close();
}
catch(Exception ex){
ex.printStackTrace();
}
return size-usedseats;
}
}
| 4,851 | 0.705628 | 0.695527 | 158 | 28.702532 | 27.597815 | 155 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.816456 | false | false | 2 |
f645722f00dcc50f9c6dfd4798d1ae102e3bbece | 17,428,977,329,404 | d7c4622ce2582ef5fc1f0da6f1a673021606db99 | /App0120/app/src/main/java/com/study/app0120/WebConnector.java | c795a9178856b109bffaf8882d90c97ce0d8ab1e | [] | no_license | cjh960504/Korea_Android | https://github.com/cjh960504/Korea_Android | b94e00570c63dbc977588e47417decd3ac055b8a | f1df05517ae13b0104c4af281ac83724b5d41a6a | refs/heads/master | 2023-02-25T05:53:34.928000 | 2021-02-04T03:55:27 | 2021-02-04T03:55:27 | 335,831,756 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.study.app0120;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
/*스프링 웹 서버와 통신하기 위한 객체*/
public class WebConnector {
URL url;
HttpURLConnection con;
public void getData(){
try {
url = new URL("http:/192.168.219.100:8888/rest/member");
con = (HttpURLConnection)url.openConnection();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 638 | java | WebConnector.java | Java | [
{
"context": "){\n try {\n url = new URL(\"http:/192.168.219.100:8888/rest/member\");\n con = (HttpURLCon",
"end": 366,
"score": 0.9997405409812927,
"start": 351,
"tag": "IP_ADDRESS",
"value": "192.168.219.100"
}
] | null | [] | package com.study.app0120;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
/*스프링 웹 서버와 통신하기 위한 객체*/
public class WebConnector {
URL url;
HttpURLConnection con;
public void getData(){
try {
url = new URL("http:/192.168.219.100:8888/rest/member");
con = (HttpURLConnection)url.openConnection();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 638 | 0.636513 | 0.603618 | 24 | 24.333334 | 17.254629 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 2 |
bece3f2f5c928d9ede78ea538d61e54016877bf4 | 5,823,975,713,504 | c4a9c5596be801cf89cc239cb0cef7b98e14101e | /jogo/iu/grafico/RegistarNomesJanela.java | 505c5865e1847b495decd73f52058ec3fdec363b | [] | no_license | Kiurads/Advanced-Programming-2021 | https://github.com/Kiurads/Advanced-Programming-2021 | fead498fc465e38990d2af427ef734e218ddda3c | 696b91b4441f295899d3571c5521a511deca4906 | refs/heads/main | 2023-06-04T01:41:21.231000 | 2021-06-17T22:30:37 | 2021-06-17T22:30:37 | 377,975,069 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package jogo.iu.grafico;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class RegistarNomesJanela {
private boolean registado;
private String jogador1;
private String jogador2;
private Stage stage;
private Text titulo;
private TextField nome1;
private TextField nome2;
private Label labelNome1;
private Label labelNome2;
private Button buttonOk;
private Button buttonCancel;
public void show() {
stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
titulo = new Text("Registar nomes");
nome1 = new TextField();
nome2 = new TextField();
labelNome1 = new Label("Jogador 1: ");
labelNome2 = new Label("Jogador 2: ");
buttonOk = new Button("OK");
buttonCancel = new Button("Cancelar");
registado = false;
nome1.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
buttonOk.setDisable(nome1.getText().equals(nome2.getText()) ||
nome1.getText().trim().isEmpty() ||
nome2.getText().trim().isEmpty());
}
});
nome2.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
buttonOk.setDisable(nome1.getText().equals(nome2.getText()) ||
nome1.getText().trim().isEmpty() ||
nome2.getText().trim().isEmpty());
}
});
nome1.setPromptText("Insira um nome");
nome2.setPromptText("Insira um nome");
buttonOk.setDisable(true);
buttonOk.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
jogador1 = nome1.getText();
jogador2 = nome2.getText();
registado = true;
stage.close();
}
});
buttonCancel.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stage.close();
}
});
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(10));
gridPane.setVgap(5);
gridPane.setHgap(5);
gridPane.add(titulo, 1, 0);
gridPane.add(nome1, 2, 1);
gridPane.add(nome2, 2, 2);
gridPane.add(labelNome1, 1, 1);
gridPane.add(labelNome2, 1, 2);
gridPane.add(buttonOk, 1, 3);
gridPane.add(buttonCancel, 2, 3);
gridPane.setGridLinesVisible(true);
buttonOk.setMaxWidth(Double.MAX_VALUE);
buttonCancel.setMaxWidth(Double.MAX_VALUE);
Scene scene = new Scene(gridPane, 250, 125);
stage.setResizable(false);
stage.setTitle("Registar nomes");
stage.setScene(scene);
stage.showAndWait();
}
public String getJogador1() {
return jogador1;
}
public String getJogador2() {
return jogador2;
}
public boolean isRegistado() {
return registado;
}
}
| UTF-8 | Java | 3,546 | java | RegistarNomesJanela.java | Java | [] | null | [] | package jogo.iu.grafico;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class RegistarNomesJanela {
private boolean registado;
private String jogador1;
private String jogador2;
private Stage stage;
private Text titulo;
private TextField nome1;
private TextField nome2;
private Label labelNome1;
private Label labelNome2;
private Button buttonOk;
private Button buttonCancel;
public void show() {
stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
titulo = new Text("Registar nomes");
nome1 = new TextField();
nome2 = new TextField();
labelNome1 = new Label("Jogador 1: ");
labelNome2 = new Label("Jogador 2: ");
buttonOk = new Button("OK");
buttonCancel = new Button("Cancelar");
registado = false;
nome1.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
buttonOk.setDisable(nome1.getText().equals(nome2.getText()) ||
nome1.getText().trim().isEmpty() ||
nome2.getText().trim().isEmpty());
}
});
nome2.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
buttonOk.setDisable(nome1.getText().equals(nome2.getText()) ||
nome1.getText().trim().isEmpty() ||
nome2.getText().trim().isEmpty());
}
});
nome1.setPromptText("Insira um nome");
nome2.setPromptText("Insira um nome");
buttonOk.setDisable(true);
buttonOk.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
jogador1 = nome1.getText();
jogador2 = nome2.getText();
registado = true;
stage.close();
}
});
buttonCancel.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stage.close();
}
});
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(10));
gridPane.setVgap(5);
gridPane.setHgap(5);
gridPane.add(titulo, 1, 0);
gridPane.add(nome1, 2, 1);
gridPane.add(nome2, 2, 2);
gridPane.add(labelNome1, 1, 1);
gridPane.add(labelNome2, 1, 2);
gridPane.add(buttonOk, 1, 3);
gridPane.add(buttonCancel, 2, 3);
gridPane.setGridLinesVisible(true);
buttonOk.setMaxWidth(Double.MAX_VALUE);
buttonCancel.setMaxWidth(Double.MAX_VALUE);
Scene scene = new Scene(gridPane, 250, 125);
stage.setResizable(false);
stage.setTitle("Registar nomes");
stage.setScene(scene);
stage.showAndWait();
}
public String getJogador1() {
return jogador1;
}
public String getJogador2() {
return jogador2;
}
public boolean isRegistado() {
return registado;
}
}
| 3,546 | 0.590807 | 0.573886 | 136 | 25.07353 | 19.988464 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.691176 | false | false | 2 |
628665a6a0f71b56e3a1e06b559fe1850c27b44c | 22,162,031,291,897 | bdc00676fb81411235ff81adf95a1418e6743178 | /test/server/RealProxyTest.java | 3d0242288f5605b860e8e42cd2c568718765ebfd | [] | no_license | cmriboldi/Settlers-of-Catan | https://github.com/cmriboldi/Settlers-of-Catan | 6f3128a1f87eb6e89469759e4f8ad95a500853b4 | cc591914287a57ccc9a6bf3f4a00afa993571830 | refs/heads/master | 2021-05-31T21:42:47.434000 | 2016-04-21T23:57:03 | 2016-04-21T23:57:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package test.server;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import model.resources.ResourceList;
import serverProxy.RealProxy;
import serverProxy.ServerException;
import shared.definitions.CatanColor;
import shared.definitions.ResourceType;
import shared.locations.EdgeDirection;
import shared.locations.EdgeLocation;
import shared.locations.HexLocation;
import shared.locations.VertexDirection;
import shared.locations.VertexLocation;
import test.TestServer;
/**
* TAs READ ME FIRST!!!
*
* Test the functionality of the Server Proxy for the client.
* These tests are designed to check for connectivity with the server, not necessarily that the action run is correct.
* The RealProxy is designed to complete a request only if the response from the server is a 200 code, any other response code
* will result in a thrown exception.
* Therefore, server.method(); assert(true); is still a valid test, because we will only reach the assert
* statement if communication with the server was successful.
*
* This test initializes it's own server for the purposes of testing. This server runs on the default port of 8081, having this
* port already occupied may result in unexpected errors.
*/
public class RealProxyTest
{
private static TestServer testServer;
private static RealProxy server;
/**
* Start the test server on port 8081 that the RealProxy will communicate with
*
* @throws Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
testServer = new TestServer();
//System.out.println("---!!!!!!!!!!!!!!!!!!!!!!!! Starting Server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---");
testServer.run();
//System.out.println("Server is running");
server = new RealProxy();
server.userLogin("Brooke", "brooke");
server.joinGame(0, CatanColor.BLUE);
}
/**
* Stop the test server
* @throws Exception
*/
@AfterClass
public static void tearDownAfterClass() throws Exception
{
testServer.stop();
//System.out.println("---!!!!!!!!!!!!!!!!!!!!!!!! Stopping Server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---");
}
@Test
public void listGames() throws ServerException
{
server.listGames();
assert(true);
}
@Test
public void createGame() throws ServerException
{
server.createGame(false, false, false, "JUnitTest Game");
assert(true);
}
@Test
public void joinGame() throws ServerException
{
server.joinGame(0, CatanColor.BLUE);
assert(true);
}
@Test
public void getGameModel() throws ServerException
{
server.getGameModel();
assert(true);
}
@Test
public void getGameModelByVersion() throws ServerException
{
server.getGameModel(2);
assert(true);
}
@Test
public void listAI() throws ServerException
{
server.listAI();
assert(true);
}
@Test
public void sendChat() throws ServerException
{
server.sendChat(1, "This is a JUnit test chat");
assert(true);
}
@Test
public void rollNumber() throws ServerException
{
server.rollNumber(0, 10);
assert(true);
}
@Test
public void robPlayer() throws ServerException
{
server.robPlayer(0, 1, new HexLocation(1,1));
assert(true);
}
@Test
public void finishTurn() throws ServerException
{
server.finishTurn(0);
assert(true);
}
@Test
public void byuDevCard() throws ServerException
{
server.buyDevCard(0);
assert(true);
}
@Test
public void year_of_plenty() throws ServerException
{
server.yearOfPlenty(0, ResourceType.SHEEP, ResourceType.ORE);
assert(true);
}
@Test
public void road_building() throws ServerException
{
server.roadBuilding(0, new EdgeLocation(new HexLocation(1,1), EdgeDirection.North), new EdgeLocation(new HexLocation(1,1), EdgeDirection.SouthEast));
assert(true);
}
@Test
public void soldier() throws ServerException
{
server.soldier(0, 1, new HexLocation(1,1));
assert(true);
}
@Test
public void monopoly() throws ServerException
{
server.monopoly(0, ResourceType.BRICK);
assert(true);
}
@Test
public void monument() throws ServerException
{
server.monument(0);
assert(true);
}
@Test
public void buildRoad() throws ServerException
{
server.buildRoad(0, new EdgeLocation(new HexLocation(1,1), EdgeDirection.North), true);
assert(true);
}
@Test
public void buildSettlement() throws ServerException
{
server.buildSettlement(0, new VertexLocation(new HexLocation(1,1), VertexDirection.NorthEast), true);
assert(true);
}
@Test
public void buildCity() throws ServerException
{
server.buildCity(0, new VertexLocation(new HexLocation(0,3), VertexDirection.NorthWest));
assert(true);
}
@Test
public void offerTrade() throws ServerException
{
server.offerTrade(0, 1, new ResourceList(1,1,1,1,1));
assert(true);
}
@Test
public void acceptTrade() throws ServerException
{
server.acceptTrade(1, false);
assert(true);
}
@Test
public void maritimeTrade() throws ServerException
{
server.maritimeTrade(0, 3, ResourceType.ORE, ResourceType.BRICK);
assert(true);
}
@Test
public void discardCards() throws ServerException
{
server.discardCards(0, new ResourceList(1,1,1,1,1));
assert(true);
}
}
| UTF-8 | Java | 5,246 | java | RealProxyTest.java | Java | [
{
"context": ";\n\t\tserver = new RealProxy();\n\t\tserver.userLogin(\"Brooke\", \"brooke\");\n\t\tserver.joinGame(0, CatanColor.BLUE",
"end": 1854,
"score": 0.9912652373313904,
"start": 1848,
"tag": "USERNAME",
"value": "Brooke"
},
{
"context": " = new RealProxy();\n\t\tserver.userLogin(\"Brooke\", \"brooke\");\n\t\tserver.joinGame(0, CatanColor.BLUE);\n\t}\n\n\t/*",
"end": 1864,
"score": 0.7715348601341248,
"start": 1858,
"tag": "USERNAME",
"value": "brooke"
}
] | null | [] | package test.server;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import model.resources.ResourceList;
import serverProxy.RealProxy;
import serverProxy.ServerException;
import shared.definitions.CatanColor;
import shared.definitions.ResourceType;
import shared.locations.EdgeDirection;
import shared.locations.EdgeLocation;
import shared.locations.HexLocation;
import shared.locations.VertexDirection;
import shared.locations.VertexLocation;
import test.TestServer;
/**
* TAs READ ME FIRST!!!
*
* Test the functionality of the Server Proxy for the client.
* These tests are designed to check for connectivity with the server, not necessarily that the action run is correct.
* The RealProxy is designed to complete a request only if the response from the server is a 200 code, any other response code
* will result in a thrown exception.
* Therefore, server.method(); assert(true); is still a valid test, because we will only reach the assert
* statement if communication with the server was successful.
*
* This test initializes it's own server for the purposes of testing. This server runs on the default port of 8081, having this
* port already occupied may result in unexpected errors.
*/
public class RealProxyTest
{
private static TestServer testServer;
private static RealProxy server;
/**
* Start the test server on port 8081 that the RealProxy will communicate with
*
* @throws Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
testServer = new TestServer();
//System.out.println("---!!!!!!!!!!!!!!!!!!!!!!!! Starting Server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---");
testServer.run();
//System.out.println("Server is running");
server = new RealProxy();
server.userLogin("Brooke", "brooke");
server.joinGame(0, CatanColor.BLUE);
}
/**
* Stop the test server
* @throws Exception
*/
@AfterClass
public static void tearDownAfterClass() throws Exception
{
testServer.stop();
//System.out.println("---!!!!!!!!!!!!!!!!!!!!!!!! Stopping Server !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---");
}
@Test
public void listGames() throws ServerException
{
server.listGames();
assert(true);
}
@Test
public void createGame() throws ServerException
{
server.createGame(false, false, false, "JUnitTest Game");
assert(true);
}
@Test
public void joinGame() throws ServerException
{
server.joinGame(0, CatanColor.BLUE);
assert(true);
}
@Test
public void getGameModel() throws ServerException
{
server.getGameModel();
assert(true);
}
@Test
public void getGameModelByVersion() throws ServerException
{
server.getGameModel(2);
assert(true);
}
@Test
public void listAI() throws ServerException
{
server.listAI();
assert(true);
}
@Test
public void sendChat() throws ServerException
{
server.sendChat(1, "This is a JUnit test chat");
assert(true);
}
@Test
public void rollNumber() throws ServerException
{
server.rollNumber(0, 10);
assert(true);
}
@Test
public void robPlayer() throws ServerException
{
server.robPlayer(0, 1, new HexLocation(1,1));
assert(true);
}
@Test
public void finishTurn() throws ServerException
{
server.finishTurn(0);
assert(true);
}
@Test
public void byuDevCard() throws ServerException
{
server.buyDevCard(0);
assert(true);
}
@Test
public void year_of_plenty() throws ServerException
{
server.yearOfPlenty(0, ResourceType.SHEEP, ResourceType.ORE);
assert(true);
}
@Test
public void road_building() throws ServerException
{
server.roadBuilding(0, new EdgeLocation(new HexLocation(1,1), EdgeDirection.North), new EdgeLocation(new HexLocation(1,1), EdgeDirection.SouthEast));
assert(true);
}
@Test
public void soldier() throws ServerException
{
server.soldier(0, 1, new HexLocation(1,1));
assert(true);
}
@Test
public void monopoly() throws ServerException
{
server.monopoly(0, ResourceType.BRICK);
assert(true);
}
@Test
public void monument() throws ServerException
{
server.monument(0);
assert(true);
}
@Test
public void buildRoad() throws ServerException
{
server.buildRoad(0, new EdgeLocation(new HexLocation(1,1), EdgeDirection.North), true);
assert(true);
}
@Test
public void buildSettlement() throws ServerException
{
server.buildSettlement(0, new VertexLocation(new HexLocation(1,1), VertexDirection.NorthEast), true);
assert(true);
}
@Test
public void buildCity() throws ServerException
{
server.buildCity(0, new VertexLocation(new HexLocation(0,3), VertexDirection.NorthWest));
assert(true);
}
@Test
public void offerTrade() throws ServerException
{
server.offerTrade(0, 1, new ResourceList(1,1,1,1,1));
assert(true);
}
@Test
public void acceptTrade() throws ServerException
{
server.acceptTrade(1, false);
assert(true);
}
@Test
public void maritimeTrade() throws ServerException
{
server.maritimeTrade(0, 3, ResourceType.ORE, ResourceType.BRICK);
assert(true);
}
@Test
public void discardCards() throws ServerException
{
server.discardCards(0, new ResourceList(1,1,1,1,1));
assert(true);
}
}
| 5,246 | 0.70873 | 0.697103 | 227 | 22.110132 | 27.507328 | 151 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.629956 | false | false | 2 |
384bc5a6fb62a662ddeff2f03b76511a9569293b | 18,021,682,817,558 | f122756d3ef81079138ff76023b311869de4f027 | /mission-man/mission-man-web/src/main/java/utils/ImageUploader.java | c1c52b28414b8cbf57f40e5257e24e0f879de469 | [] | no_license | RosaNatali/Saturday | https://github.com/RosaNatali/Saturday | f7192a58fa6c213f3ff29f016a7d32e00a70588a | 9daf5f17b71def0fe782b6e6b353cb32c0c4b699 | refs/heads/master | 2020-12-30T15:42:39.231000 | 2017-05-13T19:46:09 | 2017-05-13T19:46:09 | 91,169,665 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package utils;
import java.io.FileOutputStream;
import java.util.UUID;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;
import ctr.MissionBean;
import utilities.DirectoryInitilizer;
@ManagedBean
@ViewScoped
public class ImageUploader {
private UploadedFile uploadedFile;
@ManagedProperty(value = "#{missionBean}")
private MissionBean missionBean;
public void handleFileUpload(FileUploadEvent event) {
uploadedFile = event.getFile();
String shortImagePath = UUID.randomUUID().toString() + ".jpg";
if (uploadedFile != null && uploadedFile.getContents() != null) {
try {
byte[] contents = uploadedFile.getContents();
FileOutputStream fos = new FileOutputStream(DirectoryInitilizer.IMAGE_DIR + "/" + shortImagePath);
fos.write(contents);
fos.close();
missionBean.getImagesToBeLoaded().add(shortImagePath);
FacesMessage message = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
} catch (Exception e) {
FacesMessage message = new FacesMessage("pb", event.getFile().getFileName() + " is not uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
public MissionBean getMissionBean() {
return missionBean;
}
public void setMissionBean(MissionBean missionBean) {
this.missionBean = missionBean;
}
}
| UTF-8 | Java | 1,862 | java | ImageUploader.java | Java | [] | null | [] | package utils;
import java.io.FileOutputStream;
import java.util.UUID;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.UploadedFile;
import ctr.MissionBean;
import utilities.DirectoryInitilizer;
@ManagedBean
@ViewScoped
public class ImageUploader {
private UploadedFile uploadedFile;
@ManagedProperty(value = "#{missionBean}")
private MissionBean missionBean;
public void handleFileUpload(FileUploadEvent event) {
uploadedFile = event.getFile();
String shortImagePath = UUID.randomUUID().toString() + ".jpg";
if (uploadedFile != null && uploadedFile.getContents() != null) {
try {
byte[] contents = uploadedFile.getContents();
FileOutputStream fos = new FileOutputStream(DirectoryInitilizer.IMAGE_DIR + "/" + shortImagePath);
fos.write(contents);
fos.close();
missionBean.getImagesToBeLoaded().add(shortImagePath);
FacesMessage message = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
} catch (Exception e) {
FacesMessage message = new FacesMessage("pb", event.getFile().getFileName() + " is not uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
}
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
public MissionBean getMissionBean() {
return missionBean;
}
public void setMissionBean(MissionBean missionBean) {
this.missionBean = missionBean;
}
}
| 1,862 | 0.727175 | 0.727175 | 67 | 25.791044 | 26.873133 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.626866 | false | false | 2 |
07350bb0b8f75e42e567c50dfa7404cf9c231ad7 | 38,852,274,163,304 | 3dc0bef70f8c517d09c8c56d63a4a1740c95aff2 | /mongo-agreegation/src/main/java/com/example/demo/model/SalesReport.java | 2059b804e6aa81830bc1cef65f1152342510958b | [] | no_license | javaHelper/spring-boot-tutorials-final | https://github.com/javaHelper/spring-boot-tutorials-final | 444aa4ffec30989b5c7f8805cfb368677da61960 | 35c996eec88b779ea3edef9e1ce600c84b50dbd1 | refs/heads/master | 2020-07-15T13:00:39.203000 | 2020-01-02T16:51:04 | 2020-01-02T16:51:04 | 205,567,971 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SalesReport {
private String brand;
private long total;
private int salesyear;
}
| UTF-8 | Java | 295 | java | SalesReport.java | Java | [] | null | [] | package com.example.demo.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SalesReport {
private String brand;
private long total;
private int salesyear;
}
| 295 | 0.816949 | 0.816949 | 16 | 17.4375 | 10.948565 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6875 | false | false | 2 |
c50c0d1e8cf5e3cf7891178f8920e89c89025af5 | 5,454,608,517,048 | 4d9c11e6d569010159c7da225a47c282260e6310 | /service-management-qs/src/main/java/fr/orange/ddr/sympa/repositories/QsUseCaseCommentRepository.java | 9fe79ee8f9afd566dc597dedf8445b45f1ead014 | [] | no_license | Zouhairhajji/hypervision-bigdata | https://github.com/Zouhairhajji/hypervision-bigdata | 0c37c696ced3d98455fe67e3ba894541e8fad6a2 | 87e72120937effe61f3569d550abb1ecb2305b03 | refs/heads/master | 2020-03-29T05:39:01.712000 | 2018-09-13T14:01:25 | 2018-09-13T14:01:25 | 136,483,459 | 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 fr.orange.ddr.sympa.repositories;
import fr.orange.ddr.sympa.entities.postgresql.hhd.QsUseCaseCommentEntity;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
/**
*
* @author FQLH0717
*/
public interface QsUseCaseCommentRepository extends CrudRepository<QsUseCaseCommentEntity, Long>{
@Override
public List<QsUseCaseCommentEntity> findAll();
@Query("FROM QsUseCaseCommentEntity where useCase = ?1 and service = ?2 and dateQs = ?3 ORDER BY dateQs desc ")
public List<QsUseCaseCommentEntity> findAllByDateAndUseCase(String usecase, String service, Date date);
@Query("FROM QsUseCaseCommentEntity where dateQs > ?1 ORDER BY dateQs desc ")
public List<QsUseCaseCommentEntity> findAllCommentsAfterDate(Timestamp beginDate);
}
| UTF-8 | Java | 1,130 | java | QsUseCaseCommentRepository.java | Java | [
{
"context": ".repository.CrudRepository;\r\n\r\n/**\r\n *\r\n * @author FQLH0717\r\n */\r\npublic interface QsUseCaseCommentRepository",
"end": 531,
"score": 0.9995661973953247,
"start": 523,
"tag": "USERNAME",
"value": "FQLH0717"
}
] | 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 fr.orange.ddr.sympa.repositories;
import fr.orange.ddr.sympa.entities.postgresql.hhd.QsUseCaseCommentEntity;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
/**
*
* @author FQLH0717
*/
public interface QsUseCaseCommentRepository extends CrudRepository<QsUseCaseCommentEntity, Long>{
@Override
public List<QsUseCaseCommentEntity> findAll();
@Query("FROM QsUseCaseCommentEntity where useCase = ?1 and service = ?2 and dateQs = ?3 ORDER BY dateQs desc ")
public List<QsUseCaseCommentEntity> findAllByDateAndUseCase(String usecase, String service, Date date);
@Query("FROM QsUseCaseCommentEntity where dateQs > ?1 ORDER BY dateQs desc ")
public List<QsUseCaseCommentEntity> findAllCommentsAfterDate(Timestamp beginDate);
}
| 1,130 | 0.748673 | 0.741593 | 32 | 33.3125 | 36.21933 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 2 |
0b57e08a5b349f406a805a0bd30c78bc85ad3642 | 18,124,762,037,019 | 515cbef8fe7d190058365c1553d4e8f4407621e5 | /taiping-system/src/main/java/com/taiping/bean/riskmanage/RiskTrendAnalysisVo.java | c1bac3f9fb51e53cdd5bdcce67ba8a3a48745a35 | [] | no_license | cckmit/taiping | https://github.com/cckmit/taiping | 1e12d6751ac19f861d768da1b4b83e759d6bc939 | 28913dc13946724985610410704a9ea202bfb119 | refs/heads/main | 2023-07-14T04:07:03.036000 | 2021-08-28T04:32:51 | 2021-08-28T04:32:51 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.taiping.bean.riskmanage;
/**
* @author zhangliangyu
* @since 2019/10/31
* 风险趋势分析查询条件
*/
public class RiskTrendAnalysisVo {
/**
* 风险类型
*/
private Integer riskType;
/**
* 开始时间
*/
private Long startTime;
/**
* 结束时间
*/
private Long endTime;
public Integer getRiskType() {
return riskType;
}
public void setRiskType(Integer riskType) {
this.riskType = riskType;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}
| UTF-8 | Java | 810 | java | RiskTrendAnalysisVo.java | Java | [
{
"context": "ckage com.taiping.bean.riskmanage;\n\n/**\n * @author zhangliangyu\n * @since 2019/10/31\n * 风险趋势分析查询条件\n */\npublic cla",
"end": 65,
"score": 0.9791250228881836,
"start": 53,
"tag": "NAME",
"value": "zhangliangyu"
}
] | null | [] | package com.taiping.bean.riskmanage;
/**
* @author zhangliangyu
* @since 2019/10/31
* 风险趋势分析查询条件
*/
public class RiskTrendAnalysisVo {
/**
* 风险类型
*/
private Integer riskType;
/**
* 开始时间
*/
private Long startTime;
/**
* 结束时间
*/
private Long endTime;
public Integer getRiskType() {
return riskType;
}
public void setRiskType(Integer riskType) {
this.riskType = riskType;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}
| 810 | 0.579634 | 0.569191 | 45 | 16.022223 | 14.292949 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 11 |
5203e38e1233aa8520bcc497baf1c5c37aff1bf3 | 24,739,011,682,113 | 46c97bb665b35adcf4dd39f6316630514e6dd9b1 | /app/src/main/java/freshhints/example/com/freshhints/adapters/RemindersDbAdapter.java | e7b067a4f8eaaea5ca8a65632e0dfeb3ca68e2a9 | [] | no_license | acdevine89/FreshHints | https://github.com/acdevine89/FreshHints | 56e6d13aa18347c428608e06ad491a9d93051b49 | 3dc0400020caaf2e05a424aead89d5e86c1c2673 | refs/heads/master | 2016-09-15T23:54:25.726000 | 2015-01-13T16:20:11 | 2015-01-13T16:20:11 | 27,434,373 | 0 | 0 | null | false | 2015-01-13T16:20:12 | 2014-12-02T13:47:54 | 2015-01-13T16:20:12 | 2015-01-13T16:20:11 | 894 | 1 | 1 | 0 | Java | null | null | package freshhints.example.com.freshhints.adapters;
/**
* Created by anniedevine on 1/9/15.
*/
public class RemindersDbAdapter {
}
| UTF-8 | Java | 134 | java | RemindersDbAdapter.java | Java | [
{
"context": "xample.com.freshhints.adapters;\n\n/**\n * Created by anniedevine on 1/9/15.\n */\npublic class RemindersDbAdapter {\n",
"end": 82,
"score": 0.9996001720428467,
"start": 71,
"tag": "USERNAME",
"value": "anniedevine"
}
] | null | [] | package freshhints.example.com.freshhints.adapters;
/**
* Created by anniedevine on 1/9/15.
*/
public class RemindersDbAdapter {
}
| 134 | 0.746269 | 0.716418 | 7 | 18.142857 | 19.642727 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | false | false | 11 |
0d6a017b96e79694e40584632e724abd7f4e851e | 15,281,493,694,778 | 8b2f069983ebfbdd83e0586cb9aadba295b4315b | /src/test/java/mypackage/Test14.java | b014bb254156e5218363ecb715f4bc62630ceeaf | [] | no_license | eswaraditya/TestNG | https://github.com/eswaraditya/TestNG | 72eac753a6fe1056885d7b364415379d70f3b7ba | 690a76130184fe5333142aaf74d8a24ba902a67b | refs/heads/master | 2023-03-03T15:05:17.579000 | 2021-02-08T19:05:32 | 2021-02-08T19:05:32 | 337,176,250 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mypackage;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Test14 {
@Test
public void m1() throws Exception
{
System.out.println("I am from m1");
WebDriverManager.chromedriver().setup();
System.setProperty("webdriver.chrome.silentOutput", "true");
RemoteWebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
driver.findElement(By.xpath("//a[text()='Create New Account']")).click();
Thread.sleep(5000);
driver.findElement(By.name("firstname")).sendKeys("jkdfvjhg");
driver.findElement(By.name("lastname")).sendKeys("jkdfvjhg");
driver.findElement(By.name("reg_email__")).sendKeys("jkvfkjdzfv");
driver.findElement(By.name("reg_passwd__")).sendKeys("zkjnvfjkdbf");
}
@Test
public void m2() throws Exception
{
System.out.println("I am from m2");
WebDriverManager.chromedriver().setup();
System.setProperty("webdriver.chrome.silentOutput", "true");
RemoteWebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.amazon.in/");
Thread.sleep(5000);
driver.navigate().to("https://www.flipkart.com/");
Thread.sleep(5000);
driver.navigate().back();
Thread.sleep(5000);
driver.navigate().forward();
}
}
| UTF-8 | Java | 1,483 | java | Test14.java | Java | [
{
"context": "rt org.testng.annotations.Test;\n\nimport io.github.bonigarcia.wdm.WebDriverManager;\n\npublic class Test14 {\n\t\n\t@",
"end": 240,
"score": 0.9967632293701172,
"start": 230,
"tag": "USERNAME",
"value": "bonigarcia"
},
{
"context": "er.findElement(By.name(\"reg_email__\")).sendKeys(\"jkvfkjdzfv\");\n\t\tdriver.findElement(By.name(\"reg_passwd__\")).",
"end": 898,
"score": 0.8611408472061157,
"start": 889,
"tag": "PASSWORD",
"value": "kvfkjdzfv"
},
{
"context": "er.findElement(By.name(\"reg_passwd__\")).sendKeys(\"zkjnvfjkdbf\");\n\t\t\n\t}\n\t\n\t@Test\n\tpublic void m2() throws Except",
"end": 969,
"score": 0.9987313151359558,
"start": 958,
"tag": "PASSWORD",
"value": "zkjnvfjkdbf"
}
] | null | [] | package mypackage;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Test14 {
@Test
public void m1() throws Exception
{
System.out.println("I am from m1");
WebDriverManager.chromedriver().setup();
System.setProperty("webdriver.chrome.silentOutput", "true");
RemoteWebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
driver.findElement(By.xpath("//a[text()='Create New Account']")).click();
Thread.sleep(5000);
driver.findElement(By.name("firstname")).sendKeys("jkdfvjhg");
driver.findElement(By.name("lastname")).sendKeys("jkdfvjhg");
driver.findElement(By.name("reg_email__")).sendKeys("j<PASSWORD>");
driver.findElement(By.name("reg_passwd__")).sendKeys("<PASSWORD>");
}
@Test
public void m2() throws Exception
{
System.out.println("I am from m2");
WebDriverManager.chromedriver().setup();
System.setProperty("webdriver.chrome.silentOutput", "true");
RemoteWebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.amazon.in/");
Thread.sleep(5000);
driver.navigate().to("https://www.flipkart.com/");
Thread.sleep(5000);
driver.navigate().back();
Thread.sleep(5000);
driver.navigate().forward();
}
}
| 1,483 | 0.719488 | 0.704653 | 49 | 29.265306 | 22.46973 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.938776 | false | false | 11 |
1d0abba315d8fc401117ed6cb742680fcfd78a07 | 25,718,264,169,698 | 7447037a711120019a2c5d3a385839f56f3c2192 | /trainApp/app/src/main/java/com/example/trainapp/HelpFragment.java | b8886bf36cfe4e75980ef6374f8fcdf571a66efd | [] | no_license | Terminator-s/UEE--TrainSchedule | https://github.com/Terminator-s/UEE--TrainSchedule | 1669585c24b7331d0460168fc08e0f92519ba508 | a7a5480cf11245e91820be7c02db464c804ac964 | refs/heads/master | 2020-06-26T07:51:29.257000 | 2019-09-09T04:26:28 | 2019-09-09T04:26:28 | 199,576,507 | 0 | 0 | null | false | 2019-09-13T20:52:27 | 2019-07-30T04:48:13 | 2019-09-09T04:26:38 | 2019-09-13T20:51:22 | 158 | 0 | 0 | 1 | Java | false | false | package com.example.trainapp;
public class HelpFragment {
}
| UTF-8 | Java | 61 | java | HelpFragment.java | Java | [] | null | [] | package com.example.trainapp;
public class HelpFragment {
}
| 61 | 0.786885 | 0.786885 | 4 | 14.25 | 13.772709 | 29 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 11 |
0c9211af644703bda7afaabfae22aa1d5447095e | 20,736,102,161,960 | d90c10d4991247ebe687b8ef7966a7d106d3de18 | /Banking/src/com/deloitte/util/BankingMessages.java | 2dac2cbfca06c8128a9825f71dd22a7084669609 | [] | no_license | PriyankaPurva/WebProject | https://github.com/PriyankaPurva/WebProject | 6df841daad7e5247cff35b4da9ca48b8f6866da4 | 88e618f9b47d3d8b9af030500f8efb89af3299b9 | refs/heads/master | 2020-04-01T00:27:09.609000 | 2018-10-12T05:22:27 | 2018-10-12T05:22:27 | 152,697,712 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.deloitte.util;
public class BankingMessages {
public static final String INSUFFICIENT_BALANCE = "Insufficient Balance in Account";
public static final String DB_DRIVER_MISSING = "The driver is missing";
public static final String DB_ERROR = "Error";
}
| UTF-8 | Java | 285 | java | BankingMessages.java | Java | [] | null | [] | package com.deloitte.util;
public class BankingMessages {
public static final String INSUFFICIENT_BALANCE = "Insufficient Balance in Account";
public static final String DB_DRIVER_MISSING = "The driver is missing";
public static final String DB_ERROR = "Error";
}
| 285 | 0.733333 | 0.733333 | 11 | 23.90909 | 30.013496 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 11 |
9ccfc54dab8a4c78d0590cb6f04a2b95d05aa816 | 22,874,995,826,744 | 8fe28d510484905ab9805aab416c0f65184fada8 | /src/main/java/cho/carbon/biz/constant/RelationType.java | 66b34682351b77ea653b2cdad8e7f3ca184062a6 | [] | no_license | manxihuanchi/dxjdrule | https://github.com/manxihuanchi/dxjdrule | d834cd4f62e3dfae817dee7eb9eb01868772cf82 | 66f175769d24cfcc8a0a843a2620afd32be23902 | refs/heads/master | 2022-05-22T11:28:44.772000 | 2022-03-21T15:20:04 | 2022-03-21T15:20:04 | 204,112,012 | 0 | 1 | null | false | 2022-03-31T22:46:05 | 2019-08-24T05:16:41 | 2022-03-22T02:52:29 | 2022-03-31T22:46:02 | 363 | 0 | 1 | 17 | Java | false | false | package cho.carbon.biz.constant;
public class RelationType {
public static final Long RR_系统角色_被用户拥有_系统用户=69328017186241719L;
public static final Long RR_系统用户_拥有角色_系统角色=69328017186241721L;
public static final Long RR_系统角色_包含权限_系统权限=69328017186241727L;
public static final Long RR_系统权限_包含于_系统角色=69328017186241728L;
public static final Long RR_系统角色_包含_系统角色=69328017186241729L;
public static final Long RR_系统角色_包含于_系统角色=69328017186241730L;
public static final Long RR_享有民生保障_申请人_人口信息=71164104967856395L;
public static final Long RR_享有民生保障_享受人_人口信息=71164104967856396L;
public static final Long RR_享有民生保障_保障发放记录_民生保障发放记录=71164104967856397L;
public static final Long RR_享有民生保障_WWW2_全sql统计实体=71164104967856398L;
public static final Long RR_人口信息_户主家庭_家庭信息=71164104967856399L;
public static final Long RR_人口信息_归属家庭_家庭信息=71164104967856400L;
public static final Long RR_人口信息_申请事项_享有民生保障=71164104967856401L;
public static final Long RR_人口信息_享受事项_享有民生保障=71164104967856402L;
public static final Long RR_人口信息_夫妻_人口信息=71164104967856403L;
public static final Long RR_人口信息_居住家庭_家庭信息=71164104967856404L;
public static final Long RR_家庭信息_户主_人口信息=71164104967856405L;
public static final Long RR_家庭信息_成员_人口信息=71164104967856406L;
public static final Long RR_家庭信息_居住成员_人口信息=71164104967856407L;
public static final Long RR_民生保障发放记录_所属保障_享有民生保障=71164104967856408L;
public static final Long RR_全sql统计实体_WWWW_享有民生保障=71164104967856409L;
public static final Long RR_人口信息_产权房屋_房屋信息=78254831833063424L;
public static final Long RR_房屋信息_产权人_人口信息=78254831833063425L;
public static final Long RR_人口信息_居住房屋_房屋信息=78254922027376640L;
public static final Long RR_房屋信息_居住人_人口信息=78254922027376641L;
public static final Long RR_房屋入住_入住房屋_房屋信息=78428883235250176L;
public static final Long RR_房屋信息_入住管理_房屋入住=78428883235250177L;
public static final Long RR_房屋入住_入住人_人口信息=78613730037735424L;
public static final Long RR_人口信息_入住房屋记录_房屋入住=78613730037735425L;
public static final Long RR_人口信息_所属社区_社区信息=78982549616861184L;
public static final Long RR_社区信息_拥有人_人口信息=78982549616861185L;
public static final Long RR_房屋信息_所在社区_社区信息=78992163901153280L;
public static final Long RR_社区信息_社区房产_房屋信息=78992163901153281L;
public static final Long RR_人口信息_当前用户_系统用户=79150888712544256L;
public static final Long RR_系统用户_当前人员_人口信息=79150888712544257L;
public static final Long RR_人口信息_可被访问_系统权限=85530414090690560L;
public static final Long RR_系统权限_访问人口_人口信息=85530414090690561L;
}
| UTF-8 | Java | 3,317 | java | RelationType.java | Java | [] | null | [] | package cho.carbon.biz.constant;
public class RelationType {
public static final Long RR_系统角色_被用户拥有_系统用户=69328017186241719L;
public static final Long RR_系统用户_拥有角色_系统角色=69328017186241721L;
public static final Long RR_系统角色_包含权限_系统权限=69328017186241727L;
public static final Long RR_系统权限_包含于_系统角色=69328017186241728L;
public static final Long RR_系统角色_包含_系统角色=69328017186241729L;
public static final Long RR_系统角色_包含于_系统角色=69328017186241730L;
public static final Long RR_享有民生保障_申请人_人口信息=71164104967856395L;
public static final Long RR_享有民生保障_享受人_人口信息=71164104967856396L;
public static final Long RR_享有民生保障_保障发放记录_民生保障发放记录=71164104967856397L;
public static final Long RR_享有民生保障_WWW2_全sql统计实体=71164104967856398L;
public static final Long RR_人口信息_户主家庭_家庭信息=71164104967856399L;
public static final Long RR_人口信息_归属家庭_家庭信息=71164104967856400L;
public static final Long RR_人口信息_申请事项_享有民生保障=71164104967856401L;
public static final Long RR_人口信息_享受事项_享有民生保障=71164104967856402L;
public static final Long RR_人口信息_夫妻_人口信息=71164104967856403L;
public static final Long RR_人口信息_居住家庭_家庭信息=71164104967856404L;
public static final Long RR_家庭信息_户主_人口信息=71164104967856405L;
public static final Long RR_家庭信息_成员_人口信息=71164104967856406L;
public static final Long RR_家庭信息_居住成员_人口信息=71164104967856407L;
public static final Long RR_民生保障发放记录_所属保障_享有民生保障=71164104967856408L;
public static final Long RR_全sql统计实体_WWWW_享有民生保障=71164104967856409L;
public static final Long RR_人口信息_产权房屋_房屋信息=78254831833063424L;
public static final Long RR_房屋信息_产权人_人口信息=78254831833063425L;
public static final Long RR_人口信息_居住房屋_房屋信息=78254922027376640L;
public static final Long RR_房屋信息_居住人_人口信息=78254922027376641L;
public static final Long RR_房屋入住_入住房屋_房屋信息=78428883235250176L;
public static final Long RR_房屋信息_入住管理_房屋入住=78428883235250177L;
public static final Long RR_房屋入住_入住人_人口信息=78613730037735424L;
public static final Long RR_人口信息_入住房屋记录_房屋入住=78613730037735425L;
public static final Long RR_人口信息_所属社区_社区信息=78982549616861184L;
public static final Long RR_社区信息_拥有人_人口信息=78982549616861185L;
public static final Long RR_房屋信息_所在社区_社区信息=78992163901153280L;
public static final Long RR_社区信息_社区房产_房屋信息=78992163901153281L;
public static final Long RR_人口信息_当前用户_系统用户=79150888712544256L;
public static final Long RR_系统用户_当前人员_人口信息=79150888712544257L;
public static final Long RR_人口信息_可被访问_系统权限=85530414090690560L;
public static final Long RR_系统权限_访问人口_人口信息=85530414090690561L;
}
| 3,317 | 0.841408 | 0.580538 | 40 | 59.375 | 12.020165 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.95 | false | false | 11 |
1d732972ed429fb960a0a30098bf056261995529 | 14,542,759,282,357 | 155e91e1751c4c9e84e2e06efec9784e50e81332 | /mobisens_android/android/src/edu/cmu/sv/mobisens/util/GeoIndex.java | 0aed15b237961bea6a8d0bb14d1c886b4fd6f082 | [] | no_license | seethaa/zense | https://github.com/seethaa/zense | 088e7cfb72769e8484b338cf4e8ebc23981dcacc | 064214fb49c6ce4fb318d1ee8525d7b9ab9e65ff | refs/heads/master | 2020-12-25T14:08:40.656000 | 2014-06-04T07:53:55 | 2014-06-04T07:53:55 | 12,447,025 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.cmu.sv.mobisens.util;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import edu.cmu.sv.lifelogger.util.DataCollector;
import edu.cmu.sv.mobisens.io.Directory;
import edu.cmu.sv.mobisens.io.FileOperation;
import edu.cmu.sv.mobisens.io.MobiSensLog;
public class GeoIndex {
private static final String TAG = "GeoIndex";
private static boolean inited = false;
private static boolean changed = false;
private static LinkedList<String> dataInMemory = new LinkedList<String>();
public static synchronized void writeData(DataCollector<double[]> locationData, long start, long end){
//File indexFile = getIndexFile();
if(locationData.getDataSize() == 0)
return;
if(!inited)
return;
String content = DataCollector.toStringWhenTIsDoubleArray(locationData);
//String fileName = FileNameConstructor.getLocationFileName(start, end);
String data = start + "," + end + "," + content;
dataInMemory.add(data);
changed = true;
}
public static synchronized ArrayList<double[]> getLocations(long start, long end){
ArrayList<double[]> locations = new ArrayList<double[]>();
if(!inited)
return locations;
for(String line:dataInMemory){
String columns[] = line.split(",");
if(columns.length < 3){
continue;
}
long startTime = Long.valueOf(columns[0]).longValue();
long endTime = Long.valueOf(columns[1]).longValue();
if(endTime < start)
continue;
if(end < startTime)
break;
String dataString = line.substring(columns[0].length() + columns[1].length() + 2);
DataCollector<double[]> locationData = DataCollector.fromStringWhenTIsDoubleArray(dataString);
LinkedList<double[]> rawData = locationData.getData();
for(double[] gps:rawData){
double[] gpsClone = new double[gps.length];
for(int i = 0; i< gps.length; i++){
gpsClone[i] = gps[i];
}
locations.add(gpsClone);
}
}
return locations;
}
public static synchronized void removeLocationData(long from, long to){
if(!inited)
return;
LinkedList<String> linesToDelete = new LinkedList<String>();
for(String line:dataInMemory){
String columns[] = line.split(",");
long startTime = Long.valueOf(columns[0]).longValue();
long endTime = Long.valueOf(columns[1]).longValue();
if(endTime < from)
continue;
if(to < startTime)
break;
linesToDelete.add(line);
}
if(linesToDelete.size() > 0){
dataInMemory.removeAll(linesToDelete);
changed = true;
}
}
public static synchronized void init(){
if(inited)
return;
inited = true;
File indexFile = getIndexFile();
if(!indexFile.exists())
return;
String content = FileOperation.readFileAsString(indexFile);
String[] lines = content.split("\r\n");
for(String line:lines){
dataInMemory.add(line);
}
}
public static synchronized void close(){
if(!inited)
return;
inited = false;
dataInMemory.clear();
}
public static synchronized void save(){
if(!inited)
return;
if(!changed)
return;
StringBuilder builder = new StringBuilder(100 * dataInMemory.size());
for(String line:dataInMemory){
builder.append(line).append("\r\n");
}
File indexFile = getIndexFile();
FileOperation.writeStringToFile(indexFile, builder.toString());
changed = true;
}
public static synchronized void reset(){
File indexFile = getIndexFile();
if(!indexFile.exists())
return;
indexFile.delete();
dataInMemory.clear();
inited = false;
changed = true;
}
public static synchronized void shrink(long timeSpanInMS){
if(!inited)
return;
LinkedList<String> dataToRemove = new LinkedList<String>();
long boundary = System.currentTimeMillis() - timeSpanInMS;
for(String line:dataInMemory){
String[] columns = line.split(",");
if(columns.length < 2){
dataToRemove.add(line);
continue;
}
long startTime = Long.parseLong(columns[0]);
if(startTime < boundary){
dataToRemove.add(line);
}
}
if(dataToRemove.size() > 0){
dataInMemory.removeAll(dataToRemove);
changed = true;
}
}
private static File getIndexFile(){
try {
File indexFile = Directory.openFile(Directory.GEO_DATA_FOLDER, "index.geo2.csv");
return indexFile;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
MobiSensLog.log(e);
}
return null;
}
}
| UTF-8 | Java | 4,763 | java | GeoIndex.java | Java | [] | null | [] | package edu.cmu.sv.mobisens.util;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import edu.cmu.sv.lifelogger.util.DataCollector;
import edu.cmu.sv.mobisens.io.Directory;
import edu.cmu.sv.mobisens.io.FileOperation;
import edu.cmu.sv.mobisens.io.MobiSensLog;
public class GeoIndex {
private static final String TAG = "GeoIndex";
private static boolean inited = false;
private static boolean changed = false;
private static LinkedList<String> dataInMemory = new LinkedList<String>();
public static synchronized void writeData(DataCollector<double[]> locationData, long start, long end){
//File indexFile = getIndexFile();
if(locationData.getDataSize() == 0)
return;
if(!inited)
return;
String content = DataCollector.toStringWhenTIsDoubleArray(locationData);
//String fileName = FileNameConstructor.getLocationFileName(start, end);
String data = start + "," + end + "," + content;
dataInMemory.add(data);
changed = true;
}
public static synchronized ArrayList<double[]> getLocations(long start, long end){
ArrayList<double[]> locations = new ArrayList<double[]>();
if(!inited)
return locations;
for(String line:dataInMemory){
String columns[] = line.split(",");
if(columns.length < 3){
continue;
}
long startTime = Long.valueOf(columns[0]).longValue();
long endTime = Long.valueOf(columns[1]).longValue();
if(endTime < start)
continue;
if(end < startTime)
break;
String dataString = line.substring(columns[0].length() + columns[1].length() + 2);
DataCollector<double[]> locationData = DataCollector.fromStringWhenTIsDoubleArray(dataString);
LinkedList<double[]> rawData = locationData.getData();
for(double[] gps:rawData){
double[] gpsClone = new double[gps.length];
for(int i = 0; i< gps.length; i++){
gpsClone[i] = gps[i];
}
locations.add(gpsClone);
}
}
return locations;
}
public static synchronized void removeLocationData(long from, long to){
if(!inited)
return;
LinkedList<String> linesToDelete = new LinkedList<String>();
for(String line:dataInMemory){
String columns[] = line.split(",");
long startTime = Long.valueOf(columns[0]).longValue();
long endTime = Long.valueOf(columns[1]).longValue();
if(endTime < from)
continue;
if(to < startTime)
break;
linesToDelete.add(line);
}
if(linesToDelete.size() > 0){
dataInMemory.removeAll(linesToDelete);
changed = true;
}
}
public static synchronized void init(){
if(inited)
return;
inited = true;
File indexFile = getIndexFile();
if(!indexFile.exists())
return;
String content = FileOperation.readFileAsString(indexFile);
String[] lines = content.split("\r\n");
for(String line:lines){
dataInMemory.add(line);
}
}
public static synchronized void close(){
if(!inited)
return;
inited = false;
dataInMemory.clear();
}
public static synchronized void save(){
if(!inited)
return;
if(!changed)
return;
StringBuilder builder = new StringBuilder(100 * dataInMemory.size());
for(String line:dataInMemory){
builder.append(line).append("\r\n");
}
File indexFile = getIndexFile();
FileOperation.writeStringToFile(indexFile, builder.toString());
changed = true;
}
public static synchronized void reset(){
File indexFile = getIndexFile();
if(!indexFile.exists())
return;
indexFile.delete();
dataInMemory.clear();
inited = false;
changed = true;
}
public static synchronized void shrink(long timeSpanInMS){
if(!inited)
return;
LinkedList<String> dataToRemove = new LinkedList<String>();
long boundary = System.currentTimeMillis() - timeSpanInMS;
for(String line:dataInMemory){
String[] columns = line.split(",");
if(columns.length < 2){
dataToRemove.add(line);
continue;
}
long startTime = Long.parseLong(columns[0]);
if(startTime < boundary){
dataToRemove.add(line);
}
}
if(dataToRemove.size() > 0){
dataInMemory.removeAll(dataToRemove);
changed = true;
}
}
private static File getIndexFile(){
try {
File indexFile = Directory.openFile(Directory.GEO_DATA_FOLDER, "index.geo2.csv");
return indexFile;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
MobiSensLog.log(e);
}
return null;
}
}
| 4,763 | 0.630695 | 0.626916 | 193 | 22.678757 | 22.638643 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.326425 | false | false | 11 |
ba2ae912c5b678fc616e5163bcca824f0b8d8482 | 29,497,835,453,978 | f6070e246768b3f9a0050ae6e93fd6eb544daad0 | /integration/mediation-tests/tests-sample/src/test/java/org/wso2/carbon/esb/samples/test/mediation/Sample0TestCase.java | aea633b5554ac6d1f5f1f853fce4608ed83d4764 | [
"Apache-2.0"
] | permissive | Jean-Marc-Henry/product-ei | https://github.com/Jean-Marc-Henry/product-ei | 349192065ccf268b20f0cf22386d02c3e12b9ec4 | ffb75e1c1075c7112211a2f849016fad7009faa1 | refs/heads/master | 2021-07-09T00:35:07.064000 | 2017-10-03T15:51:25 | 2017-10-03T15:51:25 | 106,177,260 | 1 | 0 | null | true | 2017-10-08T13:12:57 | 2017-10-08T13:12:57 | 2017-08-31T21:14:24 | 2017-10-06T06:34:30 | 38,842 | 0 | 0 | 0 | null | null | null | /*
*Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*WSO2 Inc. licenses this file to you under the Apache License,
*Version 2.0 (the "License"); you may not use this file except
*in compliance with the License.
*You may obtain a copy of the License at
*
*http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
*KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
package org.wso2.carbon.esb.samples.test.mediation;
import org.apache.axiom.om.OMElement;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
import org.wso2.carbon.esb.samples.test.util.ESBSampleIntegrationTest;
import org.wso2.esb.integration.common.utils.ESBTestConstant;
/**
* Sample 0: Introduction to ESB
*/
public class Sample0TestCase extends ESBSampleIntegrationTest {
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
super.init();
loadSampleESBConfiguration(0);
}
@Test(groups = { "wso2.esb" }, description = "Test log mediator")
public void testSample0() throws Exception {
LogViewerClient logViewerClient =
new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
logViewerClient.clearLogs();
OMElement response = axis2Client.sendSimpleStockQuoteRequest(
getMainSequenceURL(),
getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE),
"WSO2");
Assert.assertTrue(response.toString().contains("GetQuoteResponse"),
"GetQuoteResponse not found");
Assert.assertTrue(response.toString().contains("WSO2 Company"), "WSO2 Company not found");
String requestLog = "<ns:symbol>WSO2</ns:symbol>";
String responseLog = "<ax21:name>WSO2 Company</ax21:name>";
boolean isRequestLogFound = false, isResponseLogFound = false;
LogEvent[] logEvents = logViewerClient.getAllSystemLogs();
for (LogEvent event : logEvents) {
if (!isRequestLogFound && event.getMessage().contains(requestLog)) {
isRequestLogFound = true;
}
if (!isResponseLogFound && event.getMessage().contains(responseLog)) {
isResponseLogFound = true;
}
if (isRequestLogFound && isResponseLogFound) {
break;
}
}
Assert.assertTrue(isRequestLogFound, "Request log not found");
Assert.assertTrue(isResponseLogFound, "Response log not found");
}
@AfterClass(alwaysRun = true)
public void destroy() throws Exception {
super.cleanup();
}
}
| UTF-8 | Java | 3,094 | java | Sample0TestCase.java | Java | [] | null | [] | /*
*Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*WSO2 Inc. licenses this file to you under the Apache License,
*Version 2.0 (the "License"); you may not use this file except
*in compliance with the License.
*You may obtain a copy of the License at
*
*http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
*KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
package org.wso2.carbon.esb.samples.test.mediation;
import org.apache.axiom.om.OMElement;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
import org.wso2.carbon.esb.samples.test.util.ESBSampleIntegrationTest;
import org.wso2.esb.integration.common.utils.ESBTestConstant;
/**
* Sample 0: Introduction to ESB
*/
public class Sample0TestCase extends ESBSampleIntegrationTest {
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
super.init();
loadSampleESBConfiguration(0);
}
@Test(groups = { "wso2.esb" }, description = "Test log mediator")
public void testSample0() throws Exception {
LogViewerClient logViewerClient =
new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
logViewerClient.clearLogs();
OMElement response = axis2Client.sendSimpleStockQuoteRequest(
getMainSequenceURL(),
getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE),
"WSO2");
Assert.assertTrue(response.toString().contains("GetQuoteResponse"),
"GetQuoteResponse not found");
Assert.assertTrue(response.toString().contains("WSO2 Company"), "WSO2 Company not found");
String requestLog = "<ns:symbol>WSO2</ns:symbol>";
String responseLog = "<ax21:name>WSO2 Company</ax21:name>";
boolean isRequestLogFound = false, isResponseLogFound = false;
LogEvent[] logEvents = logViewerClient.getAllSystemLogs();
for (LogEvent event : logEvents) {
if (!isRequestLogFound && event.getMessage().contains(requestLog)) {
isRequestLogFound = true;
}
if (!isResponseLogFound && event.getMessage().contains(responseLog)) {
isResponseLogFound = true;
}
if (isRequestLogFound && isResponseLogFound) {
break;
}
}
Assert.assertTrue(isRequestLogFound, "Request log not found");
Assert.assertTrue(isResponseLogFound, "Response log not found");
}
@AfterClass(alwaysRun = true)
public void destroy() throws Exception {
super.cleanup();
}
}
| 3,094 | 0.692308 | 0.680995 | 84 | 35.833332 | 27.966745 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 11 |
4aa0294502f96ca5a505302176c00ab01e38986e | 28,132,035,853,897 | 80f663d7bcb0d697770c7dd0a1295aba50f0cae9 | /src/io/github/monkeydatabase/visitor/singerevaluation/action/Bad.java | 6ffa312caca875f05c22e3d0a2e3449e087b1779 | [] | no_license | MonkeyDatabase/DesignPattern | https://github.com/MonkeyDatabase/DesignPattern | 1b10fcfd9783227d059ad7c42a8a9aeca9dffe24 | 75e79b0c9d754bac8dc7aa9fe5cfdba85a674299 | refs/heads/main | 2023-01-23T06:57:44.446000 | 2020-12-09T14:46:35 | 2020-12-09T14:46:35 | 316,726,271 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.monkeydatabase.visitor.singerevaluation.action;
import io.github.monkeydatabase.visitor.singerevaluation.customer.Man;
import io.github.monkeydatabase.visitor.singerevaluation.customer.Woman;
public class Bad extends Action{
@Override
public void getManResult(Man man) {
System.out.println("This man thinks it's bad");
}
@Override
public void getWomanResult(Woman woman) {
System.out.println("This woman thinks it's bad");
}
}
| UTF-8 | Java | 488 | java | Bad.java | Java | [] | null | [] | package io.github.monkeydatabase.visitor.singerevaluation.action;
import io.github.monkeydatabase.visitor.singerevaluation.customer.Man;
import io.github.monkeydatabase.visitor.singerevaluation.customer.Woman;
public class Bad extends Action{
@Override
public void getManResult(Man man) {
System.out.println("This man thinks it's bad");
}
@Override
public void getWomanResult(Woman woman) {
System.out.println("This woman thinks it's bad");
}
}
| 488 | 0.739754 | 0.739754 | 16 | 29.5 | 26.946707 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 11 |
4bb0011fec2449cbb23c1fe98d6d40de5aad43f0 | 28,132,035,853,928 | 404c137e6bd16211341ac02827330fb7fcad0a64 | /src/com/nexus/simplify/parser/core/NameParser.java | f9843d8be63eab948793b1f95878a7d0d75d4bdd | [] | no_license | sursonico/main | https://github.com/sursonico/main | ea9635b2826d1dbca470bd6bd01747236a995d71 | 70809e77153b25f0ca2853618d62835e8afd0784 | refs/heads/master | 2020-07-14T16:33:42.681000 | 2015-04-18T15:09:18 | 2015-04-18T15:09:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //@author A0111035A
package com.nexus.simplify.parser.core;
import com.nexus.simplify.parser.data.CommandData;
/**
* Parsing of name works by parsing the remaining tokens as new task name after
* all other parameters had been parsed.
*
*/
public class NameParser extends TokenParser {
CommandData commandData = CommandData.getInstance();
/**
* Parses remaining tokens in tokenList as name tokens.
*/
@Override
public String[] parseTokens(String[] tokenList) throws Exception {
if (isTokenListEmpty(tokenList)) {
return tokenList;
} else {
if (isEnclosedInDoubleQuotes(tokenList)) {
tokenList = trimQuotesInTokens(tokenList);
}
String name = tokenListToStr(tokenList);
commandData.setNewName(name);
return getRemainingTokens(name, tokenList);
}
}
}
| UTF-8 | Java | 793 | java | NameParser.java | Java | [
{
"context": "//@author A0111035A\n\npackage com.nexus.simplify.parser.core;\n\nimport ",
"end": 19,
"score": 0.996688723564148,
"start": 10,
"tag": "USERNAME",
"value": "A0111035A"
}
] | null | [] | //@author A0111035A
package com.nexus.simplify.parser.core;
import com.nexus.simplify.parser.data.CommandData;
/**
* Parsing of name works by parsing the remaining tokens as new task name after
* all other parameters had been parsed.
*
*/
public class NameParser extends TokenParser {
CommandData commandData = CommandData.getInstance();
/**
* Parses remaining tokens in tokenList as name tokens.
*/
@Override
public String[] parseTokens(String[] tokenList) throws Exception {
if (isTokenListEmpty(tokenList)) {
return tokenList;
} else {
if (isEnclosedInDoubleQuotes(tokenList)) {
tokenList = trimQuotesInTokens(tokenList);
}
String name = tokenListToStr(tokenList);
commandData.setNewName(name);
return getRemainingTokens(name, tokenList);
}
}
}
| 793 | 0.737705 | 0.728878 | 31 | 24.580645 | 23.46002 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.419355 | false | false | 11 |
a5b5fe9560fb33f94423e0551bc9ce58a44961ad | 9,732,395,900,658 | 84f1f464d603876d9590022d5a44d1b6312a8646 | /src/test/java/bobby/sfdc/prototype/bulkv1/json/test/BulkV1BatchInfoTest.java | dc3c9e86979c766d36360b9dadfef38d42c639b0 | [
"Apache-2.0"
] | permissive | bobbywhitesfdc/BulkMaster | https://github.com/bobbywhitesfdc/BulkMaster | 796c068ecdeba54b12e8fdd208c510be768fb376 | bd4fa2814f62fa327f015f699e6c6e828b96c43c | refs/heads/master | 2022-06-22T16:33:23.945000 | 2022-06-17T11:47:43 | 2022-06-17T11:47:43 | 178,326,939 | 21 | 3 | Apache-2.0 | false | 2023-08-30T19:32:42 | 2019-03-29T03:37:12 | 2023-07-26T03:44:53 | 2023-08-30T19:32:40 | 33,414 | 22 | 4 | 2 | Java | false | false | package bobby.sfdc.prototype.bulkv1.json.test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.StringReader;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import bobby.sfdc.prototype.bulkv1.json.BulkV1BatchInfo;
class BulkV1BatchInfoTest {
@BeforeAll
static void setUpBeforeClass() throws Exception {
}
@AfterAll
static void tearDownAfterClass() throws Exception {
}
@BeforeEach
void setUp() throws Exception {
}
@AfterEach
void tearDown() throws Exception {
}
@Test
void testUnmarshallXML() throws JAXBException {
final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><batchInfo\n" +
" xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">\n" +
" <id>7512M00000YA6k6QAD</id>\n" +
" <jobId>7502M00000Sp7doQAB</jobId>\n" +
" <state>Queued</state>\n" +
" <createdDate>2019-04-15T18:08:00.000Z</createdDate>\n" +
" <systemModstamp>2019-04-15T18:08:00.000Z</systemModstamp>\n" +
" <numberRecordsProcessed>0</numberRecordsProcessed>\n" +
" <numberRecordsFailed>0</numberRecordsFailed>\n" +
" <totalProcessingTime>0</totalProcessingTime>\n" +
" <apiActiveProcessingTime>0</apiActiveProcessingTime>\n" +
" <apexProcessingTime>0</apexProcessingTime>\n" +
"</batchInfo>";
JAXBContext jaxbContext = JAXBContext.newInstance(BulkV1BatchInfo.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(xml);
BulkV1BatchInfo result = (BulkV1BatchInfo) unmarshaller.unmarshal(reader);
// Check a few key fields
assertEquals("7512M00000YA6k6QAD",result.id);
assertEquals("7502M00000Sp7doQAB",result.jobId);
assertEquals("Queued",result.state);
}
}
| UTF-8 | Java | 1,978 | java | BulkV1BatchInfoTest.java | Java | [] | null | [] | package bobby.sfdc.prototype.bulkv1.json.test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.StringReader;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import bobby.sfdc.prototype.bulkv1.json.BulkV1BatchInfo;
class BulkV1BatchInfoTest {
@BeforeAll
static void setUpBeforeClass() throws Exception {
}
@AfterAll
static void tearDownAfterClass() throws Exception {
}
@BeforeEach
void setUp() throws Exception {
}
@AfterEach
void tearDown() throws Exception {
}
@Test
void testUnmarshallXML() throws JAXBException {
final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><batchInfo\n" +
" xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">\n" +
" <id>7512M00000YA6k6QAD</id>\n" +
" <jobId>7502M00000Sp7doQAB</jobId>\n" +
" <state>Queued</state>\n" +
" <createdDate>2019-04-15T18:08:00.000Z</createdDate>\n" +
" <systemModstamp>2019-04-15T18:08:00.000Z</systemModstamp>\n" +
" <numberRecordsProcessed>0</numberRecordsProcessed>\n" +
" <numberRecordsFailed>0</numberRecordsFailed>\n" +
" <totalProcessingTime>0</totalProcessingTime>\n" +
" <apiActiveProcessingTime>0</apiActiveProcessingTime>\n" +
" <apexProcessingTime>0</apexProcessingTime>\n" +
"</batchInfo>";
JAXBContext jaxbContext = JAXBContext.newInstance(BulkV1BatchInfo.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(xml);
BulkV1BatchInfo result = (BulkV1BatchInfo) unmarshaller.unmarshal(reader);
// Check a few key fields
assertEquals("7512M00000YA6k6QAD",result.id);
assertEquals("7502M00000Sp7doQAB",result.jobId);
assertEquals("Queued",result.state);
}
}
| 1,978 | 0.735086 | 0.686047 | 64 | 29.90625 | 24.941004 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.65625 | false | false | 11 |
91a23b73a268150bbcc0269a6a325dad29c7b1ca | 9,732,395,900,299 | c32e7ba63327d24aa9208ee5b35cdcd7d75c7060 | /Java Resources/src/vo/Cart.java | 5a17e14567aa59a11de693afc4a9fe4da3ba2327 | [] | no_license | namwookyung/pitAPet | https://github.com/namwookyung/pitAPet | 0b3755f353f6dabdfcb3fca67b409ed319a01211 | 7c427d8f4d23056ddfe47c59fb800d12d709458e | refs/heads/master | 2023-02-23T02:38:58.134000 | 2021-01-26T02:40:52 | 2021-01-26T02:40:52 | 321,512,391 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package vo;
public class Cart {
private String p_image;
private String p_name;
private int p_price;
private int p_qty;
public String getP_image() {
return p_image;
}
public void setP_image(String p_image) {
this.p_image = p_image;
}
public String getP_name() {
return p_name;
}
public void setP_name(String p_name) {
this.p_name = p_name;
}
public int getP_price() {
return p_price;
}
public void setP_price(int p_price) {
this.p_price = p_price;
}
public int getP_qty() {
return p_qty;
}
public void setP_qty(int p_qty) {
this.p_qty = p_qty;
}
}
| UTF-8 | Java | 624 | java | Cart.java | Java | [] | null | [] | package vo;
public class Cart {
private String p_image;
private String p_name;
private int p_price;
private int p_qty;
public String getP_image() {
return p_image;
}
public void setP_image(String p_image) {
this.p_image = p_image;
}
public String getP_name() {
return p_name;
}
public void setP_name(String p_name) {
this.p_name = p_name;
}
public int getP_price() {
return p_price;
}
public void setP_price(int p_price) {
this.p_price = p_price;
}
public int getP_qty() {
return p_qty;
}
public void setP_qty(int p_qty) {
this.p_qty = p_qty;
}
}
| 624 | 0.610577 | 0.610577 | 35 | 15.828571 | 12.663752 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.457143 | false | false | 11 |
05651b1c1fee36a37254c26ba0426ca231339d97 | 12,111,807,779,167 | aa954ee476b5ce90bd5c64514285fd7059e432ea | /src/main/java/pers/johnx/demo/TestStorageClient.java | f3397179ccd43c65e7b905fa5a630d21f3d8fb46 | [] | no_license | Xyalab/fastDFSdemo | https://github.com/Xyalab/fastDFSdemo | 74376b9edbca1e031f1a77a4c1d485b8dd045a22 | aa75c517d75418dc55f5e38e8093e816f5edc0d7 | refs/heads/master | 2022-12-27T23:28:34.763000 | 2020-10-15T14:23:03 | 2020-10-15T14:23:03 | 304,349,228 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pers.johnx.demo;
import org.csource.common.MyException;
import org.csource.fastdfs.*;
import java.io.IOException;
/**
* @BelongsProject: fastDFSdemo
* @BelongsPackage: pers.johnx.pojo
* @Author: Administrator
* @Description:
*/
public class TestStorageClient {
public static void main(String args[]) throws IOException, MyException {
// 1、加载配置文件,配置文件中的内容就是 tracker 服务的地址。
ClientGlobal.init("./src/main/resources/fdfs_client.conf");
// 2、创建一个 TrackerClient 对象。直接 new 一个。
TrackerClient trackerClient = new TrackerClient();
// 3、使用 TrackerClient 对象创建连接,获得一个 TrackerServer 对象。
TrackerServer trackerServer = trackerClient.getConnection();
// 4、创建一个 StorageServer 的引用,值为 null
StorageServer storageServer = null;
// 5、创建一个 StorageClient 对象,需要两个参数 TrackerServer 对象、StorageServer 的引用
StorageClient storageClient = new StorageClient(trackerServer, storageServer);
// 6、使用 StorageClient 对象上传图片。
//扩展名不带“.”
String[] strings = storageClient.upload_file("(文件在本地的绝对路径)", "文件后缀名(不加“.”)",null);
// 7、返回数组。包含组名和图片的路径。
for (String string : strings) {
System.out.println(string);
}
}
}
| UTF-8 | Java | 1,511 | java | TestStorageClient.java | Java | [
{
"context": "mo\n * @BelongsPackage: pers.johnx.pojo\n * @Author: Administrator\n * @Description:\n */\npublic class TestStorageClie",
"end": 222,
"score": 0.6705445647239685,
"start": 209,
"tag": "NAME",
"value": "Administrator"
}
] | null | [] | package pers.johnx.demo;
import org.csource.common.MyException;
import org.csource.fastdfs.*;
import java.io.IOException;
/**
* @BelongsProject: fastDFSdemo
* @BelongsPackage: pers.johnx.pojo
* @Author: Administrator
* @Description:
*/
public class TestStorageClient {
public static void main(String args[]) throws IOException, MyException {
// 1、加载配置文件,配置文件中的内容就是 tracker 服务的地址。
ClientGlobal.init("./src/main/resources/fdfs_client.conf");
// 2、创建一个 TrackerClient 对象。直接 new 一个。
TrackerClient trackerClient = new TrackerClient();
// 3、使用 TrackerClient 对象创建连接,获得一个 TrackerServer 对象。
TrackerServer trackerServer = trackerClient.getConnection();
// 4、创建一个 StorageServer 的引用,值为 null
StorageServer storageServer = null;
// 5、创建一个 StorageClient 对象,需要两个参数 TrackerServer 对象、StorageServer 的引用
StorageClient storageClient = new StorageClient(trackerServer, storageServer);
// 6、使用 StorageClient 对象上传图片。
//扩展名不带“.”
String[] strings = storageClient.upload_file("(文件在本地的绝对路径)", "文件后缀名(不加“.”)",null);
// 7、返回数组。包含组名和图片的路径。
for (String string : strings) {
System.out.println(string);
}
}
}
| 1,511 | 0.671255 | 0.665587 | 39 | 30.666666 | 26.534286 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 11 |
4bb790e8a9aca161295b3bdff2b1af02e79ad55c | 30,537,217,537,020 | e89d7972afe06cdd8875b94f8c251499c6e949eb | /app/src/main/java/ml/byta/byta/Server/Requests/SendNewMessageToChatRequest.java | db6b77eff638a005b8a673c445e1df39572516db | [] | no_license | bytaapp/byta | https://github.com/bytaapp/byta | 53753d7f4d5d817aa699ac816f274dc3cb7179ac | 4f0b0ed1f0ebebf00bf96a233a8a7d10fbdb64e2 | refs/heads/master | 2021-05-06T18:58:00.218000 | 2018-01-29T10:36:27 | 2018-01-29T10:36:27 | 111,995,012 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ml.byta.byta.Server.Requests;
public class SendNewMessageToChatRequest {
private int authorId;
private String text;
private long timestamp;
public SendNewMessageToChatRequest(int authorId, String text, long timestamp) {
this.authorId = authorId;
this.text = text;
this.timestamp = timestamp;
}
public int getAuthorId() {
return authorId;
}
public void setAuthorId(int authorId) {
this.authorId = authorId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}
| UTF-8 | Java | 785 | java | SendNewMessageToChatRequest.java | Java | [] | null | [] | package ml.byta.byta.Server.Requests;
public class SendNewMessageToChatRequest {
private int authorId;
private String text;
private long timestamp;
public SendNewMessageToChatRequest(int authorId, String text, long timestamp) {
this.authorId = authorId;
this.text = text;
this.timestamp = timestamp;
}
public int getAuthorId() {
return authorId;
}
public void setAuthorId(int authorId) {
this.authorId = authorId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}
| 785 | 0.628025 | 0.628025 | 38 | 19.657894 | 18.564648 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.394737 | false | false | 11 |
9267829ac8260a79c4e80595de24eacee9ff99ce | 33,028,298,553,109 | c299874bf3cf9dd3ade0977dfb2e135d598a934c | /src/main/java/fr/benkiranemedali/Game/GameState.java | 4d2ef333f6cbf54b6f0c7b25a7296da6ea36dbb2 | [] | no_license | benkiranemedali/game | https://github.com/benkiranemedali/game | b93b4860a11429e74cf90615b1837dee81df7771 | da1f97adea701f2962d0e6865f4b4ad4e2347d22 | refs/heads/master | 2018-01-08T12:33:55.807000 | 2016-03-23T23:01:55 | 2016-03-23T23:01:55 | 54,598,850 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fr.benkiranemedali.Game;
/**
* Created by Benkirane Mohamed Ali & Maaraf Yassine on 22/03/2016.
*/
public class GameState {
public static State state;
public static GameState gameState;
public static GameState getInstace(){
if(gameState == null){
gameState = new GameState();
}
return gameState;
}
public static void setState(State s){
state = s;
}
public static State getState(){
return state;
}
}
| UTF-8 | Java | 501 | java | GameState.java | Java | [
{
"context": "ckage fr.benkiranemedali.Game;\n\n\n/**\n * Created by Benkirane Mohamed Ali & Maaraf Yassine on 22/03/2016.\n */\npublic class ",
"end": 74,
"score": 0.999884843826294,
"start": 53,
"tag": "NAME",
"value": "Benkirane Mohamed Ali"
},
{
"context": ".Game;\n\n\n/**\n * Created by Benkirane Mohamed Ali & Maaraf Yassine on 22/03/2016.\n */\npublic class GameState {\n\n ",
"end": 91,
"score": 0.9998891949653625,
"start": 77,
"tag": "NAME",
"value": "Maaraf Yassine"
}
] | null | [] | package fr.benkiranemedali.Game;
/**
* Created by <NAME> & <NAME> on 22/03/2016.
*/
public class GameState {
public static State state;
public static GameState gameState;
public static GameState getInstace(){
if(gameState == null){
gameState = new GameState();
}
return gameState;
}
public static void setState(State s){
state = s;
}
public static State getState(){
return state;
}
}
| 478 | 0.608782 | 0.592814 | 28 | 16.892857 | 18.022484 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 11 |
ebc6baa1aafebc2859a68f11687fce61d48dc3b2 | 30,820,685,334,841 | 071850b48f28e7b50522f240d51b591a57a2435b | /src/strings/WordBreak.java | 09fce67ef66b4b547b38b71df30d03b7aef250da | [] | no_license | sandeepsangole/CodeCode | https://github.com/sandeepsangole/CodeCode | ad36656dd65837bc737f333c2fff7bb5d3157a5b | 5cd6cd89f3da8d2434008e23be113d3e950cb106 | refs/heads/master | 2020-03-14T19:17:08.948000 | 2018-05-01T13:48:32 | 2018-05-01T13:48:32 | 131,718,364 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package strings;
/*
139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words,
determine if s can be segmented into a space-separated sequence of one or more dictionary words.
You may assume the dictionary does not contain duplicate words.
For example, given
s = "leetcode",
dict = ["leet", "code"].
Return true because "leetcode" can be segmented as "leet code".
*/
import com.sun.org.apache.xpath.internal.operations.Bool;
import java.util.*;
public class WordBreak {
public static void main(String[] args) {
String s = "leetcode";
List<String> dic = new ArrayList<>();
//dic.add("cat");
dic.add("leet");
dic.add("code");
WordBreak obj = new WordBreak();
System.out.println(obj.wordBreak(s, dic));
}
public boolean wordBreak(String s, List<String> wordDic) {
return wordBreakUtil(s, new HashSet<>(wordDic), 0, new Boolean[ s.length() ]);
}
public boolean wordBreakUtil(String s, Set<String> wordDic, int start, Boolean[] memo) {
if (start == s.length()) {
return true;
}
if (memo[ start ] != null) {
return memo[ start ];
}
for (int i = start + 1; i <= s.length(); i++) {
System.out.println(i +" "+start +" " +s.substring(start, i));
if (wordDic.contains(s.substring(start, i)) && wordBreakUtil(s, wordDic, i, memo)){
return memo[ start ] = true;
}
}
return memo[ start ] = false;
}
} | UTF-8 | Java | 1,422 | java | WordBreak.java | Java | [] | null | [] | package strings;
/*
139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words,
determine if s can be segmented into a space-separated sequence of one or more dictionary words.
You may assume the dictionary does not contain duplicate words.
For example, given
s = "leetcode",
dict = ["leet", "code"].
Return true because "leetcode" can be segmented as "leet code".
*/
import com.sun.org.apache.xpath.internal.operations.Bool;
import java.util.*;
public class WordBreak {
public static void main(String[] args) {
String s = "leetcode";
List<String> dic = new ArrayList<>();
//dic.add("cat");
dic.add("leet");
dic.add("code");
WordBreak obj = new WordBreak();
System.out.println(obj.wordBreak(s, dic));
}
public boolean wordBreak(String s, List<String> wordDic) {
return wordBreakUtil(s, new HashSet<>(wordDic), 0, new Boolean[ s.length() ]);
}
public boolean wordBreakUtil(String s, Set<String> wordDic, int start, Boolean[] memo) {
if (start == s.length()) {
return true;
}
if (memo[ start ] != null) {
return memo[ start ];
}
for (int i = start + 1; i <= s.length(); i++) {
System.out.println(i +" "+start +" " +s.substring(start, i));
if (wordDic.contains(s.substring(start, i)) && wordBreakUtil(s, wordDic, i, memo)){
return memo[ start ] = true;
}
}
return memo[ start ] = false;
}
} | 1,422 | 0.656821 | 0.653305 | 62 | 21.951612 | 27.159878 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.516129 | false | false | 11 |
b95db19365bf3086f40b3b7e8c86f3951570073f | 29,497,835,458,664 | b7a3eac54fb6ff77f04f60bc0061dc5927fe7be7 | /java_training/sets/sortHashSet.java | 14957586e9b92b2001117d68931bcadc5698cc52 | [] | no_license | akcorut/ProgDataStruct | https://github.com/akcorut/ProgDataStruct | 74c33ffa1c48c6532c177fc73edc8a0fc07af420 | ff51f9c57f06afeecbff960e0435c26e70935b43 | refs/heads/master | 2023-02-18T05:15:32.601000 | 2021-01-20T15:41:19 | 2021-01-20T15:41:19 | 167,719,657 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
// Java program to sort a HashSet
import java.util.*;
public class GFG {
public static void main(String args[])
{
// Creating a HashSet
HashSet<String> set = new HashSet<String>();
// Adding elements into HashSet using add()
set.add("geeks");
set.add("practice");
set.add("contribute");
set.add("ide");
System.out.println("Original HashSet: "
+ set);
// Sorting HashSet using List
List<String> list = new ArrayList<String>(set);
Collections.sort(list);
// Print the sorted elements of the HashSet
System.out.println("HashSet elements "
+ "in sorted order "
+ "using List: "
+ list);
}
}
| UTF-8 | Java | 850 | java | sortHashSet.java | Java | [] | null | [] |
// Java program to sort a HashSet
import java.util.*;
public class GFG {
public static void main(String args[])
{
// Creating a HashSet
HashSet<String> set = new HashSet<String>();
// Adding elements into HashSet using add()
set.add("geeks");
set.add("practice");
set.add("contribute");
set.add("ide");
System.out.println("Original HashSet: "
+ set);
// Sorting HashSet using List
List<String> list = new ArrayList<String>(set);
Collections.sort(list);
// Print the sorted elements of the HashSet
System.out.println("HashSet elements "
+ "in sorted order "
+ "using List: "
+ list);
}
}
| 850 | 0.489412 | 0.489412 | 30 | 27.266666 | 18.473284 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 11 |
29b39eae74f5dfe43828a286efadddd183f76534 | 18,657,337,949,458 | fc3fd131ba3fd4e43b1ca0fcd58025262b08919d | /library-extension/src/main/java/com/gql/graphql/schema/idl/SchemaParser.java | 783ceb8fc4bad2fe5a61dde6cff6b6b68d21d74a | [] | no_license | pkumartv/graphql-java-v2.4.0 | https://github.com/pkumartv/graphql-java-v2.4.0 | b1e210528a1f41ee9001b8cf4e5311de2102cc75 | 021a3678800f05e85c43f6123354265049cd1df0 | refs/heads/main | 2023-04-04T17:14:00.799000 | 2021-04-10T08:09:19 | 2021-04-10T08:09:19 | 354,036,716 | 1 | 0 | null | false | 2021-04-10T08:09:20 | 2021-04-02T14:04:16 | 2021-04-10T08:06:33 | 2021-04-10T08:09:19 | 7 | 0 | 0 | 0 | Java | false | false | package com.gql.graphql.schema.idl;
import graphql.GraphQLError;
import graphql.InvalidSyntaxError;
import graphql.language.Definition;
import graphql.language.Document;
import graphql.language.SourceLocation;
import graphql.parser.Parser;
import com.gql.graphql.schema.idl.errors.SchemaProblem;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.misc.ParseCancellationException;
/**
* This can take a graphql schema definition and parse it into a {@link TypeDefinitionRegistry} of
* definitions ready to be placed into {@link SchemaGenerator} say
*/
public class SchemaParser {
//private static final Logger _LOG = new Logger(SchemaParser.class);
/**
* Parse a file of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param file the file to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(final File file) throws SchemaProblem {
try {
return parse(new FileReader(file));
} catch (final FileNotFoundException e) {
throw new RuntimeException(e);
}
}
/**
* Parse a reader of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param reader the reader to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(final Reader reader) throws SchemaProblem {
try (Reader input = reader) {
return parse(read(input));
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
/**
* Parse a string of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param schemaInput the schema string to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(String schemaInput) throws SchemaProblem
{
Document document=null;
try {
final Parser parser = new Parser();
document = parser.parseDocument(schemaInput);
} catch (final Exception e) {
//throw new handleParseException(e);
RecognitionException recognitionException = (RecognitionException) e.getCause();
SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine());
}
return buildRegistry(document);
}
// private SchemaProblem handleParseException(ParseCancellationException e) throws RuntimeException {
// RecognitionException recognitionException = (RecognitionException) e.getCause();
// SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine());
// InvalidSyntaxError invalidSyntaxError = new InvalidSyntaxError(sourceLocation);
// return new SchemaProblem(Collections.singletonList(invalidSyntaxError));
// }
private TypeDefinitionRegistry buildRegistry(final Document document) {
final List<GraphQLError> errors = new ArrayList<GraphQLError>();
final TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
final List<Definition> definitions = document.getDefinitions();
for (final Definition definition : definitions) {
//JAVA1.8TOPORT ifPresent
typeRegistry.add(definition);//.ifPresent(errors::add);
}
if (errors.size() > 0) {
throw new SchemaProblem(errors);
} else {
return typeRegistry;
}
}
private String read(final Reader reader) throws IOException {
final char[] buffer = new char[1024 * 4];
final StringWriter sw = new StringWriter();
int n;
while (-1 != (n = reader.read(buffer))) {
sw.write(buffer, 0, n);
}
return sw.toString();
}
}
| UTF-8 | Java | 4,533 | java | SchemaParser.java | Java | [] | null | [] | package com.gql.graphql.schema.idl;
import graphql.GraphQLError;
import graphql.InvalidSyntaxError;
import graphql.language.Definition;
import graphql.language.Document;
import graphql.language.SourceLocation;
import graphql.parser.Parser;
import com.gql.graphql.schema.idl.errors.SchemaProblem;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.misc.ParseCancellationException;
/**
* This can take a graphql schema definition and parse it into a {@link TypeDefinitionRegistry} of
* definitions ready to be placed into {@link SchemaGenerator} say
*/
public class SchemaParser {
//private static final Logger _LOG = new Logger(SchemaParser.class);
/**
* Parse a file of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param file the file to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(final File file) throws SchemaProblem {
try {
return parse(new FileReader(file));
} catch (final FileNotFoundException e) {
throw new RuntimeException(e);
}
}
/**
* Parse a reader of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param reader the reader to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(final Reader reader) throws SchemaProblem {
try (Reader input = reader) {
return parse(read(input));
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
/**
* Parse a string of schema definitions and create a {@link TypeDefinitionRegistry}
*
* @param schemaInput the schema string to parse
*
* @return registry of type definitions
*
* @throws SchemaProblem if there are problems compiling the schema definitions
*/
public TypeDefinitionRegistry parse(String schemaInput) throws SchemaProblem
{
Document document=null;
try {
final Parser parser = new Parser();
document = parser.parseDocument(schemaInput);
} catch (final Exception e) {
//throw new handleParseException(e);
RecognitionException recognitionException = (RecognitionException) e.getCause();
SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine());
}
return buildRegistry(document);
}
// private SchemaProblem handleParseException(ParseCancellationException e) throws RuntimeException {
// RecognitionException recognitionException = (RecognitionException) e.getCause();
// SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine());
// InvalidSyntaxError invalidSyntaxError = new InvalidSyntaxError(sourceLocation);
// return new SchemaProblem(Collections.singletonList(invalidSyntaxError));
// }
private TypeDefinitionRegistry buildRegistry(final Document document) {
final List<GraphQLError> errors = new ArrayList<GraphQLError>();
final TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
final List<Definition> definitions = document.getDefinitions();
for (final Definition definition : definitions) {
//JAVA1.8TOPORT ifPresent
typeRegistry.add(definition);//.ifPresent(errors::add);
}
if (errors.size() > 0) {
throw new SchemaProblem(errors);
} else {
return typeRegistry;
}
}
private String read(final Reader reader) throws IOException {
final char[] buffer = new char[1024 * 4];
final StringWriter sw = new StringWriter();
int n;
while (-1 != (n = reader.read(buffer))) {
sw.write(buffer, 0, n);
}
return sw.toString();
}
}
| 4,533 | 0.682991 | 0.680344 | 124 | 35.55645 | 34.073048 | 181 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.41129 | false | false | 11 |
055774fb92a9a47afc960802ce7b3031e6f0d968 | 14,577,119,021,798 | ed977136a23802f9284cfe6871e090d51a67ec5f | /src/main/java/com/james/framework/package-info.java | 34635b50a9d65b3290c01b7c72c01ae7174bab24 | [] | no_license | tangmili/framework-common | https://github.com/tangmili/framework-common | 19dfa97d3027c758a7b03c0ea95990cdf922de64 | e0528bb2670eac35b5116e2737f107190347e319 | refs/heads/master | 2021-06-25T10:39:43.056000 | 2017-09-12T10:06:13 | 2017-09-12T10:06:13 | 103,250,294 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Created by militang on 17/9/12.
*/
package com.james.framework; | UTF-8 | Java | 71 | java | package-info.java | Java | [
{
"context": "/**\n * Created by militang on 17/9/12.\n */\npackage com.james.framework;",
"end": 26,
"score": 0.9801055788993835,
"start": 18,
"tag": "USERNAME",
"value": "militang"
}
] | null | [] | /**
* Created by militang on 17/9/12.
*/
package com.james.framework; | 71 | 0.676056 | 0.605634 | 4 | 17 | 14.159802 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 11 |
294833b276b3d0b8bd9a255f60598b1dc9909fd7 | 22,797,686,409,525 | 710e027437a1d5c817f959c06bad806778c1981e | /src/main/java/flying/tool/model/XmlModel.java | c807eb886e4c73b55edce55a5918ed122900b3de | [] | no_license | fallenq/flying_spring | https://github.com/fallenq/flying_spring | 356206b0a8699d2e228b2766d01a91dc322470a6 | 0d439e1e59535b2f639e07116320d9256a282dc2 | refs/heads/master | 2021-09-06T13:57:38.477000 | 2018-02-07T07:53:10 | 2018-02-07T07:53:10 | 114,424,043 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package flying.tool.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import flying.tool.CommonTool;
public class XmlModel {
private String name = "", value = "";
private Map<String, String> attributes = null;
private List<XmlModel> childList = null;
private int isLeft = 0;
public XmlModel() {
attributes = CommonTool.emptyStringMap();
childList = new ArrayList<XmlModel>();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Map<String, String> getAttributes() {
return attributes;
}
public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}
public List<XmlModel> getChildList() {
return childList;
}
public void setChildList(List<XmlModel> childList) {
this.childList = childList;
}
public void setAttributeValue(String name, String value) {
attributes.put(name, value);
}
public void addXmlModel(XmlModel model) {
childList.add(model);
}
public int getIsLeft() {
return isLeft;
}
public void setIsLeft(int isLeft) {
this.isLeft = isLeft;
}
}
| UTF-8 | Java | 1,246 | java | XmlModel.java | Java | [] | null | [] | package flying.tool.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import flying.tool.CommonTool;
public class XmlModel {
private String name = "", value = "";
private Map<String, String> attributes = null;
private List<XmlModel> childList = null;
private int isLeft = 0;
public XmlModel() {
attributes = CommonTool.emptyStringMap();
childList = new ArrayList<XmlModel>();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Map<String, String> getAttributes() {
return attributes;
}
public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}
public List<XmlModel> getChildList() {
return childList;
}
public void setChildList(List<XmlModel> childList) {
this.childList = childList;
}
public void setAttributeValue(String name, String value) {
attributes.put(name, value);
}
public void addXmlModel(XmlModel model) {
childList.add(model);
}
public int getIsLeft() {
return isLeft;
}
public void setIsLeft(int isLeft) {
this.isLeft = isLeft;
}
}
| 1,246 | 0.704655 | 0.703852 | 69 | 17.057972 | 17.28607 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.318841 | false | false | 11 |
fc21e631b933494055d37456c838ee74b5e5766c | 22,213,570,868,513 | 7de460270260ece904bfff3529b767ec15850512 | /alpha-core/src/main/java/com/alpha/dao/VehicleCheckDao.java | f4a767974860d89384c3291a102e297d05ec1636 | [] | no_license | taoxiangxiang/alpha | https://github.com/taoxiangxiang/alpha | 8b7c0f8512a3d33b13706ff2f771790e2e1c4c8a | bf69fe6792c5a5bc308b2b83510c5c4b27dfdc9e | refs/heads/master | 2021-01-18T22:29:13.558000 | 2018-05-12T14:28:15 | 2018-05-12T14:28:15 | 87,056,789 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.alpha.dao;
import com.alpha.domain.VehicleCheckDO;
import com.alpha.query.VehicleCheckQuery;
import java.util.List;
/**
* Created by taoxiang on 2017/4/26.
*/
public interface VehicleCheckDao {
boolean insert(VehicleCheckDO vehicleCheckDO);
List<VehicleCheckDO> query(VehicleCheckQuery vehicleCheckQuery);
int count(VehicleCheckQuery vehicleCheckQuery);
boolean update(VehicleCheckDO vehicleCheckDO);
}
| UTF-8 | Java | 440 | java | VehicleCheckDao.java | Java | [
{
"context": "kQuery;\n\nimport java.util.List;\n\n/**\n * Created by taoxiang on 2017/4/26.\n */\npublic interface VehicleCheckDa",
"end": 157,
"score": 0.9995245337486267,
"start": 149,
"tag": "USERNAME",
"value": "taoxiang"
}
] | null | [] | package com.alpha.dao;
import com.alpha.domain.VehicleCheckDO;
import com.alpha.query.VehicleCheckQuery;
import java.util.List;
/**
* Created by taoxiang on 2017/4/26.
*/
public interface VehicleCheckDao {
boolean insert(VehicleCheckDO vehicleCheckDO);
List<VehicleCheckDO> query(VehicleCheckQuery vehicleCheckQuery);
int count(VehicleCheckQuery vehicleCheckQuery);
boolean update(VehicleCheckDO vehicleCheckDO);
}
| 440 | 0.779545 | 0.763636 | 20 | 21 | 22.41205 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 11 |
07444cfd95ffe7a7ee53e662f1460ea2413bacb7 | 3,539,053,080,151 | d7d32a85fac8b52c5ad14a7c57d9d2ee452e96f8 | /src/com/zqb/util/DBConnectHelper.java | 8454b12034a1ad1c2c686d70097e08c1c6a02f20 | [] | no_license | zqb1655200505/phone_book | https://github.com/zqb1655200505/phone_book | 8a77db9f69d083f067a9f02d27d921180c03d06d | 359f3646db2d68494ac473afa90ade256b399b64 | refs/heads/master | 2021-01-13T13:23:08.143000 | 2016-11-01T11:47:52 | 2016-11-01T11:47:52 | 72,445,323 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zqb.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* Created by zqb on 2016/10/16.
*/
public class DBConnectHelper {
public static Connection getConnection(String dbName)
{
String dbUrl="jdbc:mysql://localhost:3306/"+dbName;
String username="root";
String password="2011zqb,.";
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection(dbUrl,username,password);
if(!con.isClosed())
{
return con;
}
else
{
return null;
}
} catch (SQLException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
}
| UTF-8 | Java | 903 | java | DBConnectHelper.java | Java | [
{
"context": ";\nimport java.sql.SQLException;\n\n/**\n * Created by zqb on 2016/10/16.\n */\npublic class DBConnectHelper {",
"end": 134,
"score": 0.9996517300605774,
"start": 131,
"tag": "USERNAME",
"value": "zqb"
},
{
"context": " String username=\"root\";\n String password=\"2011zqb,.\";\n try {\n Class.forName(\"com.my",
"end": 374,
"score": 0.9296650886535645,
"start": 367,
"tag": "PASSWORD",
"value": "2011zqb"
}
] | null | [] | package com.zqb.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* Created by zqb on 2016/10/16.
*/
public class DBConnectHelper {
public static Connection getConnection(String dbName)
{
String dbUrl="jdbc:mysql://localhost:3306/"+dbName;
String username="root";
String password="<PASSWORD>,.";
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection(dbUrl,username,password);
if(!con.isClosed())
{
return con;
}
else
{
return null;
}
} catch (SQLException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
}
| 906 | 0.543743 | 0.526024 | 36 | 24.083334 | 18.349047 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 11 |
c168a363fb95f95d1a07745259c87633307f6115 | 20,478,404,088,761 | 338b8cba5e22b3b8eafc56d5f7b0f3ae437732bd | /heap/MainClass.java | 6aee3f5a05cc787671e9384a6d22343316230172 | [] | no_license | ChaudharyRaj/Placement-preparation-Data-Structures-Algorithm | https://github.com/ChaudharyRaj/Placement-preparation-Data-Structures-Algorithm | 79e91953c26a377a665baeb8ed58d2ba3223587b | 8e9eabba2aac35548e0c99ecd9169000b5c0f7a0 | refs/heads/master | 2023-02-28T09:01:37.667000 | 2021-02-09T17:11:47 | 2021-02-09T17:11:47 | 327,511,214 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package heap;
import java.util.*;
public class MainClass {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
// MaxHeap maxheap = new MaxHeap(n);
//
// for(int i = 1; i<=n; i++){
// int element = in.nextInt();
// maxheap.insert(element);
// }
// maxheap.buildheap();
// System.out.println();
// maxheap.printHeap();
// System.out.println();
// //System.out.println(maxheap.extractMax());
// //maxheap.printHeap();
// maxheap.Increase_Key(5, 400);
// System.out.println();
// maxheap.printHeap();
MinHeap minHeap = new MinHeap(n);
for(int i =1; i<=n; i++){
minHeap.insert(in.nextInt());
}
// System.out.println("Beffor");
// minHeap.printheap();
minHeap.buildHeap();
System.out.println();
System.out.print(minHeap.remove()+" ");
minHeap.printheap();
}
// 10
// 1 17 10 3 8 15 9 2 13 6
}
| UTF-8 | Java | 919 | java | MainClass.java | Java | [] | null | [] | package heap;
import java.util.*;
public class MainClass {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
// MaxHeap maxheap = new MaxHeap(n);
//
// for(int i = 1; i<=n; i++){
// int element = in.nextInt();
// maxheap.insert(element);
// }
// maxheap.buildheap();
// System.out.println();
// maxheap.printHeap();
// System.out.println();
// //System.out.println(maxheap.extractMax());
// //maxheap.printHeap();
// maxheap.Increase_Key(5, 400);
// System.out.println();
// maxheap.printHeap();
MinHeap minHeap = new MinHeap(n);
for(int i =1; i<=n; i++){
minHeap.insert(in.nextInt());
}
// System.out.println("Beffor");
// minHeap.printheap();
minHeap.buildHeap();
System.out.println();
System.out.print(minHeap.remove()+" ");
minHeap.printheap();
}
// 10
// 1 17 10 3 8 15 9 2 13 6
}
| 919 | 0.591948 | 0.568009 | 54 | 16.018518 | 14.413845 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.055556 | false | false | 11 |
4646f67a90a746cab7864f494e34db93935e1b46 | 20,478,404,086,514 | 57fa0f122e0324e34c410d7b710c1430d9114683 | /src/main/java/com/example/taf/widgets/impl/SearchResultWidgetImpl.java | 5bdfa2864fe03aca4d95703271c92b42507b0268 | [] | no_license | YShevchenko/example_serenity_eg | https://github.com/YShevchenko/example_serenity_eg | 8f5cd17689f3d2b447bce435f2389239d80a8888 | f2e2c452b72d89c7a05bf3d5003a257c4211ef98 | refs/heads/master | 2021-06-03T03:04:13.852000 | 2016-08-22T20:27:36 | 2016-08-22T20:27:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.taf.widgets.impl;
import com.example.taf.widgets.SearchResultWidget;
import net.serenitybdd.core.pages.PageObject;
import net.serenitybdd.core.pages.WebElementFacade;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.pagefactory.ElementLocator;
public class SearchResultWidgetImpl extends AbstractWidgetImpl implements SearchResultWidget {
@FindBy(xpath = ".//input[@type='checkbox']")
private WebElementFacade selectAdCheckbox;
public SearchResultWidgetImpl(final PageObject page, final ElementLocator locator,
final long timeoutInMilliseconds) {
super(page, locator, timeoutInMilliseconds);
}
public SearchResultWidgetImpl(final PageObject page, final ElementLocator locator,
final WebElement webElement, final long timeoutInMilliseconds) {
super(page, locator, webElement, timeoutInMilliseconds);
}
@Override
public void selectAd() {
selectAdCheckbox.click();
}
}
| UTF-8 | Java | 1,089 | java | SearchResultWidgetImpl.java | Java | [] | null | [] | package com.example.taf.widgets.impl;
import com.example.taf.widgets.SearchResultWidget;
import net.serenitybdd.core.pages.PageObject;
import net.serenitybdd.core.pages.WebElementFacade;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.pagefactory.ElementLocator;
public class SearchResultWidgetImpl extends AbstractWidgetImpl implements SearchResultWidget {
@FindBy(xpath = ".//input[@type='checkbox']")
private WebElementFacade selectAdCheckbox;
public SearchResultWidgetImpl(final PageObject page, final ElementLocator locator,
final long timeoutInMilliseconds) {
super(page, locator, timeoutInMilliseconds);
}
public SearchResultWidgetImpl(final PageObject page, final ElementLocator locator,
final WebElement webElement, final long timeoutInMilliseconds) {
super(page, locator, webElement, timeoutInMilliseconds);
}
@Override
public void selectAd() {
selectAdCheckbox.click();
}
}
| 1,089 | 0.732782 | 0.732782 | 30 | 35.299999 | 31.407166 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.7 | false | false | 11 |
c84894e034d5ea1f05823b66bea5d5c18fc98314 | 18,219,251,284,436 | 72ef55c0d98019e629cac2314025dcfeb73a8d3f | /java/ReverseLinkedList.java | 0185a6accb6d3f955ec0816f58ca05d37eeaf04d | [] | no_license | Jonathanz87/LeetCode | https://github.com/Jonathanz87/LeetCode | 604442b4e408b32f3ee733528e5af352155642a7 | f12cc77e642b8b83a2572d8eaafb3f4b35f5ce03 | refs/heads/master | 2023-04-13T15:26:11.113000 | 2023-04-05T22:28:33 | 2023-04-05T22:28:33 | 83,619,469 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
problem 206
Reverse a singly linked list.
Hint:
A linked list can be reversed either iteratively or recursively.
Could you implement both?
*/
public class ReverseLinkedList {
//Definition for singly-linked list.
public class ListNode {
int val;
ListNode next;
ListNode(int x) { val = x; }
}
public ListNode reverseList(ListNode head) {
ListNode next = null;
while (head != null) {
ListNode temp = head.next;
head.next = next;
next = head;
head = temp;
}
return next;
}
} | UTF-8 | Java | 513 | java | ReverseLinkedList.java | Java | [] | null | [] | /*
problem 206
Reverse a singly linked list.
Hint:
A linked list can be reversed either iteratively or recursively.
Could you implement both?
*/
public class ReverseLinkedList {
//Definition for singly-linked list.
public class ListNode {
int val;
ListNode next;
ListNode(int x) { val = x; }
}
public ListNode reverseList(ListNode head) {
ListNode next = null;
while (head != null) {
ListNode temp = head.next;
head.next = next;
next = head;
head = temp;
}
return next;
}
} | 513 | 0.676413 | 0.670565 | 29 | 16.724138 | 15.688557 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.551724 | false | false | 11 |
642f182bcc28600fc6df7532ba86c653fe5c017c | 7,121,055,796,631 | 7946f0e5ea2f16590415795294f3cc2f865e7387 | /src/main/java/com/websystem/www/dao/WorkDao.java | 25eacc679a99fd3d252e8b8abb7d969c5cb9a89c | [] | no_license | yoochenil/YUKAIWebsystem | https://github.com/yoochenil/YUKAIWebsystem | fb41712780a54333fa3fb193d3a5f37c288398a8 | b57243ca275bdb7734ed4b4695ad7a53b651b95a | refs/heads/master | 2020-04-03T00:45:55.821000 | 2018-11-02T12:28:11 | 2018-11-02T12:28:11 | 154,908,200 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.websystem.www.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.websystem.www.entity.Work;
public interface WorkDao {
List<Map<String,String>> getTodayWork(String today);
List<Work> ajaxGetWork(HashMap<String, String> paramMap);
int insWork(Work work);
int updWork(Work work);
int delWork(String id);
List<HashMap<String,String>> ajaxGetWorkDataTable(HashMap<String, String> paramMap);
}
| UTF-8 | Java | 453 | java | WorkDao.java | Java | [] | null | [] | package com.websystem.www.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.websystem.www.entity.Work;
public interface WorkDao {
List<Map<String,String>> getTodayWork(String today);
List<Work> ajaxGetWork(HashMap<String, String> paramMap);
int insWork(Work work);
int updWork(Work work);
int delWork(String id);
List<HashMap<String,String>> ajaxGetWorkDataTable(HashMap<String, String> paramMap);
}
| 453 | 0.763797 | 0.763797 | 23 | 18.695652 | 22.441101 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.913043 | false | false | 11 |
b98be9eeba2ed03d59c9b1384591ec9a01fee712 | 14,147,622,281,855 | 67798dc100dfc42ec419c8a9a0634a48c060dacc | /src/main/java/ie/adamdevenyi/mappers/AccountRowMapper.java | 252eac199b77228c147dbc1cb12e87eae8e1c8d6 | [] | no_license | devad11/projectSpring | https://github.com/devad11/projectSpring | 12355cac1349321373702ba3dda73f3bc19aa63d | 11f293ba13dce3902d2aee2775d8b0fd845e487e | refs/heads/master | 2020-08-31T03:55:48.161000 | 2019-10-30T16:57:10 | 2019-10-30T16:57:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ie.adamdevenyi.mappers;
import java.sql.ResultSet;
import java.sql.SQLException;
import ie.adamdevenyi.domain.Account;
import org.springframework.jdbc.core.RowMapper;
public class AccountRowMapper implements RowMapper<Account>{
public Account mapRow(ResultSet rs, int rowNumber)
throws SQLException
{
Account account = new Account();
account.setAccountId(rs.getInt("accountId"));
account.setBalance(rs.getInt("balance"));
account.setOverdraft(rs.getInt("overdraft"));
return account;
}
} | UTF-8 | Java | 525 | java | AccountRowMapper.java | Java | [] | null | [] | package ie.adamdevenyi.mappers;
import java.sql.ResultSet;
import java.sql.SQLException;
import ie.adamdevenyi.domain.Account;
import org.springframework.jdbc.core.RowMapper;
public class AccountRowMapper implements RowMapper<Account>{
public Account mapRow(ResultSet rs, int rowNumber)
throws SQLException
{
Account account = new Account();
account.setAccountId(rs.getInt("accountId"));
account.setBalance(rs.getInt("balance"));
account.setOverdraft(rs.getInt("overdraft"));
return account;
}
} | 525 | 0.76381 | 0.76381 | 20 | 25.299999 | 20.147209 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.85 | false | false | 11 |
8e19d6e1d9a74dc3470c7a678a0087b5fb806d61 | 14,894,946,642,668 | 6cbd224056341ff589ca91968c106825504de102 | /src/main/java/services/ListService.java | 0d0cb3a7164a278749b75ff1fb433c0e98692a9d | [] | no_license | drakkainen/numberPerceptron | https://github.com/drakkainen/numberPerceptron | f2aa0c6138ccf979901b770ab835bfe68859f9cc | 85fcc0aa788cd422e4c2a98c8ba3673fa496f5e3 | refs/heads/master | 2017-10-18T08:51:53.094000 | 2016-10-13T20:52:29 | 2016-10-13T20:52:29 | 70,226,465 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package services;
import java.util.List;
public interface ListService<T> {
List<List<T>> copy2DList(List<List<T>> input);
}
| UTF-8 | Java | 131 | java | ListService.java | Java | [] | null | [] | package services;
import java.util.List;
public interface ListService<T> {
List<List<T>> copy2DList(List<List<T>> input);
}
| 131 | 0.709924 | 0.70229 | 8 | 15.375 | 17.577951 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 11 |
98a783a45a3c4c464c5d0a7faab3591d74a0cdec | 14,894,946,642,861 | 22527752ed4f2a6f54b507c9aaa193783fc0e6fc | /app/src/main/java/com/webabcd/androiddemo/async/HandlerDemo1.java | 541a67f482c8a66e9cec880cd7a9b0bea5c9d0bc | [] | no_license | webabcd/AndroidDemo | https://github.com/webabcd/AndroidDemo | 1a9df344999548fde70cf32dd5677b045fd57d7f | 02031106c66b359162f32f6564c557f708cea593 | refs/heads/master | 2023-08-04T11:23:22.189000 | 2023-07-26T03:06:16 | 2023-07-26T03:06:16 | 153,596,772 | 36 | 8 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Handler 的使用(Handler 用于在线程之间传递信息)
* 本例演示后台线程向主线程发送信息
*
*
* Message - 用于封装需要传递的信息(一般通过 handler 的 obtainMessage() 来构造 Message 对象,而不是 new 一个。因为 obtainMessage() 会从 Message 池中拿一个不用的过来,这样会省去创建对象的开销)
* what - 信息类型(以便接收方区分不同类型的信息)
* arg1, arg2 - 自定义整型参数
* obj - 具体的信息对象
* Handler - 与相关的 MessageQueue 和 Looper 形成绑定关系,有两个作用
* 1、将信息发送到 Handler 所属线程的 MessageQueue
* 2、接收 Looper 获取到的信息,以便在 Handler 所属线程进行处理
* MessageQueue - 用于保存 Message 对象的消息队列
* Looper - 线程的 MessageQueue 管理者,循环从 MessageQueue 获取消息,并交给 Handler 处理
*
*
* 通过 Handler 的 send 发送信息到 MessageQueue,以及接收 send 过来的信息
* sendMessage(Message msg) - 通过 send 发送 Message 对象
* sendMessageAtFrontOfQueue(Message msg) - 通过 send 发送 Message 对象,并将其放入 MessageQueue 队列的第一个
* sendMessageDelayed(Message msg, long delayMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送 Message 对象
* sendMessageAtTime(Message msg, long uptimeMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送 Message 对象
* sendEmptyMessageDelayed(int what, long delayMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送一个只有 what 值的空信息
* sendEmptyMessageAtTime(int what, long uptimeMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送一个只有 what 值的空信息
* 通过重写 handleMessage(Message msg) 来处理 send 过来的信息
*
* 通过 Handler 的 post 发送信息到 MessageQueue,以及接收 post 过来的信息
* post(Runnable r) - 通过 post 发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtFrontOfQueue(Runnable r) - 通过 post 发送消息,并将其放入 MessageQueue 队列的第一个,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postDelayed(Runnable r, long delayMillis) - 通过 post 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtTime(Runnable r, long uptimeMillis) - 通过 post 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtTime(Runnable r, Object token, long uptimeMillis) - token 用于信息的删除,其他和 postAtTime(Runnable r, long uptimeMillis) 一样
*
* 从 MessageQueue 移除指定的信息
* removeMessages(int what) - 移除指定 what 的 send 信息
* removeMessages(int what, Object object) - 移除指定 what 和 obj 的 send 信息
* removeCallbacks(Runnable r) - 移除 post 的指定 Runnable 的回调
* removeCallbacks(Runnable r, Object token) - 移除 post 的指定 Runnable 和 token 的回调
* removeCallbacksAndMessages(Object token) - 移除 post 的指定 token 的信息和回调
*
*
* 注:
* 1、主线程已经启动 Looper 了,不用再 Looper.prepare()/Looper.loop() 了
* 2、新开线程需要自己写 Looper.prepare()/Looper.loop()/myLooper.quit()
*/
package com.webabcd.androiddemo.async;
import android.os.Message;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.webabcd.androiddemo.R;
public class HandlerDemo1 extends AppCompatActivity {
private TextView _textView1;
private TextView _textView2;
private Button _button1;
private Button _button2;
private Handler _handler;
private final int NORMAL_MESSAGE = 100;
private final int DELAY_MESSAGE = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_async_handlerdemo1);
_textView1 = (TextView) findViewById(R.id.textView1);
_textView2 = (TextView) findViewById(R.id.textView2);
_button1 = (Button) findViewById(R.id.button1);
_button2 = (Button) findViewById(R.id.button2);
sample();
}
private void sample() {
// 在 UI 线程实例化 Handler(默认与 Looper.myLooper() 形成绑定关系,也可以与指定的 Looper 形成绑定关系)
_handler = new MyHandler();
// _handler = new MyHandler(looper);
_button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// 启动一个后台线程
Thread myThread = new MyThread();
myThread.setName("myThread");
myThread.setDaemon(true);
myThread.start();
_textView1.setText("后台线程开始执行\n");
}
});
_button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
writeMessage(String.format("取消队列中的 what 值为 %d 的 send 信息的发送", DELAY_MESSAGE));
// 取消队列中的 what 值为 200 的 send 信息的发送
_handler.removeMessages(DELAY_MESSAGE);
}
});
}
// 自定义 Handler
class MyHandler extends Handler {
@Override
public void handleMessage(Message msg) {
// 本例的 Handler 是在 UI 线程上实例化的,所以这里的 handleMessage 也是在 UI 线程上执行的
_textView1.append(String.format("收到通过 handler 的 send 发送的信息,what:%d, arg1:%d, arg2:%d, obj:%s\n", msg.what, msg.arg1, msg.arg2, msg.obj));
}
}
// 自定义 Thread
class MyThread extends Thread {
@Override
public void run() {
try {
writeMessage("耗时任务开始执行");
Thread.sleep(3 * 1000);
writeMessage("耗时任务执行完毕");
} catch (InterruptedException e) {
}
// 用 handler 的 obtainMessage() 来构造 Message 对象,而不是 new 一个。因为 obtainMessage() 会从 Message 池中拿一个不用的过来,这样会省去创建对象的开销
Message msgNormal = _handler.obtainMessage();
msgNormal.what = NORMAL_MESSAGE; // 信息类型(用于在 handleMessage 中区分不同类型的信息)
msgNormal.arg1 = 1; // 自定义整型参数
msgNormal.arg2 = 2; // 自定义整型参数
msgNormal.obj = "信息 A"; // 具体的信息对象
writeMessage(String.format("send 一个信息,what:%d, obj:%s", msgNormal.what, msgNormal.obj));
// send 信息到 handler 所属线程
_handler.sendMessage(msgNormal);
Message msgDelay = _handler.obtainMessage();
msgDelay.what = DELAY_MESSAGE;
msgDelay.arg1 = 1;
msgDelay.arg2 = 2;
msgDelay.obj = "信息 B";
writeMessage(String.format("延迟 3000 毫秒 send 一个信息,what:%d, obj:%s", msgDelay.what, msgDelay.obj));
// 延迟 3000 毫秒后 send 信息到 handler 所属线程
_handler.sendMessageDelayed(msgDelay, 3000);
writeMessage("延迟 5000 毫秒 post 一个信息");
// 延迟 5000 毫秒后 post 信息到 handler 所属线程
_handler.postDelayed(new Runnable() {
@Override
public void run() {
// 这里是在 handler 所属线程执行的
_textView1.append("收到通过 handler 的 post 发送的信息\n");
}
}, 5000);
}
}
private void writeMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
_textView2.append(String.format("%s\n", message));
}
});
}
} | UTF-8 | Java | 8,606 | java | HandlerDemo1.java | Java | [] | null | [] | /**
* Handler 的使用(Handler 用于在线程之间传递信息)
* 本例演示后台线程向主线程发送信息
*
*
* Message - 用于封装需要传递的信息(一般通过 handler 的 obtainMessage() 来构造 Message 对象,而不是 new 一个。因为 obtainMessage() 会从 Message 池中拿一个不用的过来,这样会省去创建对象的开销)
* what - 信息类型(以便接收方区分不同类型的信息)
* arg1, arg2 - 自定义整型参数
* obj - 具体的信息对象
* Handler - 与相关的 MessageQueue 和 Looper 形成绑定关系,有两个作用
* 1、将信息发送到 Handler 所属线程的 MessageQueue
* 2、接收 Looper 获取到的信息,以便在 Handler 所属线程进行处理
* MessageQueue - 用于保存 Message 对象的消息队列
* Looper - 线程的 MessageQueue 管理者,循环从 MessageQueue 获取消息,并交给 Handler 处理
*
*
* 通过 Handler 的 send 发送信息到 MessageQueue,以及接收 send 过来的信息
* sendMessage(Message msg) - 通过 send 发送 Message 对象
* sendMessageAtFrontOfQueue(Message msg) - 通过 send 发送 Message 对象,并将其放入 MessageQueue 队列的第一个
* sendMessageDelayed(Message msg, long delayMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送 Message 对象
* sendMessageAtTime(Message msg, long uptimeMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送 Message 对象
* sendEmptyMessageDelayed(int what, long delayMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送一个只有 what 值的空信息
* sendEmptyMessageAtTime(int what, long uptimeMillis) - 通过 send 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送一个只有 what 值的空信息
* 通过重写 handleMessage(Message msg) 来处理 send 过来的信息
*
* 通过 Handler 的 post 发送信息到 MessageQueue,以及接收 post 过来的信息
* post(Runnable r) - 通过 post 发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtFrontOfQueue(Runnable r) - 通过 post 发送消息,并将其放入 MessageQueue 队列的第一个,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postDelayed(Runnable r, long delayMillis) - 通过 post 延迟指定的时间(相对于 SystemClock.elapsedRealtime)后发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtTime(Runnable r, long uptimeMillis) - 通过 post 延迟指定的时间(相对于 SystemClock.uptimeMillis)后发送消息,在指定的 Runnable(这个 Runnable 运行在 handler 所属线程)直接处理
* postAtTime(Runnable r, Object token, long uptimeMillis) - token 用于信息的删除,其他和 postAtTime(Runnable r, long uptimeMillis) 一样
*
* 从 MessageQueue 移除指定的信息
* removeMessages(int what) - 移除指定 what 的 send 信息
* removeMessages(int what, Object object) - 移除指定 what 和 obj 的 send 信息
* removeCallbacks(Runnable r) - 移除 post 的指定 Runnable 的回调
* removeCallbacks(Runnable r, Object token) - 移除 post 的指定 Runnable 和 token 的回调
* removeCallbacksAndMessages(Object token) - 移除 post 的指定 token 的信息和回调
*
*
* 注:
* 1、主线程已经启动 Looper 了,不用再 Looper.prepare()/Looper.loop() 了
* 2、新开线程需要自己写 Looper.prepare()/Looper.loop()/myLooper.quit()
*/
package com.webabcd.androiddemo.async;
import android.os.Message;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.webabcd.androiddemo.R;
public class HandlerDemo1 extends AppCompatActivity {
private TextView _textView1;
private TextView _textView2;
private Button _button1;
private Button _button2;
private Handler _handler;
private final int NORMAL_MESSAGE = 100;
private final int DELAY_MESSAGE = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_async_handlerdemo1);
_textView1 = (TextView) findViewById(R.id.textView1);
_textView2 = (TextView) findViewById(R.id.textView2);
_button1 = (Button) findViewById(R.id.button1);
_button2 = (Button) findViewById(R.id.button2);
sample();
}
private void sample() {
// 在 UI 线程实例化 Handler(默认与 Looper.myLooper() 形成绑定关系,也可以与指定的 Looper 形成绑定关系)
_handler = new MyHandler();
// _handler = new MyHandler(looper);
_button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// 启动一个后台线程
Thread myThread = new MyThread();
myThread.setName("myThread");
myThread.setDaemon(true);
myThread.start();
_textView1.setText("后台线程开始执行\n");
}
});
_button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
writeMessage(String.format("取消队列中的 what 值为 %d 的 send 信息的发送", DELAY_MESSAGE));
// 取消队列中的 what 值为 200 的 send 信息的发送
_handler.removeMessages(DELAY_MESSAGE);
}
});
}
// 自定义 Handler
class MyHandler extends Handler {
@Override
public void handleMessage(Message msg) {
// 本例的 Handler 是在 UI 线程上实例化的,所以这里的 handleMessage 也是在 UI 线程上执行的
_textView1.append(String.format("收到通过 handler 的 send 发送的信息,what:%d, arg1:%d, arg2:%d, obj:%s\n", msg.what, msg.arg1, msg.arg2, msg.obj));
}
}
// 自定义 Thread
class MyThread extends Thread {
@Override
public void run() {
try {
writeMessage("耗时任务开始执行");
Thread.sleep(3 * 1000);
writeMessage("耗时任务执行完毕");
} catch (InterruptedException e) {
}
// 用 handler 的 obtainMessage() 来构造 Message 对象,而不是 new 一个。因为 obtainMessage() 会从 Message 池中拿一个不用的过来,这样会省去创建对象的开销
Message msgNormal = _handler.obtainMessage();
msgNormal.what = NORMAL_MESSAGE; // 信息类型(用于在 handleMessage 中区分不同类型的信息)
msgNormal.arg1 = 1; // 自定义整型参数
msgNormal.arg2 = 2; // 自定义整型参数
msgNormal.obj = "信息 A"; // 具体的信息对象
writeMessage(String.format("send 一个信息,what:%d, obj:%s", msgNormal.what, msgNormal.obj));
// send 信息到 handler 所属线程
_handler.sendMessage(msgNormal);
Message msgDelay = _handler.obtainMessage();
msgDelay.what = DELAY_MESSAGE;
msgDelay.arg1 = 1;
msgDelay.arg2 = 2;
msgDelay.obj = "信息 B";
writeMessage(String.format("延迟 3000 毫秒 send 一个信息,what:%d, obj:%s", msgDelay.what, msgDelay.obj));
// 延迟 3000 毫秒后 send 信息到 handler 所属线程
_handler.sendMessageDelayed(msgDelay, 3000);
writeMessage("延迟 5000 毫秒 post 一个信息");
// 延迟 5000 毫秒后 post 信息到 handler 所属线程
_handler.postDelayed(new Runnable() {
@Override
public void run() {
// 这里是在 handler 所属线程执行的
_textView1.append("收到通过 handler 的 post 发送的信息\n");
}
}, 5000);
}
}
private void writeMessage(final String message) {
runOnUiThread(new Runnable() {
@Override
public void run() {
_textView2.append(String.format("%s\n", message));
}
});
}
} | 8,606 | 0.642334 | 0.6309 | 172 | 38.668606 | 34.521656 | 152 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 11 |
943eb622e6c3964ca317e9809bca1532c5cd1d8f | 9,440,338,164,069 | b1152e18d8b7efc37c243cce6f7166b6a0e90e82 | /src/com/example/mytestdemo/txz/TXZBasic.java | 5e01d81f1cf24fe8dcb0139aeeac31318204de12 | [] | no_license | ChandlerZeng/mytestdemo | https://github.com/ChandlerZeng/mytestdemo | faa8ac17949ae2bf1b1e325c3799634401521d05 | 88903fd88566c3e992133370c7672bf53a753e5d | refs/heads/master | 2021-08-28T02:15:14.887000 | 2017-04-27T08:51:54 | 2017-04-27T08:51:54 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.mytestdemo.txz;
public class TXZBasic
{
// "请说第几个选择或说取消"
public final static int ACTION_TYPE_ITEM_CANCEL = 0;
public final static int ACTION_TYPE_ITEM_1= 1;
public final static int ACTION_TYPE_ITEM_2 = 2;
public final static int ACTION_TYPE_ITEM_3 = 3;
public final static int ACTION_TYPE_ITEM_4 = 4;
public final static int ACTION_TYPE_ITEM_5 = 5;
public final static int ACTION_TYPE_ITEM_6 = 6;
// 同行者-地图操作
public final static int ACTION_TYPE_REALTIMETRAFFIC_OPEN = 20;// 打开/显示/开启实时路况
public final static int ACTION_TYPE_REALTIMETRAFFIC_CLOSE = 21;// 关闭/退出/取消实时路况
public final static int ACTION_TYPE_CHANGEROUTETYPE_FAST = 22;// 切换成高速路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_SHORT = 23;// 切换成最短路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_ECONOMIC = 24;// 切换成经济路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_OPTIMAL = 25;// 切换成推荐路线
public final static int ACTION_TYPE_VIEWADDRESSBOOK_OPEN = 26;// 查看地址薄/打开我的地址/地址薄/选择地址/查看保存的地址
public final static int ACTION_TYPE_VIEWADDRESSBOOK_CLOSE = 27;// 关闭地址簿
public final static int ACTION_TYPE_HISTORYRECORD_OPEN = 28;// 历史记录/打开历史记录/查看历史记录
public final static int ACTION_TYPE_HISTORYRECORD_CLOSE = 29;// 关闭历史记录
public final static int ACTION_TYPE_USUALLYPLACE_OPEN = 30;// 打开常用点
public final static int ACTION_TYPE_USUALLYPLACE_CLOSE = 31;// 关闭常用点
public final static int ACTION_TYPE_GO_HOME = 32;// 回家/我要回家
public final static int ACTION_TYPE_GO_TO_COMPANY = 33;// 单位/去单位/公司/去公司
public final static int ACTION_TYPE_VIEWROUTE = 34;// 概览路线/查看和预览路线/查看经过道路/查看路线/查看全程/经过道路
public final static int ACTION_TYPE_BACK_TO_MAP = 35;// 回地图/返回地图
public final static int ACTION_TYPE_ROUTEPLAN_OPEN = 36; // 路线规划/路径规划
public final static int ACTION_TYPE_ROUTEPLAN_CLOSE = 37;// 关闭(退出)路线规划/路径规划
public final static int ACTION_TYPE_EAGELVIEW_OPEN = 38;// 打开鹰眼模式
public final static int ACTION_TYPE_DOUBLESCREEN_OPEN = 40;// 打开双屏(模式)
public final static int ACTION_TYPE_SINGLESCREEN = 42; // 单屏模式
public final static int ACTION_TYPE_DETAIL_OPEN = 43; // 查看地址详情/查看详情/打开详情
public final static int ACTION_TYPE_DETAIL_CLOSE = 44;// 关闭详情栏
public final static int ACTION_TYPE_CHANGEVIEWMODE = 45;// 切换地图模式/切换显示方式/切换视图
public final static int ACTION_TYPE_SCALEMAP_ZOOMOUT = 46; // 缩小/地图缩小/缩小地图
public final static int ACTION_TYPE_SCALEMAP_ZOOMIN = 47; // 放大/地图放大/放大地图
public final static int ACTION_TYPE_BROADCASTAGAIN = 48; // 再说一次/重新播报/我没听清楚
public final static int ACTION_TYPE_NEXTSERVICE = 49; // 距离下一服务区多远/服务区还有多远/前方服务区距离
public final static int ACTION_TYPE_CHANGEPAGE_PREVIOUS = 50; // 上一页/前一页
public final static int ACTION_TYPE_CHANGEPAGE_NEXT = 51; // 下一页/后一页
}
| GB18030 | Java | 3,546 | java | TXZBasic.java | Java | [] | null | [] | package com.example.mytestdemo.txz;
public class TXZBasic
{
// "请说第几个选择或说取消"
public final static int ACTION_TYPE_ITEM_CANCEL = 0;
public final static int ACTION_TYPE_ITEM_1= 1;
public final static int ACTION_TYPE_ITEM_2 = 2;
public final static int ACTION_TYPE_ITEM_3 = 3;
public final static int ACTION_TYPE_ITEM_4 = 4;
public final static int ACTION_TYPE_ITEM_5 = 5;
public final static int ACTION_TYPE_ITEM_6 = 6;
// 同行者-地图操作
public final static int ACTION_TYPE_REALTIMETRAFFIC_OPEN = 20;// 打开/显示/开启实时路况
public final static int ACTION_TYPE_REALTIMETRAFFIC_CLOSE = 21;// 关闭/退出/取消实时路况
public final static int ACTION_TYPE_CHANGEROUTETYPE_FAST = 22;// 切换成高速路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_SHORT = 23;// 切换成最短路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_ECONOMIC = 24;// 切换成经济路线
public final static int ACTION_TYPE_CHANGEROUTETYPE_OPTIMAL = 25;// 切换成推荐路线
public final static int ACTION_TYPE_VIEWADDRESSBOOK_OPEN = 26;// 查看地址薄/打开我的地址/地址薄/选择地址/查看保存的地址
public final static int ACTION_TYPE_VIEWADDRESSBOOK_CLOSE = 27;// 关闭地址簿
public final static int ACTION_TYPE_HISTORYRECORD_OPEN = 28;// 历史记录/打开历史记录/查看历史记录
public final static int ACTION_TYPE_HISTORYRECORD_CLOSE = 29;// 关闭历史记录
public final static int ACTION_TYPE_USUALLYPLACE_OPEN = 30;// 打开常用点
public final static int ACTION_TYPE_USUALLYPLACE_CLOSE = 31;// 关闭常用点
public final static int ACTION_TYPE_GO_HOME = 32;// 回家/我要回家
public final static int ACTION_TYPE_GO_TO_COMPANY = 33;// 单位/去单位/公司/去公司
public final static int ACTION_TYPE_VIEWROUTE = 34;// 概览路线/查看和预览路线/查看经过道路/查看路线/查看全程/经过道路
public final static int ACTION_TYPE_BACK_TO_MAP = 35;// 回地图/返回地图
public final static int ACTION_TYPE_ROUTEPLAN_OPEN = 36; // 路线规划/路径规划
public final static int ACTION_TYPE_ROUTEPLAN_CLOSE = 37;// 关闭(退出)路线规划/路径规划
public final static int ACTION_TYPE_EAGELVIEW_OPEN = 38;// 打开鹰眼模式
public final static int ACTION_TYPE_DOUBLESCREEN_OPEN = 40;// 打开双屏(模式)
public final static int ACTION_TYPE_SINGLESCREEN = 42; // 单屏模式
public final static int ACTION_TYPE_DETAIL_OPEN = 43; // 查看地址详情/查看详情/打开详情
public final static int ACTION_TYPE_DETAIL_CLOSE = 44;// 关闭详情栏
public final static int ACTION_TYPE_CHANGEVIEWMODE = 45;// 切换地图模式/切换显示方式/切换视图
public final static int ACTION_TYPE_SCALEMAP_ZOOMOUT = 46; // 缩小/地图缩小/缩小地图
public final static int ACTION_TYPE_SCALEMAP_ZOOMIN = 47; // 放大/地图放大/放大地图
public final static int ACTION_TYPE_BROADCASTAGAIN = 48; // 再说一次/重新播报/我没听清楚
public final static int ACTION_TYPE_NEXTSERVICE = 49; // 距离下一服务区多远/服务区还有多远/前方服务区距离
public final static int ACTION_TYPE_CHANGEPAGE_PREVIOUS = 50; // 上一页/前一页
public final static int ACTION_TYPE_CHANGEPAGE_NEXT = 51; // 下一页/后一页
}
| 3,546 | 0.702135 | 0.676997 | 60 | 47.400002 | 33.462017 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.633333 | false | false | 11 |
601fb4986db669fb91e81ed23ef1396fa12f9647 | 30,949,534,369,878 | e1c3efa16f9ed088f71784469d7d4eae4a87e80d | /src/corp/ventas/domain/Cliente.java | 3128de7ce9b9e9c5bff86b8f661d282ca9669423 | [] | no_license | cdiazcunc97/apiventascorp | https://github.com/cdiazcunc97/apiventascorp | 2ab3dfc3f38fa3c86b895aad961a475a53e70127 | dfb079867c11dcf6058b03f6cdbc30063e1ea065 | refs/heads/master | 2022-09-19T06:43:28.269000 | 2019-07-24T02:40:20 | 2019-07-24T02:40:20 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package corp.ventas.domain;
import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlTransient;
import java.util.List;
/**
* The persistent class for the cliente database table.
*
*/
@Entity
@NamedQueries({
@NamedQuery(name="Cliente.findAllByEstado", query="SELECT c FROM Cliente c where c.estadoCliente=:estadoCliente"),
@NamedQuery(name="Cliente.findAll", query="SELECT c FROM Cliente c"),
@NamedQuery(name="Cliente.findByNombre", query="SELECT c FROM Cliente c where c.nombres LIKE :cBusqueda")
})
public class Cliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int idCliente;
private String apellidoMaterno;
private String apellidoPaterno;
private String dni;
private String estadoCliente;
private String nombres;
//bi-directional many-to-one association to Venta
@OneToMany(mappedBy="cliente")
private List<Venta> ventas;
public Cliente() {
}
public int getIdCliente() {
return this.idCliente;
}
public void setIdCliente(int idCliente) {
this.idCliente = idCliente;
}
public String getApellidoMaterno() {
return this.apellidoMaterno;
}
public void setApellidoMaterno(String apellidoMaterno) {
this.apellidoMaterno = apellidoMaterno;
}
public String getApellidoPaterno() {
return this.apellidoPaterno;
}
public void setApellidoPaterno(String apellidoPaterno) {
this.apellidoPaterno = apellidoPaterno;
}
public String getDni() {
return this.dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getEstadoCliente() {
return this.estadoCliente;
}
public void setEstadoCliente(String estadoCliente) {
this.estadoCliente = estadoCliente;
}
public String getNombres() {
return this.nombres;
}
public void setNombres(String nombres) {
this.nombres = nombres;
}
@XmlTransient
public List<Venta> getVentas() {
return this.ventas;
}
public void setVentas(List<Venta> ventas) {
this.ventas = ventas;
}
public Venta addVenta(Venta venta) {
getVentas().add(venta);
venta.setCliente(this);
return venta;
}
public Venta removeVenta(Venta venta) {
getVentas().remove(venta);
venta.setCliente(null);
return venta;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + idCliente;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Cliente))
return false;
Cliente other = (Cliente) obj;
if (idCliente != other.idCliente)
return false;
return true;
}
} | UTF-8 | Java | 2,698 | java | Cliente.java | Java | [] | null | [] | package corp.ventas.domain;
import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlTransient;
import java.util.List;
/**
* The persistent class for the cliente database table.
*
*/
@Entity
@NamedQueries({
@NamedQuery(name="Cliente.findAllByEstado", query="SELECT c FROM Cliente c where c.estadoCliente=:estadoCliente"),
@NamedQuery(name="Cliente.findAll", query="SELECT c FROM Cliente c"),
@NamedQuery(name="Cliente.findByNombre", query="SELECT c FROM Cliente c where c.nombres LIKE :cBusqueda")
})
public class Cliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int idCliente;
private String apellidoMaterno;
private String apellidoPaterno;
private String dni;
private String estadoCliente;
private String nombres;
//bi-directional many-to-one association to Venta
@OneToMany(mappedBy="cliente")
private List<Venta> ventas;
public Cliente() {
}
public int getIdCliente() {
return this.idCliente;
}
public void setIdCliente(int idCliente) {
this.idCliente = idCliente;
}
public String getApellidoMaterno() {
return this.apellidoMaterno;
}
public void setApellidoMaterno(String apellidoMaterno) {
this.apellidoMaterno = apellidoMaterno;
}
public String getApellidoPaterno() {
return this.apellidoPaterno;
}
public void setApellidoPaterno(String apellidoPaterno) {
this.apellidoPaterno = apellidoPaterno;
}
public String getDni() {
return this.dni;
}
public void setDni(String dni) {
this.dni = dni;
}
public String getEstadoCliente() {
return this.estadoCliente;
}
public void setEstadoCliente(String estadoCliente) {
this.estadoCliente = estadoCliente;
}
public String getNombres() {
return this.nombres;
}
public void setNombres(String nombres) {
this.nombres = nombres;
}
@XmlTransient
public List<Venta> getVentas() {
return this.ventas;
}
public void setVentas(List<Venta> ventas) {
this.ventas = ventas;
}
public Venta addVenta(Venta venta) {
getVentas().add(venta);
venta.setCliente(this);
return venta;
}
public Venta removeVenta(Venta venta) {
getVentas().remove(venta);
venta.setCliente(null);
return venta;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + idCliente;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Cliente))
return false;
Cliente other = (Cliente) obj;
if (idCliente != other.idCliente)
return false;
return true;
}
} | 2,698 | 0.724981 | 0.723499 | 141 | 18.141844 | 20.282957 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.283688 | false | false | 11 |
d6aaca7b3cce6cf5fc2e4c43924caba8ec5723b0 | 33,706,903,395,389 | cc65e10feea55bfa97cade23176cd6e574d3bbea | /commons/commons-base/src/main/java/com/imall/commons/base/global/ResGlobal.java | e9d4a9b8e9ae27210dc880b48444783e38ca21f8 | [] | no_license | weishihuai/imallCloudc | https://github.com/weishihuai/imallCloudc | ef5a0d7e4866ad7e63251dff512afede7246bd4f | f3163208eaf539aa63dc9e042d2ff6c7403aa405 | refs/heads/master | 2021-08-20T05:42:23.717000 | 2017-11-28T09:10:36 | 2017-11-28T09:10:36 | 112,305,704 | 2 | 4 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.imall.commons.base.global;
/**
* 异常编码
*/
public class ResGlobal {
public static final String RESOURCE_DELETE_ERROR = "RESOURCE_DELETE_ERROR";//删除资源错误
public static final String RESOURCE_RELATE_DELETE_ERROR = "RESOURCE_RELATE_DELETE_ERROR";//资源被菜单关联,不允许删除
public static final String SWITCH_JOB_ID_NULL_ERROR = "SWITCH_JOB_ID_NULL_ERROR";//切换岗位,岗位ID为空错误
public static final String SWITCH_JOB_IDENTITY_AUTH_ERROR = "SWITCH_JOB_IDENTITY_AUTH_ERROR";//切换岗位,没有授予您身份xxx,不能切换
public static final String OPERATION_NO_PERMISSION = "OPERATION_NO_PERMISSION";//当前操作,您没有权限!!!
public static final String CHECK_IS_TRUST_APP_FAILED = "CHECK_IS_TRUST_APP_FAILED";//不是信任的app,验证失败!!!
public static final String DICT_DELETE_RELATE_ERROR = "APP_DICT_ERROR";//删除字典错误
public static final String FILE_CATEGORY_DELETE_ERROR = "FILE_CATEGORY_DELETE_ERROR";//存在子节点,删除失败
public static final String APP_RELATE_DELETE_ERROR = "APP_RELATE_DELETE_ERROR";//应用被资源关联,不允许删除
public static final String JOB_RELATE_DELETE_ERROR = "JOB_RELATE_DELETE_ERROR";//岗位被资源关联,不允许删除
public static final String MENU_DELETE_ERROR = "MENU_DELETE_ERROR";//删除菜单错误
public static final String ORG_RELATE_USER_DELETE_ERROR = "ORG_RELATE_USER_DELETE_ERROR";//删除组织错误
public static final String ORG_RELATE_SERVICE_DELETE_ERROR = "ORG_RELATE_SERVICE_DELETE_ERROR";//删除组织错误
public static final String USER_ORG_JOR_RELATE_DELETE_ERROR = "USER_ORG_JOR_RELATE_DELETE_ERROR";//删除用户错误
public static final String WEB_UPLOAD_FILE_ERROR = "WEB_UPLOAD_FILE_ERROR";//上传文件错误
public static final String ERRORS_IDSF_ALL = "ERRORS_IDSF_ALL";
public static final String USER_NAME_IS_EXIST = "USER_NAME_IS_EXIST";//用户名称已被注册
public static final String USER_MAIN_JOB_NOT_EXIST = "USER_MAIN_JOB_NOT_EXIST";//此用户没有设置主岗位
public static final String DEFAULT_ERROR_OBJECT_NOT_EXIST = "DEFAULT_ERROR_OBJECT_NOT_EXIST";//对象不存在,公用错误
public static final String COMMON_OBJECT_NO_FOUND = "COMMON_OBJECT_NO_FOUND"; //对象找不到公共异常
public static final String PASSWORD_ERROR = "PASSWORD_ERROR"; //密码错误
public static final String COMMON_ERROR = "COMMON_ERROR"; //通用错误
}
| UTF-8 | Java | 2,567 | java | ResGlobal.java | Java | [] | null | [] | package com.imall.commons.base.global;
/**
* 异常编码
*/
public class ResGlobal {
public static final String RESOURCE_DELETE_ERROR = "RESOURCE_DELETE_ERROR";//删除资源错误
public static final String RESOURCE_RELATE_DELETE_ERROR = "RESOURCE_RELATE_DELETE_ERROR";//资源被菜单关联,不允许删除
public static final String SWITCH_JOB_ID_NULL_ERROR = "SWITCH_JOB_ID_NULL_ERROR";//切换岗位,岗位ID为空错误
public static final String SWITCH_JOB_IDENTITY_AUTH_ERROR = "SWITCH_JOB_IDENTITY_AUTH_ERROR";//切换岗位,没有授予您身份xxx,不能切换
public static final String OPERATION_NO_PERMISSION = "OPERATION_NO_PERMISSION";//当前操作,您没有权限!!!
public static final String CHECK_IS_TRUST_APP_FAILED = "CHECK_IS_TRUST_APP_FAILED";//不是信任的app,验证失败!!!
public static final String DICT_DELETE_RELATE_ERROR = "APP_DICT_ERROR";//删除字典错误
public static final String FILE_CATEGORY_DELETE_ERROR = "FILE_CATEGORY_DELETE_ERROR";//存在子节点,删除失败
public static final String APP_RELATE_DELETE_ERROR = "APP_RELATE_DELETE_ERROR";//应用被资源关联,不允许删除
public static final String JOB_RELATE_DELETE_ERROR = "JOB_RELATE_DELETE_ERROR";//岗位被资源关联,不允许删除
public static final String MENU_DELETE_ERROR = "MENU_DELETE_ERROR";//删除菜单错误
public static final String ORG_RELATE_USER_DELETE_ERROR = "ORG_RELATE_USER_DELETE_ERROR";//删除组织错误
public static final String ORG_RELATE_SERVICE_DELETE_ERROR = "ORG_RELATE_SERVICE_DELETE_ERROR";//删除组织错误
public static final String USER_ORG_JOR_RELATE_DELETE_ERROR = "USER_ORG_JOR_RELATE_DELETE_ERROR";//删除用户错误
public static final String WEB_UPLOAD_FILE_ERROR = "WEB_UPLOAD_FILE_ERROR";//上传文件错误
public static final String ERRORS_IDSF_ALL = "ERRORS_IDSF_ALL";
public static final String USER_NAME_IS_EXIST = "USER_NAME_IS_EXIST";//用户名称已被注册
public static final String USER_MAIN_JOB_NOT_EXIST = "USER_MAIN_JOB_NOT_EXIST";//此用户没有设置主岗位
public static final String DEFAULT_ERROR_OBJECT_NOT_EXIST = "DEFAULT_ERROR_OBJECT_NOT_EXIST";//对象不存在,公用错误
public static final String COMMON_OBJECT_NO_FOUND = "COMMON_OBJECT_NO_FOUND"; //对象找不到公共异常
public static final String PASSWORD_ERROR = "PASSWORD_ERROR"; //密码错误
public static final String COMMON_ERROR = "COMMON_ERROR"; //通用错误
}
| 2,567 | 0.743919 | 0.743919 | 30 | 71.633331 | 39.789013 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.766667 | false | false | 11 |
204f3a9c3a40b820ef22f37845685e46ad013027 | 26,938,034,908,980 | a7cca522c845178a1a289020d17f7e0b0aff1d62 | /src/client/controller/EcranFinPartieListener.java | 44cd363887c1c11a9bca0a487cf2b94368c360e9 | [] | no_license | eddasser/UrbanJungle | https://github.com/eddasser/UrbanJungle | 3506559fed21abd8d31387b4263b6ea89f0a1c22 | ae442a371590a876ce248aab1fed18a734974d92 | refs/heads/master | 2021-01-25T10:39:02.595000 | 2013-05-04T21:27:53 | 2013-05-04T21:27:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package client.controller;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import client.JeuPanel;
import client.view.jeu.EcranFinPartie;
public class EcranFinPartieListener implements ActionListener{
private EcranFinPartie ecranfinPartie;
public EcranFinPartieListener(EcranFinPartie ecranfinPartie_){
ecranfinPartie = ecranfinPartie_;
}
@Override
public void actionPerformed(ActionEvent event){
if (event.getSource() == ecranfinPartie.getButtonQuitter()){
JeuPanel.getEcranJeu().cacherPlateau();
if (ecranfinPartie.getJeu().getClient().getPartie().isSolo()){
JeuPanel.getEcranJeu().cacherPlateau();
ecranfinPartie.getJeu().chargerEcranChoixTypePartie();
}else{
JeuPanel.getEcranJeu().cacherPlateau();
ecranfinPartie.getJeu().chargerEcranChoixTypePartie();
// ecranfinPartie.getJeu().chargerEcranMenuMultijoueur();
}
}
}
}
| UTF-8 | Java | 917 | java | EcranFinPartieListener.java | Java | [] | null | [] | package client.controller;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import client.JeuPanel;
import client.view.jeu.EcranFinPartie;
public class EcranFinPartieListener implements ActionListener{
private EcranFinPartie ecranfinPartie;
public EcranFinPartieListener(EcranFinPartie ecranfinPartie_){
ecranfinPartie = ecranfinPartie_;
}
@Override
public void actionPerformed(ActionEvent event){
if (event.getSource() == ecranfinPartie.getButtonQuitter()){
JeuPanel.getEcranJeu().cacherPlateau();
if (ecranfinPartie.getJeu().getClient().getPartie().isSolo()){
JeuPanel.getEcranJeu().cacherPlateau();
ecranfinPartie.getJeu().chargerEcranChoixTypePartie();
}else{
JeuPanel.getEcranJeu().cacherPlateau();
ecranfinPartie.getJeu().chargerEcranChoixTypePartie();
// ecranfinPartie.getJeu().chargerEcranMenuMultijoueur();
}
}
}
}
| 917 | 0.757906 | 0.757906 | 35 | 25.200001 | 23.928226 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.028571 | false | false | 11 |
1111aacd9da0650e0988a9e522a57d3a54a80346 | 30,786,325,588,486 | 9c80b5488734cb5d59d400d6eb19d94b1fbdb7b7 | /src/lesson3/Num9_1.java | 086bd758b75ff52c663dde75edb7feddad75c5ee | [] | no_license | SemichGOMEL/homework | https://github.com/SemichGOMEL/homework | 37ef9de5a7ae008364ea52fc470d57458fea1027 | ab16a4593b89427eaf4341eade8456169db41fc8 | refs/heads/main | 2023-07-24T05:49:07.357000 | 2021-08-31T13:58:39 | 2021-08-31T13:58:39 | 390,796,864 | 0 | 0 | null | false | 2021-08-04T08:31:53 | 2021-07-29T17:06:14 | 2021-08-04T08:30:30 | 2021-08-04T08:31:53 | 18 | 0 | 0 | 1 | Java | false | false | package lesson3;
import java.util.Random;
import java.util.Scanner;
public class Num9_1 {
public static void main(String[] args) {
Random r = new Random();
Scanner sc = new Scanner(System.in);
int arr[], j, first = 0, two = 0;
while (true) {
j = sc.nextInt();
if ((j % 2 == 0) && j > 0) {
break;
} else {
System.out.println("Введите другое значение ");
}
}
arr = new int[j];
for(int i = 0; i<j; i++){
arr[i] = r.nextInt(16);
System.out.print(arr[i]+" ");
if(i<(j/2)){
first = first+arr[i];
} else{
two = two + arr[i];
}
}
System.out.println();
if(first>two){
System.out.println("Первая больше");
} else if(two>first){
System.out.println("Вторая больше");
} else{
System.out.println("Половины равны");
}
}
}
| UTF-8 | Java | 1,087 | java | Num9_1.java | Java | [] | null | [] | package lesson3;
import java.util.Random;
import java.util.Scanner;
public class Num9_1 {
public static void main(String[] args) {
Random r = new Random();
Scanner sc = new Scanner(System.in);
int arr[], j, first = 0, two = 0;
while (true) {
j = sc.nextInt();
if ((j % 2 == 0) && j > 0) {
break;
} else {
System.out.println("Введите другое значение ");
}
}
arr = new int[j];
for(int i = 0; i<j; i++){
arr[i] = r.nextInt(16);
System.out.print(arr[i]+" ");
if(i<(j/2)){
first = first+arr[i];
} else{
two = two + arr[i];
}
}
System.out.println();
if(first>two){
System.out.println("Первая больше");
} else if(two>first){
System.out.println("Вторая больше");
} else{
System.out.println("Половины равны");
}
}
}
| 1,087 | 0.435374 | 0.423712 | 38 | 26.078947 | 15.014697 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.605263 | false | false | 11 |
3c568499ba05a9b428e36fb225173b035c0efc34 | 33,217,277,067,727 | 2e3b1ae3842bb3a4d80d5ef5d4006bbcd516ee7c | /nab-telemetry/src/main/java/ru/hh/nab/telemetry/TelemetryPropagator.java | 67fa9f76458650b39aa48b29e854e7dbc2209471 | [] | no_license | hhru/nuts-and-bolts | https://github.com/hhru/nuts-and-bolts | 93ae7305a15eb0ad9c0f7c849367d2bb67a78bfa | a065730ddb648f71568754f57cf2c54b13cebde2 | refs/heads/master | 2023-08-25T20:22:47.553000 | 2023-08-15T09:41:53 | 2023-08-15T09:41:53 | 864,122 | 28 | 20 | null | false | 2023-09-13T16:06:53 | 2010-08-26T14:05:41 | 2023-09-04T23:00:59 | 2023-09-13T16:06:52 | 3,959 | 22 | 16 | 10 | Java | false | false | package ru.hh.nab.telemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Map;
import ru.hh.jclient.common.Request;
public class TelemetryPropagator {
private final TextMapPropagator textMapPropagator;
private static final TextMapGetter<Map<String, String>> GETTER = createGetter();
private static final TextMapSetter<Request> SETTER = createSetter();
public TelemetryPropagator(OpenTelemetry openTelemetry) {
this.textMapPropagator = openTelemetry.getPropagators().getTextMapPropagator();
}
public Context getTelemetryContext(Context context, Map<String, String> requestHeadersMap) {
return textMapPropagator.extract(context, requestHeadersMap, GETTER);
}
public void propagate(Request request) {
textMapPropagator.inject(Context.current(), request, SETTER);
}
private static TextMapSetter<Request> createSetter() {
return (carrier, key, value) -> carrier.getHeaders().set(key, value);
}
private static TextMapGetter<Map<String, String>> createGetter() {
return new TextMapGetter<>() {
@Override
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}
@Override
public String get(Map<String, String> carrier, String key) {
return carrier.get(key);
}
};
}
public static StatusCode getStatus(int httpStatusCode, boolean isServer) {
if (httpStatusCode < 100) {
return StatusCode.ERROR;
} else if (httpStatusCode <= 399) {
return StatusCode.UNSET;
} else if (httpStatusCode <= 499 && isServer) {
return StatusCode.UNSET;
}
return StatusCode.ERROR;
}
}
| UTF-8 | Java | 1,918 | java | TelemetryPropagator.java | Java | [] | null | [] | package ru.hh.nab.telemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Map;
import ru.hh.jclient.common.Request;
public class TelemetryPropagator {
private final TextMapPropagator textMapPropagator;
private static final TextMapGetter<Map<String, String>> GETTER = createGetter();
private static final TextMapSetter<Request> SETTER = createSetter();
public TelemetryPropagator(OpenTelemetry openTelemetry) {
this.textMapPropagator = openTelemetry.getPropagators().getTextMapPropagator();
}
public Context getTelemetryContext(Context context, Map<String, String> requestHeadersMap) {
return textMapPropagator.extract(context, requestHeadersMap, GETTER);
}
public void propagate(Request request) {
textMapPropagator.inject(Context.current(), request, SETTER);
}
private static TextMapSetter<Request> createSetter() {
return (carrier, key, value) -> carrier.getHeaders().set(key, value);
}
private static TextMapGetter<Map<String, String>> createGetter() {
return new TextMapGetter<>() {
@Override
public Iterable<String> keys(Map<String, String> carrier) {
return carrier.keySet();
}
@Override
public String get(Map<String, String> carrier, String key) {
return carrier.get(key);
}
};
}
public static StatusCode getStatus(int httpStatusCode, boolean isServer) {
if (httpStatusCode < 100) {
return StatusCode.ERROR;
} else if (httpStatusCode <= 399) {
return StatusCode.UNSET;
} else if (httpStatusCode <= 499 && isServer) {
return StatusCode.UNSET;
}
return StatusCode.ERROR;
}
}
| 1,918 | 0.736184 | 0.731491 | 59 | 31.508474 | 27.860653 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.644068 | false | false | 11 |
c0b0d617a21e3f71736ad69aa3ef33b3793189a0 | 6,889,127,570,136 | 26806d2e2693efe51bfb89d84a95ca503012582b | /src/com/neusoft/cargo/entity/Resource.java | 4b89924018e6705a39f3b34bd4cff6e3c429ff5d | [] | no_license | drduan/CarGoDistribution | https://github.com/drduan/CarGoDistribution | a1fa320ffd6749eb59b1799bb4d9def212e602f9 | 5cfc081333ee7f81bf9d5eee32e38cb4d711b4ab | refs/heads/master | 2021-01-13T14:07:32.212000 | 2017-06-05T12:17:03 | 2017-06-05T12:17:03 | 76,159,414 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.neusoft.cargo.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
//@Entity
//@Table(name = "sys_resource")
public class Resource implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // 编号
private String name; // 资源名称
@Column(unique = true)
private String identity;// 资源类型
}
| UTF-8 | Java | 494 | java | Resource.java | Java | [] | null | [] | package com.neusoft.cargo.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
//@Entity
//@Table(name = "sys_resource")
public class Resource implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // 编号
private String name; // 资源名称
@Column(unique = true)
private String identity;// 资源类型
}
| 494 | 0.772152 | 0.772152 | 22 | 20.545454 | 17.174843 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.681818 | false | false | 11 |
508416431fda89af6b8e46037bbcfa66b7be221b | 31,817,117,762,772 | 33118e6b35e31fa4721762475435be627c69903d | /app/src/main/java/com/foi/air1712/instad/notifikacije/ModulNotifikacija.java | 8891a311d39c48bb13f98c21f7c131012ce3d34e | [] | no_license | nsinjori/instAd | https://github.com/nsinjori/instAd | cb545e805a3b367675e4b08a548a7fcce816e691 | b46bdaf83b26eb8b202567a46b71d10ce5db797c | refs/heads/master | 2021-09-21T16:39:00.229000 | 2018-08-28T20:02:10 | 2018-08-28T20:02:10 | 106,323,698 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.foi.air1712.instad.notifikacije;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
public class ModulNotifikacija implements IModulNotifikacija
{
@Override
public void start(Context context)
{
context.startService(new Intent(context,NoviDogadajServis.class));
}
@Override
public void stop(Context context)
{
context.stopService(new Intent(context,NoviDogadajServis.class));
}
@Override
public boolean getIsRunning(Activity activity)
{
ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ((NoviDogadajServis.class).getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
}
| UTF-8 | Java | 980 | java | ModulNotifikacija.java | Java | [] | null | [] | package com.foi.air1712.instad.notifikacije;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
public class ModulNotifikacija implements IModulNotifikacija
{
@Override
public void start(Context context)
{
context.startService(new Intent(context,NoviDogadajServis.class));
}
@Override
public void stop(Context context)
{
context.stopService(new Intent(context,NoviDogadajServis.class));
}
@Override
public boolean getIsRunning(Activity activity)
{
ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ((NoviDogadajServis.class).getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
}
| 980 | 0.70102 | 0.696939 | 35 | 27 | 30.633316 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342857 | false | false | 11 |
dd05efd99483369cebde455526c4859a9d70b016 | 15,977,278,359,041 | 2b3f78cd10903d4d4bba8e5edf2c507ea5d756dc | /Test/eval_units/006_methodCall.java | dc9b7d9837e3b165d43115e155c20546f4559639 | [] | no_license | commentjava/javabien | https://github.com/commentjava/javabien | bc9b2f5bf1143299adf3d1b1e756f6c03814a02c | a25fae3ae9fa04bd40d1d34555cf375b44cb346e | refs/heads/master | 2020-05-04T12:55:46.804000 | 2019-04-29T14:10:00 | 2019-04-29T14:10:00 | 179,140,957 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //: 5
class TestClass {
int returns3() {
int x = 3;
return x + 2;
}
}
class Main {
static void main(String[] args) {
int a = 2;
TestClass t = new TestClass();
a = t.returns3();
Debug.debug(a);
}
}
| UTF-8 | Java | 328 | java | 006_methodCall.java | Java | [] | null | [] | //: 5
class TestClass {
int returns3() {
int x = 3;
return x + 2;
}
}
class Main {
static void main(String[] args) {
int a = 2;
TestClass t = new TestClass();
a = t.returns3();
Debug.debug(a);
}
}
| 328 | 0.365854 | 0.347561 | 18 | 17.222221 | 14.717924 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 11 |
4c413d4b5da9030b392a934cd5f5a1f483d9b7fb | 3,865,470,615,158 | eb9f655206c43c12b497c667ba56a0d358b6bc3a | /platform/platform-tests/testSrc/com/intellij/refactoring/rename/naming/NameSuggesterTest.java | 1776a29741642f5afbf2cb02a3f54a67b546869f | [
"Apache-2.0"
] | permissive | JetBrains/intellij-community | https://github.com/JetBrains/intellij-community | 2ed226e200ecc17c037dcddd4a006de56cd43941 | 05dbd4575d01a213f3f4d69aa4968473f2536142 | refs/heads/master | 2023-09-03T17:06:37.560000 | 2023-09-03T11:51:00 | 2023-09-03T12:12:27 | 2,489,216 | 16,288 | 6,635 | Apache-2.0 | false | 2023-09-12T07:41:58 | 2011-09-30T13:33:05 | 2023-09-12T03:37:30 | 2023-09-12T06:46:46 | 4,523,919 | 15,754 | 4,972 | 237 | null | false | false | /*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.refactoring.rename.naming;
import junit.framework.TestCase;
public class NameSuggesterTest extends TestCase {
public void testChanges1() {
doChangesTest("NameSuggesterTest", "NameUnifierTest", "[<Suggester,Unifier>]");
}
public void testChanges2() {
doChangesTest("CompletionContext", "CompletionResult", "[<Context,Result>]");
}
public void testChanges3() {
doChangesTest("CodeCompletionContext", "CompletionResult", "[<Code,>, <Context,Result>]");
}
public void testChanges4() {
doChangesTest("A", "B", "[<A,B>]");
}
public void testChanges5() {
doChangesTest("PsiManager", "PsiManagerImpl", "[<,Impl>]");
}
public void testChanges6() {
doChangesTest("IBase", "IMain", "[<Base,Main>]");
}
public void testSuggestions1() {
doSuggestionTest("NameSuggesterTest", "NameUnifierTest", "suggester", "unifier");
}
public void testSuggestions2() {
doSuggestionTest("CompletionContext", "CompletionResult", "completionContext", "completionResult");
}
public void testSuggestions3() {
doSuggestionTest("CompletionContext", "CompletionResult", "context", "result");
}
public void testSuggestions4() {
doSuggestionTest("CompletionContext", "CompletionResult", "codeCompletionContext", "codeCompletionResult");
}
public void testSuggestions5() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "codeCompletionContext", "completionResult");
}
public void testSuggestions6() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "context", "result");
}
public void testSuggestions7() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "contextWithAdvances", "resultWithAdvances");
}
public void testSuggestions8() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "_context", "_result");
}
public void testSuggestions9() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "p_context", "p_result");
}
public void testSuggestions10() {
doSuggestionTest("IBase", "IMain", "base", "main");
}
public void testSuggestions11() {
doSuggestionTest("Descriptor", "BasicDescriptor", "descriptor", "basicDescriptor");
}
public void testSuggestions12() {
doSuggestionTest("Provider", "ObjectProvider", "provider", "objectProvider");
}
public void testSuggestions13() {
doSuggestionTest("SimpleModel", "Model", "simpleModel", "model");
}
public void testSuggestions14() {
doSuggestionTest("ConfigItem", "Config", "item", "item");
}
public void testSuggestions15() {
doSuggestionTest("Transaction", "TransactionPolicy", "transaction", "transactionPolicy");
}
public void testSuggestions16() {
doSuggestionTest("Transaction", "TransactionPolicyHandler", "transaction", "transactionPolicyHandler");
}
public void testSuggestions17() {
doSuggestionTest("Transaction", "StrictTransactionPolicyHandler", "transaction", "strictTransactionPolicyHandler");
}
public void testSuggestions18() {
doSuggestionTest("Foo", "FooTask", "fooImpl", "fooTaskImpl");
}
public void testSuggestions19() {
doSuggestionTest("Foo", "FooTask", "implFoo", "implFooTask");
}
public void testSuggestions20() {
doSuggestionTest("Foo", "TaskFoo", "fooImpl", "taskFooImpl");
}
public void testSuggestions21() {
doSuggestionTest("Foo", "TaskFoo", "implFoo", "implTaskFoo");
}
private void doChangesTest(final String oldClassName, final String newClassName, final String changes) {
final NameSuggester suggester = new NameSuggester(oldClassName, newClassName);
assertEquals(
changes,
suggester.getChanges().toString()
);
}
private void doSuggestionTest(final String oldClassName, final String newClassName, final String variableName,
final String expectedSuggestion) {
final NameSuggester suggester = new NameSuggester(oldClassName, newClassName);
assertEquals(expectedSuggestion, suggester.suggestName(variableName));
}
}
| UTF-8 | Java | 4,668 | java | NameSuggesterTest.java | Java | [] | null | [] | /*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.refactoring.rename.naming;
import junit.framework.TestCase;
public class NameSuggesterTest extends TestCase {
public void testChanges1() {
doChangesTest("NameSuggesterTest", "NameUnifierTest", "[<Suggester,Unifier>]");
}
public void testChanges2() {
doChangesTest("CompletionContext", "CompletionResult", "[<Context,Result>]");
}
public void testChanges3() {
doChangesTest("CodeCompletionContext", "CompletionResult", "[<Code,>, <Context,Result>]");
}
public void testChanges4() {
doChangesTest("A", "B", "[<A,B>]");
}
public void testChanges5() {
doChangesTest("PsiManager", "PsiManagerImpl", "[<,Impl>]");
}
public void testChanges6() {
doChangesTest("IBase", "IMain", "[<Base,Main>]");
}
public void testSuggestions1() {
doSuggestionTest("NameSuggesterTest", "NameUnifierTest", "suggester", "unifier");
}
public void testSuggestions2() {
doSuggestionTest("CompletionContext", "CompletionResult", "completionContext", "completionResult");
}
public void testSuggestions3() {
doSuggestionTest("CompletionContext", "CompletionResult", "context", "result");
}
public void testSuggestions4() {
doSuggestionTest("CompletionContext", "CompletionResult", "codeCompletionContext", "codeCompletionResult");
}
public void testSuggestions5() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "codeCompletionContext", "completionResult");
}
public void testSuggestions6() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "context", "result");
}
public void testSuggestions7() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "contextWithAdvances", "resultWithAdvances");
}
public void testSuggestions8() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "_context", "_result");
}
public void testSuggestions9() {
doSuggestionTest("CodeCompletionContext", "CompletionResult", "p_context", "p_result");
}
public void testSuggestions10() {
doSuggestionTest("IBase", "IMain", "base", "main");
}
public void testSuggestions11() {
doSuggestionTest("Descriptor", "BasicDescriptor", "descriptor", "basicDescriptor");
}
public void testSuggestions12() {
doSuggestionTest("Provider", "ObjectProvider", "provider", "objectProvider");
}
public void testSuggestions13() {
doSuggestionTest("SimpleModel", "Model", "simpleModel", "model");
}
public void testSuggestions14() {
doSuggestionTest("ConfigItem", "Config", "item", "item");
}
public void testSuggestions15() {
doSuggestionTest("Transaction", "TransactionPolicy", "transaction", "transactionPolicy");
}
public void testSuggestions16() {
doSuggestionTest("Transaction", "TransactionPolicyHandler", "transaction", "transactionPolicyHandler");
}
public void testSuggestions17() {
doSuggestionTest("Transaction", "StrictTransactionPolicyHandler", "transaction", "strictTransactionPolicyHandler");
}
public void testSuggestions18() {
doSuggestionTest("Foo", "FooTask", "fooImpl", "fooTaskImpl");
}
public void testSuggestions19() {
doSuggestionTest("Foo", "FooTask", "implFoo", "implFooTask");
}
public void testSuggestions20() {
doSuggestionTest("Foo", "TaskFoo", "fooImpl", "taskFooImpl");
}
public void testSuggestions21() {
doSuggestionTest("Foo", "TaskFoo", "implFoo", "implTaskFoo");
}
private void doChangesTest(final String oldClassName, final String newClassName, final String changes) {
final NameSuggester suggester = new NameSuggester(oldClassName, newClassName);
assertEquals(
changes,
suggester.getChanges().toString()
);
}
private void doSuggestionTest(final String oldClassName, final String newClassName, final String variableName,
final String expectedSuggestion) {
final NameSuggester suggester = new NameSuggester(oldClassName, newClassName);
assertEquals(expectedSuggestion, suggester.suggestName(variableName));
}
}
| 4,668 | 0.714653 | 0.703727 | 145 | 31.193104 | 34.50563 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.896552 | false | false | 11 |
f175aa4530e3612d6d51bcfca0e85417529c357b | 2,181,843,428,510 | 4dccf64374263c0446155add22ef0a17a5562a23 | /app/src/main/java/com/kor/foodmanager/data/myEventListRepository/IMyEventListRepository.java | 9a2ce380085aafa641fa2d86910d61c5c736ad4c | [] | no_license | Rock-fact/mishpahug | https://github.com/Rock-fact/mishpahug | ca061b17b10c57b67fd7e07b67ab2c647c31f757 | 2731b342ac9addc831e1fce272b606e8efe4ee2a | refs/heads/master | 2020-04-24T05:10:48.775000 | 2019-05-11T08:12:38 | 2019-05-11T08:12:38 | 171,728,060 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kor.foodmanager.data.myEventListRepository;
import com.kor.foodmanager.data.event.ServerException;
import com.kor.foodmanager.data.model.EventDto;
import java.io.IOException;
import java.util.List;
public interface IMyEventListRepository {
List<EventDto> loadMyEventList (String token) throws ServerException, IOException;
}
| UTF-8 | Java | 344 | java | IMyEventListRepository.java | Java | [] | null | [] | package com.kor.foodmanager.data.myEventListRepository;
import com.kor.foodmanager.data.event.ServerException;
import com.kor.foodmanager.data.model.EventDto;
import java.io.IOException;
import java.util.List;
public interface IMyEventListRepository {
List<EventDto> loadMyEventList (String token) throws ServerException, IOException;
}
| 344 | 0.825581 | 0.825581 | 11 | 30.272728 | 27.568398 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 11 |
6e052eb7945a17c2f865b12d747c3f4de58c1533 | 28,432,683,559,432 | 5309cb72390d6ab7709532dfe54005202563189a | /ProjectKTHP/src/ptithcm/service/QuanHuyenService.java | f0c2bdefad76146c3224c9b2ec5152e53ae405db | [] | no_license | Minato1803/TimPhongTro-Project-Web | https://github.com/Minato1803/TimPhongTro-Project-Web | c92a5dafcfcf73d50db66260c71462401c210ecb | c9323863bc9e3bc502733075f75d10bfab297ed2 | refs/heads/main | 2023-02-14T22:20:38.628000 | 2021-01-13T04:52:37 | 2021-01-13T04:52:37 | 329,195,237 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ptithcm.service;
import java.util.List;
import ptithcm.entity.QuanHuyen;
public interface QuanHuyenService {
//tým theo ID
public QuanHuyen findById(String maQuan);
//load list theo TP
public List<QuanHuyen> getListByTP(String maTP);
//load all
public List<QuanHuyen> getAll();
}
| IBM852 | Java | 306 | java | QuanHuyenService.java | Java | [] | null | [] | package ptithcm.service;
import java.util.List;
import ptithcm.entity.QuanHuyen;
public interface QuanHuyenService {
//tým theo ID
public QuanHuyen findById(String maQuan);
//load list theo TP
public List<QuanHuyen> getListByTP(String maTP);
//load all
public List<QuanHuyen> getAll();
}
| 306 | 0.747541 | 0.747541 | 15 | 19.333334 | 16.369349 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.266667 | false | false | 11 |
62e11603285637e588dc5fce2b8b3798ff606b4e | 30,614,526,933,980 | dcaf2a701d445a2c3aaa36adbb703d744ba4a471 | /TrailRunTracker/src/main/java/com/skilldistillery/trailrun/controllers/TrailRunController.java | eeb2bc31b9dbc614376358fd92fc6ef81b29caf6 | [] | no_license | rwasek/EventTrackerProject | https://github.com/rwasek/EventTrackerProject | 77cd7d8ea7aede013989c1f755e40eea39fb97bd | 23c3f442f495402d4b442cb7d387ee3c008c07e8 | refs/heads/master | 2022-12-16T04:46:56.102000 | 2020-09-25T18:26:01 | 2020-09-25T18:26:01 | 269,778,880 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.skilldistillery.trailrun.controllers;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skilldistillery.trailrun.entities.TrailRun;
import com.skilldistillery.trailrun.entities.TrailType;
import com.skilldistillery.trailrun.services.TrailRunService;
@RestController
@RequestMapping("api")
@CrossOrigin({ "*", "http://localhost:4206" })
public class TrailRunController {
@Autowired
TrailRunService trailSvc;
@GetMapping("trailruns")
public List<TrailRun> index(){
return trailSvc.getAll();
}
@GetMapping("trailruns/{tId}")
public TrailRun retrieve(
@PathVariable Integer tId,
HttpServletResponse response
) {
TrailRun trailRun = trailSvc.findRunById(tId);
if (trailRun == null) {
response.setStatus(404); // if null 404 - no post with that id
}
return trailRun;
}
@PostMapping("trailruns")
public TrailRun createNew(
@RequestBody TrailRun trailRun,
HttpServletResponse response,
HttpServletRequest request
) {
try {
trailRun = trailSvc.createNewRun(trailRun);
response.setStatus(201); // 201 successfully created new run
StringBuffer url = request.getRequestURL(); // gets the resource created with the same url path and TrailRun id
response.setHeader("Location", url.toString()); // sets the location of the TrailRun that was created and returned
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
trailRun = null;
}
return trailRun;
}
@PutMapping("trailruns/{tId}")
public TrailRun updateRun(
@RequestBody TrailRun trailRun,
@PathVariable Integer tId,
HttpServletResponse response
) {
try {
trailRun = trailSvc.updateRun(trailRun, tId);
if (trailRun == null) {
response.setStatus(404); // 404 not found, wrong id
}
return trailRun;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400); // bad request due to poor data
trailRun = null;
}
return trailRun;
}
@PutMapping("trailruns/disable/{tId}")
public void disableRun( // postman will show true/false, may refactor as a void for future
@PathVariable Integer tId,
HttpServletResponse response
) {
try {
if(trailSvc.disableRun(tId)) {
response.setStatus(204); // ID was valid / 204 no content
}
else {
response.setStatus(404); // invalid ID, run not found
}
} catch (Exception e) {
e.printStackTrace();
response.setStatus(409); // conflict, trying to delete a run with tied child relationships
}
}
@GetMapping("trailruns/search/trailtype/{type}")
public List<TrailRun> findRunsByTrailType(
@PathVariable TrailType type,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByTrailType(type);
if (type == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/distance/{min}/{max}")
public List<TrailRun> findRunsByDistanceRange(
@PathVariable Double min,
@PathVariable Double max,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByMixMaxDistance(min, max);
if (min == null || max == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/distance/{min}")
public List<TrailRun> findRunsByMinDistance(
@PathVariable Double min,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByMinDistance(min);
if(min == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/location/{keyword}")
public List<TrailRun> findRunsByLocationKeyword(
@PathVariable String keyword,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByLocationKeyword(keyword);
if (keyword == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
}
| UTF-8 | Java | 4,932 | java | TrailRunController.java | Java | [] | null | [] | package com.skilldistillery.trailrun.controllers;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skilldistillery.trailrun.entities.TrailRun;
import com.skilldistillery.trailrun.entities.TrailType;
import com.skilldistillery.trailrun.services.TrailRunService;
@RestController
@RequestMapping("api")
@CrossOrigin({ "*", "http://localhost:4206" })
public class TrailRunController {
@Autowired
TrailRunService trailSvc;
@GetMapping("trailruns")
public List<TrailRun> index(){
return trailSvc.getAll();
}
@GetMapping("trailruns/{tId}")
public TrailRun retrieve(
@PathVariable Integer tId,
HttpServletResponse response
) {
TrailRun trailRun = trailSvc.findRunById(tId);
if (trailRun == null) {
response.setStatus(404); // if null 404 - no post with that id
}
return trailRun;
}
@PostMapping("trailruns")
public TrailRun createNew(
@RequestBody TrailRun trailRun,
HttpServletResponse response,
HttpServletRequest request
) {
try {
trailRun = trailSvc.createNewRun(trailRun);
response.setStatus(201); // 201 successfully created new run
StringBuffer url = request.getRequestURL(); // gets the resource created with the same url path and TrailRun id
response.setHeader("Location", url.toString()); // sets the location of the TrailRun that was created and returned
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
trailRun = null;
}
return trailRun;
}
@PutMapping("trailruns/{tId}")
public TrailRun updateRun(
@RequestBody TrailRun trailRun,
@PathVariable Integer tId,
HttpServletResponse response
) {
try {
trailRun = trailSvc.updateRun(trailRun, tId);
if (trailRun == null) {
response.setStatus(404); // 404 not found, wrong id
}
return trailRun;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400); // bad request due to poor data
trailRun = null;
}
return trailRun;
}
@PutMapping("trailruns/disable/{tId}")
public void disableRun( // postman will show true/false, may refactor as a void for future
@PathVariable Integer tId,
HttpServletResponse response
) {
try {
if(trailSvc.disableRun(tId)) {
response.setStatus(204); // ID was valid / 204 no content
}
else {
response.setStatus(404); // invalid ID, run not found
}
} catch (Exception e) {
e.printStackTrace();
response.setStatus(409); // conflict, trying to delete a run with tied child relationships
}
}
@GetMapping("trailruns/search/trailtype/{type}")
public List<TrailRun> findRunsByTrailType(
@PathVariable TrailType type,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByTrailType(type);
if (type == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/distance/{min}/{max}")
public List<TrailRun> findRunsByDistanceRange(
@PathVariable Double min,
@PathVariable Double max,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByMixMaxDistance(min, max);
if (min == null || max == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/distance/{min}")
public List<TrailRun> findRunsByMinDistance(
@PathVariable Double min,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByMinDistance(min);
if(min == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
@GetMapping("trailruns/search/location/{keyword}")
public List<TrailRun> findRunsByLocationKeyword(
@PathVariable String keyword,
HttpServletResponse response
){
List<TrailRun> runs = null;
try {
runs = trailSvc.findByLocationKeyword(keyword);
if (keyword == null) {
response.setStatus(404);
}
return runs;
} catch (Exception e) {
e.printStackTrace();
response.setStatus(400);
runs = null;
}
return runs;
}
}
| 4,932 | 0.713909 | 0.700933 | 196 | 24.163265 | 21.845558 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.352041 | false | false | 11 |
81d141d445695a67d03239b7709276feb076d186 | 16,922,171,179,570 | 1b2d746c9635536caa2f03564f3d00e83dd2bfa4 | /Crypto/Abstraction/CryptoManager.java | 5b3d7ea5616d3fe4b25bb4dae61eae11b142fd2f | [] | no_license | AurelienBol/TP5-Crypto | https://github.com/AurelienBol/TP5-Crypto | b3e01b9b1f81036df446e8159039b0d8c7e6bb92 | b4ab03e486127fc3f8469835ef9b9ff0665b2444 | refs/heads/master | 2020-11-25T07:33:24.146000 | 2020-02-10T12:02:06 | 2020-02-10T12:02:06 | 228,558,589 | 0 | 2 | 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 Crypto.Abstraction;
import Abstraction.Provider;
import Abstraction.Services;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
/**
*
* @author Camille
*/
public class CryptoManager extends Services
{
private static Properties cles = new Properties();
private CryptoManager(){}
public static Cle genereCle(String nomProv)
{
String nomClasse = cles.getProperty(nomProv);
if(nomClasse != null)
{
try {
Class c = Class.forName(nomClasse);
return (Cle) c.getDeclaredConstructor().newInstance();
}
catch (Exception ex) {
System.err.println("Erreur d'instantiation de "+nomClasse+": "+ex.getMessage());
}
}
else
throw new IllegalArgumentException("Aucune clé trouvée pour le Provider "+nomProv);
return null;
}
static
{
//providers
try {
Properties props = new Properties();
FileInputStream fisProv = new FileInputStream("providers.properties");
props.load(fisProv);
Enumeration e = props.propertyNames();
while(e.hasMoreElements())
{
String name = (String) e.nextElement();
String nomClasse = props.getProperty(name);
if(nomClasse != null)
{
Class c;
try {
c = Class.forName(nomClasse);
Provider prov = (Provider) c.newInstance();
providers.put(name,prov);
} catch (Exception ex) {
System.err.println("Erreur à l'instanciation de "+nomClasse+" : "+ex.getMessage());
}
}
}
}
catch (IOException ex) {
System.err.println("Erreur d'I/O: "+ex.getMessage());
}
//cles
try {
FileInputStream fisCles = new FileInputStream("cles.properties");
cles.load(fisCles);
}
catch (IOException ex) {
System.err.println("Erreur d'I/O: "+ex.getMessage());
}
}
}
| UTF-8 | Java | 2,532 | java | CryptoManager.java | Java | [
{
"context": "n;\nimport java.util.Properties;\n\n/**\n *\n * @author Camille\n */\npublic class CryptoManager extends Services\n{",
"end": 418,
"score": 0.9957138895988464,
"start": 411,
"tag": "NAME",
"value": "Camille"
}
] | 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 Crypto.Abstraction;
import Abstraction.Provider;
import Abstraction.Services;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
/**
*
* @author Camille
*/
public class CryptoManager extends Services
{
private static Properties cles = new Properties();
private CryptoManager(){}
public static Cle genereCle(String nomProv)
{
String nomClasse = cles.getProperty(nomProv);
if(nomClasse != null)
{
try {
Class c = Class.forName(nomClasse);
return (Cle) c.getDeclaredConstructor().newInstance();
}
catch (Exception ex) {
System.err.println("Erreur d'instantiation de "+nomClasse+": "+ex.getMessage());
}
}
else
throw new IllegalArgumentException("Aucune clé trouvée pour le Provider "+nomProv);
return null;
}
static
{
//providers
try {
Properties props = new Properties();
FileInputStream fisProv = new FileInputStream("providers.properties");
props.load(fisProv);
Enumeration e = props.propertyNames();
while(e.hasMoreElements())
{
String name = (String) e.nextElement();
String nomClasse = props.getProperty(name);
if(nomClasse != null)
{
Class c;
try {
c = Class.forName(nomClasse);
Provider prov = (Provider) c.newInstance();
providers.put(name,prov);
} catch (Exception ex) {
System.err.println("Erreur à l'instanciation de "+nomClasse+" : "+ex.getMessage());
}
}
}
}
catch (IOException ex) {
System.err.println("Erreur d'I/O: "+ex.getMessage());
}
//cles
try {
FileInputStream fisCles = new FileInputStream("cles.properties");
cles.load(fisCles);
}
catch (IOException ex) {
System.err.println("Erreur d'I/O: "+ex.getMessage());
}
}
}
| 2,532 | 0.528667 | 0.528667 | 83 | 29.469879 | 25.877533 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.39759 | false | false | 11 |
d7910a8f297d8a20d225d125b63b1681ab4aee27 | 22,462,679,013,585 | 7f5e76ae7db096965ef69569b0d552eb1c642d2f | /Manggo.java | baf479972f5dc561757667501cb3a3593948a98a | [] | no_license | adilahdiyana/Exercise-4.1 | https://github.com/adilahdiyana/Exercise-4.1 | 118a1acd417130269f2bfba87ae76299c05e91af | 46ce6803df076cfc77244c7a0a94cf63233bff7e | refs/heads/main | 2023-04-09T02:01:52.752000 | 2021-04-26T04:31:29 | 2021-04-26T04:31:29 | 361,575,192 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Exercise4_1;
public class Manggo extends Fruit { // subclass for Fruit
private double price;
private int quantity;
private String brand;
public Manggo(String name, double p, int q, String b) {
super(name);
this.price = p;
this.quantity = q;
this.brand = b;
}
public double getPrice() {
return this.price;
}
public int getQuantity() {
return this.quantity;
}
public String getBrand() {
return this.brand;
}
public String toString() {
return super.toString() + "\nPrice: RM " + price + "\nQuantity: " + quantity + "\nBrand: " + brand;
}
}
| UTF-8 | Java | 586 | java | Manggo.java | Java | [] | null | [] | package Exercise4_1;
public class Manggo extends Fruit { // subclass for Fruit
private double price;
private int quantity;
private String brand;
public Manggo(String name, double p, int q, String b) {
super(name);
this.price = p;
this.quantity = q;
this.brand = b;
}
public double getPrice() {
return this.price;
}
public int getQuantity() {
return this.quantity;
}
public String getBrand() {
return this.brand;
}
public String toString() {
return super.toString() + "\nPrice: RM " + price + "\nQuantity: " + quantity + "\nBrand: " + brand;
}
}
| 586 | 0.658703 | 0.65529 | 31 | 17.903225 | 21.210701 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.580645 | false | false | 11 |
9d51cb458fadae497465d12b040ced6870793443 | 25,082,609,056,388 | 56adea945b27ccaf880decadb7f7cb86de450a8d | /core/ep-core/src/test/java/com/elasticpath/service/order/impl/ShoppingItemNonShipmentPredicateTest.java | fbb777404452765379ccf60d79e32b8e5a6151e1 | [] | no_license | ryanlfoster/ep-commerce-engine-68 | https://github.com/ryanlfoster/ep-commerce-engine-68 | 89b56878806ca784eca453d58fb91836782a0987 | 7364bce45d25892e06df2e1c51da84dbdcebce5d | refs/heads/master | 2020-04-16T04:27:40.577000 | 2013-12-10T19:31:52 | 2013-12-10T20:01:08 | 40,164,760 | 1 | 1 | null | true | 2015-08-04T05:15:25 | 2015-08-04T05:15:25 | 2014-06-02T21:13:54 | 2013-12-10T21:24:38 | 86,120 | 0 | 0 | 0 | null | null | null | package com.elasticpath.service.order.impl;
import static org.junit.Assert.assertEquals;
import org.jmock.Expectations;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import com.elasticpath.domain.catalog.ProductSku;
import com.elasticpath.domain.shoppingcart.ShoppingItem;
/**
* Test cases for {@link ShoppingItemNonShipmentPredicate}.
*/
public class ShoppingItemNonShipmentPredicateTest {
@Rule
public final JUnitRuleMockery context = new JUnitRuleMockery();
private ShoppingItemNonShipmentPredicate predicate;
/**
* Setup method to be called before any test methods.
*/
@Before
public void setUp() {
predicate = new ShoppingItemNonShipmentPredicate();
}
/**
* Tests whether the predicate accepts non ShoppingItem classes.
*/
@Test (expected = ClassCastException.class)
public void testEvaluateObjectCCE() {
predicate.evaluate(new Object());
}
/**
* from description of SUBS-29: Accept items that Shippable type is not Shippable or Downloadable, is a Digital Assest.
*/
@Test
public void testEvaluateTrue() {
testForSku(false, false, false, false);
testForSku(true, false, false, false);
testForSku(false, true, false, true);
testForSku(true, true, false, false);
testForSku(false, false, true, false);
testForSku(true, false, true, false);
testForSku(false, true, true, false);
testForSku(true, true, true, false);
}
private void testForSku(final boolean shippable, final boolean digital, final boolean downloadable,
final boolean expectedValue) {
final ProductSku sku = context.mock(ProductSku.class, "ProductSku " + System.nanoTime());
final ShoppingItem shoppingItem = context.mock(ShoppingItem.class, "ShoppingItem " + System.nanoTime());
context.checking(new Expectations() {
{
allowing(sku).isShippable(); will(returnValue(shippable));
allowing(sku).isDigital(); will(returnValue(digital));
allowing(sku).isDownloadable(); will(returnValue(downloadable));
allowing(shoppingItem).getProductSku(); will(returnValue(sku));
}
});
assertEquals(predicate.evaluate(shoppingItem), expectedValue);
}
}
| UTF-8 | Java | 2,201 | java | ShoppingItemNonShipmentPredicateTest.java | Java | [] | null | [] | package com.elasticpath.service.order.impl;
import static org.junit.Assert.assertEquals;
import org.jmock.Expectations;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import com.elasticpath.domain.catalog.ProductSku;
import com.elasticpath.domain.shoppingcart.ShoppingItem;
/**
* Test cases for {@link ShoppingItemNonShipmentPredicate}.
*/
public class ShoppingItemNonShipmentPredicateTest {
@Rule
public final JUnitRuleMockery context = new JUnitRuleMockery();
private ShoppingItemNonShipmentPredicate predicate;
/**
* Setup method to be called before any test methods.
*/
@Before
public void setUp() {
predicate = new ShoppingItemNonShipmentPredicate();
}
/**
* Tests whether the predicate accepts non ShoppingItem classes.
*/
@Test (expected = ClassCastException.class)
public void testEvaluateObjectCCE() {
predicate.evaluate(new Object());
}
/**
* from description of SUBS-29: Accept items that Shippable type is not Shippable or Downloadable, is a Digital Assest.
*/
@Test
public void testEvaluateTrue() {
testForSku(false, false, false, false);
testForSku(true, false, false, false);
testForSku(false, true, false, true);
testForSku(true, true, false, false);
testForSku(false, false, true, false);
testForSku(true, false, true, false);
testForSku(false, true, true, false);
testForSku(true, true, true, false);
}
private void testForSku(final boolean shippable, final boolean digital, final boolean downloadable,
final boolean expectedValue) {
final ProductSku sku = context.mock(ProductSku.class, "ProductSku " + System.nanoTime());
final ShoppingItem shoppingItem = context.mock(ShoppingItem.class, "ShoppingItem " + System.nanoTime());
context.checking(new Expectations() {
{
allowing(sku).isShippable(); will(returnValue(shippable));
allowing(sku).isDigital(); will(returnValue(digital));
allowing(sku).isDownloadable(); will(returnValue(downloadable));
allowing(shoppingItem).getProductSku(); will(returnValue(sku));
}
});
assertEquals(predicate.evaluate(shoppingItem), expectedValue);
}
}
| 2,201 | 0.743298 | 0.741935 | 72 | 29.569445 | 29.251223 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.069444 | false | false | 11 |
48bed4651dabfab5d7b81346acf3b34b5811c788 | 15,547,781,653,763 | 17f427552edc3b81662cb97bbcd05dd3039ab59c | /src/test/java/test/xice/tsac/model/oa/propertypath/MarketTypePP.java | 9ef34c22e93ecfd4facfc948a9a6b7fb073a86a7 | [
"Apache-2.0"
] | permissive | ViaOA/oa-web | https://github.com/ViaOA/oa-web | 61fd23a45450ff9f049e4b3dbd1d3e5e75ca4e00 | ce44f24d1da8041ea5e09ac45d60fb37b2b185ba | refs/heads/master | 2023-07-06T09:45:44.640000 | 2022-12-26T21:46:05 | 2022-12-26T21:46:05 | 179,831,753 | 0 | 0 | Apache-2.0 | false | 2022-12-27T02:00:51 | 2019-04-06T12:39:12 | 2022-03-01T17:30:24 | 2022-12-27T01:39:46 | 2,351 | 0 | 0 | 0 | Java | false | false | // Generated by OABuilder
package test.xice.tsac.model.oa.propertypath;
import test.xice.tsac.model.oa.*;
public class MarketTypePP {
private static EnvironmentPPx environment;
private static UserPPx users;
public static EnvironmentPPx environment() {
if (environment == null) environment = new EnvironmentPPx(MarketType.P_Environment);
return environment;
}
public static UserPPx users() {
if (users == null) users = new UserPPx(MarketType.P_Users);
return users;
}
public static String id() {
String s = MarketType.P_Id;
return s;
}
public static String name() {
String s = MarketType.P_Name;
return s;
}
public static String seq() {
String s = MarketType.P_Seq;
return s;
}
}
| UTF-8 | Java | 824 | java | MarketTypePP.java | Java | [] | null | [] | // Generated by OABuilder
package test.xice.tsac.model.oa.propertypath;
import test.xice.tsac.model.oa.*;
public class MarketTypePP {
private static EnvironmentPPx environment;
private static UserPPx users;
public static EnvironmentPPx environment() {
if (environment == null) environment = new EnvironmentPPx(MarketType.P_Environment);
return environment;
}
public static UserPPx users() {
if (users == null) users = new UserPPx(MarketType.P_Users);
return users;
}
public static String id() {
String s = MarketType.P_Id;
return s;
}
public static String name() {
String s = MarketType.P_Name;
return s;
}
public static String seq() {
String s = MarketType.P_Seq;
return s;
}
}
| 824 | 0.623786 | 0.623786 | 35 | 22.485714 | 21.120567 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 11 |
d25ab61fd8439fbf0b851864f473cd27936fc076 | 7,765,300,923,601 | 74afe93d298b6121cd73e727c76dd2eb03b38603 | /creationalpatterns/src/main/java/com/factory/fan/parts/Motor.java | aeb69c871ab1f9a0370973d284babd612b2f01c5 | [
"MIT"
] | permissive | aashisharoradev/design-patterns | https://github.com/aashisharoradev/design-patterns | 2633ea3bf7d0da2e57148acb17cd60e30f217856 | 50116b9b371aa373c8be896242f7b5ed1fe77c26 | refs/heads/master | 2020-04-07T11:25:42.241000 | 2018-11-28T05:08:16 | 2018-11-28T05:08:16 | 158,325,722 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.factory.fan.parts;
import com.factory.fan.interfaces.Color;
import com.factory.fan.interfaces.Part;
public class Motor implements Part {
private String brand;
private Color color;
private float price;
public void setBrand(String brand) {
this.brand = brand;
}
public void setPrice(float price) {
this.price = price;
}
public void setColor(Color color) {
this.color = color;
}
public void createPart() {
System.out.println("Created Motor [color=" + color.fillColor() +", brand=" + brand + ", price=" + price + "]");
}
public float getPrice() {
return this.price;
}
@Override
public Part clone() throws CloneNotSupportedException {
return this;
}
}
| UTF-8 | Java | 699 | java | Motor.java | Java | [] | null | [] | package com.factory.fan.parts;
import com.factory.fan.interfaces.Color;
import com.factory.fan.interfaces.Part;
public class Motor implements Part {
private String brand;
private Color color;
private float price;
public void setBrand(String brand) {
this.brand = brand;
}
public void setPrice(float price) {
this.price = price;
}
public void setColor(Color color) {
this.color = color;
}
public void createPart() {
System.out.println("Created Motor [color=" + color.fillColor() +", brand=" + brand + ", price=" + price + "]");
}
public float getPrice() {
return this.price;
}
@Override
public Part clone() throws CloneNotSupportedException {
return this;
}
}
| 699 | 0.69671 | 0.69671 | 36 | 18.416666 | 22.230328 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false | 11 |
ce652b166c17d385e806e74718d62d3b3447aafe | 30,751,965,872,450 | 3d879614ef2f01648e075a86bc73c002e589cd2f | /SoundCommunicate/src/com/android/soundcommunicate/PowerSupply.java | b4585a33e8bf1c28d7a62a709bc7475f4c1412d2 | [] | no_license | lilidejing/play_sin_f_wave | https://github.com/lilidejing/play_sin_f_wave | cfd0ce55604c933234cceb7c1ab880ace0ccc594 | fe1de86437ac1ddb2a4ab851815c7d5d94904422 | refs/heads/master | 2020-12-25T06:45:37.730000 | 2016-06-24T08:35:47 | 2016-06-24T08:35:47 | 61,870,188 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.android.soundcommunicate;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
public class PowerSupply {
private boolean powerIsSupplying = false;
public static int pwMinBufferSize = AudioTrack.getMinBufferSize(EncoderCore.getPowerSupplySamplerate(),
AudioFormat.CHANNEL_OUT_STEREO,
AudioFormat.ENCODING_PCM_8BIT);
AudioTrack pwAT;
public boolean powerIsSupplying(){
return powerIsSupplying;
}
public void pwStart(byte[] carrierSignal) {
if(powerIsSupplying)
pwStop();
pwAT = new AudioTrack(AudioManager.STREAM_MUSIC,
EncoderCore.getPowerSupplySamplerate(),
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_8BIT,
pwMinBufferSize*2,
AudioTrack.MODE_STATIC);
powerIsSupplying = true;
pwAT.write(carrierSignal, 0, EncoderCore.getPowerSupplyBufferSize());
pwAT.flush();
pwAT.setStereoVolume(1, 0);
pwAT.setLoopPoints(0, EncoderCore.getPowerSupplyBufferSize(), -1);
pwAT.play();
}
public void pwStop() {
if(pwAT != null)
{
pwAT.release();
pwAT = null;
}
powerIsSupplying = false;
}
}//end class
| UTF-8 | Java | 1,176 | java | PowerSupply.java | Java | [] | null | [] | package com.android.soundcommunicate;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
public class PowerSupply {
private boolean powerIsSupplying = false;
public static int pwMinBufferSize = AudioTrack.getMinBufferSize(EncoderCore.getPowerSupplySamplerate(),
AudioFormat.CHANNEL_OUT_STEREO,
AudioFormat.ENCODING_PCM_8BIT);
AudioTrack pwAT;
public boolean powerIsSupplying(){
return powerIsSupplying;
}
public void pwStart(byte[] carrierSignal) {
if(powerIsSupplying)
pwStop();
pwAT = new AudioTrack(AudioManager.STREAM_MUSIC,
EncoderCore.getPowerSupplySamplerate(),
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_8BIT,
pwMinBufferSize*2,
AudioTrack.MODE_STATIC);
powerIsSupplying = true;
pwAT.write(carrierSignal, 0, EncoderCore.getPowerSupplyBufferSize());
pwAT.flush();
pwAT.setStereoVolume(1, 0);
pwAT.setLoopPoints(0, EncoderCore.getPowerSupplyBufferSize(), -1);
pwAT.play();
}
public void pwStop() {
if(pwAT != null)
{
pwAT.release();
pwAT = null;
}
powerIsSupplying = false;
}
}//end class
| 1,176 | 0.722789 | 0.715986 | 47 | 24.021276 | 21.84519 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.851064 | false | false | 11 |
6c7580cbbcae491e6af0f8474bc9fb191d94e72d | 13,709,535,645,094 | 40ddb3450e704d74c20cc28a26d8aa790bbbc5b3 | /src/hobby/linkedList/PalindromeList.java | 97642adf379ee55682d5344d4d6b070ec888e4eb | [] | no_license | ss511/JavaHobby | https://github.com/ss511/JavaHobby | 09c04b6d1d1c0f270769e511f11dafe99acd58a2 | ab51306a5d1a4da3bff886c1572e5243ce871b8a | refs/heads/master | 2021-03-12T20:09:22.300000 | 2017-10-17T17:00:40 | 2017-10-17T17:00:40 | 27,990,417 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hobby.linkedList;
/*
* Find whether the list is palindrome or not
*
*/
public class PalindromeList {
public static void main(String[] args) {
LinkedLists linkedLists = new LinkedLists();
ListNode node = null;
node = linkedLists.insertAtEnd(node, 2);
node = linkedLists.insertAtEnd(node, 3);
node = linkedLists.insertAtEnd(node, 5);
node = linkedLists.insertAtEnd(node, 3);
node = linkedLists.insertAtEnd(node, 2);
System.out.println("Initial List:::");
linkedLists.printList(node);
PalindromeList palindromeList = new PalindromeList();
int isPalindrome = palindromeList.isPalindrome(node);
if(isPalindrome == 1){
System.out.println("List is Palindrome");
}
else{
System.out.println("List is not palindrome");
}
}
int isPalindrome(ListNode head){
ListNode middle = getMiddle(head);
ListNode end = reverseList(middle);
int flag = 1;
while(end.getNext() != null){
System.out.println(end.getData());
if(head.getData() == end.getData()){
flag = 1;
}
else{
flag = 0;
break;
}
head = head.getNext();
end = end.getNext();
}
return flag;
}
ListNode getMiddle(ListNode head){
ListNode fast = head;
ListNode slow = head;
while(fast.getNext() != null){
fast = fast.getNext();
if(fast.getNext() != null){
fast = fast.getNext();
slow = slow.getNext();
}
}
return slow;
}
ListNode reverseList(ListNode head){
ListNode temp = null;
ListNode nextNode = null;
ListNode current = head;
while(current != null){
nextNode = current.getNext();
current.setNext(temp);
temp = current;
current = nextNode;
}
return temp;
}
}
| UTF-8 | Java | 1,662 | java | PalindromeList.java | Java | [] | null | [] | package hobby.linkedList;
/*
* Find whether the list is palindrome or not
*
*/
public class PalindromeList {
public static void main(String[] args) {
LinkedLists linkedLists = new LinkedLists();
ListNode node = null;
node = linkedLists.insertAtEnd(node, 2);
node = linkedLists.insertAtEnd(node, 3);
node = linkedLists.insertAtEnd(node, 5);
node = linkedLists.insertAtEnd(node, 3);
node = linkedLists.insertAtEnd(node, 2);
System.out.println("Initial List:::");
linkedLists.printList(node);
PalindromeList palindromeList = new PalindromeList();
int isPalindrome = palindromeList.isPalindrome(node);
if(isPalindrome == 1){
System.out.println("List is Palindrome");
}
else{
System.out.println("List is not palindrome");
}
}
int isPalindrome(ListNode head){
ListNode middle = getMiddle(head);
ListNode end = reverseList(middle);
int flag = 1;
while(end.getNext() != null){
System.out.println(end.getData());
if(head.getData() == end.getData()){
flag = 1;
}
else{
flag = 0;
break;
}
head = head.getNext();
end = end.getNext();
}
return flag;
}
ListNode getMiddle(ListNode head){
ListNode fast = head;
ListNode slow = head;
while(fast.getNext() != null){
fast = fast.getNext();
if(fast.getNext() != null){
fast = fast.getNext();
slow = slow.getNext();
}
}
return slow;
}
ListNode reverseList(ListNode head){
ListNode temp = null;
ListNode nextNode = null;
ListNode current = head;
while(current != null){
nextNode = current.getNext();
current.setNext(temp);
temp = current;
current = nextNode;
}
return temp;
}
}
| 1,662 | 0.65704 | 0.651625 | 74 | 21.445946 | 15.938346 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.527027 | false | false | 11 |
b4f43febeb1b54acced6ce715031271547579ee5 | 9,895,604,680,016 | 02fa95483c2e841e871a2ab272ebf4d94337fcda | /src/main/java/com/vobis/tankengineer/circuit/NodeDefinition.java | 93aa58ebc2a8eb3d34d2819111eeacff1e38b0e5 | [] | no_license | Shaunwild97/tank-engineer | https://github.com/Shaunwild97/tank-engineer | 2b633b312cc5adb9eb839b96ebea16a321590768 | b4e51a00b1109d34e04dc08bb6c747b410370a3e | refs/heads/master | 2020-03-27T11:58:10.919000 | 2018-09-05T12:49:30 | 2018-09-05T12:49:30 | 146,517,794 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vobis.tankengineer.circuit;
import com.vobis.tankengineer.entity.EntityModular;
import com.vobis.tankengineer.render.Screen;
import java.util.function.Consumer;
/**
*
* @author Shaun
*/
public class NodeDefinition<T extends EntityModular> {
private String name;
private String shortName;
private String[] inputs = new String[0];
private String[] outputs = new String[0];
private int width, height;
private Consumer<NodeInstance<T>> action;
private Consumer<NodePort> operation;
public String[] getInputs() {
return inputs;
}
public String[] getOutputs() {
return outputs;
}
public String getName() {
return name;
}
public Consumer<NodeInstance<T>> getAction() {
return action;
}
public String getShortName() {
return shortName;
}
public NodeDefinition<T> name(String name) {
this.name = name;
return this;
}
public NodeDefinition<T> inputs(String... inputs) {
this.inputs = inputs;
return this;
}
public NodeDefinition<T> outputs(String... outputs) {
this.outputs = outputs;
return this;
}
public NodeDefinition<T> action(Consumer<NodeInstance<T>> action) {
this.action = action;
return this;
}
public NodeDefinition<T> shortName(String shortName) {
this.shortName = shortName;
return this;
}
public void render(Screen screen, float x, float y) {
screen.drawRect(x, y, 100, 100, 0x636363);
screen.drawRect(x, y, 100, 20, 0x939393);
screen.drawShadowedString(getName(), x + 2, y + 2, 0xFFFFFF);
for (int i = 0; i < inputs.length; i++) {
screen.drawRect(x, 30 + y + i * 15, 5, 5, 0xDDDDDD);
screen.drawString(inputs[i], x + 10, 25 + y + i * 15, 0xDDDDDD);
}
y += inputs.length * 15;
for (int i = 0; i < outputs.length; i++) {
screen.drawRect(x + 95, 30 + y + i * 15, 5, 5, 0xDDDDDD);
screen.drawString(outputs[i], x + 90 - screen.stringWidth(Screen.GAME_FONT, outputs[i]), 25 + y + i * 15, 0xDDDDDD);
}
}
}
| UTF-8 | Java | 2,186 | java | NodeDefinition.java | Java | [
{
"context": "rt java.util.function.Consumer;\n\n/**\n *\n * @author Shaun\n */\npublic class NodeDefinition<T extends EntityM",
"end": 199,
"score": 0.9990608096122742,
"start": 194,
"tag": "NAME",
"value": "Shaun"
}
] | null | [] | package com.vobis.tankengineer.circuit;
import com.vobis.tankengineer.entity.EntityModular;
import com.vobis.tankengineer.render.Screen;
import java.util.function.Consumer;
/**
*
* @author Shaun
*/
public class NodeDefinition<T extends EntityModular> {
private String name;
private String shortName;
private String[] inputs = new String[0];
private String[] outputs = new String[0];
private int width, height;
private Consumer<NodeInstance<T>> action;
private Consumer<NodePort> operation;
public String[] getInputs() {
return inputs;
}
public String[] getOutputs() {
return outputs;
}
public String getName() {
return name;
}
public Consumer<NodeInstance<T>> getAction() {
return action;
}
public String getShortName() {
return shortName;
}
public NodeDefinition<T> name(String name) {
this.name = name;
return this;
}
public NodeDefinition<T> inputs(String... inputs) {
this.inputs = inputs;
return this;
}
public NodeDefinition<T> outputs(String... outputs) {
this.outputs = outputs;
return this;
}
public NodeDefinition<T> action(Consumer<NodeInstance<T>> action) {
this.action = action;
return this;
}
public NodeDefinition<T> shortName(String shortName) {
this.shortName = shortName;
return this;
}
public void render(Screen screen, float x, float y) {
screen.drawRect(x, y, 100, 100, 0x636363);
screen.drawRect(x, y, 100, 20, 0x939393);
screen.drawShadowedString(getName(), x + 2, y + 2, 0xFFFFFF);
for (int i = 0; i < inputs.length; i++) {
screen.drawRect(x, 30 + y + i * 15, 5, 5, 0xDDDDDD);
screen.drawString(inputs[i], x + 10, 25 + y + i * 15, 0xDDDDDD);
}
y += inputs.length * 15;
for (int i = 0; i < outputs.length; i++) {
screen.drawRect(x + 95, 30 + y + i * 15, 5, 5, 0xDDDDDD);
screen.drawString(outputs[i], x + 90 - screen.stringWidth(Screen.GAME_FONT, outputs[i]), 25 + y + i * 15, 0xDDDDDD);
}
}
}
| 2,186 | 0.597896 | 0.568618 | 84 | 25.023809 | 24.614155 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.797619 | false | false | 11 |
2cf807f7da93a85612c8571fdc50a2be556a2c57 | 19,335,942,800,462 | 4ec65cc12bbe6a4da684f436f99015bccb81e147 | /Git.javaproj/src/application/child_to_clean.java | 79d5c3a82c2af11758047a57e27ffcc8b71ce280 | [] | no_license | Norberts11/MoodernizeExamples | https://github.com/Norberts11/MoodernizeExamples | ec69674078c314b22cd659cc30eab1caa6f547c3 | 7ee6503ef596d6afc01220edbab77c2264969085 | refs/heads/master | 2020-08-24T17:45:36.808000 | 2020-07-27T11:13:03 | 2020-07-27T11:13:03 | 216,872,605 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package application;
public class child_to_clean {
private Object pid;
private child_process process;
private child_to_clean next;
public child_to_clean(Object pid, child_process process, child_to_clean next) {
setPid(pid);
setProcess(process);
setNext(next);
}
public child_to_clean() {
}
public Object getPid() {
return pid;
}
public void setPid(Object newPid) {
pid = newPid;
}
public child_process getProcess() {
return process;
}
public void setProcess(child_process newProcess) {
process = newProcess;
}
public child_to_clean getNext() {
return next;
}
public void setNext(child_to_clean newNext) {
next = newNext;
}
}
| UTF-8 | Java | 667 | java | child_to_clean.java | Java | [] | null | [] | package application;
public class child_to_clean {
private Object pid;
private child_process process;
private child_to_clean next;
public child_to_clean(Object pid, child_process process, child_to_clean next) {
setPid(pid);
setProcess(process);
setNext(next);
}
public child_to_clean() {
}
public Object getPid() {
return pid;
}
public void setPid(Object newPid) {
pid = newPid;
}
public child_process getProcess() {
return process;
}
public void setProcess(child_process newProcess) {
process = newProcess;
}
public child_to_clean getNext() {
return next;
}
public void setNext(child_to_clean newNext) {
next = newNext;
}
}
| 667 | 0.703148 | 0.703148 | 34 | 18.617647 | 17.566704 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.588235 | false | false | 11 |
584b703c40d6848c09cdc616514da174529a0cf0 | 1,623,497,689,161 | 136df54f387ef08a75a5d2b84062f0be06ef8660 | /src/com/medfinder/teste/Teste2.java | 88b9ec962b9d3962b72adfb1bcccf9e5461a33b3 | [] | no_license | duduipiranga/medFinder | https://github.com/duduipiranga/medFinder | 6b942580680f8be2885e65497e19acc48daa0566 | 9e86acfcd272c20c4f67e0dc12dd8eb36e9ca408 | refs/heads/master | 2021-01-25T12:02:30.441000 | 2013-10-15T01:28:36 | 2013-10-15T01:28:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.medfinder.teste;
import java.rmi.RemoteException;
import com.medfinder.bo.OperadoraBOProxy;
import com.medfinder.to.Operadora;
public class Teste2 {
public static void main(String[] args) {
int id = 12;
OperadoraBOProxy ob = new OperadoraBOProxy();
try {
Operadora o;
o = ob.consultarOperadora(id);
System.out.println(o.getDs_operadora());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| UTF-8 | Java | 532 | java | Teste2.java | Java | [] | null | [] | package com.medfinder.teste;
import java.rmi.RemoteException;
import com.medfinder.bo.OperadoraBOProxy;
import com.medfinder.to.Operadora;
public class Teste2 {
public static void main(String[] args) {
int id = 12;
OperadoraBOProxy ob = new OperadoraBOProxy();
try {
Operadora o;
o = ob.consultarOperadora(id);
System.out.println(o.getDs_operadora());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| 532 | 0.637218 | 0.631579 | 32 | 14.625 | 16.241825 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.625 | false | false | 11 |
6a636311a62a400756bf3baeff83f78f3f73062a | 11,656,541,266,404 | 37d28c0a01b435c29af8e2999154b7144ea47dea | /Spring2019_online/src/oficehours/Animal.java | 1c782a24a0557c0a3e53773759b9c11adf041e85 | [] | no_license | Alitokmak/eclipse-workspace | https://github.com/Alitokmak/eclipse-workspace | b6b995b0d703f53378572c931176d5d27f1262e2 | 5a2df72509ed1c39ebfaf68ebe2932cb4fef5cd8 | refs/heads/master | 2020-06-20T22:59:27.107000 | 2019-07-16T22:50:00 | 2019-07-16T22:50:00 | 197,278,301 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package oficehours;
public abstract class Animal {
private String name;
private int age;
public Animal(String name, int age) {
this.name = name;
this.age = age;
}
public abstract void speak();
@Override
public String toString() {
return "Animal [name=" + name + ", age=" + age + "]";
}
// we cannot instantiate abstract class, even though we can have constructor
// abstract class allows to have abstract methods
// abstract class cannot be final because
// it must me sub-classed by concrete (regular) class
// (not strict, but it's common sense)
// we have to use abstract class only
// if we are planning to define abstract methods
// abstract methods cannot be private, final and static
// because, abstract method must be implemented
// abstract method will be implemented in the concrete class
}
| UTF-8 | Java | 834 | java | Animal.java | Java | [] | null | [] | package oficehours;
public abstract class Animal {
private String name;
private int age;
public Animal(String name, int age) {
this.name = name;
this.age = age;
}
public abstract void speak();
@Override
public String toString() {
return "Animal [name=" + name + ", age=" + age + "]";
}
// we cannot instantiate abstract class, even though we can have constructor
// abstract class allows to have abstract methods
// abstract class cannot be final because
// it must me sub-classed by concrete (regular) class
// (not strict, but it's common sense)
// we have to use abstract class only
// if we are planning to define abstract methods
// abstract methods cannot be private, final and static
// because, abstract method must be implemented
// abstract method will be implemented in the concrete class
}
| 834 | 0.715827 | 0.715827 | 29 | 27.758621 | 22.082376 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.37931 | false | false | 11 |
fed5df0e269fd3ab91cc903b569d59aa22ec05d4 | 14,800,457,354,324 | 0506a21e1aa266b8eaa90ea159d5c6a0a7a7b9e0 | /src/main/java/box/exo/ExoBack/controller/bal2017Controlador.java | 75c1e98e02ae2be9d2d7586687fb252fafb62619 | [] | no_license | racso9817/ExoBack | https://github.com/racso9817/ExoBack | d855a849a645adb1dfc4fa6b8bcf5091e24ca7b2 | a2cb229022c6893c674aeb5f69ae04dbd77c5797 | refs/heads/main | 2023-08-09T12:45:44.225000 | 2021-09-13T22:05:49 | 2021-09-13T22:05:49 | null | 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 box.exo.ExoBack.controller;
import box.exo.ExoBack.models.balance2017;
import box.exo.ExoBack.models.balance2017Interface;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
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;
/**
*
* @author oscaravila9817
*/
@RestController
@CrossOrigin(origins="http://localhost:4200")
@RequestMapping("/bal2017")
@AllArgsConstructor
@Slf4j
public class bal2017Controlador {
private balance2017Interface bal2017Repo;
@GetMapping("/{exp}")
public balance2017 findByCodigo(@PathVariable int exp){
return bal2017Repo.findByExp2020(exp);
}
}
| UTF-8 | Java | 1,082 | java | bal2017Controlador.java | Java | [
{
"context": "bind.annotation.RestController;\n\n/**\n *\n * @author oscaravila9817\n */\n@RestController\n@CrossOrigin(origins=\"http://",
"end": 724,
"score": 0.9994872808456421,
"start": 710,
"tag": "USERNAME",
"value": "oscaravila9817"
}
] | 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 box.exo.ExoBack.controller;
import box.exo.ExoBack.models.balance2017;
import box.exo.ExoBack.models.balance2017Interface;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
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;
/**
*
* @author oscaravila9817
*/
@RestController
@CrossOrigin(origins="http://localhost:4200")
@RequestMapping("/bal2017")
@AllArgsConstructor
@Slf4j
public class bal2017Controlador {
private balance2017Interface bal2017Repo;
@GetMapping("/{exp}")
public balance2017 findByCodigo(@PathVariable int exp){
return bal2017Repo.findByExp2020(exp);
}
}
| 1,082 | 0.780961 | 0.737523 | 36 | 29.055555 | 23.550117 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 11 |
c2042887efc67c55b4b3416ed213b609a98c146e | 5,746,666,279,680 | 7663e53a1bf2348b21e0ca1ee7f93ee2f12c464a | /JavaOOP/02Inheritance/Exercise/p05Restaurant/restaurant/products/foods/main_dishes/MainDish.java | 856e7c80f029fe80037dc965bdd91b3727969e9b | [] | no_license | AlexBogdanov/SoftUni-JavaAdvanced | https://github.com/AlexBogdanov/SoftUni-JavaAdvanced | dd07fa27f5db81c445a31ae9ddcb066de1bbe5da | 3c9b1499d19229d67cf4c5a16e88e761267a128d | refs/heads/master | 2020-12-14T22:36:12.904000 | 2020-04-12T10:10:47 | 2020-04-12T10:10:47 | 234,895,243 | 0 | 0 | null | false | 2020-10-13T21:01:33 | 2020-01-19T12:17:59 | 2020-04-12T10:11:02 | 2020-10-13T21:01:32 | 9,753 | 0 | 0 | 5 | Java | false | false | package p05Restaurant.restaurant.products.foods.main_dishes;
import java.math.BigDecimal;
import p05Restaurant.restaurant.products.foods.Food;
public class MainDish extends Food {
public MainDish(String name, BigDecimal price, double grams) {
super(name, price, grams);
}
}
| UTF-8 | Java | 295 | java | MainDish.java | Java | [] | null | [] | package p05Restaurant.restaurant.products.foods.main_dishes;
import java.math.BigDecimal;
import p05Restaurant.restaurant.products.foods.Food;
public class MainDish extends Food {
public MainDish(String name, BigDecimal price, double grams) {
super(name, price, grams);
}
}
| 295 | 0.752542 | 0.738983 | 13 | 21.692308 | 24.502384 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615385 | false | false | 11 |
d89f96198f1a469d309e569476f36c03a3b668ab | 25,632,364,889,195 | e5411bc10a22b0cfcd4d4861910b2a6157a7958d | /src/main/java/com/diancu/webserver/httpapi/HeaderValidator.java | f2998029fe31ad94a73967bc53df41f0c83c379e | [] | no_license | daniancu/httpserver | https://github.com/daniancu/httpserver | 574ce7cbd5f9595ea6653a64e7b5a03042eac920 | c3e5166f6a08f0e7135f880ab85c0a7f6ae73c0c | refs/heads/master | 2020-05-01T19:13:46.215000 | 2019-04-09T07:43:16 | 2019-04-09T07:43:16 | 177,642,828 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.diancu.webserver.httpapi;
import java.util.Map;
/**
* Defines header validation. It has different implementations depending on the HTTP protocol version
*/
public interface HeaderValidator {
default boolean isValid(String headerName, String headerValue) {
return true;
}
default void validateHeaders(Map<String, String> httpHeaders) {
}
}
| UTF-8 | Java | 382 | java | HeaderValidator.java | Java | [] | null | [] | package com.diancu.webserver.httpapi;
import java.util.Map;
/**
* Defines header validation. It has different implementations depending on the HTTP protocol version
*/
public interface HeaderValidator {
default boolean isValid(String headerName, String headerValue) {
return true;
}
default void validateHeaders(Map<String, String> httpHeaders) {
}
}
| 382 | 0.732984 | 0.732984 | 17 | 21.470589 | 29.617399 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | false | false | 11 |
732a08df70aef55d3df18cd0421a64a231d517bd | 5,179,730,567,205 | 3a5d3743a450c2cc64a7174828920330317597c9 | /src/ExtruturaDeRepeticaoFor/Exemplo4.java | 47e60274205f3ad33e81f8abdab2a0afa1607fdd | [] | no_license | carlosaugustoa/AulasAlgoritmos | https://github.com/carlosaugustoa/AulasAlgoritmos | 804871ad6326d1b3c3f569646430e81063920faa | 82969832eed4bec77ec17f5f824de5dbb8b09d24 | refs/heads/master | 2021-01-17T17:53:41.573000 | 2016-06-25T00:02:07 | 2016-06-25T00:02:07 | 60,882,258 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ExtruturaDeRepeticaoFor;
import java.util.Scanner;
public class Exemplo4 {
public static void main(String[] args) {
Scanner ent = new Scanner(System.in);
System.out.print("Digite um número : ");
int numero = ent.nextInt();
for (int i=1; i<10; i++) {
System.out.println( numero + " * " + i + " = " + (i*numero));
}
}
}
| UTF-8 | Java | 429 | java | Exemplo4.java | Java | [] | null | [] | package ExtruturaDeRepeticaoFor;
import java.util.Scanner;
public class Exemplo4 {
public static void main(String[] args) {
Scanner ent = new Scanner(System.in);
System.out.print("Digite um número : ");
int numero = ent.nextInt();
for (int i=1; i<10; i++) {
System.out.println( numero + " * " + i + " = " + (i*numero));
}
}
}
| 429 | 0.507009 | 0.497664 | 22 | 17.454546 | 18.524498 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 11 |
62fe4eda78f47d586fe5a69c23c2601746d6a745 | 5,179,730,566,921 | d80be677523ce0ecf546fd2c679c21b8d3beee44 | /src/main/java/top/qiuk/po/BlogsLog.java | 47d7d00e3c655e58c36886dab64917b018ac32fd | [] | no_license | qiukai/qiuk_base | https://github.com/qiukai/qiuk_base | 928749764f524b532b2cdab6fd9664bd555ddb2f | 65e3c85d3c35916a2aecf77db037c5160314bc9b | refs/heads/master | 2016-08-03T07:12:41.567000 | 2016-06-11T15:15:44 | 2016-06-11T15:15:44 | 57,450,508 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package top.qiuk.po;
import java.io.Serializable;
import java.util.Date;
public class BlogsLog implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String title;
private Date createTime;
private String primaryId;
private String logId;
private Integer logType;
private String content;
public BlogsLog() {
super();
}
public BlogsLog(String id, String title, Date createTime, String primaryId, String logId, Integer logType,
String content) {
super();
this.id = id;
this.title = title;
this.createTime = createTime;
this.primaryId = primaryId;
this.logId = logId;
this.logType = logType;
this.content = content;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getPrimaryId() {
return primaryId;
}
public void setPrimaryId(String primaryId) {
this.primaryId = primaryId;
}
public String getLogId() {
return logId;
}
public void setLogId(String logId) {
this.logId = logId;
}
public Integer getLogType() {
return logType;
}
public void setLogType(Integer logType) {
this.logType = logType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "BlogsLog [id=" + id + ", title=" + title + ", createTime=" + createTime + ", primaryId=" + primaryId
+ ", logId=" + logId + ", logType=" + logType + ", content=" + content + "]";
}
} | UTF-8 | Java | 1,882 | java | BlogsLog.java | Java | [] | null | [] | package top.qiuk.po;
import java.io.Serializable;
import java.util.Date;
public class BlogsLog implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String title;
private Date createTime;
private String primaryId;
private String logId;
private Integer logType;
private String content;
public BlogsLog() {
super();
}
public BlogsLog(String id, String title, Date createTime, String primaryId, String logId, Integer logType,
String content) {
super();
this.id = id;
this.title = title;
this.createTime = createTime;
this.primaryId = primaryId;
this.logId = logId;
this.logType = logType;
this.content = content;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getPrimaryId() {
return primaryId;
}
public void setPrimaryId(String primaryId) {
this.primaryId = primaryId;
}
public String getLogId() {
return logId;
}
public void setLogId(String logId) {
this.logId = logId;
}
public Integer getLogType() {
return logType;
}
public void setLogType(Integer logType) {
this.logType = logType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "BlogsLog [id=" + id + ", title=" + title + ", createTime=" + createTime + ", primaryId=" + primaryId
+ ", logId=" + logId + ", logType=" + logType + ", content=" + content + "]";
}
} | 1,882 | 0.650372 | 0.649841 | 100 | 16.84 | 20.208771 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.45 | false | false | 11 |
40a4670304767ed53816fbe5d87f011647771525 | 13,451,837,611,833 | bd9a7ead6dc2f04bb1cdfecbec77c2b856051ed3 | /app/src/main/java/com/msht/watersystem/functionView/AppNotSufficient.java | 38180e3b9d2bfea3f1734457ec53fa37755c248b | [] | no_license | SuYingChi/msht_waterSystem | https://github.com/SuYingChi/msht_waterSystem | 5768b116973fbab2397634f305b5a3f379e0bdcc | b6dc49be3115d68ba6e82e1e5ad46e5db9d7bb4c | refs/heads/master | 2020-03-18T13:27:54.204000 | 2018-05-25T09:44:12 | 2018-05-25T09:44:12 | 134,784,750 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.msht.watersystem.functionView;
import android.content.Context;
import android.content.Intent;
import android.os.CountDownTimer;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mcloyal.serialport.entity.Packet;
import com.mcloyal.serialport.exception.CRCException;
import com.mcloyal.serialport.exception.CmdTypeException;
import com.mcloyal.serialport.exception.FrameException;
import com.mcloyal.serialport.service.PortService;
import com.mcloyal.serialport.utils.ComServiceConnection;
import com.mcloyal.serialport.utils.FrameUtils;
import com.mcloyal.serialport.utils.PacketUtils;
import com.msht.watersystem.Base.BaseActivity;
import com.msht.watersystem.R;
import com.msht.watersystem.Utils.BitmapUtil;
import com.msht.watersystem.Utils.BusinessInstruct;
import com.msht.watersystem.Utils.ByteUtils;
import com.msht.watersystem.Utils.CachePreferencesUtil;
import com.msht.watersystem.Utils.InstructUtil;
import com.msht.watersystem.Utils.DataCalculateUtils;
import com.msht.watersystem.Utils.FormatToken;
import com.msht.watersystem.Utils.VariableUtil;
import com.msht.watersystem.widget.MyImgScroll;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
public class AppNotSufficient extends BaseActivity implements Observer, Handler.Callback {
private String mAccount="0.0";
private String afterAmount="0.0";
private String afterWater="0.0";
private boolean buyStatus=false;
private double volume=0.00;
private TextView tv_time;
private TextView tv_balance;
private TextView tv_customerNo;
private boolean bindStatus=false;
private MyImgScroll myPager;
private List<View> listViews;
private ImageView textView;
private Context mContext;
private MyCountDownTimer myCountDownTimer;// 倒计时对象
private PortService portService;
private ComServiceConnection serviceConnection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_not_sufficient);
mContext=this;
myCountDownTimer=new MyCountDownTimer(30000,1000);
initView();
initWaterQuality();
OpenService();
}
private void OpenService() {
serviceConnection = new ComServiceConnection(AppNotSufficient.this, new ComServiceConnection.ConnectionCallBack() {
@Override
public void onServiceConnected(PortService service) {
//此处给portService赋值有如下两种方式
//portService=service;
portService = serviceConnection.getService();
}
});
bindService(new Intent(mContext, PortService.class), serviceConnection,
BIND_AUTO_CREATE);
bindStatus=true;
}
@Override
public boolean handleMessage(Message msg) {
return false;
}
@Override
public void update(Observable observable, Object arg) {
PortService.MyObservable myObservable = (PortService.MyObservable) observable;
if (myObservable != null) {
boolean skeyEnable = myObservable.isSkeyEnable();
Packet packet1 = myObservable.getCom1Packet();
if (packet1 != null) {
if (Arrays.equals(packet1.getCmd(),new byte[]{0x01,0x04})){
// MyLogUtil.d("主板控制指令104:",CreateOrderType.getPacketString(packet1));
initCom104Data(packet1.getData());
}else if (Arrays.equals(packet1.getCmd(),new byte[]{0x01,0x05})){
initCom105Data(packet1.getData());
}else if (Arrays.equals(packet1.getCmd(),new byte[]{0x02,0x04})){
initCom204Data();
}
}
Packet packet2 = myObservable.getCom2Packet();
if (packet2 != null) {
if (Arrays.equals(packet2.getCmd(),new byte[]{0x02,0x05})){
initCom205Data();
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x04})){
// MyLogUtil.d("服务端控制指令104:",CreateOrderType.getPacketString(packet2));
String stringWork= DataCalculateUtils.IntToBinary(ByteUtils.byteToInt(packet2.getData().get(45)));
if (DataCalculateUtils.isRechargeData(stringWork,5,6)){
responseServer(packet2.getFrame()); //回复
}
initCom104Data2(packet2.getData());
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x02})){
response102(packet2.getFrame());
initCom102Data2(packet2.getData());
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x07})){
// MyLogUtil.d("服务端业务指令107:",CreateOrderType.getPacketString(packet2));
ResponseSever(packet2.getFrame());
initCom107Data(packet2.getData());
}
}
}
}
private void initCom204Data() {
if (buyStatus){
buyStatus=false;
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,IcCardoutWater.class); //进入刷卡购水页面
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==3){
Intent intent=new Intent(mContext,AppoutWater.class); //进入app购水页面
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==5){
Intent intent=new Intent(mContext,DeliveryOutWater.class); //进入配送取水页面
startActivityForResult(intent,1);
finish();
}
}
}
private void ResponseSever(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x07};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom107Data(ArrayList<Byte> data) {
if (BusinessInstruct.CalaculateBusiness(data)){
if (FormatToken.BusinessType==3){
FormatToken.Balance=FormatToken.Balance+FormatToken.rechargeAmount;
Intent intent=new Intent(AppNotSufficient.this,PaySuccess.class);
intent.putExtra("afterAmount",afterAmount) ;
intent.putExtra("afetrWater",afterWater);
intent.putExtra("mAccount",mAccount);
intent.putExtra("sign","2");
startActivity(intent);
finish();
}else {
VariableUtil.byteArray.clear();
VariableUtil.byteArray=data;
CachePreferencesUtil.putBoolean(this,CachePreferencesUtil.FIRST_OPEN,false);//数据更变
buyStatus=true;
if (FormatToken.BusinessType==1){
if (FormatToken.AppBalance<20){
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.Balance/100.0);
tv_balance.setText(String.valueOf(balance));
tv_customerNo.setText(FormatToken.StringCardNo);
}else {
setBusiness(1);
}
}else if (FormatToken.BusinessType==2){
setBusiness(2);
}
}
}
}
private void setBusiness(int business) {
if (portService != null) {
try {
byte[] frame = FrameUtils.getFrame(mContext);
byte[] type = new byte[]{0x01, 0x04};
if (business==1){
byte[] data= InstructUtil.setBusinessType01();
byte[] packet = PacketUtils.makePackage(frame, type, data);
portService.sendToCom1(packet);
}else if (business==2){
byte[] data= InstructUtil.setBusinessType02();
byte[] packet = PacketUtils.makePackage(frame, type, data);
portService.sendToCom1(packet);
}
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void response102(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x02};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom102Data2(ArrayList<Byte> data) {
if (BusinessInstruct.ControlModel(mContext,data)){
if (FormatToken.ShowTDS==0){
layout_TDS.setVisibility(View.GONE);
}else {
layout_TDS.setVisibility(View.VISIBLE);
}
}
}
private void initCom104Data(ArrayList<Byte> data) {
try {
if(InstructUtil.ControlInstruct(data)){
String stringWork= DataCalculateUtils.IntToBinary(FormatToken.Updateflag3);
if (!DataCalculateUtils.isEvent(stringWork,3)){
if (FormatToken.Balance<=1){
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,NotSufficient.class);
startActivityForResult(intent,1);
finish();
}else {
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.Balance/100.0);
tv_balance.setText(String.valueOf(balance));
}
}else {
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,IcCardoutWater.class);
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==3){
Intent intent=new Intent(mContext,AppoutWater.class);
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==5){
Intent intent=new Intent(mContext,DeliveryOutWater.class);
startActivityForResult(intent,1);
finish();
}
}
}else {
if (FormatToken.ConsumptionType==1){
//刷卡结账
CalculateData(); //没联网计算取缓存数据
double consumption=FormatToken.ConsumptionAmount/100.0;
double waterVolume=FormatToken.WaterYield*volume;
String afterAmount=String.valueOf(DataCalculateUtils.TwoDecinmal2(consumption));
String afterWater=String.valueOf(DataCalculateUtils.TwoDecinmal2(waterVolume));
String mAccount=String.valueOf(FormatToken.StringCardNo);
Intent intent=new Intent(mContext,PaySuccess.class);
intent.putExtra("afterAmount",afterAmount) ;
intent.putExtra("afetrWater",afterWater);
intent.putExtra("mAccount",mAccount);
intent.putExtra("sign","0");
startActivityForResult(intent,1);
myCountDownTimer.cancel();
finish();
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private void CalculateData() {
String waterVolume= CachePreferencesUtil.getStringData(this,CachePreferencesUtil.Volume,"5");
String Time=CachePreferencesUtil.getStringData(this,CachePreferencesUtil.outWaterTime,"30");
int mVolume=Integer.valueOf(waterVolume).intValue();
int mTime=Integer.valueOf(Time).intValue();
volume=DataCalculateUtils.getWaterVolume(mVolume,mTime);
}
private void responseServer(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x04};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom105Data(ArrayList<Byte> data) {
try {
if (InstructUtil.StatusInstruct(data)){
tv_InTDS.setText(String.valueOf(FormatToken.OriginTDS));
tv_OutTDS.setText(String.valueOf(FormatToken.PurificationTDS));
String stringWork= DataCalculateUtils.IntToBinary(FormatToken.WorkState);
if (!DataCalculateUtils.isEvent(stringWork,6)){
Intent intent=new Intent(mContext, CannotBuywater.class);
startActivityForResult(intent,1);
CloseService();
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private void initCom205Data() {
}
private void initCom104Data2(ArrayList<Byte> data) {
String stringWork= DataCalculateUtils.IntToBinary(ByteUtils.byteToInt(data.get(45)));
int Switch=ByteUtils.byteToInt(data.get(31));
if (Switch==2&&DataCalculateUtils.isEvent(stringWork,0)){
Intent intent=new Intent(mContext, CloseSystem.class);
startActivityForResult(intent,1);
finish();
}
}
private void CloseService(){
if (serviceConnection != null && portService != null) {
if (bindStatus){
bindStatus=false;
portService.removeObserver(this);
unbindService(serviceConnection);
}
}
}
class MyCountDownTimer extends CountDownTimer {
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) { //计时过程
tv_time.setText(millisUntilFinished/1000+"");
}
@Override
public void onFinish() {
finish();
}
}
private void initView() {
tv_time=(TextView)findViewById(R.id.id_time) ;
tv_balance=(TextView)findViewById(R.id.id_balance_amount);
tv_customerNo=(TextView)findViewById(R.id.id_tv_customerNo);
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.AppBalance/100.0);
tv_balance.setText(String.valueOf(balance));
tv_customerNo.setText(FormatToken.StringCardNo);
myCountDownTimer.start();
}
private void endTimeCount(){
if (myCountDownTimer != null) {
myCountDownTimer.cancel();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode== KeyEvent.KEYCODE_BACK&& event.getRepeatCount()==0){
showTips();
return false;
}else if (keyCode==KeyEvent.KEYCODE_MENU){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_DPAD_UP){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_F1){
showTips();
}
return true;
}
private void showTips() {
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
CloseService();
endTimeCount();
}
}
| UTF-8 | Java | 17,043 | java | AppNotSufficient.java | Java | [] | null | [] | package com.msht.watersystem.functionView;
import android.content.Context;
import android.content.Intent;
import android.os.CountDownTimer;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mcloyal.serialport.entity.Packet;
import com.mcloyal.serialport.exception.CRCException;
import com.mcloyal.serialport.exception.CmdTypeException;
import com.mcloyal.serialport.exception.FrameException;
import com.mcloyal.serialport.service.PortService;
import com.mcloyal.serialport.utils.ComServiceConnection;
import com.mcloyal.serialport.utils.FrameUtils;
import com.mcloyal.serialport.utils.PacketUtils;
import com.msht.watersystem.Base.BaseActivity;
import com.msht.watersystem.R;
import com.msht.watersystem.Utils.BitmapUtil;
import com.msht.watersystem.Utils.BusinessInstruct;
import com.msht.watersystem.Utils.ByteUtils;
import com.msht.watersystem.Utils.CachePreferencesUtil;
import com.msht.watersystem.Utils.InstructUtil;
import com.msht.watersystem.Utils.DataCalculateUtils;
import com.msht.watersystem.Utils.FormatToken;
import com.msht.watersystem.Utils.VariableUtil;
import com.msht.watersystem.widget.MyImgScroll;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
public class AppNotSufficient extends BaseActivity implements Observer, Handler.Callback {
private String mAccount="0.0";
private String afterAmount="0.0";
private String afterWater="0.0";
private boolean buyStatus=false;
private double volume=0.00;
private TextView tv_time;
private TextView tv_balance;
private TextView tv_customerNo;
private boolean bindStatus=false;
private MyImgScroll myPager;
private List<View> listViews;
private ImageView textView;
private Context mContext;
private MyCountDownTimer myCountDownTimer;// 倒计时对象
private PortService portService;
private ComServiceConnection serviceConnection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_app_not_sufficient);
mContext=this;
myCountDownTimer=new MyCountDownTimer(30000,1000);
initView();
initWaterQuality();
OpenService();
}
private void OpenService() {
serviceConnection = new ComServiceConnection(AppNotSufficient.this, new ComServiceConnection.ConnectionCallBack() {
@Override
public void onServiceConnected(PortService service) {
//此处给portService赋值有如下两种方式
//portService=service;
portService = serviceConnection.getService();
}
});
bindService(new Intent(mContext, PortService.class), serviceConnection,
BIND_AUTO_CREATE);
bindStatus=true;
}
@Override
public boolean handleMessage(Message msg) {
return false;
}
@Override
public void update(Observable observable, Object arg) {
PortService.MyObservable myObservable = (PortService.MyObservable) observable;
if (myObservable != null) {
boolean skeyEnable = myObservable.isSkeyEnable();
Packet packet1 = myObservable.getCom1Packet();
if (packet1 != null) {
if (Arrays.equals(packet1.getCmd(),new byte[]{0x01,0x04})){
// MyLogUtil.d("主板控制指令104:",CreateOrderType.getPacketString(packet1));
initCom104Data(packet1.getData());
}else if (Arrays.equals(packet1.getCmd(),new byte[]{0x01,0x05})){
initCom105Data(packet1.getData());
}else if (Arrays.equals(packet1.getCmd(),new byte[]{0x02,0x04})){
initCom204Data();
}
}
Packet packet2 = myObservable.getCom2Packet();
if (packet2 != null) {
if (Arrays.equals(packet2.getCmd(),new byte[]{0x02,0x05})){
initCom205Data();
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x04})){
// MyLogUtil.d("服务端控制指令104:",CreateOrderType.getPacketString(packet2));
String stringWork= DataCalculateUtils.IntToBinary(ByteUtils.byteToInt(packet2.getData().get(45)));
if (DataCalculateUtils.isRechargeData(stringWork,5,6)){
responseServer(packet2.getFrame()); //回复
}
initCom104Data2(packet2.getData());
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x02})){
response102(packet2.getFrame());
initCom102Data2(packet2.getData());
}else if (Arrays.equals(packet2.getCmd(),new byte[]{0x01,0x07})){
// MyLogUtil.d("服务端业务指令107:",CreateOrderType.getPacketString(packet2));
ResponseSever(packet2.getFrame());
initCom107Data(packet2.getData());
}
}
}
}
private void initCom204Data() {
if (buyStatus){
buyStatus=false;
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,IcCardoutWater.class); //进入刷卡购水页面
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==3){
Intent intent=new Intent(mContext,AppoutWater.class); //进入app购水页面
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==5){
Intent intent=new Intent(mContext,DeliveryOutWater.class); //进入配送取水页面
startActivityForResult(intent,1);
finish();
}
}
}
private void ResponseSever(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x07};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom107Data(ArrayList<Byte> data) {
if (BusinessInstruct.CalaculateBusiness(data)){
if (FormatToken.BusinessType==3){
FormatToken.Balance=FormatToken.Balance+FormatToken.rechargeAmount;
Intent intent=new Intent(AppNotSufficient.this,PaySuccess.class);
intent.putExtra("afterAmount",afterAmount) ;
intent.putExtra("afetrWater",afterWater);
intent.putExtra("mAccount",mAccount);
intent.putExtra("sign","2");
startActivity(intent);
finish();
}else {
VariableUtil.byteArray.clear();
VariableUtil.byteArray=data;
CachePreferencesUtil.putBoolean(this,CachePreferencesUtil.FIRST_OPEN,false);//数据更变
buyStatus=true;
if (FormatToken.BusinessType==1){
if (FormatToken.AppBalance<20){
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.Balance/100.0);
tv_balance.setText(String.valueOf(balance));
tv_customerNo.setText(FormatToken.StringCardNo);
}else {
setBusiness(1);
}
}else if (FormatToken.BusinessType==2){
setBusiness(2);
}
}
}
}
private void setBusiness(int business) {
if (portService != null) {
try {
byte[] frame = FrameUtils.getFrame(mContext);
byte[] type = new byte[]{0x01, 0x04};
if (business==1){
byte[] data= InstructUtil.setBusinessType01();
byte[] packet = PacketUtils.makePackage(frame, type, data);
portService.sendToCom1(packet);
}else if (business==2){
byte[] data= InstructUtil.setBusinessType02();
byte[] packet = PacketUtils.makePackage(frame, type, data);
portService.sendToCom1(packet);
}
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void response102(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x02};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom102Data2(ArrayList<Byte> data) {
if (BusinessInstruct.ControlModel(mContext,data)){
if (FormatToken.ShowTDS==0){
layout_TDS.setVisibility(View.GONE);
}else {
layout_TDS.setVisibility(View.VISIBLE);
}
}
}
private void initCom104Data(ArrayList<Byte> data) {
try {
if(InstructUtil.ControlInstruct(data)){
String stringWork= DataCalculateUtils.IntToBinary(FormatToken.Updateflag3);
if (!DataCalculateUtils.isEvent(stringWork,3)){
if (FormatToken.Balance<=1){
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,NotSufficient.class);
startActivityForResult(intent,1);
finish();
}else {
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.Balance/100.0);
tv_balance.setText(String.valueOf(balance));
}
}else {
if (FormatToken.ConsumptionType==1){
Intent intent=new Intent(mContext,IcCardoutWater.class);
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==3){
Intent intent=new Intent(mContext,AppoutWater.class);
startActivityForResult(intent,1);
finish();
}else if (FormatToken.ConsumptionType==5){
Intent intent=new Intent(mContext,DeliveryOutWater.class);
startActivityForResult(intent,1);
finish();
}
}
}else {
if (FormatToken.ConsumptionType==1){
//刷卡结账
CalculateData(); //没联网计算取缓存数据
double consumption=FormatToken.ConsumptionAmount/100.0;
double waterVolume=FormatToken.WaterYield*volume;
String afterAmount=String.valueOf(DataCalculateUtils.TwoDecinmal2(consumption));
String afterWater=String.valueOf(DataCalculateUtils.TwoDecinmal2(waterVolume));
String mAccount=String.valueOf(FormatToken.StringCardNo);
Intent intent=new Intent(mContext,PaySuccess.class);
intent.putExtra("afterAmount",afterAmount) ;
intent.putExtra("afetrWater",afterWater);
intent.putExtra("mAccount",mAccount);
intent.putExtra("sign","0");
startActivityForResult(intent,1);
myCountDownTimer.cancel();
finish();
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private void CalculateData() {
String waterVolume= CachePreferencesUtil.getStringData(this,CachePreferencesUtil.Volume,"5");
String Time=CachePreferencesUtil.getStringData(this,CachePreferencesUtil.outWaterTime,"30");
int mVolume=Integer.valueOf(waterVolume).intValue();
int mTime=Integer.valueOf(Time).intValue();
volume=DataCalculateUtils.getWaterVolume(mVolume,mTime);
}
private void responseServer(byte[] frame) {
if (portService != null) {
try {
byte[] type = new byte[]{0x02, 0x04};
byte[] packet = PacketUtils.makePackage(frame, type, null);
portService.sendToCom2(packet);
} catch (CRCException e) {
e.printStackTrace();
} catch (FrameException e) {
e.printStackTrace();
} catch (CmdTypeException e) {
e.printStackTrace();
}
}
}
private void initCom105Data(ArrayList<Byte> data) {
try {
if (InstructUtil.StatusInstruct(data)){
tv_InTDS.setText(String.valueOf(FormatToken.OriginTDS));
tv_OutTDS.setText(String.valueOf(FormatToken.PurificationTDS));
String stringWork= DataCalculateUtils.IntToBinary(FormatToken.WorkState);
if (!DataCalculateUtils.isEvent(stringWork,6)){
Intent intent=new Intent(mContext, CannotBuywater.class);
startActivityForResult(intent,1);
CloseService();
}
}
}catch (Exception e){
e.printStackTrace();
}
}
private void initCom205Data() {
}
private void initCom104Data2(ArrayList<Byte> data) {
String stringWork= DataCalculateUtils.IntToBinary(ByteUtils.byteToInt(data.get(45)));
int Switch=ByteUtils.byteToInt(data.get(31));
if (Switch==2&&DataCalculateUtils.isEvent(stringWork,0)){
Intent intent=new Intent(mContext, CloseSystem.class);
startActivityForResult(intent,1);
finish();
}
}
private void CloseService(){
if (serviceConnection != null && portService != null) {
if (bindStatus){
bindStatus=false;
portService.removeObserver(this);
unbindService(serviceConnection);
}
}
}
class MyCountDownTimer extends CountDownTimer {
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) { //计时过程
tv_time.setText(millisUntilFinished/1000+"");
}
@Override
public void onFinish() {
finish();
}
}
private void initView() {
tv_time=(TextView)findViewById(R.id.id_time) ;
tv_balance=(TextView)findViewById(R.id.id_balance_amount);
tv_customerNo=(TextView)findViewById(R.id.id_tv_customerNo);
double balance= DataCalculateUtils.TwoDecinmal2(FormatToken.AppBalance/100.0);
tv_balance.setText(String.valueOf(balance));
tv_customerNo.setText(FormatToken.StringCardNo);
myCountDownTimer.start();
}
private void endTimeCount(){
if (myCountDownTimer != null) {
myCountDownTimer.cancel();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode== KeyEvent.KEYCODE_BACK&& event.getRepeatCount()==0){
showTips();
return false;
}else if (keyCode==KeyEvent.KEYCODE_MENU){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_DPAD_UP){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
showTips();
}else if (keyCode==KeyEvent.KEYCODE_F1){
showTips();
}
return true;
}
private void showTips() {
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
CloseService();
endTimeCount();
}
}
| 17,043 | 0.574418 | 0.559421 | 405 | 40.656792 | 24.690844 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.735802 | false | false | 11 |
6cd196a6efe8aa8ac4aa6bd06152c029d4a14c74 | 30,434,138,313,969 | 54ce49f27a04fbdabe76ec7b43471134909932d3 | /chapter_001/src/main/java/ru/job4j/loop/Board.java | f4f9c9e22b66ea50d9ab5e8d8f07ef0f9f083375 | [
"Apache-2.0"
] | permissive | IvanPJF/job4j | https://github.com/IvanPJF/job4j | a3c8ce587fad7f42d58e6614455c48608d4df9f0 | 1451f98bbbe70ab1afdb5f8c625e810680620989 | refs/heads/master | 2022-09-19T16:32:18.492000 | 2020-03-01T17:42:54 | 2020-03-01T17:42:54 | 147,117,520 | 0 | 0 | Apache-2.0 | false | 2022-09-08T01:00:16 | 2018-09-02T20:00:51 | 2020-03-04T11:27:19 | 2022-09-08T01:00:13 | 485 | 0 | 0 | 7 | Java | false | false | package ru.job4j.loop;
/**Построение шахматной доски в псевдографике.
*@author IvanPJF (teaching-light@yandex.ru)
*@since 12.09.2018
*@version 0.1
*/
public class Board {
/**
* Строит шахматную доску в псевдографике.
* @param width ширина доски.
* @param height высота доски.
* @return построенная доска.
*/
public String paint(int width, int height) {
StringBuilder screen = new StringBuilder();
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if ((i + j) % 2 == 0) {
screen.append("X");
} else {
screen.append(" ");
}
}
screen.append(System.lineSeparator());
}
return screen.toString();
}
} | UTF-8 | Java | 922 | java | Board.java | Java | [
{
"context": "троение шахматной доски в псевдографике.\n *@author IvanPJF (teaching-light@yandex.ru)\n *@since 12.09.2018\n *",
"end": 88,
"score": 0.9690541625022888,
"start": 81,
"tag": "USERNAME",
"value": "IvanPJF"
},
{
"context": "хматной доски в псевдографике.\n *@author IvanPJF (teaching-light@yandex.ru)\n *@since 12.09.2018\n *@version 0.1\n */\npublic cl",
"end": 114,
"score": 0.9999269247055054,
"start": 90,
"tag": "EMAIL",
"value": "teaching-light@yandex.ru"
}
] | null | [] | package ru.job4j.loop;
/**Построение шахматной доски в псевдографике.
*@author IvanPJF (<EMAIL>)
*@since 12.09.2018
*@version 0.1
*/
public class Board {
/**
* Строит шахматную доску в псевдографике.
* @param width ширина доски.
* @param height высота доски.
* @return построенная доска.
*/
public String paint(int width, int height) {
StringBuilder screen = new StringBuilder();
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if ((i + j) % 2 == 0) {
screen.append("X");
} else {
screen.append(" ");
}
}
screen.append(System.lineSeparator());
}
return screen.toString();
}
} | 905 | 0.508621 | 0.490148 | 30 | 26.1 | 16.931923 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.366667 | false | false | 11 |
207b6222d2bf639e8758addbd55e8df69ad847ea | 33,509,334,895,453 | d575b3bcad08655f86c33b8881dbabfaaa72a270 | /edu/asu/jmars/layer/streets/StreetLView.java | 7e0c963b7512d254c15049b814dcfb90d0805b31 | [] | no_license | cryptowealth-technology/jmars_clone | https://github.com/cryptowealth-technology/jmars_clone | c99f91dca54ed8bea904bd82329bd2ae1b2ff5c3 | 67a51cb938c717cd1b92514f6724aa3c9a92d19e | refs/heads/master | 2022-03-28T16:17:07.765000 | 2019-12-20T02:42:10 | 2019-12-20T02:42:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.asu.jmars.layer.streets;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.terracotta.statistics.Time;
import edu.asu.jmars.layer.LayerParameters;
import edu.asu.jmars.layer.SerializedParameters;
import edu.asu.jmars.layer.Layer.LView;
import edu.asu.jmars.util.Util;
public class StreetLView extends LView {
private StreetLayer layer;
private static final String VIEW_SETTINGS_KEY = "open_street_map";
private int osmType;
public StreetLView(StreetLayer layer, LayerParameters lp) {
super(layer);
this.layer = layer;
setLayerParameters(lp);
osmType = layer.getOsmType();
}
public SerializedParameters getInitialLayerData() {
return (StreetLViewSettings) getLayer().streetSettings;
}
protected LView _new() {
// Create a copy of ourself for use in the panner-view.
return new StreetLView((StreetLayer) getLayer(), getLayerParameters());
}
double lastUpdate = 0.00;
public void viewChanged() {
//creates a time stamp for re-drawing the screen. So it will not draw right away. This
//helps with min/max the screen as well as panning around.
try {
lastUpdate = Time.time();
Thread.sleep(600);
double currentUpdate = Time.time();
double timeLapse = currentUpdate - lastUpdate;
if (timeLapse <600){
return;
}else {
super.viewChanged();
lastUpdate = currentUpdate;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
protected Object createRequest(Rectangle2D where) {
//System.out.println("StreetLView.createRequest()");
//Get the Bounding box of the mainview/panner
int jmarsZoom = viewman.getProj().getPPD();
Rectangle2D here = viewman.getProj().getWorldWindow();
Rectangle screenHere = viewman.getProj().getScreenWindow();
Point2D spatialNW = viewman.getProj().world.toSpatial(here.getMinX(),
here.getMaxY());
Point2D spatialSE = viewman.getProj().world.toSpatial(here.getMaxX(),
here.getMinY());
Point2D spatialCenter = viewman.getProj().world.toSpatial(here.getCenterX(), here.getCenterY());
double westLon = 360 - spatialNW.getX();
westLon = (westLon > 180) ? westLon - 360.0 : westLon;
double eastLon = 360 - spatialSE.getX();
eastLon = (eastLon > 180) ? eastLon - 360.0 : eastLon;
double northLat = spatialNW.getY();
double southLat = spatialSE.getY();
final BoundingBoxDataObject boundingBox = new BoundingBoxDataObject(screenHere, spatialCenter, westLon, eastLon, northLat, southLat, jmarsZoom);
return boundingBox;
}
public void receiveData(Object layerData) {
/* Here the object needs to be pasted to offScreen and repaint
* needs to be called to draw to the screen
*/
OpenStreetMapTiles osm = (OpenStreetMapTiles) layerData;
//System.out.println("StreetLView.receiveData()");
Graphics2D g2 = getOffScreenG2Direct();
if (g2==null)
return;
double yTileLat = osm.getOdetic2ocenN1();
double xTileLon = osm.getxTileLonW();
Point2D screenPoint = viewman.getProj().spatial.toScreen(360-xTileLon, yTileLat);
int rasterX1 = (int) screenPoint.getX();
int rasterY1 = (int) screenPoint.getY();
g2.drawImage(osm.getScaledImage1(), null, rasterX1 , rasterY1);
repaint();
layer.setStatus(Util.darkGreen);
}
public void setLayerParameters(LayerParameters lp){
layerParams=lp;
layer.streetSettings.layerParams = lp;
}
public StreetLayer getLayer() {
return layer;
}
public void setLayer(StreetLayer layer) {
this.layer = layer;
}
public String getName() {
if (osmType == 0){
return "MapQuest/OSM Satellite Tiles";
}else if (osmType ==1){
return "MapQuest/OSM Map Tiles";
}
return "MapQuest-OpenStreetMap";
}
}
| UTF-8 | Java | 3,976 | java | StreetLView.java | Java | [
{
"context": "\tprivate static final String VIEW_SETTINGS_KEY = \"open_street_map\";\r\n\tprivate int osmType;\r\n\t\r\n\tpublic StreetLView(",
"end": 518,
"score": 0.7099984884262085,
"start": 503,
"tag": "KEY",
"value": "open_street_map"
}
] | null | [] | package edu.asu.jmars.layer.streets;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.terracotta.statistics.Time;
import edu.asu.jmars.layer.LayerParameters;
import edu.asu.jmars.layer.SerializedParameters;
import edu.asu.jmars.layer.Layer.LView;
import edu.asu.jmars.util.Util;
public class StreetLView extends LView {
private StreetLayer layer;
private static final String VIEW_SETTINGS_KEY = "open_street_map";
private int osmType;
public StreetLView(StreetLayer layer, LayerParameters lp) {
super(layer);
this.layer = layer;
setLayerParameters(lp);
osmType = layer.getOsmType();
}
public SerializedParameters getInitialLayerData() {
return (StreetLViewSettings) getLayer().streetSettings;
}
protected LView _new() {
// Create a copy of ourself for use in the panner-view.
return new StreetLView((StreetLayer) getLayer(), getLayerParameters());
}
double lastUpdate = 0.00;
public void viewChanged() {
//creates a time stamp for re-drawing the screen. So it will not draw right away. This
//helps with min/max the screen as well as panning around.
try {
lastUpdate = Time.time();
Thread.sleep(600);
double currentUpdate = Time.time();
double timeLapse = currentUpdate - lastUpdate;
if (timeLapse <600){
return;
}else {
super.viewChanged();
lastUpdate = currentUpdate;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
protected Object createRequest(Rectangle2D where) {
//System.out.println("StreetLView.createRequest()");
//Get the Bounding box of the mainview/panner
int jmarsZoom = viewman.getProj().getPPD();
Rectangle2D here = viewman.getProj().getWorldWindow();
Rectangle screenHere = viewman.getProj().getScreenWindow();
Point2D spatialNW = viewman.getProj().world.toSpatial(here.getMinX(),
here.getMaxY());
Point2D spatialSE = viewman.getProj().world.toSpatial(here.getMaxX(),
here.getMinY());
Point2D spatialCenter = viewman.getProj().world.toSpatial(here.getCenterX(), here.getCenterY());
double westLon = 360 - spatialNW.getX();
westLon = (westLon > 180) ? westLon - 360.0 : westLon;
double eastLon = 360 - spatialSE.getX();
eastLon = (eastLon > 180) ? eastLon - 360.0 : eastLon;
double northLat = spatialNW.getY();
double southLat = spatialSE.getY();
final BoundingBoxDataObject boundingBox = new BoundingBoxDataObject(screenHere, spatialCenter, westLon, eastLon, northLat, southLat, jmarsZoom);
return boundingBox;
}
public void receiveData(Object layerData) {
/* Here the object needs to be pasted to offScreen and repaint
* needs to be called to draw to the screen
*/
OpenStreetMapTiles osm = (OpenStreetMapTiles) layerData;
//System.out.println("StreetLView.receiveData()");
Graphics2D g2 = getOffScreenG2Direct();
if (g2==null)
return;
double yTileLat = osm.getOdetic2ocenN1();
double xTileLon = osm.getxTileLonW();
Point2D screenPoint = viewman.getProj().spatial.toScreen(360-xTileLon, yTileLat);
int rasterX1 = (int) screenPoint.getX();
int rasterY1 = (int) screenPoint.getY();
g2.drawImage(osm.getScaledImage1(), null, rasterX1 , rasterY1);
repaint();
layer.setStatus(Util.darkGreen);
}
public void setLayerParameters(LayerParameters lp){
layerParams=lp;
layer.streetSettings.layerParams = lp;
}
public StreetLayer getLayer() {
return layer;
}
public void setLayer(StreetLayer layer) {
this.layer = layer;
}
public String getName() {
if (osmType == 0){
return "MapQuest/OSM Satellite Tiles";
}else if (osmType ==1){
return "MapQuest/OSM Map Tiles";
}
return "MapQuest-OpenStreetMap";
}
}
| 3,976 | 0.681087 | 0.667253 | 147 | 25 | 25.463326 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.129252 | false | false | 11 |
52d2c0c86c5a5aaeb0263f61024b7955f59b4a90 | 5,643,587,058,654 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/27/27_77ef30a94f76590aac14dc8097c63715bc872c60/Locales/27_77ef30a94f76590aac14dc8097c63715bc872c60_Locales_t.java | 0ad72a9906fb58542dcdaa4038630eeb85b8dcd2 | [] | no_license | zhongxingyu/Seer | https://github.com/zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false | /*
* Demoiselle Framework
* Copyright (C) 2010 SERPRO
* ----------------------------------------------------------------------------
* This file is part of Demoiselle Framework.
*
* Demoiselle Framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
* ----------------------------------------------------------------------------
* Este arquivo é parte do Framework Demoiselle.
*
* O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
* modificá-lo dentro dos termos da Licença Pública Geral GNU como publicada pela Fundação
* do Software Livre (FSF); na versão 2 da Licença.
*
* Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
* GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
* APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/GPL em português
* para maiores detalhes.
*
* Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título
* "LICENCA.txt", junto com esse programa. Se não, acesse o Portal do Software Público
* Brasileiro no endereço www.softwarepublico.gov.br ou escreva para a Fundação do Software
* Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
*/
package br.gov.frameworkdemoiselle.util;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Locale;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
/**
* Utility class to configure the Locale.
*
* @author SERPRO
* */
@Named
@SessionScoped
public class Locales implements Serializable {
private static final long serialVersionUID = 1L;
private static final Locale PT_BR = new Locale("pt", "BR");
private Locale locale = Locale.getDefault();
@Inject
private FacesContext facesContext;
/**
* Set the language to "en_US". This is a shorthand to <code>setLocale(Locale.US)</code>.
*/
public void setEnglish() {
setCurrentLocale(Locale.US);
}
/**
* Set the language to "pt_BR". This is a shorthand to <code>setLocale(Locales.PT_BR)</code>.
*/
public void setPortuguese() {
setCurrentLocale(PT_BR);
}
/**
* @return The current locale, or {@link Locale#getDefault()} if one has not been set.
*/
public Locale getCurrentLocale(){
return this.locale!=null ? this.locale : Locale.getDefault();
}
/**
* Set the locale for the current view
*
* @param locale The new locale
*/
public void setCurrentLocale(Locale locale) {
Iterator<Locale> supportedLocales = getContext().getApplication().getSupportedLocales();
if (supportedLocales==null){
this.locale = locale;
getContext().getViewRoot().setLocale(this.locale);
}
else{
boolean selectedLocale = false;
while(supportedLocales.hasNext()){
Locale supportedLocale = supportedLocales.next();
if (supportedLocale.equals(locale)){
this.locale = locale;
getContext().getViewRoot().setLocale(this.locale);
selectedLocale = true;
break;
}
}
if (!selectedLocale && this.locale==null){
this.locale = Locale.getDefault();
}
}
}
/**
* Set the locale for the current view. The language will be parsed
* into an instance of {@link Locale} and then {@link #setLocale(Locale locale)} will
* be called using the parsed language.
*
* @param language String language code that will be parsed into a locale.
*/
public void setCurrentLocale(String language){
Locale locale = new Locale(language);
setCurrentLocale(locale);
}
/**
* Set the default locale for the entire application. After this call
* all views from this application will use this locale (unless a specific
* session defined a different locale using {@link #setLocale(Locale locale)}).
*
* @param locale The locale to set
*/
public void setApplicationLocale(Locale locale) {
setCurrentLocale(locale);
getContext().getApplication().setDefaultLocale(this.locale);
}
private FacesContext getContext(){
if (facesContext==null){
facesContext = Beans.getReference(FacesContext.class);
}
return facesContext;
}
}
| UTF-8 | Java | 4,911 | java | 27_77ef30a94f76590aac14dc8097c63715bc872c60_Locales_t.java | Java | [
{
"context": "/*\n * Demoiselle Framework\n * Copyright (C) 2010 SERPRO\n * ---------------------------------------------",
"end": 58,
"score": 0.9066389799118042,
"start": 52,
"tag": "USERNAME",
"value": "SERPRO"
},
{
"context": "ty class to configure the Locale.\n * \n * @author SERPRO\n * */\n @Named\n @SessionScoped\n public class Loca",
"end": 2238,
"score": 0.9995323419570923,
"start": 2232,
"tag": "USERNAME",
"value": "SERPRO"
}
] | null | [] | /*
* Demoiselle Framework
* Copyright (C) 2010 SERPRO
* ----------------------------------------------------------------------------
* This file is part of Demoiselle Framework.
*
* Demoiselle Framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
* ----------------------------------------------------------------------------
* Este arquivo é parte do Framework Demoiselle.
*
* O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
* modificá-lo dentro dos termos da Licença Pública Geral GNU como publicada pela Fundação
* do Software Livre (FSF); na versão 2 da Licença.
*
* Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
* GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
* APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/GPL em português
* para maiores detalhes.
*
* Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título
* "LICENCA.txt", junto com esse programa. Se não, acesse o Portal do Software Público
* Brasileiro no endereço www.softwarepublico.gov.br ou escreva para a Fundação do Software
* Livre (FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
*/
package br.gov.frameworkdemoiselle.util;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Locale;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
/**
* Utility class to configure the Locale.
*
* @author SERPRO
* */
@Named
@SessionScoped
public class Locales implements Serializable {
private static final long serialVersionUID = 1L;
private static final Locale PT_BR = new Locale("pt", "BR");
private Locale locale = Locale.getDefault();
@Inject
private FacesContext facesContext;
/**
* Set the language to "en_US". This is a shorthand to <code>setLocale(Locale.US)</code>.
*/
public void setEnglish() {
setCurrentLocale(Locale.US);
}
/**
* Set the language to "pt_BR". This is a shorthand to <code>setLocale(Locales.PT_BR)</code>.
*/
public void setPortuguese() {
setCurrentLocale(PT_BR);
}
/**
* @return The current locale, or {@link Locale#getDefault()} if one has not been set.
*/
public Locale getCurrentLocale(){
return this.locale!=null ? this.locale : Locale.getDefault();
}
/**
* Set the locale for the current view
*
* @param locale The new locale
*/
public void setCurrentLocale(Locale locale) {
Iterator<Locale> supportedLocales = getContext().getApplication().getSupportedLocales();
if (supportedLocales==null){
this.locale = locale;
getContext().getViewRoot().setLocale(this.locale);
}
else{
boolean selectedLocale = false;
while(supportedLocales.hasNext()){
Locale supportedLocale = supportedLocales.next();
if (supportedLocale.equals(locale)){
this.locale = locale;
getContext().getViewRoot().setLocale(this.locale);
selectedLocale = true;
break;
}
}
if (!selectedLocale && this.locale==null){
this.locale = Locale.getDefault();
}
}
}
/**
* Set the locale for the current view. The language will be parsed
* into an instance of {@link Locale} and then {@link #setLocale(Locale locale)} will
* be called using the parsed language.
*
* @param language String language code that will be parsed into a locale.
*/
public void setCurrentLocale(String language){
Locale locale = new Locale(language);
setCurrentLocale(locale);
}
/**
* Set the default locale for the entire application. After this call
* all views from this application will use this locale (unless a specific
* session defined a different locale using {@link #setLocale(Locale locale)}).
*
* @param locale The locale to set
*/
public void setApplicationLocale(Locale locale) {
setCurrentLocale(locale);
getContext().getApplication().setDefaultLocale(this.locale);
}
private FacesContext getContext(){
if (facesContext==null){
facesContext = Beans.getReference(FacesContext.class);
}
return facesContext;
}
}
| 4,911 | 0.680607 | 0.674662 | 147 | 32.176872 | 28.920181 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.380952 | false | false | 11 |
5091a5f6f6d366dc2ce4d0d645722fde68c730e6 | 5,377,299,093,991 | 5b6155848651d3be3291b02f5600385f8890faae | /src/main/java/com/tiago/vinhos/vinhos/model/Vinho.java | 03a5136e079ed33232ac7b2acbafc3234d672b48 | [] | no_license | tiago123456789/vinhos | https://github.com/tiago123456789/vinhos | 15eda7e3fcbd78d110517f0cf7f80bc9a1914693 | bcd21640a58aea3d0e101d6f62c4bd362bf7d18f | refs/heads/master | 2020-03-11T03:58:09.518000 | 2018-04-21T02:15:58 | 2018-04-21T02:15:58 | 129,763,960 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tiago.vinhos.vinhos.model;
import org.springframework.format.annotation.NumberFormat;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Objects;
@Entity
@Table(name = "vinhos")
public class Vinho {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotEmpty
private String nome;
@NotNull
@NumberFormat(pattern = "#,##0.00")
private BigDecimal valor;
@NotNull
@Enumerated(EnumType.STRING)
private TipoVinho tipo;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public BigDecimal getValor() {
return valor;
}
public void setValor(BigDecimal valor) {
this.valor = valor;
}
public TipoVinho getTipo() {
return tipo;
}
public void setTipo(TipoVinho tipo) {
this.tipo = tipo;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Vinho vinho = (Vinho) o;
return Objects.equals(id, vinho.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
| UTF-8 | Java | 1,462 | java | Vinho.java | Java | [] | null | [] | package com.tiago.vinhos.vinhos.model;
import org.springframework.format.annotation.NumberFormat;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Objects;
@Entity
@Table(name = "vinhos")
public class Vinho {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotEmpty
private String nome;
@NotNull
@NumberFormat(pattern = "#,##0.00")
private BigDecimal valor;
@NotNull
@Enumerated(EnumType.STRING)
private TipoVinho tipo;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public BigDecimal getValor() {
return valor;
}
public void setValor(BigDecimal valor) {
this.valor = valor;
}
public TipoVinho getTipo() {
return tipo;
}
public void setTipo(TipoVinho tipo) {
this.tipo = tipo;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Vinho vinho = (Vinho) o;
return Objects.equals(id, vinho.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
| 1,462 | 0.617647 | 0.615595 | 75 | 18.493334 | 16.663231 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.373333 | false | false | 11 |
cacdd3e9720034bab3b1ce97dde92d266374ba24 | 21,818,433,881,595 | a2a628bce6379ed7637c1352f81448c26af44db0 | /app/src/main/java/com/example/sun/zhangxun/http/ApiService.java | f44297fcf2b8cae755ffa741e83dc5c8990e7176 | [] | no_license | SliySun/ZhangXun | https://github.com/SliySun/ZhangXun | 5f025802237c00df920e31941f7f07c3d4bcbc92 | 3f52a8ab839f07a1758a303911e6bb29eee2bb9f | refs/heads/master | 2021-01-23T06:21:07.067000 | 2017-05-29T17:58:29 | 2017-05-29T17:58:29 | 86,360,128 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.sun.zhangxun.http;
import com.example.sun.zhangxun.bean.News;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
/**
* Created by sun on 2017/4/21.
*/
public interface ApiService {
String BASE_URL2 = "http://v.juhe.cn/toutiao/";
String APP_KEY="a611e344442a2f60d53941f21d03b9db";
String[] PARAM_URLS = {"top","shehui","guonei","guoji","yule","tiyu","junshi","keji","caijing","shishang"};
@GET("index")
Observable<News> getNewsRxjava(@Query("type") String type ,@Query("key") String key);
}
| UTF-8 | Java | 575 | java | ApiService.java | Java | [
{
"context": " \"http://v.juhe.cn/toutiao/\";\n String APP_KEY=\"a611e344442a2f60d53941f21d03b9db\";\n String[] PARAM_URLS = {\"top\",\"shehui\",\"guon",
"end": 349,
"score": 0.9997577667236328,
"start": 317,
"tag": "KEY",
"value": "a611e344442a2f60d53941f21d03b9db"
}
] | null | [] | package com.example.sun.zhangxun.http;
import com.example.sun.zhangxun.bean.News;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Query;
/**
* Created by sun on 2017/4/21.
*/
public interface ApiService {
String BASE_URL2 = "http://v.juhe.cn/toutiao/";
String APP_KEY="<KEY>";
String[] PARAM_URLS = {"top","shehui","guonei","guoji","yule","tiyu","junshi","keji","caijing","shishang"};
@GET("index")
Observable<News> getNewsRxjava(@Query("type") String type ,@Query("key") String key);
}
| 548 | 0.697391 | 0.641739 | 21 | 26.380953 | 29.986467 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.904762 | false | false | 11 |
7358583d9dc555f9af0e434183b1680611429f50 | 30,648,886,650,858 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/6/6_e8d9282643df8ff5c178f94a7e530f0fd143a684/PushCommand/6_e8d9282643df8ff5c178f94a7e530f0fd143a684_PushCommand_t.java | f54343a0387bd8bf3a707a0ade4fa8e6b81d23dd | [] | no_license | zhongxingyu/Seer | https://github.com/zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516000 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | false | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | 2023-06-21T00:53:27 | 2023-06-22T07:55:57 | 2,849,868 | 2 | 2 | 0 | null | false | false | package net.aufdemrand.denizen.scripts.commands.entity;
import java.util.List;
import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.objects.Duration;
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dList;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dScript;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.scripts.queues.ScriptQueue;
import net.aufdemrand.denizen.scripts.queues.core.InstantQueue;
import net.aufdemrand.denizen.utilities.Conversion;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.entity.Position;
import net.aufdemrand.denizen.utilities.entity.Rotation;
import org.bukkit.Material;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
/**
* Moves entities through the air from an origin to a destination.
* The origin can optionally be an entity that will look at the
* object it is moving.
*
* @author David Cernat, mcmonkey
*/
public class PushCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (!scriptEntry.hasObject("origin")
&& arg.matchesPrefix("origin, o, source, shooter, s")) {
if (arg.matchesArgumentType(dEntity.class))
scriptEntry.addObject("originEntity", arg.asType(dEntity.class));
else if (arg.matchesArgumentType(dLocation.class))
scriptEntry.addObject("originLocation", arg.asType(dLocation.class));
else
dB.echoError("Ignoring unrecognized argument: " + arg.raw_value);
}
else if (!scriptEntry.hasObject("destination")
&& arg.matchesArgumentType(dLocation.class)
&& arg.matchesPrefix("destination, d")) {
scriptEntry.addObject("destination", arg.asType(dLocation.class));
}
else if (!scriptEntry.hasObject("duration")
&& arg.matchesArgumentType(Duration.class)
&& arg.matchesPrefix("duration, d")) {
scriptEntry.addObject("duration", arg.asType(Duration.class));
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("speed, s")) {
scriptEntry.addObject("speed", arg.asElement());
}
else if (!scriptEntry.hasObject("script")
&& arg.matchesArgumentType(dScript.class)) {
scriptEntry.addObject("script", arg.asType(dScript.class));
}
else if (!scriptEntry.hasObject("entities")
&& arg.matchesArgumentList(dEntity.class)) {
scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class));
}
else arg.reportUnhandled();
}
// Use the NPC or player's locations as the origin if one is not specified
if (!scriptEntry.hasObject("originLocation")) {
scriptEntry.defaultObject("originEntity",
scriptEntry.hasNPC() ? scriptEntry.getNPC().getDenizenEntity() : null,
scriptEntry.hasPlayer() ? scriptEntry.getPlayer().getDenizenEntity() : null);
}
scriptEntry.defaultObject("speed", new Element(1.5));
scriptEntry.defaultObject("duration", new Duration(20));
// Check to make sure required arguments have been filled
if (!scriptEntry.hasObject("entities"))
throw new InvalidArgumentsException("Must specify entity/entities!");
if (!scriptEntry.hasObject("originEntity") && !scriptEntry.hasObject("originLocation"))
throw new InvalidArgumentsException("Must specify an origin location!");
}
@SuppressWarnings("unchecked")
@Override
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
dEntity originEntity = (dEntity) scriptEntry.getObject("originEntity");
dLocation originLocation = scriptEntry.hasObject("originLocation") ?
(dLocation) scriptEntry.getObject("originLocation") :
new dLocation(originEntity.getEyeLocation()
.add(originEntity.getEyeLocation().getDirection())
.subtract(0, 0.4, 0));
// If there is no destination set, but there is a shooter, get a point
// in front of the shooter and set it as the destination
final dLocation destination = scriptEntry.hasObject("destination") ?
(dLocation) scriptEntry.getObject("destination") :
(originEntity != null ? new dLocation(originEntity.getEyeLocation()
.add(originEntity.getEyeLocation().getDirection()
.multiply(30)))
: null);
// TODO: Should this be checked in argument parsing?
if (destination == null) {
dB.report(scriptEntry, getName(), "No destination specified!");
return;
}
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
final dScript script = (dScript) scriptEntry.getObject("script");
final double speed = scriptEntry.getElement("speed").asDouble();
final int maxTicks = ((Duration) scriptEntry.getObject("duration")).getTicksAsInt() / 2;
// Report to dB
dB.report(scriptEntry, getName(), aH.debugObj("origin", originEntity != null ? originEntity : originLocation) +
aH.debugObj("entities", entities.toString()) +
aH.debugObj("destination", destination) +
aH.debugObj("speed", speed) +
aH.debugObj("max ticks", maxTicks) +
(script != null ? script.debug() : ""));
// Keep a dList of entities that can be called using <entry[name].pushed_entities>
// later in the script queue
final dList entityList = new dList();
// Go through all the entities, spawning/teleporting and rotating them
for (dEntity entity : entities) {
entity.spawnAt(originLocation);
// Only add to entityList after the entities have been
// spawned, otherwise you'll get something like "e@skeleton"
// instead of "e@57" on it
entityList.add(entity.toString());
Rotation.faceLocation(entity.getBukkitEntity(), destination);
// If the current entity is a projectile, set its shooter
// when applicable
if (entity.isProjectile() && originEntity != null) {
entity.setShooter(originEntity);
}
}
// Add entities to context so that the specific entities created/spawned
// can be fetched.
scriptEntry.addObject("pushed_entities", entityList);
Position.mount(Conversion.convertEntities(entities));
// Get the entity at the bottom of the entity list, because
// only its gravity should be affected and tracked considering
// that the other entities will be mounted on it
final dEntity lastEntity = entities.get(entities.size() - 1);
final Vector v2 = destination.toVector();
BukkitRunnable task = new BukkitRunnable() {
int runs = 0;
dLocation lastLocation;
@Override
public void run() {
if (runs < maxTicks && lastEntity.isValid()) {
Vector v1 = lastEntity.getLocation().toVector();
Vector v3 = v2.clone().subtract(v1).normalize().multiply(speed);
lastEntity.setVelocity(v3);
runs++;
// Check if the entity is close to its destination
if (Math.abs(v2.getX() - v1.getX()) < 2 && Math.abs(v2.getY() - v1.getY()) < 2
&& Math.abs(v2.getZ() - v1.getZ()) < 2) {
runs = maxTicks;
}
// Check if the entity has collided with something
// using the most basic possible calculation
if (lastEntity.getLocation().add(v3).getBlock().getType() != Material.AIR) {
runs = maxTicks;
}
lastLocation = lastEntity.getLocation();
}
else {
this.cancel();
if (script != null) {
List<ScriptEntry> entries = script.getContainer().getBaseEntries(
scriptEntry.getPlayer(),
scriptEntry.getNPC());
ScriptQueue queue = InstantQueue.getQueue(ScriptQueue._getNextId()).addEntries(entries);
if (lastEntity.getLocation() != null)
queue.addDefinition("location", lastEntity.getLocation().identify());
else
queue.addDefinition("location", lastLocation.identify());
queue.addDefinition("pushed_entities", entityList.toString());
queue.addDefinition("last_entity", lastEntity.identify());
queue.start();
}
}
}
};
task.runTaskTimer(denizen, 0, 2);
}
}
| UTF-8 | Java | 10,710 | java | 6_e8d9282643df8ff5c178f94a7e530f0fd143a684_PushCommand_t.java | Java | [
{
"context": "at the\r\n * object it is moving.\r\n *\r\n * @author David Cernat, mcmonkey\r\n */\r\n \r\n public class PushCommand ext",
"end": 1352,
"score": 0.9998182058334351,
"start": 1340,
"tag": "NAME",
"value": "David Cernat"
},
{
"context": "ject it is moving.\r\n *\r\n * @author David Cernat, mcmonkey\r\n */\r\n \r\n public class PushCommand extends Abstr",
"end": 1362,
"score": 0.9988492727279663,
"start": 1354,
"tag": "USERNAME",
"value": "mcmonkey"
}
] | null | [] | package net.aufdemrand.denizen.scripts.commands.entity;
import java.util.List;
import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
import net.aufdemrand.denizen.objects.Duration;
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.aH;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dList;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dScript;
import net.aufdemrand.denizen.scripts.ScriptEntry;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.scripts.queues.ScriptQueue;
import net.aufdemrand.denizen.scripts.queues.core.InstantQueue;
import net.aufdemrand.denizen.utilities.Conversion;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.entity.Position;
import net.aufdemrand.denizen.utilities.entity.Rotation;
import org.bukkit.Material;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
/**
* Moves entities through the air from an origin to a destination.
* The origin can optionally be an entity that will look at the
* object it is moving.
*
* @author <NAME>, mcmonkey
*/
public class PushCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
if (!scriptEntry.hasObject("origin")
&& arg.matchesPrefix("origin, o, source, shooter, s")) {
if (arg.matchesArgumentType(dEntity.class))
scriptEntry.addObject("originEntity", arg.asType(dEntity.class));
else if (arg.matchesArgumentType(dLocation.class))
scriptEntry.addObject("originLocation", arg.asType(dLocation.class));
else
dB.echoError("Ignoring unrecognized argument: " + arg.raw_value);
}
else if (!scriptEntry.hasObject("destination")
&& arg.matchesArgumentType(dLocation.class)
&& arg.matchesPrefix("destination, d")) {
scriptEntry.addObject("destination", arg.asType(dLocation.class));
}
else if (!scriptEntry.hasObject("duration")
&& arg.matchesArgumentType(Duration.class)
&& arg.matchesPrefix("duration, d")) {
scriptEntry.addObject("duration", arg.asType(Duration.class));
}
else if (!scriptEntry.hasObject("speed")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("speed, s")) {
scriptEntry.addObject("speed", arg.asElement());
}
else if (!scriptEntry.hasObject("script")
&& arg.matchesArgumentType(dScript.class)) {
scriptEntry.addObject("script", arg.asType(dScript.class));
}
else if (!scriptEntry.hasObject("entities")
&& arg.matchesArgumentList(dEntity.class)) {
scriptEntry.addObject("entities", ((dList) arg.asType(dList.class)).filter(dEntity.class));
}
else arg.reportUnhandled();
}
// Use the NPC or player's locations as the origin if one is not specified
if (!scriptEntry.hasObject("originLocation")) {
scriptEntry.defaultObject("originEntity",
scriptEntry.hasNPC() ? scriptEntry.getNPC().getDenizenEntity() : null,
scriptEntry.hasPlayer() ? scriptEntry.getPlayer().getDenizenEntity() : null);
}
scriptEntry.defaultObject("speed", new Element(1.5));
scriptEntry.defaultObject("duration", new Duration(20));
// Check to make sure required arguments have been filled
if (!scriptEntry.hasObject("entities"))
throw new InvalidArgumentsException("Must specify entity/entities!");
if (!scriptEntry.hasObject("originEntity") && !scriptEntry.hasObject("originLocation"))
throw new InvalidArgumentsException("Must specify an origin location!");
}
@SuppressWarnings("unchecked")
@Override
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
dEntity originEntity = (dEntity) scriptEntry.getObject("originEntity");
dLocation originLocation = scriptEntry.hasObject("originLocation") ?
(dLocation) scriptEntry.getObject("originLocation") :
new dLocation(originEntity.getEyeLocation()
.add(originEntity.getEyeLocation().getDirection())
.subtract(0, 0.4, 0));
// If there is no destination set, but there is a shooter, get a point
// in front of the shooter and set it as the destination
final dLocation destination = scriptEntry.hasObject("destination") ?
(dLocation) scriptEntry.getObject("destination") :
(originEntity != null ? new dLocation(originEntity.getEyeLocation()
.add(originEntity.getEyeLocation().getDirection()
.multiply(30)))
: null);
// TODO: Should this be checked in argument parsing?
if (destination == null) {
dB.report(scriptEntry, getName(), "No destination specified!");
return;
}
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
final dScript script = (dScript) scriptEntry.getObject("script");
final double speed = scriptEntry.getElement("speed").asDouble();
final int maxTicks = ((Duration) scriptEntry.getObject("duration")).getTicksAsInt() / 2;
// Report to dB
dB.report(scriptEntry, getName(), aH.debugObj("origin", originEntity != null ? originEntity : originLocation) +
aH.debugObj("entities", entities.toString()) +
aH.debugObj("destination", destination) +
aH.debugObj("speed", speed) +
aH.debugObj("max ticks", maxTicks) +
(script != null ? script.debug() : ""));
// Keep a dList of entities that can be called using <entry[name].pushed_entities>
// later in the script queue
final dList entityList = new dList();
// Go through all the entities, spawning/teleporting and rotating them
for (dEntity entity : entities) {
entity.spawnAt(originLocation);
// Only add to entityList after the entities have been
// spawned, otherwise you'll get something like "e@skeleton"
// instead of "e@57" on it
entityList.add(entity.toString());
Rotation.faceLocation(entity.getBukkitEntity(), destination);
// If the current entity is a projectile, set its shooter
// when applicable
if (entity.isProjectile() && originEntity != null) {
entity.setShooter(originEntity);
}
}
// Add entities to context so that the specific entities created/spawned
// can be fetched.
scriptEntry.addObject("pushed_entities", entityList);
Position.mount(Conversion.convertEntities(entities));
// Get the entity at the bottom of the entity list, because
// only its gravity should be affected and tracked considering
// that the other entities will be mounted on it
final dEntity lastEntity = entities.get(entities.size() - 1);
final Vector v2 = destination.toVector();
BukkitRunnable task = new BukkitRunnable() {
int runs = 0;
dLocation lastLocation;
@Override
public void run() {
if (runs < maxTicks && lastEntity.isValid()) {
Vector v1 = lastEntity.getLocation().toVector();
Vector v3 = v2.clone().subtract(v1).normalize().multiply(speed);
lastEntity.setVelocity(v3);
runs++;
// Check if the entity is close to its destination
if (Math.abs(v2.getX() - v1.getX()) < 2 && Math.abs(v2.getY() - v1.getY()) < 2
&& Math.abs(v2.getZ() - v1.getZ()) < 2) {
runs = maxTicks;
}
// Check if the entity has collided with something
// using the most basic possible calculation
if (lastEntity.getLocation().add(v3).getBlock().getType() != Material.AIR) {
runs = maxTicks;
}
lastLocation = lastEntity.getLocation();
}
else {
this.cancel();
if (script != null) {
List<ScriptEntry> entries = script.getContainer().getBaseEntries(
scriptEntry.getPlayer(),
scriptEntry.getNPC());
ScriptQueue queue = InstantQueue.getQueue(ScriptQueue._getNextId()).addEntries(entries);
if (lastEntity.getLocation() != null)
queue.addDefinition("location", lastEntity.getLocation().identify());
else
queue.addDefinition("location", lastLocation.identify());
queue.addDefinition("pushed_entities", entityList.toString());
queue.addDefinition("last_entity", lastEntity.identify());
queue.start();
}
}
}
};
task.runTaskTimer(denizen, 0, 2);
}
}
| 10,704 | 0.555182 | 0.552101 | 234 | 43.764957 | 32.548325 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.508547 | false | false | 11 |
85c49bf00a95b11fb9193e4533d17c52a52fc1d7 | 29,618,094,525,572 | 7491d268f73927617d11a89510c4e917f24b8a1c | /practice 3/resultactivity/src/main/java/ru/mirea/tyve/resultactivity/DataActivity.java | 6696cf2c2458c1319964e7ff978d0bcd6ac155ba | [] | no_license | NineDoctor/lab_mobile | https://github.com/NineDoctor/lab_mobile | 58f1e069239ba99a43b4d52daf29fc2a8b1988c5 | d5d735e43b6d3fa4e8a1031c0d0e6861140062f1 | refs/heads/master | 2023-05-11T04:00:09.428000 | 2021-06-06T21:05:39 | 2021-06-06T21:05:39 | 374,461,668 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.mirea.tyve.resultactivity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
public class DataActivity extends AppCompatActivity {
private EditText universityEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data2);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
universityEditText = findViewById(R.id.EditText);
}
public void sendResultOnMainActivityOnClick(View view) {
Intent intent = new Intent();
intent.putExtra("name", universityEditText.getText().toString());
setResult(RESULT_OK, intent);
finish();
}
} | UTF-8 | Java | 1,036 | java | DataActivity.java | Java | [] | null | [] | package ru.mirea.tyve.resultactivity;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
public class DataActivity extends AppCompatActivity {
private EditText universityEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data2);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
universityEditText = findViewById(R.id.EditText);
}
public void sendResultOnMainActivityOnClick(View view) {
Intent intent = new Intent();
intent.putExtra("name", universityEditText.getText().toString());
setResult(RESULT_OK, intent);
finish();
}
} | 1,036 | 0.746139 | 0.745174 | 35 | 28.628571 | 23.79566 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 11 |
747c8004938a83b777f78cddbd777e900b8ad8e7 | 15,547,781,673,514 | 040c1893e594f8e26118d30aec8a26a7650858bc | /src/main/java/smithmicro/apps/awesomeNotes/model/Role.java | a7c549dc79578ced0448c43afca0777bce42d8b3 | [] | no_license | josebkk/awesomeNotes | https://github.com/josebkk/awesomeNotes | c0f0b32a350da5ec5436ed03a6a5a06823d3b5d2 | e163eae96db9bb52635ab6e2e25a707ac977e8bf | refs/heads/master | 2021-05-06T00:25:58.630000 | 2018-01-14T20:36:54 | 2018-01-14T20:36:54 | 117,246,562 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package smithmicro.apps.awesomeNotes.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@Table(name = "role")
@EntityListeners(AuditingEntityListener.class)
public class Role implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="role_id")
private int id;
private String role;
@ManyToMany(mappedBy = "roles", cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.LAZY)
@JsonBackReference
private List<User> users;
public Role(){
}
public Role(String role, List<User> users) {
this.role = role;
this.users = new ArrayList<User>();;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
}
| UTF-8 | Java | 1,585 | java | Role.java | Java | [] | null | [] | package smithmicro.apps.awesomeNotes.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@Table(name = "role")
@EntityListeners(AuditingEntityListener.class)
public class Role implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="role_id")
private int id;
private String role;
@ManyToMany(mappedBy = "roles", cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch=FetchType.LAZY)
@JsonBackReference
private List<User> users;
public Role(){
}
public Role(String role, List<User> users) {
this.role = role;
this.users = new ArrayList<User>();;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
}
| 1,585 | 0.757729 | 0.757098 | 73 | 20.712328 | 20.723541 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.136986 | false | false | 11 |
c13da0526e9bff626f2655ebb36d7f2bfdae68e9 | 11,811,160,100,933 | cf0393c3fb43e0e6be3757241d9b66bb0ecda20e | /PrograII/src/principal/Punto1.java | 502d16342222d5aa4b4df37cbb1a37701bc730ab | [] | no_license | matisaffirio96/PrograII | https://github.com/matisaffirio96/PrograII | 0cad9c79b5a1143998b94188ad0067a0443224b8 | 37d5d0701287f68de56ac71a4dadae964cf052e1 | refs/heads/master | 2023-06-16T03:08:55.749000 | 2021-06-25T23:33:08 | 2021-06-25T23:33:08 | 361,212,732 | 1 | 0 | null | false | 2021-06-25T23:33:08 | 2021-04-24T16:34:24 | 2021-06-16T00:46:36 | 2021-06-25T23:33:08 | 205 | 1 | 0 | 0 | Java | false | false | package principal;
import api.ColaTDA;
import impl.ColaPU;
import impl.PilaTF;
public class Punto1 {
public static void main(String[] args) {
ColaTDA col = ColaBinaria(100);
// demostración de funcionamiento
while (!col.ColaVacia()){
System.out.println(col.Primero());
col.Desacolar();
}
}
public static ColaTDA ColaBinaria(int numero) {
int entero;
double resultado;
ColaPU colabina = new ColaPU();
colabina.IncicializarCola();
PilaTF aux = new PilaTF();
aux.InicializarPila(); //uso una pila auxiliar
if (numero > 0) {
resultado = 0;
while (numero != 0) {
entero = numero % 2;
resultado = resultado + entero;
numero = numero / 2;
aux.Apilar(entero);
}
}
while (!aux.PilaVacia()){
colabina.Acolar(aux.Tope());
aux.Desapilar();
}
return colabina;
}
}
| UTF-8 | Java | 1,044 | java | Punto1.java | Java | [] | null | [] | package principal;
import api.ColaTDA;
import impl.ColaPU;
import impl.PilaTF;
public class Punto1 {
public static void main(String[] args) {
ColaTDA col = ColaBinaria(100);
// demostración de funcionamiento
while (!col.ColaVacia()){
System.out.println(col.Primero());
col.Desacolar();
}
}
public static ColaTDA ColaBinaria(int numero) {
int entero;
double resultado;
ColaPU colabina = new ColaPU();
colabina.IncicializarCola();
PilaTF aux = new PilaTF();
aux.InicializarPila(); //uso una pila auxiliar
if (numero > 0) {
resultado = 0;
while (numero != 0) {
entero = numero % 2;
resultado = resultado + entero;
numero = numero / 2;
aux.Apilar(entero);
}
}
while (!aux.PilaVacia()){
colabina.Acolar(aux.Tope());
aux.Desapilar();
}
return colabina;
}
}
| 1,044 | 0.519655 | 0.511026 | 44 | 22.704546 | 16.304739 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.477273 | false | false | 11 |
79bf10f2ca588e67a4ea3c9e0ad5731ce6d91334 | 6,983,616,886,228 | a4727a237871d157260d9100d19f4461a6cca93b | /broker/src/main/java/org/oceanq/broker/BrokerController.java | 3d3f8200369d4b623a4aa005c7bb04ce463d5604 | [] | no_license | zhuyixiang/oceanq | https://github.com/zhuyixiang/oceanq | 2d69b9dd4c788bedf20b4555ba8dc2cf9ba5c46b | 1f375a67db2eddb5d15ee4515d495703c5e5dce8 | refs/heads/master | 2018-09-02T07:58:19.520000 | 2018-06-04T03:58:47 | 2018-06-04T03:58:47 | 134,704,307 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.oceanq.broker;
import org.oceanq.broker.client.ProducerManager;
import org.oceanq.broker.processor.SendMessageProcessor;
import org.oceanq.common.BrokerConfig;
import org.oceanq.network.RemotingCommand;
import org.oceanq.network.netty.NettyClientConfig;
import org.oceanq.network.netty.NettyRemotingServer;
import org.oceanq.network.netty.NettyServerConfig;
import org.oceanq.network.protocol.CommandCodeConst;
import org.oceanq.network.protocol.header.SendMessageHeader;
import org.oceanq.network.protocol.header.SendMessageResponseHeader;
import org.oceanq.network.thread.NamedIncreaseThreadFactory;
import org.oceanq.store.DefaultMessageStore;
import org.oceanq.store.MessageStore;
import org.oceanq.store.config.MessageStoreConfig;
import org.oceanq.store.message.MessageExtBrokerInner;
import org.oceanq.store.stats.BrokerStats;
import org.oceanq.store.stats.BrokerStatsManager;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.*;
/**
* Created by zhuyx on 2018/6/1.
*/
public class BrokerController {
private final BrokerConfig brokerConfig;
private NettyServerConfig nettyServerConfig;
private MessageStoreConfig messageStoreConfig;
private ProducerManager producerManager;
private MessageStore messageStore;
private InetSocketAddress storeHost;
private ExecutorService sendMessageExecutor;
private BrokerStats brokerStats;
private BrokerStatsManager brokerStatsManager;
private NettyRemotingServer remotingServer;
private final BlockingQueue<Runnable> sendThreadPoolQueue;
private String brokerAddr;
public BrokerController(
final BrokerConfig brokerConfig,
final NettyServerConfig nettyServerConfig,
final MessageStoreConfig messageStoreConfig
) {
this.brokerConfig = brokerConfig;
this.nettyServerConfig = nettyServerConfig;
this.messageStoreConfig = messageStoreConfig;
this.producerManager = new ProducerManager();
this.setStoreHost(new InetSocketAddress(this.brokerConfig.getBrokerIP1(), this.nettyServerConfig.getListenPort()));
this.sendMessageExecutor = Executors.newFixedThreadPool(10);
this.brokerStatsManager = new BrokerStatsManager();
this.sendThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getSendThreadPoolQueueCapacity());
}
public boolean initialize() throws CloneNotSupportedException {
boolean result = true;
if (result) {
try {
this.messageStore =
new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.brokerConfig);
this.brokerStats = new BrokerStats();
//load plugin
// this.messageStore.getDispatcherList().addFirst(new CommitLogDispatcherCalcBitMap(this.brokerConfig, this.consumerFilterManager));
} catch (IOException e) {
result = false;
// log.error("Failed to initialize", e);
}
}
result = result && this.messageStore.load();
if (result) {
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);
NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
this.sendMessageExecutor = new ThreadPoolExecutor(
this.brokerConfig.getSendMessageThreadPoolNums(),
this.brokerConfig.getSendMessageThreadPoolNums(),
1000 * 60,
TimeUnit.MILLISECONDS,
this.sendThreadPoolQueue,
new NamedIncreaseThreadFactory("SendMessageThread_"));
}
registerProcessor();
RemotingCommand.registerHeaderClass(CommandCodeConst.SendMessage, SendMessageHeader.class);
RemotingCommand.registerHeaderClass(CommandCodeConst.SendMessageResponse, SendMessageResponseHeader.class);
return result;
}
public void registerProcessor() {
/**
* SendMessageProcessor
*/
SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
this.remotingServer.registerDefaultProcessor(sendProcessor);
}
public void setStoreHost(InetSocketAddress storeHost) {
this.storeHost = storeHost;
}
public void start() throws Exception {
if (this.messageStore != null) {
this.messageStore.start();
}
if (this.remotingServer != null) {
this.remotingServer.start();
}
MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
msgInner.setTopic("Test1");
msgInner.setQueueId(1);
msgInner.setBody("test start message".getBytes());
msgInner.setFlag(1);
msgInner.setBornTimestamp(System.currentTimeMillis());
msgInner.setBornHost(new InetSocketAddress(88));
msgInner.setStoreHost(new InetSocketAddress(99));
msgInner.setReconsumeTimes(0);
this.messageStore.putMessage(msgInner);
}
public BrokerConfig getBrokerConfig() {
return brokerConfig;
}
public NettyServerConfig getNettyServerConfig() {
return nettyServerConfig;
}
public String getBrokerAddr() {
return brokerAddr;
}
public MessageStore getMessageStore() {
return messageStore;
}
public static void main(String[] args) throws Exception {
BrokerConfig brokerConfig = new BrokerConfig();
NettyServerConfig nettyServerConfig = new NettyServerConfig();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, messageStoreConfig);
brokerController.initialize();
brokerController.start();
}
}
| UTF-8 | Java | 5,958 | java | BrokerController.java | Java | [
{
"context": "\nimport java.util.concurrent.*;\n\n/**\n * Created by zhuyx on 2018/6/1.\n */\npublic class BrokerController {\n",
"end": 1016,
"score": 0.9996333718299866,
"start": 1011,
"tag": "USERNAME",
"value": "zhuyx"
}
] | null | [] | package org.oceanq.broker;
import org.oceanq.broker.client.ProducerManager;
import org.oceanq.broker.processor.SendMessageProcessor;
import org.oceanq.common.BrokerConfig;
import org.oceanq.network.RemotingCommand;
import org.oceanq.network.netty.NettyClientConfig;
import org.oceanq.network.netty.NettyRemotingServer;
import org.oceanq.network.netty.NettyServerConfig;
import org.oceanq.network.protocol.CommandCodeConst;
import org.oceanq.network.protocol.header.SendMessageHeader;
import org.oceanq.network.protocol.header.SendMessageResponseHeader;
import org.oceanq.network.thread.NamedIncreaseThreadFactory;
import org.oceanq.store.DefaultMessageStore;
import org.oceanq.store.MessageStore;
import org.oceanq.store.config.MessageStoreConfig;
import org.oceanq.store.message.MessageExtBrokerInner;
import org.oceanq.store.stats.BrokerStats;
import org.oceanq.store.stats.BrokerStatsManager;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.*;
/**
* Created by zhuyx on 2018/6/1.
*/
public class BrokerController {
private final BrokerConfig brokerConfig;
private NettyServerConfig nettyServerConfig;
private MessageStoreConfig messageStoreConfig;
private ProducerManager producerManager;
private MessageStore messageStore;
private InetSocketAddress storeHost;
private ExecutorService sendMessageExecutor;
private BrokerStats brokerStats;
private BrokerStatsManager brokerStatsManager;
private NettyRemotingServer remotingServer;
private final BlockingQueue<Runnable> sendThreadPoolQueue;
private String brokerAddr;
public BrokerController(
final BrokerConfig brokerConfig,
final NettyServerConfig nettyServerConfig,
final MessageStoreConfig messageStoreConfig
) {
this.brokerConfig = brokerConfig;
this.nettyServerConfig = nettyServerConfig;
this.messageStoreConfig = messageStoreConfig;
this.producerManager = new ProducerManager();
this.setStoreHost(new InetSocketAddress(this.brokerConfig.getBrokerIP1(), this.nettyServerConfig.getListenPort()));
this.sendMessageExecutor = Executors.newFixedThreadPool(10);
this.brokerStatsManager = new BrokerStatsManager();
this.sendThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getSendThreadPoolQueueCapacity());
}
public boolean initialize() throws CloneNotSupportedException {
boolean result = true;
if (result) {
try {
this.messageStore =
new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.brokerConfig);
this.brokerStats = new BrokerStats();
//load plugin
// this.messageStore.getDispatcherList().addFirst(new CommitLogDispatcherCalcBitMap(this.brokerConfig, this.consumerFilterManager));
} catch (IOException e) {
result = false;
// log.error("Failed to initialize", e);
}
}
result = result && this.messageStore.load();
if (result) {
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);
NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
this.sendMessageExecutor = new ThreadPoolExecutor(
this.brokerConfig.getSendMessageThreadPoolNums(),
this.brokerConfig.getSendMessageThreadPoolNums(),
1000 * 60,
TimeUnit.MILLISECONDS,
this.sendThreadPoolQueue,
new NamedIncreaseThreadFactory("SendMessageThread_"));
}
registerProcessor();
RemotingCommand.registerHeaderClass(CommandCodeConst.SendMessage, SendMessageHeader.class);
RemotingCommand.registerHeaderClass(CommandCodeConst.SendMessageResponse, SendMessageResponseHeader.class);
return result;
}
public void registerProcessor() {
/**
* SendMessageProcessor
*/
SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
this.remotingServer.registerDefaultProcessor(sendProcessor);
}
public void setStoreHost(InetSocketAddress storeHost) {
this.storeHost = storeHost;
}
public void start() throws Exception {
if (this.messageStore != null) {
this.messageStore.start();
}
if (this.remotingServer != null) {
this.remotingServer.start();
}
MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
msgInner.setTopic("Test1");
msgInner.setQueueId(1);
msgInner.setBody("test start message".getBytes());
msgInner.setFlag(1);
msgInner.setBornTimestamp(System.currentTimeMillis());
msgInner.setBornHost(new InetSocketAddress(88));
msgInner.setStoreHost(new InetSocketAddress(99));
msgInner.setReconsumeTimes(0);
this.messageStore.putMessage(msgInner);
}
public BrokerConfig getBrokerConfig() {
return brokerConfig;
}
public NettyServerConfig getNettyServerConfig() {
return nettyServerConfig;
}
public String getBrokerAddr() {
return brokerAddr;
}
public MessageStore getMessageStore() {
return messageStore;
}
public static void main(String[] args) throws Exception {
BrokerConfig brokerConfig = new BrokerConfig();
NettyServerConfig nettyServerConfig = new NettyServerConfig();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
BrokerController brokerController = new BrokerController(brokerConfig, nettyServerConfig, messageStoreConfig);
brokerController.initialize();
brokerController.start();
}
}
| 5,958 | 0.705942 | 0.701913 | 159 | 36.471699 | 29.56813 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.610063 | false | false | 11 |
6c7c702b7e2912b7947282b01f611adeaed26dd2 | 20,615,843,041,971 | 9849c32325ebe2348b44b985a4b40be07338fe23 | /prs/webapp/src/main/java/org/netbeans/jackpot/prs/webapp/WebAppNotify.java | 167d154e42929a5b03baf073818d5162717da608 | [
"Apache-2.0"
] | permissive | apache/netbeans-jackpot30 | https://github.com/apache/netbeans-jackpot30 | 2788a872b4f3f83eb92247a03af28809a8b618a8 | 13e22c19c583f2ca687f951c64aab9f3f271c0fc | refs/heads/master | 2023-08-31T20:37:19.571000 | 2022-06-18T05:27:24 | 2022-06-18T05:27:24 | 102,083,575 | 8 | 5 | Apache-2.0 | false | 2023-03-12T18:22:44 | 2017-09-01T07:00:11 | 2022-06-28T19:56:56 | 2023-03-12T14:08:11 | 1,079 | 5 | 7 | 4 | Java | false | false | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.jackpot.prs.webapp;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Map;
import java.util.logging.Level;
import java.util.prefs.Preferences;
import java.util.zip.GZIPOutputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
/**
*
* @author lahvac
*/
@Path("/github/notify")
public class WebAppNotify {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public static void webhook(String data) throws IOException {
Map<String, Object> inputParsed = new ObjectMapper().readValue(data, Map.class);
Object action = inputParsed.get("action");
if (!"opened".equals(action))
return ;
Map<String, Object> pullRequest = (Map<String, Object>) inputParsed.get("pull_request");
if (pullRequest == null) {
return ;
}
Map<String, Object> repository = (Map<String, Object>) inputParsed.get("repository");
if (repository == null) {
return ;
}
String[] userAndRepo = ((String) repository.get("full_name")).split("/");
Preferences repositories = Config.getDefault().getPreferences().node("users").node(userAndRepo[0]).node("repositories");
if (!repositories.getBoolean(userAndRepo[1], false)) {
return ;
}
Preferences handlerPrefs = Config.getDefault().getPreferences().node("handler");
String handler = handlerPrefs.get("handler", "handler.local");
String remoteHost = handlerPrefs.get("remoteHost", null);
String remotePath = handlerPrefs.get("remotePath", null);
ProcessBuilder builder;
if (remoteHost != null && remotePath != null) {
builder = new ProcessBuilder(System.getProperty("install.dir") + "/handler/bin/handler.remote", remoteHost, remotePath, handler);
} else {
builder = new ProcessBuilder(System.getProperty("install.dir") + "/handler/bin/" + handler);
}
builder.environment().put("PR_CONTENT", data);
//XXX: how to handle the access tokens?
builder.environment().put("OAUTH_TOKEN", Config.getDefault().getPreferences().node("users").node(userAndRepo[0]).get("access_token", ""));
builder.environment().put("OAUTH_APP_TOKEN", Config.getDefault().getPreferences().node("app").get("access_token", ""));
java.nio.file.Path targetDir = Config.getDefault().getRunDir().resolve("github").resolve((String) repository.get("full_name"));
java.nio.file.Path thisRunDir = targetDir.resolve(String.valueOf((Integer) pullRequest.get("number")));
Files.createDirectories(thisRunDir);
Files.deleteIfExists(thisRunDir.resolve("finished"));
Files.newOutputStream(thisRunDir.resolve("preparing")).close();
java.nio.file.Path stdout = thisRunDir.resolve("stdout");
builder.redirectOutput(stdout.toFile());
java.nio.file.Path stderr = thisRunDir.resolve("stderr");
builder.redirectError(stderr.toFile());
Process process = builder.start();
Files.newOutputStream(thisRunDir.resolve("running")).close();
Files.delete(thisRunDir.resolve("preparing"));
new Thread(() -> {
while (true) {
try {
process.waitFor();
break;
} catch (InterruptedException ex) {
//ignore...
}
}
try {
Files.newOutputStream(thisRunDir.resolve("finished")).close();
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
try {
Files.delete(thisRunDir.resolve("running"));
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
pack(stdout);
pack(stderr);
}).start();
}
private static void pack(java.nio.file.Path log) {
java.nio.file.Path logGZ = log.getParent().resolve(log.getFileName() + ".gz");
try (InputStream in = Files.newInputStream(log);
OutputStream out = new GZIPOutputStream(Files.newOutputStream(logGZ))) {
int r;
while ((r = in.read()) != (-1)) {
out.write(r);
}
Files.delete(log);
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
}
}
| UTF-8 | Java | 5,403 | java | WebAppNotify.java | Java | [
{
"context": "ort javax.ws.rs.core.MediaType;\n\n/**\n *\n * @author lahvac\n */\n@Path(\"/github/notify\")\npublic class WebAppNo",
"end": 1284,
"score": 0.9996239542961121,
"start": 1278,
"tag": "USERNAME",
"value": "lahvac"
}
] | null | [] | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.jackpot.prs.webapp;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Map;
import java.util.logging.Level;
import java.util.prefs.Preferences;
import java.util.zip.GZIPOutputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
/**
*
* @author lahvac
*/
@Path("/github/notify")
public class WebAppNotify {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public static void webhook(String data) throws IOException {
Map<String, Object> inputParsed = new ObjectMapper().readValue(data, Map.class);
Object action = inputParsed.get("action");
if (!"opened".equals(action))
return ;
Map<String, Object> pullRequest = (Map<String, Object>) inputParsed.get("pull_request");
if (pullRequest == null) {
return ;
}
Map<String, Object> repository = (Map<String, Object>) inputParsed.get("repository");
if (repository == null) {
return ;
}
String[] userAndRepo = ((String) repository.get("full_name")).split("/");
Preferences repositories = Config.getDefault().getPreferences().node("users").node(userAndRepo[0]).node("repositories");
if (!repositories.getBoolean(userAndRepo[1], false)) {
return ;
}
Preferences handlerPrefs = Config.getDefault().getPreferences().node("handler");
String handler = handlerPrefs.get("handler", "handler.local");
String remoteHost = handlerPrefs.get("remoteHost", null);
String remotePath = handlerPrefs.get("remotePath", null);
ProcessBuilder builder;
if (remoteHost != null && remotePath != null) {
builder = new ProcessBuilder(System.getProperty("install.dir") + "/handler/bin/handler.remote", remoteHost, remotePath, handler);
} else {
builder = new ProcessBuilder(System.getProperty("install.dir") + "/handler/bin/" + handler);
}
builder.environment().put("PR_CONTENT", data);
//XXX: how to handle the access tokens?
builder.environment().put("OAUTH_TOKEN", Config.getDefault().getPreferences().node("users").node(userAndRepo[0]).get("access_token", ""));
builder.environment().put("OAUTH_APP_TOKEN", Config.getDefault().getPreferences().node("app").get("access_token", ""));
java.nio.file.Path targetDir = Config.getDefault().getRunDir().resolve("github").resolve((String) repository.get("full_name"));
java.nio.file.Path thisRunDir = targetDir.resolve(String.valueOf((Integer) pullRequest.get("number")));
Files.createDirectories(thisRunDir);
Files.deleteIfExists(thisRunDir.resolve("finished"));
Files.newOutputStream(thisRunDir.resolve("preparing")).close();
java.nio.file.Path stdout = thisRunDir.resolve("stdout");
builder.redirectOutput(stdout.toFile());
java.nio.file.Path stderr = thisRunDir.resolve("stderr");
builder.redirectError(stderr.toFile());
Process process = builder.start();
Files.newOutputStream(thisRunDir.resolve("running")).close();
Files.delete(thisRunDir.resolve("preparing"));
new Thread(() -> {
while (true) {
try {
process.waitFor();
break;
} catch (InterruptedException ex) {
//ignore...
}
}
try {
Files.newOutputStream(thisRunDir.resolve("finished")).close();
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
try {
Files.delete(thisRunDir.resolve("running"));
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
pack(stdout);
pack(stderr);
}).start();
}
private static void pack(java.nio.file.Path log) {
java.nio.file.Path logGZ = log.getParent().resolve(log.getFileName() + ".gz");
try (InputStream in = Files.newInputStream(log);
OutputStream out = new GZIPOutputStream(Files.newOutputStream(logGZ))) {
int r;
while ((r = in.read()) != (-1)) {
out.write(r);
}
Files.delete(log);
} catch (IOException ex) {
WebApp.LOG.log(Level.SEVERE, null, ex);
}
}
}
| 5,403 | 0.62891 | 0.627429 | 127 | 41.543308 | 31.785639 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.708661 | false | false | 11 |
07a3230337ffa326e9068898a36e976ecff2b157 | 29,420,525,997,459 | c0d7a7f7e009b93ca8a141138d570332d17a3ea3 | /src/datastructures/builtin/Problem12049.java | b9bd8c1fc3c60210bc170e6901e680e623fa9f14 | [
"Unlicense"
] | permissive | izharishaksa/UVa-Solution | https://github.com/izharishaksa/UVa-Solution | 3a47b66c86d936528a0e37842fd8c18d0b7ee0a5 | d655585c4e54f4fec277ba006530ee3f9fbabdb6 | refs/heads/master | 2022-09-04T12:56:43.325000 | 2022-08-10T07:47:59 | 2022-08-10T07:47:59 | 11,547,644 | 7 | 13 | null | false | 2019-05-02T17:53:40 | 2013-07-20T13:57:12 | 2019-04-16T21:18:43 | 2019-05-02T17:53:40 | 202 | 3 | 5 | 0 | Java | false | false | package datastructures.builtin;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* Just Prune the List.
*
* @author Izhari Ishak Aksa
*/
public class Problem12049 {
static BufferedReader br;
public static boolean isWhitespace(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
static int readInt() throws Exception {
int c = br.read();
while (isWhitespace(c)) {
c = br.read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = br.read();
}
int res = 0;
do {
res *= 10;
res += c - '0';
c = br.read();
} while (!isWhitespace(c));
return res * sgn;
}
public static void main(String[] args) throws Exception {
br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int TC = readInt();
while (TC-- > 0) {
int A = readInt();
int B = readInt();
for (int i = 0; i < A; i++) {
int x = readInt();
}
for (int i = 0; i < B; i++) {
int x = readInt();
}
int total = 0;
pw.println(total);
pw.flush();
}
pw.close();
br.close();
}
}
| UTF-8 | Java | 1,431 | java | Problem12049.java | Java | [
{
"context": "Writer;\n\n/**\n * Just Prune the List.\n *\n * @author Izhari Ishak Aksa\n */\npublic class Problem12049 {\n\n static Buffe",
"end": 186,
"score": 0.9997620582580566,
"start": 169,
"tag": "NAME",
"value": "Izhari Ishak Aksa"
}
] | null | [] | package datastructures.builtin;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* Just Prune the List.
*
* @author <NAME>
*/
public class Problem12049 {
static BufferedReader br;
public static boolean isWhitespace(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
static int readInt() throws Exception {
int c = br.read();
while (isWhitespace(c)) {
c = br.read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = br.read();
}
int res = 0;
do {
res *= 10;
res += c - '0';
c = br.read();
} while (!isWhitespace(c));
return res * sgn;
}
public static void main(String[] args) throws Exception {
br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int TC = readInt();
while (TC-- > 0) {
int A = readInt();
int B = readInt();
for (int i = 0; i < A; i++) {
int x = readInt();
}
for (int i = 0; i < B; i++) {
int x = readInt();
}
int total = 0;
pw.println(total);
pw.flush();
}
pw.close();
br.close();
}
}
| 1,420 | 0.446541 | 0.43536 | 60 | 22.85 | 16.738007 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.683333 | false | false | 11 |
a8cb0a6cae73b04751b7b57cf87bf57bd7ed6f2b | 6,622,839,641,785 | e7b4172bb95043bdcf5a4b7b4ef0c4e160992e48 | /app/src/main/java/com/myj/designpattern/DesignPattern/Iterator/InfoCollegeIterator.java | 2a9a88efb8503cb536b38116affed3addcd0a8f3 | [] | no_license | maoyujiao/DesignPattern | https://github.com/maoyujiao/DesignPattern | 7d8f9f71d718e2ca4e7e9b7b87dd85c842a871b1 | e706a4ebdf2f4d80d906dd4d225286ecab9b3285 | refs/heads/master | 2020-07-07T22:13:11.385000 | 2019-12-17T03:44:15 | 2019-12-17T03:44:15 | 203,490,638 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.myj.designpattern.DesignPattern.Iterator;
import java.util.Iterator;
import java.util.List;
/**
* Created by maoyujiao on 2019/9/2.
*/
public class InfoCollegeIterator implements Iterator {
private List<Department> departments;
private int curPos= 0;
public InfoCollegeIterator(List<Department> departments) {
this.departments = departments;
}
@Override
public boolean hasNext() {
if(curPos > departments.size() - 1 || departments == null){
return false;
}else{
return true;
}
}
@Override
public Object next() {
Department department = departments.get(curPos);
curPos += 1;
return department;
}
@Override
public void remove() {
}
}
| UTF-8 | Java | 786 | java | InfoCollegeIterator.java | Java | [
{
"context": "terator;\nimport java.util.List;\n\n/**\n * Created by maoyujiao on 2019/9/2.\n */\n\npublic class InfoCollegeIterato",
"end": 133,
"score": 0.9990165829658508,
"start": 124,
"tag": "USERNAME",
"value": "maoyujiao"
}
] | null | [] | package com.myj.designpattern.DesignPattern.Iterator;
import java.util.Iterator;
import java.util.List;
/**
* Created by maoyujiao on 2019/9/2.
*/
public class InfoCollegeIterator implements Iterator {
private List<Department> departments;
private int curPos= 0;
public InfoCollegeIterator(List<Department> departments) {
this.departments = departments;
}
@Override
public boolean hasNext() {
if(curPos > departments.size() - 1 || departments == null){
return false;
}else{
return true;
}
}
@Override
public Object next() {
Department department = departments.get(curPos);
curPos += 1;
return department;
}
@Override
public void remove() {
}
}
| 786 | 0.622137 | 0.610687 | 38 | 19.68421 | 19.355545 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.342105 | false | false | 11 |
e401dcdc7d7b7bd9868cad2e653abca0c1165242 | 3,779,571,225,018 | ecab69a023fc0b0fa0306112f207622bbc948975 | /src/main/java/net/kunmc/lab/vplayer/common/network/PacketContainer.java | ac1541129f302cc5a87817b6057c5e255827dedc | [] | no_license | kbjn/VideoPlayer | https://github.com/kbjn/VideoPlayer | d3983a7907242e3707b4e5b1a8c596c02f3f2f9c | 6d6b04c624585ca614f7daf8122c7441b31d1223 | refs/heads/master | 2023-09-01T20:23:19.823000 | 2021-05-17T11:16:55 | 2021-05-17T11:16:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.kunmc.lab.vplayer.common.network;
import net.kunmc.lab.vplayer.VideoPlayer;
import net.kunmc.lab.vplayer.common.data.DataSerializer;
import net.kunmc.lab.vplayer.common.patch.VideoPatch;
import net.kunmc.lab.vplayer.common.patch.VideoPatchOperation;
import net.minecraft.network.PacketBuffer;
import java.util.List;
public class PacketContainer {
private final VideoPatchOperation operation;
private final List<VideoPatch> patches;
public PacketContainer(VideoPatchOperation operation, List<VideoPatch> patches) {
this.operation = operation;
this.patches = patches;
}
public VideoPatchOperation getOperation() {
return operation;
}
public List<VideoPatch> getPatches() {
return patches;
}
public static void encode(PacketContainer message, PacketBuffer buffer) {
buffer.writeString(DataSerializer.encode(message));
}
public static PacketContainer decode(PacketBuffer buffer) {
PacketContainer data = DataSerializer.decode(buffer.readString(), PacketContainer.class);
if (data == null)
VideoPlayer.LOGGER.warn("Invalid Packet");
return data;
}
} | UTF-8 | Java | 1,190 | java | PacketContainer.java | Java | [] | null | [] | package net.kunmc.lab.vplayer.common.network;
import net.kunmc.lab.vplayer.VideoPlayer;
import net.kunmc.lab.vplayer.common.data.DataSerializer;
import net.kunmc.lab.vplayer.common.patch.VideoPatch;
import net.kunmc.lab.vplayer.common.patch.VideoPatchOperation;
import net.minecraft.network.PacketBuffer;
import java.util.List;
public class PacketContainer {
private final VideoPatchOperation operation;
private final List<VideoPatch> patches;
public PacketContainer(VideoPatchOperation operation, List<VideoPatch> patches) {
this.operation = operation;
this.patches = patches;
}
public VideoPatchOperation getOperation() {
return operation;
}
public List<VideoPatch> getPatches() {
return patches;
}
public static void encode(PacketContainer message, PacketBuffer buffer) {
buffer.writeString(DataSerializer.encode(message));
}
public static PacketContainer decode(PacketBuffer buffer) {
PacketContainer data = DataSerializer.decode(buffer.readString(), PacketContainer.class);
if (data == null)
VideoPlayer.LOGGER.warn("Invalid Packet");
return data;
}
} | 1,190 | 0.726891 | 0.726891 | 40 | 28.775 | 26.957827 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 11 |
9cd247357e9e8df55d930cb9e7ab189d11590c5f | 27,049,704,052,249 | 32f4844da28d03fc0fb709a39d8b2d81823fb3d1 | /src/main/java/com/springboot/MavenProfiling/MavenProfilingApplication.java | 8d045980d280322925ec17c2a4424af55868db00 | [] | no_license | thanoojgithub/MavenProfiling | https://github.com/thanoojgithub/MavenProfiling | 6d7665515924026d44f028b300b1d1feb43e9798 | 04916922489d35f84ff3e5da0388ed2f6133ae55 | refs/heads/master | 2020-04-26T14:37:10.450000 | 2019-03-03T20:11:03 | 2019-03-03T20:11:03 | 173,620,596 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.springboot.MavenProfiling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MavenProfilingApplication {
private static final Logger logger = LoggerFactory.getLogger(MavenProfilingApplication.class);
public static String host;
@Value("${host}")
public void setHost(String h) {
host = h;
}
public static void main(String[] args) {
logger.info("MavenProfilingApplication - Spring Boot started!");
SpringApplication.run(MavenProfilingApplication.class, args);
logger.trace("trace me " + host);
logger.debug("debug me " + host);
logger.info("info me " + host);
logger.warn("warn me " + host);
logger.error("error me " + host);
}
}
| UTF-8 | Java | 893 | java | MavenProfilingApplication.java | Java | [] | null | [] | package com.springboot.MavenProfiling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MavenProfilingApplication {
private static final Logger logger = LoggerFactory.getLogger(MavenProfilingApplication.class);
public static String host;
@Value("${host}")
public void setHost(String h) {
host = h;
}
public static void main(String[] args) {
logger.info("MavenProfilingApplication - Spring Boot started!");
SpringApplication.run(MavenProfilingApplication.class, args);
logger.trace("trace me " + host);
logger.debug("debug me " + host);
logger.info("info me " + host);
logger.warn("warn me " + host);
logger.error("error me " + host);
}
}
| 893 | 0.761478 | 0.759239 | 33 | 26.060606 | 24.760599 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.212121 | false | false | 11 |
de501cd59e4f5397466884c80da14a286f0ba438 | 27,917,287,488,474 | 7b95f690dc13354984ee6fcfed7b3289b380e72f | /Manfreditor/src/test/java/manfred/manfreditor/map/model/objectfactory/ConcreteMapObjectFactoryTest.java | 3705f66b163edb13e6f34614d1089cde7e41f482 | [] | no_license | RusselCK/manfred | https://github.com/RusselCK/manfred | eca994f44b1d57c8331aa86a9d1df66727544777 | 8ddc47e3bd6f2bb51f9754b660f4a4408e45b8e5 | refs/heads/master | 2023-04-06T01:49:33.534000 | 2021-05-02T13:58:00 | 2021-05-02T13:58:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package manfred.manfreditor.map.model.objectfactory;
import manfred.data.infrastructure.map.MapPrototype;
import manfred.data.infrastructure.map.TileConversionAction;
import manfred.data.infrastructure.map.tile.MapTileStructurePrototype;
import manfred.data.infrastructure.map.tile.TilePrototype;
import manfred.data.infrastructure.map.tile.ValidatedMapTileDto;
import manfred.manfreditor.map.model.mapobject.ConcreteMapObject;
import manfred.manfreditor.map.model.mapobject.MapObject;
import manfred.manfreditor.map.model.mapobject.MapObjectRepository;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.awt.image.BufferedImage;
import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class ConcreteMapObjectFactoryTest {
private ConcreteMapObjectFactory underTest;
private MapObjectRepository mapObjectRepositoryMock;
@BeforeEach
void setUp() {
mapObjectRepositoryMock = mock(MapObjectRepository.class);
underTest = new ConcreteMapObjectFactory(mapObjectRepositoryMock);
}
@Test
void doesNotApply() {
TilePrototype tilePrototypeMock = mock(TilePrototype.class);
when(tilePrototypeMock.getTileObject()).thenReturn(Optional.empty());
MapPrototype input = mock(MapPrototype.class);
when(input.getFromMap(any())).thenReturn(tilePrototypeMock);
Optional<TileConversionAction<MapObject>> result = underTest.applicableTo(input, mock(MapPrototype.Coordinate.class));
assertTrue(result.isEmpty());
}
@Test
void applies() {
TilePrototype tilePrototypeMock = tilePrototypeWithObject();
MapPrototype input = mock(MapPrototype.class);
when(input.getFromMap(any())).thenReturn(tilePrototypeMock);
ConcreteMapObject mapObjectMock = mock(ConcreteMapObject.class);
when(mapObjectRepositoryMock.getOrCreate(any())).thenReturn(mapObjectMock);
Optional<TileConversionAction<MapObject>> result = underTest.applicableTo(input, mock(MapPrototype.Coordinate.class));
assertTrue(result.isPresent());
MapObject resultingObject = result.get().create();
assertThat(resultingObject, is(mapObjectMock));
}
private TilePrototype tilePrototypeWithObject() {
ValidatedMapTileDto tileDto = new ValidatedMapTileDto("tileName", mockTileStructure(), someImage(), someImageData());
TilePrototype tilePrototypeMock = mock(TilePrototype.class);
when(tilePrototypeMock.getTileObject()).thenReturn(Optional.of(tileDto));
return tilePrototypeMock;
}
private MapTileStructurePrototype mockTileStructure() {
return mock(MapTileStructurePrototype.class);
}
private BufferedImage someImage() {
return new BufferedImage(1, 2, 1);
}
private ImageData someImageData() {
return new ImageData(1, 1, 1, new PaletteData(1, 1, 1));
}
} | UTF-8 | Java | 3,244 | java | ConcreteMapObjectFactoryTest.java | Java | [] | null | [] | package manfred.manfreditor.map.model.objectfactory;
import manfred.data.infrastructure.map.MapPrototype;
import manfred.data.infrastructure.map.TileConversionAction;
import manfred.data.infrastructure.map.tile.MapTileStructurePrototype;
import manfred.data.infrastructure.map.tile.TilePrototype;
import manfred.data.infrastructure.map.tile.ValidatedMapTileDto;
import manfred.manfreditor.map.model.mapobject.ConcreteMapObject;
import manfred.manfreditor.map.model.mapobject.MapObject;
import manfred.manfreditor.map.model.mapobject.MapObjectRepository;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.awt.image.BufferedImage;
import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class ConcreteMapObjectFactoryTest {
private ConcreteMapObjectFactory underTest;
private MapObjectRepository mapObjectRepositoryMock;
@BeforeEach
void setUp() {
mapObjectRepositoryMock = mock(MapObjectRepository.class);
underTest = new ConcreteMapObjectFactory(mapObjectRepositoryMock);
}
@Test
void doesNotApply() {
TilePrototype tilePrototypeMock = mock(TilePrototype.class);
when(tilePrototypeMock.getTileObject()).thenReturn(Optional.empty());
MapPrototype input = mock(MapPrototype.class);
when(input.getFromMap(any())).thenReturn(tilePrototypeMock);
Optional<TileConversionAction<MapObject>> result = underTest.applicableTo(input, mock(MapPrototype.Coordinate.class));
assertTrue(result.isEmpty());
}
@Test
void applies() {
TilePrototype tilePrototypeMock = tilePrototypeWithObject();
MapPrototype input = mock(MapPrototype.class);
when(input.getFromMap(any())).thenReturn(tilePrototypeMock);
ConcreteMapObject mapObjectMock = mock(ConcreteMapObject.class);
when(mapObjectRepositoryMock.getOrCreate(any())).thenReturn(mapObjectMock);
Optional<TileConversionAction<MapObject>> result = underTest.applicableTo(input, mock(MapPrototype.Coordinate.class));
assertTrue(result.isPresent());
MapObject resultingObject = result.get().create();
assertThat(resultingObject, is(mapObjectMock));
}
private TilePrototype tilePrototypeWithObject() {
ValidatedMapTileDto tileDto = new ValidatedMapTileDto("tileName", mockTileStructure(), someImage(), someImageData());
TilePrototype tilePrototypeMock = mock(TilePrototype.class);
when(tilePrototypeMock.getTileObject()).thenReturn(Optional.of(tileDto));
return tilePrototypeMock;
}
private MapTileStructurePrototype mockTileStructure() {
return mock(MapTileStructurePrototype.class);
}
private BufferedImage someImage() {
return new BufferedImage(1, 2, 1);
}
private ImageData someImageData() {
return new ImageData(1, 1, 1, new PaletteData(1, 1, 1));
}
} | 3,244 | 0.759248 | 0.756473 | 84 | 37.630951 | 31.489521 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 11 |
0da7212f6118ab32c37460b99a7d79695dfc59a5 | 20,151,986,553,433 | f6a321091c136e4368c6d6e45cf3c97c0caff31e | /src/main/java/be/intec/webcomponents/guestboook/dao/GuestBookDao.java | e8672a11bb8e39307967d7fd78d2bea8cc421e0a | [] | no_license | adnansee/guestbook | https://github.com/adnansee/guestbook | 0d70248d041248d1a6c106e2d8acb12841376b3c | 2b579e2ce53b4e139d984b3f20e22d63af71ee00 | refs/heads/master | 2020-07-16T20:38:08.244000 | 2019-09-03T13:37:39 | 2019-09-03T13:37:39 | 205,863,699 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package be.intec.webcomponents.guestboook.dao;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class GuestBookDao {
String url = "jdbc:mysql://noelvaes.eu/StudentDB";
String user = "student";
String pwd = "student123";
Connection c;
public GuestBookDao(String url, String user, String pwd) {
try {
Class.forName("org.mariadb.jdbc.Driver");
c = DriverManager.getConnection(url, user, pwd);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
}
public List<GuestBookBean> getGuestBookItems() {
List<GuestBookBean> guestBookBeans = new ArrayList<>();
try {
var p = c.prepareStatement("SELECT * FROM GuestBook ");
ResultSet rs = p.executeQuery();
while (rs.next()) {
guestBookBeans.add(new GuestBookBean().setName(rs.getString("name")).setData(rs.getDate("date")).setMessage(rs.getString("message")));
}
} catch (SQLException e) {
e.printStackTrace();
}
return guestBookBeans;
}
public void addGuestBookItem(String entererdName, String enteredMessage) {
try {
var p = c.prepareStatement("INSERT INTO GuestBook (Name, Message) VALUES (?,?)");
p.setString(1, entererdName);
p.setString(2, enteredMessage);
p.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void deleteGuestBookItem(String entererdName) {
try {
var p = c.prepareStatement("DELETE FROM GuestBook WHERE Name = ?");
p.setString(1, entererdName);
p.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 1,850 | java | GuestBookDao.java | Java | [
{
"context": "ysql://noelvaes.eu/StudentDB\";\n String user = \"student\";\n String pwd = \"student123\";\n Connection c",
"end": 229,
"score": 0.9992614388465881,
"start": 222,
"tag": "USERNAME",
"value": "student"
},
{
"context": "\";\n String user = \"student\";\n String pwd = \"student123\";\n Connection c;\n\n\n\n public GuestBookDao(St",
"end": 260,
"score": 0.9992590546607971,
"start": 250,
"tag": "PASSWORD",
"value": "student123"
}
] | null | [] | package be.intec.webcomponents.guestboook.dao;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class GuestBookDao {
String url = "jdbc:mysql://noelvaes.eu/StudentDB";
String user = "student";
String pwd = "<PASSWORD>";
Connection c;
public GuestBookDao(String url, String user, String pwd) {
try {
Class.forName("org.mariadb.jdbc.Driver");
c = DriverManager.getConnection(url, user, pwd);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
}
public List<GuestBookBean> getGuestBookItems() {
List<GuestBookBean> guestBookBeans = new ArrayList<>();
try {
var p = c.prepareStatement("SELECT * FROM GuestBook ");
ResultSet rs = p.executeQuery();
while (rs.next()) {
guestBookBeans.add(new GuestBookBean().setName(rs.getString("name")).setData(rs.getDate("date")).setMessage(rs.getString("message")));
}
} catch (SQLException e) {
e.printStackTrace();
}
return guestBookBeans;
}
public void addGuestBookItem(String entererdName, String enteredMessage) {
try {
var p = c.prepareStatement("INSERT INTO GuestBook (Name, Message) VALUES (?,?)");
p.setString(1, entererdName);
p.setString(2, enteredMessage);
p.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void deleteGuestBookItem(String entererdName) {
try {
var p = c.prepareStatement("DELETE FROM GuestBook WHERE Name = ?");
p.setString(1, entererdName);
p.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| 1,850 | 0.584324 | 0.581081 | 66 | 27.015152 | 28.166439 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.560606 | false | false | 11 |
410988e8d488cb389ac4d74354a2e657f8f796f0 | 16,441,134,861,073 | b61f59cd2195b886b62e68da65fe57ae4a0281e5 | /google-maps-java-sdk/schema/src/main/java/com/googleapis/maps/schema/Metric.java | b775217361976d0b890ab54735a724125822084c | [] | no_license | vijaymoorthy001/google-search-java-sdk | https://github.com/vijaymoorthy001/google-search-java-sdk | 975fc5066f599a5954cd3d6d3ae0d7fe7bc0e472 | d7a2cc54bdcf51d89b814652e18cc9373ce43fa0 | refs/heads/master | 2020-05-16T11:40:47.579000 | 2011-05-16T13:54:14 | 2011-05-16T13:54:14 | 39,949,561 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2010-2011 Nabeel Mukhtar
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.googleapis.maps.schema;
/**
* The Class Metric.
*/
public class Metric extends SchemaEntity {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -8677198189578821428L;
/** The value. */
private double value;
/** The text. */
private String text;
/**
* Gets the value.
*
* @return the value
*/
public double getValue() {
return value;
}
/**
* Sets the value.
*
* @param value the new value
*/
public void setValue(double value) {
this.value = value;
}
/**
* Gets the text.
*
* @return the text
*/
public String getText() {
return text;
}
/**
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Metric [text=" + text + ", value=" + value + "]";
}
}
| UTF-8 | Java | 1,544 | java | Metric.java | Java | [
{
"context": "/*\n * Copyright 2010-2011 Nabeel Mukhtar \n * \n * Licensed under the Apache License, Versio",
"end": 40,
"score": 0.9998756647109985,
"start": 26,
"tag": "NAME",
"value": "Nabeel Mukhtar"
}
] | null | [] | /*
* Copyright 2010-2011 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.googleapis.maps.schema;
/**
* The Class Metric.
*/
public class Metric extends SchemaEntity {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -8677198189578821428L;
/** The value. */
private double value;
/** The text. */
private String text;
/**
* Gets the value.
*
* @return the value
*/
public double getValue() {
return value;
}
/**
* Sets the value.
*
* @param value the new value
*/
public void setValue(double value) {
this.value = value;
}
/**
* Gets the text.
*
* @return the text
*/
public String getText() {
return text;
}
/**
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Metric [text=" + text + ", value=" + value + "]";
}
}
| 1,536 | 0.653497 | 0.63342 | 75 | 19.586666 | 21.107403 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.946667 | false | false | 11 |
a511e528d8162cfbaf0731d8e7647c0755fac1fc | 25,185,688,226,259 | c146f5aa0a1ea4503ce9f66c2141c0ad289f21e0 | /src/main/java/easy/Binary_Tree_Level_Order_Traversal_II_107.java | 772230bc826c45e79c9b06dabde47a6f37995d42 | [] | no_license | chenlijie/leetcode | https://github.com/chenlijie/leetcode | f59bd06ad800caa5a431fa0ff343838ce46a2312 | 6f298e94f9290294dd590515f8d734bc2fcb7329 | refs/heads/master | 2021-01-20T14:16:09.788000 | 2020-01-14T00:15:47 | 2020-01-14T00:15:47 | 78,302,178 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package easy;
import java.util.*;
public class Binary_Tree_Level_Order_Traversal_II_107 {
private static class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
//BFS
public static List<List<Integer>> levelOrderBottom2(TreeNode root) {
if (root == null) return new ArrayList<List<Integer>>();
List<List<Integer>> list = new ArrayList<List<Integer>>();
Queue<TreeNode> queue = new LinkedList<TreeNode>();
queue.add(root);
while (!queue.isEmpty()) {
List<Integer> subList = new ArrayList<Integer>();
int size = queue.size();
for (int i= 0; i < size; i++) {
TreeNode temp = queue.poll();
if (temp.left != null)
queue.add(temp.left);
if (temp.right != null)
queue.add(temp.right);
subList.add(temp.val);
}
list.add(0, subList);
}
return list;
}
//DFS
public static List<List<Integer>> levelOrderBottom(TreeNode root) {
List<List<Integer>> all = new ArrayList<List<Integer>>();
levelOrderBottom(root, all, new HashMap<Integer, List<Integer>>(), 0);
return all;
}
private static void levelOrderBottom(TreeNode node, List<List<Integer>> all, Map<Integer, List<Integer>> map, int level) {
if (node == null) return;
if (!map.containsKey(level)) {
map.put(level, new ArrayList<Integer>());
all.add(0, map.get(level));
}
levelOrderBottom(node.left, all, map, level+1);
levelOrderBottom(node.right, all, map, level+1);
map.get(level).add(node.val);
}
public static void main(String[] args) {
Binary_Tree_Level_Order_Traversal_II_107.TreeNode root = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(1);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(2);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(3);
root.left = left;
root.right = right;
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left2 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(4);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right2 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(5);
left.left = left2;
left.right = right2;
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left3 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(6);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right3 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(7);
right.left = left3;
right.right = right3;
levelOrderBottom2(root);
}
}
| UTF-8 | Java | 2,902 | java | Binary_Tree_Level_Order_Traversal_II_107.java | Java | [] | null | [] | package easy;
import java.util.*;
public class Binary_Tree_Level_Order_Traversal_II_107 {
private static class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) { val = x; }
}
//BFS
public static List<List<Integer>> levelOrderBottom2(TreeNode root) {
if (root == null) return new ArrayList<List<Integer>>();
List<List<Integer>> list = new ArrayList<List<Integer>>();
Queue<TreeNode> queue = new LinkedList<TreeNode>();
queue.add(root);
while (!queue.isEmpty()) {
List<Integer> subList = new ArrayList<Integer>();
int size = queue.size();
for (int i= 0; i < size; i++) {
TreeNode temp = queue.poll();
if (temp.left != null)
queue.add(temp.left);
if (temp.right != null)
queue.add(temp.right);
subList.add(temp.val);
}
list.add(0, subList);
}
return list;
}
//DFS
public static List<List<Integer>> levelOrderBottom(TreeNode root) {
List<List<Integer>> all = new ArrayList<List<Integer>>();
levelOrderBottom(root, all, new HashMap<Integer, List<Integer>>(), 0);
return all;
}
private static void levelOrderBottom(TreeNode node, List<List<Integer>> all, Map<Integer, List<Integer>> map, int level) {
if (node == null) return;
if (!map.containsKey(level)) {
map.put(level, new ArrayList<Integer>());
all.add(0, map.get(level));
}
levelOrderBottom(node.left, all, map, level+1);
levelOrderBottom(node.right, all, map, level+1);
map.get(level).add(node.val);
}
public static void main(String[] args) {
Binary_Tree_Level_Order_Traversal_II_107.TreeNode root = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(1);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(2);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(3);
root.left = left;
root.right = right;
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left2 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(4);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right2 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(5);
left.left = left2;
left.right = right2;
Binary_Tree_Level_Order_Traversal_II_107.TreeNode left3 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(6);
Binary_Tree_Level_Order_Traversal_II_107.TreeNode right3 = new Binary_Tree_Level_Order_Traversal_II_107.TreeNode(7);
right.left = left3;
right.right = right3;
levelOrderBottom2(root);
}
}
| 2,902 | 0.607512 | 0.58408 | 84 | 33.547619 | 36.144684 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 11 |
7f465a880b3280d8c3f0ca1860c939ddcb3681f8 | 17,978,733,142,057 | 6fc02a7fc1b6570007264fa84ae89f0f524049bd | /java/comp3111/webscraper/WebScraper.java | 1be989a883e6872fb41e2a07514a89f7b4d0ee13 | [] | no_license | suentsz96wing/webscraper | https://github.com/suentsz96wing/webscraper | 18df9bc543fcffb3dd992ae2595c4899d95d04c6 | e1922f9ed9f2cf751cc41ea14b4c4e14037a93d3 | refs/heads/master | 2020-05-26T09:23:00.575000 | 2019-05-23T07:39:14 | 2019-05-23T07:39:14 | 188,184,788 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package comp3111.webscraper;
import java.net.URLEncoder;
import java.util.List;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.util.Vector;
/**
* WebScraper provide a sample code that scrape web content. After it is
* constructed, you can call the method scrape with a keyword, the client will
* go to the default url and parse the page by looking at the HTML DOM. <br/>
* In this particular sample code, it access to craigslist.org. You can directly
* search on an entry by typing the URL <br/>
* https://newyork.craigslist.org/search/sss?sort=rel&query=KEYWORD <br/>
* where KEYWORD is the keyword you want to search. <br/>
* Assume you are working on Chrome, paste the url into your browser and press
* F12 to load the source code of the HTML. You might be freak out if you have
* never seen a HTML source code before. Keep calm and move on. Press
* Ctrl-Shift-C (or CMD-Shift-C if you got a mac) and move your mouse cursor
* around, different part of the HTML code and the corresponding the HTML
* objects will be highlighted. Explore your HTML page from body → section
* class="page-container" → form id="searchform" → div class="content"
* → ul class="rows" → any one of the multiple li class="result-row"
* → p class="result-info". You might see something like this: <br/>
*
* <pre>
* {@code
* <p class="result-info">
* <span class="icon icon-star" role="button" title=
"save this post in your favorites list">
* <span class="screen-reader-text">favorite this post</span>
* </span>
* <time class="result-date" datetime="2018-06-21 01:58" title=
"Thu 21 Jun 01:58:44 AM">Jun 21</time>
* <a href=
"https://newyork.craigslist.org/que/clt/d/green-star-polyp-gsp-on-rock/6596253604.html" data-id
="6596253604" class=
"result-title hdrlnk">Green Star Polyp GSP on a rock frag</a>
* <span class="result-meta">
* <span class="result-price">$15</span>
* <span class="result-tags">
* pic
* <span class="maptag" data-pid="6596253604">map</span>
* </span>
* <span class="banish icon icon-trash" role="button">
* <span class="screen-reader-text">hide this posting</span>
* </span>
* <span class="unbanish icon icon-trash red" role=
"button" aria-hidden="true"></span>
* <a href="#" class="restore-link">
* <span class="restore-narrow-text">restore</span>
* <span class="restore-wide-text">restore this posting</span>
* </a>
* </span>
* </p>
*}
* </pre>
*
* <br/>
* The code
*
* <pre>
* {
* @code
* List<?> items = (List<?>) page.getByXPath("//li[@class='result-row']");
* }
* </pre>
*
* extracts all result-row and stores the corresponding HTML elements to a list
* called items. Later in the loop it extracts the anchor tag ‹ a
* › to retrieve the display text (by .asText()) and the link (by
* .getHrefAttribute()). It also extracts
*
*
*/
public class WebScraper {
private WebClient client;
private String[] website = new String[2];
/**
* Default Constructor
*/
public WebScraper() {
client = new WebClient();
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(false);
// default website
website[0] = "https://newyork.craigslist.org";
// selected website (Price HK)
website[1] = "https://www.price.com.hk";
}
/**
* The scrape procedure and output during data scraping. This function will
* control the program to scrape web content from the craigslist and hkprice
*
* @author Leung Chun Ting
* @param keyword - the keyword you want to search
* @return A list of Item that has found. A zero size list is return if nothing
* is found.
*/
public List<Item> scrape(String keyword) {
int scrapedPages = 0;
List<Item> result = new Vector<Item>();
// loop of multiple website
for (int k = 0; k < website.length; k++) {
// loop of multiple page
for (int pages = 0; true; pages++) {
List<Item> data = new Vector<Item>();
if (k == 0) {
data = scrapeFromCraigslist(keyword, pages);
if (data == null)
break;
} else {
data = scrapeFromPricehk(keyword, pages);
if (data == null)
break;
}
// merge and sort data
result = mergeData(result, data);
// call function to print during scrape data
System.out.println(++scrapedPages + " page(s) scraped.");
}
}
return result;
}
/**
* This function will scrape web content from the craigslist
*
* @author Leung Chun Ting
* @param keyword - the keyword you want to search
* @param pages - the pages of search result
* @return A list of Item that has found. A zero size list is return if nothing
* is found. Null if any exception (e.g. no connectivity)
*/
public List<Item> scrapeFromCraigslist(String keyword, int pages) {
List<Item> data = new Vector<Item>();
try {
String searchUrl = website[0] + "/search/sss?s=" + (pages * 120) + "&sort=rel&query="
+ URLEncoder.encode(keyword, "UTF-8");
HtmlPage page = client.getPage(searchUrl);
List<?> items = (List<?>) page.getByXPath("//li[@class='result-row']");
if (items.size() == 0) {
return null;
}
for (int i = 0; i < items.size(); i++) {
HtmlElement htmlItem = (HtmlElement) items.get(i);
HtmlAnchor itemAnchor = ((HtmlAnchor) htmlItem.getFirstByXPath(".//p[@class='result-info']/a"));
HtmlElement spanPrice = ((HtmlElement) htmlItem.getFirstByXPath(".//a/span[@class='result-price']"));
HtmlElement date = ((HtmlElement) htmlItem.getFirstByXPath(".//p[@class='result-info']/time"));
// It is possible that an item doesn't have any price, we set the price to 0.0
// in this case
String itemPrice = spanPrice == null ? "0.0" : spanPrice.asText();
String resultDate = date.getAttribute("datetime");
resultDate = resultDate.substring(0, 11);
Item item = new Item();
item.setTitle(itemAnchor.asText());
item.setUrl(itemAnchor.getHrefAttribute());
item.setSource(website[0]);
item.setPrice(new Double(itemPrice.replace("$", "")) * 7.8);
item.setPostedDate(resultDate);
data.add(item);
}
return data;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
/**
* This function will scrape web content from the PriceHK
*
* @author Leung Chun Ting
* @param keyword - the keyword you want to search
* @param pages - the pages of search result
* @return A list of Item that has found. A zero size list is return if nothing
* is found. Null if any exception (e.g. no connectivity)
*/
public List<Item> scrapeFromPricehk(String keyword, int pages) {
List<Item> data = new Vector<Item>();
try {
String searchUrl = website[1] + "/search.php?g=T&q=" + URLEncoder.encode(keyword, "UTF-8") + "&page="
+ (pages + 1);
HtmlPage page = client.getPage(searchUrl);
List<?> items = (List<?>) page.getByXPath(
"//ul[@class='list-unstyled list-inline list-product-list list-search-product-list']/li");
if (items.size() == 0) {
return null;
}
for (int i = 0; i < items.size(); i++) {
HtmlElement htmlItem = (HtmlElement) items.get(i);
HtmlAnchor itemAnchor = ((HtmlAnchor) htmlItem
.getFirstByXPath(".//div/div/div[@class='column column-02']/div[@class='line line-01']/a"));
HtmlElement spanPrice = ((HtmlElement) htmlItem.getFirstByXPath(
".//div/div/div[@class='column column-03']/div[@class='line line-01']/div/a/span[@class='text-price-number']"));
HtmlElement date = ((HtmlElement) htmlItem.getFirstByXPath(
".//div/div/div[@class='column column-02']/div[@class='line line-02']/div/table/tbody/tr/td[@class='info-content']"));
// It is possible that an item doesn't have any price, we set the price to 0.0
// in this case
String itemPrice = spanPrice == null ? "0.0" : spanPrice.asText();
String datetime = date.asText();
datetime = datetime + " ";
char datearray[] = datetime.toCharArray();
/*
* because of price.com datetime show chinese character so change it to fufill
* UTF-16 to set time.
*/
for (int j = 0; j < datetime.length(); j++) {
if (datearray[j] == '\u5e74' || datearray[j] == '\u6708') {
datearray[j] = '-';
} else if (datearray[j] == '\u65e5') {
datearray[j] = ' ';
}
if (j == 5 && datearray[j + 1] == '\u6708') {
char temp = datearray[j];
char next;
datearray[j] = '0';
for (int z = j + 1; z < datetime.length(); z++) {
next = datearray[z];
datearray[z] = temp;
temp = next;
}
if (datearray[9] == '\u65e5') {
datearray[9] = datearray[8];
datearray[8] = '0';
}
} else if (j == 8 && datearray[j + 1] == '\u65e5') {
datearray[9] = datearray[8];
datearray[8] = '0';
}
}
String resultDate = String.valueOf(datearray);
resultDate = resultDate.substring(0, 11);
Item item = new Item();
item.setTitle(itemAnchor.asText());
item.setUrl(website[1] + itemAnchor.getHrefAttribute());
item.setSource(website[1]);
item.setPrice(new Double(itemPrice.replaceAll(",", "").replace("$", "")));
item.setPostedDate(resultDate);
data.add(item);
}
return data;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
/**
* This function will merge and sort data of two list of data
*
* @author Leung Chun Ting
* @param result - the main list of data
* @param data - the list of data will merge into the main list of data
* @return Return the merged and sorted data from two list of data
*/
public List<Item> mergeData(List<Item> result, List<Item> data) {
for (Item d_item : data) {
if (result.size() == 0) {
result.add(d_item);
} else {
int index = 0;
for (Item r_item : result) {
if (d_item.getPrice() < r_item.getPrice()) {
result.add(index, d_item);
break;
}
index++;
}
if (index == result.size()) {
result.add(d_item);
}
}
}
return result;
}
}
| UTF-8 | Java | 10,395 | java | WebScraper.java | Java | [
{
"context": "t from the craigslist and hkprice\n\t * \n\t * @author Leung Chun Ting\n\t * @param keyword - the keyword you want to sear",
"end": 3887,
"score": 0.999871015548706,
"start": 3872,
"tag": "NAME",
"value": "Leung Chun Ting"
},
{
"context": "e web content from the craigslist\n\t * \n\t * @author Leung Chun Ting\n\t * @param keyword - the keyword you want to sear",
"end": 4854,
"score": 0.999876081943512,
"start": 4839,
"tag": "NAME",
"value": "Leung Chun Ting"
},
{
"context": "rape web content from the PriceHK\n\t * \n\t * @author Leung Chun Ting\n\t * @param keyword - the keyword you want to sear",
"end": 6677,
"score": 0.9998705983161926,
"start": 6662,
"tag": "NAME",
"value": "Leung Chun Ting"
},
{
"context": "and sort data of two list of data\n\t * \n\t * @author Leung Chun Ting\n\t * @param result - the main list of data\n\t * @pa",
"end": 9772,
"score": 0.9998446106910706,
"start": 9757,
"tag": "NAME",
"value": "Leung Chun Ting"
}
] | null | [] | package comp3111.webscraper;
import java.net.URLEncoder;
import java.util.List;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.util.Vector;
/**
* WebScraper provide a sample code that scrape web content. After it is
* constructed, you can call the method scrape with a keyword, the client will
* go to the default url and parse the page by looking at the HTML DOM. <br/>
* In this particular sample code, it access to craigslist.org. You can directly
* search on an entry by typing the URL <br/>
* https://newyork.craigslist.org/search/sss?sort=rel&query=KEYWORD <br/>
* where KEYWORD is the keyword you want to search. <br/>
* Assume you are working on Chrome, paste the url into your browser and press
* F12 to load the source code of the HTML. You might be freak out if you have
* never seen a HTML source code before. Keep calm and move on. Press
* Ctrl-Shift-C (or CMD-Shift-C if you got a mac) and move your mouse cursor
* around, different part of the HTML code and the corresponding the HTML
* objects will be highlighted. Explore your HTML page from body → section
* class="page-container" → form id="searchform" → div class="content"
* → ul class="rows" → any one of the multiple li class="result-row"
* → p class="result-info". You might see something like this: <br/>
*
* <pre>
* {@code
* <p class="result-info">
* <span class="icon icon-star" role="button" title=
"save this post in your favorites list">
* <span class="screen-reader-text">favorite this post</span>
* </span>
* <time class="result-date" datetime="2018-06-21 01:58" title=
"Thu 21 Jun 01:58:44 AM">Jun 21</time>
* <a href=
"https://newyork.craigslist.org/que/clt/d/green-star-polyp-gsp-on-rock/6596253604.html" data-id
="6596253604" class=
"result-title hdrlnk">Green Star Polyp GSP on a rock frag</a>
* <span class="result-meta">
* <span class="result-price">$15</span>
* <span class="result-tags">
* pic
* <span class="maptag" data-pid="6596253604">map</span>
* </span>
* <span class="banish icon icon-trash" role="button">
* <span class="screen-reader-text">hide this posting</span>
* </span>
* <span class="unbanish icon icon-trash red" role=
"button" aria-hidden="true"></span>
* <a href="#" class="restore-link">
* <span class="restore-narrow-text">restore</span>
* <span class="restore-wide-text">restore this posting</span>
* </a>
* </span>
* </p>
*}
* </pre>
*
* <br/>
* The code
*
* <pre>
* {
* @code
* List<?> items = (List<?>) page.getByXPath("//li[@class='result-row']");
* }
* </pre>
*
* extracts all result-row and stores the corresponding HTML elements to a list
* called items. Later in the loop it extracts the anchor tag ‹ a
* › to retrieve the display text (by .asText()) and the link (by
* .getHrefAttribute()). It also extracts
*
*
*/
public class WebScraper {
private WebClient client;
private String[] website = new String[2];
/**
* Default Constructor
*/
public WebScraper() {
client = new WebClient();
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(false);
// default website
website[0] = "https://newyork.craigslist.org";
// selected website (Price HK)
website[1] = "https://www.price.com.hk";
}
/**
* The scrape procedure and output during data scraping. This function will
* control the program to scrape web content from the craigslist and hkprice
*
* @author <NAME>
* @param keyword - the keyword you want to search
* @return A list of Item that has found. A zero size list is return if nothing
* is found.
*/
public List<Item> scrape(String keyword) {
int scrapedPages = 0;
List<Item> result = new Vector<Item>();
// loop of multiple website
for (int k = 0; k < website.length; k++) {
// loop of multiple page
for (int pages = 0; true; pages++) {
List<Item> data = new Vector<Item>();
if (k == 0) {
data = scrapeFromCraigslist(keyword, pages);
if (data == null)
break;
} else {
data = scrapeFromPricehk(keyword, pages);
if (data == null)
break;
}
// merge and sort data
result = mergeData(result, data);
// call function to print during scrape data
System.out.println(++scrapedPages + " page(s) scraped.");
}
}
return result;
}
/**
* This function will scrape web content from the craigslist
*
* @author <NAME>
* @param keyword - the keyword you want to search
* @param pages - the pages of search result
* @return A list of Item that has found. A zero size list is return if nothing
* is found. Null if any exception (e.g. no connectivity)
*/
public List<Item> scrapeFromCraigslist(String keyword, int pages) {
List<Item> data = new Vector<Item>();
try {
String searchUrl = website[0] + "/search/sss?s=" + (pages * 120) + "&sort=rel&query="
+ URLEncoder.encode(keyword, "UTF-8");
HtmlPage page = client.getPage(searchUrl);
List<?> items = (List<?>) page.getByXPath("//li[@class='result-row']");
if (items.size() == 0) {
return null;
}
for (int i = 0; i < items.size(); i++) {
HtmlElement htmlItem = (HtmlElement) items.get(i);
HtmlAnchor itemAnchor = ((HtmlAnchor) htmlItem.getFirstByXPath(".//p[@class='result-info']/a"));
HtmlElement spanPrice = ((HtmlElement) htmlItem.getFirstByXPath(".//a/span[@class='result-price']"));
HtmlElement date = ((HtmlElement) htmlItem.getFirstByXPath(".//p[@class='result-info']/time"));
// It is possible that an item doesn't have any price, we set the price to 0.0
// in this case
String itemPrice = spanPrice == null ? "0.0" : spanPrice.asText();
String resultDate = date.getAttribute("datetime");
resultDate = resultDate.substring(0, 11);
Item item = new Item();
item.setTitle(itemAnchor.asText());
item.setUrl(itemAnchor.getHrefAttribute());
item.setSource(website[0]);
item.setPrice(new Double(itemPrice.replace("$", "")) * 7.8);
item.setPostedDate(resultDate);
data.add(item);
}
return data;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
/**
* This function will scrape web content from the PriceHK
*
* @author <NAME>
* @param keyword - the keyword you want to search
* @param pages - the pages of search result
* @return A list of Item that has found. A zero size list is return if nothing
* is found. Null if any exception (e.g. no connectivity)
*/
public List<Item> scrapeFromPricehk(String keyword, int pages) {
List<Item> data = new Vector<Item>();
try {
String searchUrl = website[1] + "/search.php?g=T&q=" + URLEncoder.encode(keyword, "UTF-8") + "&page="
+ (pages + 1);
HtmlPage page = client.getPage(searchUrl);
List<?> items = (List<?>) page.getByXPath(
"//ul[@class='list-unstyled list-inline list-product-list list-search-product-list']/li");
if (items.size() == 0) {
return null;
}
for (int i = 0; i < items.size(); i++) {
HtmlElement htmlItem = (HtmlElement) items.get(i);
HtmlAnchor itemAnchor = ((HtmlAnchor) htmlItem
.getFirstByXPath(".//div/div/div[@class='column column-02']/div[@class='line line-01']/a"));
HtmlElement spanPrice = ((HtmlElement) htmlItem.getFirstByXPath(
".//div/div/div[@class='column column-03']/div[@class='line line-01']/div/a/span[@class='text-price-number']"));
HtmlElement date = ((HtmlElement) htmlItem.getFirstByXPath(
".//div/div/div[@class='column column-02']/div[@class='line line-02']/div/table/tbody/tr/td[@class='info-content']"));
// It is possible that an item doesn't have any price, we set the price to 0.0
// in this case
String itemPrice = spanPrice == null ? "0.0" : spanPrice.asText();
String datetime = date.asText();
datetime = datetime + " ";
char datearray[] = datetime.toCharArray();
/*
* because of price.com datetime show chinese character so change it to fufill
* UTF-16 to set time.
*/
for (int j = 0; j < datetime.length(); j++) {
if (datearray[j] == '\u5e74' || datearray[j] == '\u6708') {
datearray[j] = '-';
} else if (datearray[j] == '\u65e5') {
datearray[j] = ' ';
}
if (j == 5 && datearray[j + 1] == '\u6708') {
char temp = datearray[j];
char next;
datearray[j] = '0';
for (int z = j + 1; z < datetime.length(); z++) {
next = datearray[z];
datearray[z] = temp;
temp = next;
}
if (datearray[9] == '\u65e5') {
datearray[9] = datearray[8];
datearray[8] = '0';
}
} else if (j == 8 && datearray[j + 1] == '\u65e5') {
datearray[9] = datearray[8];
datearray[8] = '0';
}
}
String resultDate = String.valueOf(datearray);
resultDate = resultDate.substring(0, 11);
Item item = new Item();
item.setTitle(itemAnchor.asText());
item.setUrl(website[1] + itemAnchor.getHrefAttribute());
item.setSource(website[1]);
item.setPrice(new Double(itemPrice.replaceAll(",", "").replace("$", "")));
item.setPostedDate(resultDate);
data.add(item);
}
return data;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
/**
* This function will merge and sort data of two list of data
*
* @author <NAME>
* @param result - the main list of data
* @param data - the list of data will merge into the main list of data
* @return Return the merged and sorted data from two list of data
*/
public List<Item> mergeData(List<Item> result, List<Item> data) {
for (Item d_item : data) {
if (result.size() == 0) {
result.add(d_item);
} else {
int index = 0;
for (Item r_item : result) {
if (d_item.getPrice() < r_item.getPrice()) {
result.add(index, d_item);
break;
}
index++;
}
if (index == result.size()) {
result.add(d_item);
}
}
}
return result;
}
}
| 10,359 | 0.62809 | 0.613468 | 295 | 34.237289 | 27.966286 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.610169 | false | false | 11 |
ed993988971f4aa3bcfcaf55bd19305f1cdbd623 | 27,719,718,994,282 | 6536a253b1b406b7fcfca35ddf15fb285c658a69 | /src/main/java/com/yaochen/manager/authorization/manager/bean/CommonPermission.java | 533afa91a743b21660b482d0a9fb8930b237d5c1 | [] | no_license | 18121861183/springboot-user-authorization | https://github.com/18121861183/springboot-user-authorization | bea2db2e48ce317756bf94099337061cf9266971 | f1089980070a1fc5239e9ab9b3ff406a03f4e0fa | refs/heads/master | 2022-12-21T12:45:08.835000 | 2020-09-25T10:13:50 | 2020-09-25T10:13:50 | 283,978,233 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yaochen.manager.authorization.manager.bean;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "common_permission")
public class CommonPermission implements Serializable {
@Id
private String id;
@Column(name = "permission_name", length = 100)
private String permissionName;
@Column(name = "status", length = 20)
private String status;
private Integer sort;
@Column(name = "create_time")
private Date createTime;
@Column(name = "create_user", length = 100)
private String createUser;
@Column(name = "modify_time")
private Date modifyTime;
@Column(name = "modify_user", length = 100)
private String modifyUser;
@Column(name = "description", length = 250)
private String description;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPermissionName() {
return permissionName;
}
public void setPermissionName(String permissionName) {
this.permissionName = permissionName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| UTF-8 | Java | 2,334 | java | CommonPermission.java | Java | [] | null | [] | package com.yaochen.manager.authorization.manager.bean;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "common_permission")
public class CommonPermission implements Serializable {
@Id
private String id;
@Column(name = "permission_name", length = 100)
private String permissionName;
@Column(name = "status", length = 20)
private String status;
private Integer sort;
@Column(name = "create_time")
private Date createTime;
@Column(name = "create_user", length = 100)
private String createUser;
@Column(name = "modify_time")
private Date modifyTime;
@Column(name = "modify_user", length = 100)
private String modifyUser;
@Column(name = "description", length = 250)
private String description;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPermissionName() {
return permissionName;
}
public void setPermissionName(String permissionName) {
this.permissionName = permissionName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifyUser() {
return modifyUser;
}
public void setModifyUser(String modifyUser) {
this.modifyUser = modifyUser;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| 2,334 | 0.645673 | 0.639674 | 111 | 20.027027 | 17.826723 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.351351 | false | false | 11 |
a604eec16b3daec7e8dbfa70e83e62866cfc0e56 | 7,258,494,759,613 | a26d461a07241a4ada19f268fecb248510e75e03 | /src/main/java/com/dp/creational/abstractfactory/kingdom/KingdomFactory.java | ae27fdb5fb9d0ae4ecd92562b846e70bdba9123a | [] | no_license | govijay/design-patterns | https://github.com/govijay/design-patterns | f9c0bd48f48e83c419ab315154a85d0fed679e58 | 91e0521f81479603601c5a0400a57b09e3589dc9 | refs/heads/main | 2023-01-23T01:52:33.973000 | 2020-11-12T20:27:06 | 2020-11-12T20:27:06 | 300,835,054 | 0 | 0 | null | false | 2020-11-12T20:27:07 | 2020-10-03T08:40:55 | 2020-10-10T10:16:48 | 2020-11-12T20:27:06 | 337 | 0 | 0 | 0 | Java | false | false | package com.dp.creational.abstractfactory.kingdom;
/**
* Abstract Factory Interface.
*/
public interface KingdomFactory {
Castle createCastle();
King createKing();
Army createArmy();
}
| UTF-8 | Java | 196 | java | KingdomFactory.java | Java | [] | null | [] | package com.dp.creational.abstractfactory.kingdom;
/**
* Abstract Factory Interface.
*/
public interface KingdomFactory {
Castle createCastle();
King createKing();
Army createArmy();
}
| 196 | 0.729592 | 0.729592 | 12 | 15.333333 | 15.975676 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 11 |
6b3bc2b69f0d71e2f295712ee79156d053606952 | 7,258,494,758,500 | 600418476a563d7f590fdd355a326572786f35cf | /app/src/main/java/com/bimii/mobile/cache/CacheConstants.java | e8aabe6b7edb67f30fe38e3258c4200cdc77ffbe | [] | no_license | thinkmobiles/Bimii | https://github.com/thinkmobiles/Bimii | 1e7fb913dd99cc00bc00196e67b90ce0f1aa3caf | b433d30604dae6beafdfcb8a55cd7a21dd7011f2 | refs/heads/master | 2021-01-20T11:01:03.898000 | 2015-10-14T13:40:26 | 2015-10-14T13:40:26 | 41,723,582 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bimii.mobile.cache;
public final class CacheConstants {
public static final String CACHE_TOKEN = "bimii_token"; // String
public static final String CACHE_LAUNCHER_BIMII = "bimii_launcher"; // Boolean
}
| UTF-8 | Java | 246 | java | CacheConstants.java | Java | [
{
"context": "ublic static final String CACHE_TOKEN = \"bimii_token\"; // String\n public static final String",
"end": 136,
"score": 0.7650160193443298,
"start": 125,
"tag": "PASSWORD",
"value": "bimii_token"
}
] | null | [] | package com.bimii.mobile.cache;
public final class CacheConstants {
public static final String CACHE_TOKEN = "<PASSWORD>"; // String
public static final String CACHE_LAUNCHER_BIMII = "bimii_launcher"; // Boolean
}
| 245 | 0.674797 | 0.674797 | 8 | 29.75 | 34.870296 | 86 | true | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 11 |
7083a32b6592afb9363fd547e2e70917632e5b31 | 11,725,260,737,574 | 68789d3d4ca2f4f6f2585f9872c4c2b5876cb339 | /Apple.java | e69a56b85d7e526b5632f4fa8fcf8c740983f02c | [] | no_license | sintanbabo/Java | https://github.com/sintanbabo/Java | dfb6e3deccd1fa9cf75207eaebb96ceb351faafa | 5ae2cc4dd99a8d279e0bed69706ddf8a720d3826 | refs/heads/master | 2022-09-25T06:50:10.253000 | 2021-02-13T13:38:49 | 2021-02-13T13:38:49 | 152,959,183 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.ArrayList;
import java.util.List;
public class Apple
{
enum Color {RED, GREEN};
public Color color;
public int weight;
public Apple()
{
this.color = Color.RED;
this.weight = 0;
}
public Apple(int weight, Color color)
{
this.color = color;
this.weight = weight;
}
public Color getColor() {
return color;
}
public int getWeight()
{
return weight;
}
public static List<Apple> filterGreenApple(List<Apple> inventory) {
List<Apple> result = new ArrayList<>();
for (Apple apple : inventory) {
if (Apple.Color.GREEN.equals(apple.getColor())) {
result.add(apple);
}
}
return result;
}
public static List<Apple> fillterAppleByColor(List<Apple> inventory, Color color) {
List<Apple> result = new ArrayList<>();
for (Apple apple : inventory) {
if (apple.getColor().equals(color)) {
result.add(apple);
}
}
return result;
}
} | UTF-8 | Java | 1,103 | java | Apple.java | Java | [] | null | [] | import java.util.ArrayList;
import java.util.List;
public class Apple
{
enum Color {RED, GREEN};
public Color color;
public int weight;
public Apple()
{
this.color = Color.RED;
this.weight = 0;
}
public Apple(int weight, Color color)
{
this.color = color;
this.weight = weight;
}
public Color getColor() {
return color;
}
public int getWeight()
{
return weight;
}
public static List<Apple> filterGreenApple(List<Apple> inventory) {
List<Apple> result = new ArrayList<>();
for (Apple apple : inventory) {
if (Apple.Color.GREEN.equals(apple.getColor())) {
result.add(apple);
}
}
return result;
}
public static List<Apple> fillterAppleByColor(List<Apple> inventory, Color color) {
List<Apple> result = new ArrayList<>();
for (Apple apple : inventory) {
if (apple.getColor().equals(color)) {
result.add(apple);
}
}
return result;
}
} | 1,103 | 0.543064 | 0.542158 | 53 | 19.830189 | 19.544565 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.377358 | false | false | 11 |
f06ae03c7a26fc9521845d965e3878594f456e92 | 10,711,648,466,362 | 7536a7a9e35fb0abdd2de02e80da2029621be09c | /app/src/main/java/com/dacodes/bepensa/adapters/RecyclerViewChatAdapter.java | 4c87a371a9f8e3bc4eb9ffdfcf388771347db362 | [] | no_license | aeuan/BBE2101.aliados.android | https://github.com/aeuan/BBE2101.aliados.android | 7d625fccb1277829accd520428122497959cea73 | c2c8692a86abe2e9f8dc46470b498fae5db55de1 | refs/heads/master | 2023-06-21T19:10:25.984000 | 2021-07-20T17:38:06 | 2021-07-20T17:38:06 | 387,868,712 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dacodes.bepensa.adapters;
/**
* Created by marioguillermo on 3/31/17.
*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.dacodes.bepensa.R;
import com.dacodes.bepensa.entities.Chat.ChatEntity;
import com.dacodes.bepensa.utils.DateFormatter;
import com.dacodes.bepensa.utils.FormatDate;
import java.util.ArrayList;
import java.util.Locale;
public class RecyclerViewChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
public void setItems(ArrayList<ChatEntity> items) {
this.items = items;
}
private ArrayList<ChatEntity> items;
public static final int CHAT_BEPENSA_ADMIN = 1;
public static final int CHAT_BEPENSA_USER = 2;
Locale locale = new Locale("es", "ES");
public RecyclerViewChatAdapter(Context context) {
this.mContext = context;
this.items = new ArrayList<>();
}
private class ChatBepensaAdmin extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView profile_iv;
TextView text_tv, date_tv,tvDate;
ChatBepensaAdmin(View v) {
super(v);
v.setOnClickListener(this);
profile_iv = (ImageView) v.findViewById(R.id.profile_iv);
text_tv = (TextView) v.findViewById(R.id.text_tv);
date_tv = (TextView)v.findViewById(R.id.date_tv);
tvDate=v.findViewById(R.id.tvDate);
}
@Override
public void onClick(View v) {
}
}
private class ChatBepensaUser extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView profile_iv;
TextView text_tv, date_tv,tvDate;
ChatBepensaUser(View v) {
super(v);
v.setOnClickListener(this);
profile_iv = (ImageView) v.findViewById(R.id.profile_iv);
text_tv = (TextView) v.findViewById(R.id.text_tv);
date_tv = (TextView)v.findViewById(R.id.date_tv);
tvDate=v.findViewById(R.id.tvDate);
}
@Override
public void onClick(View v) {
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = null;
switch (viewType) {
case CHAT_BEPENSA_ADMIN:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_bepensa_item, parent, false);
return new ChatBepensaAdmin(v);
case CHAT_BEPENSA_USER:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_user_item, parent, false);
return new ChatBepensaUser(v);
default:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_user_item, parent, false);
return new ChatBepensaUser(v);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
int viewType = viewHolder.getItemViewType();
switch (viewType) {
case CHAT_BEPENSA_ADMIN:
ChatBepensaAdmin vhBN = (ChatBepensaAdmin) viewHolder;
configureBepensaAdminChat(vhBN, position);
break;
case CHAT_BEPENSA_USER:
ChatBepensaUser vhBO = (ChatBepensaUser) viewHolder;
configureBepensaUserChat(vhBO, position);
break;
}
}
//Returns the view type of the item at position for the purposes of view recycling.
@Override
public int getItemViewType(int position) {
return items.get(position).getType_model();
}
private void configureBepensaAdminChat(final ChatBepensaAdmin vh, int position) {
String date=FormatDate.getFormatMin(items.get(position).getCreatedAt(),mContext.getResources().getString(R.string.format_date));
vh.date_tv.setText(date);
vh.text_tv.setText(""+items.get(position).getText());
vh.tvDate.setText(DateFormatter
.formatDate("yyyy-MM-dd",
"dd'/'MM'/'yyyy",items.get(position).getCreatedAt(),
locale));
Glide.with(mContext).asBitmap().load(""+items.get(position).getUser().getAvatarUrl())
.apply(new RequestOptions().placeholder(R.drawable.placeholder_image).circleCrop())
.into(vh.profile_iv);
}
private void configureBepensaUserChat(final ChatBepensaUser vh, int position) {
String date=FormatDate.getFormatMin(items.get(position).getCreatedAt(),mContext.getResources().getString(R.string.format_date));
vh.date_tv.setText(date);
vh.text_tv.setText(""+items.get(position).getText());
vh.tvDate.setText(DateFormatter
.formatDate("yyyy-MM-dd",
"dd'/'MM'/'yyyy",items.get(position).getCreatedAt(),
locale));
Glide.with(mContext).asBitmap().load(""+items.get(position).getUser().getAvatarUrl())
.apply(new RequestOptions().placeholder(R.drawable.placeholder_image).circleCrop())
.into(vh.profile_iv);
}
@Override
public int getItemCount() {
if (items!=null){
return items.size();
}else{
return 0;
}
}
public void addBepensaAdminChat(ChatEntity chatEntity) {
items.add(chatEntity);
notifyDataSetChanged();
}
public void addBepensaUserChat(ChatEntity chatEntity){
items.add(chatEntity);
notifyDataSetChanged();
}
public void clearItems(){
items.clear();
}
public ArrayList<ChatEntity> getItems(){
return items;
}
}
| UTF-8 | Java | 6,008 | java | RecyclerViewChatAdapter.java | Java | [
{
"context": "e com.dacodes.bepensa.adapters;\n\n/**\n * Created by marioguillermo on 3/31/17.\n */\n\nimport android.content.Context;\n",
"end": 71,
"score": 0.9993626475334167,
"start": 57,
"tag": "USERNAME",
"value": "marioguillermo"
}
] | null | [] | package com.dacodes.bepensa.adapters;
/**
* Created by marioguillermo on 3/31/17.
*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.dacodes.bepensa.R;
import com.dacodes.bepensa.entities.Chat.ChatEntity;
import com.dacodes.bepensa.utils.DateFormatter;
import com.dacodes.bepensa.utils.FormatDate;
import java.util.ArrayList;
import java.util.Locale;
public class RecyclerViewChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
public void setItems(ArrayList<ChatEntity> items) {
this.items = items;
}
private ArrayList<ChatEntity> items;
public static final int CHAT_BEPENSA_ADMIN = 1;
public static final int CHAT_BEPENSA_USER = 2;
Locale locale = new Locale("es", "ES");
public RecyclerViewChatAdapter(Context context) {
this.mContext = context;
this.items = new ArrayList<>();
}
private class ChatBepensaAdmin extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView profile_iv;
TextView text_tv, date_tv,tvDate;
ChatBepensaAdmin(View v) {
super(v);
v.setOnClickListener(this);
profile_iv = (ImageView) v.findViewById(R.id.profile_iv);
text_tv = (TextView) v.findViewById(R.id.text_tv);
date_tv = (TextView)v.findViewById(R.id.date_tv);
tvDate=v.findViewById(R.id.tvDate);
}
@Override
public void onClick(View v) {
}
}
private class ChatBepensaUser extends RecyclerView.ViewHolder implements View.OnClickListener {
ImageView profile_iv;
TextView text_tv, date_tv,tvDate;
ChatBepensaUser(View v) {
super(v);
v.setOnClickListener(this);
profile_iv = (ImageView) v.findViewById(R.id.profile_iv);
text_tv = (TextView) v.findViewById(R.id.text_tv);
date_tv = (TextView)v.findViewById(R.id.date_tv);
tvDate=v.findViewById(R.id.tvDate);
}
@Override
public void onClick(View v) {
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = null;
switch (viewType) {
case CHAT_BEPENSA_ADMIN:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_bepensa_item, parent, false);
return new ChatBepensaAdmin(v);
case CHAT_BEPENSA_USER:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_user_item, parent, false);
return new ChatBepensaUser(v);
default:
v = LayoutInflater.from(mContext)
.inflate(R.layout.chat_user_item, parent, false);
return new ChatBepensaUser(v);
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
int viewType = viewHolder.getItemViewType();
switch (viewType) {
case CHAT_BEPENSA_ADMIN:
ChatBepensaAdmin vhBN = (ChatBepensaAdmin) viewHolder;
configureBepensaAdminChat(vhBN, position);
break;
case CHAT_BEPENSA_USER:
ChatBepensaUser vhBO = (ChatBepensaUser) viewHolder;
configureBepensaUserChat(vhBO, position);
break;
}
}
//Returns the view type of the item at position for the purposes of view recycling.
@Override
public int getItemViewType(int position) {
return items.get(position).getType_model();
}
private void configureBepensaAdminChat(final ChatBepensaAdmin vh, int position) {
String date=FormatDate.getFormatMin(items.get(position).getCreatedAt(),mContext.getResources().getString(R.string.format_date));
vh.date_tv.setText(date);
vh.text_tv.setText(""+items.get(position).getText());
vh.tvDate.setText(DateFormatter
.formatDate("yyyy-MM-dd",
"dd'/'MM'/'yyyy",items.get(position).getCreatedAt(),
locale));
Glide.with(mContext).asBitmap().load(""+items.get(position).getUser().getAvatarUrl())
.apply(new RequestOptions().placeholder(R.drawable.placeholder_image).circleCrop())
.into(vh.profile_iv);
}
private void configureBepensaUserChat(final ChatBepensaUser vh, int position) {
String date=FormatDate.getFormatMin(items.get(position).getCreatedAt(),mContext.getResources().getString(R.string.format_date));
vh.date_tv.setText(date);
vh.text_tv.setText(""+items.get(position).getText());
vh.tvDate.setText(DateFormatter
.formatDate("yyyy-MM-dd",
"dd'/'MM'/'yyyy",items.get(position).getCreatedAt(),
locale));
Glide.with(mContext).asBitmap().load(""+items.get(position).getUser().getAvatarUrl())
.apply(new RequestOptions().placeholder(R.drawable.placeholder_image).circleCrop())
.into(vh.profile_iv);
}
@Override
public int getItemCount() {
if (items!=null){
return items.size();
}else{
return 0;
}
}
public void addBepensaAdminChat(ChatEntity chatEntity) {
items.add(chatEntity);
notifyDataSetChanged();
}
public void addBepensaUserChat(ChatEntity chatEntity){
items.add(chatEntity);
notifyDataSetChanged();
}
public void clearItems(){
items.clear();
}
public ArrayList<ChatEntity> getItems(){
return items;
}
}
| 6,008 | 0.624501 | 0.623169 | 184 | 31.641304 | 28.888874 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.532609 | false | false | 11 |
8b60b4ef7d47e747182ffc14d3a92cd01b1275b9 | 13,718,125,551,843 | 3fe26ebd7f69891365c4262c763c37ff8a4f8c88 | /firefly-db/src/test/java/test/db/MetricsDemo.java | ebad3b86e03c9e56e0e44bacb70f475199f80879 | [
"Apache-2.0"
] | permissive | annahosanna/firefly | https://github.com/annahosanna/firefly | 3fa28012074f884fe16aa49968fa4bcf43abb4d9 | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | refs/heads/master | 2020-12-06T05:35:15.700000 | 2018-11-23T05:49:31 | 2018-11-23T05:49:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package test.db;
import com.firefly.db.jdbc.helper.JDBCHelper;
import com.firefly.utils.concurrent.ThreadUtils;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
/**
* @author Pengtao Qiu
*/
public class MetricsDemo {
public static void main(String[] args) {
JDBCHelper jdbcHelper = createJDBCHelper();
initData(jdbcHelper);
while (true) {
User user = jdbcHelper.queryById(User.class, 3);
System.out.println(user);
ThreadUtils.sleep(1000L);
}
}
static JDBCHelper createJDBCHelper() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:h2:mem:test");
config.setDriverClassName("org.h2.Driver");
config.setAutoCommit(false);
HikariDataSource ds = new HikariDataSource(config);
return new JDBCHelper(ds);
}
static void initData(JDBCHelper jdbcHelper) {
int size = 10;
jdbcHelper.update("drop schema if exists test");
jdbcHelper.update("create schema test");
jdbcHelper.update("set mode MySQL");
jdbcHelper.update(
"CREATE TABLE `test`.`user`(id BIGINT AUTO_INCREMENT PRIMARY KEY, pt_name VARCHAR(255), pt_password VARCHAR(255), other_info VARCHAR(255))");
for (int i = 1; i <= size; i++) {
jdbcHelper.insert("insert into `test`.`user`(pt_name, pt_password) values(?,?)", "test" + i, "test_pwd" + i);
}
}
}
| UTF-8 | Java | 1,483 | java | MetricsDemo.java | Java | [
{
"context": "om.zaxxer.hikari.HikariDataSource;\n\n/**\n * @author Pengtao Qiu\n */\npublic class MetricsDemo {\n\n public static",
"end": 222,
"score": 0.9998422861099243,
"start": 211,
"tag": "NAME",
"value": "Pengtao Qiu"
}
] | null | [] | package test.db;
import com.firefly.db.jdbc.helper.JDBCHelper;
import com.firefly.utils.concurrent.ThreadUtils;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
/**
* @author <NAME>
*/
public class MetricsDemo {
public static void main(String[] args) {
JDBCHelper jdbcHelper = createJDBCHelper();
initData(jdbcHelper);
while (true) {
User user = jdbcHelper.queryById(User.class, 3);
System.out.println(user);
ThreadUtils.sleep(1000L);
}
}
static JDBCHelper createJDBCHelper() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:h2:mem:test");
config.setDriverClassName("org.h2.Driver");
config.setAutoCommit(false);
HikariDataSource ds = new HikariDataSource(config);
return new JDBCHelper(ds);
}
static void initData(JDBCHelper jdbcHelper) {
int size = 10;
jdbcHelper.update("drop schema if exists test");
jdbcHelper.update("create schema test");
jdbcHelper.update("set mode MySQL");
jdbcHelper.update(
"CREATE TABLE `test`.`user`(id BIGINT AUTO_INCREMENT PRIMARY KEY, pt_name VARCHAR(255), pt_password VARCHAR(255), other_info VARCHAR(255))");
for (int i = 1; i <= size; i++) {
jdbcHelper.insert("insert into `test`.`user`(pt_name, pt_password) values(?,?)", "test" + i, "test_pwd" + i);
}
}
}
| 1,478 | 0.632502 | 0.61969 | 45 | 31.955555 | 30.615868 | 157 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.711111 | false | false | 11 |
e5ffea615191ad808da817b7fccda9648fa6c4ac | 18,519,898,982,091 | cc49c91d45209b41200b7588c9040b43687664fc | /sun/security/pkcs11/wrapper/Functions.java | c6733ed70730c2faf33abf4a4d9a72f81b3ac047 | [
"Apache-2.0"
] | permissive | zeng233/rejdk | https://github.com/zeng233/rejdk | c3e2a8e3757b89dbfe143b92d6c8c5b87310512b | 3ab7da05c22d0d5a9491f4742e3b293aed408e2c | refs/heads/master | 2020-09-03T06:28:37.126000 | 2016-11-12T01:21:27 | 2016-11-12T01:21:27 | 73,522,873 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import ajava.util.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
* This class contains onyl static methods. It is the place for all functions
* that are used by several classes in this package.
*
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
*/
public class Functions {
// maps between ids and their names, forward and reverse
// ids are stored as Integers to save space
// since only the lower 32 bits are ever used anyway
// mechanisms (CKM_*)
private static final Map<Integer,String> mechNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> mechIds =
new HashMap<String,Integer>();
// key types (CKK_*)
private static final Map<Integer,String> keyNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> keyIds =
new HashMap<String,Integer>();
// attributes (CKA_*)
private static final Map<Integer,String> attributeNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> attributeIds =
new HashMap<String,Integer>();
// object classes (CKO_*)
private static final Map<Integer,String> objectClassNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> objectClassIds =
new HashMap<String,Integer>();
/**
* For converting numbers to their hex presentation.
*/
private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
/**
* Converts a long value to a hexadecimal String of length 16. Includes
* leading zeros if necessary.
*
* @param value The long value to be converted.
* @return The hexadecimal string representation of the long value.
*/
public static String toFullHexString(long value) {
long currentValue = value;
StringBuffer stringBuffer = new StringBuffer(16);
for(int j = 0; j < 16; j++) {
int currentDigit = (int) currentValue & 0xf;
stringBuffer.append(HEX_DIGITS[currentDigit]);
currentValue >>>= 4;
}
return stringBuffer.reverse().toString();
}
/**
* Converts a int value to a hexadecimal String of length 8. Includes
* leading zeros if necessary.
*
* @param value The int value to be converted.
* @return The hexadecimal string representation of the int value.
*/
public static String toFullHexString(int value) {
int currentValue = value;
StringBuffer stringBuffer = new StringBuffer(8);
for(int i = 0; i < 8; i++) {
int currentDigit = currentValue & 0xf;
stringBuffer.append(HEX_DIGITS[currentDigit]);
currentValue >>>= 4;
}
return stringBuffer.reverse().toString();
}
/**
* converts a long value to a hexadecimal String
*
* @param value the long value to be converted
* @return the hexadecimal string representation of the long value
*/
public static String toHexString(long value) {
return Long.toHexString(value);
}
/**
* Converts a byte array to a hexadecimal String. Each byte is presented by
* its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is
* included in the result.
*
* @param value the byte array to be converted
* @return the hexadecimal string representation of the byte array
*/
public static String toHexString(byte[] value) {
if (value == null) {
return null;
}
StringBuffer buffer = new StringBuffer(2 * value.length);
int single;
for (int i = 0; i < value.length; i++) {
single = value[i] & 0xFF;
if (single < 0x10) {
buffer.append('0');
}
buffer.append(Integer.toString(single, 16));
}
return buffer.toString();
}
/**
* converts a long value to a binary String
*
* @param value the long value to be converted
* @return the binary string representation of the long value
*/
public static String toBinaryString(long value) {
return Long.toString(value, 2);
}
/**
* converts a byte array to a binary String
*
* @param value the byte array to be converted
* @return the binary string representation of the byte array
*/
public static String toBinaryString(byte[] value) {
BigInteger helpBigInteger = new BigInteger(1, value);
return helpBigInteger.toString(2);
}
private static class Flags {
private final long[] flagIds;
private final String[] flagNames;
Flags(long[] flagIds, String[] flagNames) {
if (flagIds.length != flagNames.length) {
throw new AssertionError("Array lengths do not match");
}
this.flagIds = flagIds;
this.flagNames = flagNames;
}
String toString(long val) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (int i = 0; i < flagIds.length; i++) {
if ((val & flagIds[i]) != 0) {
if (first == false) {
sb.append(" | ");
}
sb.append(flagNames[i]);
first = false;
}
}
return sb.toString();
}
}
private static final Flags slotInfoFlags = new Flags(new long[] {
CKF_TOKEN_PRESENT,
CKF_REMOVABLE_DEVICE,
CKF_HW_SLOT,
}, new String[] {
"CKF_TOKEN_PRESENT",
"CKF_REMOVABLE_DEVICE",
"CKF_HW_SLOT",
});
/**
* converts the long value flags to a SlotInfoFlag string
*
* @param flags the flags to be converted
* @return the SlotInfoFlag string representation of the flags
*/
public static String slotInfoFlagsToString(long flags) {
return slotInfoFlags.toString(flags);
}
private static final Flags tokenInfoFlags = new Flags(new long[] {
CKF_RNG,
CKF_WRITE_PROTECTED,
CKF_LOGIN_REQUIRED,
CKF_USER_PIN_INITIALIZED,
CKF_RESTORE_KEY_NOT_NEEDED,
CKF_CLOCK_ON_TOKEN,
CKF_PROTECTED_AUTHENTICATION_PATH,
CKF_DUAL_CRYPTO_OPERATIONS,
CKF_TOKEN_INITIALIZED,
CKF_SECONDARY_AUTHENTICATION,
CKF_USER_PIN_COUNT_LOW,
CKF_USER_PIN_FINAL_TRY,
CKF_USER_PIN_LOCKED,
CKF_USER_PIN_TO_BE_CHANGED,
CKF_SO_PIN_COUNT_LOW,
CKF_SO_PIN_FINAL_TRY,
CKF_SO_PIN_LOCKED,
CKF_SO_PIN_TO_BE_CHANGED,
}, new String[] {
"CKF_RNG",
"CKF_WRITE_PROTECTED",
"CKF_LOGIN_REQUIRED",
"CKF_USER_PIN_INITIALIZED",
"CKF_RESTORE_KEY_NOT_NEEDED",
"CKF_CLOCK_ON_TOKEN",
"CKF_PROTECTED_AUTHENTICATION_PATH",
"CKF_DUAL_CRYPTO_OPERATIONS",
"CKF_TOKEN_INITIALIZED",
"CKF_SECONDARY_AUTHENTICATION",
"CKF_USER_PIN_COUNT_LOW",
"CKF_USER_PIN_FINAL_TRY",
"CKF_USER_PIN_LOCKED",
"CKF_USER_PIN_TO_BE_CHANGED",
"CKF_SO_PIN_COUNT_LOW",
"CKF_SO_PIN_FINAL_TRY",
"CKF_SO_PIN_LOCKED",
"CKF_SO_PIN_TO_BE_CHANGED",
});
/**
* converts long value flags to a TokenInfoFlag string
*
* @param flags the flags to be converted
* @return the TokenInfoFlag string representation of the flags
*/
public static String tokenInfoFlagsToString(long flags) {
return tokenInfoFlags.toString(flags);
}
private static final Flags sessionInfoFlags = new Flags(new long[] {
CKF_RW_SESSION,
CKF_SERIAL_SESSION,
}, new String[] {
"CKF_RW_SESSION",
"CKF_SERIAL_SESSION",
});
/**
* converts the long value flags to a SessionInfoFlag string
*
* @param flags the flags to be converted
* @return the SessionInfoFlag string representation of the flags
*/
public static String sessionInfoFlagsToString(long flags) {
return sessionInfoFlags.toString(flags);
}
/**
* converts the long value state to a SessionState string
*
* @param state the state to be converted
* @return the SessionState string representation of the state
*/
public static String sessionStateToString(long state) {
String name;
if (state == CKS_RO_PUBLIC_SESSION) {
name = "CKS_RO_PUBLIC_SESSION";
} else if (state == CKS_RO_USER_FUNCTIONS) {
name = "CKS_RO_USER_FUNCTIONS";
} else if (state == CKS_RW_PUBLIC_SESSION) {
name = "CKS_RW_PUBLIC_SESSION";
} else if (state == CKS_RW_USER_FUNCTIONS) {
name = "CKS_RW_USER_FUNCTIONS";
} else if (state == CKS_RW_SO_FUNCTIONS) {
name = "CKS_RW_SO_FUNCTIONS";
} else {
name = "ERROR: unknown session state 0x" + toFullHexString(state);
}
return name;
}
private static final Flags mechanismInfoFlags = new Flags(new long[] {
CKF_HW,
CKF_ENCRYPT,
CKF_DECRYPT,
CKF_DIGEST,
CKF_SIGN,
CKF_SIGN_RECOVER,
CKF_VERIFY,
CKF_VERIFY_RECOVER,
CKF_GENERATE,
CKF_GENERATE_KEY_PAIR,
CKF_WRAP,
CKF_UNWRAP,
CKF_DERIVE,
CKF_EC_F_P,
CKF_EC_F_2M,
CKF_EC_ECPARAMETERS,
CKF_EC_NAMEDCURVE,
CKF_EC_UNCOMPRESS,
CKF_EC_COMPRESS,
CKF_EXTENSION,
}, new String[] {
"CKF_HW",
"CKF_ENCRYPT",
"CKF_DECRYPT",
"CKF_DIGEST",
"CKF_SIGN",
"CKF_SIGN_RECOVER",
"CKF_VERIFY",
"CKF_VERIFY_RECOVER",
"CKF_GENERATE",
"CKF_GENERATE_KEY_PAIR",
"CKF_WRAP",
"CKF_UNWRAP",
"CKF_DERIVE",
"CKF_EC_F_P",
"CKF_EC_F_2M",
"CKF_EC_ECPARAMETERS",
"CKF_EC_NAMEDCURVE",
"CKF_EC_UNCOMPRESS",
"CKF_EC_COMPRESS",
"CKF_EXTENSION",
});
/**
* converts the long value flags to a MechanismInfoFlag string
*
* @param flags the flags to be converted
* @return the MechanismInfoFlag string representation of the flags
*/
public static String mechanismInfoFlagsToString(long flags) {
return mechanismInfoFlags.toString(flags);
}
private static String getName(Map<Integer,String> nameMap, long id) {
String name = null;
if ((id >>> 32) == 0) {
name = nameMap.get(Integer.valueOf((int)id));
}
if (name == null) {
name = "Unknown 0x" + toFullHexString(id);
}
return name;
}
public static long getId(Map<String,Integer> idMap, String name) {
Integer mech = idMap.get(name);
if (mech == null) {
throw new IllegalArgumentException("Unknown name " + name);
}
return mech.intValue() & 0xffffffffL;
}
public static String getMechanismName(long id) {
return getName(mechNames, id);
}
public static long getMechanismId(String name) {
return getId(mechIds, name);
}
public static String getKeyName(long id) {
return getName(keyNames, id);
}
public static long getKeyId(String name) {
return getId(keyIds, name);
}
public static String getAttributeName(long id) {
return getName(attributeNames, id);
}
public static long getAttributeId(String name) {
return getId(attributeIds, name);
}
public static String getObjectClassName(long id) {
return getName(objectClassNames, id);
}
public static long getObjectClassId(String name) {
return getId(objectClassIds, name);
}
/**
* Check the given arrays for equalitiy. This method considers both arrays as
* equal, if both are <code>null</code> or both have the same length and
* contain exactly the same char values.
*
* @param array1 The first array.
* @param array2 The second array.
* @return True, if both arrays are <code>null</code> or both have the same
* length and contain exactly the same char values. False, otherwise.
* @preconditions
* @postconditions
*/
private static boolean equals(char[] array1, char[] array2) {
return Arrays.equals(array1, array2);
}
/**
* Check the given dates for equalitiy. This method considers both dates as
* equal, if both are <code>null</code> or both contain exactly the same char
* values.
*
* @param date1 The first date.
* @param date2 The second date.
* @return True, if both dates are <code>null</code> or both contain the same
* char values. False, otherwise.
* @preconditions
* @postconditions
*/
public static boolean equals(CK_DATE date1, CK_DATE date2) {
boolean equal = false;
if (date1 == date2) {
equal = true;
} else if ((date1 != null) && (date2 != null)) {
equal = equals(date1.year, date2.year)
&& equals(date1.month, date2.month)
&& equals(date1.day, date2.day);
} else {
equal = false;
}
return equal ;
}
/**
* Calculate a hash code for the given byte array.
*
* @param array The byte array.
* @return A hash code for the given array.
* @preconditions
* @postconditions
*/
public static int hashCode(byte[] array) {
int hash = 0;
if (array != null) {
for (int i = 0; (i < 4) && (i < array.length); i++) {
hash ^= (0xFF & array[i]) << ((i%4) << 3);
}
}
return hash ;
}
/**
* Calculate a hash code for the given char array.
*
* @param array The char array.
* @return A hash code for the given array.
* @preconditions
* @postconditions
*/
public static int hashCode(char[] array) {
int hash = 0;
if (array != null) {
for (int i = 0; (i < 4) && (i < array.length); i++) {
hash ^= (0xFFFF & array[i]) << ((i%2) << 4);
}
}
return hash ;
}
/**
* Calculate a hash code for the given date object.
*
* @param date The date object.
* @return A hash code for the given date.
* @preconditions
* @postconditions
*/
public static int hashCode(CK_DATE date) {
int hash = 0;
if (date != null) {
if (date.year.length == 4) {
hash ^= (0xFFFF & date.year[0]) << 16;
hash ^= 0xFFFF & date.year[1];
hash ^= (0xFFFF & date.year[2]) << 16;
hash ^= 0xFFFF & date.year[3];
}
if (date.month.length == 2) {
hash ^= (0xFFFF & date.month[0]) << 16;
hash ^= 0xFFFF & date.month[1];
}
if (date.day.length == 2) {
hash ^= (0xFFFF & date.day[0]) << 16;
hash ^= 0xFFFF & date.day[1];
}
}
return hash ;
}
private static void addMapping(Map<Integer,String> nameMap,
Map<String,Integer> idMap, long id, String name) {
if ((id >>> 32) != 0) {
throw new AssertionError("Id has high bits set: " + id + ", " + name);
}
Integer intId = Integer.valueOf((int)id);
if (nameMap.put(intId, name) != null) {
throw new AssertionError("Duplicate id: " + id + ", " + name);
}
if (idMap.put(name, intId) != null) {
throw new AssertionError("Duplicate name: " + id + ", " + name);
}
}
private static void addMech(long id, String name) {
addMapping(mechNames, mechIds, id, name);
}
private static void addKeyType(long id, String name) {
addMapping(keyNames, keyIds, id, name);
}
private static void addAttribute(long id, String name) {
addMapping(attributeNames, attributeIds, id, name);
}
private static void addObjectClass(long id, String name) {
addMapping(objectClassNames, objectClassIds, id, name);
}
static {
addMech(CKM_RSA_PKCS_KEY_PAIR_GEN, "CKM_RSA_PKCS_KEY_PAIR_GEN");
addMech(CKM_RSA_PKCS, "CKM_RSA_PKCS");
addMech(CKM_RSA_9796, "CKM_RSA_9796");
addMech(CKM_RSA_X_509, "CKM_RSA_X_509");
addMech(CKM_MD2_RSA_PKCS, "CKM_MD2_RSA_PKCS");
addMech(CKM_MD5_RSA_PKCS, "CKM_MD5_RSA_PKCS");
addMech(CKM_SHA1_RSA_PKCS, "CKM_SHA1_RSA_PKCS");
addMech(CKM_RIPEMD128_RSA_PKCS, "CKM_RIPEMD128_RSA_PKCS");
addMech(CKM_RIPEMD160_RSA_PKCS, "CKM_RIPEMD160_RSA_PKCS");
addMech(CKM_RSA_PKCS_OAEP, "CKM_RSA_PKCS_OAEP");
addMech(CKM_RSA_X9_31_KEY_PAIR_GEN, "CKM_RSA_X9_31_KEY_PAIR_GEN");
addMech(CKM_RSA_X9_31, "CKM_RSA_X9_31");
addMech(CKM_SHA1_RSA_X9_31, "CKM_SHA1_RSA_X9_31");
addMech(CKM_RSA_PKCS_PSS, "CKM_RSA_PKCS_PSS");
addMech(CKM_SHA1_RSA_PKCS_PSS, "CKM_SHA1_RSA_PKCS_PSS");
addMech(CKM_DSA_KEY_PAIR_GEN, "CKM_DSA_KEY_PAIR_GEN");
addMech(CKM_DSA, "CKM_DSA");
addMech(CKM_DSA_SHA1, "CKM_DSA_SHA1");
addMech(CKM_DH_PKCS_KEY_PAIR_GEN, "CKM_DH_PKCS_KEY_PAIR_GEN");
addMech(CKM_DH_PKCS_DERIVE, "CKM_DH_PKCS_DERIVE");
addMech(CKM_X9_42_DH_KEY_PAIR_GEN, "CKM_X9_42_DH_KEY_PAIR_GEN");
addMech(CKM_X9_42_DH_DERIVE, "CKM_X9_42_DH_DERIVE");
addMech(CKM_X9_42_DH_HYBRID_DERIVE, "CKM_X9_42_DH_HYBRID_DERIVE");
addMech(CKM_X9_42_MQV_DERIVE, "CKM_X9_42_MQV_DERIVE");
addMech(CKM_SHA224_RSA_PKCS, "CKM_SHA224_RSA_PKCS");
addMech(CKM_SHA256_RSA_PKCS, "CKM_SHA256_RSA_PKCS");
addMech(CKM_SHA384_RSA_PKCS, "CKM_SHA384_RSA_PKCS");
addMech(CKM_SHA512_RSA_PKCS, "CKM_SHA512_RSA_PKCS");
addMech(CKM_RC2_KEY_GEN, "CKM_RC2_KEY_GEN");
addMech(CKM_RC2_ECB, "CKM_RC2_ECB");
addMech(CKM_RC2_CBC, "CKM_RC2_CBC");
addMech(CKM_RC2_MAC, "CKM_RC2_MAC");
addMech(CKM_RC2_MAC_GENERAL, "CKM_RC2_MAC_GENERAL");
addMech(CKM_RC2_CBC_PAD, "CKM_RC2_CBC_PAD");
addMech(CKM_RC4_KEY_GEN, "CKM_RC4_KEY_GEN");
addMech(CKM_RC4, "CKM_RC4");
addMech(CKM_DES_KEY_GEN, "CKM_DES_KEY_GEN");
addMech(CKM_DES_ECB, "CKM_DES_ECB");
addMech(CKM_DES_CBC, "CKM_DES_CBC");
addMech(CKM_DES_MAC, "CKM_DES_MAC");
addMech(CKM_DES_MAC_GENERAL, "CKM_DES_MAC_GENERAL");
addMech(CKM_DES_CBC_PAD, "CKM_DES_CBC_PAD");
addMech(CKM_DES2_KEY_GEN, "CKM_DES2_KEY_GEN");
addMech(CKM_DES3_KEY_GEN, "CKM_DES3_KEY_GEN");
addMech(CKM_DES3_ECB, "CKM_DES3_ECB");
addMech(CKM_DES3_CBC, "CKM_DES3_CBC");
addMech(CKM_DES3_MAC, "CKM_DES3_MAC");
addMech(CKM_DES3_MAC_GENERAL, "CKM_DES3_MAC_GENERAL");
addMech(CKM_DES3_CBC_PAD, "CKM_DES3_CBC_PAD");
addMech(CKM_CDMF_KEY_GEN, "CKM_CDMF_KEY_GEN");
addMech(CKM_CDMF_ECB, "CKM_CDMF_ECB");
addMech(CKM_CDMF_CBC, "CKM_CDMF_CBC");
addMech(CKM_CDMF_MAC, "CKM_CDMF_MAC");
addMech(CKM_CDMF_MAC_GENERAL, "CKM_CDMF_MAC_GENERAL");
addMech(CKM_CDMF_CBC_PAD, "CKM_CDMF_CBC_PAD");
addMech(CKM_MD2, "CKM_MD2");
addMech(CKM_MD2_HMAC, "CKM_MD2_HMAC");
addMech(CKM_MD2_HMAC_GENERAL, "CKM_MD2_HMAC_GENERAL");
addMech(CKM_MD5, "CKM_MD5");
addMech(CKM_MD5_HMAC, "CKM_MD5_HMAC");
addMech(CKM_MD5_HMAC_GENERAL, "CKM_MD5_HMAC_GENERAL");
addMech(CKM_SHA_1, "CKM_SHA_1");
addMech(CKM_SHA_1_HMAC, "CKM_SHA_1_HMAC");
addMech(CKM_SHA_1_HMAC_GENERAL, "CKM_SHA_1_HMAC_GENERAL");
addMech(CKM_RIPEMD128, "CKM_RIPEMD128");
addMech(CKM_RIPEMD128_HMAC, "CKM_RIPEMD128_HMAC");
addMech(CKM_RIPEMD128_HMAC_GENERAL, "CKM_RIPEMD128_HMAC_GENERAL");
addMech(CKM_RIPEMD160, "CKM_RIPEMD160");
addMech(CKM_RIPEMD160_HMAC, "CKM_RIPEMD160_HMAC");
addMech(CKM_RIPEMD160_HMAC_GENERAL, "CKM_RIPEMD160_HMAC_GENERAL");
addMech(CKM_SHA224, "CKM_SHA224");
addMech(CKM_SHA224_HMAC, "CKM_SHA224_HMAC");
addMech(CKM_SHA224_HMAC_GENERAL, "CKM_SHA224_HMAC_GENERAL");
addMech(CKM_SHA256, "CKM_SHA256");
addMech(CKM_SHA256_HMAC, "CKM_SHA256_HMAC");
addMech(CKM_SHA256_HMAC_GENERAL, "CKM_SHA256_HMAC_GENERAL");
addMech(CKM_SHA384, "CKM_SHA384");
addMech(CKM_SHA384_HMAC, "CKM_SHA384_HMAC");
addMech(CKM_SHA384_HMAC_GENERAL, "CKM_SHA384_HMAC_GENERAL");
addMech(CKM_SHA512, "CKM_SHA512");
addMech(CKM_SHA512_HMAC, "CKM_SHA512_HMAC");
addMech(CKM_SHA512_HMAC_GENERAL, "CKM_SHA512_HMAC_GENERAL");
addMech(CKM_CAST_KEY_GEN, "CKM_CAST_KEY_GEN");
addMech(CKM_CAST_ECB, "CKM_CAST_ECB");
addMech(CKM_CAST_CBC, "CKM_CAST_CBC");
addMech(CKM_CAST_MAC, "CKM_CAST_MAC");
addMech(CKM_CAST_MAC_GENERAL, "CKM_CAST_MAC_GENERAL");
addMech(CKM_CAST_CBC_PAD, "CKM_CAST_CBC_PAD");
addMech(CKM_CAST3_KEY_GEN, "CKM_CAST3_KEY_GEN");
addMech(CKM_CAST3_ECB, "CKM_CAST3_ECB");
addMech(CKM_CAST3_CBC, "CKM_CAST3_CBC");
addMech(CKM_CAST3_MAC, "CKM_CAST3_MAC");
addMech(CKM_CAST3_MAC_GENERAL, "CKM_CAST3_MAC_GENERAL");
addMech(CKM_CAST3_CBC_PAD, "CKM_CAST3_CBC_PAD");
addMech(CKM_CAST128_KEY_GEN, "CKM_CAST128_KEY_GEN");
addMech(CKM_CAST128_ECB, "CKM_CAST128_ECB");
addMech(CKM_CAST128_CBC, "CKM_CAST128_CBC");
addMech(CKM_CAST128_MAC, "CKM_CAST128_MAC");
addMech(CKM_CAST128_MAC_GENERAL, "CKM_CAST128_MAC_GENERAL");
addMech(CKM_CAST128_CBC_PAD, "CKM_CAST128_CBC_PAD");
addMech(CKM_RC5_KEY_GEN, "CKM_RC5_KEY_GEN");
addMech(CKM_RC5_ECB, "CKM_RC5_ECB");
addMech(CKM_RC5_CBC, "CKM_RC5_CBC");
addMech(CKM_RC5_MAC, "CKM_RC5_MAC");
addMech(CKM_RC5_MAC_GENERAL, "CKM_RC5_MAC_GENERAL");
addMech(CKM_RC5_CBC_PAD, "CKM_RC5_CBC_PAD");
addMech(CKM_IDEA_KEY_GEN, "CKM_IDEA_KEY_GEN");
addMech(CKM_IDEA_ECB, "CKM_IDEA_ECB");
addMech(CKM_IDEA_CBC, "CKM_IDEA_CBC");
addMech(CKM_IDEA_MAC, "CKM_IDEA_MAC");
addMech(CKM_IDEA_MAC_GENERAL, "CKM_IDEA_MAC_GENERAL");
addMech(CKM_IDEA_CBC_PAD, "CKM_IDEA_CBC_PAD");
addMech(CKM_GENERIC_SECRET_KEY_GEN, "CKM_GENERIC_SECRET_KEY_GEN");
addMech(CKM_CONCATENATE_BASE_AND_KEY, "CKM_CONCATENATE_BASE_AND_KEY");
addMech(CKM_CONCATENATE_BASE_AND_DATA, "CKM_CONCATENATE_BASE_AND_DATA");
addMech(CKM_CONCATENATE_DATA_AND_BASE, "CKM_CONCATENATE_DATA_AND_BASE");
addMech(CKM_XOR_BASE_AND_DATA, "CKM_XOR_BASE_AND_DATA");
addMech(CKM_EXTRACT_KEY_FROM_KEY, "CKM_EXTRACT_KEY_FROM_KEY");
addMech(CKM_SSL3_PRE_MASTER_KEY_GEN, "CKM_SSL3_PRE_MASTER_KEY_GEN");
addMech(CKM_SSL3_MASTER_KEY_DERIVE, "CKM_SSL3_MASTER_KEY_DERIVE");
addMech(CKM_SSL3_KEY_AND_MAC_DERIVE, "CKM_SSL3_KEY_AND_MAC_DERIVE");
addMech(CKM_SSL3_MASTER_KEY_DERIVE_DH, "CKM_SSL3_MASTER_KEY_DERIVE_DH");
addMech(CKM_TLS_PRE_MASTER_KEY_GEN, "CKM_TLS_PRE_MASTER_KEY_GEN");
addMech(CKM_TLS_MASTER_KEY_DERIVE, "CKM_TLS_MASTER_KEY_DERIVE");
addMech(CKM_TLS_KEY_AND_MAC_DERIVE, "CKM_TLS_KEY_AND_MAC_DERIVE");
addMech(CKM_TLS_MASTER_KEY_DERIVE_DH, "CKM_TLS_MASTER_KEY_DERIVE_DH");
addMech(CKM_TLS_PRF, "CKM_TLS_PRF");
addMech(CKM_SSL3_MD5_MAC, "CKM_SSL3_MD5_MAC");
addMech(CKM_SSL3_SHA1_MAC, "CKM_SSL3_SHA1_MAC");
addMech(CKM_MD5_KEY_DERIVATION, "CKM_MD5_KEY_DERIVATION");
addMech(CKM_MD2_KEY_DERIVATION, "CKM_MD2_KEY_DERIVATION");
addMech(CKM_SHA1_KEY_DERIVATION, "CKM_SHA1_KEY_DERIVATION");
addMech(CKM_SHA224_KEY_DERIVATION, "CKM_SHA224_KEY_DERIVATION");
addMech(CKM_SHA256_KEY_DERIVATION, "CKM_SHA256_KEY_DERIVATION");
addMech(CKM_SHA384_KEY_DERIVATION, "CKM_SHA384_KEY_DERIVATION");
addMech(CKM_SHA512_KEY_DERIVATION, "CKM_SHA512_KEY_DERIVATION");
addMech(CKM_PBE_MD2_DES_CBC, "CKM_PBE_MD2_DES_CBC");
addMech(CKM_PBE_MD5_DES_CBC, "CKM_PBE_MD5_DES_CBC");
addMech(CKM_PBE_MD5_CAST_CBC, "CKM_PBE_MD5_CAST_CBC");
addMech(CKM_PBE_MD5_CAST3_CBC, "CKM_PBE_MD5_CAST3_CBC");
addMech(CKM_PBE_MD5_CAST128_CBC, "CKM_PBE_MD5_CAST128_CBC");
addMech(CKM_PBE_SHA1_CAST128_CBC, "CKM_PBE_SHA1_CAST128_CBC");
addMech(CKM_PBE_SHA1_RC4_128, "CKM_PBE_SHA1_RC4_128");
addMech(CKM_PBE_SHA1_RC4_40, "CKM_PBE_SHA1_RC4_40");
addMech(CKM_PBE_SHA1_DES3_EDE_CBC, "CKM_PBE_SHA1_DES3_EDE_CBC");
addMech(CKM_PBE_SHA1_DES2_EDE_CBC, "CKM_PBE_SHA1_DES2_EDE_CBC");
addMech(CKM_PBE_SHA1_RC2_128_CBC, "CKM_PBE_SHA1_RC2_128_CBC");
addMech(CKM_PBE_SHA1_RC2_40_CBC, "CKM_PBE_SHA1_RC2_40_CBC");
addMech(CKM_PKCS5_PBKD2, "CKM_PKCS5_PBKD2");
addMech(CKM_PBA_SHA1_WITH_SHA1_HMAC, "CKM_PBA_SHA1_WITH_SHA1_HMAC");
addMech(CKM_KEY_WRAP_LYNKS, "CKM_KEY_WRAP_LYNKS");
addMech(CKM_KEY_WRAP_SET_OAEP, "CKM_KEY_WRAP_SET_OAEP");
addMech(CKM_SKIPJACK_KEY_GEN, "CKM_SKIPJACK_KEY_GEN");
addMech(CKM_SKIPJACK_ECB64, "CKM_SKIPJACK_ECB64");
addMech(CKM_SKIPJACK_CBC64, "CKM_SKIPJACK_CBC64");
addMech(CKM_SKIPJACK_OFB64, "CKM_SKIPJACK_OFB64");
addMech(CKM_SKIPJACK_CFB64, "CKM_SKIPJACK_CFB64");
addMech(CKM_SKIPJACK_CFB32, "CKM_SKIPJACK_CFB32");
addMech(CKM_SKIPJACK_CFB16, "CKM_SKIPJACK_CFB16");
addMech(CKM_SKIPJACK_CFB8, "CKM_SKIPJACK_CFB8");
addMech(CKM_SKIPJACK_WRAP, "CKM_SKIPJACK_WRAP");
addMech(CKM_SKIPJACK_PRIVATE_WRAP, "CKM_SKIPJACK_PRIVATE_WRAP");
addMech(CKM_SKIPJACK_RELAYX, "CKM_SKIPJACK_RELAYX");
addMech(CKM_KEA_KEY_PAIR_GEN, "CKM_KEA_KEY_PAIR_GEN");
addMech(CKM_KEA_KEY_DERIVE, "CKM_KEA_KEY_DERIVE");
addMech(CKM_FORTEZZA_TIMESTAMP, "CKM_FORTEZZA_TIMESTAMP");
addMech(CKM_BATON_KEY_GEN, "CKM_BATON_KEY_GEN");
addMech(CKM_BATON_ECB128, "CKM_BATON_ECB128");
addMech(CKM_BATON_ECB96, "CKM_BATON_ECB96");
addMech(CKM_BATON_CBC128, "CKM_BATON_CBC128");
addMech(CKM_BATON_COUNTER, "CKM_BATON_COUNTER");
addMech(CKM_BATON_SHUFFLE, "CKM_BATON_SHUFFLE");
addMech(CKM_BATON_WRAP, "CKM_BATON_WRAP");
addMech(CKM_EC_KEY_PAIR_GEN, "CKM_EC_KEY_PAIR_GEN");
addMech(CKM_ECDSA, "CKM_ECDSA");
addMech(CKM_ECDSA_SHA1, "CKM_ECDSA_SHA1");
addMech(CKM_ECDH1_DERIVE, "CKM_ECDH1_DERIVE");
addMech(CKM_ECDH1_COFACTOR_DERIVE, "CKM_ECDH1_COFACTOR_DERIVE");
addMech(CKM_ECMQV_DERIVE, "CKM_ECMQV_DERIVE");
addMech(CKM_JUNIPER_KEY_GEN, "CKM_JUNIPER_KEY_GEN");
addMech(CKM_JUNIPER_ECB128, "CKM_JUNIPER_ECB128");
addMech(CKM_JUNIPER_CBC128, "CKM_JUNIPER_CBC128");
addMech(CKM_JUNIPER_COUNTER, "CKM_JUNIPER_COUNTER");
addMech(CKM_JUNIPER_SHUFFLE, "CKM_JUNIPER_SHUFFLE");
addMech(CKM_JUNIPER_WRAP, "CKM_JUNIPER_WRAP");
addMech(CKM_FASTHASH, "CKM_FASTHASH");
addMech(CKM_AES_KEY_GEN, "CKM_AES_KEY_GEN");
addMech(CKM_AES_ECB, "CKM_AES_ECB");
addMech(CKM_AES_CBC, "CKM_AES_CBC");
addMech(CKM_AES_MAC, "CKM_AES_MAC");
addMech(CKM_AES_MAC_GENERAL, "CKM_AES_MAC_GENERAL");
addMech(CKM_AES_CBC_PAD, "CKM_AES_CBC_PAD");
addMech(CKM_BLOWFISH_KEY_GEN, "CKM_BLOWFISH_KEY_GEN");
addMech(CKM_BLOWFISH_CBC, "CKM_BLOWFISH_CBC");
addMech(CKM_DSA_PARAMETER_GEN, "CKM_DSA_PARAMETER_GEN");
addMech(CKM_DH_PKCS_PARAMETER_GEN, "CKM_DH_PKCS_PARAMETER_GEN");
addMech(CKM_X9_42_DH_PARAMETER_GEN, "CKM_X9_42_DH_PARAMETER_GEN");
addMech(CKM_VENDOR_DEFINED, "CKM_VENDOR_DEFINED");
addMech(CKM_NSS_TLS_PRF_GENERAL, "CKM_NSS_TLS_PRF_GENERAL");
addMech(PCKM_SECURERANDOM, "SecureRandom");
addMech(PCKM_KEYSTORE, "KeyStore");
addKeyType(CKK_RSA, "CKK_RSA");
addKeyType(CKK_DSA, "CKK_DSA");
addKeyType(CKK_DH, "CKK_DH");
addKeyType(CKK_EC, "CKK_EC");
addKeyType(CKK_X9_42_DH, "CKK_X9_42_DH");
addKeyType(CKK_KEA, "CKK_KEA");
addKeyType(CKK_GENERIC_SECRET, "CKK_GENERIC_SECRET");
addKeyType(CKK_RC2, "CKK_RC2");
addKeyType(CKK_RC4, "CKK_RC4");
addKeyType(CKK_DES, "CKK_DES");
addKeyType(CKK_DES2, "CKK_DES2");
addKeyType(CKK_DES3, "CKK_DES3");
addKeyType(CKK_CAST, "CKK_CAST");
addKeyType(CKK_CAST3, "CKK_CAST3");
addKeyType(CKK_CAST128, "CKK_CAST128");
addKeyType(CKK_RC5, "CKK_RC5");
addKeyType(CKK_IDEA, "CKK_IDEA");
addKeyType(CKK_SKIPJACK, "CKK_SKIPJACK");
addKeyType(CKK_BATON, "CKK_BATON");
addKeyType(CKK_JUNIPER, "CKK_JUNIPER");
addKeyType(CKK_CDMF, "CKK_CDMF");
addKeyType(CKK_AES, "CKK_AES");
addKeyType(CKK_BLOWFISH, "CKK_BLOWFISH");
addKeyType(CKK_VENDOR_DEFINED, "CKK_VENDOR_DEFINED");
addKeyType(PCKK_ANY, "*");
addAttribute(CKA_CLASS, "CKA_CLASS");
addAttribute(CKA_TOKEN, "CKA_TOKEN");
addAttribute(CKA_PRIVATE, "CKA_PRIVATE");
addAttribute(CKA_LABEL, "CKA_LABEL");
addAttribute(CKA_APPLICATION, "CKA_APPLICATION");
addAttribute(CKA_VALUE, "CKA_VALUE");
addAttribute(CKA_OBJECT_ID, "CKA_OBJECT_ID");
addAttribute(CKA_CERTIFICATE_TYPE, "CKA_CERTIFICATE_TYPE");
addAttribute(CKA_ISSUER, "CKA_ISSUER");
addAttribute(CKA_SERIAL_NUMBER, "CKA_SERIAL_NUMBER");
addAttribute(CKA_AC_ISSUER, "CKA_AC_ISSUER");
addAttribute(CKA_OWNER, "CKA_OWNER");
addAttribute(CKA_ATTR_TYPES, "CKA_ATTR_TYPES");
addAttribute(CKA_TRUSTED, "CKA_TRUSTED");
addAttribute(CKA_KEY_TYPE, "CKA_KEY_TYPE");
addAttribute(CKA_SUBJECT, "CKA_SUBJECT");
addAttribute(CKA_ID, "CKA_ID");
addAttribute(CKA_SENSITIVE, "CKA_SENSITIVE");
addAttribute(CKA_ENCRYPT, "CKA_ENCRYPT");
addAttribute(CKA_DECRYPT, "CKA_DECRYPT");
addAttribute(CKA_WRAP, "CKA_WRAP");
addAttribute(CKA_UNWRAP, "CKA_UNWRAP");
addAttribute(CKA_SIGN, "CKA_SIGN");
addAttribute(CKA_SIGN_RECOVER, "CKA_SIGN_RECOVER");
addAttribute(CKA_VERIFY, "CKA_VERIFY");
addAttribute(CKA_VERIFY_RECOVER, "CKA_VERIFY_RECOVER");
addAttribute(CKA_DERIVE, "CKA_DERIVE");
addAttribute(CKA_START_DATE, "CKA_START_DATE");
addAttribute(CKA_END_DATE, "CKA_END_DATE");
addAttribute(CKA_MODULUS, "CKA_MODULUS");
addAttribute(CKA_MODULUS_BITS, "CKA_MODULUS_BITS");
addAttribute(CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT");
addAttribute(CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT");
addAttribute(CKA_PRIME_1, "CKA_PRIME_1");
addAttribute(CKA_PRIME_2, "CKA_PRIME_2");
addAttribute(CKA_EXPONENT_1, "CKA_EXPONENT_1");
addAttribute(CKA_EXPONENT_2, "CKA_EXPONENT_2");
addAttribute(CKA_COEFFICIENT, "CKA_COEFFICIENT");
addAttribute(CKA_PRIME, "CKA_PRIME");
addAttribute(CKA_SUBPRIME, "CKA_SUBPRIME");
addAttribute(CKA_BASE, "CKA_BASE");
addAttribute(CKA_PRIME_BITS, "CKA_PRIME_BITS");
addAttribute(CKA_SUB_PRIME_BITS, "CKA_SUB_PRIME_BITS");
addAttribute(CKA_VALUE_BITS, "CKA_VALUE_BITS");
addAttribute(CKA_VALUE_LEN, "CKA_VALUE_LEN");
addAttribute(CKA_EXTRACTABLE, "CKA_EXTRACTABLE");
addAttribute(CKA_LOCAL, "CKA_LOCAL");
addAttribute(CKA_NEVER_EXTRACTABLE, "CKA_NEVER_EXTRACTABLE");
addAttribute(CKA_ALWAYS_SENSITIVE, "CKA_ALWAYS_SENSITIVE");
addAttribute(CKA_KEY_GEN_MECHANISM, "CKA_KEY_GEN_MECHANISM");
addAttribute(CKA_MODIFIABLE, "CKA_MODIFIABLE");
addAttribute(CKA_EC_PARAMS, "CKA_EC_PARAMS");
addAttribute(CKA_EC_POINT, "CKA_EC_POINT");
addAttribute(CKA_SECONDARY_AUTH, "CKA_SECONDARY_AUTH");
addAttribute(CKA_AUTH_PIN_FLAGS, "CKA_AUTH_PIN_FLAGS");
addAttribute(CKA_HW_FEATURE_TYPE, "CKA_HW_FEATURE_TYPE");
addAttribute(CKA_RESET_ON_INIT, "CKA_RESET_ON_INIT");
addAttribute(CKA_HAS_RESET, "CKA_HAS_RESET");
addAttribute(CKA_VENDOR_DEFINED, "CKA_VENDOR_DEFINED");
addAttribute(CKA_NETSCAPE_DB, "CKA_NETSCAPE_DB");
addAttribute(CKA_NETSCAPE_TRUST_SERVER_AUTH, "CKA_NETSCAPE_TRUST_SERVER_AUTH");
addAttribute(CKA_NETSCAPE_TRUST_CLIENT_AUTH, "CKA_NETSCAPE_TRUST_CLIENT_AUTH");
addAttribute(CKA_NETSCAPE_TRUST_CODE_SIGNING, "CKA_NETSCAPE_TRUST_CODE_SIGNING");
addAttribute(CKA_NETSCAPE_TRUST_EMAIL_PROTECTION, "CKA_NETSCAPE_TRUST_EMAIL_PROTECTION");
addAttribute(CKA_NETSCAPE_CERT_SHA1_HASH, "CKA_NETSCAPE_CERT_SHA1_HASH");
addAttribute(CKA_NETSCAPE_CERT_MD5_HASH, "CKA_NETSCAPE_CERT_MD5_HASH");
addObjectClass(CKO_DATA, "CKO_DATA");
addObjectClass(CKO_CERTIFICATE, "CKO_CERTIFICATE");
addObjectClass(CKO_PUBLIC_KEY, "CKO_PUBLIC_KEY");
addObjectClass(CKO_PRIVATE_KEY, "CKO_PRIVATE_KEY");
addObjectClass(CKO_SECRET_KEY, "CKO_SECRET_KEY");
addObjectClass(CKO_HW_FEATURE, "CKO_HW_FEATURE");
addObjectClass(CKO_DOMAIN_PARAMETERS, "CKO_DOMAIN_PARAMETERS");
addObjectClass(CKO_VENDOR_DEFINED, "CKO_VENDOR_DEFINED");
addObjectClass(PCKO_ANY, "*");
}
}
| UTF-8 | Java | 39,672 | java | Functions.java | Java | [
{
"context": " by several classes in this package.\n *\n * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>\n * @author Martin Sc",
"end": 2617,
"score": 0.9998947978019714,
"start": 2599,
"tag": "NAME",
"value": "Karl Scheibelhofer"
},
{
"context": "n this package.\n *\n * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>\n * @author Martin Schlaeffer <schlaeff@sbox.tugr",
"end": 2645,
"score": 0.9999225735664368,
"start": 2619,
"tag": "EMAIL",
"value": "Karl.Scheibelhofer@iaik.at"
},
{
"context": "eibelhofer <Karl.Scheibelhofer@iaik.at>\n * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>\n */\npublic class Functi",
"end": 2675,
"score": 0.9998838305473328,
"start": 2658,
"tag": "NAME",
"value": "Martin Schlaeffer"
},
{
"context": "eibelhofer@iaik.at>\n * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>\n */\npublic class Functions {\n\n // maps betwee",
"end": 2700,
"score": 0.9999289512634277,
"start": 2677,
"tag": "EMAIL",
"value": "schlaeff@sbox.tugraz.at"
}
] | null | [] | /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment:
*
* "This product includes software developed by IAIK of Graz University of
* Technology."
*
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
* Technology" must not be used to endorse or promote products derived from
* this software without prior written permission.
*
* 5. Products derived from this software may not be called
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
* written permission of Graz University of Technology.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package sun.security.pkcs11.wrapper;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import ajava.util.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
* This class contains onyl static methods. It is the place for all functions
* that are used by several classes in this package.
*
* @author <NAME> <<EMAIL>>
* @author <NAME> <<EMAIL>>
*/
public class Functions {
// maps between ids and their names, forward and reverse
// ids are stored as Integers to save space
// since only the lower 32 bits are ever used anyway
// mechanisms (CKM_*)
private static final Map<Integer,String> mechNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> mechIds =
new HashMap<String,Integer>();
// key types (CKK_*)
private static final Map<Integer,String> keyNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> keyIds =
new HashMap<String,Integer>();
// attributes (CKA_*)
private static final Map<Integer,String> attributeNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> attributeIds =
new HashMap<String,Integer>();
// object classes (CKO_*)
private static final Map<Integer,String> objectClassNames =
new HashMap<Integer,String>();
private static final Map<String,Integer> objectClassIds =
new HashMap<String,Integer>();
/**
* For converting numbers to their hex presentation.
*/
private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
/**
* Converts a long value to a hexadecimal String of length 16. Includes
* leading zeros if necessary.
*
* @param value The long value to be converted.
* @return The hexadecimal string representation of the long value.
*/
public static String toFullHexString(long value) {
long currentValue = value;
StringBuffer stringBuffer = new StringBuffer(16);
for(int j = 0; j < 16; j++) {
int currentDigit = (int) currentValue & 0xf;
stringBuffer.append(HEX_DIGITS[currentDigit]);
currentValue >>>= 4;
}
return stringBuffer.reverse().toString();
}
/**
* Converts a int value to a hexadecimal String of length 8. Includes
* leading zeros if necessary.
*
* @param value The int value to be converted.
* @return The hexadecimal string representation of the int value.
*/
public static String toFullHexString(int value) {
int currentValue = value;
StringBuffer stringBuffer = new StringBuffer(8);
for(int i = 0; i < 8; i++) {
int currentDigit = currentValue & 0xf;
stringBuffer.append(HEX_DIGITS[currentDigit]);
currentValue >>>= 4;
}
return stringBuffer.reverse().toString();
}
/**
* converts a long value to a hexadecimal String
*
* @param value the long value to be converted
* @return the hexadecimal string representation of the long value
*/
public static String toHexString(long value) {
return Long.toHexString(value);
}
/**
* Converts a byte array to a hexadecimal String. Each byte is presented by
* its two digit hex-code; 0x0A -> "0a", 0x00 -> "00". No leading "0x" is
* included in the result.
*
* @param value the byte array to be converted
* @return the hexadecimal string representation of the byte array
*/
public static String toHexString(byte[] value) {
if (value == null) {
return null;
}
StringBuffer buffer = new StringBuffer(2 * value.length);
int single;
for (int i = 0; i < value.length; i++) {
single = value[i] & 0xFF;
if (single < 0x10) {
buffer.append('0');
}
buffer.append(Integer.toString(single, 16));
}
return buffer.toString();
}
/**
* converts a long value to a binary String
*
* @param value the long value to be converted
* @return the binary string representation of the long value
*/
public static String toBinaryString(long value) {
return Long.toString(value, 2);
}
/**
* converts a byte array to a binary String
*
* @param value the byte array to be converted
* @return the binary string representation of the byte array
*/
public static String toBinaryString(byte[] value) {
BigInteger helpBigInteger = new BigInteger(1, value);
return helpBigInteger.toString(2);
}
private static class Flags {
private final long[] flagIds;
private final String[] flagNames;
Flags(long[] flagIds, String[] flagNames) {
if (flagIds.length != flagNames.length) {
throw new AssertionError("Array lengths do not match");
}
this.flagIds = flagIds;
this.flagNames = flagNames;
}
String toString(long val) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (int i = 0; i < flagIds.length; i++) {
if ((val & flagIds[i]) != 0) {
if (first == false) {
sb.append(" | ");
}
sb.append(flagNames[i]);
first = false;
}
}
return sb.toString();
}
}
private static final Flags slotInfoFlags = new Flags(new long[] {
CKF_TOKEN_PRESENT,
CKF_REMOVABLE_DEVICE,
CKF_HW_SLOT,
}, new String[] {
"CKF_TOKEN_PRESENT",
"CKF_REMOVABLE_DEVICE",
"CKF_HW_SLOT",
});
/**
* converts the long value flags to a SlotInfoFlag string
*
* @param flags the flags to be converted
* @return the SlotInfoFlag string representation of the flags
*/
public static String slotInfoFlagsToString(long flags) {
return slotInfoFlags.toString(flags);
}
private static final Flags tokenInfoFlags = new Flags(new long[] {
CKF_RNG,
CKF_WRITE_PROTECTED,
CKF_LOGIN_REQUIRED,
CKF_USER_PIN_INITIALIZED,
CKF_RESTORE_KEY_NOT_NEEDED,
CKF_CLOCK_ON_TOKEN,
CKF_PROTECTED_AUTHENTICATION_PATH,
CKF_DUAL_CRYPTO_OPERATIONS,
CKF_TOKEN_INITIALIZED,
CKF_SECONDARY_AUTHENTICATION,
CKF_USER_PIN_COUNT_LOW,
CKF_USER_PIN_FINAL_TRY,
CKF_USER_PIN_LOCKED,
CKF_USER_PIN_TO_BE_CHANGED,
CKF_SO_PIN_COUNT_LOW,
CKF_SO_PIN_FINAL_TRY,
CKF_SO_PIN_LOCKED,
CKF_SO_PIN_TO_BE_CHANGED,
}, new String[] {
"CKF_RNG",
"CKF_WRITE_PROTECTED",
"CKF_LOGIN_REQUIRED",
"CKF_USER_PIN_INITIALIZED",
"CKF_RESTORE_KEY_NOT_NEEDED",
"CKF_CLOCK_ON_TOKEN",
"CKF_PROTECTED_AUTHENTICATION_PATH",
"CKF_DUAL_CRYPTO_OPERATIONS",
"CKF_TOKEN_INITIALIZED",
"CKF_SECONDARY_AUTHENTICATION",
"CKF_USER_PIN_COUNT_LOW",
"CKF_USER_PIN_FINAL_TRY",
"CKF_USER_PIN_LOCKED",
"CKF_USER_PIN_TO_BE_CHANGED",
"CKF_SO_PIN_COUNT_LOW",
"CKF_SO_PIN_FINAL_TRY",
"CKF_SO_PIN_LOCKED",
"CKF_SO_PIN_TO_BE_CHANGED",
});
/**
* converts long value flags to a TokenInfoFlag string
*
* @param flags the flags to be converted
* @return the TokenInfoFlag string representation of the flags
*/
public static String tokenInfoFlagsToString(long flags) {
return tokenInfoFlags.toString(flags);
}
private static final Flags sessionInfoFlags = new Flags(new long[] {
CKF_RW_SESSION,
CKF_SERIAL_SESSION,
}, new String[] {
"CKF_RW_SESSION",
"CKF_SERIAL_SESSION",
});
/**
* converts the long value flags to a SessionInfoFlag string
*
* @param flags the flags to be converted
* @return the SessionInfoFlag string representation of the flags
*/
public static String sessionInfoFlagsToString(long flags) {
return sessionInfoFlags.toString(flags);
}
/**
* converts the long value state to a SessionState string
*
* @param state the state to be converted
* @return the SessionState string representation of the state
*/
public static String sessionStateToString(long state) {
String name;
if (state == CKS_RO_PUBLIC_SESSION) {
name = "CKS_RO_PUBLIC_SESSION";
} else if (state == CKS_RO_USER_FUNCTIONS) {
name = "CKS_RO_USER_FUNCTIONS";
} else if (state == CKS_RW_PUBLIC_SESSION) {
name = "CKS_RW_PUBLIC_SESSION";
} else if (state == CKS_RW_USER_FUNCTIONS) {
name = "CKS_RW_USER_FUNCTIONS";
} else if (state == CKS_RW_SO_FUNCTIONS) {
name = "CKS_RW_SO_FUNCTIONS";
} else {
name = "ERROR: unknown session state 0x" + toFullHexString(state);
}
return name;
}
private static final Flags mechanismInfoFlags = new Flags(new long[] {
CKF_HW,
CKF_ENCRYPT,
CKF_DECRYPT,
CKF_DIGEST,
CKF_SIGN,
CKF_SIGN_RECOVER,
CKF_VERIFY,
CKF_VERIFY_RECOVER,
CKF_GENERATE,
CKF_GENERATE_KEY_PAIR,
CKF_WRAP,
CKF_UNWRAP,
CKF_DERIVE,
CKF_EC_F_P,
CKF_EC_F_2M,
CKF_EC_ECPARAMETERS,
CKF_EC_NAMEDCURVE,
CKF_EC_UNCOMPRESS,
CKF_EC_COMPRESS,
CKF_EXTENSION,
}, new String[] {
"CKF_HW",
"CKF_ENCRYPT",
"CKF_DECRYPT",
"CKF_DIGEST",
"CKF_SIGN",
"CKF_SIGN_RECOVER",
"CKF_VERIFY",
"CKF_VERIFY_RECOVER",
"CKF_GENERATE",
"CKF_GENERATE_KEY_PAIR",
"CKF_WRAP",
"CKF_UNWRAP",
"CKF_DERIVE",
"CKF_EC_F_P",
"CKF_EC_F_2M",
"CKF_EC_ECPARAMETERS",
"CKF_EC_NAMEDCURVE",
"CKF_EC_UNCOMPRESS",
"CKF_EC_COMPRESS",
"CKF_EXTENSION",
});
/**
* converts the long value flags to a MechanismInfoFlag string
*
* @param flags the flags to be converted
* @return the MechanismInfoFlag string representation of the flags
*/
public static String mechanismInfoFlagsToString(long flags) {
return mechanismInfoFlags.toString(flags);
}
private static String getName(Map<Integer,String> nameMap, long id) {
String name = null;
if ((id >>> 32) == 0) {
name = nameMap.get(Integer.valueOf((int)id));
}
if (name == null) {
name = "Unknown 0x" + toFullHexString(id);
}
return name;
}
public static long getId(Map<String,Integer> idMap, String name) {
Integer mech = idMap.get(name);
if (mech == null) {
throw new IllegalArgumentException("Unknown name " + name);
}
return mech.intValue() & 0xffffffffL;
}
public static String getMechanismName(long id) {
return getName(mechNames, id);
}
public static long getMechanismId(String name) {
return getId(mechIds, name);
}
public static String getKeyName(long id) {
return getName(keyNames, id);
}
public static long getKeyId(String name) {
return getId(keyIds, name);
}
public static String getAttributeName(long id) {
return getName(attributeNames, id);
}
public static long getAttributeId(String name) {
return getId(attributeIds, name);
}
public static String getObjectClassName(long id) {
return getName(objectClassNames, id);
}
public static long getObjectClassId(String name) {
return getId(objectClassIds, name);
}
/**
* Check the given arrays for equalitiy. This method considers both arrays as
* equal, if both are <code>null</code> or both have the same length and
* contain exactly the same char values.
*
* @param array1 The first array.
* @param array2 The second array.
* @return True, if both arrays are <code>null</code> or both have the same
* length and contain exactly the same char values. False, otherwise.
* @preconditions
* @postconditions
*/
private static boolean equals(char[] array1, char[] array2) {
return Arrays.equals(array1, array2);
}
/**
* Check the given dates for equalitiy. This method considers both dates as
* equal, if both are <code>null</code> or both contain exactly the same char
* values.
*
* @param date1 The first date.
* @param date2 The second date.
* @return True, if both dates are <code>null</code> or both contain the same
* char values. False, otherwise.
* @preconditions
* @postconditions
*/
public static boolean equals(CK_DATE date1, CK_DATE date2) {
boolean equal = false;
if (date1 == date2) {
equal = true;
} else if ((date1 != null) && (date2 != null)) {
equal = equals(date1.year, date2.year)
&& equals(date1.month, date2.month)
&& equals(date1.day, date2.day);
} else {
equal = false;
}
return equal ;
}
/**
* Calculate a hash code for the given byte array.
*
* @param array The byte array.
* @return A hash code for the given array.
* @preconditions
* @postconditions
*/
public static int hashCode(byte[] array) {
int hash = 0;
if (array != null) {
for (int i = 0; (i < 4) && (i < array.length); i++) {
hash ^= (0xFF & array[i]) << ((i%4) << 3);
}
}
return hash ;
}
/**
* Calculate a hash code for the given char array.
*
* @param array The char array.
* @return A hash code for the given array.
* @preconditions
* @postconditions
*/
public static int hashCode(char[] array) {
int hash = 0;
if (array != null) {
for (int i = 0; (i < 4) && (i < array.length); i++) {
hash ^= (0xFFFF & array[i]) << ((i%2) << 4);
}
}
return hash ;
}
/**
* Calculate a hash code for the given date object.
*
* @param date The date object.
* @return A hash code for the given date.
* @preconditions
* @postconditions
*/
public static int hashCode(CK_DATE date) {
int hash = 0;
if (date != null) {
if (date.year.length == 4) {
hash ^= (0xFFFF & date.year[0]) << 16;
hash ^= 0xFFFF & date.year[1];
hash ^= (0xFFFF & date.year[2]) << 16;
hash ^= 0xFFFF & date.year[3];
}
if (date.month.length == 2) {
hash ^= (0xFFFF & date.month[0]) << 16;
hash ^= 0xFFFF & date.month[1];
}
if (date.day.length == 2) {
hash ^= (0xFFFF & date.day[0]) << 16;
hash ^= 0xFFFF & date.day[1];
}
}
return hash ;
}
private static void addMapping(Map<Integer,String> nameMap,
Map<String,Integer> idMap, long id, String name) {
if ((id >>> 32) != 0) {
throw new AssertionError("Id has high bits set: " + id + ", " + name);
}
Integer intId = Integer.valueOf((int)id);
if (nameMap.put(intId, name) != null) {
throw new AssertionError("Duplicate id: " + id + ", " + name);
}
if (idMap.put(name, intId) != null) {
throw new AssertionError("Duplicate name: " + id + ", " + name);
}
}
private static void addMech(long id, String name) {
addMapping(mechNames, mechIds, id, name);
}
private static void addKeyType(long id, String name) {
addMapping(keyNames, keyIds, id, name);
}
private static void addAttribute(long id, String name) {
addMapping(attributeNames, attributeIds, id, name);
}
private static void addObjectClass(long id, String name) {
addMapping(objectClassNames, objectClassIds, id, name);
}
static {
addMech(CKM_RSA_PKCS_KEY_PAIR_GEN, "CKM_RSA_PKCS_KEY_PAIR_GEN");
addMech(CKM_RSA_PKCS, "CKM_RSA_PKCS");
addMech(CKM_RSA_9796, "CKM_RSA_9796");
addMech(CKM_RSA_X_509, "CKM_RSA_X_509");
addMech(CKM_MD2_RSA_PKCS, "CKM_MD2_RSA_PKCS");
addMech(CKM_MD5_RSA_PKCS, "CKM_MD5_RSA_PKCS");
addMech(CKM_SHA1_RSA_PKCS, "CKM_SHA1_RSA_PKCS");
addMech(CKM_RIPEMD128_RSA_PKCS, "CKM_RIPEMD128_RSA_PKCS");
addMech(CKM_RIPEMD160_RSA_PKCS, "CKM_RIPEMD160_RSA_PKCS");
addMech(CKM_RSA_PKCS_OAEP, "CKM_RSA_PKCS_OAEP");
addMech(CKM_RSA_X9_31_KEY_PAIR_GEN, "CKM_RSA_X9_31_KEY_PAIR_GEN");
addMech(CKM_RSA_X9_31, "CKM_RSA_X9_31");
addMech(CKM_SHA1_RSA_X9_31, "CKM_SHA1_RSA_X9_31");
addMech(CKM_RSA_PKCS_PSS, "CKM_RSA_PKCS_PSS");
addMech(CKM_SHA1_RSA_PKCS_PSS, "CKM_SHA1_RSA_PKCS_PSS");
addMech(CKM_DSA_KEY_PAIR_GEN, "CKM_DSA_KEY_PAIR_GEN");
addMech(CKM_DSA, "CKM_DSA");
addMech(CKM_DSA_SHA1, "CKM_DSA_SHA1");
addMech(CKM_DH_PKCS_KEY_PAIR_GEN, "CKM_DH_PKCS_KEY_PAIR_GEN");
addMech(CKM_DH_PKCS_DERIVE, "CKM_DH_PKCS_DERIVE");
addMech(CKM_X9_42_DH_KEY_PAIR_GEN, "CKM_X9_42_DH_KEY_PAIR_GEN");
addMech(CKM_X9_42_DH_DERIVE, "CKM_X9_42_DH_DERIVE");
addMech(CKM_X9_42_DH_HYBRID_DERIVE, "CKM_X9_42_DH_HYBRID_DERIVE");
addMech(CKM_X9_42_MQV_DERIVE, "CKM_X9_42_MQV_DERIVE");
addMech(CKM_SHA224_RSA_PKCS, "CKM_SHA224_RSA_PKCS");
addMech(CKM_SHA256_RSA_PKCS, "CKM_SHA256_RSA_PKCS");
addMech(CKM_SHA384_RSA_PKCS, "CKM_SHA384_RSA_PKCS");
addMech(CKM_SHA512_RSA_PKCS, "CKM_SHA512_RSA_PKCS");
addMech(CKM_RC2_KEY_GEN, "CKM_RC2_KEY_GEN");
addMech(CKM_RC2_ECB, "CKM_RC2_ECB");
addMech(CKM_RC2_CBC, "CKM_RC2_CBC");
addMech(CKM_RC2_MAC, "CKM_RC2_MAC");
addMech(CKM_RC2_MAC_GENERAL, "CKM_RC2_MAC_GENERAL");
addMech(CKM_RC2_CBC_PAD, "CKM_RC2_CBC_PAD");
addMech(CKM_RC4_KEY_GEN, "CKM_RC4_KEY_GEN");
addMech(CKM_RC4, "CKM_RC4");
addMech(CKM_DES_KEY_GEN, "CKM_DES_KEY_GEN");
addMech(CKM_DES_ECB, "CKM_DES_ECB");
addMech(CKM_DES_CBC, "CKM_DES_CBC");
addMech(CKM_DES_MAC, "CKM_DES_MAC");
addMech(CKM_DES_MAC_GENERAL, "CKM_DES_MAC_GENERAL");
addMech(CKM_DES_CBC_PAD, "CKM_DES_CBC_PAD");
addMech(CKM_DES2_KEY_GEN, "CKM_DES2_KEY_GEN");
addMech(CKM_DES3_KEY_GEN, "CKM_DES3_KEY_GEN");
addMech(CKM_DES3_ECB, "CKM_DES3_ECB");
addMech(CKM_DES3_CBC, "CKM_DES3_CBC");
addMech(CKM_DES3_MAC, "CKM_DES3_MAC");
addMech(CKM_DES3_MAC_GENERAL, "CKM_DES3_MAC_GENERAL");
addMech(CKM_DES3_CBC_PAD, "CKM_DES3_CBC_PAD");
addMech(CKM_CDMF_KEY_GEN, "CKM_CDMF_KEY_GEN");
addMech(CKM_CDMF_ECB, "CKM_CDMF_ECB");
addMech(CKM_CDMF_CBC, "CKM_CDMF_CBC");
addMech(CKM_CDMF_MAC, "CKM_CDMF_MAC");
addMech(CKM_CDMF_MAC_GENERAL, "CKM_CDMF_MAC_GENERAL");
addMech(CKM_CDMF_CBC_PAD, "CKM_CDMF_CBC_PAD");
addMech(CKM_MD2, "CKM_MD2");
addMech(CKM_MD2_HMAC, "CKM_MD2_HMAC");
addMech(CKM_MD2_HMAC_GENERAL, "CKM_MD2_HMAC_GENERAL");
addMech(CKM_MD5, "CKM_MD5");
addMech(CKM_MD5_HMAC, "CKM_MD5_HMAC");
addMech(CKM_MD5_HMAC_GENERAL, "CKM_MD5_HMAC_GENERAL");
addMech(CKM_SHA_1, "CKM_SHA_1");
addMech(CKM_SHA_1_HMAC, "CKM_SHA_1_HMAC");
addMech(CKM_SHA_1_HMAC_GENERAL, "CKM_SHA_1_HMAC_GENERAL");
addMech(CKM_RIPEMD128, "CKM_RIPEMD128");
addMech(CKM_RIPEMD128_HMAC, "CKM_RIPEMD128_HMAC");
addMech(CKM_RIPEMD128_HMAC_GENERAL, "CKM_RIPEMD128_HMAC_GENERAL");
addMech(CKM_RIPEMD160, "CKM_RIPEMD160");
addMech(CKM_RIPEMD160_HMAC, "CKM_RIPEMD160_HMAC");
addMech(CKM_RIPEMD160_HMAC_GENERAL, "CKM_RIPEMD160_HMAC_GENERAL");
addMech(CKM_SHA224, "CKM_SHA224");
addMech(CKM_SHA224_HMAC, "CKM_SHA224_HMAC");
addMech(CKM_SHA224_HMAC_GENERAL, "CKM_SHA224_HMAC_GENERAL");
addMech(CKM_SHA256, "CKM_SHA256");
addMech(CKM_SHA256_HMAC, "CKM_SHA256_HMAC");
addMech(CKM_SHA256_HMAC_GENERAL, "CKM_SHA256_HMAC_GENERAL");
addMech(CKM_SHA384, "CKM_SHA384");
addMech(CKM_SHA384_HMAC, "CKM_SHA384_HMAC");
addMech(CKM_SHA384_HMAC_GENERAL, "CKM_SHA384_HMAC_GENERAL");
addMech(CKM_SHA512, "CKM_SHA512");
addMech(CKM_SHA512_HMAC, "CKM_SHA512_HMAC");
addMech(CKM_SHA512_HMAC_GENERAL, "CKM_SHA512_HMAC_GENERAL");
addMech(CKM_CAST_KEY_GEN, "CKM_CAST_KEY_GEN");
addMech(CKM_CAST_ECB, "CKM_CAST_ECB");
addMech(CKM_CAST_CBC, "CKM_CAST_CBC");
addMech(CKM_CAST_MAC, "CKM_CAST_MAC");
addMech(CKM_CAST_MAC_GENERAL, "CKM_CAST_MAC_GENERAL");
addMech(CKM_CAST_CBC_PAD, "CKM_CAST_CBC_PAD");
addMech(CKM_CAST3_KEY_GEN, "CKM_CAST3_KEY_GEN");
addMech(CKM_CAST3_ECB, "CKM_CAST3_ECB");
addMech(CKM_CAST3_CBC, "CKM_CAST3_CBC");
addMech(CKM_CAST3_MAC, "CKM_CAST3_MAC");
addMech(CKM_CAST3_MAC_GENERAL, "CKM_CAST3_MAC_GENERAL");
addMech(CKM_CAST3_CBC_PAD, "CKM_CAST3_CBC_PAD");
addMech(CKM_CAST128_KEY_GEN, "CKM_CAST128_KEY_GEN");
addMech(CKM_CAST128_ECB, "CKM_CAST128_ECB");
addMech(CKM_CAST128_CBC, "CKM_CAST128_CBC");
addMech(CKM_CAST128_MAC, "CKM_CAST128_MAC");
addMech(CKM_CAST128_MAC_GENERAL, "CKM_CAST128_MAC_GENERAL");
addMech(CKM_CAST128_CBC_PAD, "CKM_CAST128_CBC_PAD");
addMech(CKM_RC5_KEY_GEN, "CKM_RC5_KEY_GEN");
addMech(CKM_RC5_ECB, "CKM_RC5_ECB");
addMech(CKM_RC5_CBC, "CKM_RC5_CBC");
addMech(CKM_RC5_MAC, "CKM_RC5_MAC");
addMech(CKM_RC5_MAC_GENERAL, "CKM_RC5_MAC_GENERAL");
addMech(CKM_RC5_CBC_PAD, "CKM_RC5_CBC_PAD");
addMech(CKM_IDEA_KEY_GEN, "CKM_IDEA_KEY_GEN");
addMech(CKM_IDEA_ECB, "CKM_IDEA_ECB");
addMech(CKM_IDEA_CBC, "CKM_IDEA_CBC");
addMech(CKM_IDEA_MAC, "CKM_IDEA_MAC");
addMech(CKM_IDEA_MAC_GENERAL, "CKM_IDEA_MAC_GENERAL");
addMech(CKM_IDEA_CBC_PAD, "CKM_IDEA_CBC_PAD");
addMech(CKM_GENERIC_SECRET_KEY_GEN, "CKM_GENERIC_SECRET_KEY_GEN");
addMech(CKM_CONCATENATE_BASE_AND_KEY, "CKM_CONCATENATE_BASE_AND_KEY");
addMech(CKM_CONCATENATE_BASE_AND_DATA, "CKM_CONCATENATE_BASE_AND_DATA");
addMech(CKM_CONCATENATE_DATA_AND_BASE, "CKM_CONCATENATE_DATA_AND_BASE");
addMech(CKM_XOR_BASE_AND_DATA, "CKM_XOR_BASE_AND_DATA");
addMech(CKM_EXTRACT_KEY_FROM_KEY, "CKM_EXTRACT_KEY_FROM_KEY");
addMech(CKM_SSL3_PRE_MASTER_KEY_GEN, "CKM_SSL3_PRE_MASTER_KEY_GEN");
addMech(CKM_SSL3_MASTER_KEY_DERIVE, "CKM_SSL3_MASTER_KEY_DERIVE");
addMech(CKM_SSL3_KEY_AND_MAC_DERIVE, "CKM_SSL3_KEY_AND_MAC_DERIVE");
addMech(CKM_SSL3_MASTER_KEY_DERIVE_DH, "CKM_SSL3_MASTER_KEY_DERIVE_DH");
addMech(CKM_TLS_PRE_MASTER_KEY_GEN, "CKM_TLS_PRE_MASTER_KEY_GEN");
addMech(CKM_TLS_MASTER_KEY_DERIVE, "CKM_TLS_MASTER_KEY_DERIVE");
addMech(CKM_TLS_KEY_AND_MAC_DERIVE, "CKM_TLS_KEY_AND_MAC_DERIVE");
addMech(CKM_TLS_MASTER_KEY_DERIVE_DH, "CKM_TLS_MASTER_KEY_DERIVE_DH");
addMech(CKM_TLS_PRF, "CKM_TLS_PRF");
addMech(CKM_SSL3_MD5_MAC, "CKM_SSL3_MD5_MAC");
addMech(CKM_SSL3_SHA1_MAC, "CKM_SSL3_SHA1_MAC");
addMech(CKM_MD5_KEY_DERIVATION, "CKM_MD5_KEY_DERIVATION");
addMech(CKM_MD2_KEY_DERIVATION, "CKM_MD2_KEY_DERIVATION");
addMech(CKM_SHA1_KEY_DERIVATION, "CKM_SHA1_KEY_DERIVATION");
addMech(CKM_SHA224_KEY_DERIVATION, "CKM_SHA224_KEY_DERIVATION");
addMech(CKM_SHA256_KEY_DERIVATION, "CKM_SHA256_KEY_DERIVATION");
addMech(CKM_SHA384_KEY_DERIVATION, "CKM_SHA384_KEY_DERIVATION");
addMech(CKM_SHA512_KEY_DERIVATION, "CKM_SHA512_KEY_DERIVATION");
addMech(CKM_PBE_MD2_DES_CBC, "CKM_PBE_MD2_DES_CBC");
addMech(CKM_PBE_MD5_DES_CBC, "CKM_PBE_MD5_DES_CBC");
addMech(CKM_PBE_MD5_CAST_CBC, "CKM_PBE_MD5_CAST_CBC");
addMech(CKM_PBE_MD5_CAST3_CBC, "CKM_PBE_MD5_CAST3_CBC");
addMech(CKM_PBE_MD5_CAST128_CBC, "CKM_PBE_MD5_CAST128_CBC");
addMech(CKM_PBE_SHA1_CAST128_CBC, "CKM_PBE_SHA1_CAST128_CBC");
addMech(CKM_PBE_SHA1_RC4_128, "CKM_PBE_SHA1_RC4_128");
addMech(CKM_PBE_SHA1_RC4_40, "CKM_PBE_SHA1_RC4_40");
addMech(CKM_PBE_SHA1_DES3_EDE_CBC, "CKM_PBE_SHA1_DES3_EDE_CBC");
addMech(CKM_PBE_SHA1_DES2_EDE_CBC, "CKM_PBE_SHA1_DES2_EDE_CBC");
addMech(CKM_PBE_SHA1_RC2_128_CBC, "CKM_PBE_SHA1_RC2_128_CBC");
addMech(CKM_PBE_SHA1_RC2_40_CBC, "CKM_PBE_SHA1_RC2_40_CBC");
addMech(CKM_PKCS5_PBKD2, "CKM_PKCS5_PBKD2");
addMech(CKM_PBA_SHA1_WITH_SHA1_HMAC, "CKM_PBA_SHA1_WITH_SHA1_HMAC");
addMech(CKM_KEY_WRAP_LYNKS, "CKM_KEY_WRAP_LYNKS");
addMech(CKM_KEY_WRAP_SET_OAEP, "CKM_KEY_WRAP_SET_OAEP");
addMech(CKM_SKIPJACK_KEY_GEN, "CKM_SKIPJACK_KEY_GEN");
addMech(CKM_SKIPJACK_ECB64, "CKM_SKIPJACK_ECB64");
addMech(CKM_SKIPJACK_CBC64, "CKM_SKIPJACK_CBC64");
addMech(CKM_SKIPJACK_OFB64, "CKM_SKIPJACK_OFB64");
addMech(CKM_SKIPJACK_CFB64, "CKM_SKIPJACK_CFB64");
addMech(CKM_SKIPJACK_CFB32, "CKM_SKIPJACK_CFB32");
addMech(CKM_SKIPJACK_CFB16, "CKM_SKIPJACK_CFB16");
addMech(CKM_SKIPJACK_CFB8, "CKM_SKIPJACK_CFB8");
addMech(CKM_SKIPJACK_WRAP, "CKM_SKIPJACK_WRAP");
addMech(CKM_SKIPJACK_PRIVATE_WRAP, "CKM_SKIPJACK_PRIVATE_WRAP");
addMech(CKM_SKIPJACK_RELAYX, "CKM_SKIPJACK_RELAYX");
addMech(CKM_KEA_KEY_PAIR_GEN, "CKM_KEA_KEY_PAIR_GEN");
addMech(CKM_KEA_KEY_DERIVE, "CKM_KEA_KEY_DERIVE");
addMech(CKM_FORTEZZA_TIMESTAMP, "CKM_FORTEZZA_TIMESTAMP");
addMech(CKM_BATON_KEY_GEN, "CKM_BATON_KEY_GEN");
addMech(CKM_BATON_ECB128, "CKM_BATON_ECB128");
addMech(CKM_BATON_ECB96, "CKM_BATON_ECB96");
addMech(CKM_BATON_CBC128, "CKM_BATON_CBC128");
addMech(CKM_BATON_COUNTER, "CKM_BATON_COUNTER");
addMech(CKM_BATON_SHUFFLE, "CKM_BATON_SHUFFLE");
addMech(CKM_BATON_WRAP, "CKM_BATON_WRAP");
addMech(CKM_EC_KEY_PAIR_GEN, "CKM_EC_KEY_PAIR_GEN");
addMech(CKM_ECDSA, "CKM_ECDSA");
addMech(CKM_ECDSA_SHA1, "CKM_ECDSA_SHA1");
addMech(CKM_ECDH1_DERIVE, "CKM_ECDH1_DERIVE");
addMech(CKM_ECDH1_COFACTOR_DERIVE, "CKM_ECDH1_COFACTOR_DERIVE");
addMech(CKM_ECMQV_DERIVE, "CKM_ECMQV_DERIVE");
addMech(CKM_JUNIPER_KEY_GEN, "CKM_JUNIPER_KEY_GEN");
addMech(CKM_JUNIPER_ECB128, "CKM_JUNIPER_ECB128");
addMech(CKM_JUNIPER_CBC128, "CKM_JUNIPER_CBC128");
addMech(CKM_JUNIPER_COUNTER, "CKM_JUNIPER_COUNTER");
addMech(CKM_JUNIPER_SHUFFLE, "CKM_JUNIPER_SHUFFLE");
addMech(CKM_JUNIPER_WRAP, "CKM_JUNIPER_WRAP");
addMech(CKM_FASTHASH, "CKM_FASTHASH");
addMech(CKM_AES_KEY_GEN, "CKM_AES_KEY_GEN");
addMech(CKM_AES_ECB, "CKM_AES_ECB");
addMech(CKM_AES_CBC, "CKM_AES_CBC");
addMech(CKM_AES_MAC, "CKM_AES_MAC");
addMech(CKM_AES_MAC_GENERAL, "CKM_AES_MAC_GENERAL");
addMech(CKM_AES_CBC_PAD, "CKM_AES_CBC_PAD");
addMech(CKM_BLOWFISH_KEY_GEN, "CKM_BLOWFISH_KEY_GEN");
addMech(CKM_BLOWFISH_CBC, "CKM_BLOWFISH_CBC");
addMech(CKM_DSA_PARAMETER_GEN, "CKM_DSA_PARAMETER_GEN");
addMech(CKM_DH_PKCS_PARAMETER_GEN, "CKM_DH_PKCS_PARAMETER_GEN");
addMech(CKM_X9_42_DH_PARAMETER_GEN, "CKM_X9_42_DH_PARAMETER_GEN");
addMech(CKM_VENDOR_DEFINED, "CKM_VENDOR_DEFINED");
addMech(CKM_NSS_TLS_PRF_GENERAL, "CKM_NSS_TLS_PRF_GENERAL");
addMech(PCKM_SECURERANDOM, "SecureRandom");
addMech(PCKM_KEYSTORE, "KeyStore");
addKeyType(CKK_RSA, "CKK_RSA");
addKeyType(CKK_DSA, "CKK_DSA");
addKeyType(CKK_DH, "CKK_DH");
addKeyType(CKK_EC, "CKK_EC");
addKeyType(CKK_X9_42_DH, "CKK_X9_42_DH");
addKeyType(CKK_KEA, "CKK_KEA");
addKeyType(CKK_GENERIC_SECRET, "CKK_GENERIC_SECRET");
addKeyType(CKK_RC2, "CKK_RC2");
addKeyType(CKK_RC4, "CKK_RC4");
addKeyType(CKK_DES, "CKK_DES");
addKeyType(CKK_DES2, "CKK_DES2");
addKeyType(CKK_DES3, "CKK_DES3");
addKeyType(CKK_CAST, "CKK_CAST");
addKeyType(CKK_CAST3, "CKK_CAST3");
addKeyType(CKK_CAST128, "CKK_CAST128");
addKeyType(CKK_RC5, "CKK_RC5");
addKeyType(CKK_IDEA, "CKK_IDEA");
addKeyType(CKK_SKIPJACK, "CKK_SKIPJACK");
addKeyType(CKK_BATON, "CKK_BATON");
addKeyType(CKK_JUNIPER, "CKK_JUNIPER");
addKeyType(CKK_CDMF, "CKK_CDMF");
addKeyType(CKK_AES, "CKK_AES");
addKeyType(CKK_BLOWFISH, "CKK_BLOWFISH");
addKeyType(CKK_VENDOR_DEFINED, "CKK_VENDOR_DEFINED");
addKeyType(PCKK_ANY, "*");
addAttribute(CKA_CLASS, "CKA_CLASS");
addAttribute(CKA_TOKEN, "CKA_TOKEN");
addAttribute(CKA_PRIVATE, "CKA_PRIVATE");
addAttribute(CKA_LABEL, "CKA_LABEL");
addAttribute(CKA_APPLICATION, "CKA_APPLICATION");
addAttribute(CKA_VALUE, "CKA_VALUE");
addAttribute(CKA_OBJECT_ID, "CKA_OBJECT_ID");
addAttribute(CKA_CERTIFICATE_TYPE, "CKA_CERTIFICATE_TYPE");
addAttribute(CKA_ISSUER, "CKA_ISSUER");
addAttribute(CKA_SERIAL_NUMBER, "CKA_SERIAL_NUMBER");
addAttribute(CKA_AC_ISSUER, "CKA_AC_ISSUER");
addAttribute(CKA_OWNER, "CKA_OWNER");
addAttribute(CKA_ATTR_TYPES, "CKA_ATTR_TYPES");
addAttribute(CKA_TRUSTED, "CKA_TRUSTED");
addAttribute(CKA_KEY_TYPE, "CKA_KEY_TYPE");
addAttribute(CKA_SUBJECT, "CKA_SUBJECT");
addAttribute(CKA_ID, "CKA_ID");
addAttribute(CKA_SENSITIVE, "CKA_SENSITIVE");
addAttribute(CKA_ENCRYPT, "CKA_ENCRYPT");
addAttribute(CKA_DECRYPT, "CKA_DECRYPT");
addAttribute(CKA_WRAP, "CKA_WRAP");
addAttribute(CKA_UNWRAP, "CKA_UNWRAP");
addAttribute(CKA_SIGN, "CKA_SIGN");
addAttribute(CKA_SIGN_RECOVER, "CKA_SIGN_RECOVER");
addAttribute(CKA_VERIFY, "CKA_VERIFY");
addAttribute(CKA_VERIFY_RECOVER, "CKA_VERIFY_RECOVER");
addAttribute(CKA_DERIVE, "CKA_DERIVE");
addAttribute(CKA_START_DATE, "CKA_START_DATE");
addAttribute(CKA_END_DATE, "CKA_END_DATE");
addAttribute(CKA_MODULUS, "CKA_MODULUS");
addAttribute(CKA_MODULUS_BITS, "CKA_MODULUS_BITS");
addAttribute(CKA_PUBLIC_EXPONENT, "CKA_PUBLIC_EXPONENT");
addAttribute(CKA_PRIVATE_EXPONENT, "CKA_PRIVATE_EXPONENT");
addAttribute(CKA_PRIME_1, "CKA_PRIME_1");
addAttribute(CKA_PRIME_2, "CKA_PRIME_2");
addAttribute(CKA_EXPONENT_1, "CKA_EXPONENT_1");
addAttribute(CKA_EXPONENT_2, "CKA_EXPONENT_2");
addAttribute(CKA_COEFFICIENT, "CKA_COEFFICIENT");
addAttribute(CKA_PRIME, "CKA_PRIME");
addAttribute(CKA_SUBPRIME, "CKA_SUBPRIME");
addAttribute(CKA_BASE, "CKA_BASE");
addAttribute(CKA_PRIME_BITS, "CKA_PRIME_BITS");
addAttribute(CKA_SUB_PRIME_BITS, "CKA_SUB_PRIME_BITS");
addAttribute(CKA_VALUE_BITS, "CKA_VALUE_BITS");
addAttribute(CKA_VALUE_LEN, "CKA_VALUE_LEN");
addAttribute(CKA_EXTRACTABLE, "CKA_EXTRACTABLE");
addAttribute(CKA_LOCAL, "CKA_LOCAL");
addAttribute(CKA_NEVER_EXTRACTABLE, "CKA_NEVER_EXTRACTABLE");
addAttribute(CKA_ALWAYS_SENSITIVE, "CKA_ALWAYS_SENSITIVE");
addAttribute(CKA_KEY_GEN_MECHANISM, "CKA_KEY_GEN_MECHANISM");
addAttribute(CKA_MODIFIABLE, "CKA_MODIFIABLE");
addAttribute(CKA_EC_PARAMS, "CKA_EC_PARAMS");
addAttribute(CKA_EC_POINT, "CKA_EC_POINT");
addAttribute(CKA_SECONDARY_AUTH, "CKA_SECONDARY_AUTH");
addAttribute(CKA_AUTH_PIN_FLAGS, "CKA_AUTH_PIN_FLAGS");
addAttribute(CKA_HW_FEATURE_TYPE, "CKA_HW_FEATURE_TYPE");
addAttribute(CKA_RESET_ON_INIT, "CKA_RESET_ON_INIT");
addAttribute(CKA_HAS_RESET, "CKA_HAS_RESET");
addAttribute(CKA_VENDOR_DEFINED, "CKA_VENDOR_DEFINED");
addAttribute(CKA_NETSCAPE_DB, "CKA_NETSCAPE_DB");
addAttribute(CKA_NETSCAPE_TRUST_SERVER_AUTH, "CKA_NETSCAPE_TRUST_SERVER_AUTH");
addAttribute(CKA_NETSCAPE_TRUST_CLIENT_AUTH, "CKA_NETSCAPE_TRUST_CLIENT_AUTH");
addAttribute(CKA_NETSCAPE_TRUST_CODE_SIGNING, "CKA_NETSCAPE_TRUST_CODE_SIGNING");
addAttribute(CKA_NETSCAPE_TRUST_EMAIL_PROTECTION, "CKA_NETSCAPE_TRUST_EMAIL_PROTECTION");
addAttribute(CKA_NETSCAPE_CERT_SHA1_HASH, "CKA_NETSCAPE_CERT_SHA1_HASH");
addAttribute(CKA_NETSCAPE_CERT_MD5_HASH, "CKA_NETSCAPE_CERT_MD5_HASH");
addObjectClass(CKO_DATA, "CKO_DATA");
addObjectClass(CKO_CERTIFICATE, "CKO_CERTIFICATE");
addObjectClass(CKO_PUBLIC_KEY, "CKO_PUBLIC_KEY");
addObjectClass(CKO_PRIVATE_KEY, "CKO_PRIVATE_KEY");
addObjectClass(CKO_SECRET_KEY, "CKO_SECRET_KEY");
addObjectClass(CKO_HW_FEATURE, "CKO_HW_FEATURE");
addObjectClass(CKO_DOMAIN_PARAMETERS, "CKO_DOMAIN_PARAMETERS");
addObjectClass(CKO_VENDOR_DEFINED, "CKO_VENDOR_DEFINED");
addObjectClass(PCKO_ANY, "*");
}
}
| 39,614 | 0.554648 | 0.537255 | 908 | 42.691631 | 26.890987 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.012115 | false | false | 11 |
71564969eb618907a4046a32e7764f73223f3bfa | 22,187,801,058,663 | f5bc77ebfff979e806130a693f0b26501d602cfa | /model-camt-types/src/generated/java/com/prowidesoftware/swift/model/mx/dic/LimitReport2.java | 4c4224449456dffa8486e8837861df3e00d2f56c | [
"Apache-2.0"
] | permissive | prowide/prowide-iso20022 | https://github.com/prowide/prowide-iso20022 | 0549c1a8dc3350d2a13578bfa400192159b2c57d | 689b50a9b0bdf8b6cd33af5e101d038871b61d2d | refs/heads/develop | 2023-08-10T04:12:19.973000 | 2023-07-28T01:05:28 | 2023-07-28T01:05:28 | 257,418,273 | 104 | 50 | Apache-2.0 | false | 2023-08-25T15:08:17 | 2020-04-20T22:26:39 | 2023-08-20T04:59:44 | 2023-08-25T15:08:16 | 51,269 | 103 | 56 | 15 | Java | false | false |
package com.prowidesoftware.swift.model.mx.dic;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Reports either on the risk management limit or on a business error.
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LimitReport2", propOrder = {
"lmtId",
"lmt",
"bizErr"
})
public class LimitReport2 {
@XmlElement(name = "LmtId", required = true)
protected LimitIdentificationDetails2 lmtId;
@XmlElement(name = "Lmt")
protected LimitDetails3 lmt;
@XmlElement(name = "BizErr")
protected ErrorHandling2 bizErr;
/**
* Gets the value of the lmtId property.
*
* @return
* possible object is
* {@link LimitIdentificationDetails2 }
*
*/
public LimitIdentificationDetails2 getLmtId() {
return lmtId;
}
/**
* Sets the value of the lmtId property.
*
* @param value
* allowed object is
* {@link LimitIdentificationDetails2 }
*
*/
public LimitReport2 setLmtId(LimitIdentificationDetails2 value) {
this.lmtId = value;
return this;
}
/**
* Gets the value of the lmt property.
*
* @return
* possible object is
* {@link LimitDetails3 }
*
*/
public LimitDetails3 getLmt() {
return lmt;
}
/**
* Sets the value of the lmt property.
*
* @param value
* allowed object is
* {@link LimitDetails3 }
*
*/
public LimitReport2 setLmt(LimitDetails3 value) {
this.lmt = value;
return this;
}
/**
* Gets the value of the bizErr property.
*
* @return
* possible object is
* {@link ErrorHandling2 }
*
*/
public ErrorHandling2 getBizErr() {
return bizErr;
}
/**
* Sets the value of the bizErr property.
*
* @param value
* allowed object is
* {@link ErrorHandling2 }
*
*/
public LimitReport2 setBizErr(ErrorHandling2 value) {
this.bizErr = value;
return this;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
@Override
public boolean equals(Object that) {
return EqualsBuilder.reflectionEquals(this, that);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
| UTF-8 | Java | 2,870 | java | LimitReport2.java | Java | [] | null | [] |
package com.prowidesoftware.swift.model.mx.dic;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Reports either on the risk management limit or on a business error.
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LimitReport2", propOrder = {
"lmtId",
"lmt",
"bizErr"
})
public class LimitReport2 {
@XmlElement(name = "LmtId", required = true)
protected LimitIdentificationDetails2 lmtId;
@XmlElement(name = "Lmt")
protected LimitDetails3 lmt;
@XmlElement(name = "BizErr")
protected ErrorHandling2 bizErr;
/**
* Gets the value of the lmtId property.
*
* @return
* possible object is
* {@link LimitIdentificationDetails2 }
*
*/
public LimitIdentificationDetails2 getLmtId() {
return lmtId;
}
/**
* Sets the value of the lmtId property.
*
* @param value
* allowed object is
* {@link LimitIdentificationDetails2 }
*
*/
public LimitReport2 setLmtId(LimitIdentificationDetails2 value) {
this.lmtId = value;
return this;
}
/**
* Gets the value of the lmt property.
*
* @return
* possible object is
* {@link LimitDetails3 }
*
*/
public LimitDetails3 getLmt() {
return lmt;
}
/**
* Sets the value of the lmt property.
*
* @param value
* allowed object is
* {@link LimitDetails3 }
*
*/
public LimitReport2 setLmt(LimitDetails3 value) {
this.lmt = value;
return this;
}
/**
* Gets the value of the bizErr property.
*
* @return
* possible object is
* {@link ErrorHandling2 }
*
*/
public ErrorHandling2 getBizErr() {
return bizErr;
}
/**
* Sets the value of the bizErr property.
*
* @param value
* allowed object is
* {@link ErrorHandling2 }
*
*/
public LimitReport2 setBizErr(ErrorHandling2 value) {
this.bizErr = value;
return this;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
@Override
public boolean equals(Object that) {
return EqualsBuilder.reflectionEquals(this, that);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
| 2,870 | 0.609756 | 0.601394 | 124 | 22.137096 | 19.579176 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.241935 | false | false | 11 |
10bdc15e7855e74a9ae05a1c8d41954906206f75 | 24,945,170,119,150 | 4c430dc9a11f598b4080b7bbb59faddfdef5ed39 | /modules/api/src/main/java/com/intuit/wasabi/api/APISwaggerResource.java | d0ae6dc0330f1519355d5ad6336a57fe2ad2f51f | [
"Apache-2.0"
] | permissive | MikeKMiller/wasabi | https://github.com/MikeKMiller/wasabi | 2acc1bc2590bb6742dbddf226bf6cbea4440e5dd | 39db4d1a509acc6ede767c064937d84f6d5501aa | refs/heads/develop | 2020-04-08T06:38:23.646000 | 2019-12-08T19:02:06 | 2019-12-08T19:02:06 | 159,103,745 | 1 | 0 | Apache-2.0 | true | 2019-12-08T19:02:08 | 2018-11-26T03:18:57 | 2018-11-26T03:19:03 | 2019-12-08T19:02:07 | 19,323 | 0 | 0 | 0 | Java | false | false | /*******************************************************************************
* Copyright 2016 Intuit
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.intuit.wasabi.api;
/**
* Contains all default and example values for Swagger resources
*/
interface APISwaggerResource {
String DEFAULT_UUID = "54ae563f-242e-43bc-9eeb-0a9454c97110";
String DEFAULT_DRAFT = "6022afe5-3dd1-427a-b049-c4e4c6e2e229";
String DEFAULT_BUCKET = "bucketa";
String DEFAULT_EXP = "swaggerExp";
String DEFAULT_APP = "swaggerApp";
String DEFAULT_USERID = "johnDoe";
String DEFAULT_EVENT = "{\"events\":[{\"name\":\"IMPRESSION\"}]}";
String DEFAULT_MODEXP = "{\"id\": \"" + DEFAULT_DRAFT + "\",\"label\":\"" + DEFAULT_EXP + "\"," +
"\"applicationName\":\"" + DEFAULT_EXP + "\",\"description\":\"try to change\"}";
String DEFAULT_MODBUCK = "{\"label\": \"bucketa\"," +
"\"allocationPercent\": 0.2," +
"\"description\": \"bucket for swagger test\",\"isControl\": false}";
String DEFAULT_PUTBUCK = "{\"label\": \"bucketa\"," +
"\"allocationPercent\": 0.2," +
"\"description\": \"bucket modification\",\"isControl\": false}";
String DEFAULT_BATCHAPP = "example";
String DEFAULT_LABELLIST = "{\"labels\":[\"expone\", \"exptwo\"]}";
String DEFAULT_ASSIGNMENT = "{\"assignment\": \"" + DEFAULT_BUCKET + "\"}";
String DEFAULT_EMPTY = "{}";
String DEFAULT_ROLE = "admin";
String EXAMPLE_AUTHORIZATION_HEADER = "Basic d2FzYWJpLW5vcmVwbHlAaW50dWl0LmNvbTp3ZWFrcGFzcw";
String EXAMPLE_ALL_ROLES = "Example: SUPERADMIN / ADMIN / READONLY / READWRITE";
String DEFAULT_PAGE = "1";
String DEFAULT_PER_PAGE = "10";
String DEFAULT_PER_PAGE_CARDVIEW = "8";
String DEFAULT_FILTER = "";
String DEFAULT_SORT = "";
String DEFAULT_TIMEZONE = "+0000";
String DEFAULT_ALL = "false";
String DOC_PAGE = "A positive integer determining the page to return. If the page does not exist, it is " +
"returned empty.";
String DOC_PER_PAGE = "A positive integer determining the number of entries per page to return. If -1, all " +
"entries are returned and the page option is ignored.";
String DOC_FILTER = "A filter string to filter the elements. The exact semantics depend on the resource, but in " +
"general the filter follows the pattern: fulltext,key=value,key2=value2,... . It is possible to either " +
"only supply the fulltext or only key=value pairs. Note that the fulltext must not contain '=' and the " +
"filter keys and values must not contain '=' or ','. An example would be: matchThis,experiment=myExp";
String DOC_SORT = "A sort string to sort the elements. The exact semantics depend on the resource, but in " +
"general the sort order follows the pattern: [-]primary[,[-]secondary[...]] . The keys determine the " +
"fields and a prefixed hyphen changes the sort order to descending.";
String DOC_TIMEZONE = "The user's timezone offset. Valid values are for example: +0100, -07:30 or the like.";
String DOC_All = "A boolean value indicating whether all the underlying configurations should be retrieved.";
}
| UTF-8 | Java | 3,846 | java | APISwaggerResource.java | Java | [
{
"context": "_APP = \"swaggerApp\";\n String DEFAULT_USERID = \"johnDoe\";\n String DEFAULT_EVENT = \"{\\\"events\\\":[{\\\"nam",
"end": 1177,
"score": 0.9993550181388855,
"start": 1170,
"tag": "USERNAME",
"value": "johnDoe"
}
] | null | [] | /*******************************************************************************
* Copyright 2016 Intuit
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.intuit.wasabi.api;
/**
* Contains all default and example values for Swagger resources
*/
interface APISwaggerResource {
String DEFAULT_UUID = "54ae563f-242e-43bc-9eeb-0a9454c97110";
String DEFAULT_DRAFT = "6022afe5-3dd1-427a-b049-c4e4c6e2e229";
String DEFAULT_BUCKET = "bucketa";
String DEFAULT_EXP = "swaggerExp";
String DEFAULT_APP = "swaggerApp";
String DEFAULT_USERID = "johnDoe";
String DEFAULT_EVENT = "{\"events\":[{\"name\":\"IMPRESSION\"}]}";
String DEFAULT_MODEXP = "{\"id\": \"" + DEFAULT_DRAFT + "\",\"label\":\"" + DEFAULT_EXP + "\"," +
"\"applicationName\":\"" + DEFAULT_EXP + "\",\"description\":\"try to change\"}";
String DEFAULT_MODBUCK = "{\"label\": \"bucketa\"," +
"\"allocationPercent\": 0.2," +
"\"description\": \"bucket for swagger test\",\"isControl\": false}";
String DEFAULT_PUTBUCK = "{\"label\": \"bucketa\"," +
"\"allocationPercent\": 0.2," +
"\"description\": \"bucket modification\",\"isControl\": false}";
String DEFAULT_BATCHAPP = "example";
String DEFAULT_LABELLIST = "{\"labels\":[\"expone\", \"exptwo\"]}";
String DEFAULT_ASSIGNMENT = "{\"assignment\": \"" + DEFAULT_BUCKET + "\"}";
String DEFAULT_EMPTY = "{}";
String DEFAULT_ROLE = "admin";
String EXAMPLE_AUTHORIZATION_HEADER = "Basic d2FzYWJpLW5vcmVwbHlAaW50dWl0LmNvbTp3ZWFrcGFzcw";
String EXAMPLE_ALL_ROLES = "Example: SUPERADMIN / ADMIN / READONLY / READWRITE";
String DEFAULT_PAGE = "1";
String DEFAULT_PER_PAGE = "10";
String DEFAULT_PER_PAGE_CARDVIEW = "8";
String DEFAULT_FILTER = "";
String DEFAULT_SORT = "";
String DEFAULT_TIMEZONE = "+0000";
String DEFAULT_ALL = "false";
String DOC_PAGE = "A positive integer determining the page to return. If the page does not exist, it is " +
"returned empty.";
String DOC_PER_PAGE = "A positive integer determining the number of entries per page to return. If -1, all " +
"entries are returned and the page option is ignored.";
String DOC_FILTER = "A filter string to filter the elements. The exact semantics depend on the resource, but in " +
"general the filter follows the pattern: fulltext,key=value,key2=value2,... . It is possible to either " +
"only supply the fulltext or only key=value pairs. Note that the fulltext must not contain '=' and the " +
"filter keys and values must not contain '=' or ','. An example would be: matchThis,experiment=myExp";
String DOC_SORT = "A sort string to sort the elements. The exact semantics depend on the resource, but in " +
"general the sort order follows the pattern: [-]primary[,[-]secondary[...]] . The keys determine the " +
"fields and a prefixed hyphen changes the sort order to descending.";
String DOC_TIMEZONE = "The user's timezone offset. Valid values are for example: +0100, -07:30 or the like.";
String DOC_All = "A boolean value indicating whether all the underlying configurations should be retrieved.";
}
| 3,846 | 0.632605 | 0.612324 | 68 | 55.558823 | 35.99321 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.838235 | false | false | 11 |
89e52b62230919295fd1aff80cd84382dc136e64 | 3,547,643,007,792 | dae93148be139e776f7f66743b603106378058a6 | /src/StackMinimum.java | bd80027128e51b6917a752c896c626645f92fbfd | [] | no_license | ashwini-anand/CPPractice | https://github.com/ashwini-anand/CPPractice | dae43c3d801b83ca8c5e5891f29880e15fe6d547 | 5133c614c75f63d7ce5c80405a81806be72f1ec7 | refs/heads/master | 2023-08-29T09:35:19.392000 | 2021-10-26T13:42:31 | 2021-10-26T13:42:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Stack;
public class StackMinimum {
int minEle;
Stack<Integer> s = new Stack<Integer>();
/*returns min element from stack*/
int getMin() {
if (s.isEmpty()) return -1;
else return minEle;
}
/*returns poped element from stack*/
int pop() {
if (s.isEmpty()) return -1;
int top = s.pop();
if (top < minEle) {
int curr = minEle;
minEle = 2 * minEle - top;
return curr;
}
return top;
}
/*push element x into the stack*/
void push(int x) {
if (s.isEmpty()) {
minEle = x;
}
if (x < minEle) {
int t = 2 * x - minEle;
minEle = x;
s.push(t);
} else {
s.push(x);
}
}
}
| UTF-8 | Java | 695 | java | StackMinimum.java | Java | [] | null | [] | import java.util.Stack;
public class StackMinimum {
int minEle;
Stack<Integer> s = new Stack<Integer>();
/*returns min element from stack*/
int getMin() {
if (s.isEmpty()) return -1;
else return minEle;
}
/*returns poped element from stack*/
int pop() {
if (s.isEmpty()) return -1;
int top = s.pop();
if (top < minEle) {
int curr = minEle;
minEle = 2 * minEle - top;
return curr;
}
return top;
}
/*push element x into the stack*/
void push(int x) {
if (s.isEmpty()) {
minEle = x;
}
if (x < minEle) {
int t = 2 * x - minEle;
minEle = x;
s.push(t);
} else {
s.push(x);
}
}
}
| 695 | 0.523741 | 0.517986 | 38 | 17.289474 | 11.851955 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false | 11 |
a2e9c61aab25e3c7ffe32f53dadb79fe67ca2243 | 30,408,368,490,220 | 2fd43b208a77b77b698770735f9fe7a754797148 | /b2c-cloud-test-parent/b2c-cloud-test-learn-maven/src/main/java/com/csair/b2c/cloud/test/learn/maven/service/MailService.java | ef747357f39691a2f577745ed7e0910a8550f8c9 | [
"Unlicense"
] | permissive | jufeng98/b2c | https://github.com/jufeng98/b2c | 8aa6909005b67fc389d33d5485e3f936af373f43 | 68c75e8e2c905cbcede41375511cedde4bf0218f | refs/heads/master | 2020-02-18T13:16:20.311000 | 2020-01-19T08:44:04 | 2020-01-19T08:44:04 | 125,715,328 | 2 | 2 | Unlicense | false | 2021-01-21T00:32:31 | 2018-03-18T10:52:18 | 2021-01-18T12:12:33 | 2021-01-21T00:32:30 | 7,290 | 2 | 2 | 17 | JavaScript | false | false | package com.csair.b2c.cloud.test.learn.maven.service;
public interface MailService {
void sendEmail(String to,String from,String content);
}
| UTF-8 | Java | 143 | java | MailService.java | Java | [] | null | [] | package com.csair.b2c.cloud.test.learn.maven.service;
public interface MailService {
void sendEmail(String to,String from,String content);
}
| 143 | 0.797203 | 0.79021 | 5 | 27.6 | 23.736891 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.