blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
list | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
list | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
54f21bc45981e3e2e62a975db8bcd162ae83f316 | 21,930,103,083,334 | 04cc4b16fbffaa09a4139c1efb70af6f428c3131 | /CarlosVarela_Lab#2/src/carlosvarela_lab/pkg2/Amigos.java | 0bfddea775f7ce49b48a32679094866f64fce4c7 | [
"MIT"
] | permissive | Carlosvhz/CarlosVarela_Lab2 | https://github.com/Carlosvhz/CarlosVarela_Lab2 | 4e6693f1e3e3a9a54f7a2aa1202268fd7b9403a5 | 663ea08e6cd139b121cbe7fde7e1a0cdcd5f511d | refs/heads/master | 2021-01-01T19:47:27.141000 | 2017-07-29T00:10:47 | 2017-07-29T00:10:47 | 98,681,282 | 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 carlosvarela_lab.pkg2;
/**
*
* @author carlo
*/
public class Amigos {
String Minombre, amigo;
public Amigos(String Minombre, String amigo){
this.Minombre = Minombre;
this.amigo = amigo;
}
public String toString(){
return amigo;
}
public String getMinombre(){
return Minombre;
}
public String getNomAmigo(){
return amigo;
}
}
| UTF-8 | Java | 623 | java | Amigos.java | Java | [
{
"context": "\npackage carlosvarela_lab.pkg2;\n\n/**\n *\n * @author carlo\n */\npublic class Amigos {\n \n String Minombr",
"end": 240,
"score": 0.8885930180549622,
"start": 235,
"tag": "USERNAME",
"value": "carlo"
}
] | 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 carlosvarela_lab.pkg2;
/**
*
* @author carlo
*/
public class Amigos {
String Minombre, amigo;
public Amigos(String Minombre, String amigo){
this.Minombre = Minombre;
this.amigo = amigo;
}
public String toString(){
return amigo;
}
public String getMinombre(){
return Minombre;
}
public String getNomAmigo(){
return amigo;
}
}
| 623 | 0.614767 | 0.613162 | 32 | 18.46875 | 18.711601 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 8 |
20a1aaa49a072f42ace676b4236298ef3cd62b3b | 9,783,935,543,167 | fa805698f5919764a6876babca21db08c455ccb3 | /frame-base/src/main/java/com/codeyn/base/httpclient/Request.java | 4c9d17e83667f08ae1df8f8093e481c0fe4564ed | [
"Apache-2.0"
] | permissive | efsn/frame-standard | https://github.com/efsn/frame-standard | 515aab77e428343b4df256f0e3b422276e442632 | d70a12ac875526444e00769f528c7d0fd85c065d | refs/heads/master | 2022-12-26T11:17:19.290000 | 2020-05-04T02:50:40 | 2020-05-04T02:50:40 | 40,405,519 | 0 | 2 | Apache-2.0 | false | 2022-12-16T15:30:35 | 2015-08-08T14:34:01 | 2020-05-04T02:50:51 | 2022-12-16T15:30:34 | 146 | 0 | 1 | 19 | Java | false | false | package com.codeyn.base.httpclient;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
/**
* HTTP请求信息包装类
*
* @author leyuanren 2013-6-14 下午2:16:09
*/
public class Request {
/**
* 默认的请求编码方式
*/
private String charset = "UTF-8";
private String scheme = "http";
private String host = null;
private String path = "";
/**
* 如果设置了gateway,将忽略scheme、host、path的设置
*/
private String gateway = null;
private boolean excludeEmptyValue = false;
private List<NameValuePair> parameters = new ArrayList<NameValuePair>();
/**
* 默认的请求方式
*/
private HttpMethod method = HttpMethod.GET;
private int soTimeout = 0;
private int connectionTimeout = 0;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public HttpMethod getMethod() {
return method;
}
public void setMethod(HttpMethod method) {
this.method = method;
}
public int getConnectionTimeout() {
return connectionTimeout;
}
public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public int getSoTimeout() {
return soTimeout;
}
public void setSoTimeout(int soTimeout) {
this.soTimeout = soTimeout;
}
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public void addParam(String key, String value) {
if (key != null) {
parameters.add(new BasicNameValuePair(key, value));
}
}
public List<NameValuePair> getNameValuePairList() {
return parameters;
}
public boolean isExcludeEmptyValue() {
return excludeEmptyValue;
}
public void setExcludeEmptyValue(boolean excludeEmptyValue) {
this.excludeEmptyValue = excludeEmptyValue;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
}
| UTF-8 | Java | 2,557 | java | Request.java | Java | [
{
"context": "cNameValuePair;\n\n/**\n * HTTP请求信息包装类\n * \n * @author leyuanren 2013-6-14 下午2:16:09\n */\n\npublic class Request {\n ",
"end": 222,
"score": 0.9991281032562256,
"start": 213,
"tag": "USERNAME",
"value": "leyuanren"
}
] | null | [] | package com.codeyn.base.httpclient;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
/**
* HTTP请求信息包装类
*
* @author leyuanren 2013-6-14 下午2:16:09
*/
public class Request {
/**
* 默认的请求编码方式
*/
private String charset = "UTF-8";
private String scheme = "http";
private String host = null;
private String path = "";
/**
* 如果设置了gateway,将忽略scheme、host、path的设置
*/
private String gateway = null;
private boolean excludeEmptyValue = false;
private List<NameValuePair> parameters = new ArrayList<NameValuePair>();
/**
* 默认的请求方式
*/
private HttpMethod method = HttpMethod.GET;
private int soTimeout = 0;
private int connectionTimeout = 0;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public HttpMethod getMethod() {
return method;
}
public void setMethod(HttpMethod method) {
this.method = method;
}
public int getConnectionTimeout() {
return connectionTimeout;
}
public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
public int getSoTimeout() {
return soTimeout;
}
public void setSoTimeout(int soTimeout) {
this.soTimeout = soTimeout;
}
public String getCharset() {
return charset;
}
public void setCharset(String charset) {
this.charset = charset;
}
public void addParam(String key, String value) {
if (key != null) {
parameters.add(new BasicNameValuePair(key, value));
}
}
public List<NameValuePair> getNameValuePairList() {
return parameters;
}
public boolean isExcludeEmptyValue() {
return excludeEmptyValue;
}
public void setExcludeEmptyValue(boolean excludeEmptyValue) {
this.excludeEmptyValue = excludeEmptyValue;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
}
| 2,557 | 0.62233 | 0.616284 | 125 | 18.848 | 18.768082 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304 | false | false | 8 |
ad3ef4fe745f36ab47a02047bcb54688818fabf9 | 21,655,225,152,469 | dfc50ccf22129e0bef499bb90a1c6c622d6fe1f9 | /rm.java | b494b5238ef816ce5904e1b8bdec5188ce9c7c93 | [] | no_license | bryandebourbon/bash_clone | https://github.com/bryandebourbon/bash_clone | 9bd40fb305884fe6810969bfff11429d697a7cdc | 9f291127f0f38b257629387684f8fc0b3e44bdc7 | refs/heads/master | 2021-01-25T05:50:47.492000 | 2017-02-02T04:38:31 | 2017-02-02T04:38:31 | 80,692,927 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.security.InvalidParameterException;
public class rm extends Command {
/**
* Creates a <code>rm</code> object.
* This object knows the amount of parameters that it can expect.
*
* @param numParams, the number of parameters given by the user.
* @return void
*/
public rm(int[] numParams){
super(numParams);
}
/**
* Copies an item and adds it to the specified directory.
* Note that current directory is the default directory.
*
* @param shell, the current JShell object
* @param item, the item that is to be copied
* @param itemName, the name of the item
* @param folder, the folder that the copy is to be inserted into
* @throws Exception - if the target file already exists.
*/
public String remove(JShell shell, Item item, boolean paramPresent) throws Exception{
DIR folder = item.getParentDIR(shell);
if (item instanceof DIR) {
//recursively remove subItems
for (Item component : ((DIR)item).getSubContents().values()) {
this.remove(shell, component, paramPresent);
}
}
if (!paramPresent){
String result = folder.removalPrompt(shell, "are you sure you want to remove " + item.getName() + "? (yes or no) ", "yes|no" );
if (result.equals("no")){
return item.getName() + " was not removed.\n";
}
}
folder.getSubContents().remove(item.getName());
return item.getName() + " was removed.";
}
/**
*
*/
public String looper(JShell shell, String[] parameters, int i, Object[] params ) throws Exception {
if (parameters.length == 1){
throw new InvalidParameterException("Error! rm takes a list of parameters!");
}
Item item = shell.getCurDir().followPath(shell, parameters[i]);
return this.remove(shell, item, ((String)params[0]).equals("-f"));
}
/**
*
*/
public String exe(JShell shell, String[] parameters, String input)
throws Exception{
Object [] extractedParams = super.extractOptParam(input, "-f");
String [] nonOptParameters = (String[])extractedParams[1];
String output = super.exeForList(shell, nonOptParameters, input, nonOptParameters.length,
new Object[] {(String)extractedParams[0]});
return super.passToEcho(shell, input, output);
}
}
| UTF-8 | Java | 2,196 | java | rm.java | Java | [] | null | [] | import java.security.InvalidParameterException;
public class rm extends Command {
/**
* Creates a <code>rm</code> object.
* This object knows the amount of parameters that it can expect.
*
* @param numParams, the number of parameters given by the user.
* @return void
*/
public rm(int[] numParams){
super(numParams);
}
/**
* Copies an item and adds it to the specified directory.
* Note that current directory is the default directory.
*
* @param shell, the current JShell object
* @param item, the item that is to be copied
* @param itemName, the name of the item
* @param folder, the folder that the copy is to be inserted into
* @throws Exception - if the target file already exists.
*/
public String remove(JShell shell, Item item, boolean paramPresent) throws Exception{
DIR folder = item.getParentDIR(shell);
if (item instanceof DIR) {
//recursively remove subItems
for (Item component : ((DIR)item).getSubContents().values()) {
this.remove(shell, component, paramPresent);
}
}
if (!paramPresent){
String result = folder.removalPrompt(shell, "are you sure you want to remove " + item.getName() + "? (yes or no) ", "yes|no" );
if (result.equals("no")){
return item.getName() + " was not removed.\n";
}
}
folder.getSubContents().remove(item.getName());
return item.getName() + " was removed.";
}
/**
*
*/
public String looper(JShell shell, String[] parameters, int i, Object[] params ) throws Exception {
if (parameters.length == 1){
throw new InvalidParameterException("Error! rm takes a list of parameters!");
}
Item item = shell.getCurDir().followPath(shell, parameters[i]);
return this.remove(shell, item, ((String)params[0]).equals("-f"));
}
/**
*
*/
public String exe(JShell shell, String[] parameters, String input)
throws Exception{
Object [] extractedParams = super.extractOptParam(input, "-f");
String [] nonOptParameters = (String[])extractedParams[1];
String output = super.exeForList(shell, nonOptParameters, input, nonOptParameters.length,
new Object[] {(String)extractedParams[0]});
return super.passToEcho(shell, input, output);
}
}
| 2,196 | 0.681694 | 0.679873 | 83 | 25.45783 | 30.089546 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.73494 | false | false | 8 |
63e353e9fba93e56ab7573a6b323dcda751e14c1 | 13,907,104,144,348 | 0fb17be6bc7b7a581fc5124087363400a92af6e6 | /src/java/penoplatinum/simulator/Tiles.java | f1ffbdc139756e0476dec8e099deeb578e605ad4 | [] | no_license | s0202579/po-mindstorms | https://github.com/s0202579/po-mindstorms | 96f4759b951b300bafb2df1e645f64bc9d6a13b5 | 254673f99d37982289feba9693099dd867235621 | refs/heads/master | 2021-04-15T08:18:11.821000 | 2011-12-02T14:14:00 | 2011-12-02T14:14:00 | 2,525,780 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package penoplatinum.simulator;
/**
* Enumeration of commonly used Tiles
*
* Author: Team Platinum
*/
public class Tiles {
// static instantiations of common tiles
// up-down, down-up
public static Tile N_S = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.N)
.withWall (Baring.E) .withWall (Baring.W)
.withLine (Baring.E, Tile.WHITE) .withLine (Baring.W, Tile.BLACK);
public static Tile S_N = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.S)
.withWall (Baring.E) .withWall (Baring.W)
.withLine (Baring.E, Tile.BLACK) .withLine (Baring.W, Tile.WHITE);
// left-right, right-left
public static Tile W_E = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.W)
.withWall (Baring.S) .withWall (Baring.N)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.S, Tile.BLACK);
public static Tile E_W = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.E)
.withWall (Baring.N) .withWall (Baring.S)
.withLine (Baring.N, Tile.BLACK) .withLine (Baring.S, Tile.WHITE);
// up-right, right-up
public static Tile N_E = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.N)
.withWall (Baring.S) .withWall (Baring.W)
.withLine (Baring.S, Tile.BLACK) .withLine (Baring.W, Tile.BLACK)
.withCorner (Baring.NE, Tile.WHITE);
public static Tile E_N = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.E)
.withWall (Baring.S) .withWall (Baring.W)
.withLine (Baring.S, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.NE, Tile.BLACK);
// down-right, right-down
public static Tile S_E = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.S)
.withWall (Baring.N) .withWall (Baring.W)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.SE, Tile.BLACK);
public static Tile E_S = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.E)
.withWall (Baring.N) .withWall (Baring.W)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.SE, Tile.BLACK);
// down-left, left-down
public static Tile S_W = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.S)
.withWall (Baring.N) .withWall (Baring.E)
.withLine (Baring.N, Tile.BLACK) .withLine (Baring.E, Tile.BLACK)
.withCorner (Baring.SW, Tile.WHITE);
public static Tile W_S = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.W)
.withWall (Baring.N) .withWall (Baring.E)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.E, Tile.WHITE)
.withCorner (Baring.SW, Tile.BLACK);
// up-left, left-up
public static Tile N_W = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.N)
.withWall (Baring.S) .withWall (Baring.E)
.withLine (Baring.S, Tile.WHITE) .withLine (Baring.E, Tile.WHITE)
.withCorner (Baring.NW, Tile.BLACK);
public static Tile W_N = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.W)
.withWall (Baring.S) .withWall (Baring.E)
.withLine (Baring.S, Tile.BLACK) .withLine (Baring.E, Tile.BLACK)
.withCorner (Baring.NW, Tile.WHITE);
public static Tile NONE = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile N = new Tile()
.withWall(Baring.E)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile E = new Tile()
.withWall(Baring.N)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile S = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.W);
public static Tile W = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.S);
}
| UTF-8 | Java | 4,242 | java | Tiles.java | Java | [
{
"context": " Enumeration of commonly used Tiles\n * \n * Author: Team Platinum\n */\n\npublic class Tiles {\n // static instantiati",
"end": 103,
"score": 0.9995356798171997,
"start": 90,
"tag": "NAME",
"value": "Team Platinum"
}
] | null | [] | package penoplatinum.simulator;
/**
* Enumeration of commonly used Tiles
*
* Author: <NAME>
*/
public class Tiles {
// static instantiations of common tiles
// up-down, down-up
public static Tile N_S = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.N)
.withWall (Baring.E) .withWall (Baring.W)
.withLine (Baring.E, Tile.WHITE) .withLine (Baring.W, Tile.BLACK);
public static Tile S_N = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.S)
.withWall (Baring.E) .withWall (Baring.W)
.withLine (Baring.E, Tile.BLACK) .withLine (Baring.W, Tile.WHITE);
// left-right, right-left
public static Tile W_E = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.W)
.withWall (Baring.S) .withWall (Baring.N)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.S, Tile.BLACK);
public static Tile E_W = new Tile()
.withBarcode(Barcode.Forward) .putBarcodeAt(Baring.E)
.withWall (Baring.N) .withWall (Baring.S)
.withLine (Baring.N, Tile.BLACK) .withLine (Baring.S, Tile.WHITE);
// up-right, right-up
public static Tile N_E = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.N)
.withWall (Baring.S) .withWall (Baring.W)
.withLine (Baring.S, Tile.BLACK) .withLine (Baring.W, Tile.BLACK)
.withCorner (Baring.NE, Tile.WHITE);
public static Tile E_N = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.E)
.withWall (Baring.S) .withWall (Baring.W)
.withLine (Baring.S, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.NE, Tile.BLACK);
// down-right, right-down
public static Tile S_E = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.S)
.withWall (Baring.N) .withWall (Baring.W)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.SE, Tile.BLACK);
public static Tile E_S = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.E)
.withWall (Baring.N) .withWall (Baring.W)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.W, Tile.WHITE)
.withCorner (Baring.SE, Tile.BLACK);
// down-left, left-down
public static Tile S_W = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.S)
.withWall (Baring.N) .withWall (Baring.E)
.withLine (Baring.N, Tile.BLACK) .withLine (Baring.E, Tile.BLACK)
.withCorner (Baring.SW, Tile.WHITE);
public static Tile W_S = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.W)
.withWall (Baring.N) .withWall (Baring.E)
.withLine (Baring.N, Tile.WHITE) .withLine (Baring.E, Tile.WHITE)
.withCorner (Baring.SW, Tile.BLACK);
// up-left, left-up
public static Tile N_W = new Tile()
.withBarcode(Barcode.Right) .putBarcodeAt(Baring.N)
.withWall (Baring.S) .withWall (Baring.E)
.withLine (Baring.S, Tile.WHITE) .withLine (Baring.E, Tile.WHITE)
.withCorner (Baring.NW, Tile.BLACK);
public static Tile W_N = new Tile()
.withBarcode(Barcode.Left) .putBarcodeAt(Baring.W)
.withWall (Baring.S) .withWall (Baring.E)
.withLine (Baring.S, Tile.BLACK) .withLine (Baring.E, Tile.BLACK)
.withCorner (Baring.NW, Tile.WHITE);
public static Tile NONE = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile N = new Tile()
.withWall(Baring.E)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile E = new Tile()
.withWall(Baring.N)
.withWall(Baring.S)
.withWall(Baring.W);
public static Tile S = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.W);
public static Tile W = new Tile()
.withWall(Baring.N)
.withWall(Baring.E)
.withWall(Baring.S);
}
| 4,235 | 0.598303 | 0.598303 | 101 | 41 | 22.614723 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.554455 | false | false | 8 |
9957fe5af5ec81156bff8f8dc2e61488ea11ac9f | 9,268,539,434,348 | 6f9a8bd30666997c833444b282d7032a6b27df7e | /SkateboardTeleOp.java | 5123c1b5dbc9310de8937f5b9e7093c39698f9e2 | [] | no_license | SteelSerpents/TeamCode | https://github.com/SteelSerpents/TeamCode | d69c1760f8fa55167ca1e80f17d590349bced3c5 | dc54580e7afcec4c585bdc075cb122b74c83814d | refs/heads/master | 2021-05-04T08:20:20.702000 | 2016-12-23T19:34:09 | 2016-12-23T19:34:09 | 70,334,551 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.firstinspires.ftc.teamcode;
import android.util.Log;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
@TeleOp(name = "SkateboardTeleOp", group = "TeleOp")
public class SkateboardTeleOp extends OpMode
{
SteelSerpentsRobot robot;
@Override
public void init()
{
robot = new SteelSerpentsRobot(hardwareMap);
}
@Override
public void loop()
{
gamePad1Control();
}
/**
* Processes the inputs from gamepad1 and converts them into controls to drive the robot.
*/
public void gamePad1Control()
{
double robotVelocity;
double heading;
// The robot should go forward if the right trigger is pulled, and backward if the left trigger is pulled
robotVelocity = gamepad1.left_trigger - gamepad1.right_trigger;
// Ensure that the speed is in the correct range [-1,1]
robotVelocity = robot.clamp(robotVelocity);
// Set the direction of travel to be the same as the left joystick
heading = joystickToRadians(gamepad1.left_stick_x,gamepad1.left_stick_y);
// Set the appropriate values for each motor
robot.setMotorValues(robotVelocity, heading, gamepad1.right_stick_x);
// Drive the robot
robot.drive();
}
/**
* This function converts a joystick's direction into a heading in radians.
* @param stickX The joystick's x value.
* @param stickY The joystick's y value.
* @return The joystick's heading in radians.
*/
public static double joystickToRadians(double stickX, double stickY) throws IllegalArgumentException
{
try
{
if (stickX < -1 || 1 < stickX) {
throw new IllegalArgumentException("The joystick x value of " + stickX + " is out of bounds from [-1,1].");
} else if (stickY < -1 || 1 < stickY) {
throw new IllegalArgumentException("The joystick y value of " + stickY + " is out of bounds from [-1,1].");
}
}
catch (IllegalArgumentException e)
{
if (stickX < -1) { stickX = -1; }
if (stickX > 1) { stickX = 1; }
if (stickY < -1) { stickY = -1; }
if (stickY > 1) { stickY = 1; }
e.printStackTrace();
}
double radians = 0;
// If stick is on the y axis
if (stickX == 0)
{
// And if the stick is centered or pushing forward on the Y axis
if (0 <= stickY)
{
// Set direction to be straight forward
radians = Math.PI/2;
}
// If stick is pulled backward
else if (stickY < 0)
{
// Set the direction to be backwards
radians = 3*Math.PI/2;
}
}
// If the stick is either above or below the x axis.
else
{
// Use arctangent to convert stick position into radians
radians = Math.atan(stickY/stickX);
// If x is negative add Pi to the value
if (stickX < 0) {
radians += Math.PI;
}
// If x is positive but y is negative
else if (0 < stickX && stickY < 0)
{
// When x is positive but y is negative arctan returns values which are off by 2*Pi
radians += 2*Math.PI;
}
}
// Rotate the axis by 90 degrees
radians += Math.PI/2;
// Ensure that the result is in the range [0,2PI]
radians %= 2*Math.PI;
return radians;
}
@Override
public void stop()
{
}
/**
* Print to the Logcat debug console as well as to the FTC Telemetry.
* @param key A text key that we can use to filter our debug output.
* @param text The information to be monitored when debugging.
*/
public void print(String key, String text)
{
Log.d(key, text);
telemetry.addData(key, text);
}
/**
* Print to the Logcat debug console as well as to the FTC Telemetry.
* @param key A text key that we can use to filter our debug output.
* @param text The information to be monitored when debugging.
*/
public void print(String key, double text)
{
print(key, String.valueOf(text));
}
} | UTF-8 | Java | 4,476 | java | SkateboardTeleOp.java | Java | [] | null | [] | package org.firstinspires.ftc.teamcode;
import android.util.Log;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
@TeleOp(name = "SkateboardTeleOp", group = "TeleOp")
public class SkateboardTeleOp extends OpMode
{
SteelSerpentsRobot robot;
@Override
public void init()
{
robot = new SteelSerpentsRobot(hardwareMap);
}
@Override
public void loop()
{
gamePad1Control();
}
/**
* Processes the inputs from gamepad1 and converts them into controls to drive the robot.
*/
public void gamePad1Control()
{
double robotVelocity;
double heading;
// The robot should go forward if the right trigger is pulled, and backward if the left trigger is pulled
robotVelocity = gamepad1.left_trigger - gamepad1.right_trigger;
// Ensure that the speed is in the correct range [-1,1]
robotVelocity = robot.clamp(robotVelocity);
// Set the direction of travel to be the same as the left joystick
heading = joystickToRadians(gamepad1.left_stick_x,gamepad1.left_stick_y);
// Set the appropriate values for each motor
robot.setMotorValues(robotVelocity, heading, gamepad1.right_stick_x);
// Drive the robot
robot.drive();
}
/**
* This function converts a joystick's direction into a heading in radians.
* @param stickX The joystick's x value.
* @param stickY The joystick's y value.
* @return The joystick's heading in radians.
*/
public static double joystickToRadians(double stickX, double stickY) throws IllegalArgumentException
{
try
{
if (stickX < -1 || 1 < stickX) {
throw new IllegalArgumentException("The joystick x value of " + stickX + " is out of bounds from [-1,1].");
} else if (stickY < -1 || 1 < stickY) {
throw new IllegalArgumentException("The joystick y value of " + stickY + " is out of bounds from [-1,1].");
}
}
catch (IllegalArgumentException e)
{
if (stickX < -1) { stickX = -1; }
if (stickX > 1) { stickX = 1; }
if (stickY < -1) { stickY = -1; }
if (stickY > 1) { stickY = 1; }
e.printStackTrace();
}
double radians = 0;
// If stick is on the y axis
if (stickX == 0)
{
// And if the stick is centered or pushing forward on the Y axis
if (0 <= stickY)
{
// Set direction to be straight forward
radians = Math.PI/2;
}
// If stick is pulled backward
else if (stickY < 0)
{
// Set the direction to be backwards
radians = 3*Math.PI/2;
}
}
// If the stick is either above or below the x axis.
else
{
// Use arctangent to convert stick position into radians
radians = Math.atan(stickY/stickX);
// If x is negative add Pi to the value
if (stickX < 0) {
radians += Math.PI;
}
// If x is positive but y is negative
else if (0 < stickX && stickY < 0)
{
// When x is positive but y is negative arctan returns values which are off by 2*Pi
radians += 2*Math.PI;
}
}
// Rotate the axis by 90 degrees
radians += Math.PI/2;
// Ensure that the result is in the range [0,2PI]
radians %= 2*Math.PI;
return radians;
}
@Override
public void stop()
{
}
/**
* Print to the Logcat debug console as well as to the FTC Telemetry.
* @param key A text key that we can use to filter our debug output.
* @param text The information to be monitored when debugging.
*/
public void print(String key, String text)
{
Log.d(key, text);
telemetry.addData(key, text);
}
/**
* Print to the Logcat debug console as well as to the FTC Telemetry.
* @param key A text key that we can use to filter our debug output.
* @param text The information to be monitored when debugging.
*/
public void print(String key, double text)
{
print(key, String.valueOf(text));
}
} | 4,476 | 0.57328 | 0.56345 | 132 | 32.916668 | 28.054611 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.401515 | false | false | 8 |
22f5867606483c6e76271331f1a37839f0eb2692 | 18,245,021,133,511 | bb2b909f324cbd9589199113523e28b1898e2747 | /accountService/src/main/java/edu/kpi/dto/ReceiptDto.java | 8ae8a5d368c35ed63f4039ebbc10cc98aad85229 | [] | no_license | PavloRospopa/microservices-poc | https://github.com/PavloRospopa/microservices-poc | 2c595feabf05a56327385d1954a05e21615aee99 | d1ad6f6b575186f05db715c521cb03ac307afae8 | refs/heads/master | 2020-03-11T10:49:45.996000 | 2018-04-26T22:02:54 | 2018-04-26T22:02:54 | 129,952,824 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.kpi.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
@AllArgsConstructor
public class ReceiptDto {
private String id;
private String orderId;
private int totalPrice;
}
| UTF-8 | Java | 243 | java | ReceiptDto.java | Java | [] | null | [] | package edu.kpi.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
@AllArgsConstructor
public class ReceiptDto {
private String id;
private String orderId;
private int totalPrice;
}
| 243 | 0.765432 | 0.765432 | 15 | 15.2 | 11.214276 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 8 |
3b0200b6c4920044945d4bab5c72c7fd19ab9766 | 14,697,378,129,981 | 316499f683ae08e71dfea2f3b5576d9b92ae2be4 | /src/main/java/com/admiosflix/exceptions/MovieNotFoundException.java | 988c9acece411df1aa85e9bf6431fb5dffb6079b | [] | no_license | matiasballester/movies-management-api | https://github.com/matiasballester/movies-management-api | 759370b90784a946b097bcf9a7e51ffc98f8edc4 | 764873d2fffaf96eec1cd922461b26326bf53a30 | refs/heads/master | 2023-04-28T06:38:51.714000 | 2021-05-14T14:05:02 | 2021-05-14T14:05:02 | 366,126,344 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.admiosflix.exceptions;
public class MovieNotFoundException extends RuntimeException {
public MovieNotFoundException(Long id) {
super("Could not found movie id " + id);
}
}
| UTF-8 | Java | 201 | java | MovieNotFoundException.java | Java | [] | null | [] | package com.admiosflix.exceptions;
public class MovieNotFoundException extends RuntimeException {
public MovieNotFoundException(Long id) {
super("Could not found movie id " + id);
}
}
| 201 | 0.731343 | 0.731343 | 7 | 27.714285 | 23.571861 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 8 |
09dc63261ee3d4bb712e691378515678514599d0 | 22,239,340,714,074 | 58865b1cf28ca114e710430ebe0343d58ba1dc98 | /projects/driver/modbus/src/main/java/org/openmuc/framework/driver/modbus/rtutcp/bonino/MasterConnection.java | a3f10bcc906813e4449ed65f1e15ebd2b5ca4098 | [
"GPL-1.0-or-later",
"GPL-3.0-only"
] | permissive | gythialy/openmuc | https://github.com/gythialy/openmuc | 2d0b9709740ea2ef0b7cd5e9e704310b544ec3dd | 675a85c14ce86c35dbcf70af9c2bf6731c4f7f03 | refs/heads/master | 2022-10-09T17:46:29.147000 | 2022-08-15T05:24:32 | 2022-08-15T05:24:32 | 24,041,094 | 16 | 26 | Apache-2.0 | false | 2023-09-12T04:30:11 | 2014-09-15T03:16:21 | 2023-07-24T19:08:08 | 2023-09-12T04:30:10 | 41,749 | 15 | 23 | 3 | Java | false | false | package org.openmuc.framework.driver.modbus.rtutcp.bonino;
/**
* A common interface for master connections (not strictly covering serial connections)
*
* @author bonino
*
* https://github.com/dog-gateway/jamod-rtu-over-tcp
*/
public interface MasterConnection {
public void connect() throws Exception;
public boolean isConnected();
public void close();
}
| UTF-8 | Java | 389 | java | MasterConnection.java | Java | [
{
"context": "rictly covering serial connections)\n * \n * @author bonino\n * \n * https://github.com/dog-gateway/jam",
"end": 173,
"score": 0.9996225237846375,
"start": 167,
"tag": "USERNAME",
"value": "bonino"
},
{
"context": " @author bonino\n * \n * https://github.com/dog-gateway/jamod-rtu-over-tcp\n */\n\npublic interface MasterCo",
"end": 219,
"score": 0.9991199374198914,
"start": 208,
"tag": "USERNAME",
"value": "dog-gateway"
}
] | null | [] | package org.openmuc.framework.driver.modbus.rtutcp.bonino;
/**
* A common interface for master connections (not strictly covering serial connections)
*
* @author bonino
*
* https://github.com/dog-gateway/jamod-rtu-over-tcp
*/
public interface MasterConnection {
public void connect() throws Exception;
public boolean isConnected();
public void close();
}
| 389 | 0.706941 | 0.706941 | 19 | 19.473684 | 25.539171 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.210526 | false | false | 8 |
8d41cdc8bde3e4ace055bee9ce4a167a8fe7efc0 | 7,335,804,152,349 | 80e13d6a30190615fe9af732bbfd068d536a6e54 | /src/test/java/com/bitbucket/learningjava/WeightConvertorTest.java | 588273f3c9a685b8e8be406edb741c9a3a25b076 | [] | no_license | sjose8/learningjava | https://github.com/sjose8/learningjava | b4887d9c95f5204697bb6b5b1060db01cb364f89 | 5acc45637e09da33bc52b492fa22bdbb00465c0a | refs/heads/master | 2021-01-21T03:49:25.045000 | 2015-07-29T22:26:41 | 2015-07-29T22:26:41 | 39,859,405 | 0 | 0 | null | true | 2015-07-28T21:47:56 | 2015-07-28T21:47:55 | 2015-07-28T21:47:56 | 2015-04-05T23:03:35 | 732 | 0 | 0 | 0 | Java | null | null | package com.bitbucket.learningjava;
import org.assertj.core.data.Offset;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.offset;
/**
* Created by amit on 9/11/14.
*/
public class WeightConvertorTest {
@Test
public void shouldConvertPoundsToKilograms(){
WeightConvertor weightConvertor = new WeightConvertor();
assertThat(weightConvertor.poundsToKilograms(10.0)).isCloseTo(4.535, Offset.offset(0.001));
}
}
| UTF-8 | Java | 522 | java | WeightConvertorTest.java | Java | [
{
"context": "tj.core.api.Assertions.offset;\n\n\n/**\n * Created by amit on 9/11/14.\n */\npublic class WeightConvertorTest ",
"end": 234,
"score": 0.9937872886657715,
"start": 230,
"tag": "USERNAME",
"value": "amit"
}
] | null | [] | package com.bitbucket.learningjava;
import org.assertj.core.data.Offset;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.offset;
/**
* Created by amit on 9/11/14.
*/
public class WeightConvertorTest {
@Test
public void shouldConvertPoundsToKilograms(){
WeightConvertor weightConvertor = new WeightConvertor();
assertThat(weightConvertor.poundsToKilograms(10.0)).isCloseTo(4.535, Offset.offset(0.001));
}
}
| 522 | 0.745211 | 0.714559 | 22 | 22.727272 | 27.117893 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 8 |
e1df8bde4305ccd8793463de03b023f998108a6f | 30,322,469,151,992 | 0b82313fcb6c0adf71da7c88fb148424d9307446 | /web-console/src/main/resources/generator/service/impl/TemplateServiceImpl.java | f733b7777710d263ffe88f4ba0cb6e035e125cff | [
"Apache-2.0"
] | permissive | kxjl168/jmqtt | https://github.com/kxjl168/jmqtt | 9777e9800e23d3552f5e4bcd84e2a26c1c2f71a3 | e03a24e16d6262c9bd0c4b781bb968bbd48c27e9 | refs/heads/master | 2020-09-24T16:55:28.962000 | 2020-02-14T05:31:13 | 2020-02-14T05:31:13 | 225,802,304 | 0 | 0 | Apache-2.0 | true | 2019-12-04T07:08:07 | 2019-12-04T07:08:06 | 2019-12-03T06:40:14 | 2019-10-23T11:15:07 | 475 | 0 | 0 | 0 | null | false | false | package ${basepackageName}.service.impl;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import ${basepackageName}.util.ExceptionUntil;
import ${basepackageName}.util.UUIDUtil;
import ${basepackageName}.dao.${modelClass}Mapper;
import ${basepackageName}.pojo.${modelClass};
import ${basepackageName}.service.${modelClass}Service;
import java.util.*;
@Service
public class ${modelClass}ServiceImpl implements ${modelClass}Service {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private ${modelClass}Mapper itemMapper;
/**
* @param item
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject save${modelClass}(${modelClass} item) {
JSONObject rtn = new JSONObject();
/*
* if (null == item || null == item.getPassword() || null ==
* item.getTelephone()) { rtn.put("bol", false); rtn.put("message",
* "手机号码或者密码为空"); return rtn; }
*/
try {
<#if idType=='2'>
item.setId(UUIDUtil.getUUID());
</#if >
<#if idType=='1'>
item.setId( UUIDUtil. getLongUUID());
</#if>
itemMapper.insertSelective(item);
rtn.put("bol", true);
return rtn;
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("新增失败", e);
rtn.put("bol", false);
rtn.put("message", "新增失败");
log.error(ExceptionUntil.getMessage(e));
return rtn;
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject update${modelClass}(${modelClass} item) {
JSONObject rtn = new JSONObject();
if (null == item || null == item.getId()) {
rtn.put("bol", false);
rtn.put("message", "id为空");
return rtn;
}
try {
itemMapper.updateByPrimaryKeySelective(item);
rtn.put("bol", true);
return rtn;
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("更新出错", e);
rtn.put("bol", false);
rtn.put("message", "更新出错");
return rtn;
}
}
@Override
public List<${modelClass}> select${modelClass}List(${modelClass} item) {
List<${modelClass}> itemList = new ArrayList<>();
try {
itemList = itemMapper.selectList(item);
} catch (Exception e) {
e.printStackTrace();
log.error("查询列表出错");
log.error(ExceptionUntil.getMessage(e));
}
return itemList;
}
@Transactional(rollbackFor = Exception.class)
@Override
public int delete${modelClass}(${modelClass} item) {
int result = 0;
try {
result = itemMapper.delete(item);
} catch (Exception e) {
e.printStackTrace();
log.error("删除出错");
log.error(ExceptionUntil.getMessage(e));
}
return result;
}
@Override
public ${modelClass} select${modelClass}ById(String id) {
${modelClass} data = null;
${modelClass} query = new ${modelClass}();
<#if idType=='2'>
query.setId(id);
</#if >
<#if idType=='1'>
Long lid=Long.parseLong(id);
query.setId(lid);
</#if>
List<${modelClass}> datas = select${modelClass}List(query);
if (datas != null && datas.size() > 0) {
data = datas.get(0);
}
return data;
}
}
| UTF-8 | Java | 3,469 | java | TemplateServiceImpl.java | Java | [] | null | [] | package ${basepackageName}.service.impl;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import ${basepackageName}.util.ExceptionUntil;
import ${basepackageName}.util.UUIDUtil;
import ${basepackageName}.dao.${modelClass}Mapper;
import ${basepackageName}.pojo.${modelClass};
import ${basepackageName}.service.${modelClass}Service;
import java.util.*;
@Service
public class ${modelClass}ServiceImpl implements ${modelClass}Service {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private ${modelClass}Mapper itemMapper;
/**
* @param item
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject save${modelClass}(${modelClass} item) {
JSONObject rtn = new JSONObject();
/*
* if (null == item || null == item.getPassword() || null ==
* item.getTelephone()) { rtn.put("bol", false); rtn.put("message",
* "手机号码或者密码为空"); return rtn; }
*/
try {
<#if idType=='2'>
item.setId(UUIDUtil.getUUID());
</#if >
<#if idType=='1'>
item.setId( UUIDUtil. getLongUUID());
</#if>
itemMapper.insertSelective(item);
rtn.put("bol", true);
return rtn;
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("新增失败", e);
rtn.put("bol", false);
rtn.put("message", "新增失败");
log.error(ExceptionUntil.getMessage(e));
return rtn;
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject update${modelClass}(${modelClass} item) {
JSONObject rtn = new JSONObject();
if (null == item || null == item.getId()) {
rtn.put("bol", false);
rtn.put("message", "id为空");
return rtn;
}
try {
itemMapper.updateByPrimaryKeySelective(item);
rtn.put("bol", true);
return rtn;
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
log.error("更新出错", e);
rtn.put("bol", false);
rtn.put("message", "更新出错");
return rtn;
}
}
@Override
public List<${modelClass}> select${modelClass}List(${modelClass} item) {
List<${modelClass}> itemList = new ArrayList<>();
try {
itemList = itemMapper.selectList(item);
} catch (Exception e) {
e.printStackTrace();
log.error("查询列表出错");
log.error(ExceptionUntil.getMessage(e));
}
return itemList;
}
@Transactional(rollbackFor = Exception.class)
@Override
public int delete${modelClass}(${modelClass} item) {
int result = 0;
try {
result = itemMapper.delete(item);
} catch (Exception e) {
e.printStackTrace();
log.error("删除出错");
log.error(ExceptionUntil.getMessage(e));
}
return result;
}
@Override
public ${modelClass} select${modelClass}ById(String id) {
${modelClass} data = null;
${modelClass} query = new ${modelClass}();
<#if idType=='2'>
query.setId(id);
</#if >
<#if idType=='1'>
Long lid=Long.parseLong(id);
query.setId(lid);
</#if>
List<${modelClass}> datas = select${modelClass}List(query);
if (datas != null && datas.size() > 0) {
data = datas.get(0);
}
return data;
}
}
| 3,469 | 0.671677 | 0.669024 | 147 | 22.081633 | 21.115011 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.108844 | false | false | 8 |
73e400a348edc41866e9c19fb498096b988e8bca | 21,766,894,295,916 | 7cbeb734d77ba06e13619836ff01286b26f02341 | /Level011.java | dc0cab5d3052c77ddb3eed66cc083167feaf39ad | [] | no_license | DaeYoung7/sogang-2019_02_java | https://github.com/DaeYoung7/sogang-2019_02_java | 048df5244b7ae39ace4dd32679390a1208bac57c | 4fc8fab5bdce1c18c7819fe866a3087390aa6b39 | refs/heads/master | 2020-11-26T15:04:46.589000 | 2019-12-19T18:31:25 | 2019-12-19T18:31:25 | 229,115,481 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* CSE3040 HW2
* Level011.java
* Purpose: Calculate fibonacci Sequence
*
* @version 1.0 10/17/2019
* @author Daeyoung Eo
*/
package cse3040;
interface IntSequence {
boolean hasNext();
int next();
}
/**
* This class calculate fibonacci sequence hasNext method always return true
* next method returns temp1+temp2 temp1 stores number that this method returned
* two loops before temp2 stores number that this method returned two loops
* before temp is for temporary storing a number
*/
class FibonacciSequence implements IntSequence {
int temp = 0;
int temp1 = 0;
int temp2 = 1;
int num = 0;
public boolean hasNext() {
this.num++;
return true;
}
public int next() {
if (this.num == 1)
return temp1;
else if (this.num == 2)
return temp2;
else {
temp = temp1 + temp2;
temp1 = temp2;
temp2 = temp;
return temp2;
}
}
}
/**
* The main method for the fibonacci Sequence program
*
* @param args not used
*/
public class Level011 {
public static void main(String[] args) {
IntSequence seq = new FibonacciSequence();
for (int i = 0; i < 20; i++) {
if (seq.hasNext() == false)
break;
System.out.print(seq.next() + " ");
}
System.out.println(" ");
}
}
| UTF-8 | Java | 1,227 | java | Level011.java | Java | [
{
"context": "Sequence\n * \n * @version 1.0 10/17/2019\n * @author Daeyoung Eo\n */\n\npackage cse3040;\n\ninterface IntSequence {\n\tb",
"end": 130,
"score": 0.9998905062675476,
"start": 119,
"tag": "NAME",
"value": "Daeyoung Eo"
}
] | null | [] | /**
* CSE3040 HW2
* Level011.java
* Purpose: Calculate fibonacci Sequence
*
* @version 1.0 10/17/2019
* @author <NAME>
*/
package cse3040;
interface IntSequence {
boolean hasNext();
int next();
}
/**
* This class calculate fibonacci sequence hasNext method always return true
* next method returns temp1+temp2 temp1 stores number that this method returned
* two loops before temp2 stores number that this method returned two loops
* before temp is for temporary storing a number
*/
class FibonacciSequence implements IntSequence {
int temp = 0;
int temp1 = 0;
int temp2 = 1;
int num = 0;
public boolean hasNext() {
this.num++;
return true;
}
public int next() {
if (this.num == 1)
return temp1;
else if (this.num == 2)
return temp2;
else {
temp = temp1 + temp2;
temp1 = temp2;
temp2 = temp;
return temp2;
}
}
}
/**
* The main method for the fibonacci Sequence program
*
* @param args not used
*/
public class Level011 {
public static void main(String[] args) {
IntSequence seq = new FibonacciSequence();
for (int i = 0; i < 20; i++) {
if (seq.hasNext() == false)
break;
System.out.print(seq.next() + " ");
}
System.out.println(" ");
}
}
| 1,222 | 0.656072 | 0.616952 | 64 | 18.171875 | 18.87339 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.265625 | false | false | 8 |
6c74adbb33ec7ec6add3b2c3f1b703687210aa2d | 29,008,209,147,555 | 472ffa58eece26b89feff6167d0abc022a525591 | /app/src/main/java/app/com/murli/android/geoquiz/CheatActivity.java | efbf69f313864843aa5e369d8c508c130d10ea9a | [] | no_license | murli0802/GeoQuiz | https://github.com/murli0802/GeoQuiz | 81d72679d51b56bc1a0a434b45ecb5d1fef9b58b | 9feaf6fa57cc1996c5e7b55621a1913158995777 | refs/heads/master | 2021-01-19T15:07:49.857000 | 2017-04-13T19:07:15 | 2017-04-13T19:07:15 | 88,197,144 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package app.com.murli.android.geoquiz;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by MURLI on 12-01-2017.
*/
public class CheatActivity extends Activity {
public static final String EXTRA_ANSWER_IS_TRUE = "com.murli.android.geoquiz.answer_is_true";
public static final String EXTRA_ANSWER_IS_SHOWN = "com.murli.android.geoquiz.answer_shown";
public static final String is_Cheated = "Cheater";
private boolean mAnswerIsTrue;
// Wiring of Button in second Activity//
private TextView mAnswerTextView;
private Button mShowAnswer;
private void setAnswerShownResult(boolean isAnswerShown){
Intent data = new Intent();
data.putExtra(EXTRA_ANSWER_IS_SHOWN,isAnswerShown);
setResult(RESULT_OK,data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cheat);
//TextView devie_api;
// devie_api = (TextView)findViewById(R.id.device_API);
//devie_api.setText("API level" + Build.VERSION.SDK_INT);
if(savedInstanceState != null){
setAnswerShownResult(savedInstanceState.getBoolean(is_Cheated,false));
}
//Answer will not be shown until user presses button
setAnswerShownResult(false);
mAnswerIsTrue = getIntent().getBooleanExtra(EXTRA_ANSWER_IS_TRUE,mAnswerIsTrue);
mAnswerTextView = (TextView)findViewById(R.id.answerTextView);
mShowAnswer = (Button)findViewById(R.id.showAnswerButton);
mShowAnswer.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if (mAnswerIsTrue){
mAnswerTextView.setText(R.string.true_button);
}
else{
mAnswerTextView.setText(R.string.false_button);
}
setAnswerShownResult(true);
}
});
}
}
| UTF-8 | Java | 2,126 | java | CheatActivity.java | Java | [
{
"context": "mport android.widget.TextView;\n\n\n/**\n * Created by MURLI on 12-01-2017.\n */\npublic class CheatActivity ext",
"end": 239,
"score": 0.9738664627075195,
"start": 234,
"tag": "USERNAME",
"value": "MURLI"
}
] | null | [] | package app.com.murli.android.geoquiz;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by MURLI on 12-01-2017.
*/
public class CheatActivity extends Activity {
public static final String EXTRA_ANSWER_IS_TRUE = "com.murli.android.geoquiz.answer_is_true";
public static final String EXTRA_ANSWER_IS_SHOWN = "com.murli.android.geoquiz.answer_shown";
public static final String is_Cheated = "Cheater";
private boolean mAnswerIsTrue;
// Wiring of Button in second Activity//
private TextView mAnswerTextView;
private Button mShowAnswer;
private void setAnswerShownResult(boolean isAnswerShown){
Intent data = new Intent();
data.putExtra(EXTRA_ANSWER_IS_SHOWN,isAnswerShown);
setResult(RESULT_OK,data);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cheat);
//TextView devie_api;
// devie_api = (TextView)findViewById(R.id.device_API);
//devie_api.setText("API level" + Build.VERSION.SDK_INT);
if(savedInstanceState != null){
setAnswerShownResult(savedInstanceState.getBoolean(is_Cheated,false));
}
//Answer will not be shown until user presses button
setAnswerShownResult(false);
mAnswerIsTrue = getIntent().getBooleanExtra(EXTRA_ANSWER_IS_TRUE,mAnswerIsTrue);
mAnswerTextView = (TextView)findViewById(R.id.answerTextView);
mShowAnswer = (Button)findViewById(R.id.showAnswerButton);
mShowAnswer.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if (mAnswerIsTrue){
mAnswerTextView.setText(R.string.true_button);
}
else{
mAnswerTextView.setText(R.string.false_button);
}
setAnswerShownResult(true);
}
});
}
}
| 2,126 | 0.662747 | 0.658984 | 57 | 36.298244 | 25.618637 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.596491 | false | false | 8 |
d123288bb97dd9b8f996adf9656dbcfacb22eead | 2,671,469,709,551 | b97d96fbcd8f4a9a3139698d14447d5773a72f06 | /pattern-training/interface/src/main/java/com/example/manyimplements/manyimplements/OneImpl.java | bc401d25e63f85f41647ccd1bac9d75db2cfb027 | [] | no_license | kobeomseok95/spring_playground | https://github.com/kobeomseok95/spring_playground | d788a6cd9c31379a16c4b9b67aaae68ae82dd614 | 0e7fb7a8fd4888caee6f5903a1344d754225b7e1 | refs/heads/main | 2023-03-29T06:32:15.426000 | 2023-03-05T09:40:20 | 2023-03-05T09:40:20 | 338,787,366 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.manyimplements.manyimplements;
import org.springframework.stereotype.Service;
@Service
public class OneImpl implements One{
@Override
public String getOne() {
return "one";
}
}
| UTF-8 | Java | 219 | java | OneImpl.java | Java | [] | null | [] | package com.example.manyimplements.manyimplements;
import org.springframework.stereotype.Service;
@Service
public class OneImpl implements One{
@Override
public String getOne() {
return "one";
}
}
| 219 | 0.726027 | 0.726027 | 11 | 18.90909 | 17.742884 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 8 |
d517c323e6c64ddf9a01ed2d44ff670a5fef39b1 | 2,671,469,709,618 | 62aaa67a468107022635b566cbcf1109d3e4e648 | /zulin/src/private/nc/bs/hkjt/zulin/sdflr/ace/bp/AceHk_zulin_sdflrUnApproveBP.java | e4518fbea42e9200997f6ca70276abb53337322d | [] | no_license | boblee821226/hongkun | https://github.com/boblee821226/hongkun | f17a90221683f816f382443f5c223347b41afefc | 46c02ab124924f2c976044c5f31e632f706e61cf | refs/heads/master | 2021-06-25T03:57:28.516000 | 2021-02-22T05:42:07 | 2021-02-22T05:42:07 | 204,677,636 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package nc.bs.hkjt.zulin.sdflr.ace.bp;
import nc.impl.pubapp.pattern.data.bill.BillUpdate;
import nc.vo.hkjt.zulin.sdflr.SdflrBillVO;
import nc.vo.pub.VOStatus;
/**
* 标准单据弃审的BP
*/
public class AceHk_zulin_sdflrUnApproveBP {
public SdflrBillVO[] unApprove(SdflrBillVO[] clientBills,
SdflrBillVO[] originBills) {
for (SdflrBillVO clientBill : clientBills) {
clientBill.getParentVO().setStatus(VOStatus.UPDATED);
}
BillUpdate<SdflrBillVO> update = new BillUpdate<SdflrBillVO>();
SdflrBillVO[] returnVos = update.update(clientBills, originBills);
return returnVos;
}
}
| GB18030 | Java | 623 | java | AceHk_zulin_sdflrUnApproveBP.java | Java | [] | null | [] | package nc.bs.hkjt.zulin.sdflr.ace.bp;
import nc.impl.pubapp.pattern.data.bill.BillUpdate;
import nc.vo.hkjt.zulin.sdflr.SdflrBillVO;
import nc.vo.pub.VOStatus;
/**
* 标准单据弃审的BP
*/
public class AceHk_zulin_sdflrUnApproveBP {
public SdflrBillVO[] unApprove(SdflrBillVO[] clientBills,
SdflrBillVO[] originBills) {
for (SdflrBillVO clientBill : clientBills) {
clientBill.getParentVO().setStatus(VOStatus.UPDATED);
}
BillUpdate<SdflrBillVO> update = new BillUpdate<SdflrBillVO>();
SdflrBillVO[] returnVos = update.update(clientBills, originBills);
return returnVos;
}
}
| 623 | 0.730706 | 0.730706 | 21 | 27 | 23.892616 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.333333 | false | false | 8 |
75571d6bb4340c7b446a3fd8bf0f6c51f44ea10b | 22,960,895,218,662 | 34f08c92ab175f743ef203eca164c82bdf9ba064 | /src/main/java/com/shframework/common/interceptor/LoggingResponseInterceptor.java | 8611b5432c4e12db1de5d9376b034862d5a615c7 | [] | no_license | Gh0st0ne/shframework | https://github.com/Gh0st0ne/shframework | 1f756ba7bba25d6843dabd6d218700240592d701 | 02c393769b102643fd2cf81299ebe1f50bac26d9 | refs/heads/master | 2021-06-19T07:03:16.588000 | 2017-05-16T00:39:16 | 2017-05-16T00:39:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* @description
* @author Josh Yan
* @version 1.0
* @datetime 2014年9月1日 下午4:33:27
*/
package com.shframework.common.interceptor;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.shframework.common.base.BaseComponent;
import com.shframework.common.filter.RequestWrapper;
import com.shframework.common.util.Constants;
import com.shframework.common.util.StringUtils;
import com.shframework.modules.sys.entity.User;
import eu.bitwalker.useragentutils.UserAgent;
/**
* @author Josh
*
*/
public class LoggingResponseInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = LoggerFactory.getLogger(LoggingResponseInterceptor.class);
private AtomicLong id = new AtomicLong(1);
// before the actual handler will be executed
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
long startTime = System.currentTimeMillis();
request.setAttribute("startTime", startTime);
return true;
}
// after the handler is executed
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// if (logger.isInfoEnabled()) {
long requestId = id.incrementAndGet();
request = new RequestWrapper(requestId, request);
if (!StringUtils.containsAny(request.getRequestURI(), Constants.WEB_RES_TYPE)) {
logRequest(request, handler);
}
// }
}
private void logRequest(HttpServletRequest request, Object handler) {
long startTime = (Long) request.getAttribute("startTime");
long endTime = System.currentTimeMillis();
long executeTime = endTime - startTime;
StringBuilder msg = new StringBuilder();
if (request instanceof RequestWrapper) {
msg.append("[REQUEST ID=").append(((RequestWrapper) request).getId()).append("] ");
}
msg.append("[EXECUTE TIME=").append(executeTime).append("ms] ");
msg.append("[URI=").append(request.getRequestURI());
if (StringUtils.isNotBlank(request.getQueryString())) {
msg.append('?').append(request.getQueryString()).append("] ");
} else {
msg.append("] ");
}
if (handler instanceof HandlerMethod && ((HandlerMethod) handler).getBean() instanceof BaseComponent) {
User user = (User) request.getSession().getAttribute("curUser");
if (user != null) {
msg.append("[USER ID=").append(user.getId()).append("] ").append("[USER NAME=").append(user.getUsername()).append("] ");
} else {
msg.append("[USER ID=").append("] ").append("[USER NAME=").append("] ");
}
}
msg.append("[HTTP METHOD=").append(request.getMethod()).append("] ");
msg.append("[CONTENT TYPE=").append(request.getContentType()).append("] ");
msg.append("[REFERER=").append(request.getHeader("referer")).append("] ");
String ipAddress = request.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = request.getRemoteAddr();
}
msg.append("[IP=").append(ipAddress).append("] ");
HttpSession session = request.getSession(false);
if (session != null) {
msg.append("[SESSION ID=").append(session.getId()).append("] ");
}
UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
msg.append("[DEVICE=").append(userAgent.getOperatingSystem().getDeviceType()).append("] ");
msg.append("[USERAGENT=").append(userAgent).append("] ");
msg.append("[BROWSER VERSION=").append(userAgent.getBrowserVersion()).append("] ");
msg.append("[ENGINE=").append(userAgent.getBrowser().getRenderingEngine()).append("] ");
if (request instanceof RequestWrapper && !isMultipart(request)) {
RequestWrapper requestWrapper = (RequestWrapper) request;
try {
String charEncoding = requestWrapper.getCharacterEncoding() != null ? requestWrapper.getCharacterEncoding() : "UTF-8";
msg.append("[PAYLOAD=").append(new String(requestWrapper.toByteArray(), charEncoding)).append("] ");
} catch (UnsupportedEncodingException e) {
logger.warn("Failed to parse request payload", e);
}
}
logger.info(msg.toString());
}
private boolean isMultipart(HttpServletRequest request) {
return request.getContentType() != null && request.getContentType().startsWith("multipart/form-data");
}
}
| UTF-8 | Java | 4,660 | java | LoggingResponseInterceptor.java | Java | [
{
"context": "/**\n * @description \n * @author Josh Yan\n * @version 1.0\n * @datetime 2014年9月1日 下午4:33:27\n",
"end": 40,
"score": 0.9998613595962524,
"start": 32,
"tag": "NAME",
"value": "Josh Yan"
},
{
"context": "itwalker.useragentutils.UserAgent;\n\n/**\n * @author Josh\n *\n */\npublic class LoggingResponseInterceptor ex",
"end": 915,
"score": 0.999498724937439,
"start": 911,
"tag": "NAME",
"value": "Josh"
}
] | null | [] | /**
* @description
* @author <NAME>
* @version 1.0
* @datetime 2014年9月1日 下午4:33:27
*/
package com.shframework.common.interceptor;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.shframework.common.base.BaseComponent;
import com.shframework.common.filter.RequestWrapper;
import com.shframework.common.util.Constants;
import com.shframework.common.util.StringUtils;
import com.shframework.modules.sys.entity.User;
import eu.bitwalker.useragentutils.UserAgent;
/**
* @author Josh
*
*/
public class LoggingResponseInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = LoggerFactory.getLogger(LoggingResponseInterceptor.class);
private AtomicLong id = new AtomicLong(1);
// before the actual handler will be executed
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
long startTime = System.currentTimeMillis();
request.setAttribute("startTime", startTime);
return true;
}
// after the handler is executed
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// if (logger.isInfoEnabled()) {
long requestId = id.incrementAndGet();
request = new RequestWrapper(requestId, request);
if (!StringUtils.containsAny(request.getRequestURI(), Constants.WEB_RES_TYPE)) {
logRequest(request, handler);
}
// }
}
private void logRequest(HttpServletRequest request, Object handler) {
long startTime = (Long) request.getAttribute("startTime");
long endTime = System.currentTimeMillis();
long executeTime = endTime - startTime;
StringBuilder msg = new StringBuilder();
if (request instanceof RequestWrapper) {
msg.append("[REQUEST ID=").append(((RequestWrapper) request).getId()).append("] ");
}
msg.append("[EXECUTE TIME=").append(executeTime).append("ms] ");
msg.append("[URI=").append(request.getRequestURI());
if (StringUtils.isNotBlank(request.getQueryString())) {
msg.append('?').append(request.getQueryString()).append("] ");
} else {
msg.append("] ");
}
if (handler instanceof HandlerMethod && ((HandlerMethod) handler).getBean() instanceof BaseComponent) {
User user = (User) request.getSession().getAttribute("curUser");
if (user != null) {
msg.append("[USER ID=").append(user.getId()).append("] ").append("[USER NAME=").append(user.getUsername()).append("] ");
} else {
msg.append("[USER ID=").append("] ").append("[USER NAME=").append("] ");
}
}
msg.append("[HTTP METHOD=").append(request.getMethod()).append("] ");
msg.append("[CONTENT TYPE=").append(request.getContentType()).append("] ");
msg.append("[REFERER=").append(request.getHeader("referer")).append("] ");
String ipAddress = request.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = request.getRemoteAddr();
}
msg.append("[IP=").append(ipAddress).append("] ");
HttpSession session = request.getSession(false);
if (session != null) {
msg.append("[SESSION ID=").append(session.getId()).append("] ");
}
UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
msg.append("[DEVICE=").append(userAgent.getOperatingSystem().getDeviceType()).append("] ");
msg.append("[USERAGENT=").append(userAgent).append("] ");
msg.append("[BROWSER VERSION=").append(userAgent.getBrowserVersion()).append("] ");
msg.append("[ENGINE=").append(userAgent.getBrowser().getRenderingEngine()).append("] ");
if (request instanceof RequestWrapper && !isMultipart(request)) {
RequestWrapper requestWrapper = (RequestWrapper) request;
try {
String charEncoding = requestWrapper.getCharacterEncoding() != null ? requestWrapper.getCharacterEncoding() : "UTF-8";
msg.append("[PAYLOAD=").append(new String(requestWrapper.toByteArray(), charEncoding)).append("] ");
} catch (UnsupportedEncodingException e) {
logger.warn("Failed to parse request payload", e);
}
}
logger.info(msg.toString());
}
private boolean isMultipart(HttpServletRequest request) {
return request.getContentType() != null && request.getContentType().startsWith("multipart/form-data");
}
}
| 4,658 | 0.730753 | 0.727097 | 117 | 38.743591 | 33.79707 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.034188 | false | false | 8 |
c5a33fa1ff3f964653a908ba71f958b4498bc7c3 | 6,227,702,616,083 | 0293cbf0de0ec2ae9dd16e8c58fcec7732838757 | /AgentStandaloneEngine/dimes/AgentGuiComm/Event/MessageEvent.java | af8dc39492e0d8add0b2283a251868990774b6cd | [] | no_license | NetDimes/dimes-agent | https://github.com/NetDimes/dimes-agent | a9a48cc5221fd74a996264838985b979fa6ab677 | 1ae0f716e32fdac7e17c7c5ee03186682f60ab39 | refs/heads/master | 2020-09-12T14:34:46.333000 | 2014-08-28T12:47:08 | 2014-08-28T12:47:08 | 18,098,948 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dimes.AgentGuiComm.Event;
import java.util.EventObject;
//import dimes.connector.util.Message;
public class MessageEvent extends EventObject{
private static final long serialVersionUID = 1L;
private String msg;
private int messageType;
private int messageSubType;
private MessageEvent(Object source) {
super(source);
}
public MessageEvent(Object source, String message){
this(source);
msg=message;
}
public MessageEvent(Object source, String message, int type, int subType){
this(source);
msg=message;
messageType=type;
messageSubType=subType;
}
public String getMessage(){
return msg;
}
public int getType(){
return messageType;
}
public int getSubType(){
return messageSubType;
}
}
| UTF-8 | Java | 783 | java | MessageEvent.java | Java | [] | null | [] | package dimes.AgentGuiComm.Event;
import java.util.EventObject;
//import dimes.connector.util.Message;
public class MessageEvent extends EventObject{
private static final long serialVersionUID = 1L;
private String msg;
private int messageType;
private int messageSubType;
private MessageEvent(Object source) {
super(source);
}
public MessageEvent(Object source, String message){
this(source);
msg=message;
}
public MessageEvent(Object source, String message, int type, int subType){
this(source);
msg=message;
messageType=type;
messageSubType=subType;
}
public String getMessage(){
return msg;
}
public int getType(){
return messageType;
}
public int getSubType(){
return messageSubType;
}
}
| 783 | 0.703704 | 0.702427 | 40 | 17.575001 | 17.544069 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.575 | false | false | 8 |
7cd803d92eebb07b645ab2b2d8bde2511fad61ab | 17,162,689,350,322 | ea3bc75203db0aed7e535618aaaf456dbb1797fa | /src/main/java/com/client/xenon/tests/AccountToOpportunityFlow.java | 588d0eac645b8fb670db013efffe229898c89241 | [] | no_license | sachinboob-jade/selenium-integration | https://github.com/sachinboob-jade/selenium-integration | 50994c8fefcefd7ecdaf1c3f3944efe977ddb65c | e18daba5c02eb8533b09915122dc9d6fcdfc76ac | refs/heads/master | 2023-03-11T14:41:25.884000 | 2021-02-23T17:52:09 | 2021-02-23T17:52:09 | 343,787,278 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.client.xenon.tests;
import java.util.Random;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.client.xenon.operations.PageObjects;
import com.xenon.core.framework.Xenon;
import com.xenon.excel.xlsx.ReadExcel;
public class AccountToOpportunityFlow extends Xenon {
PageObjects sfdcObject = new PageObjects();
ReadExcel readExcel = new ReadExcel();
String quoteName="New Quote Nov 2019";
@BeforeSuite
public void setup() throws Exception{
sfdcObject.login("abhijeet.kulkarni@jadeglobal.com", "Abhijeet@123");
}
@Test(testName = "SFTC-1100", priority = 1, description = "Create campaign Salesforce")
public void createCampaign() throws Exception {
Random random = new Random();
int randomCampaignNumber = random.nextInt(150000);
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateCampaign");
String campaignName = data[0][0].toString();
String type = data[0][1].toString();
String status = data[0][2].toString();
String expectedRevenue = data[0][3].toString();
String budgetedCost = data[0][4].toString();
String actualRevenue = data[0][5].toString();
String expectedReturn = data[0][6].toString();
String randomCampaignName = campaignName + randomCampaignNumber + "";
sfdcObject.gotoCampaign();
sfdcObject.createCampaign(randomCampaignName, type, status, expectedRevenue, budgetedCost, actualRevenue,
expectedReturn);
}
@Test(testName = "SFTC-1101", priority = 2, description = "Create lead from campaign in Salesforce")
public void createLeadFromCampaign() throws Exception {
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateLeadFromCampaign");
String salutation = data[0][0].toString();
String firstname = data[0][1].toString();
String lastname = data[0][2].toString();
String email = data[0][3].toString();
String phone = data[0][4].toString();
String company = data[0][5].toString();
sfdcObject.createLeadFromCampaign(salutation, firstname, lastname, email, phone, company);
}
@Test(testName = "SFTC-1102", priority = 3, description = "Convert a lead to create account,contact,opportunity")
public void convertLeadtoOpportunity() throws Exception {
sfdcObject.convertLeadToOpportunity("John Smith");
}
@Test(testName = "SFTC-1103", priority = 4, description = "Verification check")
public void verificationCheck() throws Exception {
// sfdcObject.verificationCheck("LastNamen6r1lMgfo3Dch");
// sfdcObject.verificationCheck("LastNamen6r1lMgfo3Dch12");
// sfdcObject.logOutOfApplication(driver);
Random random = new Random();
int randomCampaignNumber = random.nextInt(150000);
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateCampaign");
String campaignName = data[0][0].toString();
String type = data[0][1].toString();
String status = data[0][2].toString();
String expectedRevenue = data[0][3].toString();
String budgetedCost = data[0][4].toString();
String actualRevenue = data[0][5].toString();
String expectedReturn = data[0][6].toString();
String randomCampaignName = campaignName + randomCampaignNumber + "";
sfdcObject.gotoCampaign();
sfdcObject.createCampaign("", type, status, expectedRevenue, budgetedCost, actualRevenue,
expectedReturn);
}
@AfterSuite
public void cleanup() {
// driver.quit();
}
}
| UTF-8 | Java | 3,465 | java | AccountToOpportunityFlow.java | Java | [
{
"context": "oid setup() throws Exception{\n\t\tsfdcObject.login(\"abhijeet.kulkarni@jadeglobal.com\", \"Abhijeet@123\");\n\t}\n\n\t@Test(testName = \"SFTC-11",
"end": 596,
"score": 0.9999020099639893,
"start": 564,
"tag": "EMAIL",
"value": "abhijeet.kulkarni@jadeglobal.com"
},
{
"context": "Object.login(\"abhijeet.kulkarni@jadeglobal.com\", \"Abhijeet@123\");\n\t}\n\n\t@Test(testName = \"SFTC-1100\", priority = ",
"end": 612,
"score": 0.9719852805137634,
"start": 600,
"tag": "PASSWORD",
"value": "Abhijeet@123"
},
{
"context": "xception {\n\t\tsfdcObject.convertLeadToOpportunity(\"John Smith\");\n\t}\n\t\n\t@Test(testName = \"SFTC-1103\", priority =",
"end": 2355,
"score": 0.999740481376648,
"start": 2345,
"tag": "NAME",
"value": "John Smith"
}
] | null | [] | package com.client.xenon.tests;
import java.util.Random;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.client.xenon.operations.PageObjects;
import com.xenon.core.framework.Xenon;
import com.xenon.excel.xlsx.ReadExcel;
public class AccountToOpportunityFlow extends Xenon {
PageObjects sfdcObject = new PageObjects();
ReadExcel readExcel = new ReadExcel();
String quoteName="New Quote Nov 2019";
@BeforeSuite
public void setup() throws Exception{
sfdcObject.login("<EMAIL>", "<PASSWORD>");
}
@Test(testName = "SFTC-1100", priority = 1, description = "Create campaign Salesforce")
public void createCampaign() throws Exception {
Random random = new Random();
int randomCampaignNumber = random.nextInt(150000);
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateCampaign");
String campaignName = data[0][0].toString();
String type = data[0][1].toString();
String status = data[0][2].toString();
String expectedRevenue = data[0][3].toString();
String budgetedCost = data[0][4].toString();
String actualRevenue = data[0][5].toString();
String expectedReturn = data[0][6].toString();
String randomCampaignName = campaignName + randomCampaignNumber + "";
sfdcObject.gotoCampaign();
sfdcObject.createCampaign(randomCampaignName, type, status, expectedRevenue, budgetedCost, actualRevenue,
expectedReturn);
}
@Test(testName = "SFTC-1101", priority = 2, description = "Create lead from campaign in Salesforce")
public void createLeadFromCampaign() throws Exception {
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateLeadFromCampaign");
String salutation = data[0][0].toString();
String firstname = data[0][1].toString();
String lastname = data[0][2].toString();
String email = data[0][3].toString();
String phone = data[0][4].toString();
String company = data[0][5].toString();
sfdcObject.createLeadFromCampaign(salutation, firstname, lastname, email, phone, company);
}
@Test(testName = "SFTC-1102", priority = 3, description = "Convert a lead to create account,contact,opportunity")
public void convertLeadtoOpportunity() throws Exception {
sfdcObject.convertLeadToOpportunity("<NAME>");
}
@Test(testName = "SFTC-1103", priority = 4, description = "Verification check")
public void verificationCheck() throws Exception {
// sfdcObject.verificationCheck("LastNamen6r1lMgfo3Dch");
// sfdcObject.verificationCheck("LastNamen6r1lMgfo3Dch12");
// sfdcObject.logOutOfApplication(driver);
Random random = new Random();
int randomCampaignNumber = random.nextInt(150000);
Object[][] data = readExcel.getExcelData("src/main/resources/Excel/SFDC_Data.xlsx", "CreateCampaign");
String campaignName = data[0][0].toString();
String type = data[0][1].toString();
String status = data[0][2].toString();
String expectedRevenue = data[0][3].toString();
String budgetedCost = data[0][4].toString();
String actualRevenue = data[0][5].toString();
String expectedReturn = data[0][6].toString();
String randomCampaignName = campaignName + randomCampaignNumber + "";
sfdcObject.gotoCampaign();
sfdcObject.createCampaign("", type, status, expectedRevenue, budgetedCost, actualRevenue,
expectedReturn);
}
@AfterSuite
public void cleanup() {
// driver.quit();
}
}
| 3,434 | 0.736508 | 0.7114 | 99 | 34 | 30.722939 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 8 |
ce349114cc89cc8e4ef64c5a623c4c498c51183e | 18,459,769,475,147 | 41dc05e3000db8421456fe9a6e0a746206b3ef7c | /web-study/android/helloworld/app/src/main/java/com/amandayi/helloworld/MainActivity.java | cc6fcfd5bd8d6952016493f1502d424b8046b3f7 | [] | no_license | AmandaYi/web-study | https://github.com/AmandaYi/web-study | 6049aae475cea0bb27ba3b6a2bac612759304cfe | 51ad6b88cf6e3a45d22e66bac9322f84123f653c | refs/heads/master | 2023-09-03T21:04:56.032000 | 2023-09-01T02:42:37 | 2023-09-01T02:42:37 | 166,373,240 | 0 | 0 | null | false | 2023-01-04T01:42:25 | 2019-01-18T08:45:06 | 2021-10-26T13:54:01 | 2023-01-04T01:42:24 | 223,430 | 0 | 0 | 127 | JavaScript | false | false | package com.amandayi.helloworld;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Button mBtn;
private Button mbtn2;
private Button push_et;
private Button push_radio_btn,push_checkbox,push_image_view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 找到xml里面的button
mBtn = findViewById(R.id.btn_1);
mBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,TextViewActivity.class);
startActivity(intent);
}
});
mbtn2 = findViewById(R.id.btn_5);
mbtn2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,ButtonActivity.class);
startActivity(intent);
}
});
// 点击进入登录页面
push_et=findViewById(R.id.push_et);
push_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入登录页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,EditTextActivity.class);
startActivity(i);
}
});
push_radio_btn = findViewById(R.id.push_radio_btn);
push_radio_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入单选页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,RadioButtonActivity.class);
startActivity(i);
}
});
push_checkbox = findViewById(R.id.push_radio_btn);
push_checkbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入单选页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,CheckBoxActivity.class);
startActivity(i);
}
});
push_image_view = findViewById(R.id.push_image_view);
push_image_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入图片页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,ImageViewActivity.class);
startActivity(i);
}
});
}
}
| UTF-8 | Java | 3,155 | java | MainActivity.java | Java | [] | null | [] | package com.amandayi.helloworld;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Button mBtn;
private Button mbtn2;
private Button push_et;
private Button push_radio_btn,push_checkbox,push_image_view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 找到xml里面的button
mBtn = findViewById(R.id.btn_1);
mBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,TextViewActivity.class);
startActivity(intent);
}
});
mbtn2 = findViewById(R.id.btn_5);
mbtn2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,ButtonActivity.class);
startActivity(intent);
}
});
// 点击进入登录页面
push_et=findViewById(R.id.push_et);
push_et.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入登录页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,EditTextActivity.class);
startActivity(i);
}
});
push_radio_btn = findViewById(R.id.push_radio_btn);
push_radio_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入单选页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,RadioButtonActivity.class);
startActivity(i);
}
});
push_checkbox = findViewById(R.id.push_radio_btn);
push_checkbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入单选页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,CheckBoxActivity.class);
startActivity(i);
}
});
push_image_view = findViewById(R.id.push_image_view);
push_image_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"进入图片页面",Toast.LENGTH_SHORT).show();
// 登录
Intent i = new Intent(MainActivity.this,ImageViewActivity.class);
startActivity(i);
}
});
}
}
| 3,155 | 0.594127 | 0.59217 | 93 | 31.956989 | 26.230539 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.623656 | false | false | 8 |
2d6fcb46c83d6de692abf21a1c1e9aa719787473 | 25,426,206,426,422 | 95461f9d3ae5c86ade7509aef25e4db3fed13331 | /src/main/java/prs/corejava/thread/TestUncaughtExceptionHandler.java | ed9b776696627847ce15b9f6972a6be8c20118f4 | [] | no_license | zhangbin11/TestSpring | https://github.com/zhangbin11/TestSpring | 27572ae9d3829454e1d9ddf92f8cf47061e1ccc0 | c6d4cc7ed8ff6a9cec9f5d33b33ddf18ddeb4715 | refs/heads/master | 2021-06-12T05:42:55.179000 | 2018-11-22T09:03:01 | 2018-11-22T09:03:01 | 96,009,344 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package prs.corejava.thread;
/**
* Created by zhangbin on 2017/7/5.
*/
public class TestUncaughtExceptionHandler implements Runnable {
@Override
public void run() {
int i = 12/0;
}
public static void main(String[] args) {
Thread t = new Thread(new TestUncaughtExceptionHandler());
t.setUncaughtExceptionHandler(new ThreadExceptionHandler());
t.start();
}
}
| UTF-8 | Java | 414 | java | TestUncaughtExceptionHandler.java | Java | [
{
"context": "package prs.corejava.thread;\n\n/**\n * Created by zhangbin on 2017/7/5.\n */\npublic class TestUncaughtExcepti",
"end": 56,
"score": 0.9992216229438782,
"start": 48,
"tag": "USERNAME",
"value": "zhangbin"
}
] | null | [] | package prs.corejava.thread;
/**
* Created by zhangbin on 2017/7/5.
*/
public class TestUncaughtExceptionHandler implements Runnable {
@Override
public void run() {
int i = 12/0;
}
public static void main(String[] args) {
Thread t = new Thread(new TestUncaughtExceptionHandler());
t.setUncaughtExceptionHandler(new ThreadExceptionHandler());
t.start();
}
}
| 414 | 0.652174 | 0.630435 | 17 | 23.352942 | 23.366495 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | false | false | 8 |
40253a5ba350c8e3848054b683fa585dbf8e99b8 | 14,285,061,269,796 | cc953f667e11f32d4119ac827d9378ed477b7706 | /backend-exts/product-ext/src/main/java/com/stosz/product/ext/model/CategoryUserRel.java | 022f5f4ee2647c37b391badeef9c8ea6e03a4c75 | [] | no_license | ttggaa/erp | https://github.com/ttggaa/erp | e20ed03ecf6965da95c9fc472d505ae8ef4f3902 | 167f5d60d085d016b08452083f172df654a7c5c5 | refs/heads/master | 2020-04-22T12:03:43.913000 | 2018-12-05T16:16:11 | 2018-12-05T16:16:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.stosz.product.ext.model;
import com.stosz.plat.enums.CategoryUserTypeEnum;
import com.stosz.plat.model.AbstractParamEntity;
import com.stosz.plat.model.DBColumn;
import com.stosz.plat.model.ITable;
public class CategoryUserRel extends AbstractParamEntity implements ITable {
@DBColumn
private Integer id;
@DBColumn
private Integer userId;
@DBColumn
private Integer categoryId;
private String userName;
private String categoryName;
@DBColumn
private CategoryUserTypeEnum userType;
@DBColumn
private String departmentNo;
private String departmentName;
private String userTypeName;
@DBColumn
private Boolean usable;
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getUserTypeName() {
userTypeName = (userType == null?"":userType.name());
return userTypeName;
}
public void setUserTypeName(String userTypeName) {
this.userTypeName = userTypeName;
}
public String getDepartmentNo() {
return departmentNo;
}
public void setDepartmentNo(String departmentNo) {
this.departmentNo = departmentNo;
}
public Boolean getUsable() {
return usable;
}
public void setUsable(Boolean usable) {
this.usable = usable;
}
// boolean值,交给前端去处理
// public String getStatusStr() {
// if(usable == 1){
// this.statusStr = "有效";
// }else{
// this.statusStr = "无效";
// }
// return statusStr;
// }
// public void setStatusStr(String statusStr) {
// this.statusStr = statusStr;
// }
public CategoryUserTypeEnum getUserType() {
return userType;
}
public void setUserType(CategoryUserTypeEnum userType) {
this.userType = userType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id=id;
}
@Override
public String getTable() {
return "category_user_rel";
}
} | UTF-8 | Java | 2,579 | java | CategoryUserRel.java | Java | [] | null | [] | package com.stosz.product.ext.model;
import com.stosz.plat.enums.CategoryUserTypeEnum;
import com.stosz.plat.model.AbstractParamEntity;
import com.stosz.plat.model.DBColumn;
import com.stosz.plat.model.ITable;
public class CategoryUserRel extends AbstractParamEntity implements ITable {
@DBColumn
private Integer id;
@DBColumn
private Integer userId;
@DBColumn
private Integer categoryId;
private String userName;
private String categoryName;
@DBColumn
private CategoryUserTypeEnum userType;
@DBColumn
private String departmentNo;
private String departmentName;
private String userTypeName;
@DBColumn
private Boolean usable;
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
}
public String getUserTypeName() {
userTypeName = (userType == null?"":userType.name());
return userTypeName;
}
public void setUserTypeName(String userTypeName) {
this.userTypeName = userTypeName;
}
public String getDepartmentNo() {
return departmentNo;
}
public void setDepartmentNo(String departmentNo) {
this.departmentNo = departmentNo;
}
public Boolean getUsable() {
return usable;
}
public void setUsable(Boolean usable) {
this.usable = usable;
}
// boolean值,交给前端去处理
// public String getStatusStr() {
// if(usable == 1){
// this.statusStr = "有效";
// }else{
// this.statusStr = "无效";
// }
// return statusStr;
// }
// public void setStatusStr(String statusStr) {
// this.statusStr = statusStr;
// }
public CategoryUserTypeEnum getUserType() {
return userType;
}
public void setUserType(CategoryUserTypeEnum userType) {
this.userType = userType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getCategoryId() {
return categoryId;
}
public void setCategoryId(Integer categoryId) {
this.categoryId = categoryId;
}
@Override
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id=id;
}
@Override
public String getTable() {
return "category_user_rel";
}
} | 2,579 | 0.705836 | 0.705445 | 136 | 17.779411 | 17.707464 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.007353 | false | false | 8 |
af55f001c7d0888f48c166170208b2a42ef99a64 | 26,439,818,724,686 | e9d0c81d26e30a4727cebabecded4ff69f3b0845 | /proxy/src/main/java/com/td/admin/entity/SysFtpClientConfig.java | 10ecc956e15a19fb1bb323bf4247db010a060978 | [
"Apache-2.0"
] | permissive | tyang513/enterprise.adapter | https://github.com/tyang513/enterprise.adapter | 429f1965483c8e571d2a65f767fa91f8cf19950a | a97b717a76b615a6cff5581d93fa217728211503 | refs/heads/master | 2022-10-01T23:01:52.904000 | 2022-09-23T03:35:15 | 2022-09-23T03:35:15 | 56,971,309 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.td.admin.entity;
import java.util.Date;
public class SysFtpClientConfig {
private Integer beginIndex;
private Integer numPerPage;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Long id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String clientname;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String rootpath;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String code;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Date mtime;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Date ctime;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.id
*
* @return the value of FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.id
*
* @param id the value for FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.clientName
*
* @return the value of FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getClientname() {
return clientname;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.clientName
*
* @param clientname the value for FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setClientname(String clientname) {
this.clientname = clientname;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.rootPath
*
* @return the value of FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getRootpath() {
return rootpath;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.rootPath
*
* @param rootpath the value for FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setRootpath(String rootpath) {
this.rootpath = rootpath;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.code
*
* @return the value of FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getCode() {
return code;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.code
*
* @param code the value for FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setCode(String code) {
this.code = code;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.MTime
*
* @return the value of FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Date getMtime() {
return mtime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.MTime
*
* @param mtime the value for FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setMtime(Date mtime) {
this.mtime = mtime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.CTime
*
* @return the value of FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Date getCtime() {
return ctime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.CTime
*
* @param ctime the value for FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setCtime(Date ctime) {
this.ctime = ctime;
}
public Integer getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(Integer beginIndex) {
this.beginIndex = beginIndex;
}
public Integer getNumPerPage() {
return numPerPage;
}
public void setNumPerPage(Integer numPerPage) {
this.numPerPage = numPerPage;
}
@Override
public String toString() {
return "FtpClientConfig [id=" + id + ", clientname=" + clientname + ", rootpath=" + rootpath + ", code=" + code + ", mtime=" + mtime
+ ", ctime=" + ctime + "]";
}
} | UTF-8 | Java | 6,131 | java | SysFtpClientConfig.java | Java | [] | null | [] | package com.td.admin.entity;
import java.util.Date;
public class SysFtpClientConfig {
private Integer beginIndex;
private Integer numPerPage;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Long id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String clientname;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String rootpath;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private String code;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Date mtime;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
private Date ctime;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.id
*
* @return the value of FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.id
*
* @param id the value for FtpClientConfig.id
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.clientName
*
* @return the value of FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getClientname() {
return clientname;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.clientName
*
* @param clientname the value for FtpClientConfig.clientName
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setClientname(String clientname) {
this.clientname = clientname;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.rootPath
*
* @return the value of FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getRootpath() {
return rootpath;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.rootPath
*
* @param rootpath the value for FtpClientConfig.rootPath
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setRootpath(String rootpath) {
this.rootpath = rootpath;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.code
*
* @return the value of FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public String getCode() {
return code;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.code
*
* @param code the value for FtpClientConfig.code
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setCode(String code) {
this.code = code;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.MTime
*
* @return the value of FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Date getMtime() {
return mtime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.MTime
*
* @param mtime the value for FtpClientConfig.MTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setMtime(Date mtime) {
this.mtime = mtime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column FtpClientConfig.CTime
*
* @return the value of FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public Date getCtime() {
return ctime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column FtpClientConfig.CTime
*
* @param ctime the value for FtpClientConfig.CTime
*
* @mbggenerated Thu Jun 20 17:32:28 CST 2013
*/
public void setCtime(Date ctime) {
this.ctime = ctime;
}
public Integer getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(Integer beginIndex) {
this.beginIndex = beginIndex;
}
public Integer getNumPerPage() {
return numPerPage;
}
public void setNumPerPage(Integer numPerPage) {
this.numPerPage = numPerPage;
}
@Override
public String toString() {
return "FtpClientConfig [id=" + id + ", clientname=" + clientname + ", rootpath=" + rootpath + ", code=" + code + ", mtime=" + mtime
+ ", ctime=" + ctime + "]";
}
} | 6,131 | 0.637253 | 0.602023 | 225 | 26.253334 | 25.900885 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.231111 | false | false | 8 |
48826e12fc8156262631d94686559d1fc9b55dc5 | 1,322,849,980,731 | e56319cce51579c5648c74d1d52443460374dd4a | /src/main/java/e2e/ClientUI.java | a4f926ca53e15f179b76a2ab26b616be339c2bfe | [] | no_license | mkm1899/e2e-email | https://github.com/mkm1899/e2e-email | 3c46c3d4fbb7026e93a32be0a389436920c609bf | db7105b81c66ca4dac0ac84b702e8086de6b5006 | refs/heads/master | 2022-12-17T17:09:13.509000 | 2020-09-19T01:22:17 | 2020-09-19T01:22:17 | 266,193,564 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package e2e;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Scanner;
public class ClientUI {
public final static int NUMBER_OF_MAIN_MENU_OPTIONS = 2;
private final static int NUM_MSG_CREAT_OPTS = 5; //the Number of message creation options in the menu below
private Client client;
private String emailAddress = null;
public static void clearSystemInput(){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
sc.next();
}
sc.close();
}
public ClientUI(Client client, String emailAddress){
this.client = client;
this.emailAddress = emailAddress;
//clearSystemInput();
}
public static void printMainMenu(){
System.out.println("Enter the number for the action you want to do");
System.out.println("\t1: send email");
System.out.println("\t2: check emails");
}
public static int menuSelection(Scanner sc, int maxValue){
int optionPicked = Integer.MIN_VALUE;
// makes sure the user only inputs a valid number
do{
if(optionPicked != Integer.MIN_VALUE){
System.out.println("Please enter a number between 1 - " + maxValue);
}
//makes sure the user only inputed an integer value;
while(sc.hasNext() && !sc.hasNextInt()){
System.out.println("Please only enter a number between 1 - " + maxValue);
//if(optionPicked != Integer.MIN_VALUE){
sc.next();
//}
}
optionPicked = sc.nextInt();
} while(!(optionPicked <= maxValue && optionPicked > 0));
return optionPicked;
}
public void MainMenuFunctionality(){
Scanner sc = new Scanner(System.in);
printMainMenu();
int optionPicked = menuSelection(sc, NUMBER_OF_MAIN_MENU_OPTIONS);
switch(optionPicked){
case 1:
sendMessageFunctionality(sc);
break;
case 2:
//@TODO
break;
default :
sc.close();
System.err.append("\nGot number "+ optionPicked +" that was not yet accounted for\n");
System.exit(1);
}
sc.close();
}
public static void printMessageCreationMenu(Email email){
System.out.println("Enter the number for the action you want to do");
System.out.println("\t1: To: " + email.getTo());
System.out.println("\t2: Subject: " + email.getSubject());
System.out.println("\t3: Message: " + email.getMessage());
System.out.println("\t4: Send");
System.out.println("\t5: Discard");
}
private void sendMessageFunctionality(Scanner sc){
Email email = new Email("", emailAddress, "", "");
boolean bool = true; //is false when the user sends or discard
do{
printMessageCreationMenu(email);
int option_selected = menuSelection(sc, NUM_MSG_CREAT_OPTS);
switch(option_selected) {
case 1:
System.out.println("Please write the email address of the person you want to email");
sc.nextLine();
email.setTo(sc.nextLine());
break;
case 2:
System.out.println("Please write the subject of the email");
sc.nextLine();
email.setSubject(sc.nextLine());
break;
case 3:
System.out.println("Please write the message of the email");
sc.nextLine();
email.setMessage(GetMultipleLinesFromUser(sc));
break;
case 4:
if(email.getTo() == null || email.getTo().equals("")){
System.out.println("You did not specify who you want to send to");
break;
}
client.sendEmail(email);
bool = false;
break;
case 5:
System.out.println("Email discarded");
bool = false;
break;
default:
System.out.println("Client Input Incorrect");
}
}while(bool);
}
private String GetMultipleLinesFromUser(Scanner sc, String delimeter){
String message = "";
while(true){
message += sc.nextLine() + "\n";
if(message.length() >= delimeter.length() && message.substring(message.length() - delimeter.length()).equals(delimeter)){
break;
}
}
message = message.substring(0,message.length() - delimeter.length());
return message;
}
private String GetMultipleLinesFromUser(Scanner sc){
return GetMultipleLinesFromUser(sc, "\n\n\n\n");
}
} | UTF-8 | Java | 5,020 | java | ClientUI.java | Java | [] | null | [] | package e2e;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Scanner;
public class ClientUI {
public final static int NUMBER_OF_MAIN_MENU_OPTIONS = 2;
private final static int NUM_MSG_CREAT_OPTS = 5; //the Number of message creation options in the menu below
private Client client;
private String emailAddress = null;
public static void clearSystemInput(){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
sc.next();
}
sc.close();
}
public ClientUI(Client client, String emailAddress){
this.client = client;
this.emailAddress = emailAddress;
//clearSystemInput();
}
public static void printMainMenu(){
System.out.println("Enter the number for the action you want to do");
System.out.println("\t1: send email");
System.out.println("\t2: check emails");
}
public static int menuSelection(Scanner sc, int maxValue){
int optionPicked = Integer.MIN_VALUE;
// makes sure the user only inputs a valid number
do{
if(optionPicked != Integer.MIN_VALUE){
System.out.println("Please enter a number between 1 - " + maxValue);
}
//makes sure the user only inputed an integer value;
while(sc.hasNext() && !sc.hasNextInt()){
System.out.println("Please only enter a number between 1 - " + maxValue);
//if(optionPicked != Integer.MIN_VALUE){
sc.next();
//}
}
optionPicked = sc.nextInt();
} while(!(optionPicked <= maxValue && optionPicked > 0));
return optionPicked;
}
public void MainMenuFunctionality(){
Scanner sc = new Scanner(System.in);
printMainMenu();
int optionPicked = menuSelection(sc, NUMBER_OF_MAIN_MENU_OPTIONS);
switch(optionPicked){
case 1:
sendMessageFunctionality(sc);
break;
case 2:
//@TODO
break;
default :
sc.close();
System.err.append("\nGot number "+ optionPicked +" that was not yet accounted for\n");
System.exit(1);
}
sc.close();
}
public static void printMessageCreationMenu(Email email){
System.out.println("Enter the number for the action you want to do");
System.out.println("\t1: To: " + email.getTo());
System.out.println("\t2: Subject: " + email.getSubject());
System.out.println("\t3: Message: " + email.getMessage());
System.out.println("\t4: Send");
System.out.println("\t5: Discard");
}
private void sendMessageFunctionality(Scanner sc){
Email email = new Email("", emailAddress, "", "");
boolean bool = true; //is false when the user sends or discard
do{
printMessageCreationMenu(email);
int option_selected = menuSelection(sc, NUM_MSG_CREAT_OPTS);
switch(option_selected) {
case 1:
System.out.println("Please write the email address of the person you want to email");
sc.nextLine();
email.setTo(sc.nextLine());
break;
case 2:
System.out.println("Please write the subject of the email");
sc.nextLine();
email.setSubject(sc.nextLine());
break;
case 3:
System.out.println("Please write the message of the email");
sc.nextLine();
email.setMessage(GetMultipleLinesFromUser(sc));
break;
case 4:
if(email.getTo() == null || email.getTo().equals("")){
System.out.println("You did not specify who you want to send to");
break;
}
client.sendEmail(email);
bool = false;
break;
case 5:
System.out.println("Email discarded");
bool = false;
break;
default:
System.out.println("Client Input Incorrect");
}
}while(bool);
}
private String GetMultipleLinesFromUser(Scanner sc, String delimeter){
String message = "";
while(true){
message += sc.nextLine() + "\n";
if(message.length() >= delimeter.length() && message.substring(message.length() - delimeter.length()).equals(delimeter)){
break;
}
}
message = message.substring(0,message.length() - delimeter.length());
return message;
}
private String GetMultipleLinesFromUser(Scanner sc){
return GetMultipleLinesFromUser(sc, "\n\n\n\n");
}
} | 5,020 | 0.534861 | 0.530478 | 144 | 33.868057 | 27.129383 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.652778 | false | false | 8 |
0613dd704d158f33656549e0bb938ae9fd94ec37 | 10,479,720,240,347 | 34db30cd9190a98f79ede8da84145e5c8de25e8c | /src/ClientHandler.java | 0a3e87bddc1cf234997bb6cf2dab76e684d2aea4 | [] | no_license | xiaogangy/Socket1 | https://github.com/xiaogangy/Socket1 | 5b5f785e690ede9f032dc066773b700a50c49113 | e8b97b37041d3f068407d97292ff46ed92a17192 | refs/heads/master | 2021-01-20T01:14:39.269000 | 2017-04-24T13:54:55 | 2017-04-24T13:54:55 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
//import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import org.apache.commons.cli.CommandLine;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class ClientHandler implements Runnable {
public int clientnum;
public boolean debugmode = true;
public String secret;
public String hostname;
public Socket connectionSock;
public DataInputStream clientInput;
public DataOutputStream clientOutput;
public static ServerResourceList resourcelist;
public ArrayList<String> serverrecordslist;
public CommandParse commandparse;
public ClientHandler(ServerResourceList resourcelist, Socket connectionSock, String hostname,
int clientnum, String secret, ArrayList<String> serverrecordslist, boolean debug){
ClientHandler.resourcelist = resourcelist;
this.serverrecordslist = serverrecordslist;
this.connectionSock = connectionSock;
this.clientnum = clientnum;
debugmode = debug;
this.secret = secret;
this.hostname = hostname;
System.out.println("Client " + clientnum + " connected to the server");
commandparse = new CommandParse(secret,connectionSock,hostname,resourcelist,serverrecordslist);
}
public void run(){
try {
//clientOutput.close();
//clientInput.close();
//connectionSock.close();
clientOutput = new DataOutputStream(connectionSock.getOutputStream());
clientInput = new DataInputStream(connectionSock.getInputStream());
/*String fileName = clientInput.readUTF();
System.out.println(fileName);
long fileLength = clientInput.readLong();
System.out.println(fileLength);
File f = new File("F:/eclipse-workspace/Socket1/src/temp/" );
if(!f.exists()){
f.mkdir();
}
String filepath = "F:/eclipse-workspace/Socket1/src/temp/" + fileName;
FileOutputStream fs = new FileOutputStream(new File(filepath));
byte[] inputByte = new byte[1024];
double suml = 0;
int length = 0;
while ((length = clientInput.read(inputByte)) > 0){
double left = fileLength - suml;
if(left < 1024){
System.out.println("Already received: 100%");
fs.write(inputByte, 0, (int) left);
fs.flush();
break;
}else{
suml += length;
System.out.println("Already received:" + ((suml/fileLength)*100)+"%");
fs.write(inputByte, 0, length);
fs.flush();
}
}
JSONObject json = new JSONObject();
json.put("feedback", "Transfer complete");
System.out.println("Transfer complete");
clientOutput.writeUTF(json.toJSONString());
String temp = clientInput.readUTF();
Object obj = JSONValue.parse(temp);
JSONObject jsonObject = (JSONObject)obj;
String confirm = (String)jsonObject.get("command");
System.out.println(confirm);
fs.close();*/
JSONParser parser = new JSONParser();
while(true){
//if(clientInput.available() > 0){
// Attempt to convert read data to JSON
JSONObject command = (JSONObject) parser.parse(clientInput.readUTF());
if(debugmode){
System.out.println("COMMAND RECEIVED: "+command.toJSONString());
}
clientOutput.writeUTF(parseCommand(command).toString());
System.out.println("hhhhhh");
/*Integer result = parseCommand(command);
JSONObject results = new JSONObject();
results.put("result", result);
output.writeUTF(results.toJSONString());*/
//}
}
} catch (IOException | ParseException | URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public ArrayList<JSONObject> parseCommand(JSONObject command)
throws ParseException, URISyntaxException{
ArrayList<JSONObject> res = new ArrayList<JSONObject>();
switch((String) command.get("command")){
case "publish":
res.add(commandparse.ParsePUBLISHSHARE(command));
return res;
case "share":
res.add(commandparse.ParsePUBLISHSHARE(command));
return res;
case "fetch":
break;
case "query":
res = commandparse.ParseQUERY(command);
return res;
case "remove":
res.add(commandparse.ParseREMOVE(command));
return res;
case "exchange":
break;
default:
try {
throw new Exception();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return res;
}
/*private static JSONObject ParsePUBLISHSHARE(JSONObject command, ServerResourceList resourcelist)
throws ParseException,URISyntaxException{
JSONObject tempobject;
JSONObject jsonobject = new JSONObject();
Resource temp = new Resource();
if(command.get("resource") != null && (tempobject = StoreResourceInfo(command, temp)) != null){
return tempobject;
}else if(command.get("resource") == null){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing field");
return jsonobject;
}else{
if((command.get("command").equals("publish") && resourcelist.PublishResource(temp))
||(command.get("command").equals("share") && resourcelist.ShareResource(temp))){
jsonobject.put("response", "success");
return jsonobject;
}else{
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "cannot " + command.get("command") + " resource");
return jsonobject;
}
}
}
private static ArrayList<JSONObject> ParseQUERY(JSONObject command, ServerResourceList resourcelist) {
ArrayList<JSONObject> jsonlist = new ArrayList<JSONObject>();
ArrayList<Resource> resourcefound = new ArrayList<Resource>();
JSONObject jsontemp = new JSONObject();
Resource temp_1 = new Resource();
StoreResourceInfo(command, temp_1);
if(command.get("relay").equals("false")){
resourcefound = resourcelist.queryResource(temp_1, false);
}
if(!resourcefound.isEmpty()){
jsontemp.put("response", "success");
jsonlist.add(jsontemp);
jsontemp.clear();
for(Resource temp_2 : resourcefound){
jsontemp.put("name", temp_2.resource_name);
jsontemp.put("tags", temp_2.resource_tags);
jsontemp.put("description", temp_2.resource_description);
jsontemp.put("uri", temp_2.resource_uri);
jsontemp.put("channel", temp_2.channel);
jsontemp.put("owner", temp_2.owner);
jsontemp.put("ezserver", temp_2.ezserver);
jsonlist.add(jsontemp);
jsontemp.clear();
}
jsontemp.put("responseSize", jsonlist.size());
jsonlist.add(jsontemp);
}
return jsonlist;
}
private static JSONObject ParseREMOVE(JSONObject command,ServerResourceList resourcelist){
JSONObject jsonobject = new JSONObject();
Resource temp = new Resource();
JSONObject subcommand = (JSONObject) command.get("resource");
if(subcommand.get("channel") == null || subcommand.get("owner") == null
||subcommand.get("uri") == null){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing resource");
return jsonobject;
}
temp.resource_name = (subcommand.get("name") != null) ? ((String)subcommand.get("name")).trim() : "";
temp.resource_description = (subcommand.get("description") != null) ?
((String)subcommand.get("description")).trim() : "";
temp.resource_tags = (subcommand.get("tags") != null) ? subcommand.get("tags").toString().trim() : "";
temp.ezserver = (subcommand.get("ezserver") != null) ? ((String)subcommand.get("ezserver")).trim() : null;
if(resourcelist.RemoveResource(temp)){
jsonobject.put("response", "success");
return jsonobject;
}else{
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "cannot remove resource");
return jsonobject;
}
}
private static JSONObject StoreResourceInfo(JSONObject command,Resource resource){
JSONObject jsonobject = new JSONObject();
Resource temp = resource;
JSONObject subcommand = (JSONObject) command.get("resource");
temp.resource_name = (subcommand.get("name") != null) ? ((String)subcommand.get("name")).trim() : "";
temp.resource_description = (subcommand.get("description") != null) ?
((String)subcommand.get("description")).trim() : "";
temp.resource_tags = (subcommand.get("tags") != null) ? subcommand.get("tags").toString().trim() : "";
temp.channel = (subcommand.get("channel") != null) ? ((String)subcommand.get("channel")).trim() : "";
temp.owner = (subcommand.get("owner") != null) ? ((String)subcommand.get("owner")).trim() : "";
temp.ezserver = hostname +" : " + connectionSock.getPort();
if(command.get("command").equals("share") && !command.get("secret").equals(secret)){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "incorrect secret");
return jsonobject;
}
if(subcommand.get("uri") == null && !command.get("command").equals("query")){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing resource");
return jsonobject;
}else if(command.get("command").equals("query")){
temp.resource_uri = (subcommand.get("uri") != null) ? (String) subcommand.get("uri") : "";
}else{
try {
URI uri = new URI((String) subcommand.get("uri"));
File f = new File("F:" + uri.getPath());
if((uri.getScheme().equals("file") && ((String)command.get("command")).equals("publish"))
||(!uri.getScheme().equals("file") && ((String)command.get("command")).equals("share"))
||(((String)command.get("command")).equals("share") && (!f.isAbsolute() || uri.getAuthority() != null))){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "invaild resource");
return jsonobject;
}
temp.resource_uri = (String) subcommand.get("uri");
} catch (URISyntaxException e) {
System.out.println("URIEXCEption");
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "invaild resource");
return jsonobject;
}
}
return null;
}*/
}
| UTF-8 | Java | 10,266 | java | ClientHandler.java | Java | [] | null | [] | import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
//import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import org.apache.commons.cli.CommandLine;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class ClientHandler implements Runnable {
public int clientnum;
public boolean debugmode = true;
public String secret;
public String hostname;
public Socket connectionSock;
public DataInputStream clientInput;
public DataOutputStream clientOutput;
public static ServerResourceList resourcelist;
public ArrayList<String> serverrecordslist;
public CommandParse commandparse;
public ClientHandler(ServerResourceList resourcelist, Socket connectionSock, String hostname,
int clientnum, String secret, ArrayList<String> serverrecordslist, boolean debug){
ClientHandler.resourcelist = resourcelist;
this.serverrecordslist = serverrecordslist;
this.connectionSock = connectionSock;
this.clientnum = clientnum;
debugmode = debug;
this.secret = secret;
this.hostname = hostname;
System.out.println("Client " + clientnum + " connected to the server");
commandparse = new CommandParse(secret,connectionSock,hostname,resourcelist,serverrecordslist);
}
public void run(){
try {
//clientOutput.close();
//clientInput.close();
//connectionSock.close();
clientOutput = new DataOutputStream(connectionSock.getOutputStream());
clientInput = new DataInputStream(connectionSock.getInputStream());
/*String fileName = clientInput.readUTF();
System.out.println(fileName);
long fileLength = clientInput.readLong();
System.out.println(fileLength);
File f = new File("F:/eclipse-workspace/Socket1/src/temp/" );
if(!f.exists()){
f.mkdir();
}
String filepath = "F:/eclipse-workspace/Socket1/src/temp/" + fileName;
FileOutputStream fs = new FileOutputStream(new File(filepath));
byte[] inputByte = new byte[1024];
double suml = 0;
int length = 0;
while ((length = clientInput.read(inputByte)) > 0){
double left = fileLength - suml;
if(left < 1024){
System.out.println("Already received: 100%");
fs.write(inputByte, 0, (int) left);
fs.flush();
break;
}else{
suml += length;
System.out.println("Already received:" + ((suml/fileLength)*100)+"%");
fs.write(inputByte, 0, length);
fs.flush();
}
}
JSONObject json = new JSONObject();
json.put("feedback", "Transfer complete");
System.out.println("Transfer complete");
clientOutput.writeUTF(json.toJSONString());
String temp = clientInput.readUTF();
Object obj = JSONValue.parse(temp);
JSONObject jsonObject = (JSONObject)obj;
String confirm = (String)jsonObject.get("command");
System.out.println(confirm);
fs.close();*/
JSONParser parser = new JSONParser();
while(true){
//if(clientInput.available() > 0){
// Attempt to convert read data to JSON
JSONObject command = (JSONObject) parser.parse(clientInput.readUTF());
if(debugmode){
System.out.println("COMMAND RECEIVED: "+command.toJSONString());
}
clientOutput.writeUTF(parseCommand(command).toString());
System.out.println("hhhhhh");
/*Integer result = parseCommand(command);
JSONObject results = new JSONObject();
results.put("result", result);
output.writeUTF(results.toJSONString());*/
//}
}
} catch (IOException | ParseException | URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public ArrayList<JSONObject> parseCommand(JSONObject command)
throws ParseException, URISyntaxException{
ArrayList<JSONObject> res = new ArrayList<JSONObject>();
switch((String) command.get("command")){
case "publish":
res.add(commandparse.ParsePUBLISHSHARE(command));
return res;
case "share":
res.add(commandparse.ParsePUBLISHSHARE(command));
return res;
case "fetch":
break;
case "query":
res = commandparse.ParseQUERY(command);
return res;
case "remove":
res.add(commandparse.ParseREMOVE(command));
return res;
case "exchange":
break;
default:
try {
throw new Exception();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return res;
}
/*private static JSONObject ParsePUBLISHSHARE(JSONObject command, ServerResourceList resourcelist)
throws ParseException,URISyntaxException{
JSONObject tempobject;
JSONObject jsonobject = new JSONObject();
Resource temp = new Resource();
if(command.get("resource") != null && (tempobject = StoreResourceInfo(command, temp)) != null){
return tempobject;
}else if(command.get("resource") == null){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing field");
return jsonobject;
}else{
if((command.get("command").equals("publish") && resourcelist.PublishResource(temp))
||(command.get("command").equals("share") && resourcelist.ShareResource(temp))){
jsonobject.put("response", "success");
return jsonobject;
}else{
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "cannot " + command.get("command") + " resource");
return jsonobject;
}
}
}
private static ArrayList<JSONObject> ParseQUERY(JSONObject command, ServerResourceList resourcelist) {
ArrayList<JSONObject> jsonlist = new ArrayList<JSONObject>();
ArrayList<Resource> resourcefound = new ArrayList<Resource>();
JSONObject jsontemp = new JSONObject();
Resource temp_1 = new Resource();
StoreResourceInfo(command, temp_1);
if(command.get("relay").equals("false")){
resourcefound = resourcelist.queryResource(temp_1, false);
}
if(!resourcefound.isEmpty()){
jsontemp.put("response", "success");
jsonlist.add(jsontemp);
jsontemp.clear();
for(Resource temp_2 : resourcefound){
jsontemp.put("name", temp_2.resource_name);
jsontemp.put("tags", temp_2.resource_tags);
jsontemp.put("description", temp_2.resource_description);
jsontemp.put("uri", temp_2.resource_uri);
jsontemp.put("channel", temp_2.channel);
jsontemp.put("owner", temp_2.owner);
jsontemp.put("ezserver", temp_2.ezserver);
jsonlist.add(jsontemp);
jsontemp.clear();
}
jsontemp.put("responseSize", jsonlist.size());
jsonlist.add(jsontemp);
}
return jsonlist;
}
private static JSONObject ParseREMOVE(JSONObject command,ServerResourceList resourcelist){
JSONObject jsonobject = new JSONObject();
Resource temp = new Resource();
JSONObject subcommand = (JSONObject) command.get("resource");
if(subcommand.get("channel") == null || subcommand.get("owner") == null
||subcommand.get("uri") == null){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing resource");
return jsonobject;
}
temp.resource_name = (subcommand.get("name") != null) ? ((String)subcommand.get("name")).trim() : "";
temp.resource_description = (subcommand.get("description") != null) ?
((String)subcommand.get("description")).trim() : "";
temp.resource_tags = (subcommand.get("tags") != null) ? subcommand.get("tags").toString().trim() : "";
temp.ezserver = (subcommand.get("ezserver") != null) ? ((String)subcommand.get("ezserver")).trim() : null;
if(resourcelist.RemoveResource(temp)){
jsonobject.put("response", "success");
return jsonobject;
}else{
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "cannot remove resource");
return jsonobject;
}
}
private static JSONObject StoreResourceInfo(JSONObject command,Resource resource){
JSONObject jsonobject = new JSONObject();
Resource temp = resource;
JSONObject subcommand = (JSONObject) command.get("resource");
temp.resource_name = (subcommand.get("name") != null) ? ((String)subcommand.get("name")).trim() : "";
temp.resource_description = (subcommand.get("description") != null) ?
((String)subcommand.get("description")).trim() : "";
temp.resource_tags = (subcommand.get("tags") != null) ? subcommand.get("tags").toString().trim() : "";
temp.channel = (subcommand.get("channel") != null) ? ((String)subcommand.get("channel")).trim() : "";
temp.owner = (subcommand.get("owner") != null) ? ((String)subcommand.get("owner")).trim() : "";
temp.ezserver = hostname +" : " + connectionSock.getPort();
if(command.get("command").equals("share") && !command.get("secret").equals(secret)){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "incorrect secret");
return jsonobject;
}
if(subcommand.get("uri") == null && !command.get("command").equals("query")){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "missing resource");
return jsonobject;
}else if(command.get("command").equals("query")){
temp.resource_uri = (subcommand.get("uri") != null) ? (String) subcommand.get("uri") : "";
}else{
try {
URI uri = new URI((String) subcommand.get("uri"));
File f = new File("F:" + uri.getPath());
if((uri.getScheme().equals("file") && ((String)command.get("command")).equals("publish"))
||(!uri.getScheme().equals("file") && ((String)command.get("command")).equals("share"))
||(((String)command.get("command")).equals("share") && (!f.isAbsolute() || uri.getAuthority() != null))){
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "invaild resource");
return jsonobject;
}
temp.resource_uri = (String) subcommand.get("uri");
} catch (URISyntaxException e) {
System.out.println("URIEXCEption");
jsonobject.put("response", "error");
jsonobject.put("errorMessage", "invaild resource");
return jsonobject;
}
}
return null;
}*/
}
| 10,266 | 0.672803 | 0.669589 | 315 | 31.584127 | 27.369577 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.422222 | false | false | 8 |
7e90bf28044c2eed4ce19b302974794ce6dd388c | 10,479,720,242,507 | 33fe6e2a113d18a063f68a0be83d74a98a15ff99 | /src/com/jetbrains/ther/typing/types/TheRUnionType.java | 82ec39fc5c02ae3f43c738626c2f35f5aa4a82a5 | [
"MIT"
] | permissive | Avila-Diego/TheRPlugin | https://github.com/Avila-Diego/TheRPlugin | 848240d35689006ab8496f274157683b3415ea44 | be2593c26dee8f6287d5ec0a82aebbca9c74f657 | refs/heads/master | 2023-03-19T19:59:18.881000 | 2016-07-05T13:08:10 | 2016-07-05T13:08:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jetbrains.ther.typing.types;
import com.jetbrains.ther.psi.api.TheRExpression;
import com.jetbrains.ther.typing.TheRTypeProvider;
import java.util.*;
public class TheRUnionType extends TheRType {
private Set<TheRType> myTypes;
public Set<TheRType> getTypes() {
return myTypes;
}
@Override
public String getCanonicalName() {
return "union";
}
private TheRUnionType(Set<TheRType> types) {
myTypes = types;
}
public static TheRType create(Set<TheRType> types) {
if (types.isEmpty()) {
return TheRUnknownType.INSTANCE;
}
unpackUnions(types );
types = mergeSimilar(types);
if (types.size() == 1) {
return types.iterator().next();
}
return new TheRUnionType(types);
}
private static Set<TheRType> mergeSimilar(Set<TheRType> types) {
List<TheRType> typeList = new ArrayList<TheRType>(types);
Map<TheRType, TheRType> parentTypes = new HashMap<TheRType, TheRType>(types.size());
//initially each type is itself parent
for (TheRType type : types) {
parentTypes.put(type, type);
}
//merge like simple DSU
for (int i = 0; i < typeList.size(); i++) {
TheRType curType = typeList.get(i);
for (int j = i + 1; j < typeList.size(); j++) {
TheRType type = typeList.get(j);
mergeTypes(parentTypes, curType, type);
}
}
return new HashSet<TheRType>(parentTypes.values());
}
private static void mergeTypes(Map<TheRType, TheRType> parentTypes, TheRType curType, TheRType type) {
TheRType curTypeParent = parentTypes.get(curType);
TheRType typeParent = parentTypes.get(type);
if (TheRTypeProvider.isSubtype(curTypeParent, typeParent)) {
parentTypes.put(curType, typeParent);
return;
}
if (TheRTypeProvider.isSubtype(typeParent, curTypeParent)) {
parentTypes.put(type, curTypeParent);
}
}
private static void unpackUnions(Set<TheRType> types) {
Set<TheRType> savedTypes = new HashSet<TheRType>(types);
types.clear();
for (TheRType type : savedTypes) {
if (type instanceof TheRUnionType) {
types.addAll(((TheRUnionType)type).myTypes);
} else {
types.add(type);
}
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof TheRUnionType)) {
return super.equals(o);
}
TheRUnionType type = (TheRUnionType)o;
if (type.myTypes.size() != myTypes.size()) {
return false;
}
for (TheRType t : myTypes) {
if (!type.myTypes.contains(t)) {
return false;
}
}
return true;
}
public boolean contains(TheRType type) {
return myTypes.contains(type);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
for (TheRType type : myTypes) {
builder.append(type.toString()).append("|");
}
builder.deleteCharAt(builder.length() - 1);
return builder.toString();
}
@Override
public TheRType getSubscriptionType(List<TheRExpression> expressions, boolean isSingleBracket) {
HashSet<TheRType> subscriptTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
subscriptTypes.add(type.getSubscriptionType(expressions, isSingleBracket));
}
return TheRUnionType.create(subscriptTypes);
}
@Override
public TheRType afterSubscriptionType(List<TheRExpression> arguments, TheRType valueType, boolean isSingle) {
HashSet<TheRType> afterTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
afterTypes.add(type.afterSubscriptionType(arguments, valueType, isSingle));
}
return TheRUnionType.create(afterTypes);
}
@Override
public TheRType getElementTypes() {
HashSet<TheRType> elementTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
elementTypes.add(type.getElementTypes());
}
return TheRUnionType.create(elementTypes);
}
@Override
public TheRUnionType clone() {
TheRUnionType result = (TheRUnionType)super.clone();
result.myTypes = new HashSet<TheRType>(myTypes);
return result;
}
}
| UTF-8 | Java | 4,091 | java | TheRUnionType.java | Java | [] | null | [] | package com.jetbrains.ther.typing.types;
import com.jetbrains.ther.psi.api.TheRExpression;
import com.jetbrains.ther.typing.TheRTypeProvider;
import java.util.*;
public class TheRUnionType extends TheRType {
private Set<TheRType> myTypes;
public Set<TheRType> getTypes() {
return myTypes;
}
@Override
public String getCanonicalName() {
return "union";
}
private TheRUnionType(Set<TheRType> types) {
myTypes = types;
}
public static TheRType create(Set<TheRType> types) {
if (types.isEmpty()) {
return TheRUnknownType.INSTANCE;
}
unpackUnions(types );
types = mergeSimilar(types);
if (types.size() == 1) {
return types.iterator().next();
}
return new TheRUnionType(types);
}
private static Set<TheRType> mergeSimilar(Set<TheRType> types) {
List<TheRType> typeList = new ArrayList<TheRType>(types);
Map<TheRType, TheRType> parentTypes = new HashMap<TheRType, TheRType>(types.size());
//initially each type is itself parent
for (TheRType type : types) {
parentTypes.put(type, type);
}
//merge like simple DSU
for (int i = 0; i < typeList.size(); i++) {
TheRType curType = typeList.get(i);
for (int j = i + 1; j < typeList.size(); j++) {
TheRType type = typeList.get(j);
mergeTypes(parentTypes, curType, type);
}
}
return new HashSet<TheRType>(parentTypes.values());
}
private static void mergeTypes(Map<TheRType, TheRType> parentTypes, TheRType curType, TheRType type) {
TheRType curTypeParent = parentTypes.get(curType);
TheRType typeParent = parentTypes.get(type);
if (TheRTypeProvider.isSubtype(curTypeParent, typeParent)) {
parentTypes.put(curType, typeParent);
return;
}
if (TheRTypeProvider.isSubtype(typeParent, curTypeParent)) {
parentTypes.put(type, curTypeParent);
}
}
private static void unpackUnions(Set<TheRType> types) {
Set<TheRType> savedTypes = new HashSet<TheRType>(types);
types.clear();
for (TheRType type : savedTypes) {
if (type instanceof TheRUnionType) {
types.addAll(((TheRUnionType)type).myTypes);
} else {
types.add(type);
}
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof TheRUnionType)) {
return super.equals(o);
}
TheRUnionType type = (TheRUnionType)o;
if (type.myTypes.size() != myTypes.size()) {
return false;
}
for (TheRType t : myTypes) {
if (!type.myTypes.contains(t)) {
return false;
}
}
return true;
}
public boolean contains(TheRType type) {
return myTypes.contains(type);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
for (TheRType type : myTypes) {
builder.append(type.toString()).append("|");
}
builder.deleteCharAt(builder.length() - 1);
return builder.toString();
}
@Override
public TheRType getSubscriptionType(List<TheRExpression> expressions, boolean isSingleBracket) {
HashSet<TheRType> subscriptTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
subscriptTypes.add(type.getSubscriptionType(expressions, isSingleBracket));
}
return TheRUnionType.create(subscriptTypes);
}
@Override
public TheRType afterSubscriptionType(List<TheRExpression> arguments, TheRType valueType, boolean isSingle) {
HashSet<TheRType> afterTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
afterTypes.add(type.afterSubscriptionType(arguments, valueType, isSingle));
}
return TheRUnionType.create(afterTypes);
}
@Override
public TheRType getElementTypes() {
HashSet<TheRType> elementTypes = new HashSet<TheRType>();
for (TheRType type : myTypes) {
elementTypes.add(type.getElementTypes());
}
return TheRUnionType.create(elementTypes);
}
@Override
public TheRUnionType clone() {
TheRUnionType result = (TheRUnionType)super.clone();
result.myTypes = new HashSet<TheRType>(myTypes);
return result;
}
}
| 4,091 | 0.670496 | 0.669518 | 145 | 27.213793 | 24.540237 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.510345 | false | false | 8 |
1473403dd3d0614e0d78cf4547975c2ed7dafd4d | 13,503,377,216,490 | f870563e72a0f022e02750f5012b654425f48b8a | /ranger/src/main/java/com/ranger/resource/ResCallback.java | 0d635cb37e61129d188cdd392ffef785d471dfb8 | [] | no_license | Ityang/RangerCode | https://github.com/Ityang/RangerCode | 2268d6580dd2f7f2f37c86b3c817061d89d06223 | 4d97357bcde390697fcdca6da5b9f1d792236dda | refs/heads/master | 2019-07-30T00:43:17.169000 | 2017-03-17T06:36:34 | 2017-03-17T06:36:34 | 84,781,341 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ranger.resource;
import com.ranger.network.RequestCallback;
import java.io.File;
public interface ResCallback extends RequestCallback<File> {
}
| UTF-8 | Java | 160 | java | ResCallback.java | Java | [] | null | [] | package com.ranger.resource;
import com.ranger.network.RequestCallback;
import java.io.File;
public interface ResCallback extends RequestCallback<File> {
}
| 160 | 0.80625 | 0.80625 | 9 | 16.777779 | 21.122805 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 8 |
1ba2d755f309572f0aa95849cdab3cdf4cfff7bd | 309,237,664,846 | a18fb82b9b4d23ebcc6c2e038c00e5cfc83d1994 | /ThirdModule/src/StringList.java | de2817759b1b00f1a58365970f0a1183560597fc | [] | no_license | superblast/JVA-45-maks | https://github.com/superblast/JVA-45-maks | 17e9d81d6e466d6a09184a1536150b35b87b736f | ea9be153216586178164ded907bcb477146bfab3 | refs/heads/master | 2021-01-19T09:55:43.263000 | 2017-04-18T10:56:32 | 2017-04-18T10:56:32 | 87,799,277 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Created by red6 on 4/13/2017.
*/
public class StringList {
private String str = new String();
public StringList() {
this.str = str;
}
public String getStr() {
return str;
}
public String addString(String strToAdd) {
str = str + strToAdd;
return getStr();
}
}
| UTF-8 | Java | 330 | java | StringList.java | Java | [
{
"context": "/**\n * Created by red6 on 4/13/2017.\n */\npublic class StringList {\n p",
"end": 22,
"score": 0.9994688630104065,
"start": 18,
"tag": "USERNAME",
"value": "red6"
}
] | null | [] | /**
* Created by red6 on 4/13/2017.
*/
public class StringList {
private String str = new String();
public StringList() {
this.str = str;
}
public String getStr() {
return str;
}
public String addString(String strToAdd) {
str = str + strToAdd;
return getStr();
}
}
| 330 | 0.551515 | 0.527273 | 19 | 16.368422 | 14.379117 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.263158 | false | false | 8 |
c42be70ad5656301516e612f434bcc7a528b590b | 25,615,184,975,561 | c26b7b6c04be20f552be94a32a2c234006f1f010 | /src/main/java/com/witgather/utils/ObjectPool.java | 24c933f0220813bc6fe58ce1b8d07bee691a0956 | [] | no_license | MyTestClass/witgather | https://github.com/MyTestClass/witgather | be4e5fb16e8d1895a6d63d92d8059f4fc9505f04 | f2c357c4212cf0a4192898af4fe92f7502c0b311 | refs/heads/master | 2020-03-17T23:26:29.006000 | 2018-05-19T08:39:59 | 2018-05-19T08:39:59 | 134,045,105 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.witgather.utils;
import org.apache.commons.pool2.BaseKeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import com.witgather.baseadapter.BaseAdapter;
import com.witgather.service.user.LoginHandler;
public class ObjectPool {
public static GenericKeyedObjectPool<String,BaseAdapter> objectpool =
new GenericKeyedObjectPool<String,BaseAdapter>(new BeanFactory());
static {
GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
config.setMaxTotalPerKey(50);
config.setMaxWaitMillis(10000);
config.setMinIdlePerKey(5);
objectpool.setConfig(config);
}
}
class BeanFactory extends BaseKeyedPooledObjectFactory<String,BaseAdapter>{
@Override
public BaseAdapter create(String key) throws Exception {
switch(key) {
case "login":
return new LoginHandler();
case "register":
return null;
}
return null;
}
@Override
public PooledObject<BaseAdapter> wrap(BaseAdapter arg0) {
return new DefaultPooledObject<BaseAdapter>(arg0);
}
} | UTF-8 | Java | 1,210 | java | ObjectPool.java | Java | [] | null | [] | package com.witgather.utils;
import org.apache.commons.pool2.BaseKeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import com.witgather.baseadapter.BaseAdapter;
import com.witgather.service.user.LoginHandler;
public class ObjectPool {
public static GenericKeyedObjectPool<String,BaseAdapter> objectpool =
new GenericKeyedObjectPool<String,BaseAdapter>(new BeanFactory());
static {
GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
config.setMaxTotalPerKey(50);
config.setMaxWaitMillis(10000);
config.setMinIdlePerKey(5);
objectpool.setConfig(config);
}
}
class BeanFactory extends BaseKeyedPooledObjectFactory<String,BaseAdapter>{
@Override
public BaseAdapter create(String key) throws Exception {
switch(key) {
case "login":
return new LoginHandler();
case "register":
return null;
}
return null;
}
@Override
public PooledObject<BaseAdapter> wrap(BaseAdapter arg0) {
return new DefaultPooledObject<BaseAdapter>(arg0);
}
} | 1,210 | 0.795868 | 0.783471 | 45 | 25.911112 | 25.366489 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.466667 | false | false | 8 |
08ced62050fb9af5a9283cc0c6236b9b4eb7a005 | 25,615,184,972,137 | f5e28c681dd76e3076185b443e32829b259e5943 | /src/main/java/com/tecacet/poc/clp/ChocoMagicSeries.java | b6cd35a038dc4a43c2d4d1917e427001a65d667b | [] | no_license | stochasticstoic/ConstraintProgrammingPOC | https://github.com/stochasticstoic/ConstraintProgrammingPOC | 5ba1c514b326eb65bee4d41e4d309cb2aaf2c138 | 50ebc0db0a4ede256d14ceed86a07d4b576da17a | refs/heads/master | 2016-09-05T17:12:58.320000 | 2015-07-26T01:56:08 | 2015-07-26T01:56:08 | 39,702,438 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tecacet.poc.clp;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.constraints.Constraint;
import org.chocosolver.solver.constraints.IntConstraintFactory;
import org.chocosolver.solver.search.strategy.IntStrategyFactory;
import org.chocosolver.solver.trace.Chatterbox;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.solver.variables.VariableFactory;
public class ChocoMagicSeries {
public static void main(String[] args) {
int length = 7;
Solver solver = new Solver();
IntVar[] vars = new IntVar[length];
for (int i = 0; i < vars.length; i++) {
vars[i] = VariableFactory.enumerated("S_" + i, 0, length-1, solver);
}
for (int i = 0; i < vars.length; i++) {
// Number of variables equal to i = vars[i]
// Constraint c = IntConstraintFactory.count(i, vars, VariableFactory.eq(vars[i]));
Constraint c = IntConstraintFactory.count(i, vars, vars[i]);
solver.post(c);
}
solver.set(IntStrategyFactory.lexico_UB(vars));
//solver.set(IntStrategyFactory.minDom_LB(vars));
long solutionCount = solver.findAllSolutions();
Chatterbox.printStatistics(solver);
Chatterbox.printSolutions(solver);
}
}
| UTF-8 | Java | 1,314 | java | ChocoMagicSeries.java | Java | [] | null | [] | package com.tecacet.poc.clp;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.constraints.Constraint;
import org.chocosolver.solver.constraints.IntConstraintFactory;
import org.chocosolver.solver.search.strategy.IntStrategyFactory;
import org.chocosolver.solver.trace.Chatterbox;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.solver.variables.VariableFactory;
public class ChocoMagicSeries {
public static void main(String[] args) {
int length = 7;
Solver solver = new Solver();
IntVar[] vars = new IntVar[length];
for (int i = 0; i < vars.length; i++) {
vars[i] = VariableFactory.enumerated("S_" + i, 0, length-1, solver);
}
for (int i = 0; i < vars.length; i++) {
// Number of variables equal to i = vars[i]
// Constraint c = IntConstraintFactory.count(i, vars, VariableFactory.eq(vars[i]));
Constraint c = IntConstraintFactory.count(i, vars, vars[i]);
solver.post(c);
}
solver.set(IntStrategyFactory.lexico_UB(vars));
//solver.set(IntStrategyFactory.minDom_LB(vars));
long solutionCount = solver.findAllSolutions();
Chatterbox.printStatistics(solver);
Chatterbox.printSolutions(solver);
}
}
| 1,314 | 0.666667 | 0.662861 | 34 | 37.64706 | 24.80617 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.911765 | false | false | 8 |
1cfa0f23e06dcfc8e47585604ac8b15392180d7f | 25,615,184,972,515 | 8673e8b4e037383b24a2b8136e06024919872eb3 | /src/br/com/rn/treinador/TreinadorPortaLogica.java | f70ae19e0c23de8cae509cc606e861f662a6c919 | [] | no_license | brholanda/perceptron | https://github.com/brholanda/perceptron | c377204bb65142dd5ad13739f12e82e314ae1866 | f839fae9f15c48dd98d496da77e0d39ef7a09d6f | refs/heads/master | 2022-01-09T02:11:55.661000 | 2019-06-27T01:55:10 | 2019-06-27T01:55:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.rn.treinador;
import br.com.rn.neurorio.Perceptron;
import br.com.rn.validador.Degrau;
public class TreinadorPortaLogica extends Treinador {
public void treinar() {
double[][] conjuntoEntradas = { { 1, 1 }, { 1, 0 }, { 0, 1 }, { 0, 0 } };
int[] saidasEsperadas = { 0, 0, 0, 1 };
int erro, saida, passos = 0;
Boolean saidasOk;
Perceptron perceptron = new Perceptron(conjuntoEntradas[0].length, new Degrau());
do {
saidasOk = true;
for (int i = 0; i < conjuntoEntradas.length; i++) {
erro = 0;
saida = perceptron.saidaAxionio(conjuntoEntradas[i]);
if (saida != saidasEsperadas[i]) {
saidasOk = false;
erro = saidasEsperadas[i] - saida;
System.out.println("erro: " + erro);
perceptron.verificaErro(erro, fator, conjuntoEntradas[i]);
}
System.out.println("Saida: " + saida + "\nSaída Esperada: " + saidasEsperadas[i] + "\nErro: " + erro
+ "\n=====================================");
}
passos++;
System.out.println("Passo: " + passos + "\n#####################################");
} while (!saidasOk);
System.out.println("\nPassos: " + passos);
}
}
| ISO-8859-1 | Java | 1,145 | java | TreinadorPortaLogica.java | Java | [] | null | [] | package br.com.rn.treinador;
import br.com.rn.neurorio.Perceptron;
import br.com.rn.validador.Degrau;
public class TreinadorPortaLogica extends Treinador {
public void treinar() {
double[][] conjuntoEntradas = { { 1, 1 }, { 1, 0 }, { 0, 1 }, { 0, 0 } };
int[] saidasEsperadas = { 0, 0, 0, 1 };
int erro, saida, passos = 0;
Boolean saidasOk;
Perceptron perceptron = new Perceptron(conjuntoEntradas[0].length, new Degrau());
do {
saidasOk = true;
for (int i = 0; i < conjuntoEntradas.length; i++) {
erro = 0;
saida = perceptron.saidaAxionio(conjuntoEntradas[i]);
if (saida != saidasEsperadas[i]) {
saidasOk = false;
erro = saidasEsperadas[i] - saida;
System.out.println("erro: " + erro);
perceptron.verificaErro(erro, fator, conjuntoEntradas[i]);
}
System.out.println("Saida: " + saida + "\nSaída Esperada: " + saidasEsperadas[i] + "\nErro: " + erro
+ "\n=====================================");
}
passos++;
System.out.println("Passo: " + passos + "\n#####################################");
} while (!saidasOk);
System.out.println("\nPassos: " + passos);
}
}
| 1,145 | 0.583042 | 0.569056 | 37 | 29.918919 | 27.647764 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.135135 | false | false | 8 |
2a716d8032d5a128668406ef10067168352dfa36 | 11,149,735,124,589 | 38d4865ccd7f06d79744bf6900638db9684e62ca | /src/main/java/com/example/zhaocong/luntan/model/QuestionPageList.java | 92e3d7d45b0892cae6c9a213872202aa329b1744 | [] | no_license | a38213106/2019-11-30 | https://github.com/a38213106/2019-11-30 | 7c6f6fb2b24357d198fa344b2d4855db896d242c | 89126948f6e61336993dd005cc70e5f37d92dc41 | refs/heads/master | 2022-06-27T22:12:44.884000 | 2020-04-18T01:58:34 | 2020-04-18T01:58:34 | 224,974,187 | 0 | 0 | null | false | 2022-06-17T02:43:39 | 2019-11-30T07:11:29 | 2020-04-18T01:58:46 | 2022-06-17T02:43:39 | 1,588 | 0 | 0 | 2 | Java | false | false | package com.example.zhaocong.luntan.model;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class QuestionPageList {
private boolean firstPage; //第一页
private boolean endPage; //末尾页
private boolean previousPage; //上一页
private boolean nextPage; //下一页
private List<QuestionDto> questionData;
private List<Integer> pages=new ArrayList<>();
private Integer totalPage; //总的页数
private Integer currentPage; //当前页数
public void PageSet(Integer totalPage, Integer currentPage){
this.totalPage=totalPage;
this.currentPage=currentPage;
pages.add(currentPage);
for(int i=1;i<=3;i++){
if(currentPage-i>0){
pages.add(0,currentPage-i);
}
if(currentPage+i<=totalPage){
pages.add(currentPage+i);
}
}
//是否有上一页
previousPage=currentPage==1?false:true;
//是否有下一页
nextPage=currentPage==totalPage?false:true;
//是否有首页
firstPage=pages.contains(1)?false:true;
//是否有末尾页
endPage=pages.contains(totalPage)?false:true;
}
}
| UTF-8 | Java | 1,274 | java | QuestionPageList.java | Java | [] | null | [] | package com.example.zhaocong.luntan.model;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class QuestionPageList {
private boolean firstPage; //第一页
private boolean endPage; //末尾页
private boolean previousPage; //上一页
private boolean nextPage; //下一页
private List<QuestionDto> questionData;
private List<Integer> pages=new ArrayList<>();
private Integer totalPage; //总的页数
private Integer currentPage; //当前页数
public void PageSet(Integer totalPage, Integer currentPage){
this.totalPage=totalPage;
this.currentPage=currentPage;
pages.add(currentPage);
for(int i=1;i<=3;i++){
if(currentPage-i>0){
pages.add(0,currentPage-i);
}
if(currentPage+i<=totalPage){
pages.add(currentPage+i);
}
}
//是否有上一页
previousPage=currentPage==1?false:true;
//是否有下一页
nextPage=currentPage==totalPage?false:true;
//是否有首页
firstPage=pages.contains(1)?false:true;
//是否有末尾页
endPage=pages.contains(totalPage)?false:true;
}
}
| 1,274 | 0.609428 | 0.604377 | 48 | 23.75 | 19.201237 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.520833 | false | false | 8 |
5238f279fc9bc416556e04e4b640ee9cfddc61f8 | 28,415,503,650,556 | 86bcbcbebed4aa1aecef9939302d4610f8972d2d | /app/src/main/java/com/example/alice/androidchat/contactslist/ui/ContactListView.java | b6b95ffdfaaa1062f2003bec005bc76dbc83744d | [] | no_license | aliceresponde/AndroidChat-1 | https://github.com/aliceresponde/AndroidChat-1 | 6753fab28f3a146abd2eb3423ea1161705f7d6ac | 2f3ac6215572f44587a4e78a164e24f5a819383c | refs/heads/master | 2020-04-08T04:25:16.690000 | 2016-06-21T03:27:52 | 2016-06-21T03:27:52 | 60,994,917 | 0 | 0 | null | true | 2016-06-12T23:52:05 | 2016-06-12T23:52:04 | 2016-06-07T04:25:41 | 2016-06-12T23:45:39 | 110 | 0 | 0 | 0 | null | null | null | package com.example.alice.androidchat.contactslist.ui;
import com.example.alice.androidchat.entities.User;
/**
* Created by alice on 6/15/16.
*/
public interface ContactListView {
void onContactAdded(User user);
void onContactChanged(User user);
void onContactRemoved(User user);
}
| UTF-8 | Java | 299 | java | ContactListView.java | Java | [
{
"context": "lice.androidchat.entities.User;\n\n/**\n * Created by alice on 6/15/16.\n */\n\npublic interface ContactListView",
"end": 132,
"score": 0.9623206853866577,
"start": 127,
"tag": "USERNAME",
"value": "alice"
}
] | null | [] | package com.example.alice.androidchat.contactslist.ui;
import com.example.alice.androidchat.entities.User;
/**
* Created by alice on 6/15/16.
*/
public interface ContactListView {
void onContactAdded(User user);
void onContactChanged(User user);
void onContactRemoved(User user);
}
| 299 | 0.749164 | 0.732441 | 13 | 22 | 20.237057 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 8 |
2a497bbd9e1103c7ab32960498144d63e8bacf0f | 5,454,608,485,610 | bb7262d8cb44ac38d57064a2cd2d578a38ede75a | /java_class/src/kr/hs/dgsw/c2/d0521/ConnectionReceiver.java | e8e81be37e289ca3d880d8975d5a13a12f220960 | [] | no_license | maryoh2003/Java_class | https://github.com/maryoh2003/Java_class | b6f9b1cfdd9e51c2cd6f5e4f794253994f0341bc | 35cbd7916a9cdfe945265d749270134ebfd7dbf3 | refs/heads/master | 2022-11-18T08:47:20.577000 | 2020-07-20T04:24:44 | 2020-07-20T04:24:44 | 261,657,037 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kr.hs.dgsw.c2.d0521;
import java.net.Socket;
public interface ConnectionReceiver
{
public void onClientConnected(Socket socket);
}
| UTF-8 | Java | 145 | java | ConnectionReceiver.java | Java | [] | null | [] | package kr.hs.dgsw.c2.d0521;
import java.net.Socket;
public interface ConnectionReceiver
{
public void onClientConnected(Socket socket);
}
| 145 | 0.77931 | 0.744828 | 10 | 13.5 | 16.835974 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 8 |
461c53de1bdfc290468662765bf123817e7dde04 | 5,454,608,486,153 | e6f7b17064e9fca31bc202ca64d497f40e3a095c | /app/src/main/java/com/grability/msalcedo/itunesstore_test/backend/request/Http.java | 6a04df4944c33a7a6a03988ce340f94726e5003e | [
"Apache-2.0"
] | permissive | m-salcedo/itunes-store | https://github.com/m-salcedo/itunes-store | e0921c1abcef88d343d51d963ddf83ec8374bd2d | fe815a69acbbc51017cd9bd67cda70d3bac9f15f | refs/heads/master | 2021-01-10T22:57:26.793000 | 2016-10-10T02:10:26 | 2016-10-10T02:10:26 | 70,437,144 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.grability.msalcedo.itunesstore_test.backend.request;
import android.content.Context;
import com.grability.msalcedo.itunesstore_test.backend.manager.RequestManager;
import com.grability.msalcedo.itunesstore_test.backend.response.IHttpListener;
import com.grability.msalcedo.itunesstore_test.model.Response;
import retrofit2.Call;
import retrofit2.Callback;
/**
* Created by Mariangela Salcedo (msalcedo047@gmail.com) on 08/10/16.
* Copyright (c) 2016 m-salcedo. All rights reserved.
*/
public class Http extends RequestManager {
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private static final String TAG = Http.class.getSimpleName();
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Fields
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private Context mContext;
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Methods
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private Http(Context context) {
mContext = context;
}
public static Http request(Context context) {
return new Http(context);
}
private static IHttp api(Context context) {
return retrofit(context).create(IHttp.class);
}
public Call<Response> getFreeApplications(final IHttpListener.Applications listener) {
return getFreeApplications(0, listener);
}
public Call<Response> getFreeApplications(int category, final IHttpListener.Applications listener) {
Call<Response> call = api(mContext).getFreeApplications(category);
call.enqueue(new Callback<Response>() {
@Override
public void onResponse(Call<Response> call, retrofit2.Response<Response> response) {
if (call.isCanceled()) return;
if (response.isSuccessful()) {
listener.onAppSuccess(response.body().getFeed().getEntry());
} else {
listener.onAppFailed();
}
}
@Override
public void onFailure(Call<Response> call, Throwable t) {
if (call.isCanceled()) return;
listener.onError(t != null ? t.getMessage() : "");
}
});
return call;
}
}
| UTF-8 | Java | 3,210 | java | Http.java | Java | [
{
"context": "all;\nimport retrofit2.Callback;\n\n/**\n * Created by Mariangela Salcedo (msalcedo047@gmail.com) on 08/10/16.\n * Copyright",
"end": 408,
"score": 0.9998893737792969,
"start": 390,
"tag": "NAME",
"value": "Mariangela Salcedo"
},
{
"context": ".Callback;\n\n/**\n * Created by Mariangela Salcedo (msalcedo047@gmail.com) on 08/10/16.\n * Copyright (c) 2016 m-salcedo. Al",
"end": 431,
"score": 0.9999209046363831,
"start": 410,
"tag": "EMAIL",
"value": "msalcedo047@gmail.com"
},
{
"context": "o047@gmail.com) on 08/10/16.\n * Copyright (c) 2016 m-salcedo. All rights reserved.\n */\npublic class Http exten",
"end": 477,
"score": 0.9989396929740906,
"start": 468,
"tag": "USERNAME",
"value": "m-salcedo"
}
] | null | [] | package com.grability.msalcedo.itunesstore_test.backend.request;
import android.content.Context;
import com.grability.msalcedo.itunesstore_test.backend.manager.RequestManager;
import com.grability.msalcedo.itunesstore_test.backend.response.IHttpListener;
import com.grability.msalcedo.itunesstore_test.model.Response;
import retrofit2.Call;
import retrofit2.Callback;
/**
* Created by <NAME> (<EMAIL>) on 08/10/16.
* Copyright (c) 2016 m-salcedo. All rights reserved.
*/
public class Http extends RequestManager {
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private static final String TAG = Http.class.getSimpleName();
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Fields
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private Context mContext;
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// Methods
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
private Http(Context context) {
mContext = context;
}
public static Http request(Context context) {
return new Http(context);
}
private static IHttp api(Context context) {
return retrofit(context).create(IHttp.class);
}
public Call<Response> getFreeApplications(final IHttpListener.Applications listener) {
return getFreeApplications(0, listener);
}
public Call<Response> getFreeApplications(int category, final IHttpListener.Applications listener) {
Call<Response> call = api(mContext).getFreeApplications(category);
call.enqueue(new Callback<Response>() {
@Override
public void onResponse(Call<Response> call, retrofit2.Response<Response> response) {
if (call.isCanceled()) return;
if (response.isSuccessful()) {
listener.onAppSuccess(response.body().getFeed().getEntry());
} else {
listener.onAppFailed();
}
}
@Override
public void onFailure(Call<Response> call, Throwable t) {
if (call.isCanceled()) return;
listener.onError(t != null ? t.getMessage() : "");
}
});
return call;
}
}
| 3,184 | 0.402804 | 0.397508 | 77 | 40.688313 | 36.895874 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.324675 | false | false | 8 |
bd33262f581c6cb9e4306cb74236f52cb6bb9796 | 26,920,855,033,780 | 6abf5496594d4f41b310f059a52b26d66aab11e8 | /src/main/java/com/rbkmoney/newway/handler/event/stock/impl/identity/IdentityChallengeStatusChangedHandler.java | 35b07478d16414748709ff7a1843668cd4781d1c | [
"Apache-2.0"
] | permissive | rbkmoney/newway | https://github.com/rbkmoney/newway | e45a91ac4757aeb095a39bc73b521e00f58a121b | fb1c12a000a51fc111cf49b5be0519a2a7d031ec | refs/heads/master | 2022-01-01T07:10:41.415000 | 2021-12-15T13:52:09 | 2021-12-15T13:52:09 | 143,171,332 | 3 | 4 | Apache-2.0 | false | 2021-12-22T15:32:33 | 2018-08-01T15:00:19 | 2021-12-15T13:52:13 | 2021-12-22T15:32:25 | 1,734 | 2 | 3 | 2 | Java | false | false | package com.rbkmoney.newway.handler.event.stock.impl.identity;
import com.rbkmoney.fistful.identity.*;
import com.rbkmoney.geck.common.util.TBaseUtil;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.machinegun.eventsink.MachineEvent;
import com.rbkmoney.newway.dao.identity.iface.ChallengeDao;
import com.rbkmoney.newway.domain.enums.ChallengeResolution;
import com.rbkmoney.newway.domain.tables.pojos.Challenge;
import com.rbkmoney.newway.factory.MachineEventCopyFactory;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Component
@RequiredArgsConstructor
public class IdentityChallengeStatusChangedHandler implements IdentityHandler {
private final ChallengeDao challengeDao;
private final MachineEventCopyFactory<Challenge, String> challengeMachineEventCopyFactory;
@Getter
private Filter filter = new PathConditionFilter(
new PathConditionRule("change.identity_challenge.payload.status_changed", new IsNullCondition().not()));
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void handle(TimestampedChange timestampedChange, MachineEvent event) {
Change change = timestampedChange.getChange();
ChallengeChange challengeChange = change.getIdentityChallenge();
ChallengeStatus status = challengeChange.getPayload().getStatusChanged();
long sequenceId = event.getEventId();
String identityId = event.getSourceId();
String challengeId = challengeChange.getId();
log.info("Start identity challenge status changed handling, sequenceId={}, identityId={}, challengeId={}",
sequenceId, identityId, challengeId);
final Challenge challengeOld = challengeDao.get(identityId, challengeChange.getId());
Challenge challengeNew = challengeMachineEventCopyFactory
.create(event, sequenceId, identityId, challengeOld, timestampedChange.getOccuredAt());
challengeNew.setChallengeId(challengeChange.getId());
challengeNew.setChallengeStatus(
TBaseUtil.unionFieldToEnum(status, com.rbkmoney.newway.domain.enums.ChallengeStatus.class));
if (status.isSetCompleted()) {
ChallengeCompleted challengeCompleted = status.getCompleted();
challengeNew.setChallengeResolution(
TypeUtil.toEnumField(challengeCompleted.getResolution().toString(), ChallengeResolution.class));
if (challengeCompleted.isSetValidUntil()) {
challengeNew.setChallengeValidUntil(TypeUtil.stringToLocalDateTime(challengeCompleted.getValidUntil()));
}
}
challengeDao.save(challengeNew).ifPresentOrElse(
id -> {
challengeDao.updateNotCurrent(identityId, challengeOld.getId());
log.info("Identity challenge status have been changed, sequenceId={}, identityId={}", sequenceId,
identityId);
},
() -> log.info("Identity challenge have been saved, sequenceId={}, identityId={}", sequenceId,
identityId));
}
}
| UTF-8 | Java | 3,563 | java | IdentityChallengeStatusChangedHandler.java | Java | [] | null | [] | package com.rbkmoney.newway.handler.event.stock.impl.identity;
import com.rbkmoney.fistful.identity.*;
import com.rbkmoney.geck.common.util.TBaseUtil;
import com.rbkmoney.geck.common.util.TypeUtil;
import com.rbkmoney.geck.filter.Filter;
import com.rbkmoney.geck.filter.PathConditionFilter;
import com.rbkmoney.geck.filter.condition.IsNullCondition;
import com.rbkmoney.geck.filter.rule.PathConditionRule;
import com.rbkmoney.machinegun.eventsink.MachineEvent;
import com.rbkmoney.newway.dao.identity.iface.ChallengeDao;
import com.rbkmoney.newway.domain.enums.ChallengeResolution;
import com.rbkmoney.newway.domain.tables.pojos.Challenge;
import com.rbkmoney.newway.factory.MachineEventCopyFactory;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Component
@RequiredArgsConstructor
public class IdentityChallengeStatusChangedHandler implements IdentityHandler {
private final ChallengeDao challengeDao;
private final MachineEventCopyFactory<Challenge, String> challengeMachineEventCopyFactory;
@Getter
private Filter filter = new PathConditionFilter(
new PathConditionRule("change.identity_challenge.payload.status_changed", new IsNullCondition().not()));
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void handle(TimestampedChange timestampedChange, MachineEvent event) {
Change change = timestampedChange.getChange();
ChallengeChange challengeChange = change.getIdentityChallenge();
ChallengeStatus status = challengeChange.getPayload().getStatusChanged();
long sequenceId = event.getEventId();
String identityId = event.getSourceId();
String challengeId = challengeChange.getId();
log.info("Start identity challenge status changed handling, sequenceId={}, identityId={}, challengeId={}",
sequenceId, identityId, challengeId);
final Challenge challengeOld = challengeDao.get(identityId, challengeChange.getId());
Challenge challengeNew = challengeMachineEventCopyFactory
.create(event, sequenceId, identityId, challengeOld, timestampedChange.getOccuredAt());
challengeNew.setChallengeId(challengeChange.getId());
challengeNew.setChallengeStatus(
TBaseUtil.unionFieldToEnum(status, com.rbkmoney.newway.domain.enums.ChallengeStatus.class));
if (status.isSetCompleted()) {
ChallengeCompleted challengeCompleted = status.getCompleted();
challengeNew.setChallengeResolution(
TypeUtil.toEnumField(challengeCompleted.getResolution().toString(), ChallengeResolution.class));
if (challengeCompleted.isSetValidUntil()) {
challengeNew.setChallengeValidUntil(TypeUtil.stringToLocalDateTime(challengeCompleted.getValidUntil()));
}
}
challengeDao.save(challengeNew).ifPresentOrElse(
id -> {
challengeDao.updateNotCurrent(identityId, challengeOld.getId());
log.info("Identity challenge status have been changed, sequenceId={}, identityId={}", sequenceId,
identityId);
},
() -> log.info("Identity challenge have been saved, sequenceId={}, identityId={}", sequenceId,
identityId));
}
}
| 3,563 | 0.732809 | 0.731967 | 72 | 48.486111 | 33.930481 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.902778 | false | false | 8 |
e2fbee2f54256e048a9f14fd9d30c0e5e449df26 | 11,046,655,913,202 | dc8333e9b650da96f790908bdceac611a1eae93a | /src/main/java/com/dhruba/eco/service/UserServiceImp.java | 76e7d4f2e443ad5ef9ac13d1eef585bf05d1ea9e | [] | no_license | dhrubacb/EcommerceSite | https://github.com/dhrubacb/EcommerceSite | 3cf0daeacc36cce9728a1af8cef6aa78e185868f | 118491db1cc314b5a5f4f27767afdc4a08a233cc | refs/heads/master | 2020-03-12T21:46:01.558000 | 2018-04-24T10:02:40 | 2018-04-24T10:02:40 | 130,834,435 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dhruba.eco.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dhruba.eco.dao.UserDao;
import com.dhruba.eco.exception.UserExistsException;
import com.dhruba.eco.model.UserType;
import com.dhruba.eco.model.Users;
@Service
public class UserServiceImp implements UserService{
@Autowired
UserDao userDao;
@Override
public boolean doesEmailExists(String email) throws UserExistsException{
if(userDao.findByEmail(email)!=null)
throw new UserExistsException();
return true;
}
@Override
public Users saveUser(Users user) {
// TODO Auto-generated method stub
try {
UserType type=new UserType();
type.setType("user");
user.setType(type);
user.setImage("nk");
return userDao.save(user);
}
catch(Exception e) {
return null;
}
}
}
| UTF-8 | Java | 856 | java | UserServiceImp.java | Java | [] | null | [] | package com.dhruba.eco.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dhruba.eco.dao.UserDao;
import com.dhruba.eco.exception.UserExistsException;
import com.dhruba.eco.model.UserType;
import com.dhruba.eco.model.Users;
@Service
public class UserServiceImp implements UserService{
@Autowired
UserDao userDao;
@Override
public boolean doesEmailExists(String email) throws UserExistsException{
if(userDao.findByEmail(email)!=null)
throw new UserExistsException();
return true;
}
@Override
public Users saveUser(Users user) {
// TODO Auto-generated method stub
try {
UserType type=new UserType();
type.setType("user");
user.setType(type);
user.setImage("nk");
return userDao.save(user);
}
catch(Exception e) {
return null;
}
}
}
| 856 | 0.757009 | 0.757009 | 39 | 20.948717 | 19.061235 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.435897 | false | false | 8 |
eae67ad2a318e03bfb6b3bf035d78cf9355cd2cf | 11,046,655,913,345 | c12b18fb2e7ef0cdb0fd4d30ca25e7debc4a0775 | /CaissaProject/src/net/lhorizon/caissa/line/dao/iml/LineMysqlJDBCImpl.java | d321a93bf01bc691bff1597912beaa79bcb3824a | [] | no_license | lhorizon/aa | https://github.com/lhorizon/aa | 7ff3e2b55d09167412bf78eb5402f6c58c3c659b | f049af8824784cab751375314881a1726aa5495a | refs/heads/master | 2016-09-05T20:12:34.625000 | 2013-03-31T05:22:54 | 2013-03-31T05:22:54 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.lhorizon.caissa.line.dao.iml;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.lhorizon.caissa.area.vo.AreaModel;
import net.lhorizon.caissa.line.dao.dao.LineDAO;
import net.lhorizon.caissa.line.vo.LineModel;
import net.lhorizon.caissa.util.db.DbHelper;
public class LineMysqlJDBCImpl implements LineDAO {
public boolean addNewLine(LineModel lm) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
// Insert into table (...............) value()
sql.append("insert into ");
sql.append(LineModel.TABLE_NAME);
sql
.append(" (lineName,areaUuid,startTime,endTime,peoples,price,days,type,station,description) value('");
sql.append(lm.getLineName());
sql.append("' , '");
sql.append(lm.getAreaUuid());
sql.append("' , '");
sql.append(lm.getStartTime());
sql.append(lm.getEndTime());
sql.append("' , '");
sql.append(lm.getPeopels());
sql.append("' , '");
sql.append(lm.getPrice());
sql.append("' , '");
sql.append(lm.getDays());
sql.append("' , '");
sql.append(lm.getType());
sql.append("' , '");
sql.append(lm.getStation());
sql.append("' , '");
sql.append("' , '");
sql.append(lm.getDescription());
sql.append("') ");
System.out.println(sql.toString());
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public List<LineModel> getAllLineInfo() {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = " select * from " + LineModel.TABLE_NAME;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setPrice(rs.getDouble("price"));
lm.setDays(rs.getInt("days"));
lm.setStartTime(rs.getLong("startTime"));
lm.setEndTime(rs.getLong("endTime"));
lm.setPeopels(rs.getLong("peoples"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setDescription(rs.getString("description"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public boolean updLine(LineModel lm) {
Connection conn = null;
try {
conn = DbHelper.getConn();
StringBuffer sql = new StringBuffer();
sql.append("update ");
sql.append(LineModel.TABLE_NAME);
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public boolean delete(Long uuid) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
sql.append(" delete from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid=");
sql.append(uuid);
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public LineModel getByUuid(Long uuid) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select * from " + LineModel.TABLE_NAME
+ " where uuid=" + uuid;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setPrice(rs.getDouble("price"));
lm.setDays(rs.getInt("days"));
lm.setStartTime(rs.getLong("startTime"));
lm.setEndTime(rs.getLong("endTime"));
lm.setPeopels(rs.getLong("peoples"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setDescription(rs.getString("description"));
return lm;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
/*
*
* 根据puuid查找区域内线路 (non-Javadoc)
*
* @see net.lhorizon.caissa.line.dao.dao.LineDAO#getAreaInfo(java.lang.Long)
*/
// "select line.*,area.areaName from tbl_line line,tbl_area area where
// area.uuid = line.areaUuid and line.areaUuid in (.....)
public List<LineModel> getAreaInfo(Long uuid) {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select line.*,area.areaName from tbl_line line,tbl_area area where area.uuid = line.areaUuid and line.areaUuid in (";
String areaStr = getStringByUuids(uuid);
sql += areaStr;
sql += ")";
// System.out.println("sql:"+sql);
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setDays(rs.getInt("days"));
lm.setDescription(rs.getString("description"));
lm.setEndTime(rs.getLong("endTime"));
lm.setEndTime_View(rs.getLong("endTime"));
lm.setLineName(rs.getString("lineName"));
lm.setPeopels(rs.getLong("peoples"));
lm.setPrice(rs.getDouble("price"));
lm.setStartTime(rs.getLong("startTime"));
lm.setStartTime_View(rs.getLong("startTime"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setUuid(rs.getLong("uuid"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 1.获取uuid作为puuid一共有多少个子项
// 2.将所有子项添加到集合s中
// 3.对每一个子项调用当前方法
private List<Long> getUuidSons(Long uuid) {
Connection conn = null;
List<Long> temp = new ArrayList<Long>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select uuid from tbl_area where puuid=" + uuid;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
temp.add(rs.getLong("uuid"));
}
return temp;
} catch (Exception e) {
e.printStackTrace();
return temp;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void getUuidByPuuid(Long uuid, Set<Long> s) {
List<Long> us = getUuidSons(uuid);
s.addAll(us);
for (Long id : us) {
getUuidByPuuid(id, s);
}
}
private String getStringByUuids(Long uuid) {
Set<Long> uuids = new HashSet<Long>();
getUuidByPuuid(uuid, uuids);
StringBuffer temp = new StringBuffer();
for (Long id : uuids) {
temp.append(id);
temp.append(",");
}
temp.append(uuid);
return temp.toString();
}
public List<LineModel> getAllByUuids(Set<Long> cars) {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = " select * from tbl_line where uuid in(";
for (Long uuid : cars) {
sql += uuid;
sql += ",";
}
sql = sql.substring(0, sql.length() - 1);
sql += ")";
// System.out.println("showsql:"+sql);
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setPrice(rs.getDouble("price"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public String getStationByAreaUuid(Long areaUuid) {
String sql = "select areaName from " + AreaModel.TABLE_NAME
+ " where uuid=" + areaUuid;
Connection conn = null;
String rr = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
rr = rs.getString("areaName");
}
return rr;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/*
*
*
* 获取商品价格
*
* 并且计算因支付额度
*
*
*
*
*/
public String priceSql(ArrayList<Long> uuidList){
StringBuffer sql= new StringBuffer();
sql.append(" select price from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid in(");
for(Long uu:uuidList ){
sql.append(uu);
sql.append(",");
}
String rSql=sql.toString().substring(0, sql.length() - 1);
rSql=rSql+")";
Connection conn = null;
List<Double> priceList = new ArrayList<Double>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(rSql);
} catch (Exception e) {
// TODO: handle exception
}
return sql.toString();
}
public Double getPrice(Long uuid) {
StringBuffer sql = new StringBuffer();
sql.append("select price from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid=");
sql.append(uuid);
Connection conn = null;
Double price = 0.0;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next()) {
price = rs.getDouble("price");
}
return price;
} catch (Exception e) {
e.printStackTrace();
return 0.0;
}
}
}
| GB18030 | Java | 10,120 | java | LineMysqlJDBCImpl.java | Java | [] | null | [] | package net.lhorizon.caissa.line.dao.iml;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.lhorizon.caissa.area.vo.AreaModel;
import net.lhorizon.caissa.line.dao.dao.LineDAO;
import net.lhorizon.caissa.line.vo.LineModel;
import net.lhorizon.caissa.util.db.DbHelper;
public class LineMysqlJDBCImpl implements LineDAO {
public boolean addNewLine(LineModel lm) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
// Insert into table (...............) value()
sql.append("insert into ");
sql.append(LineModel.TABLE_NAME);
sql
.append(" (lineName,areaUuid,startTime,endTime,peoples,price,days,type,station,description) value('");
sql.append(lm.getLineName());
sql.append("' , '");
sql.append(lm.getAreaUuid());
sql.append("' , '");
sql.append(lm.getStartTime());
sql.append(lm.getEndTime());
sql.append("' , '");
sql.append(lm.getPeopels());
sql.append("' , '");
sql.append(lm.getPrice());
sql.append("' , '");
sql.append(lm.getDays());
sql.append("' , '");
sql.append(lm.getType());
sql.append("' , '");
sql.append(lm.getStation());
sql.append("' , '");
sql.append("' , '");
sql.append(lm.getDescription());
sql.append("') ");
System.out.println(sql.toString());
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public List<LineModel> getAllLineInfo() {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = " select * from " + LineModel.TABLE_NAME;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setPrice(rs.getDouble("price"));
lm.setDays(rs.getInt("days"));
lm.setStartTime(rs.getLong("startTime"));
lm.setEndTime(rs.getLong("endTime"));
lm.setPeopels(rs.getLong("peoples"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setDescription(rs.getString("description"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public boolean updLine(LineModel lm) {
Connection conn = null;
try {
conn = DbHelper.getConn();
StringBuffer sql = new StringBuffer();
sql.append("update ");
sql.append(LineModel.TABLE_NAME);
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public boolean delete(Long uuid) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
StringBuffer sql = new StringBuffer();
sql.append(" delete from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid=");
sql.append(uuid);
return DbHelper.execute(sql.toString());
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public LineModel getByUuid(Long uuid) {
Connection conn = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select * from " + LineModel.TABLE_NAME
+ " where uuid=" + uuid;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setPrice(rs.getDouble("price"));
lm.setDays(rs.getInt("days"));
lm.setStartTime(rs.getLong("startTime"));
lm.setEndTime(rs.getLong("endTime"));
lm.setPeopels(rs.getLong("peoples"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setDescription(rs.getString("description"));
return lm;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
/*
*
* 根据puuid查找区域内线路 (non-Javadoc)
*
* @see net.lhorizon.caissa.line.dao.dao.LineDAO#getAreaInfo(java.lang.Long)
*/
// "select line.*,area.areaName from tbl_line line,tbl_area area where
// area.uuid = line.areaUuid and line.areaUuid in (.....)
public List<LineModel> getAreaInfo(Long uuid) {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select line.*,area.areaName from tbl_line line,tbl_area area where area.uuid = line.areaUuid and line.areaUuid in (";
String areaStr = getStringByUuids(uuid);
sql += areaStr;
sql += ")";
// System.out.println("sql:"+sql);
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setAreaUuid(rs.getLong("areaUuid"));
lm.setDays(rs.getInt("days"));
lm.setDescription(rs.getString("description"));
lm.setEndTime(rs.getLong("endTime"));
lm.setEndTime_View(rs.getLong("endTime"));
lm.setLineName(rs.getString("lineName"));
lm.setPeopels(rs.getLong("peoples"));
lm.setPrice(rs.getDouble("price"));
lm.setStartTime(rs.getLong("startTime"));
lm.setStartTime_View(rs.getLong("startTime"));
lm.setStation(rs.getString("station"));
lm.setType(rs.getInt("type"));
lm.setUuid(rs.getLong("uuid"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 1.获取uuid作为puuid一共有多少个子项
// 2.将所有子项添加到集合s中
// 3.对每一个子项调用当前方法
private List<Long> getUuidSons(Long uuid) {
Connection conn = null;
List<Long> temp = new ArrayList<Long>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = "select uuid from tbl_area where puuid=" + uuid;
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
temp.add(rs.getLong("uuid"));
}
return temp;
} catch (Exception e) {
e.printStackTrace();
return temp;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void getUuidByPuuid(Long uuid, Set<Long> s) {
List<Long> us = getUuidSons(uuid);
s.addAll(us);
for (Long id : us) {
getUuidByPuuid(id, s);
}
}
private String getStringByUuids(Long uuid) {
Set<Long> uuids = new HashSet<Long>();
getUuidByPuuid(uuid, uuids);
StringBuffer temp = new StringBuffer();
for (Long id : uuids) {
temp.append(id);
temp.append(",");
}
temp.append(uuid);
return temp.toString();
}
public List<LineModel> getAllByUuids(Set<Long> cars) {
Connection conn = null;
List<LineModel> lineList = new ArrayList<LineModel>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
String sql = " select * from tbl_line where uuid in(";
for (Long uuid : cars) {
sql += uuid;
sql += ",";
}
sql = sql.substring(0, sql.length() - 1);
sql += ")";
// System.out.println("showsql:"+sql);
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
LineModel lm = new LineModel();
lm.setUuid(rs.getLong("uuid"));
lm.setLineName(rs.getString("lineName"));
lm.setPrice(rs.getDouble("price"));
lineList.add(lm);
}
return lineList;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
try {
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public String getStationByAreaUuid(Long areaUuid) {
String sql = "select areaName from " + AreaModel.TABLE_NAME
+ " where uuid=" + areaUuid;
Connection conn = null;
String rr = null;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
rr = rs.getString("areaName");
}
return rr;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/*
*
*
* 获取商品价格
*
* 并且计算因支付额度
*
*
*
*
*/
public String priceSql(ArrayList<Long> uuidList){
StringBuffer sql= new StringBuffer();
sql.append(" select price from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid in(");
for(Long uu:uuidList ){
sql.append(uu);
sql.append(",");
}
String rSql=sql.toString().substring(0, sql.length() - 1);
rSql=rSql+")";
Connection conn = null;
List<Double> priceList = new ArrayList<Double>();
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(rSql);
} catch (Exception e) {
// TODO: handle exception
}
return sql.toString();
}
public Double getPrice(Long uuid) {
StringBuffer sql = new StringBuffer();
sql.append("select price from ");
sql.append(LineModel.TABLE_NAME);
sql.append(" where uuid=");
sql.append(uuid);
Connection conn = null;
Double price = 0.0;
try {
conn = DbHelper.getConn();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next()) {
price = rs.getDouble("price");
}
return price;
} catch (Exception e) {
e.printStackTrace();
return 0.0;
}
}
}
| 10,120 | 0.634973 | 0.633873 | 418 | 22.92823 | 18.04764 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.88756 | false | false | 8 |
749b64dff8d4419289e9a066f8cd5c30e5d7964a | 13,829,794,719,075 | e96fbc4896bdede360e5e1abdf8c643133ea77bd | /swift-core/swift-core-analyse/src/main/java/com/fr/swift/cloud/query/aggregator/AggregatorValueUtils.java | 44b57ca19a65d80471dd74f6c310a7fca657946c | [
"Apache-2.0"
] | permissive | fanruan/intelli-swift-core | https://github.com/fanruan/intelli-swift-core | a16c20f54f6ae47153935c6cf85e384511303fe6 | fe84c1110b9ef3a5dc496fedd3fb0253835bcd1b | refs/heads/master | 2022-07-19T21:32:05.770000 | 2021-06-28T10:00:26 | 2021-06-28T10:00:26 | 153,720,329 | 25 | 11 | Apache-2.0 | false | 2022-06-21T04:16:11 | 2018-10-19T03:15:51 | 2022-04-07T20:27:08 | 2022-06-21T04:16:09 | 80,360 | 17 | 9 | 2 | Java | false | false | package com.fr.swift.cloud.query.aggregator;
/**
* @author Lyon
* @date 2018/5/2
*/
public class AggregatorValueUtils {
/**
* 返回新创建的合并结果
*
* @param value
* @param otherValue
* @param aggregator
* @param <T>
* @return
*/
public static <T extends AggregatorValue<?>> T combine(T value, T otherValue, Aggregator<T> aggregator) {
if (value == null && otherValue == null) {
return null;
}
if (value == null) {
return (T) otherValue.clone();
}
if (otherValue == null) {
return (T) value.clone();
}
aggregator.combine(value, otherValue);
return (T) value.clone();
}
}
| UTF-8 | Java | 738 | java | AggregatorValueUtils.java | Java | [
{
"context": "m.fr.swift.cloud.query.aggregator;\n\n/**\n * @author Lyon\n * @date 2018/5/2\n */\npublic class AggregatorValu",
"end": 65,
"score": 0.9962425231933594,
"start": 61,
"tag": "USERNAME",
"value": "Lyon"
}
] | null | [] | package com.fr.swift.cloud.query.aggregator;
/**
* @author Lyon
* @date 2018/5/2
*/
public class AggregatorValueUtils {
/**
* 返回新创建的合并结果
*
* @param value
* @param otherValue
* @param aggregator
* @param <T>
* @return
*/
public static <T extends AggregatorValue<?>> T combine(T value, T otherValue, Aggregator<T> aggregator) {
if (value == null && otherValue == null) {
return null;
}
if (value == null) {
return (T) otherValue.clone();
}
if (otherValue == null) {
return (T) value.clone();
}
aggregator.combine(value, otherValue);
return (T) value.clone();
}
}
| 738 | 0.530641 | 0.522284 | 31 | 22.161291 | 21.497332 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.290323 | false | false | 8 |
9521cc964363653c808d34c4a2868deda48572f3 | 7,000,796,718,802 | 7970d62f4cf68ad1e42b6fee3bda980de0c34b92 | /java_zixue_20/src/com/chenlong/java_zixue_20/TestDate.java | df95c2a48ad134fed5f4b8ffc011a9ef27f0a201 | [] | no_license | Long-Cc/JavaCodeDemo | https://github.com/Long-Cc/JavaCodeDemo | e027c7c971efd7030f302c8a68fc4ba4e8dca755 | 57a38dc7c509abb08f88767143d2a0bb28d63def | refs/heads/master | 2021-07-16T06:45:29.258000 | 2017-10-21T02:31:36 | 2017-10-21T02:31:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.chenlong.java_zixue_20;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
public class TestDate {
/*
* 两天打渔三天晒网 1990-01-01 XXX-XX-XX 打渔? 晒网?
*/
// 返回date1与date2之间的天数 date1早于date2
public int getDays(String date1, String date2) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = sdf.parse(date1);
Date d2 = sdf.parse(date2);
long miliTime = d2.getTime() - d1.getTime();
return (int) miliTime / 1000 / 360 / 24 + 1;
}
@Test
public void test3() throws Exception {
String str1 = "1990-01-01";
String str2 = "1990-01-06";
int dates = getDays(str1, str2);
if (dates % 5 == 0 || dates % 5 == 4) {
System.out.println("晒网");
} else {
System.out.println("打渔");
}
}
@Test
public void test2() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.format(new Date()));// 16-7-29 下午2:10
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = sdf1.format(new Date());
System.out.println(date);// 2016-07-29 02:17:23
// 解析
Date date1 = sdf.parse("16-7-29 下午2:10");
System.out.println(date1);
date1 = sdf1.parse("2016-07-29 02:17:23");
System.out.println(date1);
}
@Test
public void test1() {
Date d1 = new Date();
System.out.println(d1.toString());// Fri Jul 29 13:25:24 CST 2016
System.out.println(d1.getTime());// 1469770140314
Date d3 = new Date(1469770140314L);
System.out.println(d3.toString());
// java.sql.Date d2=new java.sql.Date(12346466L);
// System.out.println(d2.toString());//1970-01-01
}
}
| UTF-8 | Java | 1,691 | java | TestDate.java | Java | [] | null | [] | package com.chenlong.java_zixue_20;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
public class TestDate {
/*
* 两天打渔三天晒网 1990-01-01 XXX-XX-XX 打渔? 晒网?
*/
// 返回date1与date2之间的天数 date1早于date2
public int getDays(String date1, String date2) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = sdf.parse(date1);
Date d2 = sdf.parse(date2);
long miliTime = d2.getTime() - d1.getTime();
return (int) miliTime / 1000 / 360 / 24 + 1;
}
@Test
public void test3() throws Exception {
String str1 = "1990-01-01";
String str2 = "1990-01-06";
int dates = getDays(str1, str2);
if (dates % 5 == 0 || dates % 5 == 4) {
System.out.println("晒网");
} else {
System.out.println("打渔");
}
}
@Test
public void test2() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.format(new Date()));// 16-7-29 下午2:10
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = sdf1.format(new Date());
System.out.println(date);// 2016-07-29 02:17:23
// 解析
Date date1 = sdf.parse("16-7-29 下午2:10");
System.out.println(date1);
date1 = sdf1.parse("2016-07-29 02:17:23");
System.out.println(date1);
}
@Test
public void test1() {
Date d1 = new Date();
System.out.println(d1.toString());// Fri Jul 29 13:25:24 CST 2016
System.out.println(d1.getTime());// 1469770140314
Date d3 = new Date(1469770140314L);
System.out.println(d3.toString());
// java.sql.Date d2=new java.sql.Date(12346466L);
// System.out.println(d2.toString());//1970-01-01
}
}
| 1,691 | 0.666051 | 0.56069 | 62 | 25.17742 | 20.931936 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.822581 | false | false | 8 |
5ba01b95801afaad6b7ea7d57532edc88df10d88 | 16,655,883,199,065 | fe4b5ea7759e1d57b9f6f344e178b88863fb812d | /ScreenCastingLocalHub/src/main/java/edu/ncsu/dlf/ScreenRecordingModule.java | 7c408411ff64712b703e832cd7576b40c1695076 | [] | no_license | DeveloperLiberationFront/social-screencasting-core | https://github.com/DeveloperLiberationFront/social-screencasting-core | 9bfbfd3f2ddfa4e6c3a316c1718fb8db8dce881d | 48700f5a8a3a89e7b656aac1b7d068070103ada5 | refs/heads/master | 2020-04-05T20:26:22.440000 | 2015-11-26T15:14:42 | 2015-11-26T15:14:42 | 36,465,036 | 0 | 1 | null | false | 2015-11-26T15:14:43 | 2015-05-28T20:43:49 | 2015-05-28T20:50:14 | 2015-11-26T15:14:42 | 56,380 | 0 | 1 | 0 | Java | null | null | package edu.ncsu.dlf;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.wet.wired.jsr.recorder.DesktopScreenRecorder;
import com.wet.wired.jsr.recorder.ScreenRecorder;
import com.wet.wired.jsr.recorder.ScreenRecorderListener;
public class ScreenRecordingModule implements ScreenRecorderListener
{
public static final String LOGGING_FILE_PATH = "/etc/log4j.settings";
private static Logger logger;
private File outputFolder;
private ScreenRecorder recorder;
private boolean isRecording;
private boolean isPaused;
//Static initializer to get the logging path set up and create the hub
static {
try
{
URL url = ScreenRecordingModule.class.getResource(LOGGING_FILE_PATH);
PropertyConfigurator.configure(url);
Logger.getRootLogger().info("Logging initialized");
}
catch (Exception e)
{
//load safe defaults
BasicConfigurator.configure();
Logger.getRootLogger().info("Could not load property file, loading defaults", e);
}
logger = Logger.getLogger(ScreenRecordingModule.class.getName());
}
public ScreenRecordingModule(File folderToOutput) {
setOutputDirectory(folderToOutput);
recorder = new DesktopScreenRecorder(folderToOutput, this);
}
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
File scratchDir = new File("scratch/");
ScreenRecordingModule recordingModule = new ScreenRecordingModule(scratchDir);
recordingModule.clearOutputDirectory();
recordingModule.startRecording();
logger.info("recording for 180 seconds" );
System.out.println(new Date());
for(int i = 1;i<=180;i++)
{
logger.info(i);
Thread.sleep(1000);
}
recordingModule.stopRecording();
}
public void stopRecording()
{
if (isRecording)
{
logger.debug("Screen recording module stopped");
recorder.stopRecording();
isRecording = false;
}
}
public void startRecording()
{
if (!isRecording)
{
logger.debug("Screen recording module started");
recorder.startRecording();
isRecording = true;
}
}
public void pauseRecording() {
if (!isPaused) {
recorder.pause(true);
isPaused = true;
}
}
public void unpauseRecording() {
if (isPaused) {
recorder.pause(false);
isPaused = false;
}
}
private void clearOutputDirectory() {
//clear out all the temp files
for(File file: this.outputFolder.listFiles())
{
if (!file.isDirectory())
{
if (!file.delete())
{
logger.error("Could not clear out file "+file.getName()+ "in output folder");
}
}
}
}
private void setOutputDirectory(File outputFolder) {
if (!outputFolder.exists())
{
if (!outputFolder.mkdir())
{
throw new RuntimeException("Could not create scratch folder");
}
}
this.outputFolder = outputFolder;
}
@Override
public void frameRecorded(boolean fullFrame) throws IOException
{
//we don't care about this
}
@Override
public void recordingStopped()
{
logger.info("Recording Stopped");
}
}
| UTF-8 | Java | 3,181 | java | ScreenRecordingModule.java | Java | [] | null | [] | package edu.ncsu.dlf;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.wet.wired.jsr.recorder.DesktopScreenRecorder;
import com.wet.wired.jsr.recorder.ScreenRecorder;
import com.wet.wired.jsr.recorder.ScreenRecorderListener;
public class ScreenRecordingModule implements ScreenRecorderListener
{
public static final String LOGGING_FILE_PATH = "/etc/log4j.settings";
private static Logger logger;
private File outputFolder;
private ScreenRecorder recorder;
private boolean isRecording;
private boolean isPaused;
//Static initializer to get the logging path set up and create the hub
static {
try
{
URL url = ScreenRecordingModule.class.getResource(LOGGING_FILE_PATH);
PropertyConfigurator.configure(url);
Logger.getRootLogger().info("Logging initialized");
}
catch (Exception e)
{
//load safe defaults
BasicConfigurator.configure();
Logger.getRootLogger().info("Could not load property file, loading defaults", e);
}
logger = Logger.getLogger(ScreenRecordingModule.class.getName());
}
public ScreenRecordingModule(File folderToOutput) {
setOutputDirectory(folderToOutput);
recorder = new DesktopScreenRecorder(folderToOutput, this);
}
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
File scratchDir = new File("scratch/");
ScreenRecordingModule recordingModule = new ScreenRecordingModule(scratchDir);
recordingModule.clearOutputDirectory();
recordingModule.startRecording();
logger.info("recording for 180 seconds" );
System.out.println(new Date());
for(int i = 1;i<=180;i++)
{
logger.info(i);
Thread.sleep(1000);
}
recordingModule.stopRecording();
}
public void stopRecording()
{
if (isRecording)
{
logger.debug("Screen recording module stopped");
recorder.stopRecording();
isRecording = false;
}
}
public void startRecording()
{
if (!isRecording)
{
logger.debug("Screen recording module started");
recorder.startRecording();
isRecording = true;
}
}
public void pauseRecording() {
if (!isPaused) {
recorder.pause(true);
isPaused = true;
}
}
public void unpauseRecording() {
if (isPaused) {
recorder.pause(false);
isPaused = false;
}
}
private void clearOutputDirectory() {
//clear out all the temp files
for(File file: this.outputFolder.listFiles())
{
if (!file.isDirectory())
{
if (!file.delete())
{
logger.error("Could not clear out file "+file.getName()+ "in output folder");
}
}
}
}
private void setOutputDirectory(File outputFolder) {
if (!outputFolder.exists())
{
if (!outputFolder.mkdir())
{
throw new RuntimeException("Could not create scratch folder");
}
}
this.outputFolder = outputFolder;
}
@Override
public void frameRecorded(boolean fullFrame) throws IOException
{
//we don't care about this
}
@Override
public void recordingStopped()
{
logger.info("Recording Stopped");
}
}
| 3,181 | 0.706382 | 0.701666 | 174 | 17.281609 | 21.34705 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.614943 | false | false | 8 |
46aaf31e2ab2b28fcd7da9a6107992f8863340d7 | 20,426,864,489,340 | 94a5e8877f74defecf768c95622296e10d885b5d | /src/pages/sample.java | 3de0aff26babc9c48c60ab6d7f47ddb932d1fc23 | [] | no_license | rakhi08/Flipcart | https://github.com/rakhi08/Flipcart | c9eade4f7ba0ae28c61669db0b3a12505aa91fb4 | 32e50d231a207612268fa6cb94a6f1ad9a7c5041 | refs/heads/master | 2020-06-19T07:13:07.234000 | 2016-10-06T12:26:15 | 2016-10-06T12:26:15 | 68,199,673 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pages;
import org.testng.annotations.Test;
import Base.Testbase;
public class sample extends Testbase {
@Test
public void testlogin()
{
driver.get("https://www.google.com");
}
}
| UTF-8 | Java | 199 | java | sample.java | Java | [] | null | [] | package pages;
import org.testng.annotations.Test;
import Base.Testbase;
public class sample extends Testbase {
@Test
public void testlogin()
{
driver.get("https://www.google.com");
}
}
| 199 | 0.708543 | 0.708543 | 15 | 12.266666 | 14.594367 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.8 | false | false | 8 |
794b60248a133ba57cdc73d945d382ece19368cf | 10,075,993,301,898 | c382f90db23948d5d7037f519f6c1e1988da955a | /SEMESTR_5/src/main/java/com/gut/waniusza/semestr_5/progWspol/colloquium_3_online/result/Sum.java | 68acebbcd254497eff068a0c8c860121a0ed84e0 | [] | no_license | Waniusza/Study | https://github.com/Waniusza/Study | fdcaecf8ce0f26f86fe97b0f9210be53ee05a665 | 9253af58fba0ffdbb286ddfd46c13a49d6226341 | refs/heads/master | 2021-03-12T23:33:00.741000 | 2016-01-14T16:42:17 | 2016-01-14T16:42:17 | 31,658,934 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gut.waniusza.semestr_5.progWspol.colloquium_3_online.result;
/**
*
* @author janusz
*/
public class Sum {
public Sum() {
}
public double sum = 0;
}
| UTF-8 | Java | 182 | java | Sum.java | Java | [
{
"context": "pol.colloquium_3_online.result;\n\n/**\n *\n * @author janusz\n */\npublic class Sum {\n\n public Sum() {\n }\n",
"end": 98,
"score": 0.9968892335891724,
"start": 92,
"tag": "USERNAME",
"value": "janusz"
}
] | null | [] | package com.gut.waniusza.semestr_5.progWspol.colloquium_3_online.result;
/**
*
* @author janusz
*/
public class Sum {
public Sum() {
}
public double sum = 0;
}
| 182 | 0.615385 | 0.598901 | 13 | 13 | 18.941204 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | false | false | 8 |
35c9a5e120c3c2a1eea08624bf8e62c69ad46b1e | 27,393,301,418,568 | d4a657b935397c7e81975b7ebe2a09c96c075534 | /src/relevant_craft/vento/media_player/gui/main/elements/scrollbar/ContentScrollBar.java | 3ad76b5e1116e89924a214cdfd3cfe96262b4f4d | [] | no_license | VENTO-off/MediaPlayer | https://github.com/VENTO-off/MediaPlayer | 91a3dd75a8fef3a2aa4f8f2b3a640af9e8cf9402 | b764432e043877116876ea66a69157eb64a06d8f | refs/heads/master | 2022-11-28T17:38:15.125000 | 2020-08-02T00:38:51 | 2020-08-02T00:38:51 | 259,415,934 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package relevant_craft.vento.media_player.gui.main.elements.scrollbar;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Cursor;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
public class ContentScrollBar extends ScrollBar {
private final double defaultWidth = 3;
private final double defaultOpacity = 0.3;
private final double hoverWidth = 7;
private final double hoverOpacity = 0.6;
private final Duration animationTime = Duration.millis(200);
private final Duration animationDelay = Duration.millis(500);
private final double layoutX;
private final ScrollPane parent;
private final Stage stage;
private Timeline positionAnimation;
private Timeline widthAnimation;
private Timeline opacityAnimation;
private boolean isPressed = false;
private boolean isHovered = false;
/**
* Init scroll bar
*/
public ContentScrollBar(Stage stage, ScrollPane parent) {
super();
this.stage = stage;
this.parent = parent;
//orientation
this.setOrientation(Orientation.VERTICAL);
//position
this.layoutX = this.parent.getLayoutX() + this.parent.getPrefWidth() - defaultWidth - 2;
this.setLayoutX(layoutX);
this.setLayoutY(this.parent.getLayoutY());
//transparent background
this.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//width by default
this.setPrefWidth(defaultWidth);
this.setMaxWidth(hoverWidth);
this.setMinWidth(defaultWidth);
//height
this.setPrefHeight(this.parent.getPrefHeight());
//opacity by default
this.setOpacity(defaultOpacity);
//on scroll event
this.valueProperty().addListener((observable, oldValue, newValue) -> this.parent.setVvalue(newValue.doubleValue()));
this.parent.vvalueProperty().addListener((observable, oldValue, newValue) -> this.setValue(newValue.doubleValue()));
this.stage.addEventFilter(WindowEvent.WINDOW_SHOWN, event -> {
//track
Region track = (Region) this.lookup(".track");
track.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//track-background
Region trackBackground = (Region) this.lookup(".track-background");
trackBackground.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//thumb
Region thumb = (Region) this.lookup(".thumb");
thumb.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(1.0, 0.0, 1.0, 0.0))));
thumb.setOpacity(defaultOpacity);
thumb.setOnMouseEntered(this::onHover);
thumb.setOnMouseExited(this::onExit);
thumb.setOnMousePressed(this::onPressed);
thumb.setOnMouseReleased(this::onRelease);
//increment button
Region incrementButton = (Region) this.lookup(".increment-button");
incrementButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//decrement button
Region decrementButton = (Region) this.lookup(".decrement-button");
decrementButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//increment arrow
Region incrementArrow = (Region) this.lookup(".increment-arrow");
incrementArrow.setShape(null);
incrementArrow.setPadding(new Insets(0.5, 0, 0.5, 0));
//decrement arrow
Region decrementArrow = (Region) this.lookup(".decrement-arrow");
decrementArrow.setShape(null);
decrementArrow.setPadding(new Insets(0.5, 0, 0.5, 0));
});
}
/**
* Set thumb height
*/
public void setThumbHeight(double contentHeight) {
this.setVisible(!(contentHeight < this.getPrefHeight()));
this.setVisibleAmount(this.getMax() * this.getPrefHeight() / contentHeight);
}
/**
* Play animation to show scrollbar
*/
private void showScrollbar(Region thumb) {
thumb.setCursor(Cursor.HAND);
if (positionAnimation != null && positionAnimation.getStatus() == Animation.Status.RUNNING) {
positionAnimation.stop();
}
positionAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.layoutXProperty(), layoutX - (hoverWidth - defaultWidth))));
positionAnimation.play();
if (widthAnimation != null && widthAnimation.getStatus() == Animation.Status.RUNNING) {
widthAnimation.stop();
}
widthAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.prefWidthProperty(), hoverWidth)));
widthAnimation.play();
if (opacityAnimation != null && opacityAnimation.getStatus() == Animation.Status.RUNNING) {
opacityAnimation.stop();
}
opacityAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.opacityProperty(), hoverOpacity)));
opacityAnimation.play();
}
/**
* Play animation to hide scrollbar
*/
private void hideScrollbar(Region thumb) {
thumb.setCursor(Cursor.DEFAULT);
positionAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.layoutXProperty(), layoutX)));
positionAnimation.setDelay(animationDelay);
positionAnimation.play();
widthAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.prefWidthProperty(), defaultWidth)));
widthAnimation.setDelay(animationDelay);
widthAnimation.play();
opacityAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.opacityProperty(), defaultOpacity)));
opacityAnimation.setDelay(animationDelay);
opacityAnimation.play();
}
/**
* Event on mouse hover
*/
private void onHover(MouseEvent e) {
isHovered = true;
Region thumb = (Region) e.getSource();
showScrollbar(thumb);
}
/**
* Event on mouse exit
*/
private void onExit(MouseEvent e) {
isHovered = false;
if (isPressed) {
return;
}
Region thumb = (Region) e.getSource();
hideScrollbar(thumb);
}
/**
* Event on mouse pressed
*/
private void onPressed(MouseEvent e) {
isPressed = true;
}
/**
* Event on mouse release
*/
private void onRelease(MouseEvent e) {
isPressed = false;
if (!isHovered) {
Region thumb = (Region) e.getSource();
hideScrollbar(thumb);
}
}
}
| UTF-8 | Java | 7,371 | java | ContentScrollBar.java | Java | [] | null | [] | package relevant_craft.vento.media_player.gui.main.elements.scrollbar;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Cursor;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.Region;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
public class ContentScrollBar extends ScrollBar {
private final double defaultWidth = 3;
private final double defaultOpacity = 0.3;
private final double hoverWidth = 7;
private final double hoverOpacity = 0.6;
private final Duration animationTime = Duration.millis(200);
private final Duration animationDelay = Duration.millis(500);
private final double layoutX;
private final ScrollPane parent;
private final Stage stage;
private Timeline positionAnimation;
private Timeline widthAnimation;
private Timeline opacityAnimation;
private boolean isPressed = false;
private boolean isHovered = false;
/**
* Init scroll bar
*/
public ContentScrollBar(Stage stage, ScrollPane parent) {
super();
this.stage = stage;
this.parent = parent;
//orientation
this.setOrientation(Orientation.VERTICAL);
//position
this.layoutX = this.parent.getLayoutX() + this.parent.getPrefWidth() - defaultWidth - 2;
this.setLayoutX(layoutX);
this.setLayoutY(this.parent.getLayoutY());
//transparent background
this.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//width by default
this.setPrefWidth(defaultWidth);
this.setMaxWidth(hoverWidth);
this.setMinWidth(defaultWidth);
//height
this.setPrefHeight(this.parent.getPrefHeight());
//opacity by default
this.setOpacity(defaultOpacity);
//on scroll event
this.valueProperty().addListener((observable, oldValue, newValue) -> this.parent.setVvalue(newValue.doubleValue()));
this.parent.vvalueProperty().addListener((observable, oldValue, newValue) -> this.setValue(newValue.doubleValue()));
this.stage.addEventFilter(WindowEvent.WINDOW_SHOWN, event -> {
//track
Region track = (Region) this.lookup(".track");
track.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//track-background
Region trackBackground = (Region) this.lookup(".track-background");
trackBackground.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//thumb
Region thumb = (Region) this.lookup(".thumb");
thumb.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(1.0, 0.0, 1.0, 0.0))));
thumb.setOpacity(defaultOpacity);
thumb.setOnMouseEntered(this::onHover);
thumb.setOnMouseExited(this::onExit);
thumb.setOnMousePressed(this::onPressed);
thumb.setOnMouseReleased(this::onRelease);
//increment button
Region incrementButton = (Region) this.lookup(".increment-button");
incrementButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//decrement button
Region decrementButton = (Region) this.lookup(".decrement-button");
decrementButton.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
//increment arrow
Region incrementArrow = (Region) this.lookup(".increment-arrow");
incrementArrow.setShape(null);
incrementArrow.setPadding(new Insets(0.5, 0, 0.5, 0));
//decrement arrow
Region decrementArrow = (Region) this.lookup(".decrement-arrow");
decrementArrow.setShape(null);
decrementArrow.setPadding(new Insets(0.5, 0, 0.5, 0));
});
}
/**
* Set thumb height
*/
public void setThumbHeight(double contentHeight) {
this.setVisible(!(contentHeight < this.getPrefHeight()));
this.setVisibleAmount(this.getMax() * this.getPrefHeight() / contentHeight);
}
/**
* Play animation to show scrollbar
*/
private void showScrollbar(Region thumb) {
thumb.setCursor(Cursor.HAND);
if (positionAnimation != null && positionAnimation.getStatus() == Animation.Status.RUNNING) {
positionAnimation.stop();
}
positionAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.layoutXProperty(), layoutX - (hoverWidth - defaultWidth))));
positionAnimation.play();
if (widthAnimation != null && widthAnimation.getStatus() == Animation.Status.RUNNING) {
widthAnimation.stop();
}
widthAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.prefWidthProperty(), hoverWidth)));
widthAnimation.play();
if (opacityAnimation != null && opacityAnimation.getStatus() == Animation.Status.RUNNING) {
opacityAnimation.stop();
}
opacityAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.opacityProperty(), hoverOpacity)));
opacityAnimation.play();
}
/**
* Play animation to hide scrollbar
*/
private void hideScrollbar(Region thumb) {
thumb.setCursor(Cursor.DEFAULT);
positionAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.layoutXProperty(), layoutX)));
positionAnimation.setDelay(animationDelay);
positionAnimation.play();
widthAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.prefWidthProperty(), defaultWidth)));
widthAnimation.setDelay(animationDelay);
widthAnimation.play();
opacityAnimation = new Timeline(new KeyFrame(animationTime, new KeyValue(this.opacityProperty(), defaultOpacity)));
opacityAnimation.setDelay(animationDelay);
opacityAnimation.play();
}
/**
* Event on mouse hover
*/
private void onHover(MouseEvent e) {
isHovered = true;
Region thumb = (Region) e.getSource();
showScrollbar(thumb);
}
/**
* Event on mouse exit
*/
private void onExit(MouseEvent e) {
isHovered = false;
if (isPressed) {
return;
}
Region thumb = (Region) e.getSource();
hideScrollbar(thumb);
}
/**
* Event on mouse pressed
*/
private void onPressed(MouseEvent e) {
isPressed = true;
}
/**
* Event on mouse release
*/
private void onRelease(MouseEvent e) {
isPressed = false;
if (!isHovered) {
Region thumb = (Region) e.getSource();
hideScrollbar(thumb);
}
}
}
| 7,371 | 0.663546 | 0.658934 | 206 | 34.781555 | 33.345875 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.68932 | false | false | 8 |
054000b01f714a001c750459d9622f36010b2f61 | 8,546,984,980,294 | 54d07334410933d812cd1f5f349cf7b71c6646c7 | /Ch01/src/cn/entity/LiangXiaoHu.java | de5e2971988e995af8b35a5c686d9cfed4745ab4 | [] | no_license | ChineseTigerNB/HongXing | https://github.com/ChineseTigerNB/HongXing | 833d8da99ad01f791d5b6dab318f1b3085069ac7 | eae611ccba9bea9105fca5af7857bfa368d5164b | refs/heads/master | 2020-04-17T02:36:25.330000 | 2019-01-21T10:45:13 | 2019-01-21T10:45:13 | 166,143,456 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.entity;
/**
* 集合类
* @author 梁小虎
*/
public class LiangXiaoHu<E> {
Object [] num=new Object[0];
/**
* 新增的方法
* @param obj
*/
public void add(Object obj) {
if(num.length==0){
num=new Object[1];
num[0]=obj;
}else{
Object [] arr=num;
num=new Object[arr.length+1];
for (int i = 0; i < num.length; i++) {
num[i]=arr[i];
if(arr.length-1==i){
break;
}
}
for (int i = 0; i < num.length; i++) {
if(num[i]==null){
num[i]=obj;
}
}
}
}
/**
* 根据下标获得值
* @param i
* @return
*/
public Object get(int i) {
if(i>num.length||num.length==0){
return "当前集合没有内容!";
}
return num[i];
}
/**
* 返回长度的方法
* @return
*/
public int size() {
return num.length;
}
/**
* 返回出现次数最多的字符
* @param list
* @return
*/
public int count(LiangXiaoHu<E> list) {
int nums=(int) list.get(0);
int index=0;
for (int i = 0; i < list.size(); i++) {
if(nums==(int)list.get(i)){
index=i;
if(i==list.size()){
break;
}
}else{
nums=(int)list.get(i);
}
}
return (int)list.get(index);
}
/**
* 获得最大数
* @param list
* @return
*/
public int max(LiangXiaoHu<E> list) {
int num=(int)list.get(0);
for (int i = 0; i < list.size(); i++) {
if(num<(int)list.get(i)){
num=(int)list.get(i);
}
}
return num;
}
/**
* 获得最小数
* @param list
* @return
*/
public int min(LiangXiaoHu<E> list) {
int num=(int)list.get(0);
for (int i = 0; i < list.size(); i++) {
if(num>(int)list.get(i)){
num=(int)list.get(i);
}
}
return num;
}
/**
* 移除的方法
* @param i
*/
public void remove(int i) {
int index=0;
Object [] arr=new Object[num.length-1];
for (int j = 0; j < num.length; j++) {
if(i!=j){
arr[index]=num[j];
index++;
}
}
num=new Object[arr.length];
for (int j = 0; j < num.length; j++) {
num[j]=arr[j];
}
}
/**
* 排序的方法
* @param list
*/
public void sort(LiangXiaoHu<E> list) {
for (int i = 0; i < list.size(); i++) {
num[i]=list.get(i);
}
for(int i=0;i<num.length-1;i++){//外层循环控制排序趟数
for (int j = 0; j < num.length-1-i; j++) {
if((int)num[j]>(int)num[j+1]){
int temp=(int)num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
}
}
}
}
| UTF-8 | Java | 2,537 | java | LiangXiaoHu.java | Java | [
{
"context": "package cn.entity;\r\n\r\n/**\r\n * 集合类\r\n * @author 梁小虎\r\n */\r\npublic class LiangXiaoHu<E> {\r\n\r\n\tObject []",
"end": 49,
"score": 0.9997077584266663,
"start": 46,
"tag": "NAME",
"value": "梁小虎"
}
] | null | [] | package cn.entity;
/**
* 集合类
* @author 梁小虎
*/
public class LiangXiaoHu<E> {
Object [] num=new Object[0];
/**
* 新增的方法
* @param obj
*/
public void add(Object obj) {
if(num.length==0){
num=new Object[1];
num[0]=obj;
}else{
Object [] arr=num;
num=new Object[arr.length+1];
for (int i = 0; i < num.length; i++) {
num[i]=arr[i];
if(arr.length-1==i){
break;
}
}
for (int i = 0; i < num.length; i++) {
if(num[i]==null){
num[i]=obj;
}
}
}
}
/**
* 根据下标获得值
* @param i
* @return
*/
public Object get(int i) {
if(i>num.length||num.length==0){
return "当前集合没有内容!";
}
return num[i];
}
/**
* 返回长度的方法
* @return
*/
public int size() {
return num.length;
}
/**
* 返回出现次数最多的字符
* @param list
* @return
*/
public int count(LiangXiaoHu<E> list) {
int nums=(int) list.get(0);
int index=0;
for (int i = 0; i < list.size(); i++) {
if(nums==(int)list.get(i)){
index=i;
if(i==list.size()){
break;
}
}else{
nums=(int)list.get(i);
}
}
return (int)list.get(index);
}
/**
* 获得最大数
* @param list
* @return
*/
public int max(LiangXiaoHu<E> list) {
int num=(int)list.get(0);
for (int i = 0; i < list.size(); i++) {
if(num<(int)list.get(i)){
num=(int)list.get(i);
}
}
return num;
}
/**
* 获得最小数
* @param list
* @return
*/
public int min(LiangXiaoHu<E> list) {
int num=(int)list.get(0);
for (int i = 0; i < list.size(); i++) {
if(num>(int)list.get(i)){
num=(int)list.get(i);
}
}
return num;
}
/**
* 移除的方法
* @param i
*/
public void remove(int i) {
int index=0;
Object [] arr=new Object[num.length-1];
for (int j = 0; j < num.length; j++) {
if(i!=j){
arr[index]=num[j];
index++;
}
}
num=new Object[arr.length];
for (int j = 0; j < num.length; j++) {
num[j]=arr[j];
}
}
/**
* 排序的方法
* @param list
*/
public void sort(LiangXiaoHu<E> list) {
for (int i = 0; i < list.size(); i++) {
num[i]=list.get(i);
}
for(int i=0;i<num.length-1;i++){//外层循环控制排序趟数
for (int j = 0; j < num.length-1-i; j++) {
if((int)num[j]>(int)num[j+1]){
int temp=(int)num[j];
num[j]=num[j+1];
num[j+1]=temp;
}
}
}
}
}
| 2,537 | 0.475073 | 0.463343 | 138 | 15.297101 | 12.689954 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.384058 | false | false | 8 |
668144473901d640e9e0b20875c8ef6ac0d5e922 | 8,383,776,224,857 | 662dc3a12dfcc428e3006a3a613ae49adf8d2849 | /app/src/main/java/com/turing/turingsdksample/util/MyNetUtil.java | 05d03ce0c32b1b8adde35ff5cd362366d79072c5 | [] | no_license | tlq123/MySdkSampleJM | https://github.com/tlq123/MySdkSampleJM | 00b748b37220a7423af7e42bfef578ee1e572061 | 90d56351d73a3f5d4c96f1f31379b4fa04c36917 | refs/heads/master | 2020-04-12T15:10:51.114000 | 2019-03-02T02:49:38 | 2019-03-02T02:49:38 | 162,573,346 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.turing.turingsdksample.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 网络监测工具类
*
* @author :licheng@uzoo.com
**/
public class MyNetUtil {
public static boolean isNetWork = false ;// 没网络
/**
* 判断网络是否可用
*
* @return boolean
**/
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// if (cm == null) {
// } else {
// NetworkInfo[] info = cm.getAllNetworkInfo();
// if (info != null) {
// for (int i = 0; i < info.length; i++) {
// if (info[i].getState() == NetworkInfo.State.CONNECTED) {
// return true;
// }
// }
// }
// }
// return false;
// }
/*
判断网络是否可用 wifi
*/
public static boolean isNetworkAvailable2(Context context) {
if (context != null) {
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWiFiNetworkInfo = mConnectivityManager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWiFiNetworkInfo != null) {
return mWiFiNetworkInfo.isAvailable();
}
}
return false;
}
/* @author suncat
* @category 判断是否有外网连接(普通方法不能判断外网的网络是否连接,比如连接上局域网)
* @return
*/
public static boolean isNetworkAvailable(Context context) {
String result = null;
try {
long time =System.currentTimeMillis();
Logger.e("------ping-----", "time : " + time);
String ip = "www.baidu.com";// ping 的地址,可以换成任何一种可靠的外网
Process p = Runtime.getRuntime().exec("ping -c 3 -w 10 " + ip);//代表ping 3 次 超时时间为10秒
// 读取ping的内容,可以不加
InputStream input = p.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(input));
StringBuffer stringBuffer = new StringBuffer();
String content = "";
while ((content = in.readLine()) != null) {
stringBuffer.append(content);
}
Logger.e("------ping-----", "result content : " + stringBuffer.toString()+" time :" + (System.currentTimeMillis()-time));
// ping的状态
int status = p.waitFor();
Logger.e("------ping-----", "time : " + (System.currentTimeMillis()-time));
if (status == 0) {
result = "success";
isNetWork = true ;
return true;
} else {
result = "failed";
}
} catch (IOException e) {
result = "IOException";
} catch (InterruptedException e) {
result = "InterruptedException";
} finally {
Logger.e("----ping result---", "result = " + result);
}
isNetWork = false ;
return false;
}
/**
* 判断是否是3g
*
* @param context context
* @return boolean
**/
public static boolean is3rd(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_MOBILE) {
return true;
}
return false;
}
/**
* 判断是否是wifi
*
* @param context context
* @return boolean
**/
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}
/**
* 判断wifi是否打开
*
* @param context context
* @return boolean
**/
public static boolean isWifiEnabled(Context context) {
ConnectivityManager mgrConn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null
&& mgrConn.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED)
|| mgrTel.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
}
}
| UTF-8 | Java | 5,155 | java | MyNetUtil.java | Java | [
{
"context": "InputStreamReader;\n\n/**\n * 网络监测工具类\n *\n * @author :licheng@uzoo.com\n **/\npublic class MyNetUtil {\n\n public static ",
"end": 383,
"score": 0.9999135136604309,
"start": 367,
"tag": "EMAIL",
"value": "licheng@uzoo.com"
},
{
"context": " }\n return false;\n }\n\n /* @author suncat\n * @category 判断是否有外网连接(普通方法不能判断外网的网络是否连接,比如连接",
"end": 1720,
"score": 0.9991340637207031,
"start": 1714,
"tag": "USERNAME",
"value": "suncat"
}
] | null | [] | package com.turing.turingsdksample.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 网络监测工具类
*
* @author :<EMAIL>
**/
public class MyNetUtil {
public static boolean isNetWork = false ;// 没网络
/**
* 判断网络是否可用
*
* @return boolean
**/
// public static boolean isNetworkAvailable(Context context) {
// ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// if (cm == null) {
// } else {
// NetworkInfo[] info = cm.getAllNetworkInfo();
// if (info != null) {
// for (int i = 0; i < info.length; i++) {
// if (info[i].getState() == NetworkInfo.State.CONNECTED) {
// return true;
// }
// }
// }
// }
// return false;
// }
/*
判断网络是否可用 wifi
*/
public static boolean isNetworkAvailable2(Context context) {
if (context != null) {
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWiFiNetworkInfo = mConnectivityManager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWiFiNetworkInfo != null) {
return mWiFiNetworkInfo.isAvailable();
}
}
return false;
}
/* @author suncat
* @category 判断是否有外网连接(普通方法不能判断外网的网络是否连接,比如连接上局域网)
* @return
*/
public static boolean isNetworkAvailable(Context context) {
String result = null;
try {
long time =System.currentTimeMillis();
Logger.e("------ping-----", "time : " + time);
String ip = "www.baidu.com";// ping 的地址,可以换成任何一种可靠的外网
Process p = Runtime.getRuntime().exec("ping -c 3 -w 10 " + ip);//代表ping 3 次 超时时间为10秒
// 读取ping的内容,可以不加
InputStream input = p.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(input));
StringBuffer stringBuffer = new StringBuffer();
String content = "";
while ((content = in.readLine()) != null) {
stringBuffer.append(content);
}
Logger.e("------ping-----", "result content : " + stringBuffer.toString()+" time :" + (System.currentTimeMillis()-time));
// ping的状态
int status = p.waitFor();
Logger.e("------ping-----", "time : " + (System.currentTimeMillis()-time));
if (status == 0) {
result = "success";
isNetWork = true ;
return true;
} else {
result = "failed";
}
} catch (IOException e) {
result = "IOException";
} catch (InterruptedException e) {
result = "InterruptedException";
} finally {
Logger.e("----ping result---", "result = " + result);
}
isNetWork = false ;
return false;
}
/**
* 判断是否是3g
*
* @param context context
* @return boolean
**/
public static boolean is3rd(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_MOBILE) {
return true;
}
return false;
}
/**
* 判断是否是wifi
*
* @param context context
* @return boolean
**/
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}
/**
* 判断wifi是否打开
*
* @param context context
* @return boolean
**/
public static boolean isWifiEnabled(Context context) {
ConnectivityManager mgrConn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null
&& mgrConn.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED)
|| mgrTel.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
}
}
| 5,146 | 0.576774 | 0.574537 | 146 | 32.678082 | 29.339285 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.410959 | false | false | 8 |
7d24b0106c54bfd2fcdc122a60b991fe00ac7f8a | 22,582,938,059,904 | f2e6d23b4e34e3dc3b7c7830d9c7d3c523a82450 | /exercitii/lab3/src/classes/Cat.java | 44f1563baac75762026772a220ad61c129895c3d | [] | no_license | dianavasiliu10/PAO_lab | https://github.com/dianavasiliu10/PAO_lab | 7f203435bb16d6c9592173c0da616ebf2c118562 | d02d41fb932b81f07c06be75aa65dbcf0dc9ce14 | refs/heads/master | 2023-05-01T22:23:27.476000 | 2021-05-20T08:15:51 | 2021-05-20T08:15:51 | 341,927,022 | 0 | 0 | null | false | 2021-02-24T14:43:23 | 2021-02-24T14:29:28 | 2021-02-24T14:29:31 | 2021-02-24T14:43:21 | 0 | 0 | 0 | 0 | null | false | false | package classes;
public class Cat {
String name;
int age;
static int numberOfCats = 0;
public Cat() {
System.out.println("Constructor 1");
numberOfCats++;
}
public Cat(String name, int age) {
this.age = age;
this.name = name;
System.out.println("Constructor 2");
numberOfCats++;
}
public String displayDetails() {
return "Cat: name = " + this.name + " , age = " + this.age;
}
@Override
public String toString() {
return "Cat: name = " + this.name + " , age = " + this.age;
}
}
class MainCat{
public static void main(String[] args) {
System.out.println("numberOfCats = " + Cat.numberOfCats);
Cat cat = new Cat();
System.out.println("numberOfCats = " + Cat.numberOfCats);
Cat cat2 = new Cat("Tom", 4);
System.out.println("numberOfCats = " + Cat.numberOfCats);
System.out.println(cat.name);
System.out.println(cat.age);
System.out.println(cat2.name);
System.out.println(cat2.age);
cat.name = "Fluffy";
cat.age = 10;
System.out.println(cat.name);
System.out.println(cat.age);
System.out.println(cat2.displayDetails());
System.out.println(cat2);
}
}
| UTF-8 | Java | 1,303 | java | Cat.java | Java | [
{
"context": " + Cat.numberOfCats);\n Cat cat2 = new Cat(\"Tom\", 4);\n System.out.println(\"numberOfCats = ",
"end": 857,
"score": 0.9968410134315491,
"start": 854,
"tag": "NAME",
"value": "Tom"
},
{
"context": "System.out.println(cat2.age);\n cat.name = \"Fluffy\";\n cat.age = 10;\n System.out.printl",
"end": 1108,
"score": 0.9954854846000671,
"start": 1102,
"tag": "NAME",
"value": "Fluffy"
}
] | null | [] | package classes;
public class Cat {
String name;
int age;
static int numberOfCats = 0;
public Cat() {
System.out.println("Constructor 1");
numberOfCats++;
}
public Cat(String name, int age) {
this.age = age;
this.name = name;
System.out.println("Constructor 2");
numberOfCats++;
}
public String displayDetails() {
return "Cat: name = " + this.name + " , age = " + this.age;
}
@Override
public String toString() {
return "Cat: name = " + this.name + " , age = " + this.age;
}
}
class MainCat{
public static void main(String[] args) {
System.out.println("numberOfCats = " + Cat.numberOfCats);
Cat cat = new Cat();
System.out.println("numberOfCats = " + Cat.numberOfCats);
Cat cat2 = new Cat("Tom", 4);
System.out.println("numberOfCats = " + Cat.numberOfCats);
System.out.println(cat.name);
System.out.println(cat.age);
System.out.println(cat2.name);
System.out.println(cat2.age);
cat.name = "Fluffy";
cat.age = 10;
System.out.println(cat.name);
System.out.println(cat.age);
System.out.println(cat2.displayDetails());
System.out.println(cat2);
}
}
| 1,303 | 0.560246 | 0.551804 | 50 | 25.059999 | 20.228109 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62 | false | false | 8 |
ba3b17d4492a21fcb1d1c19719ef32a89ff2b56c | 19,490,561,589,399 | 80ca24337cc4501491fa944bbb98a3affc7b4cf2 | /src/LeetCode/Graphs/union_find/[721]Accounts Merge.java | 93663d2d01103796c6bbfbf83a7cf3664dea0371 | [] | no_license | RajeshAatrayan/InterviewPreparation | https://github.com/RajeshAatrayan/InterviewPreparation | 235661cb77c5d9002d0c0609f7840104882b776d | f93eebc44a0cf6094411c05c7989561b53da42bb | refs/heads/master | 2023-03-03T20:37:14.247000 | 2023-02-28T19:55:53 | 2023-02-28T19:55:53 | 197,302,550 | 3 | 4 | null | null | null | null | null | null | null | null | null | null | null | null | null | package LeetCode.Graphs.union_find;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
/**
* Given a list of accounts where each element accounts[i] is a list of strings,
* where the first element accounts[i][0] is a name, and the rest of the elements
* are emails representing emails of the account.
*
* Now, we would like to merge these accounts. Two accounts definitely belong to
* the same person if there is some common email to both accounts. Note that even
* if two accounts have the same name, they may belong to different people as people
* could have the same name. A person can have any number of accounts initially,
* but all of their accounts definitely have the same name.
*
* After merging the accounts, return the accounts in the following format: the
* first element of each account is the name, and the rest of the elements are
* emails in sorted order. The accounts themselves can be returned in any order.
*
*
* Example 1:
*
*
* Input: accounts = [["John","johnsmith@mail.com","john_newyork@mail.com"],[
* "John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John",
* "johnnybravo@mail.com"]]
* Output: [["John","john00@mail.com","john_newyork@mail.com","johnsmith@mail.com"]
* ,["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]
* Explanation:
* The first and second John's are the same person as they have the common email
* "johnsmith@mail.com".
* The third John and Mary are different people as none of their email addresses
* are used by other accounts.
* We could return these lists in any order, for example the answer [['Mary',
* 'mary@mail.com'], ['John', 'johnnybravo@mail.com'],
* ['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']]
* would still be accepted.
*
*
* Example 2:
*
*
* Input: accounts = [["Gabe","Gabe0@m.co","Gabe3@m.co","Gabe1@m.co"],["Kevin",
* "Kevin3@m.co","Kevin5@m.co","Kevin0@m.co"],["Ethan","Ethan5@m.co","Ethan4@m.co",
* "Ethan0@m.co"],["Hanzo","Hanzo3@m.co","Hanzo1@m.co","Hanzo0@m.co"],["Fern","Fern5@m.
* co","Fern1@m.co","Fern0@m.co"]]
* Output: [["Ethan","Ethan0@m.co","Ethan4@m.co","Ethan5@m.co"],["Gabe","Gabe0@m.
* co","Gabe1@m.co","Gabe3@m.co"],["Hanzo","Hanzo0@m.co","Hanzo1@m.co","Hanzo3@m.co"]
* ,["Kevin","Kevin0@m.co","Kevin3@m.co","Kevin5@m.co"],["Fern","Fern0@m.co","Fern1
*
* @m.co","Fern5@m.co"]] Constraints:
*
*
* 1 <= accounts.length <= 1000
* 2 <= accounts[i].length <= 10
* 1 <= accounts[i][j].length <= 30
* accounts[i][0] consists of English letters.
* accounts[i][j] (for j > 0) is a valid email.
*
*
* Related Topics Array String Depth-First Search Breadth-First Search Union Find
* 👍 5218 👎 899
*/
//leetcode submit region begin(Prohibit modification and deletion)
class Solution721 {
/**
* The idea is to create adjacencyMap using the emailIds and we have to perform the DFS on it to find the
* individual connected components.
*
* The adjacencyMap looks like the below:
* {johnnybravo@mail.com=[], johnsmith@mail.com=[john_newyork@mail.com, john00@mail.com], john00@mail.com=[johnsmith@mail.com], john_newyork@mail.com=[johnsmith@mail.com], mary@mail.com=[]}
*/
private HashMap<String, ArrayList<String>> adjacencyMap;
private HashSet<String> visited;
public List<List<String>> accountsMerge(List<List<String>> accounts) {
adjacencyMap = new HashMap<>();
visited = new HashSet<>();
for (List<String> account : accounts) {
buildAdjacencyMap(account);
}
List<List<String>> result = new ArrayList<>();
List<String> temp = new ArrayList<>();
for (List<String> account : accounts) {
String name = account.get(0);
String email = account.get(1);
if (!visited.contains(email)) {
dfs(email, temp);
temp.sort(null);
List<String> sortedList = new ArrayList<>();
sortedList.add(name);
sortedList.addAll(temp);
result.add(sortedList);
temp.clear();
}
}
return result;
}
private void dfs(String email, List<String> temp) {
visited.add(email);
temp.add(email);
for (String nextEmail : adjacencyMap.get(email)) {
if (!visited.contains(nextEmail))
dfs(nextEmail, temp);
}
}
private void buildAdjacencyMap(List<String> account) {
for (int i = 1; i < account.size(); i++) {
String current = account.get(i);
String next = (i + 1) < account.size() ? account.get(i + 1) : null;
if (adjacencyMap.get(current) == null) {
adjacencyMap.put(current, new ArrayList<>());
}
if (next != null)
adjacencyMap.get(current).add(next);
if (next != null && adjacencyMap.get(next) == null) {
adjacencyMap.put(next, new ArrayList<>());
adjacencyMap.get(next).add(current);
} else if (adjacencyMap.get(next) != null) {
adjacencyMap.get(next).add(current);
}
}
}
}
//leetcode submit region end(Prohibit modification and deletion)
| UTF-8 | Java | 5,312 | java | [721]Accounts Merge.java | Java | [
{
"context": " *\n *\n * Example 1:\n *\n *\n * Input: accounts = [[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\n",
"end": 1047,
"score": 0.9986649751663208,
"start": 1043,
"tag": "NAME",
"value": "John"
},
{
"context": "* Example 1:\n *\n *\n * Input: accounts = [[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\n * \"John\",\"johnsmith@",
"end": 1068,
"score": 0.999927818775177,
"start": 1050,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": " Input: accounts = [[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\n * \"John\",\"johnsmith@mail.com\",\"john00@mail.c",
"end": 1092,
"score": 0.9999268651008606,
"start": 1071,
"tag": "EMAIL",
"value": "john_newyork@mail.com"
},
{
"context": "ohnsmith@mail.com\",\"john_newyork@mail.com\"],[\n * \"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",",
"end": 1105,
"score": 0.9988082051277161,
"start": 1101,
"tag": "NAME",
"value": "John"
},
{
"context": "h@mail.com\",\"john_newyork@mail.com\"],[\n * \"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"Jo",
"end": 1126,
"score": 0.9999275207519531,
"start": 1108,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": "york@mail.com\"],[\n * \"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\n * \"johnnybra",
"end": 1144,
"score": 0.9999292492866516,
"start": 1129,
"tag": "EMAIL",
"value": "john00@mail.com"
},
{
"context": " \"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\n * \"johnnybravo@mail.c",
"end": 1153,
"score": 0.9997761249542236,
"start": 1149,
"tag": "NAME",
"value": "Mary"
},
{
"context": ",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\n * \"johnnybravo@mail.com\"]]\n * Output:",
"end": 1169,
"score": 0.9999274015426636,
"start": 1156,
"tag": "EMAIL",
"value": "mary@mail.com"
},
{
"context": "om\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\n * \"johnnybravo@mail.com\"]]\n * Output: [[\"John\"",
"end": 1178,
"score": 0.9972471594810486,
"start": 1174,
"tag": "NAME",
"value": "John"
},
{
"context": "@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\n * \"johnnybravo@mail.com\"]]\n * Output: [[\"John\",\"john00@mail.com\",\"john_ne",
"end": 1205,
"score": 0.9999276399612427,
"start": 1185,
"tag": "EMAIL",
"value": "johnnybravo@mail.com"
},
{
"context": "\"John\",\n * \"johnnybravo@mail.com\"]]\n * Output: [[\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johns",
"end": 1227,
"score": 0.99781733751297,
"start": 1223,
"tag": "NAME",
"value": "John"
},
{
"context": "\n * \"johnnybravo@mail.com\"]]\n * Output: [[\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johnsmith@mail.com\"]\n *",
"end": 1245,
"score": 0.9999297261238098,
"start": 1230,
"tag": "EMAIL",
"value": "john00@mail.com"
},
{
"context": "ail.com\"]]\n * Output: [[\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johnsmith@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com",
"end": 1269,
"score": 0.9999303817749023,
"start": 1248,
"tag": "EMAIL",
"value": "john_newyork@mail.com"
},
{
"context": "\"John\",\"john00@mail.com\",\"john_newyork@mail.com\",\"johnsmith@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybra",
"end": 1290,
"score": 0.9999290108680725,
"start": 1272,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": "ohn_newyork@mail.com\",\"johnsmith@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]",
"end": 1303,
"score": 0.9997175335884094,
"start": 1299,
"tag": "NAME",
"value": "Mary"
},
{
"context": "york@mail.com\",\"johnsmith@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\n * Explanation",
"end": 1319,
"score": 0.9999271631240845,
"start": 1306,
"tag": "EMAIL",
"value": "mary@mail.com"
},
{
"context": "hnsmith@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\n * Explanation:\n * The ",
"end": 1328,
"score": 0.996117353439331,
"start": 1324,
"tag": "NAME",
"value": "John"
},
{
"context": "@mail.com\"]\n * ,[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]\n * Explanation:\n * The first and second John's",
"end": 1351,
"score": 0.9999300241470337,
"start": 1331,
"tag": "EMAIL",
"value": "johnnybravo@mail.com"
},
{
"context": "the same person as they have the common email\n * \"johnsmith@mail.com\".\n * The third John and Mary are different people",
"end": 1474,
"score": 0.9999298453330994,
"start": 1456,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": "common email\n * \"johnsmith@mail.com\".\n * The third John and Mary are different people as none of their em",
"end": 1494,
"score": 0.9971289038658142,
"start": 1490,
"tag": "NAME",
"value": "John"
},
{
"context": "ail\n * \"johnsmith@mail.com\".\n * The third John and Mary are different people as none of their email addre",
"end": 1503,
"score": 0.9996172189712524,
"start": 1499,
"tag": "NAME",
"value": "Mary"
},
{
"context": "ese lists in any order, for example the answer [['Mary',\n * 'mary@mail.com'], ['John', 'johnnybravo@mail",
"end": 1664,
"score": 0.9996566772460938,
"start": 1660,
"tag": "NAME",
"value": "Mary"
},
{
"context": "n any order, for example the answer [['Mary',\n * 'mary@mail.com'], ['John', 'johnnybravo@mail.com'],\n * ['John', ",
"end": 1684,
"score": 0.9999256134033203,
"start": 1671,
"tag": "EMAIL",
"value": "mary@mail.com"
},
{
"context": "ample the answer [['Mary',\n * 'mary@mail.com'], ['John', 'johnnybravo@mail.com'],\n * ['John', 'john00@ma",
"end": 1694,
"score": 0.9981749057769775,
"start": 1690,
"tag": "NAME",
"value": "John"
},
{
"context": "e answer [['Mary',\n * 'mary@mail.com'], ['John', 'johnnybravo@mail.com'],\n * ['John', 'john00@mail.com', 'john_newyork@m",
"end": 1718,
"score": 0.9999312162399292,
"start": 1698,
"tag": "EMAIL",
"value": "johnnybravo@mail.com"
},
{
"context": "ail.com'], ['John', 'johnnybravo@mail.com'],\n * ['John', 'john00@mail.com', 'john_newyork@mail.com', 'jo",
"end": 1731,
"score": 0.9985108971595764,
"start": 1727,
"tag": "NAME",
"value": "John"
},
{
"context": "], ['John', 'johnnybravo@mail.com'],\n * ['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']]",
"end": 1750,
"score": 0.9999294281005859,
"start": 1735,
"tag": "EMAIL",
"value": "john00@mail.com"
},
{
"context": "bravo@mail.com'],\n * ['John', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']]\n * would still be accept",
"end": 1775,
"score": 0.9999294281005859,
"start": 1754,
"tag": "EMAIL",
"value": "john_newyork@mail.com"
},
{
"context": "hn', 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com']]\n * would still be accepted.\n *\n *\n * Example 2",
"end": 1797,
"score": 0.9999045729637146,
"start": 1779,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": " *\n *\n * Example 2:\n *\n *\n * Input: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\"",
"end": 1883,
"score": 0.9982610940933228,
"start": 1879,
"tag": "NAME",
"value": "Gabe"
},
{
"context": "* Example 2:\n *\n *\n * Input: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@",
"end": 1896,
"score": 0.999884307384491,
"start": 1886,
"tag": "EMAIL",
"value": "Gabe0@m.co"
},
{
"context": " *\n *\n * Input: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5",
"end": 1909,
"score": 0.9998880624771118,
"start": 1899,
"tag": "EMAIL",
"value": "Gabe3@m.co"
},
{
"context": "t: accounts = [[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin",
"end": 1922,
"score": 0.9998498558998108,
"start": 1912,
"tag": "EMAIL",
"value": "Gabe1@m.co"
},
{
"context": "[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[",
"end": 1932,
"score": 0.9981000423431396,
"start": 1927,
"tag": "NAME",
"value": "Kevin"
},
{
"context": "e0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.",
"end": 1950,
"score": 0.9998903274536133,
"start": 1939,
"tag": "EMAIL",
"value": "Kevin3@m.co"
},
{
"context": "3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.",
"end": 1964,
"score": 0.9998987317085266,
"start": 1953,
"tag": "EMAIL",
"value": "Kevin5@m.co"
},
{
"context": "@m.co\"],[\"Kevin\",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan",
"end": 1978,
"score": 0.9998979568481445,
"start": 1967,
"tag": "EMAIL",
"value": "Kevin0@m.co"
},
{
"context": ",\n * \"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[",
"end": 1988,
"score": 0.9980810880661011,
"start": 1983,
"tag": "NAME",
"value": "Ethan"
},
{
"context": "vin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo",
"end": 2002,
"score": 0.9998970627784729,
"start": 1991,
"tag": "EMAIL",
"value": "Ethan5@m.co"
},
{
"context": "vin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo",
"end": 2016,
"score": 0.9998995065689087,
"start": 2005,
"tag": "EMAIL",
"value": "Ethan4@m.co"
},
{
"context": "@m.co\"],[\"Ethan\",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.",
"end": 2034,
"score": 0.9998841285705566,
"start": 2023,
"tag": "EMAIL",
"value": "Ethan0@m.co"
},
{
"context": ",\"Ethan5@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fer",
"end": 2044,
"score": 0.9977257251739502,
"start": 2039,
"tag": "NAME",
"value": "Hanzo"
},
{
"context": "@m.co\",\"Ethan4@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n ",
"end": 2058,
"score": 0.9998941421508789,
"start": 2047,
"tag": "EMAIL",
"value": "Hanzo3@m.co"
},
{
"context": "@m.co\",\n * \"Ethan0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m",
"end": 2072,
"score": 0.999893069267273,
"start": 2061,
"tag": "EMAIL",
"value": "Hanzo1@m.co"
},
{
"context": "han0@m.co\"],[\"Hanzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m.co\",\"Fern0@m.",
"end": 2086,
"score": 0.999849259853363,
"start": 2075,
"tag": "EMAIL",
"value": "Hanzo0@m.co"
},
{
"context": "nzo\",\"Hanzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\n * ",
"end": 2095,
"score": 0.996399998664856,
"start": 2091,
"tag": "NAME",
"value": "Fern"
},
{
"context": "anzo3@m.co\",\"Hanzo1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\n * Output: [[\"Ethan\"",
"end": 2112,
"score": 0.9911547899246216,
"start": 2098,
"tag": "EMAIL",
"value": "Fern5@m.\n * co"
},
{
"context": "o1@m.co\",\"Hanzo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\n * Output: [[\"Ethan\",\"Ethan0@m.co",
"end": 2125,
"score": 0.9998308420181274,
"start": 2115,
"tag": "EMAIL",
"value": "Fern1@m.co"
},
{
"context": "zo0@m.co\"],[\"Fern\",\"Fern5@m.\n * co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\n * Output: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.c",
"end": 2138,
"score": 0.9998641014099121,
"start": 2128,
"tag": "EMAIL",
"value": "Fern0@m.co"
},
{
"context": "\n * co\",\"Fern1@m.co\",\"Fern0@m.co\"]]\n * Output: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gab",
"end": 2161,
"score": 0.9985584616661072,
"start": 2156,
"tag": "NAME",
"value": "Ethan"
},
{
"context": "\"Fern1@m.co\",\"Fern0@m.co\"]]\n * Output: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n ",
"end": 2175,
"score": 0.9998233914375305,
"start": 2164,
"tag": "EMAIL",
"value": "Ethan0@m.co"
},
{
"context": "Fern0@m.co\"]]\n * Output: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m",
"end": 2189,
"score": 0.999862790107727,
"start": 2178,
"tag": "EMAIL",
"value": "Ethan4@m.co"
},
{
"context": " * Output: [[\"Ethan\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.",
"end": 2203,
"score": 0.9998499155044556,
"start": 2192,
"tag": "EMAIL",
"value": "Ethan5@m.co"
},
{
"context": "han\",\"Ethan0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Ha",
"end": 2212,
"score": 0.9982995986938477,
"start": 2208,
"tag": "NAME",
"value": "Gabe"
},
{
"context": "than0@m.co\",\"Ethan4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co",
"end": 2229,
"score": 0.9511270523071289,
"start": 2215,
"tag": "EMAIL",
"value": "Gabe0@m.\n * co"
},
{
"context": "n4@m.co\",\"Ethan5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.c",
"end": 2242,
"score": 0.999836266040802,
"start": 2232,
"tag": "EMAIL",
"value": "Gabe1@m.co"
},
{
"context": "an5@m.co\"],[\"Gabe\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.",
"end": 2255,
"score": 0.9998486638069153,
"start": 2245,
"tag": "EMAIL",
"value": "Gabe3@m.co"
},
{
"context": "be\",\"Gabe0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[",
"end": 2265,
"score": 0.9973520636558533,
"start": 2260,
"tag": "NAME",
"value": "Hanzo"
},
{
"context": "e0@m.\n * co\",\"Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin",
"end": 2279,
"score": 0.9998623728752136,
"start": 2268,
"tag": "EMAIL",
"value": "Hanzo0@m.co"
},
{
"context": "Gabe1@m.co\",\"Gabe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin",
"end": 2293,
"score": 0.9998723268508911,
"start": 2282,
"tag": "EMAIL",
"value": "Hanzo1@m.co"
},
{
"context": "abe3@m.co\"],[\"Hanzo\",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin",
"end": 2307,
"score": 0.9998798370361328,
"start": 2296,
"tag": "EMAIL",
"value": "Hanzo3@m.co"
},
{
"context": ",\"Hanzo0@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fer",
"end": 2321,
"score": 0.9989145398139954,
"start": 2316,
"tag": "NAME",
"value": "Kevin"
},
{
"context": "@m.co\",\"Hanzo1@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co",
"end": 2335,
"score": 0.9998946785926819,
"start": 2324,
"tag": "EMAIL",
"value": "Kevin0@m.co"
},
{
"context": "@m.co\",\"Hanzo3@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n *",
"end": 2349,
"score": 0.9999025464057922,
"start": 2338,
"tag": "EMAIL",
"value": "Kevin3@m.co"
},
{
"context": "@m.co\"]\n * ,[\"Kevin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n * @m.co\",\"Fern5",
"end": 2363,
"score": 0.9998856782913208,
"start": 2352,
"tag": "EMAIL",
"value": "Kevin5@m.co"
},
{
"context": "vin\",\"Kevin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n * @m.co\",\"Fern5@m.co\"]] ",
"end": 2372,
"score": 0.9982465505599976,
"start": 2368,
"tag": "NAME",
"value": "Fern"
},
{
"context": "evin0@m.co\",\"Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n * @m.co\",\"Fern5@m.co\"]] Constraints:\n",
"end": 2385,
"score": 0.9998754262924194,
"start": 2375,
"tag": "EMAIL",
"value": "Fern0@m.co"
},
{
"context": "Kevin3@m.co\",\"Kevin5@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n * @m.co\",\"Fern5@m.co\"]] Constraints:\n *\n *\n * 1 <= accoun",
"end": 2405,
"score": 0.901681661605835,
"start": 2388,
"tag": "EMAIL",
"value": "Fern1\n *\n * @m.co"
},
{
"context": "@m.co\"],[\"Fern\",\"Fern0@m.co\",\"Fern1\n *\n * @m.co\",\"Fern5@m.co\"]] Constraints:\n *\n *\n * 1 <= accounts.length <= ",
"end": 2418,
"score": 0.9998661875724792,
"start": 2408,
"tag": "EMAIL",
"value": "Fern5@m.co"
},
{
"context": " * The adjacencyMap looks like the below:\n * {johnnybravo@mail.com=[], johnsmith@mail.com=[john_newyork@mail.com, jo",
"end": 3072,
"score": 0.9999245405197144,
"start": 3052,
"tag": "EMAIL",
"value": "johnnybravo@mail.com"
},
{
"context": "s like the below:\n * {johnnybravo@mail.com=[], johnsmith@mail.com=[john_newyork@mail.com, john00@mail.com], john00@",
"end": 3095,
"score": 0.99992436170578,
"start": 3077,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": " * {johnnybravo@mail.com=[], johnsmith@mail.com=[john_newyork@mail.com, john00@mail.com], john00@mail.com=[johnsmith@mai",
"end": 3118,
"score": 0.9999302625656128,
"start": 3097,
"tag": "EMAIL",
"value": "john_newyork@mail.com"
},
{
"context": "com=[], johnsmith@mail.com=[john_newyork@mail.com, john00@mail.com], john00@mail.com=[johnsmith@mail.com], john_newy",
"end": 3135,
"score": 0.9999271631240845,
"start": 3120,
"tag": "EMAIL",
"value": "john00@mail.com"
},
{
"context": "mail.com=[john_newyork@mail.com, john00@mail.com], john00@mail.com=[johnsmith@mail.com], john_newyork@mail.com=[john",
"end": 3153,
"score": 0.9999243021011353,
"start": 3138,
"tag": "EMAIL",
"value": "john00@mail.com"
},
{
"context": "york@mail.com, john00@mail.com], john00@mail.com=[johnsmith@mail.com], john_newyork@mail.com=[johnsmith@mail.com], mar",
"end": 3173,
"score": 0.9999292492866516,
"start": 3155,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": "0@mail.com], john00@mail.com=[johnsmith@mail.com], john_newyork@mail.com=[johnsmith@mail.com], mary@mail.com=[]}\n */\n ",
"end": 3197,
"score": 0.999925434589386,
"start": 3176,
"tag": "EMAIL",
"value": "john_newyork@mail.com"
},
{
"context": ".com=[johnsmith@mail.com], john_newyork@mail.com=[johnsmith@mail.com], mary@mail.com=[]}\n */\n private HashMap<S",
"end": 3217,
"score": 0.9999275207519531,
"start": 3199,
"tag": "EMAIL",
"value": "johnsmith@mail.com"
},
{
"context": ".com], john_newyork@mail.com=[johnsmith@mail.com], mary@mail.com=[]}\n */\n private HashMap<String, ArrayList",
"end": 3233,
"score": 0.9999175071716309,
"start": 3220,
"tag": "EMAIL",
"value": "mary@mail.com"
}
] | null | [] | package LeetCode.Graphs.union_find;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
/**
* Given a list of accounts where each element accounts[i] is a list of strings,
* where the first element accounts[i][0] is a name, and the rest of the elements
* are emails representing emails of the account.
*
* Now, we would like to merge these accounts. Two accounts definitely belong to
* the same person if there is some common email to both accounts. Note that even
* if two accounts have the same name, they may belong to different people as people
* could have the same name. A person can have any number of accounts initially,
* but all of their accounts definitely have the same name.
*
* After merging the accounts, return the accounts in the following format: the
* first element of each account is the name, and the rest of the elements are
* emails in sorted order. The accounts themselves can be returned in any order.
*
*
* Example 1:
*
*
* Input: accounts = [["John","<EMAIL>","<EMAIL>"],[
* "John","<EMAIL>","<EMAIL>"],["Mary","<EMAIL>"],["John",
* "<EMAIL>"]]
* Output: [["John","<EMAIL>","<EMAIL>","<EMAIL>"]
* ,["Mary","<EMAIL>"],["John","<EMAIL>"]]
* Explanation:
* The first and second John's are the same person as they have the common email
* "<EMAIL>".
* The third John and Mary are different people as none of their email addresses
* are used by other accounts.
* We could return these lists in any order, for example the answer [['Mary',
* '<EMAIL>'], ['John', '<EMAIL>'],
* ['John', '<EMAIL>', '<EMAIL>', '<EMAIL>']]
* would still be accepted.
*
*
* Example 2:
*
*
* Input: accounts = [["Gabe","<EMAIL>","<EMAIL>","<EMAIL>"],["Kevin",
* "<EMAIL>","<EMAIL>","<EMAIL>"],["Ethan","<EMAIL>","<EMAIL>",
* "<EMAIL>"],["Hanzo","<EMAIL>","<EMAIL>","<EMAIL>"],["Fern","<EMAIL>","<EMAIL>","<EMAIL>"]]
* Output: [["Ethan","<EMAIL>","<EMAIL>","<EMAIL>"],["Gabe","<EMAIL>","<EMAIL>","<EMAIL>"],["Hanzo","<EMAIL>","<EMAIL>","<EMAIL>"]
* ,["Kevin","<EMAIL>","<EMAIL>","<EMAIL>"],["Fern","<EMAIL>","<EMAIL>","<EMAIL>"]] Constraints:
*
*
* 1 <= accounts.length <= 1000
* 2 <= accounts[i].length <= 10
* 1 <= accounts[i][j].length <= 30
* accounts[i][0] consists of English letters.
* accounts[i][j] (for j > 0) is a valid email.
*
*
* Related Topics Array String Depth-First Search Breadth-First Search Union Find
* 👍 5218 👎 899
*/
//leetcode submit region begin(Prohibit modification and deletion)
class Solution721 {
/**
* The idea is to create adjacencyMap using the emailIds and we have to perform the DFS on it to find the
* individual connected components.
*
* The adjacencyMap looks like the below:
* {<EMAIL>=[], <EMAIL>=[<EMAIL>, <EMAIL>], <EMAIL>=[<EMAIL>], <EMAIL>=[<EMAIL>], <EMAIL>=[]}
*/
private HashMap<String, ArrayList<String>> adjacencyMap;
private HashSet<String> visited;
public List<List<String>> accountsMerge(List<List<String>> accounts) {
adjacencyMap = new HashMap<>();
visited = new HashSet<>();
for (List<String> account : accounts) {
buildAdjacencyMap(account);
}
List<List<String>> result = new ArrayList<>();
List<String> temp = new ArrayList<>();
for (List<String> account : accounts) {
String name = account.get(0);
String email = account.get(1);
if (!visited.contains(email)) {
dfs(email, temp);
temp.sort(null);
List<String> sortedList = new ArrayList<>();
sortedList.add(name);
sortedList.addAll(temp);
result.add(sortedList);
temp.clear();
}
}
return result;
}
private void dfs(String email, List<String> temp) {
visited.add(email);
temp.add(email);
for (String nextEmail : adjacencyMap.get(email)) {
if (!visited.contains(nextEmail))
dfs(nextEmail, temp);
}
}
private void buildAdjacencyMap(List<String> account) {
for (int i = 1; i < account.size(); i++) {
String current = account.get(i);
String next = (i + 1) < account.size() ? account.get(i + 1) : null;
if (adjacencyMap.get(current) == null) {
adjacencyMap.put(current, new ArrayList<>());
}
if (next != null)
adjacencyMap.get(current).add(next);
if (next != null && adjacencyMap.get(next) == null) {
adjacencyMap.put(next, new ArrayList<>());
adjacencyMap.get(next).add(current);
} else if (adjacencyMap.get(next) != null) {
adjacencyMap.get(next).add(current);
}
}
}
}
//leetcode submit region end(Prohibit modification and deletion)
| 4,915 | 0.620053 | 0.606672 | 133 | 38.894737 | 31.744577 | 193 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.857143 | false | false | 8 |
c999bccf9137b5c0e66b8164c9578d1bcfb3528c | 4,810,363,399,381 | 14fc62bed9893087e1943f5f0dbb4cc43a77fc90 | /src/main/java/com/johe/api/pump/ApiPumpApplication.java | 0d737b159a1b45c61cd60b28cc16f1f438473a64 | [] | no_license | gitjgy/api-pump | https://github.com/gitjgy/api-pump | 3676a72634141546c4beeb29e60a4ae5e55c808d | 3d19b35f5698612ba12d3b8e985b6b415541d4a6 | refs/heads/master | 2021-01-24T11:49:22.937000 | 2018-08-01T06:43:40 | 2018-08-01T06:43:40 | 123,106,319 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.johe.api.pump;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.johe.api.pump.service.impl.UserDetailsServiceImpl;
@EnableTransactionManagement
@SpringBootApplication
//public class ApiPumpApplication {// jar运行测试
public class ApiPumpApplication extends SpringBootServletInitializer {//=====================================打war包
//
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ApiPumpApplication.class);
}
//====================================END WAR
public static void main(String[] args) {
SpringApplication.run(ApiPumpApplication.class, args);
}
@Bean
public BCryptPasswordEncoder bcryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public UserDetailsService userDetailsService() {
return new UserDetailsServiceImpl();
}
}
| UTF-8 | Java | 1,365 | java | ApiPumpApplication.java | Java | [] | null | [] | package com.johe.api.pump;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.johe.api.pump.service.impl.UserDetailsServiceImpl;
@EnableTransactionManagement
@SpringBootApplication
//public class ApiPumpApplication {// jar运行测试
public class ApiPumpApplication extends SpringBootServletInitializer {//=====================================打war包
//
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ApiPumpApplication.class);
}
//====================================END WAR
public static void main(String[] args) {
SpringApplication.run(ApiPumpApplication.class, args);
}
@Bean
public BCryptPasswordEncoder bcryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public UserDetailsService userDetailsService() {
return new UserDetailsServiceImpl();
}
}
| 1,365 | 0.792313 | 0.792313 | 37 | 35.567566 | 30.464458 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.027027 | false | false | 8 |
1c317f6e5077db5d01656713fc55db4a98cd5258 | 22,376,779,663,152 | 8975c110eb3a9bd7629992521f3f2b6929cbf9a3 | /SAS_HospitalManagement/src/main/java/com/inno/SAS_HospitalManagement/controller/EmployeeController.java | 8af0d9a636a18fcb14297614b7b199a04e8142d9 | [] | no_license | saathwika-25/Hospital_Management | https://github.com/saathwika-25/Hospital_Management | c4a722decfbce6d8eb42fc71bfebea443c6f6470 | 03e6fc560981852f0db2b8183513352a59fcf693 | refs/heads/main | 2023-06-29T21:45:03.307000 | 2021-08-02T05:55:12 | 2021-08-02T05:55:12 | 390,775,686 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.inno.SAS_HospitalManagement.controller;
import java.sql.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.inno.SAS_HospitalManagement.model.Employee;
import com.inno.SAS_HospitalManagement.service.EmployeeService;
@RestController
@RequestMapping("/hospital/admin")
public class EmployeeController {
@Autowired
EmployeeService employeeService;
@PostMapping(path = "hire", consumes = MediaType.APPLICATION_JSON_VALUE)
private String hireEmployee(@RequestBody Employee employee)
{
Date joinDate = new Date(System.currentTimeMillis());
employee.setJoinDate(joinDate);
employeeService.hireEmployee(employee);
return "successful";
}
@PutMapping(path = "updateemployee", consumes = MediaType.APPLICATION_JSON_VALUE)
public String updateEmployee(@RequestBody Employee employee)
{
Date joinDate = new Date(System.currentTimeMillis());
employee.setJoinDate(joinDate);
employeeService.updateEmployee(employee);
return "update successful";
}
@DeleteMapping(path="fire")
public String fireEmployee(@RequestParam String emp_id)
{
employeeService.fireEmployee(emp_id);
return "Deleted Successfully";
}
} | UTF-8 | Java | 1,647 | java | EmployeeController.java | Java | [] | null | [] | package com.inno.SAS_HospitalManagement.controller;
import java.sql.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.inno.SAS_HospitalManagement.model.Employee;
import com.inno.SAS_HospitalManagement.service.EmployeeService;
@RestController
@RequestMapping("/hospital/admin")
public class EmployeeController {
@Autowired
EmployeeService employeeService;
@PostMapping(path = "hire", consumes = MediaType.APPLICATION_JSON_VALUE)
private String hireEmployee(@RequestBody Employee employee)
{
Date joinDate = new Date(System.currentTimeMillis());
employee.setJoinDate(joinDate);
employeeService.hireEmployee(employee);
return "successful";
}
@PutMapping(path = "updateemployee", consumes = MediaType.APPLICATION_JSON_VALUE)
public String updateEmployee(@RequestBody Employee employee)
{
Date joinDate = new Date(System.currentTimeMillis());
employee.setJoinDate(joinDate);
employeeService.updateEmployee(employee);
return "update successful";
}
@DeleteMapping(path="fire")
public String fireEmployee(@RequestParam String emp_id)
{
employeeService.fireEmployee(emp_id);
return "Deleted Successfully";
}
} | 1,647 | 0.811779 | 0.811779 | 49 | 32.632652 | 25.327805 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.285714 | false | false | 8 |
9c4980ff18c2f0c1b313ed75bedd2f89783501ba | 32,770,600,527,562 | df6d7d68bda7f8f74ea4f09e2e8b973f303b78fa | /chassis/util/src/main/java/com/griddynamics/jagger/util/MetricNamesRankingProvider.java | 100cbc1c644d170723ad8df5119411aaa890cf3f | [
"Apache-2.0"
] | permissive | ehabibov/jagger | https://github.com/ehabibov/jagger | a4d2e45210f814b00b716ad6abdb034afe9bf7c0 | 70e6ff532fadce0a4aec10e2bb5941e557bbc97b | refs/heads/master | 2020-04-26T18:24:22.347000 | 2018-03-12T13:41:04 | 2018-03-12T13:41:04 | 173,744,024 | 0 | 0 | Apache-2.0 | true | 2019-03-04T12:50:21 | 2019-03-04T12:50:21 | 2018-10-16T10:56:56 | 2018-03-12T13:40:15 | 51,736 | 0 | 0 | 0 | null | false | null | package com.griddynamics.jagger.util;
import java.util.Arrays;
import java.util.List;
public class MetricNamesRankingProvider {
private static List<String> patterns = Arrays.asList(
"^" + StandardMetricsNamesUtil.ITERATIONS_SAMPLES + ".*",
"^" + StandardMetricsNamesUtil.DURATION_SEC + ".*",
"^" + StandardMetricsNamesUtil.THROUGHPUT + ".*",
"^" + StandardMetricsNamesUtil.LATENCY_SEC + ".*",
"^" + StandardMetricsNamesUtil.LATENCY_STD_DEV_SEC + ".*",
"^" + StandardMetricsNamesUtil.TIME_LATENCY_PERCENTILE + ".*",
"^" + StandardMetricsNamesUtil.SUCCESS_RATE + ".*"
);
protected static int compare(String o1, String o2){
Comparable o1Rank = getRank(o1);
Comparable o2Rank = getRank(o2);
if (o1Rank.compareTo(0)==0 && o2Rank.compareTo(0)==0){
// display names, not matched to pattern above
int res = String.CASE_INSENSITIVE_ORDER.compare(o1,o2);
return (res != 0) ? res : o1.compareTo(o2);
}
if (o1Rank.compareTo(o2Rank)==0){
return o1.compareTo(o2);
}
return o1Rank.compareTo(o2Rank);
}
protected static Comparable getRank(String o){
int rank = 0;
for (String pattern : patterns){
if (o.matches(pattern)){
return new Integer(-patterns.size()+rank);
}
rank++;
}
return 0;
}
}
| UTF-8 | Java | 1,475 | java | MetricNamesRankingProvider.java | Java | [] | null | [] | package com.griddynamics.jagger.util;
import java.util.Arrays;
import java.util.List;
public class MetricNamesRankingProvider {
private static List<String> patterns = Arrays.asList(
"^" + StandardMetricsNamesUtil.ITERATIONS_SAMPLES + ".*",
"^" + StandardMetricsNamesUtil.DURATION_SEC + ".*",
"^" + StandardMetricsNamesUtil.THROUGHPUT + ".*",
"^" + StandardMetricsNamesUtil.LATENCY_SEC + ".*",
"^" + StandardMetricsNamesUtil.LATENCY_STD_DEV_SEC + ".*",
"^" + StandardMetricsNamesUtil.TIME_LATENCY_PERCENTILE + ".*",
"^" + StandardMetricsNamesUtil.SUCCESS_RATE + ".*"
);
protected static int compare(String o1, String o2){
Comparable o1Rank = getRank(o1);
Comparable o2Rank = getRank(o2);
if (o1Rank.compareTo(0)==0 && o2Rank.compareTo(0)==0){
// display names, not matched to pattern above
int res = String.CASE_INSENSITIVE_ORDER.compare(o1,o2);
return (res != 0) ? res : o1.compareTo(o2);
}
if (o1Rank.compareTo(o2Rank)==0){
return o1.compareTo(o2);
}
return o1Rank.compareTo(o2Rank);
}
protected static Comparable getRank(String o){
int rank = 0;
for (String pattern : patterns){
if (o.matches(pattern)){
return new Integer(-patterns.size()+rank);
}
rank++;
}
return 0;
}
}
| 1,475 | 0.574237 | 0.55661 | 41 | 34.975609 | 23.988298 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.560976 | false | false | 8 |
c7b0c50890c305bccd9a1c38a175ef9211445789 | 17,102,559,793,245 | b150e83f4f0c672b74e92da3d4c9e45e619db6fb | /app/src/main/java/org/akoraingdkb/foodorder/MainActivity.java | 7e611d60f4d764b7133267291f78819c81ba84c2 | [] | no_license | Akora-IngDKB/Food-Rank | https://github.com/Akora-IngDKB/Food-Rank | 0b649edd9fbdce217dd99f0f1e1a98dc85061210 | 66e3ff55134e24430ea48bf24415289433094e24 | refs/heads/master | 2021-07-02T19:54:08.309000 | 2020-10-26T10:35:46 | 2020-10-26T10:35:46 | 171,108,582 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.akoraingdkb.foodorder;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.amulyakhare.textdrawable.TextDrawable;
import com.android.volley.Cache;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.JsonArrayRequest;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.miguelcatalan.materialsearchview.MaterialSearchView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static com.miguelcatalan.materialsearchview.MaterialSearchView.REQUEST_VOICE;
public class MainActivity extends AppCompatActivity implements FoodAdapter.CardClickListener, BottomSheetFragment.OnAddToCartBtnClickListener {
private DrawerLayout mDrawerLayout;
private NavigationView mNavigationView;
private MaterialSearchView mSearchView;
private ImageView mNavProfileImg;
private TextView mNavUsername;
private TextView mNavUserEmail;
private AHBottomNavigation bottomNavigation;
private List<FoodItem> mFoodList;
private FoodAdapter mFoodAdapter;
private BottomSheetFragment bottomSheetFragment;
public static FoodItem currentFoodItem;
private String[] searchSuggestions = new String[10];
private FirebaseUser mCurrentUser;
private SharedPreferences mSharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create an instance of the FireBase User
mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
setContentView(R.layout.activity_main);
mSharedPreferences = getSharedPreferences(getString(R.string.pref_file_name), Context.MODE_PRIVATE);
// Check if the user is logged in and fetch user info
if (mCurrentUser == null) {
storeSignOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
MainActivity.this.finish();
}
// Prepare the food list to be inflated
prepareFoodList();
Toolbar toolbar = findViewById(R.id.toolbar);
mDrawerLayout = findViewById(R.id.drawer_layout);
mNavigationView = findViewById(R.id.nav_view);
mSearchView = findViewById(R.id.search_view);
bottomNavigation = findViewById(R.id.bottom_nav);
RecyclerView mRecyclerView = findViewById(R.id.recycler_view);
// Configure the Toolbar
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_24dp);
}
// Create items
AHBottomNavigationItem itemCart = new AHBottomNavigationItem(R.string.bottom_nav_cart, R.drawable.ic_shopping_cart_24dp, R.color.colorAccentFirebase);
bottomNavigation.addItem(itemCart);
// Configure the DrawerLayout
configureDrawerLayout();
// Configure the Navigation View
configureNavigationView();
// Update Profile info in the nav header
updateUserInfoInNavHeader();
// Setup the Recycler View
mFoodAdapter = new FoodAdapter(this, mFoodList);
mFoodAdapter.setCardClickListener(this);
// Setup the recycler view layout manager
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, dpToPx(), true));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setAdapter(mFoodAdapter);
// Configure the Material Search View
configureMaterialSearchView();
configureBottomNavigation();
bottomSheetFragment = new BottomSheetFragment();
getCartItemCount();
}
private void configureBottomNavigation() {
// Force to tint the drawable (useful for font with icon for example)
bottomNavigation.setForceTint(true);
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
// Use colored navigation with circle reveal effect
bottomNavigation.setColored(true);
// Set current item programmatically
bottomNavigation.setCurrentItem(1);
if (FoodAdapter.count > 0)
setCartNotification(FoodAdapter.count);
// Set listeners
bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public boolean onTabSelected(int position, boolean wasSelected) {
Toast.makeText(MainActivity.this, FoodAdapter.count + " items in cart", Toast.LENGTH_SHORT).show();
return true;
}
});
}
void setCartNotification(int num) {
bottomNavigation.setNotification("" + num, 0);
}
private void updateUserInfoInNavHeader() {
if (FirebaseAuth.getInstance().getCurrentUser() != null) {
String name = FirebaseAuth.getInstance().getCurrentUser().getDisplayName();
String firstLetter = "";
if (name != null)
firstLetter = name.substring(0, 1);
TextDrawable textDrawable = TextDrawable.builder().buildRound(firstLetter, getResources().getColor(R.color.royal_blue));
mNavProfileImg.setImageDrawable(textDrawable);
// Change the user name to the signed in user display name
mNavUsername.setText(mCurrentUser.getDisplayName());
// Change the user email to the signed in email
mNavUserEmail.setText(mCurrentUser.getEmail());
}
}
private void configureMaterialSearchView() {
//mSearchView.setEllipsize(true); // Not available in 1.3.0
mSearchView.setHint("Search for an item...");
mSearchView.setSuggestions(searchSuggestions);
mSearchView.setVoiceSearch(true); // Activate voice search
mSearchView.setVoiceIcon(getResources().getDrawable(R.drawable.ic_action_voice_search));
mSearchView.closeSearch(); // Close search view by default
// Set Query Text Listener
mSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
mFoodAdapter.getFilter().filter(query);
mSearchView.closeSearch();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
mFoodAdapter.getFilter().filter(newText);
return true;
}
});
// Set Search View Listener
mSearchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
mSearchView.showSuggestions();
}
@Override
public void onSearchViewClosed() {
hideKeyboard();
}
});
}
private void configureNavigationView() {
// Create an object of the nav header and find the various widgets
View navHeader = mNavigationView.getHeaderView(0);
mNavProfileImg = navHeader.findViewById(R.id.nav_profile_img);
mNavUsername = navHeader.findViewById(R.id.nav_user_name);
mNavUserEmail = navHeader.findViewById(R.id.nav_email);
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
if (menuItem.getItemId() == R.id.nav_sign_out) {
// Check if user is already signed in
if (mCurrentUser != null) {
// Sign out the user
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signOut();
// Take user to the login page
storeSignOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
MainActivity.this.finish();
}
}
// Add code here to update the UI based on the item selected
// For example, swap UI fragments here
return true;
}
});
}
private void configureDrawerLayout() {
mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(@NonNull View view, float v) {
if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
}
@Override
public void onDrawerOpened(@NonNull View view) {
// Respond when the drawer is opened
if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
invalidateOptionsMenu();
hideKeyboard();
}
@Override
public void onDrawerClosed(@NonNull View view) {
// Respond when the drawer is closed
}
@Override
public void onDrawerStateChanged(int i) {
// Respond when the drawer motion state changes
}
});
}
// Reads the food items from the JSON file
private void prepareFoodList() {
mFoodList = new ArrayList<>();
String jsonUrl = "https://jsonblob.com/api/jsonBlob/a90254ad-3670-11e9-9056-e12fdc2cad95";
RequestQueue requestQueue;
// Instantiate the cache
Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap
// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());
// Instantiate the RequestQueue with the cache and network.
requestQueue = new RequestQueue(cache, network);
// Start the queue
requestQueue.start();
// Formulate the request and handle the response
JsonArrayRequest jsonObjectRequest = new JsonArrayRequest(
Request.Method.GET,
jsonUrl,
null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (response.length() > 0) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject foodObject = response.getJSONObject(i);
mFoodList.add(new FoodItem(
foodObject.getString("name"),
foodObject.getString("price"),
foodObject.getInt("rating"),
foodObject.getString("imageUrl")
));
searchSuggestions[i] = foodObject.getString("name");
mFoodAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
Log.i("JSON_Error", e.getMessage());
}
}
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
// Add the request to the queue
requestQueue.add(jsonObjectRequest);
}
private int dpToPx() {
Resources r = getResources();
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()));
}
// Hides the soft input touch when called
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mDrawerLayout.getWindowToken(), 0);
}
// This method is called when the user signs out from the nav drawer
private void storeSignOut() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(getString(R.string.user_signed_out), true);
editor.apply();
}
// Save the number of items in cart in the SP API
private void storeCartCount() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putInt("cart_count", FoodAdapter.count);
editor.apply();
}
// Read the number of items in cart stored in the SP API
private int readCartCount() {
return mSharedPreferences.getInt("cart_count", 0);
}
// Writes the number of items in the cart to the user's database
private void putCartItemCount() {
// Get a reference to the database node to read cart item count
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
// Write the value
mDatabase.child(mCurrentUser.getUid()).child("cart_count")
.setValue(readCartCount())
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
getCartItemCount(); // Call method to update the bottom nav
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "Failed to update cart count", Toast.LENGTH_SHORT).show();
}
});
}
// Reads the number of items in the cart from the user's database
private void getCartItemCount() {
// Get a reference to the database node to read cart item count
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
// Read the value
mDatabase.child(mCurrentUser.getUid()).child("cart_count").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Integer count = dataSnapshot.getValue(Integer.class);
if (count != null && count > 0)
setCartNotification(count); // Set item count to bottom nav
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(MainActivity.this, "Operation cancelled: "+databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == REQUEST_VOICE && resultCode == RESULT_OK) {
if (data != null) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (matches != null && matches.size() > 0) {
String searchWrd = matches.get(0);
if (!TextUtils.isEmpty(searchWrd)) {
mSearchView.setQuery(searchWrd, false);
}
}
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
MenuItem menuItem = menu.findItem(R.id.menu_search);
mSearchView.setMenuItem(menuItem);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
mDrawerLayout.openDrawer(GravityCompat.START);
invalidateOptionsMenu();
return true;
case R.id.menu_search:
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
mDrawerLayout.closeDrawers();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
mDrawerLayout.closeDrawers();
else if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
else
super.onBackPressed();
}
@Override
public void cardClicked(View view, int position) {
// Handle card clicked events over here
currentFoodItem = mFoodList.get(position);
bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
}
@Override
public void onAddToCartBtnClick() {
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
mDatabase.child(mCurrentUser.getUid())
.child(currentFoodItem.getName())
.setValue(currentFoodItem)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
storeCartCount(); // Store cart item count in SP API
putCartItemCount(); // Write stored value to the database
Toast.makeText(MainActivity.this, currentFoodItem.getName() + " added to Cart", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "" + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
| UTF-8 | Java | 20,126 | java | MainActivity.java | Java | [
{
"context": "erview.widget.RecyclerView;\n\nimport static com.miguelcatalan.materialsearchview.MaterialSearchView.REQUEST_VOI",
"end": 2377,
"score": 0.5723991990089417,
"start": 2367,
"tag": "USERNAME",
"value": "uelcatalan"
},
{
"context": "avUsername = navHeader.findViewById(R.id.nav_user_name);\n mNavUserEmail = navHeader.findViewById(",
"end": 9314,
"score": 0.5249834656715393,
"start": 9310,
"tag": "USERNAME",
"value": "name"
}
] | null | [] | package org.akoraingdkb.foodorder;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.amulyakhare.textdrawable.TextDrawable;
import com.android.volley.Cache;
import com.android.volley.Network;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.JsonArrayRequest;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.miguelcatalan.materialsearchview.MaterialSearchView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import static com.miguelcatalan.materialsearchview.MaterialSearchView.REQUEST_VOICE;
public class MainActivity extends AppCompatActivity implements FoodAdapter.CardClickListener, BottomSheetFragment.OnAddToCartBtnClickListener {
private DrawerLayout mDrawerLayout;
private NavigationView mNavigationView;
private MaterialSearchView mSearchView;
private ImageView mNavProfileImg;
private TextView mNavUsername;
private TextView mNavUserEmail;
private AHBottomNavigation bottomNavigation;
private List<FoodItem> mFoodList;
private FoodAdapter mFoodAdapter;
private BottomSheetFragment bottomSheetFragment;
public static FoodItem currentFoodItem;
private String[] searchSuggestions = new String[10];
private FirebaseUser mCurrentUser;
private SharedPreferences mSharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create an instance of the FireBase User
mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
setContentView(R.layout.activity_main);
mSharedPreferences = getSharedPreferences(getString(R.string.pref_file_name), Context.MODE_PRIVATE);
// Check if the user is logged in and fetch user info
if (mCurrentUser == null) {
storeSignOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
MainActivity.this.finish();
}
// Prepare the food list to be inflated
prepareFoodList();
Toolbar toolbar = findViewById(R.id.toolbar);
mDrawerLayout = findViewById(R.id.drawer_layout);
mNavigationView = findViewById(R.id.nav_view);
mSearchView = findViewById(R.id.search_view);
bottomNavigation = findViewById(R.id.bottom_nav);
RecyclerView mRecyclerView = findViewById(R.id.recycler_view);
// Configure the Toolbar
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_24dp);
}
// Create items
AHBottomNavigationItem itemCart = new AHBottomNavigationItem(R.string.bottom_nav_cart, R.drawable.ic_shopping_cart_24dp, R.color.colorAccentFirebase);
bottomNavigation.addItem(itemCart);
// Configure the DrawerLayout
configureDrawerLayout();
// Configure the Navigation View
configureNavigationView();
// Update Profile info in the nav header
updateUserInfoInNavHeader();
// Setup the Recycler View
mFoodAdapter = new FoodAdapter(this, mFoodList);
mFoodAdapter.setCardClickListener(this);
// Setup the recycler view layout manager
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.addItemDecoration(new GridSpacingItemDecoration(2, dpToPx(), true));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setAdapter(mFoodAdapter);
// Configure the Material Search View
configureMaterialSearchView();
configureBottomNavigation();
bottomSheetFragment = new BottomSheetFragment();
getCartItemCount();
}
private void configureBottomNavigation() {
// Force to tint the drawable (useful for font with icon for example)
bottomNavigation.setForceTint(true);
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
// Use colored navigation with circle reveal effect
bottomNavigation.setColored(true);
// Set current item programmatically
bottomNavigation.setCurrentItem(1);
if (FoodAdapter.count > 0)
setCartNotification(FoodAdapter.count);
// Set listeners
bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public boolean onTabSelected(int position, boolean wasSelected) {
Toast.makeText(MainActivity.this, FoodAdapter.count + " items in cart", Toast.LENGTH_SHORT).show();
return true;
}
});
}
void setCartNotification(int num) {
bottomNavigation.setNotification("" + num, 0);
}
private void updateUserInfoInNavHeader() {
if (FirebaseAuth.getInstance().getCurrentUser() != null) {
String name = FirebaseAuth.getInstance().getCurrentUser().getDisplayName();
String firstLetter = "";
if (name != null)
firstLetter = name.substring(0, 1);
TextDrawable textDrawable = TextDrawable.builder().buildRound(firstLetter, getResources().getColor(R.color.royal_blue));
mNavProfileImg.setImageDrawable(textDrawable);
// Change the user name to the signed in user display name
mNavUsername.setText(mCurrentUser.getDisplayName());
// Change the user email to the signed in email
mNavUserEmail.setText(mCurrentUser.getEmail());
}
}
private void configureMaterialSearchView() {
//mSearchView.setEllipsize(true); // Not available in 1.3.0
mSearchView.setHint("Search for an item...");
mSearchView.setSuggestions(searchSuggestions);
mSearchView.setVoiceSearch(true); // Activate voice search
mSearchView.setVoiceIcon(getResources().getDrawable(R.drawable.ic_action_voice_search));
mSearchView.closeSearch(); // Close search view by default
// Set Query Text Listener
mSearchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
mFoodAdapter.getFilter().filter(query);
mSearchView.closeSearch();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
mFoodAdapter.getFilter().filter(newText);
return true;
}
});
// Set Search View Listener
mSearchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
mSearchView.showSuggestions();
}
@Override
public void onSearchViewClosed() {
hideKeyboard();
}
});
}
private void configureNavigationView() {
// Create an object of the nav header and find the various widgets
View navHeader = mNavigationView.getHeaderView(0);
mNavProfileImg = navHeader.findViewById(R.id.nav_profile_img);
mNavUsername = navHeader.findViewById(R.id.nav_user_name);
mNavUserEmail = navHeader.findViewById(R.id.nav_email);
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
if (menuItem.getItemId() == R.id.nav_sign_out) {
// Check if user is already signed in
if (mCurrentUser != null) {
// Sign out the user
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signOut();
// Take user to the login page
storeSignOut();
startActivity(new Intent(MainActivity.this, LoginActivity.class));
MainActivity.this.finish();
}
}
// Add code here to update the UI based on the item selected
// For example, swap UI fragments here
return true;
}
});
}
private void configureDrawerLayout() {
mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerSlide(@NonNull View view, float v) {
if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
}
@Override
public void onDrawerOpened(@NonNull View view) {
// Respond when the drawer is opened
if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
invalidateOptionsMenu();
hideKeyboard();
}
@Override
public void onDrawerClosed(@NonNull View view) {
// Respond when the drawer is closed
}
@Override
public void onDrawerStateChanged(int i) {
// Respond when the drawer motion state changes
}
});
}
// Reads the food items from the JSON file
private void prepareFoodList() {
mFoodList = new ArrayList<>();
String jsonUrl = "https://jsonblob.com/api/jsonBlob/a90254ad-3670-11e9-9056-e12fdc2cad95";
RequestQueue requestQueue;
// Instantiate the cache
Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap
// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());
// Instantiate the RequestQueue with the cache and network.
requestQueue = new RequestQueue(cache, network);
// Start the queue
requestQueue.start();
// Formulate the request and handle the response
JsonArrayRequest jsonObjectRequest = new JsonArrayRequest(
Request.Method.GET,
jsonUrl,
null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if (response.length() > 0) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject foodObject = response.getJSONObject(i);
mFoodList.add(new FoodItem(
foodObject.getString("name"),
foodObject.getString("price"),
foodObject.getInt("rating"),
foodObject.getString("imageUrl")
));
searchSuggestions[i] = foodObject.getString("name");
mFoodAdapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
Log.i("JSON_Error", e.getMessage());
}
}
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
// Add the request to the queue
requestQueue.add(jsonObjectRequest);
}
private int dpToPx() {
Resources r = getResources();
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()));
}
// Hides the soft input touch when called
private void hideKeyboard() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mDrawerLayout.getWindowToken(), 0);
}
// This method is called when the user signs out from the nav drawer
private void storeSignOut() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(getString(R.string.user_signed_out), true);
editor.apply();
}
// Save the number of items in cart in the SP API
private void storeCartCount() {
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putInt("cart_count", FoodAdapter.count);
editor.apply();
}
// Read the number of items in cart stored in the SP API
private int readCartCount() {
return mSharedPreferences.getInt("cart_count", 0);
}
// Writes the number of items in the cart to the user's database
private void putCartItemCount() {
// Get a reference to the database node to read cart item count
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
// Write the value
mDatabase.child(mCurrentUser.getUid()).child("cart_count")
.setValue(readCartCount())
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
getCartItemCount(); // Call method to update the bottom nav
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "Failed to update cart count", Toast.LENGTH_SHORT).show();
}
});
}
// Reads the number of items in the cart from the user's database
private void getCartItemCount() {
// Get a reference to the database node to read cart item count
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
// Read the value
mDatabase.child(mCurrentUser.getUid()).child("cart_count").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Integer count = dataSnapshot.getValue(Integer.class);
if (count != null && count > 0)
setCartNotification(count); // Set item count to bottom nav
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(MainActivity.this, "Operation cancelled: "+databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == REQUEST_VOICE && resultCode == RESULT_OK) {
if (data != null) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
if (matches != null && matches.size() > 0) {
String searchWrd = matches.get(0);
if (!TextUtils.isEmpty(searchWrd)) {
mSearchView.setQuery(searchWrd, false);
}
}
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
MenuItem menuItem = menu.findItem(R.id.menu_search);
mSearchView.setMenuItem(menuItem);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
mDrawerLayout.openDrawer(GravityCompat.START);
invalidateOptionsMenu();
return true;
case R.id.menu_search:
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
mDrawerLayout.closeDrawers();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START))
mDrawerLayout.closeDrawers();
else if (mSearchView.isSearchOpen())
mSearchView.closeSearch();
else
super.onBackPressed();
}
@Override
public void cardClicked(View view, int position) {
// Handle card clicked events over here
currentFoodItem = mFoodList.get(position);
bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
}
@Override
public void onAddToCartBtnClick() {
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
mDatabase.child(mCurrentUser.getUid())
.child(currentFoodItem.getName())
.setValue(currentFoodItem)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
storeCartCount(); // Store cart item count in SP API
putCartItemCount(); // Write stored value to the database
Toast.makeText(MainActivity.this, currentFoodItem.getName() + " added to Cart", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, "" + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
| 20,126 | 0.625609 | 0.622876 | 509 | 38.540276 | 28.532627 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.524558 | false | false | 8 |
fca51cb4c5c11c886c4a196677ebb945163bfba6 | 31,722,628,461,092 | 3d04c2e4d8cb1cea947133465d7f6f56e36d469a | /parkinglot/src/main/java/com/oca/parkinglot/entity/Mobil.java | c42ec4d6f26d3f447b5e248a7b4ba7f9465d1622 | [] | no_license | sidulanaksekolahan/parkinglot | https://github.com/sidulanaksekolahan/parkinglot | ed3915774ebe030e6fede2c164f822b3c77330d5 | f48e5590265faaa8c9c79461c7a721ed6efafc94 | refs/heads/master | 2023-04-01T10:07:40.098000 | 2021-04-09T07:50:08 | 2021-04-09T07:50:08 | 356,182,465 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.oca.parkinglot.entity;
public class Mobil {
private String platNomor;
private String warna;
private String tipe;
public Mobil() {}
public Mobil(String platNomor, String warna, String tipe) {
this.platNomor = platNomor;
this.warna = warna;
this.tipe = tipe;
}
public String getPlatNomor() {
return platNomor;
}
public void setPlatNomor(String platNomor) {
this.platNomor = platNomor;
}
public String getWarna() {
return warna;
}
public void setWarna(String warna) {
this.warna = warna;
}
public String getTipe() {
return tipe;
}
public void setTipe(String tipe) {
this.tipe = tipe;
}
@Override
public String toString() {
return "Mobil{" +
"platNomor='" + platNomor + '\'' +
", warna='" + warna + '\'' +
", tipe='" + tipe + '\'' +
'}';
}
}
| UTF-8 | Java | 989 | java | Mobil.java | Java | [] | null | [] | package com.oca.parkinglot.entity;
public class Mobil {
private String platNomor;
private String warna;
private String tipe;
public Mobil() {}
public Mobil(String platNomor, String warna, String tipe) {
this.platNomor = platNomor;
this.warna = warna;
this.tipe = tipe;
}
public String getPlatNomor() {
return platNomor;
}
public void setPlatNomor(String platNomor) {
this.platNomor = platNomor;
}
public String getWarna() {
return warna;
}
public void setWarna(String warna) {
this.warna = warna;
}
public String getTipe() {
return tipe;
}
public void setTipe(String tipe) {
this.tipe = tipe;
}
@Override
public String toString() {
return "Mobil{" +
"platNomor='" + platNomor + '\'' +
", warna='" + warna + '\'' +
", tipe='" + tipe + '\'' +
'}';
}
}
| 989 | 0.528817 | 0.528817 | 49 | 19.183674 | 16.499441 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.367347 | false | false | 8 |
d817cade56677ed83c975f799e09eb15ea0893f9 | 25,185,688,241,474 | 7126f341aa42dd2d0f4f312bc464c250fc49a936 | /src/main/java/com/jerry/test/mytetrisgame/Model/BlocksFrame.java | f73469160c056eb070648b0850a1c5f7ba2c030b | [] | no_license | weg896/Android_Tetris_module | https://github.com/weg896/Android_Tetris_module | 0551fc781563ffd0f05eec9de58647cd5ba87687 | c6594e00b56d45c7182f0a87d74cc02618208e5f | refs/heads/master | 2021-01-10T02:14:24.658000 | 2016-01-25T03:52:19 | 2016-01-25T03:52:19 | 50,160,546 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jerry.test.mytetrisgame.Model;
import com.jerry.test.mytetrisgame.Shapes.*;
/**
* Created by test on 22/01/16.
*/
public class BlocksFrame {
/* O ------> x
|
| blocks coordinate
y |
+
*/
public static final int NUMBER_BLOCKS_X_AXIS = 10;
public static final int NUMBER_BLOCKS_Y_AXIS = 20;
public static final int EXTEND_BLOCKS_Y_AXIS = 4;
public static final int SHAPE_ORIGIN_X = 4;
public static final int SHAPE_ORIGIN_Y = 0;
private boolean[][] blocks = new boolean[NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS][NUMBER_BLOCKS_X_AXIS];
private boolean[] rowsNeedClean = new boolean[NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS];
public BlocksFrame(){
// blocks data init
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
rowsNeedClean[y] = false;
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
blocks[y][x] = false;
}
}
}
private void detectRowsNeedClean(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
int cleanCount = 0;
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
if(blocks[y][x]){
cleanCount++;
}
}
if(cleanCount == NUMBER_BLOCKS_X_AXIS){
rowsNeedClean[y] = true;
}
}
}
public void cleanRows(){
detectRowsNeedClean();
boolean[][] currentBlocks = blocks;
int rowShift = 0;
// clean from bottom to top,
// it will remain the top 'rowShift' number rows haven't clean
for(int y=NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS-1;y>=0;y--){
if(rowsNeedClean[y]){
rowShift++;
rowsNeedClean[y]=false;
}else{
if(rowShift != 0) {
for (int x = 0; x < NUMBER_BLOCKS_X_AXIS; x++) {
blocks[y+rowShift][x] = currentBlocks[y][x];
}
}
}
}
// clean the top 'rowShift' number rows
for(int y=0;y<rowShift;y++){
for (int x = 0; x < NUMBER_BLOCKS_X_AXIS; x++) {
blocks[y][x] = false;
}
}
}
public void stickShapeToBlocks(RootShape shape){
int[][] shapePositions = shape.getShapePosition();
for(int b=0;b<RootShape.TOTAL_BLOCKS_NUMBER;b++){
blocks[shapePositions[b][RootShape.POSITION_Y]][shapePositions[b][RootShape.POSITION_X]] = true;
}
}
public boolean[][] getBlocks(){
return blocks;
}
///////////// code for testing ///////////////////////////
public void test_setBlock(int y, int x,boolean haveBlock){
blocks[y][x] = haveBlock;
}
public void test_printGameScreen(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
if(blocks[y][x]){
System.out.print("@");
}else{
System.out.print(".");
}
}
System.out.println("");
}
System.out.println(">>>>>>>>>");
}
public void test_printRowsNeedClean(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
if(rowsNeedClean[y]){
System.out.println(y);
}
}
}
public static void main(String[] args){
BlocksFrame gameBlocks = new BlocksFrame();
gameBlocks.test_setBlock(1,3, true);
gameBlocks.test_setBlock(2,0, true);
gameBlocks.test_setBlock(2,1, true);
gameBlocks.test_setBlock(2,2, true);
gameBlocks.test_setBlock(2,3, true);
gameBlocks.test_setBlock(3,0, true);
gameBlocks.test_setBlock(3,1, true);
gameBlocks.test_setBlock(3,2, true);
gameBlocks.test_setBlock(3,3, true);
gameBlocks.test_setBlock(4,1, true);
gameBlocks.test_setBlock(5,2, true);
/*gameBlocks.test_setBlock(6,0, true);
gameBlocks.test_setBlock(6,1, true);
gameBlocks.test_setBlock(6,2, true);
gameBlocks.test_setBlock(6,3, true);*/
gameBlocks.test_setBlock(7, 2, true);
gameBlocks.test_printGameScreen();
gameBlocks.cleanRows();
gameBlocks.test_printGameScreen();
}
}
| UTF-8 | Java | 4,451 | java | BlocksFrame.java | Java | [
{
"context": "rry.test.mytetrisgame.Shapes.*;\n\n/**\n * Created by test on 22/01/16.\n */\npublic class BlocksFrame {\n\n ",
"end": 112,
"score": 0.9987889528274536,
"start": 108,
"tag": "USERNAME",
"value": "test"
}
] | null | [] | package com.jerry.test.mytetrisgame.Model;
import com.jerry.test.mytetrisgame.Shapes.*;
/**
* Created by test on 22/01/16.
*/
public class BlocksFrame {
/* O ------> x
|
| blocks coordinate
y |
+
*/
public static final int NUMBER_BLOCKS_X_AXIS = 10;
public static final int NUMBER_BLOCKS_Y_AXIS = 20;
public static final int EXTEND_BLOCKS_Y_AXIS = 4;
public static final int SHAPE_ORIGIN_X = 4;
public static final int SHAPE_ORIGIN_Y = 0;
private boolean[][] blocks = new boolean[NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS][NUMBER_BLOCKS_X_AXIS];
private boolean[] rowsNeedClean = new boolean[NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS];
public BlocksFrame(){
// blocks data init
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
rowsNeedClean[y] = false;
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
blocks[y][x] = false;
}
}
}
private void detectRowsNeedClean(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
int cleanCount = 0;
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
if(blocks[y][x]){
cleanCount++;
}
}
if(cleanCount == NUMBER_BLOCKS_X_AXIS){
rowsNeedClean[y] = true;
}
}
}
public void cleanRows(){
detectRowsNeedClean();
boolean[][] currentBlocks = blocks;
int rowShift = 0;
// clean from bottom to top,
// it will remain the top 'rowShift' number rows haven't clean
for(int y=NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS-1;y>=0;y--){
if(rowsNeedClean[y]){
rowShift++;
rowsNeedClean[y]=false;
}else{
if(rowShift != 0) {
for (int x = 0; x < NUMBER_BLOCKS_X_AXIS; x++) {
blocks[y+rowShift][x] = currentBlocks[y][x];
}
}
}
}
// clean the top 'rowShift' number rows
for(int y=0;y<rowShift;y++){
for (int x = 0; x < NUMBER_BLOCKS_X_AXIS; x++) {
blocks[y][x] = false;
}
}
}
public void stickShapeToBlocks(RootShape shape){
int[][] shapePositions = shape.getShapePosition();
for(int b=0;b<RootShape.TOTAL_BLOCKS_NUMBER;b++){
blocks[shapePositions[b][RootShape.POSITION_Y]][shapePositions[b][RootShape.POSITION_X]] = true;
}
}
public boolean[][] getBlocks(){
return blocks;
}
///////////// code for testing ///////////////////////////
public void test_setBlock(int y, int x,boolean haveBlock){
blocks[y][x] = haveBlock;
}
public void test_printGameScreen(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
for(int x=0;x<NUMBER_BLOCKS_X_AXIS;x++){
if(blocks[y][x]){
System.out.print("@");
}else{
System.out.print(".");
}
}
System.out.println("");
}
System.out.println(">>>>>>>>>");
}
public void test_printRowsNeedClean(){
for(int y=0;y<NUMBER_BLOCKS_Y_AXIS+EXTEND_BLOCKS_Y_AXIS;y++){
if(rowsNeedClean[y]){
System.out.println(y);
}
}
}
public static void main(String[] args){
BlocksFrame gameBlocks = new BlocksFrame();
gameBlocks.test_setBlock(1,3, true);
gameBlocks.test_setBlock(2,0, true);
gameBlocks.test_setBlock(2,1, true);
gameBlocks.test_setBlock(2,2, true);
gameBlocks.test_setBlock(2,3, true);
gameBlocks.test_setBlock(3,0, true);
gameBlocks.test_setBlock(3,1, true);
gameBlocks.test_setBlock(3,2, true);
gameBlocks.test_setBlock(3,3, true);
gameBlocks.test_setBlock(4,1, true);
gameBlocks.test_setBlock(5,2, true);
/*gameBlocks.test_setBlock(6,0, true);
gameBlocks.test_setBlock(6,1, true);
gameBlocks.test_setBlock(6,2, true);
gameBlocks.test_setBlock(6,3, true);*/
gameBlocks.test_setBlock(7, 2, true);
gameBlocks.test_printGameScreen();
gameBlocks.cleanRows();
gameBlocks.test_printGameScreen();
}
}
| 4,451 | 0.528196 | 0.514491 | 153 | 28.091503 | 23.889002 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.732026 | false | false | 8 |
d85bec415b26a5ac9e272913c9b194a4b7645d88 | 26,508,538,155,685 | 112c3ad71052772e671b175d5e98693a0475fde3 | /Simple_Server/src/model/PostEvent.java | f5b4a60d7b18afb02528b8f03d5096482e79fb77 | [] | no_license | pinsondg/simple_server_pong | https://github.com/pinsondg/simple_server_pong | 41ed52d23b2a5cbc0f8f9ef52ebb329646277916 | 4ca8ed85c88ff72f03b9002cf61b0d9dee3ca95e | refs/heads/master | 2020-04-20T12:28:15.099000 | 2019-02-15T21:24:47 | 2019-02-15T21:24:47 | 168,844,150 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package model;
import java.net.Socket;
public class PostEvent {
private String message;
private String fileRequest;
private Socket socket;
public PostEvent(String message, String fileRequest, Socket socket) {
this.message = message;
this.fileRequest = fileRequest;
this.socket = socket;
}
public String getMessage() {
return message;
}
public String getFileRequest() {
return fileRequest;
}
public Socket getSocket() {
return socket;
}
} | UTF-8 | Java | 474 | java | PostEvent.java | Java | [] | null | [] | package model;
import java.net.Socket;
public class PostEvent {
private String message;
private String fileRequest;
private Socket socket;
public PostEvent(String message, String fileRequest, Socket socket) {
this.message = message;
this.fileRequest = fileRequest;
this.socket = socket;
}
public String getMessage() {
return message;
}
public String getFileRequest() {
return fileRequest;
}
public Socket getSocket() {
return socket;
}
} | 474 | 0.721519 | 0.721519 | 29 | 15.379311 | 15.753301 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.448276 | false | false | 8 |
e3f2c0c9f406c89e0ea020e41e8c10555d4fefd7 | 6,150,393,219,985 | cdb267144301bcede8c067875367fe7d452cf647 | /src/main/java/org/assertj/jodatime/error/ShouldHaveMonthOfYearEqualTo.java | 3c838911cd08cd2310fd6ea722d2716b11a5c830 | [
"Apache-2.0"
] | permissive | sullis/assertj-joda-time | https://github.com/sullis/assertj-joda-time | cbd5d6a8ec8c8fbd5c018b29ade5385443c420f5 | 15a88e9e2febe5274998d83247f08ba19d739e94 | refs/heads/main | 2022-11-22T04:01:43.518000 | 2020-07-08T03:50:59 | 2020-07-08T03:50:59 | 277,108,056 | 0 | 0 | NOASSERTION | true | 2020-07-24T17:16:51 | 2020-07-04T12:44:34 | 2020-07-24T17:16:22 | 2020-07-24T17:16:49 | 199 | 0 | 0 | 1 | Java | false | false | /*
* 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.
*
* Copyright 2012-2018 the original author or authors.
*/
package org.assertj.jodatime.error;
import org.assertj.core.error.BasicErrorMessageFactory;
import org.assertj.core.error.ErrorMessageFactory;
/**
* Creates an error message indicating that an assertion that verifies a Joda DateTime or LocalDateTime has a month of year
* equal to a given one failed.
*
* @author John Killmer
*/
public class ShouldHaveMonthOfYearEqualTo extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldHaveMonthOfYearEqualTo(Object actual, int actualMonthOfYear, int expectedMonthOfYear) {
return new ShouldHaveMonthOfYearEqualTo(actual, actualMonthOfYear, expectedMonthOfYear);
}
private ShouldHaveMonthOfYearEqualTo(Object actual, int actualMonthOfYear, int expectedMonthOfYear) {
super("%n" +
"Expecting:%n" +
" <%s>%n" +
"month of year to be:%n" +
" <%s>%n" +
"but was:%n" +
" <%s>",
actual, expectedMonthOfYear, actualMonthOfYear);
}
}
| UTF-8 | Java | 1,591 | java | ShouldHaveMonthOfYearEqualTo.java | Java | [
{
"context": "year\n * equal to a given one failed.\n *\n * @author John Killmer\n */\npublic class ShouldHaveMonthOfYearEqualTo ext",
"end": 939,
"score": 0.999534547328949,
"start": 927,
"tag": "NAME",
"value": "John Killmer"
}
] | null | [] | /*
* 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.
*
* Copyright 2012-2018 the original author or authors.
*/
package org.assertj.jodatime.error;
import org.assertj.core.error.BasicErrorMessageFactory;
import org.assertj.core.error.ErrorMessageFactory;
/**
* Creates an error message indicating that an assertion that verifies a Joda DateTime or LocalDateTime has a month of year
* equal to a given one failed.
*
* @author <NAME>
*/
public class ShouldHaveMonthOfYearEqualTo extends BasicErrorMessageFactory {
public static ErrorMessageFactory shouldHaveMonthOfYearEqualTo(Object actual, int actualMonthOfYear, int expectedMonthOfYear) {
return new ShouldHaveMonthOfYearEqualTo(actual, actualMonthOfYear, expectedMonthOfYear);
}
private ShouldHaveMonthOfYearEqualTo(Object actual, int actualMonthOfYear, int expectedMonthOfYear) {
super("%n" +
"Expecting:%n" +
" <%s>%n" +
"month of year to be:%n" +
" <%s>%n" +
"but was:%n" +
" <%s>",
actual, expectedMonthOfYear, actualMonthOfYear);
}
}
| 1,585 | 0.728473 | 0.72093 | 40 | 38.775002 | 41.219223 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.475 | false | false | 8 |
d8bcfdcfa844a9e930ea134557b08d2f4906698f | 22,737,556,894,971 | 44541ffb528133f0ef04352992315faf55fb0b25 | /E-Recruitment/src/main/java/com/macauslot/recruitment_ms/vo/DeptVO.java | bcb336c75d95a360abe36993ebee3c04572e1d9b | [] | no_license | JohnnyMacau/SPRING | https://github.com/JohnnyMacau/SPRING | 57cba27b61fe1828a64c54b66920beef2e6d95d1 | 41bfaa14675edb00d6b539152f7bb5c0f4eb9293 | refs/heads/main | 2023-07-09T03:06:41.017000 | 2021-08-12T14:51:35 | 2021-08-12T14:51:35 | 394,017,643 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.macauslot.recruitment_ms.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author jim.deng
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DeptVO {
private String description;
private Integer departmentCode;
}
| UTF-8 | Java | 295 | java | DeptVO.java | Java | [
{
"context": ";\nimport lombok.NoArgsConstructor;\n\n/**\n * @author jim.deng\n */\n@Data\n@AllArgsConstructor\n@NoArgsConstructor\n",
"end": 153,
"score": 0.8642750978469849,
"start": 145,
"tag": "NAME",
"value": "jim.deng"
}
] | null | [] | package com.macauslot.recruitment_ms.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author jim.deng
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DeptVO {
private String description;
private Integer departmentCode;
}
| 295 | 0.779661 | 0.779661 | 16 | 17.4375 | 13.522984 | 40 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 8 |
668c08d42c5cc417b0f67255730ab52b06aa55ae | 25,606,595,055,335 | 80ca72ed0c747e7437f394059ddd1808c9e7bcf9 | /LearningJava/src/arrays/StringMethods.java | a959e9fdbf598748ff434580e31e0bd4209676d2 | [] | no_license | ashishshresthatest/Javatest | https://github.com/ashishshresthatest/Javatest | 40e520c27627a2e4ec11b05a7fdf3a082100c887 | 595f50bc5dd33939da6aea4b3b3249f3e4df8b81 | refs/heads/master | 2022-11-06T00:39:56.274000 | 2020-06-17T21:33:57 | 2020-06-17T21:33:57 | 273,075,296 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package arrays;
public class StringMethods {
public static void main(String[] args) {
// TODO Auto-generated method stub
// :=Length
String s = "Welcome";
System.out.println(s.length());
// Concatenation
String S1 = "Ashish";
String S2 = "Shrestha";
System.out.println(S1.concat(S2));
/// Equals
System.out.println(S1.equals(S2));
// EqualsIgnoreCase
String S4 = "ASHISH";
System.out.println(S1.equalsIgnoreCase(S4));
// Contains
System.out.println(S4.contains("AS"));
// SubString
System.out.println(S4.substring(0, 5));
System.out.println(S4.substring(2, 6));
System.out.println(S4.substring(0, 2));
// replace
System.out.println(S4.replace('S', 'X'));
System.out.println(S4.replace("ASHISH", "Shrestha"));
}
}
| UTF-8 | Java | 806 | java | StringMethods.java | Java | [
{
"context": ".length());\r\n\r\n\t\t// Concatenation\r\n\t\tString S1 = \"Ashish\";\r\n\t\tString S2 = \"Shrestha\";\r\n\t\tSystem.out.printl",
"end": 250,
"score": 0.9951837658882141,
"start": 244,
"tag": "NAME",
"value": "Ashish"
},
{
"context": "tenation\r\n\t\tString S1 = \"Ashish\";\r\n\t\tString S2 = \"Shrestha\";\r\n\t\tSystem.out.println(S1.concat(S2));\r\n\r\n\t\t/// ",
"end": 277,
"score": 0.9967787861824036,
"start": 269,
"tag": "NAME",
"value": "Shrestha"
},
{
"context": "ls(S2));\r\n\r\n\t\t// EqualsIgnoreCase\r\n\t\tString S4 = \"ASHISH\";\r\n\t\tSystem.out.println(S1.equalsIgnoreCase(S4));",
"end": 419,
"score": 0.8614115715026855,
"start": 413,
"tag": "NAME",
"value": "ASHISH"
},
{
"context": "X'));\r\n\t\tSystem.out.println(S4.replace(\"ASHISH\", \"Shrestha\"));\r\n\t}\r\n\r\n}\r\n",
"end": 791,
"score": 0.9805994033813477,
"start": 783,
"tag": "NAME",
"value": "Shrestha"
}
] | null | [] | package arrays;
public class StringMethods {
public static void main(String[] args) {
// TODO Auto-generated method stub
// :=Length
String s = "Welcome";
System.out.println(s.length());
// Concatenation
String S1 = "Ashish";
String S2 = "Shrestha";
System.out.println(S1.concat(S2));
/// Equals
System.out.println(S1.equals(S2));
// EqualsIgnoreCase
String S4 = "ASHISH";
System.out.println(S1.equalsIgnoreCase(S4));
// Contains
System.out.println(S4.contains("AS"));
// SubString
System.out.println(S4.substring(0, 5));
System.out.println(S4.substring(2, 6));
System.out.println(S4.substring(0, 2));
// replace
System.out.println(S4.replace('S', 'X'));
System.out.println(S4.replace("ASHISH", "Shrestha"));
}
}
| 806 | 0.631514 | 0.605459 | 37 | 19.783783 | 16.943684 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.783784 | false | false | 8 |
393f9b5643d478453e1d28618d0e5d74d8e66fc3 | 33,921,651,722,696 | eba577f5bfd0bcf1ef14aa2180366e8cd6c6e046 | /src/main/java/WorkersServlet.java | 262ac7e5784c5cead3fad2798346a9a8eaf11c59 | [] | no_license | Mone20/university_ee | https://github.com/Mone20/university_ee | bd413ffb4ebe7959c62b05278f5792ced728df4f | 89a9c92dd81aea236edcd869736e6d85d2cffb5e | refs/heads/master | 2022-07-19T16:16:21.750000 | 2020-03-23T12:07:36 | 2020-03-23T12:07:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
import model.Degree;
import model.UniversityPosition;
import model.Worker;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
public class WorkersServlet extends HttpServlet {
public static final String POSITION_ID = "positionId";
public static final String DEGREE_ID = "degreeId";
public static final String PARENT_ID = "parentId";
public static final String FILTER="_filter";
private Controller controllerWorkers=null;
private Controller controllerPositions=null;
private Controller controllerDegrees=null;
public WorkersServlet() throws SQLException {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
if (Database.connection == null)
Database.connectDB();
if (controllerPositions == null) {
controllerPositions = new Controller<UniversityPosition>(new PositionTable());
}
if (controllerDegrees == null) {
controllerDegrees = new Controller<Degree>(new DegreeTable());
}
if (controllerWorkers == null) {
controllerWorkers = new Controller<Worker>(new WorkersTable(Database.connection));
}
String action = req.getParameter("action");
String htmlReq = "";
boolean flag = false;
int id;
List result = controllerPositions.selectAll();
String htmlReqPos = "";
String htmlReqParent = " ";
for (int i = 0; i < result.size(); i++) {
id = (((UniversityPosition) result.get(i)).getId());
String pos = (((UniversityPosition) result.get(i)).getPosition());
htmlReqPos += " <option value=\"" + Integer.toString(id) + "\">" + pos + "</option>\n";
}
req.setAttribute("htmlPos", htmlReqPos);
result = controllerDegrees.selectAll();
String htmlReqDeg = "";
for (int i = 0; i < result.size(); i++) {
id = (((Degree) result.get(i)).getId());
String deg = (((Degree) result.get(i)).getDegree());
htmlReqDeg += " <option value=\"" + Integer.toString(id) + "\">" + deg + "</option>\n";
}
req.setAttribute("htmlDeg", htmlReqDeg);
if (action != null)
{
switch (action) {
case "info":
flag = true;
id = Integer.parseInt(req.getParameter("id"));
if (id >= 0) {
Worker worker = (Worker) controllerWorkers.select(id);
if (null == ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree()
|| 0 > worker.getDegreeId())
req.setAttribute("degree", "empty");
else
req.setAttribute("degree", ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree());
if (null == ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition() || 0 > worker.getPositionId())
req.setAttribute("position", "empty");
else
req.setAttribute("position", ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition());
req.setAttribute("worker", worker);
req.getRequestDispatcher("info.jsp").forward(req, resp);
} else
flag = false;
break;
case "update":
flag = true;
id = Integer.parseInt(req.getParameter("id"));
result = controllerWorkers.selectAll();
htmlReqParent = "";
for (int i = 0; i < result.size(); i++) {
int idSelect = (((Worker) result.get(i)).getId());
if (idSelect != id) {
String lastName = (((Worker) result.get(i)).getLastName());
String firstName = (((Worker) result.get(i)).getFirstName());
String middleName = (((Worker) result.get(i)).getMiddleName());
String birthDate = (((Worker) result.get(i)).getBirthDate());
htmlReqParent += " <option value=\"" + Integer.toString(idSelect) + "\">" + lastName + " " + firstName + " " +
middleName + " " + birthDate + "</option>\n";
}
}
req.setAttribute("htmlParent", htmlReqParent);
Worker worker = (Worker) controllerWorkers.select(id);
req.setAttribute("position", ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition());
req.setAttribute("degree", ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree());
req.setAttribute("worker", worker);
req.getRequestDispatcher("update.jsp").forward(req, resp);
break;
case "create":
/* */
result = controllerWorkers.selectAll();
htmlReqParent = "";
for (int i = 0; i < result.size(); i++) {
int idSelect = (((Worker) result.get(i)).getId());
String lastName = (((Worker) result.get(i)).getLastName());
String firstName = (((Worker) result.get(i)).getFirstName());
String middleName = (((Worker) result.get(i)).getMiddleName());
String birthDate = (((Worker) result.get(i)).getBirthDate());
htmlReqParent += " <option value=\"" + Integer.toString(idSelect) + "\">" + lastName + " " + firstName + " " +
middleName + " " + birthDate + "</option>\n";
}
req.setAttribute("htmlParent", htmlReqParent);
flag = true;
req.getRequestDispatcher("create.jsp").forward(req, resp);
break;
case "delete":
id = Integer.parseInt(req.getParameter("id"));
Worker w = (Worker) controllerWorkers.select(id);
List resultDelete = null;
if (w.getParentId() < 0) {
resultDelete = controllerWorkers.selectAll();
for (int i = 0; i < resultDelete.size(); i++) {
if (((Worker) resultDelete.get(i)).getId() == id) {
controllerWorkers.update(((Worker) resultDelete.get(i)).getId(), PARENT_ID, -2);
}
}
} else {
resultDelete = controllerWorkers.selectAll();
for (int i = 0; i < resultDelete.size(); i++) {
if (((Worker) resultDelete.get(i)).getId() == id) {
controllerWorkers.update(((Worker) resultDelete.get(i)).getId(), PARENT_ID, w.getParentId());
}
}
}
controllerWorkers.delete(id);
break;
}
}
if(flag==false)
{
result=controllerWorkers.selectAll();
for(int i=0;i<result.size();i++)
{
Worker w=(Worker)result.get(i);
htmlReq += "\n<tr>\n" +
" <td>" + Integer.toString(w.getId()) + "</td>\n" +
" <td>" + w.getLastName() + "</td>\n" +
" <td>" + w.getFirstName() + "</td>\n" +
" <td>" + w.getMiddleName() + "</td>\n" +
" <td><a href=\"time?action=info&id=" + Integer.toString(w.getId()) + "\">more...</a></td>\n" +
" </tr>";
}
req.setAttribute("select", htmlReq);
req.getRequestDispatcher("time.jsp").forward(req, resp);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("Enter doPost");
if(Database.connection==null) {
try {
Database.connectDB();
} catch (SQLException e) {
e.printStackTrace();
}
}
req.setCharacterEncoding("UTF-8");
String action = req.getParameter("action");
List result=null;
PreparedStatement preparedStatement = null;
try {
switch(action)
{
case "createSubmit":
if(controllerWorkers==null)
controllerWorkers = new Controller(new WorkersTable(Database.connection));
List resultWorkers=controllerWorkers.selectAll();
int maxId=-1;
for(int i=0;i<resultWorkers.size();i++)
{
Worker w=(Worker)resultWorkers.get(i);
if(w.getId()>maxId)
maxId=w.getId();
}
String lastName =req.getParameter("lastName");
String firstName=req.getParameter("firstName");
String middleName=req.getParameter("middleName");
String birthDate=req.getParameter("birthDate");
int positionId=Integer.parseInt(req.getParameter("selectPos"));
int degreeId=Integer.parseInt(req.getParameter("selectDeg"));
int parentId=Integer.parseInt(req.getParameter("selectParent"));
Worker newWorker=new Worker(firstName,birthDate,maxId+1,lastName,middleName,positionId,degreeId,parentId);
controllerWorkers.insert(newWorker);
doGet(req,resp);
break;
case "submit":
int id=Integer.parseInt(req.getParameter("id"));
if(controllerWorkers==null)
controllerWorkers = new Controller(new WorkersTable(Database.connection));
HashMap<String,String> mapUpdate=new HashMap<>();
mapUpdate.put("lastname",req.getParameter("lastName"));
mapUpdate.put("firstname",req.getParameter("firstName"));
mapUpdate.put("middlename",req.getParameter("middleName"));
mapUpdate.put("birthdate",req.getParameter("birthDate"));
mapUpdate.put(POSITION_ID,req.getParameter(POSITION_ID));
mapUpdate.put( DEGREE_ID,req.getParameter(DEGREE_ID));
mapUpdate.put( PARENT_ID,req.getParameter(PARENT_ID));
controllerWorkers.update(mapUpdate,id);
req.setAttribute("worker", controllerWorkers.select(id));
doGet(req,resp);
break;
case "show":
String sql = "";
if (Database.connection == null)
Database.connectDB();
result = controllerPositions.selectAll();
String htmlReqPos = "";
for(int i=0;i<result.size();i++) {
UniversityPosition up=(UniversityPosition) result.get(i);
htmlReqPos += " <option value=\""+Integer.toString(up.getId())+"\">"+up.getPosition()+"</option>\n" ;
}
req.setAttribute("htmlPos",htmlReqPos);
result = controllerDegrees.selectAll();
String htmlReqDeg = "";
for(int i=0;i<result.size();i++) {
Degree d=(Degree)result.get(i);
htmlReqDeg += " <option value=\""+Integer.toString(d.getId())+"\">"+d.getDegree()+"</option>\n" ;
}
req.setAttribute("htmlDeg",htmlReqDeg);
HashMap <String,String> map= new HashMap<>();
Enumeration<String> attributesNames=req.getParameterNames();
while(attributesNames.hasMoreElements())
{
String item=attributesNames.nextElement();
int p=item.indexOf("_");
if(p>0) {
String suff=item.substring(p,item.length());
if("_filter".equals(suff)) {
String name = item.substring(0, p);
System.out.println(name);
map.put(name, req.getParameter(item));
}
}
}
List<Worker> list=controllerWorkers.select(map);
ResultSet resultQuery=null;
String htmlReq = "";
for(Worker w:list) {
htmlReq += "\n<tr>\n" +
" <td>" + Integer.toString(w.getId()) + "</td>\n" +
" <td>" + w.getLastName()+ "</td>\n" +
" <td>" + w.getFirstName()+ "</td>\n" +
" <td>" + w.getMiddleName() + "</td>\n" +
" <td><a href=\"time?action=info&id=" + Integer.toString(w.getId()) + "\">more...</a></td>\n" +
" </tr>";
}
req.setAttribute("select", htmlReq);
break;
default:break;
}
} catch (SQLException e) {
e.printStackTrace();
}
req.getRequestDispatcher("/time.jsp").forward(req, resp);
}
}
| UTF-8 | Java | 15,427 | java | WorkersServlet.java | Java | [
{
"context": "\r\n Worker newWorker=new Worker(firstName,birthDate,maxId+1,lastName,middleName,positionId,",
"end": 11183,
"score": 0.7230502367019653,
"start": 11174,
"tag": "NAME",
"value": "firstName"
},
{
"context": " newWorker=new Worker(firstName,birthDate,maxId+1,lastName,middleName,positionId,degreeId,parentId);\r\n ",
"end": 11210,
"score": 0.6634253263473511,
"start": 11202,
"tag": "NAME",
"value": "lastName"
},
{
"context": "r=new Worker(firstName,birthDate,maxId+1,lastName,middleName,positionId,degreeId,parentId);\r\n ",
"end": 11217,
"score": 0.8496493697166443,
"start": 11211,
"tag": "NAME",
"value": "middle"
}
] | null | [] |
import model.Degree;
import model.UniversityPosition;
import model.Worker;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
public class WorkersServlet extends HttpServlet {
public static final String POSITION_ID = "positionId";
public static final String DEGREE_ID = "degreeId";
public static final String PARENT_ID = "parentId";
public static final String FILTER="_filter";
private Controller controllerWorkers=null;
private Controller controllerPositions=null;
private Controller controllerDegrees=null;
public WorkersServlet() throws SQLException {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
if (Database.connection == null)
Database.connectDB();
if (controllerPositions == null) {
controllerPositions = new Controller<UniversityPosition>(new PositionTable());
}
if (controllerDegrees == null) {
controllerDegrees = new Controller<Degree>(new DegreeTable());
}
if (controllerWorkers == null) {
controllerWorkers = new Controller<Worker>(new WorkersTable(Database.connection));
}
String action = req.getParameter("action");
String htmlReq = "";
boolean flag = false;
int id;
List result = controllerPositions.selectAll();
String htmlReqPos = "";
String htmlReqParent = " ";
for (int i = 0; i < result.size(); i++) {
id = (((UniversityPosition) result.get(i)).getId());
String pos = (((UniversityPosition) result.get(i)).getPosition());
htmlReqPos += " <option value=\"" + Integer.toString(id) + "\">" + pos + "</option>\n";
}
req.setAttribute("htmlPos", htmlReqPos);
result = controllerDegrees.selectAll();
String htmlReqDeg = "";
for (int i = 0; i < result.size(); i++) {
id = (((Degree) result.get(i)).getId());
String deg = (((Degree) result.get(i)).getDegree());
htmlReqDeg += " <option value=\"" + Integer.toString(id) + "\">" + deg + "</option>\n";
}
req.setAttribute("htmlDeg", htmlReqDeg);
if (action != null)
{
switch (action) {
case "info":
flag = true;
id = Integer.parseInt(req.getParameter("id"));
if (id >= 0) {
Worker worker = (Worker) controllerWorkers.select(id);
if (null == ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree()
|| 0 > worker.getDegreeId())
req.setAttribute("degree", "empty");
else
req.setAttribute("degree", ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree());
if (null == ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition() || 0 > worker.getPositionId())
req.setAttribute("position", "empty");
else
req.setAttribute("position", ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition());
req.setAttribute("worker", worker);
req.getRequestDispatcher("info.jsp").forward(req, resp);
} else
flag = false;
break;
case "update":
flag = true;
id = Integer.parseInt(req.getParameter("id"));
result = controllerWorkers.selectAll();
htmlReqParent = "";
for (int i = 0; i < result.size(); i++) {
int idSelect = (((Worker) result.get(i)).getId());
if (idSelect != id) {
String lastName = (((Worker) result.get(i)).getLastName());
String firstName = (((Worker) result.get(i)).getFirstName());
String middleName = (((Worker) result.get(i)).getMiddleName());
String birthDate = (((Worker) result.get(i)).getBirthDate());
htmlReqParent += " <option value=\"" + Integer.toString(idSelect) + "\">" + lastName + " " + firstName + " " +
middleName + " " + birthDate + "</option>\n";
}
}
req.setAttribute("htmlParent", htmlReqParent);
Worker worker = (Worker) controllerWorkers.select(id);
req.setAttribute("position", ((UniversityPosition) controllerPositions.select(worker.getPositionId())).getPosition());
req.setAttribute("degree", ((Degree) controllerDegrees.select(worker.getDegreeId())).getDegree());
req.setAttribute("worker", worker);
req.getRequestDispatcher("update.jsp").forward(req, resp);
break;
case "create":
/* */
result = controllerWorkers.selectAll();
htmlReqParent = "";
for (int i = 0; i < result.size(); i++) {
int idSelect = (((Worker) result.get(i)).getId());
String lastName = (((Worker) result.get(i)).getLastName());
String firstName = (((Worker) result.get(i)).getFirstName());
String middleName = (((Worker) result.get(i)).getMiddleName());
String birthDate = (((Worker) result.get(i)).getBirthDate());
htmlReqParent += " <option value=\"" + Integer.toString(idSelect) + "\">" + lastName + " " + firstName + " " +
middleName + " " + birthDate + "</option>\n";
}
req.setAttribute("htmlParent", htmlReqParent);
flag = true;
req.getRequestDispatcher("create.jsp").forward(req, resp);
break;
case "delete":
id = Integer.parseInt(req.getParameter("id"));
Worker w = (Worker) controllerWorkers.select(id);
List resultDelete = null;
if (w.getParentId() < 0) {
resultDelete = controllerWorkers.selectAll();
for (int i = 0; i < resultDelete.size(); i++) {
if (((Worker) resultDelete.get(i)).getId() == id) {
controllerWorkers.update(((Worker) resultDelete.get(i)).getId(), PARENT_ID, -2);
}
}
} else {
resultDelete = controllerWorkers.selectAll();
for (int i = 0; i < resultDelete.size(); i++) {
if (((Worker) resultDelete.get(i)).getId() == id) {
controllerWorkers.update(((Worker) resultDelete.get(i)).getId(), PARENT_ID, w.getParentId());
}
}
}
controllerWorkers.delete(id);
break;
}
}
if(flag==false)
{
result=controllerWorkers.selectAll();
for(int i=0;i<result.size();i++)
{
Worker w=(Worker)result.get(i);
htmlReq += "\n<tr>\n" +
" <td>" + Integer.toString(w.getId()) + "</td>\n" +
" <td>" + w.getLastName() + "</td>\n" +
" <td>" + w.getFirstName() + "</td>\n" +
" <td>" + w.getMiddleName() + "</td>\n" +
" <td><a href=\"time?action=info&id=" + Integer.toString(w.getId()) + "\">more...</a></td>\n" +
" </tr>";
}
req.setAttribute("select", htmlReq);
req.getRequestDispatcher("time.jsp").forward(req, resp);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("Enter doPost");
if(Database.connection==null) {
try {
Database.connectDB();
} catch (SQLException e) {
e.printStackTrace();
}
}
req.setCharacterEncoding("UTF-8");
String action = req.getParameter("action");
List result=null;
PreparedStatement preparedStatement = null;
try {
switch(action)
{
case "createSubmit":
if(controllerWorkers==null)
controllerWorkers = new Controller(new WorkersTable(Database.connection));
List resultWorkers=controllerWorkers.selectAll();
int maxId=-1;
for(int i=0;i<resultWorkers.size();i++)
{
Worker w=(Worker)resultWorkers.get(i);
if(w.getId()>maxId)
maxId=w.getId();
}
String lastName =req.getParameter("lastName");
String firstName=req.getParameter("firstName");
String middleName=req.getParameter("middleName");
String birthDate=req.getParameter("birthDate");
int positionId=Integer.parseInt(req.getParameter("selectPos"));
int degreeId=Integer.parseInt(req.getParameter("selectDeg"));
int parentId=Integer.parseInt(req.getParameter("selectParent"));
Worker newWorker=new Worker(firstName,birthDate,maxId+1,lastName,middleName,positionId,degreeId,parentId);
controllerWorkers.insert(newWorker);
doGet(req,resp);
break;
case "submit":
int id=Integer.parseInt(req.getParameter("id"));
if(controllerWorkers==null)
controllerWorkers = new Controller(new WorkersTable(Database.connection));
HashMap<String,String> mapUpdate=new HashMap<>();
mapUpdate.put("lastname",req.getParameter("lastName"));
mapUpdate.put("firstname",req.getParameter("firstName"));
mapUpdate.put("middlename",req.getParameter("middleName"));
mapUpdate.put("birthdate",req.getParameter("birthDate"));
mapUpdate.put(POSITION_ID,req.getParameter(POSITION_ID));
mapUpdate.put( DEGREE_ID,req.getParameter(DEGREE_ID));
mapUpdate.put( PARENT_ID,req.getParameter(PARENT_ID));
controllerWorkers.update(mapUpdate,id);
req.setAttribute("worker", controllerWorkers.select(id));
doGet(req,resp);
break;
case "show":
String sql = "";
if (Database.connection == null)
Database.connectDB();
result = controllerPositions.selectAll();
String htmlReqPos = "";
for(int i=0;i<result.size();i++) {
UniversityPosition up=(UniversityPosition) result.get(i);
htmlReqPos += " <option value=\""+Integer.toString(up.getId())+"\">"+up.getPosition()+"</option>\n" ;
}
req.setAttribute("htmlPos",htmlReqPos);
result = controllerDegrees.selectAll();
String htmlReqDeg = "";
for(int i=0;i<result.size();i++) {
Degree d=(Degree)result.get(i);
htmlReqDeg += " <option value=\""+Integer.toString(d.getId())+"\">"+d.getDegree()+"</option>\n" ;
}
req.setAttribute("htmlDeg",htmlReqDeg);
HashMap <String,String> map= new HashMap<>();
Enumeration<String> attributesNames=req.getParameterNames();
while(attributesNames.hasMoreElements())
{
String item=attributesNames.nextElement();
int p=item.indexOf("_");
if(p>0) {
String suff=item.substring(p,item.length());
if("_filter".equals(suff)) {
String name = item.substring(0, p);
System.out.println(name);
map.put(name, req.getParameter(item));
}
}
}
List<Worker> list=controllerWorkers.select(map);
ResultSet resultQuery=null;
String htmlReq = "";
for(Worker w:list) {
htmlReq += "\n<tr>\n" +
" <td>" + Integer.toString(w.getId()) + "</td>\n" +
" <td>" + w.getLastName()+ "</td>\n" +
" <td>" + w.getFirstName()+ "</td>\n" +
" <td>" + w.getMiddleName() + "</td>\n" +
" <td><a href=\"time?action=info&id=" + Integer.toString(w.getId()) + "\">more...</a></td>\n" +
" </tr>";
}
req.setAttribute("select", htmlReq);
break;
default:break;
}
} catch (SQLException e) {
e.printStackTrace();
}
req.getRequestDispatcher("/time.jsp").forward(req, resp);
}
}
| 15,427 | 0.45537 | 0.454074 | 340 | 43.367645 | 34.445057 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.702941 | false | false | 8 |
a2163136a62e6affd8f8499316a068ba2297d729 | 35,639,638,629,199 | f5152883136b90628fe3f344490febce61d1ab20 | /app/src/main/java/vn/ghtk/carrier/models/WorkPhoneLocation.java | 516e1accbc05d80f2fe6f8495be7cd36db00190e | [] | no_license | NguyenVanLeNguyen/Main_App | https://github.com/NguyenVanLeNguyen/Main_App | 55f53b979f0f39eb0d1c89c418c16d6773addc3c | 1a2f5534fe5c0978cdd1958e18d09393b6a24512 | refs/heads/master | 2020-06-18T17:38:54.945000 | 2019-07-11T11:48:07 | 2019-07-11T11:48:07 | 196,381,649 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package vn.ghtk.carrier.models;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by nghiamac on 6/12/17.
*/
public class WorkPhoneLocation implements Serializable {
public int type = 0;
public boolean isCallshop = false;
public String first_address = "";
public String full_name = "";
private String tel = "";
private String telShop = "";
public String codId;
public String codName;
public String subjectId;
public String userName;
private int mUserID;
private String mShopOrder;
public String mShopCode = "";
public String mShopInfor = "";
public ArrayList<PhoneOrder> orders;
public WorkPhoneLocation(WorkLocation workLocation) {
this.type = workLocation.type;
this.isCallshop = workLocation.isCallshop;
this.first_address = workLocation.first_address;
this.full_name = workLocation.codName;
this.tel = workLocation.getTel();
this.telShop = workLocation.getTelShop();
this.codId = workLocation.codId;
this.codName = workLocation.codName;
this.subjectId = workLocation.subjectId;
this.userName = workLocation.userName;
this.mUserID = workLocation.user_id;
this.mShopOrder = workLocation.shop_order;
this.mShopCode = workLocation.shop_code;
this.mShopInfor = workLocation.getShopInfor();
this.orders = workLocation.getPhoneOrders();
}
public String getTel(){
if(!tel.equals("")){
return stripNonDigits(tel);
}else {
return tel;
}
}
public String getTelShop(){
if(!telShop.equals("")){
return stripNonDigits(telShop);
}else {
return telShop;
}
}
public String getShopTelOrigin() {
if (orders.size() == 0) {
return "";
}
PhoneOrder order = orders.get(0);
String tel = order.getPickTel();
if (tel == null) {
tel = "";
}
return tel;
}
public String stripNonDigits(final CharSequence input){
final StringBuilder sb = new StringBuilder(input.length());
for(int i = 0; i < input.length(); i++){
final char c = input.charAt(i);
if(i == 0 && c == 43){
sb.append(c);
}else if(c > 47 && c < 58){
sb.append(c);
}
}
return sb.toString();
}
public void setTel(String tel){
this.tel = tel;
}
public void setTelShop(String tel){
this.telShop = tel;
}
public boolean isType(int type) {
return this.type == type;
}
}
| UTF-8 | Java | 2,698 | java | WorkPhoneLocation.java | Java | [
{
"context": "le;\nimport java.util.ArrayList;\n\n/**\n * Created by nghiamac on 6/12/17.\n */\n\npublic class WorkPhoneLocation i",
"end": 117,
"score": 0.9996976852416992,
"start": 109,
"tag": "USERNAME",
"value": "nghiamac"
}
] | null | [] | package vn.ghtk.carrier.models;
import java.io.Serializable;
import java.util.ArrayList;
/**
* Created by nghiamac on 6/12/17.
*/
public class WorkPhoneLocation implements Serializable {
public int type = 0;
public boolean isCallshop = false;
public String first_address = "";
public String full_name = "";
private String tel = "";
private String telShop = "";
public String codId;
public String codName;
public String subjectId;
public String userName;
private int mUserID;
private String mShopOrder;
public String mShopCode = "";
public String mShopInfor = "";
public ArrayList<PhoneOrder> orders;
public WorkPhoneLocation(WorkLocation workLocation) {
this.type = workLocation.type;
this.isCallshop = workLocation.isCallshop;
this.first_address = workLocation.first_address;
this.full_name = workLocation.codName;
this.tel = workLocation.getTel();
this.telShop = workLocation.getTelShop();
this.codId = workLocation.codId;
this.codName = workLocation.codName;
this.subjectId = workLocation.subjectId;
this.userName = workLocation.userName;
this.mUserID = workLocation.user_id;
this.mShopOrder = workLocation.shop_order;
this.mShopCode = workLocation.shop_code;
this.mShopInfor = workLocation.getShopInfor();
this.orders = workLocation.getPhoneOrders();
}
public String getTel(){
if(!tel.equals("")){
return stripNonDigits(tel);
}else {
return tel;
}
}
public String getTelShop(){
if(!telShop.equals("")){
return stripNonDigits(telShop);
}else {
return telShop;
}
}
public String getShopTelOrigin() {
if (orders.size() == 0) {
return "";
}
PhoneOrder order = orders.get(0);
String tel = order.getPickTel();
if (tel == null) {
tel = "";
}
return tel;
}
public String stripNonDigits(final CharSequence input){
final StringBuilder sb = new StringBuilder(input.length());
for(int i = 0; i < input.length(); i++){
final char c = input.charAt(i);
if(i == 0 && c == 43){
sb.append(c);
}else if(c > 47 && c < 58){
sb.append(c);
}
}
return sb.toString();
}
public void setTel(String tel){
this.tel = tel;
}
public void setTelShop(String tel){
this.telShop = tel;
}
public boolean isType(int type) {
return this.type == type;
}
}
| 2,698 | 0.580059 | 0.574129 | 105 | 24.695238 | 18.225113 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.495238 | false | false | 8 |
aeff47708c9aa721d5afba7d61c99b42feedcf42 | 31,026,843,771,956 | 708e68c7b019a64c64f22b4bfbadb4be2560676b | /LevelMaker/src/interfaces/Resizable.java | 652126a2aa01233521cb1369244387d8f94e3218 | [] | no_license | brandonhoward/level-maker | https://github.com/brandonhoward/level-maker | b77155ea813a1796527f661d3dae93fab5032b69 | 17ebc53003b1a12661f3271f55994444b042db2e | refs/heads/master | 2019-05-25T04:59:29.311000 | 2019-02-16T09:31:36 | 2019-02-16T09:31:36 | 85,145,287 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interfaces;
/**
* Created by Brandon on 5/16/2018.
*/
public interface Resizable {
void handleResize();
}
| UTF-8 | Java | 122 | java | Resizable.java | Java | [
{
"context": "package interfaces;\n\n/**\n * Created by Brandon on 5/16/2018.\n */\npublic interface Resizable {\n\n ",
"end": 46,
"score": 0.9996657967567444,
"start": 39,
"tag": "NAME",
"value": "Brandon"
}
] | null | [] | package interfaces;
/**
* Created by Brandon on 5/16/2018.
*/
public interface Resizable {
void handleResize();
}
| 122 | 0.672131 | 0.614754 | 9 | 12.555555 | 13.107344 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 8 |
27ceec3adf1c9de2dd468793b85e0837c059d5f6 | 35,313,221,118,584 | 366cbb0b437b7198448b1e640fc5f77fdb5437dd | /src/main/java/com/xiongdiyibeizi/controller/CompanyPictureController.java | 5ffbde32af69d46632bfa77fe9dc3813d5abb028 | [] | no_license | yrgithub/wushu | https://github.com/yrgithub/wushu | d4dc963a5013c1396a377515b0f3ed89ae6c8856 | 152aba8346b4b9b8bb778fa735e253275d4ff8cd | refs/heads/master | 2022-12-24T02:20:56.001000 | 2019-05-30T12:38:55 | 2019-05-30T12:38:55 | 189,233,937 | 0 | 0 | null | false | 2022-12-16T10:56:00 | 2019-05-29T13:44:38 | 2019-05-30T12:39:59 | 2022-12-16T10:55:57 | 65,614 | 0 | 0 | 10 | HTML | false | false | package com.xiongdiyibeizi.controller;
import com.xiongdiyibeizi.bean.user.CompanyPicture;
import com.xiongdiyibeizi.common.Contains;
import com.xiongdiyibeizi.config.ServerPathConfig;
import com.xiongdiyibeizi.service.api.CompanyPictureService;
import com.xiongdiyibeizi.service.api.CompanyService;
import com.xiongdiyibeizi.util.StringUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@RequestMapping("companyPicture")
@Controller
public class CompanyPictureController {
private static final Logger c_logger = Logger.getLogger(CompanyPictureController.class);
@Autowired
private CompanyPictureService companyPictureService;
@Resource
private ServerPathConfig serverPathConfig;
@RequestMapping(value = "uploadPicture",method = RequestMethod.POST)
@ResponseBody
public Object uploadPicture(MultipartFile file,
HttpServletRequest request)
{
Map map = new HashMap();
try{
//String path = request.getSession().getServletContext().getRealPath("\\upload\\");
String realName = file.getOriginalFilename();//上传文件的真实名称
String suffixName = realName.substring(realName.lastIndexOf("."));//文件后缀名
String hash = StringUtil.INST.getGeneralKey().replaceAll("-","");//自定义随机数作为文件名
String fileName = hash + suffixName;
String relativePath = serverPathConfig.getModuleName() +fileName;
String filePath = serverPathConfig.getUploadPath()+relativePath;
String ServerPath = serverPathConfig.getServerPath()+relativePath;
System.out.println("filePath: "+filePath);
System.out.println("ServerPath: "+ServerPath);
File tempFile = new File(filePath);
if (!tempFile.getParentFile().exists()){
tempFile.getParentFile().mkdirs();
}
file.transferTo(tempFile);
CompanyPicture companyPicture = new CompanyPicture();
String pictureId = StringUtil.INST.getGeneralKey();
companyPicture.setPictureId(pictureId);
companyPicture.setOriginalName(realName);
companyPicture.setPictureName(fileName);
companyPicture.setPicturePath(relativePath);
companyPicture.setSuffixName(suffixName);
companyPictureService.insert2picture(companyPicture);
map.put("code",0);
map.put("msg","");
map.put("count",0);
map.put("data",companyPicture);
return map;
}catch (Exception e)
{
c_logger.error("uploadPicture error:",e);
map.put("code",0);
map.put("msg","");
map.put("count",0);
map.put("data",1);
return map;
}
}
}
| UTF-8 | Java | 3,337 | java | CompanyPictureController.java | Java | [] | null | [] | package com.xiongdiyibeizi.controller;
import com.xiongdiyibeizi.bean.user.CompanyPicture;
import com.xiongdiyibeizi.common.Contains;
import com.xiongdiyibeizi.config.ServerPathConfig;
import com.xiongdiyibeizi.service.api.CompanyPictureService;
import com.xiongdiyibeizi.service.api.CompanyService;
import com.xiongdiyibeizi.util.StringUtil;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@RequestMapping("companyPicture")
@Controller
public class CompanyPictureController {
private static final Logger c_logger = Logger.getLogger(CompanyPictureController.class);
@Autowired
private CompanyPictureService companyPictureService;
@Resource
private ServerPathConfig serverPathConfig;
@RequestMapping(value = "uploadPicture",method = RequestMethod.POST)
@ResponseBody
public Object uploadPicture(MultipartFile file,
HttpServletRequest request)
{
Map map = new HashMap();
try{
//String path = request.getSession().getServletContext().getRealPath("\\upload\\");
String realName = file.getOriginalFilename();//上传文件的真实名称
String suffixName = realName.substring(realName.lastIndexOf("."));//文件后缀名
String hash = StringUtil.INST.getGeneralKey().replaceAll("-","");//自定义随机数作为文件名
String fileName = hash + suffixName;
String relativePath = serverPathConfig.getModuleName() +fileName;
String filePath = serverPathConfig.getUploadPath()+relativePath;
String ServerPath = serverPathConfig.getServerPath()+relativePath;
System.out.println("filePath: "+filePath);
System.out.println("ServerPath: "+ServerPath);
File tempFile = new File(filePath);
if (!tempFile.getParentFile().exists()){
tempFile.getParentFile().mkdirs();
}
file.transferTo(tempFile);
CompanyPicture companyPicture = new CompanyPicture();
String pictureId = StringUtil.INST.getGeneralKey();
companyPicture.setPictureId(pictureId);
companyPicture.setOriginalName(realName);
companyPicture.setPictureName(fileName);
companyPicture.setPicturePath(relativePath);
companyPicture.setSuffixName(suffixName);
companyPictureService.insert2picture(companyPicture);
map.put("code",0);
map.put("msg","");
map.put("count",0);
map.put("data",companyPicture);
return map;
}catch (Exception e)
{
c_logger.error("uploadPicture error:",e);
map.put("code",0);
map.put("msg","");
map.put("count",0);
map.put("data",1);
return map;
}
}
}
| 3,337 | 0.680864 | 0.678734 | 82 | 39.085365 | 24.868042 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.817073 | false | false | 8 |
18dd0001da4ff6a9f3ee3ee7938ddf8c4faa9d2c | 34,222,299,431,914 | 84da3274282fc1f739b886ae6ce857bc50b3d61a | /source/mmsmp-vac-ra/src/main/java/com/zbensoft/mmsmp/vac/ra/mina/listen/ServerSenderThread.java | be7b4a08627da0f7e0e13863e40a3e56fda05db0 | [] | no_license | SliTaz/mm7 | https://github.com/SliTaz/mm7 | 299b1809eb9a2f5f52687a01a7ce95d497014e6e | 99ed4e3437d0925ae1174dc2dd87f38befe8b47b | refs/heads/master | 2020-03-26T07:51:23.156000 | 2018-09-21T09:20:10 | 2018-09-21T09:20:10 | 144,674,514 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zbensoft.mmsmp.vac.ra.mina.listen;
import java.util.Date;
import java.util.Map;
import org.apache.log4j.Logger;
import com.zbensoft.mmsmp.common.ra.common.message.CheckRequest;
import com.zbensoft.mmsmp.vac.ra.aaa.Header;
import com.zbensoft.mmsmp.vac.ra.mina.util.MessageProcessor;
import com.zbensoft.mmsmp.vac.ra.mina.vac.VACConnectManager;
import com.zbensoft.mmsmp.vac.ra.util.PropertiesHelper;
import com.zbensoft.mmsmp.vac.ra.util.SequenceIDHelper;
public class ServerSenderThread implements Runnable {
private static final Logger logger = Logger.getLogger(ServerSenderThread.class);
private CheckMessageQuence cMessageQuence;
private String threadname;
private VACConnectManager connectManager = null;
public ServerSenderThread(CheckMessageQuence instance, String threadname) {
this.cMessageQuence = instance;
this.threadname = threadname;
}
public String getThreadame() {
return this.threadname;
}
private VACConnectManager getConnectManagerInstance() {
if (this.connectManager == null) {
this.connectManager = new VACConnectManager(this.threadname);
}
return this.connectManager;
}
public void run() {
getConnectManagerInstance().start();
Long intervel = PropertiesHelper.getVacAaaSendIntervel();
while (true) {
CheckRequest cRequest = null;
try {
cRequest = (CheckRequest) this.cMessageQuence.getRequestQuence().take();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
try {
if (cRequest != null) {
if (cRequest.getMessageid() == null) {
cRequest.setMessageid(SequenceIDHelper.getIntValue());
}
if ((!"6".equals(cRequest.getServiceType())) || (cRequest.getSrc_SequenceNumber() == null)) {
cRequest.setSrc_SequenceNumber(new Header().generateSequenceNumber("090102"));
}
logger.info("===========Src_SequenceNumber:" + cRequest.getSrc_SequenceNumber());
cRequest.setPutTime(new Date().getTime());
Map rMap = this.cMessageQuence.getRequestMap();
rMap.put(cRequest.getMessageid(), cRequest);
MessageProcessor.dealCheckRequest(cRequest, this.threadname);
}
} catch (RuntimeException e1) {
e1.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(intervel.longValue());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| UTF-8 | Java | 2,465 | java | ServerSenderThread.java | Java | [] | null | [] | package com.zbensoft.mmsmp.vac.ra.mina.listen;
import java.util.Date;
import java.util.Map;
import org.apache.log4j.Logger;
import com.zbensoft.mmsmp.common.ra.common.message.CheckRequest;
import com.zbensoft.mmsmp.vac.ra.aaa.Header;
import com.zbensoft.mmsmp.vac.ra.mina.util.MessageProcessor;
import com.zbensoft.mmsmp.vac.ra.mina.vac.VACConnectManager;
import com.zbensoft.mmsmp.vac.ra.util.PropertiesHelper;
import com.zbensoft.mmsmp.vac.ra.util.SequenceIDHelper;
public class ServerSenderThread implements Runnable {
private static final Logger logger = Logger.getLogger(ServerSenderThread.class);
private CheckMessageQuence cMessageQuence;
private String threadname;
private VACConnectManager connectManager = null;
public ServerSenderThread(CheckMessageQuence instance, String threadname) {
this.cMessageQuence = instance;
this.threadname = threadname;
}
public String getThreadame() {
return this.threadname;
}
private VACConnectManager getConnectManagerInstance() {
if (this.connectManager == null) {
this.connectManager = new VACConnectManager(this.threadname);
}
return this.connectManager;
}
public void run() {
getConnectManagerInstance().start();
Long intervel = PropertiesHelper.getVacAaaSendIntervel();
while (true) {
CheckRequest cRequest = null;
try {
cRequest = (CheckRequest) this.cMessageQuence.getRequestQuence().take();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
try {
if (cRequest != null) {
if (cRequest.getMessageid() == null) {
cRequest.setMessageid(SequenceIDHelper.getIntValue());
}
if ((!"6".equals(cRequest.getServiceType())) || (cRequest.getSrc_SequenceNumber() == null)) {
cRequest.setSrc_SequenceNumber(new Header().generateSequenceNumber("090102"));
}
logger.info("===========Src_SequenceNumber:" + cRequest.getSrc_SequenceNumber());
cRequest.setPutTime(new Date().getTime());
Map rMap = this.cMessageQuence.getRequestMap();
rMap.put(cRequest.getMessageid(), cRequest);
MessageProcessor.dealCheckRequest(cRequest, this.threadname);
}
} catch (RuntimeException e1) {
e1.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(intervel.longValue());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| 2,465 | 0.72211 | 0.718053 | 82 | 29.060976 | 25.367228 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.597561 | false | false | 8 |
c00ee363be3fc7057494c73b1684dd2dde198edb | 11,287,174,110,285 | b5206f0d24ea99e18610b2049877145a28fcf641 | /dagger2t/src/main/java/com/slzr/dagger2test/BeanComponent.java | 4c8d4ad06cb744354aeacb0ae2a7b223abafdae0 | [
"Apache-2.0"
] | permissive | loongX/AndroidDemo | https://github.com/loongX/AndroidDemo | 3b47a8bfac727244c6005ced56a1e362485a52de | edc918d7aaef1793ea385abd85431a1a7b833af6 | refs/heads/master | 2021-01-13T11:16:39.572000 | 2018-06-04T15:21:25 | 2018-06-04T15:21:25 | 77,328,469 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.slzr.dagger2test;
import javax.inject.Singleton;
import dagger.Component;
/**
* Created by pxl on 2017/9/14.
*/
@Singleton
@Component(modules = BeanModule.class)
public interface BeanComponent {
void inject(MainActivity activity);
//将BeanModule注入OtherClass
void inject(MainActivity.OtherClass otherClass);
}
| UTF-8 | Java | 344 | java | BeanComponent.java | Java | [
{
"context": "eton;\n\nimport dagger.Component;\n\n/**\n * Created by pxl on 2017/9/14.\n */\n@Singleton\n@Component(modules =",
"end": 110,
"score": 0.9995443224906921,
"start": 107,
"tag": "USERNAME",
"value": "pxl"
}
] | null | [] | package com.slzr.dagger2test;
import javax.inject.Singleton;
import dagger.Component;
/**
* Created by pxl on 2017/9/14.
*/
@Singleton
@Component(modules = BeanModule.class)
public interface BeanComponent {
void inject(MainActivity activity);
//将BeanModule注入OtherClass
void inject(MainActivity.OtherClass otherClass);
}
| 344 | 0.757396 | 0.733728 | 17 | 18.882353 | 16.925034 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | false | false | 8 |
c3bbedb15dafa32fd161bafb48df76e405ce2e02 | 6,390,911,405,726 | 9d5460b386e8fa324a950e662524073510076e42 | /for-basejava/src/main/java/com/alexstudy/designmodel/FactoryPattern/JinShang.java | 945e66bdf1a049d16b07f5cb6ee541d2506f9b62 | [] | no_license | AlexT1/codefortest | https://github.com/AlexT1/codefortest | 3994064b91f83fcb622281f8304c4442d2ef75fc | 2325ae4df884f8c2855a665b0c6b17d38bb48c14 | refs/heads/master | 2022-12-20T23:02:18.211000 | 2020-11-12T11:05:40 | 2020-11-12T11:05:40 | 118,699,433 | 0 | 0 | null | false | 2022-12-16T11:30:27 | 2018-01-24T02:24:00 | 2020-11-12T11:05:43 | 2022-12-16T11:30:24 | 147,976 | 0 | 0 | 8 | Java | false | false | package com.alexstudy.designmodel.FactoryPattern;
import com.alexstudy.util.FeeType;
import com.alexstudy.util.SourceType;
import java.util.Map;
/**
* @author AlexTong
* @ClassName JinShang
* @Description TODO()
* @date 2018/6/8 17:01:16
*/
public class JinShang implements ChannelStrategy{
public Map<SourceType,FeeType> setChannelRepayOrder() {
System.out.println("jinshang setChannelRepayOrder");
return null;
}
public Map<String,Integer> setChannelRankSequence(){
System.out.println("jinshang setChannelRankSequence");
return null;
}
}
| UTF-8 | Java | 591 | java | JinShang.java | Java | [
{
"context": "SourceType;\n\nimport java.util.Map;\n\n/**\n * @author AlexTong\n * @ClassName JinShang\n * @Description TODO()\n * ",
"end": 171,
"score": 0.9828268885612488,
"start": 163,
"tag": "NAME",
"value": "AlexTong"
}
] | null | [] | package com.alexstudy.designmodel.FactoryPattern;
import com.alexstudy.util.FeeType;
import com.alexstudy.util.SourceType;
import java.util.Map;
/**
* @author AlexTong
* @ClassName JinShang
* @Description TODO()
* @date 2018/6/8 17:01:16
*/
public class JinShang implements ChannelStrategy{
public Map<SourceType,FeeType> setChannelRepayOrder() {
System.out.println("jinshang setChannelRepayOrder");
return null;
}
public Map<String,Integer> setChannelRankSequence(){
System.out.println("jinshang setChannelRankSequence");
return null;
}
}
| 591 | 0.724196 | 0.703892 | 23 | 24.695652 | 21.09901 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.434783 | false | false | 8 |
72300061ce2c957e4fc5ecea695d7e705260f311 | 11,854,109,768,328 | a7f7cfd7af8e5323052414a33be81cf0d9e00de1 | /OneCampusDominator/app/src/main/java/tw/com/ischool/embaadmin/model/SchoolMapInfo.java | 63cbb70d953d5b49b7378e8c30b86cd99a17d321 | [] | no_license | dylan2013/myEMBA_Android | https://github.com/dylan2013/myEMBA_Android | 8b19ac9e34baf830e9e4460a0790457015ed55bc | 616a31347804779b46c442e0c011f1b4a613ede5 | refs/heads/master | 2016-08-11T09:10:39.394000 | 2016-03-11T09:02:58 | 2016-03-11T09:02:58 | 45,234,313 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tw.com.ischool.embaadmin.model;
import android.database.Cursor;
/**
* Created by jianwenlai on 15/6/22.
*/
public class SchoolMapInfo {
public static final int TYPE_JH_1 = 1;
public static final int TYPE_JH_2 = 2;
public static final int TYPE_SH_N = 4;
public static final int TYPE_EMBA = 3;
public static final int TYPE_SH = 0;
public static final int TYPE_UNKNOW = -1;
private static final String TYPE_NAME_SH = "高中日校";
private static final String TYPE_NAME_JH_1 = "國中新竹";
private static final String TYPE_NAME_JH_2 = "國中高雄";
private static final String TYPE_NAME_SH_N = "高中進校";
private static final String TYPE_NAME_EMBA = "EMBA";
private String title;
private String accesspoint;
private String coreSystem;
public SchoolMapInfo(Cursor cursor) {
this.title = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_TITLE));
this.accesspoint = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_ACCESSPOINT));
this.coreSystem = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_CORE_SYSTEM));
}
public String getTitle(){
return this.title;
}
public String getAccesspoint(){
return this.accesspoint;
}
public int getCoreSystem(){
if (coreSystem.equalsIgnoreCase(TYPE_NAME_SH))
return TYPE_SH;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_JH_1))
return TYPE_JH_1;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_JH_2))
return TYPE_JH_2;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_EMBA))
return TYPE_EMBA;
if(coreSystem.equalsIgnoreCase(TYPE_NAME_SH_N))
return TYPE_SH_N;
return TYPE_UNKNOW;
}
public String getCoreSystemName(){
return this.coreSystem;
}
}
| UTF-8 | Java | 1,884 | java | SchoolMapInfo.java | Java | [
{
"context": "import android.database.Cursor;\n\n/**\n * Created by jianwenlai on 15/6/22.\n */\npublic class SchoolMapInfo {\n\n ",
"end": 102,
"score": 0.9948681592941284,
"start": 92,
"tag": "USERNAME",
"value": "jianwenlai"
}
] | null | [] | package tw.com.ischool.embaadmin.model;
import android.database.Cursor;
/**
* Created by jianwenlai on 15/6/22.
*/
public class SchoolMapInfo {
public static final int TYPE_JH_1 = 1;
public static final int TYPE_JH_2 = 2;
public static final int TYPE_SH_N = 4;
public static final int TYPE_EMBA = 3;
public static final int TYPE_SH = 0;
public static final int TYPE_UNKNOW = -1;
private static final String TYPE_NAME_SH = "高中日校";
private static final String TYPE_NAME_JH_1 = "國中新竹";
private static final String TYPE_NAME_JH_2 = "國中高雄";
private static final String TYPE_NAME_SH_N = "高中進校";
private static final String TYPE_NAME_EMBA = "EMBA";
private String title;
private String accesspoint;
private String coreSystem;
public SchoolMapInfo(Cursor cursor) {
this.title = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_TITLE));
this.accesspoint = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_ACCESSPOINT));
this.coreSystem = cursor.getString(cursor.getColumnIndex(SchoolMapHelper.COLUMN_CORE_SYSTEM));
}
public String getTitle(){
return this.title;
}
public String getAccesspoint(){
return this.accesspoint;
}
public int getCoreSystem(){
if (coreSystem.equalsIgnoreCase(TYPE_NAME_SH))
return TYPE_SH;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_JH_1))
return TYPE_JH_1;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_JH_2))
return TYPE_JH_2;
if (coreSystem.equalsIgnoreCase(TYPE_NAME_EMBA))
return TYPE_EMBA;
if(coreSystem.equalsIgnoreCase(TYPE_NAME_SH_N))
return TYPE_SH_N;
return TYPE_UNKNOW;
}
public String getCoreSystemName(){
return this.coreSystem;
}
}
| 1,884 | 0.665767 | 0.655508 | 63 | 28.396826 | 25.451191 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 8 |
d186c57fa6e708f5a7f45ea5518914d22ee4b015 | 36,429,912,613,314 | 7b402e28fbc21fae263eebcb5fbecacb074aa46c | /src/analyzer/SummarizationAnalyzer.java | 14c62d5f56b1159679e36e77ee806eac9eb7229f | [] | no_license | houzhenggang/summarization | https://github.com/houzhenggang/summarization | 4418d5e6a2f36f36725d82637f850aae5185dbc8 | 6128acc3b294c7641dcd1436f38a26cb89793d9f | refs/heads/master | 2021-01-15T22:52:18.760000 | 2014-03-28T12:58:41 | 2014-03-28T12:58:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package analyzer;
import java.util.ArrayList;
import model.Passage;
import model.SummarizationResult;
import controller.SummarizationPrepressor;
public abstract class SummarizationAnalyzer {
public ArrayList<SummarizationResult> analyze(String targetPath){
System.out.println("开始进行摘要...");
ArrayList<Passage> passages = SummarizationPrepressor.extractEvaluatePassageFromFolder(targetPath);
ArrayList<SummarizationResult> resultArrayList = new ArrayList<SummarizationResult>();
this.analyze(passages, resultArrayList);
for (int i = 0; i < passages.size(); i++) {
resultArrayList.get(i).originalAbstract = passages.get(i).getOriginalAbstractString();
resultArrayList.get(i).originalLength = passages.get(i).getLength();
}
System.out.println("摘要结束");
return resultArrayList;
}
abstract public void analyze(ArrayList<Passage> passages, ArrayList<SummarizationResult> results);
}
| UTF-8 | Java | 942 | java | SummarizationAnalyzer.java | Java | [] | null | [] | package analyzer;
import java.util.ArrayList;
import model.Passage;
import model.SummarizationResult;
import controller.SummarizationPrepressor;
public abstract class SummarizationAnalyzer {
public ArrayList<SummarizationResult> analyze(String targetPath){
System.out.println("开始进行摘要...");
ArrayList<Passage> passages = SummarizationPrepressor.extractEvaluatePassageFromFolder(targetPath);
ArrayList<SummarizationResult> resultArrayList = new ArrayList<SummarizationResult>();
this.analyze(passages, resultArrayList);
for (int i = 0; i < passages.size(); i++) {
resultArrayList.get(i).originalAbstract = passages.get(i).getOriginalAbstractString();
resultArrayList.get(i).originalLength = passages.get(i).getLength();
}
System.out.println("摘要结束");
return resultArrayList;
}
abstract public void analyze(ArrayList<Passage> passages, ArrayList<SummarizationResult> results);
}
| 942 | 0.774403 | 0.773319 | 30 | 29.733334 | 32.314014 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.833333 | false | false | 8 |
5b6208c34ad89b601e94071f593164e6ef4c53ad | 35,502,199,680,063 | 2ee02d512162648c976a6321ad939b49af6d530d | /src/main/java/xavier/xavierblogcms/controller/FrontPageController.java | f71bfa9b431547c141418e6996a51298095c8072 | [
"Apache-2.0"
] | permissive | KrissSaviour/Blog-CMS | https://github.com/KrissSaviour/Blog-CMS | 81ea336c6074b104aa447a61aa22b677a33f6919 | 4ad6492b446468dcceafd648a27b33403996d170 | refs/heads/master | 2020-04-16T16:52:07.204000 | 2019-01-15T01:06:28 | 2019-01-15T01:06:28 | 165,752,758 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package xavier.xavierblogcms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import xavier.xavierblogcms.models.Post;
import xavier.xavierblogcms.models.PostCategory;
import xavier.xavierblogcms.repository.PostCategoryRepository;
import xavier.xavierblogcms.repository.PostRepository;
import xavier.xavierblogcms.service.impl.PostServiceImpl;
import java.util.List;
@Controller
public class FrontPageController {
@Autowired
private PostServiceImpl postSerImpl;
@Autowired
private PostRepository postRepo;
@Autowired
private PostCategoryRepository postCatRepo;
@RequestMapping("/home")
public String index(Model model){
model.addAttribute("poss",postSerImpl.findAllPost());
model.addAttribute("postCat",postCatRepo.findAll());
return "home";
}
@RequestMapping("/category")
public String showCategories(Model model){
model.addAttribute("postCat",postCatRepo.findAll());
model.addAttribute("pageTitle","Xaiver Blog : Post Categories");
return "postCategories";
}
@RequestMapping("/view{id}")
public String viewPost(Model model,@PathVariable(name="id") Long id){
Post post = postSerImpl.findOne(id);
model.addAttribute("post",post);
model.addAttribute("pageTitle","Xaiver Blog : "+post.getPostName());
return "viewPost";
}
@RequestMapping(value="/postCat{id}", method=RequestMethod.GET)
public String category(Model model, @PathVariable(name="id") Long id){
PostCategory cat = postCatRepo.getOne(id);
List<Post> posts = cat.getPosts();
model.addAttribute("posts",posts);
model.addAttribute("title", "Posts in category: "+ cat.getCategoryName());
if (posts.isEmpty()){model.addAttribute("emptyCat",true);
}
model.addAttribute("pageTitle","Xaiver Blog : Posts in Category "+cat.getCategoryName());
return"postCategory";
}
@RequestMapping("/about")
public String aboutPage(Model model){
model.addAttribute("pageTitle","Xaiver Blog : About Page");
return "about";
}
}
| UTF-8 | Java | 2,408 | java | FrontPageController.java | Java | [] | null | [] | package xavier.xavierblogcms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import xavier.xavierblogcms.models.Post;
import xavier.xavierblogcms.models.PostCategory;
import xavier.xavierblogcms.repository.PostCategoryRepository;
import xavier.xavierblogcms.repository.PostRepository;
import xavier.xavierblogcms.service.impl.PostServiceImpl;
import java.util.List;
@Controller
public class FrontPageController {
@Autowired
private PostServiceImpl postSerImpl;
@Autowired
private PostRepository postRepo;
@Autowired
private PostCategoryRepository postCatRepo;
@RequestMapping("/home")
public String index(Model model){
model.addAttribute("poss",postSerImpl.findAllPost());
model.addAttribute("postCat",postCatRepo.findAll());
return "home";
}
@RequestMapping("/category")
public String showCategories(Model model){
model.addAttribute("postCat",postCatRepo.findAll());
model.addAttribute("pageTitle","Xaiver Blog : Post Categories");
return "postCategories";
}
@RequestMapping("/view{id}")
public String viewPost(Model model,@PathVariable(name="id") Long id){
Post post = postSerImpl.findOne(id);
model.addAttribute("post",post);
model.addAttribute("pageTitle","Xaiver Blog : "+post.getPostName());
return "viewPost";
}
@RequestMapping(value="/postCat{id}", method=RequestMethod.GET)
public String category(Model model, @PathVariable(name="id") Long id){
PostCategory cat = postCatRepo.getOne(id);
List<Post> posts = cat.getPosts();
model.addAttribute("posts",posts);
model.addAttribute("title", "Posts in category: "+ cat.getCategoryName());
if (posts.isEmpty()){model.addAttribute("emptyCat",true);
}
model.addAttribute("pageTitle","Xaiver Blog : Posts in Category "+cat.getCategoryName());
return"postCategory";
}
@RequestMapping("/about")
public String aboutPage(Model model){
model.addAttribute("pageTitle","Xaiver Blog : About Page");
return "about";
}
}
| 2,408 | 0.719269 | 0.719269 | 69 | 33.898552 | 25.867638 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.710145 | false | false | 8 |
56ed56acc3e4ee28933195c8025e23814b1c69c3 | 16,045,997,842,686 | d834bd8712b35e4efea4c82fa6807af7fbb3df5f | /src/main/java/net/cytron/webservices/Cliente.java | d4c11abfb59b4772aaae52438f71d42910d76af4 | [] | no_license | Proteam01/webtests | https://github.com/Proteam01/webtests | d95826b68cc043c3b8dd53433a828ab344e91a03 | 2d9877bd87b572699d6ce275b4936a9a8251176d | refs/heads/master | 2016-08-12T14:38:54.689000 | 2015-10-25T21:52:41 | 2015-10-25T21:52:41 | 44,931,021 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package net.cytron.webservices;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Clase Java para cliente complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* <complexType name="cliente">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="activo" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="codbarras" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="condicionpago" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="creditoutilizado" type="{http://www.w3.org/2001/XMLSchema}double"/>
* <element name="diascredito" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="fechacreditocliente" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="fecharegistro" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="fechaultmodifica" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="idcliente" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="idvendedor" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="limitecredito" type="{http://www.w3.org/2001/XMLSchema}double"/>
* <element name="listaprecios" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="nomcliente" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="nomplantilla" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="pagaimpuestos" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="razonsocial" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="rfc" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="sincronizado" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "cliente", propOrder = {
"activo",
"codbarras",
"condicionpago",
"creditoutilizado",
"diascredito",
"fechacreditocliente",
"fecharegistro",
"fechaultmodifica",
"idcliente",
"idvendedor",
"limitecredito",
"listaprecios",
"nomcliente",
"nomplantilla",
"pagaimpuestos",
"razonsocial",
"rfc",
"sincronizado"
})
public class Cliente {
protected boolean activo;
protected String codbarras;
protected long condicionpago;
protected double creditoutilizado;
protected long diascredito;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fechacreditocliente;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fecharegistro;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fechaultmodifica;
protected long idcliente;
protected long idvendedor;
protected double limitecredito;
protected long listaprecios;
protected String nomcliente;
protected String nomplantilla;
protected boolean pagaimpuestos;
protected String razonsocial;
protected String rfc;
protected boolean sincronizado;
/**
* Obtiene el valor de la propiedad activo.
*
*/
public boolean isActivo() {
return activo;
}
/**
* Define el valor de la propiedad activo.
*
*/
public void setActivo(boolean value) {
this.activo = value;
}
/**
* Obtiene el valor de la propiedad codbarras.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCodbarras() {
return codbarras;
}
/**
* Define el valor de la propiedad codbarras.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCodbarras(String value) {
this.codbarras = value;
}
/**
* Obtiene el valor de la propiedad condicionpago.
*
*/
public long getCondicionpago() {
return condicionpago;
}
/**
* Define el valor de la propiedad condicionpago.
*
*/
public void setCondicionpago(long value) {
this.condicionpago = value;
}
/**
* Obtiene el valor de la propiedad creditoutilizado.
*
*/
public double getCreditoutilizado() {
return creditoutilizado;
}
/**
* Define el valor de la propiedad creditoutilizado.
*
*/
public void setCreditoutilizado(double value) {
this.creditoutilizado = value;
}
/**
* Obtiene el valor de la propiedad diascredito.
*
*/
public long getDiascredito() {
return diascredito;
}
/**
* Define el valor de la propiedad diascredito.
*
*/
public void setDiascredito(long value) {
this.diascredito = value;
}
/**
* Obtiene el valor de la propiedad fechacreditocliente.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFechacreditocliente() {
return fechacreditocliente;
}
/**
* Define el valor de la propiedad fechacreditocliente.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFechacreditocliente(XMLGregorianCalendar value) {
this.fechacreditocliente = value;
}
/**
* Obtiene el valor de la propiedad fecharegistro.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFecharegistro() {
return fecharegistro;
}
/**
* Define el valor de la propiedad fecharegistro.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFecharegistro(XMLGregorianCalendar value) {
this.fecharegistro = value;
}
/**
* Obtiene el valor de la propiedad fechaultmodifica.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFechaultmodifica() {
return fechaultmodifica;
}
/**
* Define el valor de la propiedad fechaultmodifica.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFechaultmodifica(XMLGregorianCalendar value) {
this.fechaultmodifica = value;
}
/**
* Obtiene el valor de la propiedad idcliente.
*
*/
public long getIdcliente() {
return idcliente;
}
/**
* Define el valor de la propiedad idcliente.
*
*/
public void setIdcliente(long value) {
this.idcliente = value;
}
/**
* Obtiene el valor de la propiedad idvendedor.
*
*/
public long getIdvendedor() {
return idvendedor;
}
/**
* Define el valor de la propiedad idvendedor.
*
*/
public void setIdvendedor(long value) {
this.idvendedor = value;
}
/**
* Obtiene el valor de la propiedad limitecredito.
*
*/
public double getLimitecredito() {
return limitecredito;
}
/**
* Define el valor de la propiedad limitecredito.
*
*/
public void setLimitecredito(double value) {
this.limitecredito = value;
}
/**
* Obtiene el valor de la propiedad listaprecios.
*
*/
public long getListaprecios() {
return listaprecios;
}
/**
* Define el valor de la propiedad listaprecios.
*
*/
public void setListaprecios(long value) {
this.listaprecios = value;
}
/**
* Obtiene el valor de la propiedad nomcliente.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNomcliente() {
return nomcliente;
}
/**
* Define el valor de la propiedad nomcliente.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNomcliente(String value) {
this.nomcliente = value;
}
/**
* Obtiene el valor de la propiedad nomplantilla.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNomplantilla() {
return nomplantilla;
}
/**
* Define el valor de la propiedad nomplantilla.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNomplantilla(String value) {
this.nomplantilla = value;
}
/**
* Obtiene el valor de la propiedad pagaimpuestos.
*
*/
public boolean isPagaimpuestos() {
return pagaimpuestos;
}
/**
* Define el valor de la propiedad pagaimpuestos.
*
*/
public void setPagaimpuestos(boolean value) {
this.pagaimpuestos = value;
}
/**
* Obtiene el valor de la propiedad razonsocial.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRazonsocial() {
return razonsocial;
}
/**
* Define el valor de la propiedad razonsocial.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRazonsocial(String value) {
this.razonsocial = value;
}
/**
* Obtiene el valor de la propiedad rfc.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRfc() {
return rfc;
}
/**
* Define el valor de la propiedad rfc.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRfc(String value) {
this.rfc = value;
}
/**
* Obtiene el valor de la propiedad sincronizado.
*
*/
public boolean isSincronizado() {
return sincronizado;
}
/**
* Define el valor de la propiedad sincronizado.
*
*/
public void setSincronizado(boolean value) {
this.sincronizado = value;
}
}
| UTF-8 | Java | 11,020 | java | Cliente.java | Java | [
{
"context": "\n \"limitecredito\",\n \"listaprecios\",\n \"nomcliente\",\n \"nomplantilla\",\n \"pagaimpuestos\",\n \"r",
"end": 2905,
"score": 0.5079902410507202,
"start": 2898,
"tag": "USERNAME",
"value": "cliente"
}
] | null | [] |
package net.cytron.webservices;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Clase Java para cliente complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* <complexType name="cliente">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="activo" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="codbarras" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="condicionpago" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="creditoutilizado" type="{http://www.w3.org/2001/XMLSchema}double"/>
* <element name="diascredito" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="fechacreditocliente" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="fecharegistro" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="fechaultmodifica" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="idcliente" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="idvendedor" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="limitecredito" type="{http://www.w3.org/2001/XMLSchema}double"/>
* <element name="listaprecios" type="{http://www.w3.org/2001/XMLSchema}long"/>
* <element name="nomcliente" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="nomplantilla" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="pagaimpuestos" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="razonsocial" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="rfc" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="sincronizado" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "cliente", propOrder = {
"activo",
"codbarras",
"condicionpago",
"creditoutilizado",
"diascredito",
"fechacreditocliente",
"fecharegistro",
"fechaultmodifica",
"idcliente",
"idvendedor",
"limitecredito",
"listaprecios",
"nomcliente",
"nomplantilla",
"pagaimpuestos",
"razonsocial",
"rfc",
"sincronizado"
})
public class Cliente {
protected boolean activo;
protected String codbarras;
protected long condicionpago;
protected double creditoutilizado;
protected long diascredito;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fechacreditocliente;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fecharegistro;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar fechaultmodifica;
protected long idcliente;
protected long idvendedor;
protected double limitecredito;
protected long listaprecios;
protected String nomcliente;
protected String nomplantilla;
protected boolean pagaimpuestos;
protected String razonsocial;
protected String rfc;
protected boolean sincronizado;
/**
* Obtiene el valor de la propiedad activo.
*
*/
public boolean isActivo() {
return activo;
}
/**
* Define el valor de la propiedad activo.
*
*/
public void setActivo(boolean value) {
this.activo = value;
}
/**
* Obtiene el valor de la propiedad codbarras.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCodbarras() {
return codbarras;
}
/**
* Define el valor de la propiedad codbarras.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCodbarras(String value) {
this.codbarras = value;
}
/**
* Obtiene el valor de la propiedad condicionpago.
*
*/
public long getCondicionpago() {
return condicionpago;
}
/**
* Define el valor de la propiedad condicionpago.
*
*/
public void setCondicionpago(long value) {
this.condicionpago = value;
}
/**
* Obtiene el valor de la propiedad creditoutilizado.
*
*/
public double getCreditoutilizado() {
return creditoutilizado;
}
/**
* Define el valor de la propiedad creditoutilizado.
*
*/
public void setCreditoutilizado(double value) {
this.creditoutilizado = value;
}
/**
* Obtiene el valor de la propiedad diascredito.
*
*/
public long getDiascredito() {
return diascredito;
}
/**
* Define el valor de la propiedad diascredito.
*
*/
public void setDiascredito(long value) {
this.diascredito = value;
}
/**
* Obtiene el valor de la propiedad fechacreditocliente.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFechacreditocliente() {
return fechacreditocliente;
}
/**
* Define el valor de la propiedad fechacreditocliente.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFechacreditocliente(XMLGregorianCalendar value) {
this.fechacreditocliente = value;
}
/**
* Obtiene el valor de la propiedad fecharegistro.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFecharegistro() {
return fecharegistro;
}
/**
* Define el valor de la propiedad fecharegistro.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFecharegistro(XMLGregorianCalendar value) {
this.fecharegistro = value;
}
/**
* Obtiene el valor de la propiedad fechaultmodifica.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getFechaultmodifica() {
return fechaultmodifica;
}
/**
* Define el valor de la propiedad fechaultmodifica.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setFechaultmodifica(XMLGregorianCalendar value) {
this.fechaultmodifica = value;
}
/**
* Obtiene el valor de la propiedad idcliente.
*
*/
public long getIdcliente() {
return idcliente;
}
/**
* Define el valor de la propiedad idcliente.
*
*/
public void setIdcliente(long value) {
this.idcliente = value;
}
/**
* Obtiene el valor de la propiedad idvendedor.
*
*/
public long getIdvendedor() {
return idvendedor;
}
/**
* Define el valor de la propiedad idvendedor.
*
*/
public void setIdvendedor(long value) {
this.idvendedor = value;
}
/**
* Obtiene el valor de la propiedad limitecredito.
*
*/
public double getLimitecredito() {
return limitecredito;
}
/**
* Define el valor de la propiedad limitecredito.
*
*/
public void setLimitecredito(double value) {
this.limitecredito = value;
}
/**
* Obtiene el valor de la propiedad listaprecios.
*
*/
public long getListaprecios() {
return listaprecios;
}
/**
* Define el valor de la propiedad listaprecios.
*
*/
public void setListaprecios(long value) {
this.listaprecios = value;
}
/**
* Obtiene el valor de la propiedad nomcliente.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNomcliente() {
return nomcliente;
}
/**
* Define el valor de la propiedad nomcliente.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNomcliente(String value) {
this.nomcliente = value;
}
/**
* Obtiene el valor de la propiedad nomplantilla.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNomplantilla() {
return nomplantilla;
}
/**
* Define el valor de la propiedad nomplantilla.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNomplantilla(String value) {
this.nomplantilla = value;
}
/**
* Obtiene el valor de la propiedad pagaimpuestos.
*
*/
public boolean isPagaimpuestos() {
return pagaimpuestos;
}
/**
* Define el valor de la propiedad pagaimpuestos.
*
*/
public void setPagaimpuestos(boolean value) {
this.pagaimpuestos = value;
}
/**
* Obtiene el valor de la propiedad razonsocial.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRazonsocial() {
return razonsocial;
}
/**
* Define el valor de la propiedad razonsocial.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRazonsocial(String value) {
this.razonsocial = value;
}
/**
* Obtiene el valor de la propiedad rfc.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRfc() {
return rfc;
}
/**
* Define el valor de la propiedad rfc.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRfc(String value) {
this.rfc = value;
}
/**
* Obtiene el valor de la propiedad sincronizado.
*
*/
public boolean isSincronizado() {
return sincronizado;
}
/**
* Define el valor de la propiedad sincronizado.
*
*/
public void setSincronizado(boolean value) {
this.sincronizado = value;
}
}
| 11,020 | 0.584029 | 0.574682 | 443 | 23.873589 | 23.742455 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.293454 | false | false | 8 |
c2b511058f6762f44402c0e0839f8e36a1115c25 | 27,419,071,280,532 | 06cb682c821e8a384640286438c4953f315be4a0 | /eSpotifai Server/src/view/components/SongListRowCellRenderer.java | e13470e587e84262a2f804b38d042f3262f2464e | [] | no_license | dpoo-crew/spotyfai | https://github.com/dpoo-crew/spotyfai | 86dd8bc014ee401aeace30f0fa369e692a741ba6 | 44acb7e781b39bcbace44485050c45602676e80a | refs/heads/master | 2021-01-23T19:36:13.358000 | 2015-05-27T14:19:10 | 2015-05-27T14:19:10 | 33,725,950 | 0 | 0 | null | false | 2015-05-27T14:19:11 | 2015-04-10T11:51:32 | 2015-04-28T06:46:12 | 2015-05-27T14:19:10 | 57,164 | 0 | 0 | 0 | Java | null | null | package view.components;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
//
public class SongListRowCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if(value instanceof SongListRow) {
SongListRow p = (SongListRow)value;
if(isSelected) {
p.setBackground( list.getSelectionBackground());
System.out.println("estic selected");
}
return p;
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
}
| UTF-8 | Java | 726 | java | SongListRowCellRenderer.java | Java | [] | null | [] | package view.components;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
//
public class SongListRowCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if(value instanceof SongListRow) {
SongListRow p = (SongListRow)value;
if(isSelected) {
p.setBackground( list.getSelectionBackground());
System.out.println("estic selected");
}
return p;
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
}
| 726 | 0.679063 | 0.679063 | 28 | 24.928572 | 31.712917 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.571429 | false | false | 8 |
d03355656d6136cea84a5839b1173c40b5963bb0 | 35,570,919,152,199 | eac27e1be42a0ae53ebf5f061bda5a09032e1ec0 | /practise/src/collectionframework/map/hashtable/HashTableWorkNHashMethodOverTest.java | 7fb4a9c3f188a9cc8aee0d69487c9df2c51deed1 | [] | no_license | vishwanathpal/L11-COUCHBASE | https://github.com/vishwanathpal/L11-COUCHBASE | 9a77c99573db016b3659bcea159a4bff7f50db34 | 557d9c471c9c78ae9edcafac4cb9fb8fcdd4d435 | refs/heads/master | 2020-10-01T16:56:10.675000 | 2019-12-12T10:47:30 | 2019-12-12T10:47:30 | 227,581,211 | 0 | 0 | null | false | 2020-09-09T19:45:27 | 2019-12-12T10:34:28 | 2019-12-12T10:57:56 | 2020-09-09T19:45:25 | 298 | 0 | 0 | 1 | Java | false | false | package collectionframework.map.hashtable;
import java.util.Hashtable;
public class HashTableWorkNHashMethodOverTest {
public static void main(String[] args) {
Hashtable<HashTableWorkNHashMethodOver, String> ht = new Hashtable<HashTableWorkNHashMethodOver, String>();
ht.put(new HashTableWorkNHashMethodOver(5), "A");
ht.put(new HashTableWorkNHashMethodOver(2), "B");
ht.put(new HashTableWorkNHashMethodOver(6), "C");
ht.put(new HashTableWorkNHashMethodOver(15), "D");
ht.put(new HashTableWorkNHashMethodOver(23), "E");
ht.put(new HashTableWorkNHashMethodOver(16), "F");
//ht.put(null, "dhu"); // NPE both key and value should not be null
System.out.println(ht);
}
}
//{6=c, 16=F, 5=A, 15=D, 2=B, 23=E}
//Hashtable going to create 11 bucket and fill the element based on the hashing technique. The order would be:
//From top to bottom and if multiple element in a single bucket then order would be right to left.
// if we change hashCode method of 'HashTableWorkNHashMethodOver' class as i%9 then the output would also change.
//if you change the initial capacity of the Hashtable object then output would be change for sure.
| UTF-8 | Java | 1,156 | java | HashTableWorkNHashMethodOverTest.java | Java | [] | null | [] | package collectionframework.map.hashtable;
import java.util.Hashtable;
public class HashTableWorkNHashMethodOverTest {
public static void main(String[] args) {
Hashtable<HashTableWorkNHashMethodOver, String> ht = new Hashtable<HashTableWorkNHashMethodOver, String>();
ht.put(new HashTableWorkNHashMethodOver(5), "A");
ht.put(new HashTableWorkNHashMethodOver(2), "B");
ht.put(new HashTableWorkNHashMethodOver(6), "C");
ht.put(new HashTableWorkNHashMethodOver(15), "D");
ht.put(new HashTableWorkNHashMethodOver(23), "E");
ht.put(new HashTableWorkNHashMethodOver(16), "F");
//ht.put(null, "dhu"); // NPE both key and value should not be null
System.out.println(ht);
}
}
//{6=c, 16=F, 5=A, 15=D, 2=B, 23=E}
//Hashtable going to create 11 bucket and fill the element based on the hashing technique. The order would be:
//From top to bottom and if multiple element in a single bucket then order would be right to left.
// if we change hashCode method of 'HashTableWorkNHashMethodOver' class as i%9 then the output would also change.
//if you change the initial capacity of the Hashtable object then output would be change for sure.
| 1,156 | 0.75173 | 0.733564 | 25 | 45.240002 | 36.723049 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 8 |
e3a4a41959769a03d70ca22a7714e49584a7782c | 7,275,674,622,520 | b059c646202d7dc95dc3fe360765534b3d6f6915 | /src/main/java/myProject_LSP/PolicyHandler.java | 7f98dd4a55b8430b0d20df0260bcba2f133ad8d1 | [] | no_license | ladyfirst15/final-cna-order | https://github.com/ladyfirst15/final-cna-order | 0c3683d5710024a0696a27d64ee8fbb645b783f0 | a5dd5565443e2ec7cfb657618b9edd1c6e8bc884 | refs/heads/master | 2022-12-16T13:53:23.510000 | 2020-09-14T01:02:35 | 2020-09-14T01:02:35 | 295,267,857 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package myProject_LSP;
import jdk.nashorn.internal.runtime.options.Option;
import myProject_LSP.config.kafka.KafkaProcessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class PolicyHandler{
@StreamListener(KafkaProcessor.INPUT)
public void onStringEventListener(@Payload String eventString){
}
@Autowired
OrderRepository orderRepository;
@StreamListener(KafkaProcessor.INPUT)
public void wheneverCookQtyChecked_CookCancelUpdate(@Payload CookQtyChecked cookQtyChecked){
if(cookQtyChecked.isMe()){
Optional<Order> orderOptional = orderRepository.findById(cookQtyChecked.getOrderId());
Order order = orderOptional.get();
//System.out.println("##### listener CookCancelUpdate : " + cookQtyChecked.toJson());
//order.setId(cookQtyChecked.getOrderId());
order.setStatus("ORDER : QTY OVER CANCELED");
orderRepository.save(order);
}
}
} | UTF-8 | Java | 1,311 | java | PolicyHandler.java | Java | [] | null | [] | package myProject_LSP;
import jdk.nashorn.internal.runtime.options.Option;
import myProject_LSP.config.kafka.KafkaProcessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class PolicyHandler{
@StreamListener(KafkaProcessor.INPUT)
public void onStringEventListener(@Payload String eventString){
}
@Autowired
OrderRepository orderRepository;
@StreamListener(KafkaProcessor.INPUT)
public void wheneverCookQtyChecked_CookCancelUpdate(@Payload CookQtyChecked cookQtyChecked){
if(cookQtyChecked.isMe()){
Optional<Order> orderOptional = orderRepository.findById(cookQtyChecked.getOrderId());
Order order = orderOptional.get();
//System.out.println("##### listener CookCancelUpdate : " + cookQtyChecked.toJson());
//order.setId(cookQtyChecked.getOrderId());
order.setStatus("ORDER : QTY OVER CANCELED");
orderRepository.save(order);
}
}
} | 1,311 | 0.751335 | 0.751335 | 37 | 34.459461 | 29.684462 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.459459 | false | false | 8 |
016396b903b6ecd9d0e50cb47acb2f6c59f9ce9e | 5,403,068,883,075 | dac2fef59764fb0c56a7bdca9dddae291a9fe8e5 | /01strategy/01use_inheritance/src/RedheadDuck.java | d313c105577d9541810b785e9f65a11b78ab5b0f | [] | no_license | yongnam-kwon/Head_First_Design_Pattern | https://github.com/yongnam-kwon/Head_First_Design_Pattern | 570e4c72e0ebff837931f2786548a5bd17bf9806 | cffd196ad5b8f0a39fc3d7b1ea0ecef9fc8543f9 | refs/heads/master | 2023-07-23T16:32:31.807000 | 2021-09-07T17:17:29 | 2021-09-07T17:17:29 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class RedheadDuck extends Duck {
@Override
void display() {
System.out.println("저는 홍머리오리입니다.");
}
}
| UTF-8 | Java | 147 | java | RedheadDuck.java | Java | [] | null | [] | public class RedheadDuck extends Duck {
@Override
void display() {
System.out.println("저는 홍머리오리입니다.");
}
}
| 147 | 0.614173 | 0.614173 | 6 | 20.166666 | 15.941734 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 8 |
fadb3186a6d82c68cc759bf115010e41275c1b00 | 30,880,814,887,193 | 952eb831861cb8648a5244b76a306ed467c69dd7 | /src/businesslayer/Main.java | 87ee1dd52c498139e63bc45c9d40cc304f292c98 | [] | no_license | jediburrito/Three-Layer-Architecture | https://github.com/jediburrito/Three-Layer-Architecture | d50853ff193bf890e3eda7c52f40b5ca7c85ddae | cc367e9e8714b7623bb10e0ccc83901717867440 | refs/heads/master | 2021-01-20T10:19:29.342000 | 2017-05-05T07:03:28 | 2017-05-05T07:03:28 | 90,345,515 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package businesslayer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import datalayer.UserDB;
import userinterface.UserControl;
import userinterface.guiInterface;
public class Main {
public static void main(String[] args) {
UserControl newGuy = new UserControl();
UserDB con = new UserDB();
try {
newGuy.main();
} catch (Exception e1) {
e1.printStackTrace();
System.out.println(e1);
}
try {
con.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
try {
con.createTable();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 784 | java | Main.java | Java | [] | null | [] | package businesslayer;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import datalayer.UserDB;
import userinterface.UserControl;
import userinterface.guiInterface;
public class Main {
public static void main(String[] args) {
UserControl newGuy = new UserControl();
UserDB con = new UserDB();
try {
newGuy.main();
} catch (Exception e1) {
e1.printStackTrace();
System.out.println(e1);
}
try {
con.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
try {
con.createTable();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| 784 | 0.557398 | 0.553571 | 64 | 10.25 | 12.299644 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.84375 | false | false | 8 |
95591009955368552b628b418a06219e79882487 | 2,388,001,847,205 | 85acc70f3fc66f2905399985ec22f608e92fd86b | /src/graphic/GamePanel.java | df1269903cff744b00ab2f9346fb4d8e82a25161 | [] | no_license | daniele122008/The_Fallen_King | https://github.com/daniele122008/The_Fallen_King | 643fe873734698b60ae8556ae3d3c43f9d7f82ca | 7d0c554539865bb8a34a2793a56ba529e6d262ca | refs/heads/master | 2021-05-01T02:52:59.720000 | 2015-06-28T13:52:08 | 2015-06-28T13:52:08 | 28,402,653 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package graphic;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import javax.swing.JPanel;
import execution.gamestate.GameStateManager;
@SuppressWarnings("serial")
public class GamePanel extends JPanel implements Runnable, KeyListener, MouseListener{
// options
private static Properties options;
public static int width;
public static int height;
// game thread
private Thread gameThread;
private boolean running;
private static int FPS = 60;
private static int targetTime = 1000/FPS;
// image
private BufferedImage image;
private Graphics2D g;
// game state manager
private GameStateManager gsm;
public GamePanel() {
super();
try {
options = new Properties();
loadProperties();
}catch(FileNotFoundException e) {
System.exit(0);
}
width = Integer.parseInt(options.getProperty("screen.width"));
height = Integer.parseInt(options.getProperty("screen.height"));
Dimension preferredSize = new Dimension(width, height);
this.setPreferredSize(preferredSize);
this.setFocusable(true);
this.requestFocusInWindow();
}
/**
* Metodo che carica le opzioni del programma dal file TFK.properties
* @throws FileNotFoundException file TFK.properties non trovato
*/
public static void loadProperties() throws FileNotFoundException {
InputStream inputStream = null;
try {
inputStream = new FileInputStream("TFK.properties");
options.load(inputStream);
} catch (FileNotFoundException e) {
System.out.println("Error: file TFK.properties not found!");
e.printStackTrace();
throw e;
} catch (IOException e) {
System.out.println("Error thile reading the TFK.properties file!");
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
System.out.println("Error while closing the input stream!");
e.printStackTrace();
}
}
}
/**
* Metodo che salva le opzioni del programma nel file TFK.properties
*/
public static void saveProperties() {
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream("TFK.properties");
options.store(outputStream, "TFK OPTIONS -- DO NOT EDIT MANUALLY");
} catch (FileNotFoundException e) {
System.out.println("Error: file TFK.properties not found!");
e.printStackTrace();
} catch (IOException e) {
System.out.println("Errore while writing the TFK.properties file!");
e.printStackTrace();
} finally {
try {
outputStream.close();
} catch (IOException e) {
System.out.println("Error while closing the output stream!");
e.printStackTrace();
}
}
}
/**
* Metodo che ritorna le opzioni
* @return oggetto contenente le opzioni
*/
public static Properties getProperties() {
return options;
}
/**
* Metodo che ricarica le proprieta del programma nel file TFK.properties
*/
public static void updateProperties() {
try {
loadProperties();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println("Options updated!");
}
public void addNotify() {
super.addNotify();
if(gameThread == null) {
gameThread = new Thread(this);
addKeyListener(this);
addMouseListener(this);
gameThread.start();
}
}
private void init() {
image = new BufferedImage(width, height , BufferedImage.TYPE_INT_RGB);
g = (Graphics2D) image.getGraphics();
running = true;
gsm = new GameStateManager();
}
@Override
public void run() {
init();
long start;
long elapsed;
long wait;
//game loop
while(running) {
start = System.nanoTime();
update();
draw();
drawToScreen();
elapsed = System.nanoTime() - start;
wait = targetTime - elapsed / 1000000;
if(wait < 0) wait = 1;
try {
Thread.sleep(wait);
}catch(Exception e) {
e.printStackTrace();
}
}
}
private void update() {
gsm.update();
}
private void draw() {
gsm.draw(g);
}
private void drawToScreen() {
Graphics g2 = getGraphics();
g2.drawImage(image, 0, 0, width, height, null);
g2.dispose();
}
@Override
public void mouseClicked(MouseEvent arg0) {
gsm.mouseClicked(arg0);
}
@Override
public void mouseEntered(MouseEvent arg0) {
gsm.mouseEntered(arg0);
}
@Override
public void mouseExited(MouseEvent arg0) {
gsm.mouseExited(arg0);
}
@Override
public void mousePressed(MouseEvent arg0) {
gsm.mousePressed(arg0);
}
@Override
public void mouseReleased(MouseEvent arg0) {
gsm.mouseReleased(arg0);
}
@Override
public void keyPressed(KeyEvent arg0) {
gsm.keyPressed(arg0);
}
@Override
public void keyReleased(KeyEvent arg0) {
gsm.keyReleased(arg0);
}
@Override
public void keyTyped(KeyEvent arg0) {
gsm.keyTyped(arg0);
}
}
| UTF-8 | Java | 5,349 | java | GamePanel.java | Java | [] | null | [] | package graphic;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import javax.swing.JPanel;
import execution.gamestate.GameStateManager;
@SuppressWarnings("serial")
public class GamePanel extends JPanel implements Runnable, KeyListener, MouseListener{
// options
private static Properties options;
public static int width;
public static int height;
// game thread
private Thread gameThread;
private boolean running;
private static int FPS = 60;
private static int targetTime = 1000/FPS;
// image
private BufferedImage image;
private Graphics2D g;
// game state manager
private GameStateManager gsm;
public GamePanel() {
super();
try {
options = new Properties();
loadProperties();
}catch(FileNotFoundException e) {
System.exit(0);
}
width = Integer.parseInt(options.getProperty("screen.width"));
height = Integer.parseInt(options.getProperty("screen.height"));
Dimension preferredSize = new Dimension(width, height);
this.setPreferredSize(preferredSize);
this.setFocusable(true);
this.requestFocusInWindow();
}
/**
* Metodo che carica le opzioni del programma dal file TFK.properties
* @throws FileNotFoundException file TFK.properties non trovato
*/
public static void loadProperties() throws FileNotFoundException {
InputStream inputStream = null;
try {
inputStream = new FileInputStream("TFK.properties");
options.load(inputStream);
} catch (FileNotFoundException e) {
System.out.println("Error: file TFK.properties not found!");
e.printStackTrace();
throw e;
} catch (IOException e) {
System.out.println("Error thile reading the TFK.properties file!");
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
System.out.println("Error while closing the input stream!");
e.printStackTrace();
}
}
}
/**
* Metodo che salva le opzioni del programma nel file TFK.properties
*/
public static void saveProperties() {
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream("TFK.properties");
options.store(outputStream, "TFK OPTIONS -- DO NOT EDIT MANUALLY");
} catch (FileNotFoundException e) {
System.out.println("Error: file TFK.properties not found!");
e.printStackTrace();
} catch (IOException e) {
System.out.println("Errore while writing the TFK.properties file!");
e.printStackTrace();
} finally {
try {
outputStream.close();
} catch (IOException e) {
System.out.println("Error while closing the output stream!");
e.printStackTrace();
}
}
}
/**
* Metodo che ritorna le opzioni
* @return oggetto contenente le opzioni
*/
public static Properties getProperties() {
return options;
}
/**
* Metodo che ricarica le proprieta del programma nel file TFK.properties
*/
public static void updateProperties() {
try {
loadProperties();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println("Options updated!");
}
public void addNotify() {
super.addNotify();
if(gameThread == null) {
gameThread = new Thread(this);
addKeyListener(this);
addMouseListener(this);
gameThread.start();
}
}
private void init() {
image = new BufferedImage(width, height , BufferedImage.TYPE_INT_RGB);
g = (Graphics2D) image.getGraphics();
running = true;
gsm = new GameStateManager();
}
@Override
public void run() {
init();
long start;
long elapsed;
long wait;
//game loop
while(running) {
start = System.nanoTime();
update();
draw();
drawToScreen();
elapsed = System.nanoTime() - start;
wait = targetTime - elapsed / 1000000;
if(wait < 0) wait = 1;
try {
Thread.sleep(wait);
}catch(Exception e) {
e.printStackTrace();
}
}
}
private void update() {
gsm.update();
}
private void draw() {
gsm.draw(g);
}
private void drawToScreen() {
Graphics g2 = getGraphics();
g2.drawImage(image, 0, 0, width, height, null);
g2.dispose();
}
@Override
public void mouseClicked(MouseEvent arg0) {
gsm.mouseClicked(arg0);
}
@Override
public void mouseEntered(MouseEvent arg0) {
gsm.mouseEntered(arg0);
}
@Override
public void mouseExited(MouseEvent arg0) {
gsm.mouseExited(arg0);
}
@Override
public void mousePressed(MouseEvent arg0) {
gsm.mousePressed(arg0);
}
@Override
public void mouseReleased(MouseEvent arg0) {
gsm.mouseReleased(arg0);
}
@Override
public void keyPressed(KeyEvent arg0) {
gsm.keyPressed(arg0);
}
@Override
public void keyReleased(KeyEvent arg0) {
gsm.keyReleased(arg0);
}
@Override
public void keyTyped(KeyEvent arg0) {
gsm.keyTyped(arg0);
}
}
| 5,349 | 0.67134 | 0.663862 | 229 | 21.358078 | 19.124123 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.048035 | false | false | 8 |
5bd47bbe6c580ce7e7091766b6934c9732a47562 | 9,972,914,095,473 | 85ab42ced23111fa9d5e8064d6b60501a2aa05d0 | /Weeklycontest/fallContest2020/c4.java | 9f15712b9badffb57a8927e37d1b1a9f46b3e0e5 | [] | no_license | j-tooyoung/leetcode-Solution | https://github.com/j-tooyoung/leetcode-Solution | 6807ee2e5fede35252f6872759e561a6f81eb597 | 7146224d70744dd679fb47a30633ec55048acc61 | refs/heads/master | 2021-04-23T17:10:35.825000 | 2021-03-15T13:32:04 | 2021-03-15T13:32:04 | 249,941,745 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fallContest2020;
/**
* 4. 快速公交
* https://leetcode-cn.com/contest/season/2020-fall/problems/meChtZ/
*/
public class c4 {
public int busRapidTransit(int target, int inc, int dec, int[] jump, int[] cost) {
return 0;
}
}
| UTF-8 | Java | 254 | java | c4.java | Java | [] | null | [] | package fallContest2020;
/**
* 4. 快速公交
* https://leetcode-cn.com/contest/season/2020-fall/problems/meChtZ/
*/
public class c4 {
public int busRapidTransit(int target, int inc, int dec, int[] jump, int[] cost) {
return 0;
}
}
| 254 | 0.646341 | 0.601626 | 12 | 19.5 | 27.010799 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 8 |
46dd2e2f74c1524e9b869bac45f01e051c41f97d | 25,855,703,157,208 | a26279b06ce2bd0e58bf586419364651613a3174 | /Desktop/android/skworkspace/MvpDemo/TvLib/src/main/java/com/yunos/tv/lib/SystemProUtils.java | 58388ff97c70b8558b5bd4b26e985d4046279b85 | [
"Apache-2.0"
] | permissive | yangbolin1/MyDemo_MVP | https://github.com/yangbolin1/MyDemo_MVP | f93e0d1f2c2a5b11b1ec5d854aa8f9297c3c08ca | 5c16bd2a3b063bd07699e0ba44af9d8bf1e49a3c | refs/heads/master | 2020-04-19T08:38:15.205000 | 2017-06-24T02:19:02 | 2017-06-24T02:19:03 | 168,070,779 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yunos.tv.lib;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SystemProUtils {
static int mFocusMode = 2;
public static boolean isQiyi = false;
public SystemProUtils() {
}
public static void setGlobalFocusMode(int mode) {
mFocusMode = mode;
}
public static int getGlobalFocusMode() {
return mFocusMode;
}
public static String getSystemVersion() {
String version = VERSION.RELEASE;
String[] versionArray = version.split("-");
return versionArray[0];
}
public static String getUUID() {
try {
Class e = Class.forName("com.yunos.baseservice.clouduuid.CloudUUID");
Method m = e.getMethod("getCloudUUID", new Class[0]);
String result = (String)m.invoke((Object)null, new Object[0]);
return !TextUtils.isEmpty(result) && !"false".equalsIgnoreCase(result)?result:"unknow_tv_imei";
} catch (ClassNotFoundException var3) {
return "unknow_tv_uuid";
} catch (NoSuchMethodException var4) {
return "unknow_tv_uuid";
} catch (Exception var5) {
var5.printStackTrace();
return "unknow_tv_uuid";
}
}
public static String getDomain() {
String prefix = "http://";
String posfix = "/";
String default_domain = "http://api.yunos.wasu.tv/";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi is falsenull, return default");
return default_domain;
} else {
return !TextUtils.isEmpty(result)?"http://" + result.trim().replaceAll("/", "") + "/":default_domain;
}
} catch (Exception var6) {
Log.w("System", "getDomain: error");
return default_domain;
}
}
public static String getDomainMTOP() {
String prefix = "http://";
String posfix = "/rest/api3.do?";
String default_domainmtop = "http://m.yunos.wasu.tv/rest/api3.do?";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi.mtop", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "getDomainMTOP falsenull,return default");
return default_domainmtop;
} else {
return !TextUtils.isEmpty(result)?"http://" + result.trim().replaceAll("/", "") + "/rest/api3.do?":default_domainmtop;
}
} catch (Exception var6) {
Log.w("System", "getDomainMTOP: error");
return default_domainmtop;
}
}
public static String getLicense() {
String liscence = "1";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.license", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi mtop is unknow!!!");
return liscence;
} else {
return TextUtils.isEmpty(result)?liscence:result.trim();
}
} catch (Exception var4) {
Log.w("System", "getLicense: error");
return liscence;
}
}
public static String getLogoPath() {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.license.logo", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi logo path is unknow!!!");
return null;
} else {
return result.trim();
}
} catch (Exception var3) {
Log.w("System", "getLogoPath: error");
return null;
}
}
public static String getContents() {
String defaultContent = "0,3,4,5";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi.cts", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi contents is unknow!!!");
return defaultContent;
} else {
return TextUtils.isEmpty(result)?defaultContent:result;
}
} catch (Exception var4) {
Log.w("System", "getContents: error");
return defaultContent;
}
}
public static String getManufacture() {
if(isQiyi) {
return "ali_haiertv";
} else {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.product.manufacturer", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "manufactuer is unknow!!!");
return "unknow_tv_manufactuer";
} else {
return TextUtils.isEmpty(result)?"":result;
}
} catch (Exception var3) {
Log.w("System", "getManufacture: error");
return "";
}
}
}
public static String getChip() {
if(isQiyi) {
return "amlogic_t866";
} else {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.product.chip", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "chip is unknow!!!");
return "unknow_tv_chip";
} else {
return TextUtils.isEmpty(result)?"":result;
}
} catch (Exception var3) {
Log.w("System", "getChip: error");
return "";
}
}
}
public static String getMediaParams() {
String strProp = getSystemProperties("ro.media.ability");
if(strProp != null && !TextUtils.isEmpty(strProp)) {
Log.d("media", "=====strProp====" + strProp);
return strProp;
} else {
Log.w("media", "=====strProp null====");
return "";
}
}
public static String getDeviceName() {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.product.model", "falsenull"});
return "falsenull".equals(result)?null:result;
} catch (Exception var3) {
var3.printStackTrace();
return null;
}
}
public static String getSystemProperties(String key) {
String value = null;
Class cls = null;
try {
cls = Class.forName("android.os.SystemProperties");
Method e = cls.getMethod("get", new Class[]{String.class});
Object object = cls.newInstance();
value = (String)e.invoke(object, new Object[]{key});
} catch (SecurityException var5) {
var5.printStackTrace();
} catch (NoSuchMethodException var6) {
var6.printStackTrace();
} catch (IllegalAccessException var7) {
var7.printStackTrace();
} catch (InstantiationException var8) {
var8.printStackTrace();
} catch (IllegalArgumentException var9) {
var9.printStackTrace();
} catch (InvocationTargetException var10) {
var10.printStackTrace();
} catch (ClassNotFoundException var11) {
var11.printStackTrace();
}
return value;
}
}
| UTF-8 | Java | 8,931 | java | SystemProUtils.java | Java | [] | null | [] | package com.yunos.tv.lib;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class SystemProUtils {
static int mFocusMode = 2;
public static boolean isQiyi = false;
public SystemProUtils() {
}
public static void setGlobalFocusMode(int mode) {
mFocusMode = mode;
}
public static int getGlobalFocusMode() {
return mFocusMode;
}
public static String getSystemVersion() {
String version = VERSION.RELEASE;
String[] versionArray = version.split("-");
return versionArray[0];
}
public static String getUUID() {
try {
Class e = Class.forName("com.yunos.baseservice.clouduuid.CloudUUID");
Method m = e.getMethod("getCloudUUID", new Class[0]);
String result = (String)m.invoke((Object)null, new Object[0]);
return !TextUtils.isEmpty(result) && !"false".equalsIgnoreCase(result)?result:"unknow_tv_imei";
} catch (ClassNotFoundException var3) {
return "unknow_tv_uuid";
} catch (NoSuchMethodException var4) {
return "unknow_tv_uuid";
} catch (Exception var5) {
var5.printStackTrace();
return "unknow_tv_uuid";
}
}
public static String getDomain() {
String prefix = "http://";
String posfix = "/";
String default_domain = "http://api.yunos.wasu.tv/";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi is falsenull, return default");
return default_domain;
} else {
return !TextUtils.isEmpty(result)?"http://" + result.trim().replaceAll("/", "") + "/":default_domain;
}
} catch (Exception var6) {
Log.w("System", "getDomain: error");
return default_domain;
}
}
public static String getDomainMTOP() {
String prefix = "http://";
String posfix = "/rest/api3.do?";
String default_domainmtop = "http://m.yunos.wasu.tv/rest/api3.do?";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi.mtop", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "getDomainMTOP falsenull,return default");
return default_domainmtop;
} else {
return !TextUtils.isEmpty(result)?"http://" + result.trim().replaceAll("/", "") + "/rest/api3.do?":default_domainmtop;
}
} catch (Exception var6) {
Log.w("System", "getDomainMTOP: error");
return default_domainmtop;
}
}
public static String getLicense() {
String liscence = "1";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.license", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi mtop is unknow!!!");
return liscence;
} else {
return TextUtils.isEmpty(result)?liscence:result.trim();
}
} catch (Exception var4) {
Log.w("System", "getLicense: error");
return liscence;
}
}
public static String getLogoPath() {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.license.logo", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi logo path is unknow!!!");
return null;
} else {
return result.trim();
}
} catch (Exception var3) {
Log.w("System", "getLogoPath: error");
return null;
}
}
public static String getContents() {
String defaultContent = "0,3,4,5";
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.domain.aliyingshi.cts", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "domain yingshi contents is unknow!!!");
return defaultContent;
} else {
return TextUtils.isEmpty(result)?defaultContent:result;
}
} catch (Exception var4) {
Log.w("System", "getContents: error");
return defaultContent;
}
}
public static String getManufacture() {
if(isQiyi) {
return "ali_haiertv";
} else {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.product.manufacturer", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "manufactuer is unknow!!!");
return "unknow_tv_manufactuer";
} else {
return TextUtils.isEmpty(result)?"":result;
}
} catch (Exception var3) {
Log.w("System", "getManufacture: error");
return "";
}
}
}
public static String getChip() {
if(isQiyi) {
return "amlogic_t866";
} else {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.yunos.product.chip", "falsenull"});
if("falsenull".equals(result)) {
Log.w("System", "chip is unknow!!!");
return "unknow_tv_chip";
} else {
return TextUtils.isEmpty(result)?"":result;
}
} catch (Exception var3) {
Log.w("System", "getChip: error");
return "";
}
}
}
public static String getMediaParams() {
String strProp = getSystemProperties("ro.media.ability");
if(strProp != null && !TextUtils.isEmpty(strProp)) {
Log.d("media", "=====strProp====" + strProp);
return strProp;
} else {
Log.w("media", "=====strProp null====");
return "";
}
}
public static String getDeviceName() {
try {
Class e = Class.forName("android.os.SystemProperties");
Method m = e.getMethod("get", new Class[]{String.class, String.class});
String result = (String)m.invoke((Object)null, new Object[]{"ro.product.model", "falsenull"});
return "falsenull".equals(result)?null:result;
} catch (Exception var3) {
var3.printStackTrace();
return null;
}
}
public static String getSystemProperties(String key) {
String value = null;
Class cls = null;
try {
cls = Class.forName("android.os.SystemProperties");
Method e = cls.getMethod("get", new Class[]{String.class});
Object object = cls.newInstance();
value = (String)e.invoke(object, new Object[]{key});
} catch (SecurityException var5) {
var5.printStackTrace();
} catch (NoSuchMethodException var6) {
var6.printStackTrace();
} catch (IllegalAccessException var7) {
var7.printStackTrace();
} catch (InstantiationException var8) {
var8.printStackTrace();
} catch (IllegalArgumentException var9) {
var9.printStackTrace();
} catch (InvocationTargetException var10) {
var10.printStackTrace();
} catch (ClassNotFoundException var11) {
var11.printStackTrace();
}
return value;
}
}
| 8,931 | 0.543948 | 0.538797 | 235 | 37.004257 | 28.914915 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.72766 | false | false | 8 |
4c7956dfcb5a7e76c2f77ee44abba7ee55a70b72 | 13,984,413,540,738 | 6d59613a8f0bf44f419de91d6ffe7cdcd6653001 | /common/common-module/src/main/java/com/union/aimei/common/vo/store/app/StoreBeauticianByAppointmentVo.java | 4b496182cbe69d0bf6a9050509bfd338d1be8e3e | [] | no_license | moutainhigh/amez-springcloud | https://github.com/moutainhigh/amez-springcloud | a343ce35e47af9281002e17d9f7707728ba86600 | b2880475ec454fa88b2d0ab6885a5a0ee7d6059a | refs/heads/master | 2021-10-22T13:50:55.343000 | 2019-03-11T09:31:21 | 2019-03-11T09:31:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.union.aimei.common.vo.store.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* 美容师查询条件(预约时间)
*
* @author liurenkai
* @time 2018/1/13 17:28
*/
@Data
@EqualsAndHashCode
@ApiModel("美容师查询条件(预约时间)")
public class StoreBeauticianByAppointmentVo implements Serializable {
@ApiModelProperty(value = "店铺ID")
private Integer storeId;
@ApiModelProperty(value = "预约时间")
private String appointmentTime;
}
| UTF-8 | Java | 624 | java | StoreBeauticianByAppointmentVo.java | Java | [
{
"context": ".Serializable;\n\n/**\n * 美容师查询条件(预约时间)\n *\n * @author liurenkai\n * @time 2018/1/13 17:28\n */\n@Data\n@EqualsAndHash",
"end": 262,
"score": 0.9996568560600281,
"start": 253,
"tag": "USERNAME",
"value": "liurenkai"
}
] | null | [] | package com.union.aimei.common.vo.store.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* 美容师查询条件(预约时间)
*
* @author liurenkai
* @time 2018/1/13 17:28
*/
@Data
@EqualsAndHashCode
@ApiModel("美容师查询条件(预约时间)")
public class StoreBeauticianByAppointmentVo implements Serializable {
@ApiModelProperty(value = "店铺ID")
private Integer storeId;
@ApiModelProperty(value = "预约时间")
private String appointmentTime;
}
| 624 | 0.757143 | 0.7375 | 27 | 19.74074 | 18.359764 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.296296 | false | false | 8 |
a88d433fbb36cfa88aaf1db92ef49d30c86cf740 | 14,010,183,342,124 | 55033e61f7ddae9eb63e7183650151fb7787f01b | /kraken-designtime-project/src/main/java/kraken/model/project/DefaultKrakenProjectFactory.java | b3f34b84b0dfafd3031f182ec58d8ece00a33ca6 | [
"Apache-2.0"
] | permissive | cothong/kraken-rules | https://github.com/cothong/kraken-rules | 7e53a47a44cbd4ecdb940542f0b44d3daaf3035b | 920a5a23492b8bc0a1c4621f674a145c53dea5c6 | refs/heads/main | 2023-08-30T00:50:14.186000 | 2021-11-15T16:12:36 | 2021-11-15T16:12:36 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2017 EIS Ltd and/or one of its affiliates.
*
* 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 kraken.model.project;
import java.text.MessageFormat;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kraken.model.project.exception.KrakenProjectValidationException;
import kraken.model.project.validator.KrakenProjectValidationService;
import kraken.model.project.validator.ValidationResult;
import kraken.model.resource.Resource;
import kraken.namespace.Namespaced;
/**
* Default implementation of {@link KrakenProjectFactory} based on {@link Resource} API
* that provides validated {@link KrakenProject} implementations as created by {@link KrakenProjectBuilder}.
*
* @author mulevicius
*/
public class DefaultKrakenProjectFactory implements KrakenProjectFactory {
private static final Logger logger = LoggerFactory.getLogger(DefaultKrakenProjectFactory.class);
private final KrakenProjectBuilder krakenProjectBuilder;
private final KrakenProjectValidationService krakenProjectValidationService;
public DefaultKrakenProjectFactory(KrakenProjectBuilder krakenProjectBuilder,
KrakenProjectValidationService krakenProjectValidationService) {
this.krakenProjectBuilder = krakenProjectBuilder;
this.krakenProjectValidationService = krakenProjectValidationService;
}
@Override
public KrakenProject createKrakenProject(String namespace) {
logger.trace("Building KrakenProject for: " + namespace);
KrakenProject krakenProject = krakenProjectBuilder.buildKrakenProject(namespace);
ValidationResult validationResult = krakenProjectValidationService.validate(krakenProject);
validationResult.logMessages(logger);
if(!validationResult.getErrors().isEmpty()) {
String namespaceName = namespace.equals(Namespaced.GLOBAL) ? "GLOBAL" : namespace;
String pattern = "KrakenProject for namespace ''{0}'' is not valid. Validation errors:\n{1}";
String validationErrors = validationResult.getErrors().stream()
.map(error -> error.toString())
.collect(Collectors.joining(System.lineSeparator()));
String message = MessageFormat.format(pattern, namespaceName, validationErrors);
throw new KrakenProjectValidationException(message);
}
return krakenProject;
}
}
| UTF-8 | Java | 2,987 | java | DefaultKrakenProjectFactory.java | Java | [
{
"context": "ted by {@link KrakenProjectBuilder}.\n *\n * @author mulevicius\n */\npublic class DefaultKrakenProjectFactory impl",
"end": 1284,
"score": 0.9992786049842834,
"start": 1274,
"tag": "USERNAME",
"value": "mulevicius"
}
] | null | [] | /*
* Copyright 2017 EIS Ltd and/or one of its affiliates.
*
* 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 kraken.model.project;
import java.text.MessageFormat;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kraken.model.project.exception.KrakenProjectValidationException;
import kraken.model.project.validator.KrakenProjectValidationService;
import kraken.model.project.validator.ValidationResult;
import kraken.model.resource.Resource;
import kraken.namespace.Namespaced;
/**
* Default implementation of {@link KrakenProjectFactory} based on {@link Resource} API
* that provides validated {@link KrakenProject} implementations as created by {@link KrakenProjectBuilder}.
*
* @author mulevicius
*/
public class DefaultKrakenProjectFactory implements KrakenProjectFactory {
private static final Logger logger = LoggerFactory.getLogger(DefaultKrakenProjectFactory.class);
private final KrakenProjectBuilder krakenProjectBuilder;
private final KrakenProjectValidationService krakenProjectValidationService;
public DefaultKrakenProjectFactory(KrakenProjectBuilder krakenProjectBuilder,
KrakenProjectValidationService krakenProjectValidationService) {
this.krakenProjectBuilder = krakenProjectBuilder;
this.krakenProjectValidationService = krakenProjectValidationService;
}
@Override
public KrakenProject createKrakenProject(String namespace) {
logger.trace("Building KrakenProject for: " + namespace);
KrakenProject krakenProject = krakenProjectBuilder.buildKrakenProject(namespace);
ValidationResult validationResult = krakenProjectValidationService.validate(krakenProject);
validationResult.logMessages(logger);
if(!validationResult.getErrors().isEmpty()) {
String namespaceName = namespace.equals(Namespaced.GLOBAL) ? "GLOBAL" : namespace;
String pattern = "KrakenProject for namespace ''{0}'' is not valid. Validation errors:\n{1}";
String validationErrors = validationResult.getErrors().stream()
.map(error -> error.toString())
.collect(Collectors.joining(System.lineSeparator()));
String message = MessageFormat.format(pattern, namespaceName, validationErrors);
throw new KrakenProjectValidationException(message);
}
return krakenProject;
}
}
| 2,987 | 0.746234 | 0.742216 | 70 | 41.671429 | 35.057796 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.471429 | false | false | 8 |
6136a7d78223add03a76aa95663d284d1b8bb788 | 26,980,984,593,504 | 3eaf6fef46b7893b9e97900925b7d9be34fa8620 | /okra-ax-remote/src/main/java/org/okraAx/room/module/RoomManager.java | 9d56065cbdf81b47445f962719a7d611dcefef63 | [
"Apache-2.0"
] | permissive | midniteblue/Okra-Ax | https://github.com/midniteblue/Okra-Ax | 4f8dd28e40f205b10619268d8d8e36c3accc6232 | af88e47a09a9a3e3bd93725ea117a3e4469b1d13 | refs/heads/master | 2021-07-10T21:26:33.481000 | 2017-10-10T17:14:46 | 2017-10-10T17:14:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //package org.okraAx.room.module;
//
//import org.springframework.stereotype.Service;
//
//import java.util.Map;
//import java.util.Set;
//import java.util.concurrent.ConcurrentHashMap;
//import java.util.stream.Collectors;
//
///**
// * @author : TinyZ.
// * @email : tinyzzh815@gmail.com
// * @since 1.0
// */
//@Service("roomManager")
//public class RoomManager {
//
// // roomId - room
// private static final Map<Long, Room> ROOMS = new ConcurrentHashMap<>();
//
// // uid - Room
// private static final Map<Long, Room> PLAYERS = new ConcurrentHashMap<>();
//
// public Room get(long roomId) {
// return ROOMS.get(roomId);
// }
//
// public Room getByUid(long uid) {
// return PLAYERS.get(uid);
// }
//
// public Set<Room> getAllRoom() {
// return ROOMS.values().stream().collect(Collectors.toSet());
// }
//
// public void put(long uid, Room room) {
// ROOMS.put(room.id(), room);
// PLAYERS.put(uid, room);
// }
//
// public void destroy(long roomId) {
// Room room = ROOMS.remove(roomId);
// if (room != null) {
// Set<Long> players = room.players();
// for (Long uid : players) {
// PLAYERS.remove(uid);
// }
// room.onDestroy();
// }
// }
//
// public void exit(long uid) {
// Room room = PLAYERS.remove(uid);
// if (room != null) {
// room.onExit(uid);
// }
// }
//}
| UTF-8 | Java | 1,473 | java | RoomManager.java | Java | [
{
"context": "va.util.stream.Collectors;\n//\n///**\n// * @author : TinyZ.\n// * @email : tinyzzh815@gmail.com\n// * @since 1",
"end": 253,
"score": 0.9995813369750977,
"start": 248,
"tag": "USERNAME",
"value": "TinyZ"
},
{
"context": "tors;\n//\n///**\n// * @author : TinyZ.\n// * @email : tinyzzh815@gmail.com\n// * @since 1.0\n// */\n//@Service(\"roomManager\")\n/",
"end": 289,
"score": 0.999930202960968,
"start": 269,
"tag": "EMAIL",
"value": "tinyzzh815@gmail.com"
}
] | null | [] | //package org.okraAx.room.module;
//
//import org.springframework.stereotype.Service;
//
//import java.util.Map;
//import java.util.Set;
//import java.util.concurrent.ConcurrentHashMap;
//import java.util.stream.Collectors;
//
///**
// * @author : TinyZ.
// * @email : <EMAIL>
// * @since 1.0
// */
//@Service("roomManager")
//public class RoomManager {
//
// // roomId - room
// private static final Map<Long, Room> ROOMS = new ConcurrentHashMap<>();
//
// // uid - Room
// private static final Map<Long, Room> PLAYERS = new ConcurrentHashMap<>();
//
// public Room get(long roomId) {
// return ROOMS.get(roomId);
// }
//
// public Room getByUid(long uid) {
// return PLAYERS.get(uid);
// }
//
// public Set<Room> getAllRoom() {
// return ROOMS.values().stream().collect(Collectors.toSet());
// }
//
// public void put(long uid, Room room) {
// ROOMS.put(room.id(), room);
// PLAYERS.put(uid, room);
// }
//
// public void destroy(long roomId) {
// Room room = ROOMS.remove(roomId);
// if (room != null) {
// Set<Long> players = room.players();
// for (Long uid : players) {
// PLAYERS.remove(uid);
// }
// room.onDestroy();
// }
// }
//
// public void exit(long uid) {
// Room room = PLAYERS.remove(uid);
// if (room != null) {
// room.onExit(uid);
// }
// }
//}
| 1,460 | 0.54243 | 0.539036 | 58 | 24.396551 | 19.376434 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413793 | false | false | 8 |
3b79e98266396a566cb3a20674428331d73cd6be | 30,786,325,608,125 | be11999a76a889705d2e7a84d3d444b6c7df196e | /src/main/java/net/customware/confluence/plugin/perimeter/SecureIncludeMacro.java | a579afca7a58b3e62be6f44031d1fdfd99072a96 | [
"BSD-3-Clause"
] | permissive | tied/perimeter | https://github.com/tied/perimeter | 064afbf1fd8813fccb1aa3318acf5ecac793d933 | d662deac0db7fce0e01f1c2c134f05a2d9207596 | refs/heads/master | 2021-04-29T16:02:45.765000 | 2017-04-10T10:58:11 | 2017-04-10T10:58:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (c) 2017, ServiceRocket Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of "ServiceRocket Inc" nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.customware.confluence.plugin.perimeter;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext;
import com.atlassian.confluence.content.render.xhtml.XhtmlException;
import com.atlassian.confluence.core.ConfluenceEntityObject;
import com.atlassian.confluence.core.ContentEntityManager;
import com.atlassian.confluence.core.ContentEntityObject;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
import com.atlassian.confluence.renderer.PageContext;
import com.atlassian.confluence.security.Permission;
import com.atlassian.confluence.security.PermissionManager;
import com.atlassian.confluence.servlet.FileServerServlet;
import com.atlassian.confluence.setup.BootstrapManager;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.util.GeneralUtil;
import com.atlassian.confluence.web.context.StaticHttpContext;
import com.atlassian.confluence.xhtml.api.XhtmlContent;
import com.atlassian.renderer.RenderContext;
import com.atlassian.renderer.v2.RenderMode;
import com.atlassian.renderer.v2.macro.BaseMacro;
import com.atlassian.renderer.v2.macro.MacroException;
import com.atlassian.spring.container.ContainerManager;
import com.atlassian.user.User;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import javax.xml.stream.XMLStreamException;
import java.util.Map;
import static com.atlassian.confluence.util.GeneralUtil.htmlEncode;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.slf4j.LoggerFactory.getLogger;
/**
* @since 2005-12-10
*/
public class SecureIncludeMacro extends BaseMacro implements Macro {
private static Logger log = getLogger(SecureIncludeMacro.class);
private static final String ID = "id";
public static final String ID_PARAM = "secureIncludeId";
public static final String LINK_PARAM = "secureIncludeLink";
public static final String PAGE_ID_PARAM = "pageId";
private ContentEntityManager contentEntityManager;
private PermissionManager permissionManager;
private UserAccessor userAccessor;
private BootstrapManager bootstrapManager;
private XhtmlContent xhtmlContent;
private LinkAssistant linkAssistant;
@Override
public String execute(Map params, String body, RenderContext renderContext) throws MacroException {
try {
return execute(params, body, new DefaultConversionContext(renderContext));
} catch (MacroExecutionException e) {
throw new MacroException(e);
}
}
@Override
public String execute(Map<String, String> params, String body, ConversionContext ctx) throws MacroExecutionException {
String id = isNotBlank(params.get(ID)) ? params.get(ID) : null;
if (id == null)
throw new MacroExecutionException("Please supply an id which is unique to this page.");
SecureIncludeData data = SecureIncludeData.load(ctx.getEntity(), id);
if (data == null) {
data = processRequest(id, ctx);
}
if (data != null) {
return includePage(id, data, ctx);
} else {
ConfluenceUser user = AuthenticatedUserThreadLocal.get();
if (permissionManager.hasPermission(user, Permission.EDIT, ctx.getEntity()))
return inputForm(id, ctx);
return "";
}
}
private String inputForm(String id, ConversionContext ctx) {
String link = getRequestParam(LINK_PARAM, null);
String ctxPath = ctx.getPageContext().getSiteRoot();
StringBuffer out = new StringBuffer();
out.append("<div style='border: 1px dashed gray'>");
out.append("<form id=\"secureIncludeForm_" + htmlEncode(id) + "\" name=\"secureIncludeForm\" method=\"post\" action=\"")
.append(ctxPath).append("/pages/viewpage.action?pageId=")
.append(ctx.getEntity().getId()).append("\">\n");
out.append("<input type=\"hidden\" name=\"").append(ID_PARAM)
.append("\" value=\"").append(htmlEncode(id)).append("\"/>\n");
if (link != null)
out.append("<div class='error'>The specified link does not exist or is not accessible.</div>\n");
out.append("<p>");
out.append("Enter the link to any other page you can view, in any space, and anyone who can view <i>this</i> page will be able to view it.<br/>");
out.append("<b>Link:</b> <input type='text' name='").append(LINK_PARAM)
.append("' value=\"").append((link == null) ? "" : link).append("\" width='20'/>");
out.append(" <input type='submit' name='go' value='Include'/>");
out.append("</p>\n");
out.append("</form>");
out.append("</div>");
return out.toString();
}
private SecureIncludeData processRequest(String id, ConversionContext ctx) {
if (id.equals(getRequestParam(ID_PARAM, null))) {
String link = getRequestParam(LINK_PARAM, null);
if (link != null && link.length() > 0) {
// Try to find the content.
ConfluenceEntityObject entity = linkAssistant.getEntityForWikiLink(ctx, link);
if (entity instanceof ContentEntityObject) {
User user = AuthenticatedUserThreadLocal.get();
if (permissionManager.hasPermission(user, Permission.VIEW, entity)) {
SecureIncludeData data = new SecureIncludeData();
data.setUsername(user.getName());
data.setContentId(entity.getId());
SecureIncludeData.save(ctx.getEntity(), id, data);
return data;
}
}
}
}
return null;
}
private String getRequestParam(String name, String defaultVal) {
if ((new StaticHttpContext()).getRequest() != null) {
String param = (new StaticHttpContext()).getRequest().getParameter(name);
if (isBlank(param)) {
return defaultVal;
} else {
return param;
}
}
return defaultVal;
}
private String includePage(String id, SecureIncludeData data, ConversionContext conversionContext) throws MacroExecutionException {
ContentEntityObject targetContent = getContentEntityManager().getById(data.getContentId());
if (targetContent == null) {
throw new MacroExecutionException("The targetContent this secure include accesses no longer exists.");
}
ConfluenceUser user = userAccessor.getUserByName(data.getUsername());
if (user == null) {
throw new MacroExecutionException("The user who set up this secure include no longer exists: " + data.getUsername());
}
if (!permissionManager.hasPermission(user, Permission.VIEW, targetContent)) {
throw new MacroExecutionException("The user who set up this secure include no longer has access to the resource.");
}
PageContext ctx = targetContent.toPageContext();
String contentIncludeId = SecureAttachmentDownload.ATTACHMENT_PATH + "/" + targetContent.getId()
+ "/" + conversionContext.getEntity().getId() + "/" + GeneralUtil.urlEncode(id);
String securePath = bootstrapManager.getWebAppContextPath() + contentIncludeId;
ctx.setSiteRoot(conversionContext.getPageContext().getSiteRoot());
ctx.setBaseUrl(conversionContext.getPageContext().getBaseUrl());
ctx.setImagePath(conversionContext.getPageContext().getImagePath());
ctx.setAttachmentsPath(securePath);
// Fake logging in as the original accessor...
ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
AuthenticatedUserThreadLocal.set(user);
//return subRenderer.render(targetContent.getContent(), ctx, RenderMode.ALL);
String rendered;
try {
rendered = xhtmlContent.convertStorageToView(targetContent.getBodyAsString(), conversionContext);
} catch (XhtmlException | XMLStreamException e) {
throw new MacroExecutionException(e.getMessage());
}
// Return to the real user...
AuthenticatedUserThreadLocal.set(currentUser);
rendered = replaceAttachmentUrls(rendered, data, contentIncludeId);
return rendered;
}
private String replaceAttachmentUrls(String rendered, SecureIncludeData data, String contentIncludeId) {
String attachmentUrl = "/" + FileServerServlet.SERVLET_PATH + "/" + FileServerServlet.ATTACHMENTS_URL_PREFIX + "/" + data.getContentId();
return rendered.replaceAll(attachmentUrl, contentIncludeId);
}
public boolean isInline() {
return false;
}
public boolean hasBody() {
return true;
}
public RenderMode getBodyRenderMode() {
return RenderMode.suppress(RenderMode.F_FIRST_PARA);
}
public BodyType getBodyType() {
return BodyType.NONE;
}
public OutputType getOutputType() {
return OutputType.INLINE;
}
public ContentEntityManager getContentEntityManager() {
if (contentEntityManager == null) {
contentEntityManager = (ContentEntityManager) ContainerManager.getComponent("contentEntityManager");
}
return contentEntityManager;
}
@Autowired
public void setPermissionManager(PermissionManager permissionManager) {
this.permissionManager = permissionManager;
}
@Autowired
public void setUserAccessor(UserAccessor userAccessor) {
this.userAccessor = userAccessor;
}
@Autowired
public void setBootstrapManager(BootstrapManager bootstrapManager) {
this.bootstrapManager = bootstrapManager;
}
@Autowired
public void setXhtmlContent(XhtmlContent xhtmlContent) {
this.xhtmlContent = xhtmlContent;
}
@Autowired
public void setLinkAssistant(LinkAssistant linkAssistant) {
this.linkAssistant = linkAssistant;
}
}
| UTF-8 | Java | 12,003 | java | SecureIncludeMacro.java | Java | [
{
"context": "eData();\n data.setUsername(user.getName());\n data.setContentId(ent",
"end": 7438,
"score": 0.7919986844062805,
"start": 7426,
"tag": "USERNAME",
"value": "user.getName"
}
] | null | [] | /*
* Copyright (c) 2017, ServiceRocket Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of "ServiceRocket Inc" nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS 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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.customware.confluence.plugin.perimeter;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext;
import com.atlassian.confluence.content.render.xhtml.XhtmlException;
import com.atlassian.confluence.core.ConfluenceEntityObject;
import com.atlassian.confluence.core.ContentEntityManager;
import com.atlassian.confluence.core.ContentEntityObject;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
import com.atlassian.confluence.renderer.PageContext;
import com.atlassian.confluence.security.Permission;
import com.atlassian.confluence.security.PermissionManager;
import com.atlassian.confluence.servlet.FileServerServlet;
import com.atlassian.confluence.setup.BootstrapManager;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.util.GeneralUtil;
import com.atlassian.confluence.web.context.StaticHttpContext;
import com.atlassian.confluence.xhtml.api.XhtmlContent;
import com.atlassian.renderer.RenderContext;
import com.atlassian.renderer.v2.RenderMode;
import com.atlassian.renderer.v2.macro.BaseMacro;
import com.atlassian.renderer.v2.macro.MacroException;
import com.atlassian.spring.container.ContainerManager;
import com.atlassian.user.User;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import javax.xml.stream.XMLStreamException;
import java.util.Map;
import static com.atlassian.confluence.util.GeneralUtil.htmlEncode;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.slf4j.LoggerFactory.getLogger;
/**
* @since 2005-12-10
*/
public class SecureIncludeMacro extends BaseMacro implements Macro {
private static Logger log = getLogger(SecureIncludeMacro.class);
private static final String ID = "id";
public static final String ID_PARAM = "secureIncludeId";
public static final String LINK_PARAM = "secureIncludeLink";
public static final String PAGE_ID_PARAM = "pageId";
private ContentEntityManager contentEntityManager;
private PermissionManager permissionManager;
private UserAccessor userAccessor;
private BootstrapManager bootstrapManager;
private XhtmlContent xhtmlContent;
private LinkAssistant linkAssistant;
@Override
public String execute(Map params, String body, RenderContext renderContext) throws MacroException {
try {
return execute(params, body, new DefaultConversionContext(renderContext));
} catch (MacroExecutionException e) {
throw new MacroException(e);
}
}
@Override
public String execute(Map<String, String> params, String body, ConversionContext ctx) throws MacroExecutionException {
String id = isNotBlank(params.get(ID)) ? params.get(ID) : null;
if (id == null)
throw new MacroExecutionException("Please supply an id which is unique to this page.");
SecureIncludeData data = SecureIncludeData.load(ctx.getEntity(), id);
if (data == null) {
data = processRequest(id, ctx);
}
if (data != null) {
return includePage(id, data, ctx);
} else {
ConfluenceUser user = AuthenticatedUserThreadLocal.get();
if (permissionManager.hasPermission(user, Permission.EDIT, ctx.getEntity()))
return inputForm(id, ctx);
return "";
}
}
private String inputForm(String id, ConversionContext ctx) {
String link = getRequestParam(LINK_PARAM, null);
String ctxPath = ctx.getPageContext().getSiteRoot();
StringBuffer out = new StringBuffer();
out.append("<div style='border: 1px dashed gray'>");
out.append("<form id=\"secureIncludeForm_" + htmlEncode(id) + "\" name=\"secureIncludeForm\" method=\"post\" action=\"")
.append(ctxPath).append("/pages/viewpage.action?pageId=")
.append(ctx.getEntity().getId()).append("\">\n");
out.append("<input type=\"hidden\" name=\"").append(ID_PARAM)
.append("\" value=\"").append(htmlEncode(id)).append("\"/>\n");
if (link != null)
out.append("<div class='error'>The specified link does not exist or is not accessible.</div>\n");
out.append("<p>");
out.append("Enter the link to any other page you can view, in any space, and anyone who can view <i>this</i> page will be able to view it.<br/>");
out.append("<b>Link:</b> <input type='text' name='").append(LINK_PARAM)
.append("' value=\"").append((link == null) ? "" : link).append("\" width='20'/>");
out.append(" <input type='submit' name='go' value='Include'/>");
out.append("</p>\n");
out.append("</form>");
out.append("</div>");
return out.toString();
}
private SecureIncludeData processRequest(String id, ConversionContext ctx) {
if (id.equals(getRequestParam(ID_PARAM, null))) {
String link = getRequestParam(LINK_PARAM, null);
if (link != null && link.length() > 0) {
// Try to find the content.
ConfluenceEntityObject entity = linkAssistant.getEntityForWikiLink(ctx, link);
if (entity instanceof ContentEntityObject) {
User user = AuthenticatedUserThreadLocal.get();
if (permissionManager.hasPermission(user, Permission.VIEW, entity)) {
SecureIncludeData data = new SecureIncludeData();
data.setUsername(user.getName());
data.setContentId(entity.getId());
SecureIncludeData.save(ctx.getEntity(), id, data);
return data;
}
}
}
}
return null;
}
private String getRequestParam(String name, String defaultVal) {
if ((new StaticHttpContext()).getRequest() != null) {
String param = (new StaticHttpContext()).getRequest().getParameter(name);
if (isBlank(param)) {
return defaultVal;
} else {
return param;
}
}
return defaultVal;
}
private String includePage(String id, SecureIncludeData data, ConversionContext conversionContext) throws MacroExecutionException {
ContentEntityObject targetContent = getContentEntityManager().getById(data.getContentId());
if (targetContent == null) {
throw new MacroExecutionException("The targetContent this secure include accesses no longer exists.");
}
ConfluenceUser user = userAccessor.getUserByName(data.getUsername());
if (user == null) {
throw new MacroExecutionException("The user who set up this secure include no longer exists: " + data.getUsername());
}
if (!permissionManager.hasPermission(user, Permission.VIEW, targetContent)) {
throw new MacroExecutionException("The user who set up this secure include no longer has access to the resource.");
}
PageContext ctx = targetContent.toPageContext();
String contentIncludeId = SecureAttachmentDownload.ATTACHMENT_PATH + "/" + targetContent.getId()
+ "/" + conversionContext.getEntity().getId() + "/" + GeneralUtil.urlEncode(id);
String securePath = bootstrapManager.getWebAppContextPath() + contentIncludeId;
ctx.setSiteRoot(conversionContext.getPageContext().getSiteRoot());
ctx.setBaseUrl(conversionContext.getPageContext().getBaseUrl());
ctx.setImagePath(conversionContext.getPageContext().getImagePath());
ctx.setAttachmentsPath(securePath);
// Fake logging in as the original accessor...
ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
AuthenticatedUserThreadLocal.set(user);
//return subRenderer.render(targetContent.getContent(), ctx, RenderMode.ALL);
String rendered;
try {
rendered = xhtmlContent.convertStorageToView(targetContent.getBodyAsString(), conversionContext);
} catch (XhtmlException | XMLStreamException e) {
throw new MacroExecutionException(e.getMessage());
}
// Return to the real user...
AuthenticatedUserThreadLocal.set(currentUser);
rendered = replaceAttachmentUrls(rendered, data, contentIncludeId);
return rendered;
}
private String replaceAttachmentUrls(String rendered, SecureIncludeData data, String contentIncludeId) {
String attachmentUrl = "/" + FileServerServlet.SERVLET_PATH + "/" + FileServerServlet.ATTACHMENTS_URL_PREFIX + "/" + data.getContentId();
return rendered.replaceAll(attachmentUrl, contentIncludeId);
}
public boolean isInline() {
return false;
}
public boolean hasBody() {
return true;
}
public RenderMode getBodyRenderMode() {
return RenderMode.suppress(RenderMode.F_FIRST_PARA);
}
public BodyType getBodyType() {
return BodyType.NONE;
}
public OutputType getOutputType() {
return OutputType.INLINE;
}
public ContentEntityManager getContentEntityManager() {
if (contentEntityManager == null) {
contentEntityManager = (ContentEntityManager) ContainerManager.getComponent("contentEntityManager");
}
return contentEntityManager;
}
@Autowired
public void setPermissionManager(PermissionManager permissionManager) {
this.permissionManager = permissionManager;
}
@Autowired
public void setUserAccessor(UserAccessor userAccessor) {
this.userAccessor = userAccessor;
}
@Autowired
public void setBootstrapManager(BootstrapManager bootstrapManager) {
this.bootstrapManager = bootstrapManager;
}
@Autowired
public void setXhtmlContent(XhtmlContent xhtmlContent) {
this.xhtmlContent = xhtmlContent;
}
@Autowired
public void setLinkAssistant(LinkAssistant linkAssistant) {
this.linkAssistant = linkAssistant;
}
}
| 12,003 | 0.690077 | 0.688161 | 282 | 41.563831 | 34.322903 | 154 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.641844 | false | false | 8 |
505b6f3a67d9e3498575c3a0c3afe3eca2965f77 | 14,336,600,865,339 | 94986d605097d72c4977eddac1f188949b5bab6b | /target/generated-sources/gwt/org/niklas/elemental/Elemental/client/elements/HTMLMenuElement.java | 0b6b33cd3a24c0e4f78ef21e8512a5448c84fa80 | [
"Apache-2.0"
] | permissive | Nickel671/JsInteropGenerator | https://github.com/Nickel671/JsInteropGenerator | b74677c0ea381268f87c1dc317a95b31a1de7ce9 | 0835429f53e47c8f86ca3df22f959f8ed786d32e | refs/heads/master | 2021-01-19T06:58:52.450000 | 2015-04-01T21:47:39 | 2015-04-01T21:47:39 | 33,270,334 | 3 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.niklas.elemental.Elemental.client.elements;
import com.google.gwt.core.client.js.JsProperty;
import com.google.gwt.core.client.js.JsType;
@JsType(
prototype = "HTMLMenuElement"
)
interface HTMLMenuElement extends HTMLElement {
@JsProperty
String getType();
@JsProperty
void setType(String value);
@JsProperty
String getLabel();
@JsProperty
void setLabel(String value);
@JsProperty
boolean getCompact();
@JsProperty
void setCompact(boolean value);
}
| UTF-8 | Java | 496 | java | HTMLMenuElement.java | Java | [] | null | [] | package org.niklas.elemental.Elemental.client.elements;
import com.google.gwt.core.client.js.JsProperty;
import com.google.gwt.core.client.js.JsType;
@JsType(
prototype = "HTMLMenuElement"
)
interface HTMLMenuElement extends HTMLElement {
@JsProperty
String getType();
@JsProperty
void setType(String value);
@JsProperty
String getLabel();
@JsProperty
void setLabel(String value);
@JsProperty
boolean getCompact();
@JsProperty
void setCompact(boolean value);
}
| 496 | 0.747984 | 0.747984 | 27 | 17.370371 | 16.795387 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 8 |
0335220bbb8d6ca4c78229ae8c2d86a12f8d29cc | 22,668,837,441,614 | 26a77fd254407ff030cf1afff2befe3fe7004be6 | /fullstop-web/fullstop-violations-rest/src/main/java/org/zalando/stups/fullstop/web/converter/ViolationTypeEntityToDtoConverter.java | 2f167067cf49f2d9ca60ddec35c09f6b3681bf9d | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | zalando-stups/fullstop | https://github.com/zalando-stups/fullstop | cae443dd13d482fc8c185d181ff872cf3ba1d90b | 42f3bab557380aab0114028b58d745e3000897e8 | refs/heads/master | 2023-08-15T06:57:11.615000 | 2018-08-06T10:05:44 | 2018-08-06T10:05:44 | 32,521,417 | 41 | 23 | Apache-2.0 | false | 2018-08-06T10:05:46 | 2015-03-19T12:59:49 | 2018-08-06T09:53:59 | 2018-08-06T10:05:45 | 4,771 | 36 | 15 | 6 | Java | false | null | package org.zalando.stups.fullstop.web.converter;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import org.zalando.stups.fullstop.violation.entity.ViolationTypeEntity;
import org.zalando.stups.fullstop.web.model.ViolationType;
@Component
public class ViolationTypeEntityToDtoConverter implements Converter<ViolationTypeEntity, ViolationType> {
@Override
public ViolationType convert(final ViolationTypeEntity source) {
final ViolationType target = new ViolationType();
target.setId(source.getId());
target.setHelpText(source.getHelpText());
target.setIsAuditRelevant(source.isAuditRelevant());
target.setTitle(source.getTitle());
target.setViolationSeverity(source.getViolationSeverity());
target.setPriority(source.getPriority());
target.setCreated(source.getCreated());
target.setCreatedBy(source.getCreatedBy());
target.setLastModified(source.getLastModified());
target.setLastModifiedBy(source.getLastModifiedBy());
target.setVersion(source.getVersion());
return target;
}
}
| UTF-8 | Java | 1,162 | java | ViolationTypeEntityToDtoConverter.java | Java | [] | null | [] | package org.zalando.stups.fullstop.web.converter;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import org.zalando.stups.fullstop.violation.entity.ViolationTypeEntity;
import org.zalando.stups.fullstop.web.model.ViolationType;
@Component
public class ViolationTypeEntityToDtoConverter implements Converter<ViolationTypeEntity, ViolationType> {
@Override
public ViolationType convert(final ViolationTypeEntity source) {
final ViolationType target = new ViolationType();
target.setId(source.getId());
target.setHelpText(source.getHelpText());
target.setIsAuditRelevant(source.isAuditRelevant());
target.setTitle(source.getTitle());
target.setViolationSeverity(source.getViolationSeverity());
target.setPriority(source.getPriority());
target.setCreated(source.getCreated());
target.setCreatedBy(source.getCreatedBy());
target.setLastModified(source.getLastModified());
target.setLastModifiedBy(source.getLastModifiedBy());
target.setVersion(source.getVersion());
return target;
}
}
| 1,162 | 0.752151 | 0.752151 | 27 | 42.037037 | 26.368446 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.703704 | false | false | 8 |
dcb8ff70cf5536a5e97c67758e404395b90ccef7 | 3,367,254,396,989 | 42429e42e78c0457e044f7316d511448a298ffc7 | /applications/appCatalogAndGazetteerClient/src/es/gva/cit/catalog/schemas/RecordFactory.java | d39e595a7fdf7975da6ab75f62e0466b73de154c | [] | no_license | gvtools/gvtools-legacy | https://github.com/gvtools/gvtools-legacy | 17b8ba50d391f61d1a897a4d94648e16acfc08e6 | 55115bb467891a95a6ae87111dd43a451920f94c | refs/heads/master | 2021-01-23T04:00:15.896000 | 2012-11-30T10:54:53 | 2012-11-30T10:54:53 | 6,940,052 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package es.gva.cit.catalog.schemas;
import java.net.URI;
import java.util.ArrayList;
import es.gva.cit.catalog.metadataxml.XMLNode;
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
*
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
*
* For more information, contact:
*
* Generalitat Valenciana
* Conselleria d'Infraestructures i Transport
* Av. Blasco Ibáñez, 50
* 46010 VALENCIA
* SPAIN
*
* +34 963862235
* gvsig@gva.es
* www.gvsig.gva.es
*
* or
*
* IVER T.I. S.A
* Salamanca 50
* 46005 Valencia
* Spain
*
* +34 963163400
* dac@iver.es
*/
/* CVS MESSAGES:
*
* $Id: RecordFactory.java 600 2007-09-19 11:30:05 +0000 (Wed, 19 Sep 2007) jpiera $
* $Log$
* Revision 1.1.2.1 2007/07/23 07:14:24 jorpiell
* Catalog refactoring
*
*
*/
/**
* This class creates a parsed record from a uri and a XMLNode.
*
* @author Jorge Piera LLodrá (jorge.piera@iver.es)
*/
public class RecordFactory {
private static ArrayList records = null;
static {
records = new ArrayList();
records.add(new GeonetworkISO19115Record());
records.add(new DeegreeISO19115Record());
records.add(new DublinCoreRecord());
records.add(new IdecISO19115Record());
records.add(new IdeeISO19115Record());
records.add(new Iso19139Record());
records.add(new LaitsGmuISO19115Record());
records.add(new LaitsGmuServicesRecord());
records.add(new LaitsGmuEbRIMRecord());
}
/**
* Adds a new record
*
* @param record
* New record to add
*/
public static void addRecord(Record record) {
records.add(record);
}
/**
* Try to identify the XML format and return a record
*
* @param uri
* Server URI (used to retrieve the images)
* @param node
* XML node
* @return
*/
public static Record createRecord(URI uri, XMLNode node) {
for (int i = 0; i < records.size(); i++) {
Record record = (Record) records.get(i);
if (node != null) {
if (record.accept(uri, node)) {
Object[] values = { uri, node };
Class[] types = { URI.class, XMLNode.class };
try {
return (Record) record.getClass().getConstructor(types)
.newInstance(values);
} catch (Exception e) {
// It the instance can be created the
// default record has to be returned
}
}
}
}
return new UnknownRecord(uri, node);
}
}
| ISO-8859-1 | Java | 3,119 | java | RecordFactory.java | Java | [
{
"context": "la Generalitat Valenciana\n *\n * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.\n *\n * This program i",
"end": 241,
"score": 0.728864312171936,
"start": 233,
"tag": "NAME",
"value": "IVER T.I"
},
{
"context": " VALENCIA\n * SPAIN\n *\n * +34 963862235\n * gvsig@gva.es\n * www.gvsig.gva.es\n *\n * or\n *\n * IVER",
"end": 1203,
"score": 0.9998011589050293,
"start": 1191,
"tag": "EMAIL",
"value": "gvsig@gva.es"
},
{
"context": "005 Valencia\n * Spain\n *\n * +34 963163400\n * dac@iver.es\n */\n/* CVS MESSAGES:\n *\n * $Id: RecordFactory.jav",
"end": 1350,
"score": 0.999617874622345,
"start": 1339,
"tag": "EMAIL",
"value": "dac@iver.es"
},
{
"context": "ed record from a uri and a XMLNode.\n * \n * @author Jorge Piera LLodrá (jorge.piera@iver.es)\n */\npublic class RecordFact",
"end": 1654,
"score": 0.9998885989189148,
"start": 1636,
"tag": "NAME",
"value": "Jorge Piera LLodrá"
},
{
"context": "and a XMLNode.\n * \n * @author Jorge Piera LLodrá (jorge.piera@iver.es)\n */\npublic class RecordFactory {\n\tprivate static",
"end": 1675,
"score": 0.9998847246170044,
"start": 1656,
"tag": "EMAIL",
"value": "jorge.piera@iver.es"
}
] | null | [] | package es.gva.cit.catalog.schemas;
import java.net.URI;
import java.util.ArrayList;
import es.gva.cit.catalog.metadataxml.XMLNode;
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
*
* Copyright (C) 2004 <NAME>. and Generalitat Valenciana.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
*
* For more information, contact:
*
* Generalitat Valenciana
* Conselleria d'Infraestructures i Transport
* Av. Blasco Ibáñez, 50
* 46010 VALENCIA
* SPAIN
*
* +34 963862235
* <EMAIL>
* www.gvsig.gva.es
*
* or
*
* IVER T.I. S.A
* Salamanca 50
* 46005 Valencia
* Spain
*
* +34 963163400
* <EMAIL>
*/
/* CVS MESSAGES:
*
* $Id: RecordFactory.java 600 2007-09-19 11:30:05 +0000 (Wed, 19 Sep 2007) jpiera $
* $Log$
* Revision 1.1.2.1 2007/07/23 07:14:24 jorpiell
* Catalog refactoring
*
*
*/
/**
* This class creates a parsed record from a uri and a XMLNode.
*
* @author <NAME> (<EMAIL>)
*/
public class RecordFactory {
private static ArrayList records = null;
static {
records = new ArrayList();
records.add(new GeonetworkISO19115Record());
records.add(new DeegreeISO19115Record());
records.add(new DublinCoreRecord());
records.add(new IdecISO19115Record());
records.add(new IdeeISO19115Record());
records.add(new Iso19139Record());
records.add(new LaitsGmuISO19115Record());
records.add(new LaitsGmuServicesRecord());
records.add(new LaitsGmuEbRIMRecord());
}
/**
* Adds a new record
*
* @param record
* New record to add
*/
public static void addRecord(Record record) {
records.add(record);
}
/**
* Try to identify the XML format and return a record
*
* @param uri
* Server URI (used to retrieve the images)
* @param node
* XML node
* @return
*/
public static Record createRecord(URI uri, XMLNode node) {
for (int i = 0; i < records.size(); i++) {
Record record = (Record) records.get(i);
if (node != null) {
if (record.accept(uri, node)) {
Object[] values = { uri, node };
Class[] types = { URI.class, XMLNode.class };
try {
return (Record) record.getClass().getConstructor(types)
.newInstance(values);
} catch (Exception e) {
// It the instance can be created the
// default record has to be returned
}
}
}
}
return new UnknownRecord(uri, node);
}
}
| 3,083 | 0.667951 | 0.625883 | 116 | 25.844828 | 22.592188 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.387931 | false | false | 8 |
9482102f2e767d3390671c83b203568ced2482e0 | 27,479,200,810,384 | b0c6cd0e407cbe469cd9f7900b9796345803907c | /test-src/org/pentaho/metastore/test/MetaStoreFactoryTest.java | f4246a37f4426ebc9b9010358de6b2f0a5ec42db | [] | no_license | mkambol/metastore | https://github.com/mkambol/metastore | 8b200942dde56ac31f8951dde27c9ca4101b8b3d | 3c114bc36062bb74615a267fe26c83c569dd45fc | refs/heads/master | 2020-12-25T12:17:23.851000 | 2014-05-19T18:26:11 | 2014-05-19T18:26:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.pentaho.metastore.test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import junit.framework.TestCase;
import org.pentaho.metastore.api.IMetaStore;
import org.pentaho.metastore.api.IMetaStoreAttribute;
import org.pentaho.metastore.api.IMetaStoreElement;
import org.pentaho.metastore.api.IMetaStoreElementType;
import org.pentaho.metastore.persist.MetaStoreFactory;
import org.pentaho.metastore.stores.memory.MemoryMetaStore;
import org.pentaho.metastore.test.testclasses.MyElement;
import org.pentaho.metastore.test.testclasses.MyElementAttr;
import org.pentaho.metastore.test.testclasses.MyFilenameElement;
import org.pentaho.metastore.test.testclasses.MyNameElement;
import org.pentaho.metastore.util.MetaStoreUtil;
public class MetaStoreFactoryTest extends TestCase {
public void testMyElement() throws Exception {
String NAME = "one";
String ATTR = "11111111";
String ANOTHER = "2222222";
String PASSWORD = "my secret password";
int INT = 3;
long LONG = 4;
boolean BOOL = true;
Date DATE = new Date();
final int NR_ATTR = 10;
final int NR_NAME = 5;
final int NR_FILENAME = 5;
// List of named elements...
//
List<MyNameElement> nameList = new ArrayList<MyNameElement>();
for ( int i = 0; i < NR_NAME; i++ ) {
nameList.add( new MyNameElement( "name" + i, "description" + i, "color" + i ) );
}
List<MyFilenameElement> filenameList = new ArrayList<MyFilenameElement>();
for ( int i = 0; i < NR_FILENAME; i++ ) {
filenameList.add( new MyFilenameElement( "filename" + i, "size" + i, "gender" + i ) );
}
// Construct our test element...
//
MyElement me = new MyElement( NAME, ATTR, ANOTHER, PASSWORD, INT, LONG, BOOL, DATE );
for ( int i = 0; i < NR_ATTR; i++ ) {
me.getSubAttributes().add( new MyElementAttr( "key" + i, "value" + i, "desc" + i ) );
}
me.setNameElement( nameList.get( NR_NAME - 1 ) );
me.setFilenameElement( filenameList.get( NR_FILENAME - 1 ) );
IMetaStore metaStore = new MemoryMetaStore();
MetaStoreFactory<MyElement> factory = new MetaStoreFactory<MyElement>( MyElement.class, metaStore, "custom" );
// Store the class in the meta store
//
factory.saveElement( me );
// For loading, specify the name and filename lists we're referencing...
//
factory.addNameList( MyElement.LIST_KEY_MY_NAMES, nameList );
factory.addFilenameList( MyElement.LIST_KEY_MY_FILENAMES, filenameList );
// Load the class from the meta store
//
MyElement verify = factory.loadElement( NAME );
// Verify list element details...
//
IMetaStoreElement element = metaStore.getElementByName( "custom", factory.getElementType(), NAME );
assertNotNull( element );
// Verify the general idea
//
assertNotNull( verify );
assertEquals( ATTR, verify.getMyAttribute() );
assertEquals( ANOTHER, verify.getAnotherAttribute() );
assertEquals( PASSWORD, verify.getPasswordAttribute() );
assertEquals( INT, verify.getIntAttribute() );
assertEquals( LONG, verify.getLongAttribute() );
assertEquals( BOOL, verify.isBoolAttribute() );
assertEquals( DATE, verify.getDateAttribute() );
assertEquals( me.getSubAttributes().size(), verify.getSubAttributes().size() );
assertEquals( me.getNameElement(), verify.getNameElement() );
assertEquals( me.getFilenameElement(), verify.getFilenameElement() );
// verify the details...
//
assertTrue( metaStore.namespaceExists( "custom" ) );
IMetaStoreElementType elementType = factory.getElementType();
assertNotNull( elementType );
assertEquals( "My element type", elementType.getName() );
assertEquals( "This is my element type", elementType.getDescription() );
assertNotNull( element );
IMetaStoreAttribute child = element.getChild( "my_attribute" );
assertNotNull( child );
assertEquals( ATTR, MetaStoreUtil.getAttributeString( child ) );
child = element.getChild( "passwordAttribute" );
assertNotNull( child );
assertNotSame( "Password needs to be encoded", PASSWORD, MetaStoreUtil.getAttributeString( child ) );
child = element.getChild( "anotherAttribute" );
assertNotNull( child );
assertEquals( ANOTHER, MetaStoreUtil.getAttributeString( child ) );
// Verify the child attributes as well...
// This also verifies that the attributes are in the right order.
// The list can't be re-ordered after loading.
//
for ( int i = 0; i < NR_ATTR; i++ ) {
MyElementAttr attr = verify.getSubAttributes().get( i );
assertEquals( "key" + i, attr.getKey() );
assertEquals( "value" + i, attr.getValue() );
assertEquals( "desc" + i, attr.getDescription() );
}
List<String> names = factory.getElementNames();
assertEquals( 1, names.size() );
assertEquals( NAME, names.get( 0 ) );
List<MyElement> list = factory.getElements();
assertEquals( 1, list.size() );
assertEquals( NAME, list.get( 0 ).getName() );
factory.deleteElement( NAME );
assertEquals( 0, factory.getElementNames().size() );
assertEquals( 0, factory.getElements().size() );
}
}
| UTF-8 | Java | 5,198 | java | MetaStoreFactoryTest.java | Java | [
{
"context": "tring ANOTHER = \"2222222\";\n String PASSWORD = \"my secret password\";\n int INT = 3;\n long LONG = 4;\n boolean",
"end": 994,
"score": 0.9993958473205566,
"start": 976,
"tag": "PASSWORD",
"value": "my secret password"
}
] | null | [] | package org.pentaho.metastore.test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import junit.framework.TestCase;
import org.pentaho.metastore.api.IMetaStore;
import org.pentaho.metastore.api.IMetaStoreAttribute;
import org.pentaho.metastore.api.IMetaStoreElement;
import org.pentaho.metastore.api.IMetaStoreElementType;
import org.pentaho.metastore.persist.MetaStoreFactory;
import org.pentaho.metastore.stores.memory.MemoryMetaStore;
import org.pentaho.metastore.test.testclasses.MyElement;
import org.pentaho.metastore.test.testclasses.MyElementAttr;
import org.pentaho.metastore.test.testclasses.MyFilenameElement;
import org.pentaho.metastore.test.testclasses.MyNameElement;
import org.pentaho.metastore.util.MetaStoreUtil;
public class MetaStoreFactoryTest extends TestCase {
public void testMyElement() throws Exception {
String NAME = "one";
String ATTR = "11111111";
String ANOTHER = "2222222";
String PASSWORD = "<PASSWORD>";
int INT = 3;
long LONG = 4;
boolean BOOL = true;
Date DATE = new Date();
final int NR_ATTR = 10;
final int NR_NAME = 5;
final int NR_FILENAME = 5;
// List of named elements...
//
List<MyNameElement> nameList = new ArrayList<MyNameElement>();
for ( int i = 0; i < NR_NAME; i++ ) {
nameList.add( new MyNameElement( "name" + i, "description" + i, "color" + i ) );
}
List<MyFilenameElement> filenameList = new ArrayList<MyFilenameElement>();
for ( int i = 0; i < NR_FILENAME; i++ ) {
filenameList.add( new MyFilenameElement( "filename" + i, "size" + i, "gender" + i ) );
}
// Construct our test element...
//
MyElement me = new MyElement( NAME, ATTR, ANOTHER, PASSWORD, INT, LONG, BOOL, DATE );
for ( int i = 0; i < NR_ATTR; i++ ) {
me.getSubAttributes().add( new MyElementAttr( "key" + i, "value" + i, "desc" + i ) );
}
me.setNameElement( nameList.get( NR_NAME - 1 ) );
me.setFilenameElement( filenameList.get( NR_FILENAME - 1 ) );
IMetaStore metaStore = new MemoryMetaStore();
MetaStoreFactory<MyElement> factory = new MetaStoreFactory<MyElement>( MyElement.class, metaStore, "custom" );
// Store the class in the meta store
//
factory.saveElement( me );
// For loading, specify the name and filename lists we're referencing...
//
factory.addNameList( MyElement.LIST_KEY_MY_NAMES, nameList );
factory.addFilenameList( MyElement.LIST_KEY_MY_FILENAMES, filenameList );
// Load the class from the meta store
//
MyElement verify = factory.loadElement( NAME );
// Verify list element details...
//
IMetaStoreElement element = metaStore.getElementByName( "custom", factory.getElementType(), NAME );
assertNotNull( element );
// Verify the general idea
//
assertNotNull( verify );
assertEquals( ATTR, verify.getMyAttribute() );
assertEquals( ANOTHER, verify.getAnotherAttribute() );
assertEquals( PASSWORD, verify.getPasswordAttribute() );
assertEquals( INT, verify.getIntAttribute() );
assertEquals( LONG, verify.getLongAttribute() );
assertEquals( BOOL, verify.isBoolAttribute() );
assertEquals( DATE, verify.getDateAttribute() );
assertEquals( me.getSubAttributes().size(), verify.getSubAttributes().size() );
assertEquals( me.getNameElement(), verify.getNameElement() );
assertEquals( me.getFilenameElement(), verify.getFilenameElement() );
// verify the details...
//
assertTrue( metaStore.namespaceExists( "custom" ) );
IMetaStoreElementType elementType = factory.getElementType();
assertNotNull( elementType );
assertEquals( "My element type", elementType.getName() );
assertEquals( "This is my element type", elementType.getDescription() );
assertNotNull( element );
IMetaStoreAttribute child = element.getChild( "my_attribute" );
assertNotNull( child );
assertEquals( ATTR, MetaStoreUtil.getAttributeString( child ) );
child = element.getChild( "passwordAttribute" );
assertNotNull( child );
assertNotSame( "Password needs to be encoded", PASSWORD, MetaStoreUtil.getAttributeString( child ) );
child = element.getChild( "anotherAttribute" );
assertNotNull( child );
assertEquals( ANOTHER, MetaStoreUtil.getAttributeString( child ) );
// Verify the child attributes as well...
// This also verifies that the attributes are in the right order.
// The list can't be re-ordered after loading.
//
for ( int i = 0; i < NR_ATTR; i++ ) {
MyElementAttr attr = verify.getSubAttributes().get( i );
assertEquals( "key" + i, attr.getKey() );
assertEquals( "value" + i, attr.getValue() );
assertEquals( "desc" + i, attr.getDescription() );
}
List<String> names = factory.getElementNames();
assertEquals( 1, names.size() );
assertEquals( NAME, names.get( 0 ) );
List<MyElement> list = factory.getElements();
assertEquals( 1, list.size() );
assertEquals( NAME, list.get( 0 ).getName() );
factory.deleteElement( NAME );
assertEquals( 0, factory.getElementNames().size() );
assertEquals( 0, factory.getElements().size() );
}
}
| 5,190 | 0.687187 | 0.680839 | 136 | 37.220589 | 27.50259 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.992647 | false | false | 8 |
d1e72cdd981b1e654030780b85883f9dc69a5ef3 | 1,743,756,769,324 | 0b200dc7e662f6ec73f11df8428c682c198a2dcd | /project/leinbow-web-ec-front/src/main/java/com/leinbow/web/controller/UserController.java | 1b6aa6f3d88ef2bea46f8d9de0ada71bdfc5e992 | [] | no_license | Tob1112/seungbeomi | https://github.com/Tob1112/seungbeomi | 45ea004bb1e388ccbe89eeced69da448d9b8d9cd | 845119f6cb5d311bb376bfc9a3e688089a06e83f | refs/heads/master | 2021-01-20T15:37:23.714000 | 2012-05-25T05:23:26 | 2012-05-25T05:23:26 | 41,893,041 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.leinbow.web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.leinbow.service.UserService;
@Controller
@RequestMapping("/user")
public class UserController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(Model model) {
model.addAttribute("list", userService.getUsers());
return "user/list";
}
}
| UTF-8 | Java | 909 | java | UserController.java | Java | [] | null | [] | package com.leinbow.web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.leinbow.service.UserService;
@Controller
@RequestMapping("/user")
public class UserController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
UserService userService;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(Model model) {
model.addAttribute("list", userService.getUsers());
return "user/list";
}
}
| 909 | 0.757976 | 0.755776 | 35 | 24.971428 | 24.025564 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.457143 | false | false | 8 |
dcccc8660d1c0bba92c01a0b98b1f1dfd14d8080 | 1,743,756,769,546 | e89e4d4bdb1cdcd77683f9bfa1cc8f75b72bb20d | /pallas-core/src/main/java/com/vip/pallas/utils/CommonQueue.java | 749660852c9b3fb08da8532d9f316f90705dee47 | [] | no_license | xiaoyanghapi/pallas | https://github.com/xiaoyanghapi/pallas | 32bf48c8b004d217f3150daaf041ceabd7eeda45 | 7d6e084f7bd0ec5e26882feec28b4aebfa70f430 | refs/heads/master | 2020-05-04T14:59:31.443000 | 2019-04-02T07:39:16 | 2019-04-02T07:39:16 | 179,219,013 | 2 | 0 | null | true | 2019-04-03T05:47:28 | 2019-04-03T05:47:28 | 2019-04-03T03:19:14 | 2019-04-03T03:19:12 | 238,922 | 0 | 0 | 0 | null | false | null | /**
* Copyright 2019 vip.com.
* <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
*
* 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.
* </p>
*/
package com.vip.pallas.utils;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
public class CommonQueue<T> {
private BlockingQueue<T> queue;
public CommonQueue(int capacity){
queue = new ArrayBlockingQueue<>(capacity);
}
public void put(T e) throws InterruptedException {
queue.put(e);
}
public void put(List<T> list) throws InterruptedException{
for (T e: list){
put(e);
}
}
public void poll(List<T> list, int max){
queue.drainTo(list, max); //NOSONAR
}
public T poll(){
return queue.poll();
}
public int size(){
return queue.size();
}
public void clear(){
queue.clear();
}
} | UTF-8 | Java | 1,396 | java | CommonQueue.java | Java | [] | null | [] | /**
* Copyright 2019 vip.com.
* <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
*
* 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.
* </p>
*/
package com.vip.pallas.utils;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
public class CommonQueue<T> {
private BlockingQueue<T> queue;
public CommonQueue(int capacity){
queue = new ArrayBlockingQueue<>(capacity);
}
public void put(T e) throws InterruptedException {
queue.put(e);
}
public void put(List<T> list) throws InterruptedException{
for (T e: list){
put(e);
}
}
public void poll(List<T> list, int max){
queue.drainTo(list, max); //NOSONAR
}
public T poll(){
return queue.poll();
}
public int size(){
return queue.size();
}
public void clear(){
queue.clear();
}
} | 1,396 | 0.654728 | 0.648997 | 57 | 23.508772 | 23.157827 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 8 |
6b5f27f1fe033658d1950dde24c53b5216fd942b | 3,839,700,776,556 | 0c8be736df3bd3a76c3e41e08c9c345500434aba | /src/main/java/dao/ManageProductData.java | 8ce65710caf9c0b5e820795b957be5d6eca3d4ce | [] | no_license | Ethanm12/shopping | https://github.com/Ethanm12/shopping | 38372595fe76e0af5d1ad6ae2bd169d7e9249cfe | a7a6a9f35d00c9a8ea314d0a1ac69b75eeeb4f36 | refs/heads/master | 2023-03-24T05:18:32.478000 | 2021-03-07T00:22:29 | 2021-03-07T00:22:29 | 241,341,156 | 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 dao;
import domain.Product;
import java.util.Collection;
public interface ManageProductData {
void delete(Product product);
Collection<Product> filter(String cat);
Collection<String> getCategories();
Collection<Product> getProducts();
void save(Product product);
Product search(Integer productID);
}
| UTF-8 | Java | 531 | java | ManageProductData.java | Java | [] | 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 dao;
import domain.Product;
import java.util.Collection;
public interface ManageProductData {
void delete(Product product);
Collection<Product> filter(String cat);
Collection<String> getCategories();
Collection<Product> getProducts();
void save(Product product);
Product search(Integer productID);
}
| 531 | 0.72693 | 0.72693 | 26 | 19.423077 | 21.704613 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 8 |
f73c191245d2d8a640ca6126cb51a29bcb404c14 | 9,191,230,045,394 | 4a52560e7eaf90c172707e16710d5ec4b25feed7 | /toolbox/src/main/java/com/honglei/toolbox/utils/ok/MediaPlayUtil.java | 158eafa890a1255c2784b9114c954fa325dcb8bd | [
"Apache-2.0"
] | permissive | tukela/androidToolBox | https://github.com/tukela/androidToolBox | c7345beee97185f064346ded1c097c450d63e628 | e099f47cdcda9cf8250e2fcc089f8d061d5495ab | refs/heads/master | 2021-01-20T07:24:01.736000 | 2017-06-28T03:38:56 | 2017-06-28T03:38:56 | 89,998,095 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.honglei.toolbox.utils.ok;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.MediaDataSource;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.RequiresApi;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by hl on 2017/5/10.
*/
public class MediaPlayUtil implements MediaPlayer.OnPreparedListener,MediaPlayer.OnCompletionListener{
private static MediaPlayUtil mMediaPlayUtil;
public static final int MEDIA_STATUS_START = -1;
public static final int MEDIA_STATUS_PREPARE=0;
public static final int MEDIA_STATUS_PLAY = 1;
public static final int MEDIA_STATUS_STOP = 2;
public static final int MEDIA_STATUS_PAUSE = 3;
private MediaPlayer mMediaPlayer;
private IMediaPlayerProgressListener mediaPlayerProgressLisener=null;
private IOnPreparedListener onPreparedListener=null;
private ScheduledExecutorService service;
public int media_player_status;
private MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener;
/*资源准备完成开启 开放播放功能*/
@Override
public void onPrepared(MediaPlayer mp) {
media_player_status=MEDIA_STATUS_PREPARE;
if (onPreparedListener!=null)
onPreparedListener.onPrepared(mp);
}
private IOnCompleteListener onCompleteListener=null;
@Override
public void onCompletion(MediaPlayer mp) {
media_player_status=MEDIA_STATUS_STOP;
updateProgress(false);
if (onCompleteListener!=null)
onCompleteListener.onCompletion(mp);
}
/*资源准备完成*/
public interface IOnPreparedListener{
void onPrepared(MediaPlayer mp);
}
/*播放结束事件*/
public interface IOnCompleteListener{
void onCompletion(MediaPlayer mp);
}
/* 播放进度监听*/
public interface IMediaPlayerProgressListener{
void mediaPlayer(int duration, int CurrentPosition);
}
public void setOnCompleteListener(IOnCompleteListener onCompleteListener){
this.onCompleteListener=onCompleteListener;
}
public void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener){
this.onBufferingUpdateListener=onBufferingUpdateListener;
}
public void setOnPreparedListener(IOnPreparedListener onPreparedListener){
this.onPreparedListener=onPreparedListener;
}
public void setMediaPlayerProgressLisener(IMediaPlayerProgressListener mediaPlayerProgressLisener){
this.mediaPlayerProgressLisener=mediaPlayerProgressLisener;
}
public static MediaPlayUtil getInstance(){
if(mMediaPlayUtil == null){
mMediaPlayUtil = new MediaPlayUtil();
}
return mMediaPlayUtil;
}
private MediaPlayUtil() {
create();
}
public void play(){
try {
if (media_player_status==MEDIA_STATUS_PREPARE)
{
mMediaPlayer.start();
updateProgress(true);
media_player_status=MEDIA_STATUS_PLAY;
}
}catch (Exception e){
e.printStackTrace();
}
}
private void updateProgress(boolean b){
if (mMediaPlayer!=null)
{
Runnable runnable = new Runnable() {
public void run() {
if (mediaPlayerProgressLisener!=null)
mediaPlayerProgressLisener
.mediaPlayer(mMediaPlayer.getDuration(),mMediaPlayer.getCurrentPosition());
}
};
if (!b&service!=null)
service.shutdown();
service = Executors .newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(runnable, 800, 500, TimeUnit.MILLISECONDS);// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
}
}
public void pause(){
if(mMediaPlayer != null){
try {
mMediaPlayer.pause();
media_player_status=MEDIA_STATUS_PAUSE;
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
}
public void stop(){
if(mMediaPlayer != null && mMediaPlayer.isPlaying()){
mMediaPlayer.stop();
media_player_status=MEDIA_STATUS_STOP;
}
}
public int getCurrentPosition(){
if(mMediaPlayer != null && mMediaPlayer.isPlaying()){
return mMediaPlayer.getCurrentPosition();
}else{
return 0;
}
}
public int getDutation(){
if(mMediaPlayer!= null && mMediaPlayer.isPlaying()){
return mMediaPlayer.getDuration();
}else{
return 0;
}
}
public boolean isPlaying(){
if(mMediaPlayer != null){
return mMediaPlayer.isPlaying();
}else{
return false;
}
}
public void create( ) {
if (mMediaPlayer!=null)
{
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.stop();
}
mMediaPlayer.release();
mMediaPlayer=null;
}
mMediaPlayer = new MediaPlayer();
}
private String getPathFromUri(Uri songUri){
try {
return URLDecoder.decode(songUri.getPath().toString(), "UTF8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void setDataSource(AssetFileDescriptor afd){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(afd);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
public void setDataSource(Context context,Uri uri){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(context,uri);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
public void setDataSource(String path){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(path);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
public void setDataSource(FileDescriptor fileDescriptor){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(fileDescriptor);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.M)
public void setDataSource(MediaDataSource mediaDataSource){
reserMediaPlay();
mMediaPlayer.setDataSource(mediaDataSource);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
}
private void reserMediaPlay(){
if (mMediaPlayer==null)
create();
if (mMediaPlayer.isPlaying())
{
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer=null;
mMediaPlayer=new MediaPlayer();
}
media_player_status=MEDIA_STATUS_START;
}
}
| UTF-8 | Java | 8,167 | java | MediaPlayUtil.java | Java | [
{
"context": " java.util.concurrent.TimeUnit;\n\n/**\n * Created by hl on 2017/5/10.\n */\n\npublic class MediaPlayUtil imp",
"end": 691,
"score": 0.9415804743766785,
"start": 689,
"tag": "USERNAME",
"value": "hl"
}
] | null | [] | package com.honglei.toolbox.utils.ok;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.MediaDataSource;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.RequiresApi;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Created by hl on 2017/5/10.
*/
public class MediaPlayUtil implements MediaPlayer.OnPreparedListener,MediaPlayer.OnCompletionListener{
private static MediaPlayUtil mMediaPlayUtil;
public static final int MEDIA_STATUS_START = -1;
public static final int MEDIA_STATUS_PREPARE=0;
public static final int MEDIA_STATUS_PLAY = 1;
public static final int MEDIA_STATUS_STOP = 2;
public static final int MEDIA_STATUS_PAUSE = 3;
private MediaPlayer mMediaPlayer;
private IMediaPlayerProgressListener mediaPlayerProgressLisener=null;
private IOnPreparedListener onPreparedListener=null;
private ScheduledExecutorService service;
public int media_player_status;
private MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener;
/*资源准备完成开启 开放播放功能*/
@Override
public void onPrepared(MediaPlayer mp) {
media_player_status=MEDIA_STATUS_PREPARE;
if (onPreparedListener!=null)
onPreparedListener.onPrepared(mp);
}
private IOnCompleteListener onCompleteListener=null;
@Override
public void onCompletion(MediaPlayer mp) {
media_player_status=MEDIA_STATUS_STOP;
updateProgress(false);
if (onCompleteListener!=null)
onCompleteListener.onCompletion(mp);
}
/*资源准备完成*/
public interface IOnPreparedListener{
void onPrepared(MediaPlayer mp);
}
/*播放结束事件*/
public interface IOnCompleteListener{
void onCompletion(MediaPlayer mp);
}
/* 播放进度监听*/
public interface IMediaPlayerProgressListener{
void mediaPlayer(int duration, int CurrentPosition);
}
public void setOnCompleteListener(IOnCompleteListener onCompleteListener){
this.onCompleteListener=onCompleteListener;
}
public void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener){
this.onBufferingUpdateListener=onBufferingUpdateListener;
}
public void setOnPreparedListener(IOnPreparedListener onPreparedListener){
this.onPreparedListener=onPreparedListener;
}
public void setMediaPlayerProgressLisener(IMediaPlayerProgressListener mediaPlayerProgressLisener){
this.mediaPlayerProgressLisener=mediaPlayerProgressLisener;
}
public static MediaPlayUtil getInstance(){
if(mMediaPlayUtil == null){
mMediaPlayUtil = new MediaPlayUtil();
}
return mMediaPlayUtil;
}
private MediaPlayUtil() {
create();
}
public void play(){
try {
if (media_player_status==MEDIA_STATUS_PREPARE)
{
mMediaPlayer.start();
updateProgress(true);
media_player_status=MEDIA_STATUS_PLAY;
}
}catch (Exception e){
e.printStackTrace();
}
}
private void updateProgress(boolean b){
if (mMediaPlayer!=null)
{
Runnable runnable = new Runnable() {
public void run() {
if (mediaPlayerProgressLisener!=null)
mediaPlayerProgressLisener
.mediaPlayer(mMediaPlayer.getDuration(),mMediaPlayer.getCurrentPosition());
}
};
if (!b&service!=null)
service.shutdown();
service = Executors .newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(runnable, 800, 500, TimeUnit.MILLISECONDS);// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
}
}
public void pause(){
if(mMediaPlayer != null){
try {
mMediaPlayer.pause();
media_player_status=MEDIA_STATUS_PAUSE;
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
}
public void stop(){
if(mMediaPlayer != null && mMediaPlayer.isPlaying()){
mMediaPlayer.stop();
media_player_status=MEDIA_STATUS_STOP;
}
}
public int getCurrentPosition(){
if(mMediaPlayer != null && mMediaPlayer.isPlaying()){
return mMediaPlayer.getCurrentPosition();
}else{
return 0;
}
}
public int getDutation(){
if(mMediaPlayer!= null && mMediaPlayer.isPlaying()){
return mMediaPlayer.getDuration();
}else{
return 0;
}
}
public boolean isPlaying(){
if(mMediaPlayer != null){
return mMediaPlayer.isPlaying();
}else{
return false;
}
}
public void create( ) {
if (mMediaPlayer!=null)
{
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.stop();
}
mMediaPlayer.release();
mMediaPlayer=null;
}
mMediaPlayer = new MediaPlayer();
}
private String getPathFromUri(Uri songUri){
try {
return URLDecoder.decode(songUri.getPath().toString(), "UTF8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void setDataSource(AssetFileDescriptor afd){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(afd);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
public void setDataSource(Context context,Uri uri){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(context,uri);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
public void setDataSource(String path){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(path);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
public void setDataSource(FileDescriptor fileDescriptor){
reserMediaPlay();
try {
mMediaPlayer.setDataSource(fileDescriptor);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.M)
public void setDataSource(MediaDataSource mediaDataSource){
reserMediaPlay();
mMediaPlayer.setDataSource(mediaDataSource);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.prepareAsync();
}
private void reserMediaPlay(){
if (mMediaPlayer==null)
create();
if (mMediaPlayer.isPlaying())
{
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer=null;
mMediaPlayer=new MediaPlayer();
}
media_player_status=MEDIA_STATUS_START;
}
}
| 8,167 | 0.632135 | 0.629524 | 266 | 29.218044 | 22.860426 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.443609 | false | false | 8 |
ce03c84139fe63ec4c78e4a87f7492c649b6f85e | 7,447,473,342,104 | e5f389f03e2009bab29e57cc355b5d852faa38f2 | /SCAP_WEBCO/.svn/pristine/cc/cc1dd60aa20af2588d2b4083f78dd4b5681d4436.svn-base | 9007ec16ce098960f2290abb4ebf1a2e2f17771c | [
"MIT"
] | permissive | j735059474/gzw | https://github.com/j735059474/gzw | 5e17f1fbd63fd46a3da7b45b417cae9c49b25b4b | 22516ebbc10bf6b90094db0468f3caf86de857a0 | refs/heads/master | 2021-04-27T03:24:34.858000 | 2018-03-08T09:04:31 | 2018-03-08T10:47:15 | 122,713,360 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package nc.scap.pub.attlist.comp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import uap.web.bd.pub.AppUtil;
import nc.scap.pub.attlist.AttachRoleDao;
import nc.scap.pub.vos.AttachGroupVO;
import nc.scap.pub.vos.AttachRoleVO;
import nc.uap.lfw.core.common.StringDataTypeConst;
import nc.uap.lfw.core.comp.GridColumn;
import nc.uap.lfw.core.comp.GridComp;
import nc.uap.lfw.core.comp.IGridColumn;
import nc.uap.lfw.core.comp.MenuItem;
import nc.uap.lfw.core.comp.MenubarComp;
import nc.uap.lfw.core.data.Dataset;
import nc.uap.lfw.core.data.Field;
import nc.uap.lfw.core.event.DatasetEvent;
import nc.uap.lfw.core.event.DialogEvent;
import nc.uap.lfw.core.event.MouseEvent;
import nc.uap.lfw.core.event.conf.EventConf;
import nc.uap.lfw.core.model.IWidgetContentProvider;
import nc.uap.lfw.core.page.Connector;
import nc.uap.lfw.core.page.LfwView;
import nc.uap.lfw.core.page.LfwWindow;
import nc.uap.lfw.core.page.PluginDesc;
import nc.uap.lfw.core.page.PluginDescItem;
import nc.uap.lfw.core.page.PluginProxy;
import nc.uap.lfw.core.uimodel.Application;
public class AttachRoleCompProvider implements IWidgetContentProvider {
private static String[] columnColIds = new String[] {
AttachRoleVO.PK_ATTACH_ROLE,
AttachRoleVO.PK_ATTACH_GROUP,
AttachRoleVO.CODE,
AttachRoleVO.NAME,
AttachRoleVO.MAX_COUNT,
AttachRoleVO.MIN_COUNT,
"current_count"
};
private static String[] columnColNames = new String[] {
"主键",
"上层单据主键",
"编码",
"附件名称",
"最大上传文件数量",
"最少上传文件数量",
"已上传文件数量"
};
private static String[] hiddenColIds = new String[] { AttachRoleVO.PK_ATTACH_ROLE, AttachRoleVO.CODE, AttachRoleVO.PK_ATTACH_GROUP };
/**
* 生成grid控件列
*/
public static List<IGridColumn> genGridColumnList() {
List<IGridColumn> colList = new ArrayList<IGridColumn>();
List<String> hiddenColList = Arrays.asList(hiddenColIds);
for (int i = 0; i < columnColIds.length; i++) {
String id = columnColIds[i];
// 过滤隐藏列
if (hiddenColList.contains(id)) {
continue;
} else {
String name = columnColNames[i];
GridColumn col = new GridColumn();
col.setId(id);
col.setField(id);
col.setText(name);
col.setDataType(StringDataTypeConst.STRING);
col.setVisible(true);
col.setEditable(false);
if (AttachRoleVO.NAME.equals(id)) { // “附件名称”列宽度
col.setWidth(400);
}
colList.add(col);
}
}
return colList;
}
/**
* 生成数据集
*/
public static Dataset genDataset(String dsId) {
Dataset ds = new Dataset(dsId);
for (int i = 0; i < columnColIds.length; i++) {
String id = columnColIds[i];
Field field = new Field();
field.setId(id);
field.setOriId(id);
field.setField(id);
field.setDataType(StringDataTypeConst.STRING);
ds.getFieldSet().addField(field);
}
return ds;
}
public static void bindWithFileMgr(Application app, LfwWindow pm, LfwView conf) {
// 附件规则view Plugin
PluginDesc plugin = new PluginDesc();
plugin.setId("afterOperate_plugin");
plugin.setMethodName("doRefresh");
// View里的Connection
Connector conn = new Connector();
conn.setConnType(Connector.INLINEWINDOW_VIEW);
conn.setId("attachrole_mainview_connector");
conn.setPluginId(plugin.getId());
conn.setPlugoutId("proxyAfterOperate_plugout");
conn.setSource("filemgr");
// 附件规则window ProxyPlugin
PluginProxy pluginProxy = new PluginProxy();
pluginProxy.setId("proxyAfterOperate_plugin");
pluginProxy.setDelegatedViewId(conf.getId());
// 附件规则window Connector
Connector pluginConnector = new Connector();
pluginConnector.setId("afterOperate_connector_in");
pluginConnector.setPluginId(plugin.getId());
pluginConnector.setPlugoutId(pluginProxy.getId());
pluginConnector.setSource(pm.getFullId());
pluginConnector.setTarget(conf.getId());
pluginConnector.setConnType(Connector.WINDOW_RPOXY_INT);
// 以下步骤前,需要先修改LFW默认的filemgr window的pagemeta和main view的widget,增加plugout
// 应用Connector关联proxyPlugout和proxyPlugin
Connector appConnector = new Connector();
appConnector.setId(pm.getId() + "_filemgr_connector");
appConnector.setPluginId(pluginProxy.getId());
appConnector.setPlugoutId("proxyAfterOperate_plugout");
appConnector.setSource("filemgr");
appConnector.setTarget(pm.getFullId());
appConnector.setConnType(Connector.WINDOW_WINDOW);
if (conf.getPluginDesc(plugin.getId()) == null)
conf.addPluginDescs(plugin);
if (conf.getConnector(conn.getId()) == null)
conf.addConnector(conn);
if (pm.getPluginDesc(pluginProxy.getId()) == null)
pm.addPluginDesc(pluginProxy);
if (pm.getConnectorMap().get(pluginConnector.getId()) == null)
pm.addConnector(pluginConnector);
boolean b = true;
for (Connector connector : app.getConnectors()) {
// 判断是否有名称重复的Connector,如果有就跳过,防止重复调用 app.addConnector(appConnector);
if (appConnector.getId().equals(connector.getId())){
b = false;
break;
}
}
}
@Override
public LfwView buildWidget(LfwWindow pm, LfwView conf, Map<String, Object> paramMap, String currWidgetId) {
// add plugin & plugout
Application app = AppUtil.getCntApplication();
bindWithFileMgr(app, pm, conf);
// bind events
conf.setControllerClazz(AttachRoleCompController.class.getName());
EventConf beforeShow = DialogEvent.getBeforeShowEvent();
beforeShow.setMethodName("beforeShow");
conf.addEventConf(beforeShow);
String codenode = (String) AppUtil.getAppAttr("nodecode");
AttachGroupVO[] groups = AttachRoleDao.retrieveAttachGroupByNodeCode(codenode);
// add components
for (int i = 0; i < (groups == null ? IAttachRoleCompConstant.MAX_ROLE_GROUP_COUNT : groups.length); i++) {
// GridComp
GridComp gridComp = new GridComp();
gridComp.setId("grid" + i);
gridComp.setView(conf);
gridComp.setShowImageBtn(true);
conf.getViewComponents().addComponent(gridComp);
// Menubar
MenubarComp menubar = new MenubarComp();
menubar.setId("menubar" + i);
menubar.setView(conf);
gridComp.setMenuBar(menubar);
// Menubar item
MenuItem attachBtn = new MenuItem();
attachBtn.setId(menubar.getId() + "_attachbtn");
attachBtn.setView(conf);
attachBtn.setText("查看附件");
attachBtn.setEnabled(false);
menubar.addMenuItem(attachBtn);
EventConf onGridClick = MouseEvent.getOnClickEvent();
onGridClick.setMethodName("onGridClick");
attachBtn.addEventConf(onGridClick);
// Dataset
Dataset ds = genDataset(gridComp.getId() + "_ds");
gridComp.setDataset(ds.getId());
EventConf onAfterRowSelect = DatasetEvent.getOnAfterRowSelectEvent();
onAfterRowSelect.setMethodName("onAfterRoleSelect");
ds.addEventConf(onAfterRowSelect);
conf.getViewModels().addDataset(ds);
// GridColumns
List<IGridColumn> columnList = genGridColumnList();
gridComp.setColumnList(columnList);
}
return conf;
}
}
| GB18030 | Java | 7,101 | cc1dd60aa20af2588d2b4083f78dd4b5681d4436.svn-base | Java | [] | null | [] | package nc.scap.pub.attlist.comp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import uap.web.bd.pub.AppUtil;
import nc.scap.pub.attlist.AttachRoleDao;
import nc.scap.pub.vos.AttachGroupVO;
import nc.scap.pub.vos.AttachRoleVO;
import nc.uap.lfw.core.common.StringDataTypeConst;
import nc.uap.lfw.core.comp.GridColumn;
import nc.uap.lfw.core.comp.GridComp;
import nc.uap.lfw.core.comp.IGridColumn;
import nc.uap.lfw.core.comp.MenuItem;
import nc.uap.lfw.core.comp.MenubarComp;
import nc.uap.lfw.core.data.Dataset;
import nc.uap.lfw.core.data.Field;
import nc.uap.lfw.core.event.DatasetEvent;
import nc.uap.lfw.core.event.DialogEvent;
import nc.uap.lfw.core.event.MouseEvent;
import nc.uap.lfw.core.event.conf.EventConf;
import nc.uap.lfw.core.model.IWidgetContentProvider;
import nc.uap.lfw.core.page.Connector;
import nc.uap.lfw.core.page.LfwView;
import nc.uap.lfw.core.page.LfwWindow;
import nc.uap.lfw.core.page.PluginDesc;
import nc.uap.lfw.core.page.PluginDescItem;
import nc.uap.lfw.core.page.PluginProxy;
import nc.uap.lfw.core.uimodel.Application;
public class AttachRoleCompProvider implements IWidgetContentProvider {
private static String[] columnColIds = new String[] {
AttachRoleVO.PK_ATTACH_ROLE,
AttachRoleVO.PK_ATTACH_GROUP,
AttachRoleVO.CODE,
AttachRoleVO.NAME,
AttachRoleVO.MAX_COUNT,
AttachRoleVO.MIN_COUNT,
"current_count"
};
private static String[] columnColNames = new String[] {
"主键",
"上层单据主键",
"编码",
"附件名称",
"最大上传文件数量",
"最少上传文件数量",
"已上传文件数量"
};
private static String[] hiddenColIds = new String[] { AttachRoleVO.PK_ATTACH_ROLE, AttachRoleVO.CODE, AttachRoleVO.PK_ATTACH_GROUP };
/**
* 生成grid控件列
*/
public static List<IGridColumn> genGridColumnList() {
List<IGridColumn> colList = new ArrayList<IGridColumn>();
List<String> hiddenColList = Arrays.asList(hiddenColIds);
for (int i = 0; i < columnColIds.length; i++) {
String id = columnColIds[i];
// 过滤隐藏列
if (hiddenColList.contains(id)) {
continue;
} else {
String name = columnColNames[i];
GridColumn col = new GridColumn();
col.setId(id);
col.setField(id);
col.setText(name);
col.setDataType(StringDataTypeConst.STRING);
col.setVisible(true);
col.setEditable(false);
if (AttachRoleVO.NAME.equals(id)) { // “附件名称”列宽度
col.setWidth(400);
}
colList.add(col);
}
}
return colList;
}
/**
* 生成数据集
*/
public static Dataset genDataset(String dsId) {
Dataset ds = new Dataset(dsId);
for (int i = 0; i < columnColIds.length; i++) {
String id = columnColIds[i];
Field field = new Field();
field.setId(id);
field.setOriId(id);
field.setField(id);
field.setDataType(StringDataTypeConst.STRING);
ds.getFieldSet().addField(field);
}
return ds;
}
public static void bindWithFileMgr(Application app, LfwWindow pm, LfwView conf) {
// 附件规则view Plugin
PluginDesc plugin = new PluginDesc();
plugin.setId("afterOperate_plugin");
plugin.setMethodName("doRefresh");
// View里的Connection
Connector conn = new Connector();
conn.setConnType(Connector.INLINEWINDOW_VIEW);
conn.setId("attachrole_mainview_connector");
conn.setPluginId(plugin.getId());
conn.setPlugoutId("proxyAfterOperate_plugout");
conn.setSource("filemgr");
// 附件规则window ProxyPlugin
PluginProxy pluginProxy = new PluginProxy();
pluginProxy.setId("proxyAfterOperate_plugin");
pluginProxy.setDelegatedViewId(conf.getId());
// 附件规则window Connector
Connector pluginConnector = new Connector();
pluginConnector.setId("afterOperate_connector_in");
pluginConnector.setPluginId(plugin.getId());
pluginConnector.setPlugoutId(pluginProxy.getId());
pluginConnector.setSource(pm.getFullId());
pluginConnector.setTarget(conf.getId());
pluginConnector.setConnType(Connector.WINDOW_RPOXY_INT);
// 以下步骤前,需要先修改LFW默认的filemgr window的pagemeta和main view的widget,增加plugout
// 应用Connector关联proxyPlugout和proxyPlugin
Connector appConnector = new Connector();
appConnector.setId(pm.getId() + "_filemgr_connector");
appConnector.setPluginId(pluginProxy.getId());
appConnector.setPlugoutId("proxyAfterOperate_plugout");
appConnector.setSource("filemgr");
appConnector.setTarget(pm.getFullId());
appConnector.setConnType(Connector.WINDOW_WINDOW);
if (conf.getPluginDesc(plugin.getId()) == null)
conf.addPluginDescs(plugin);
if (conf.getConnector(conn.getId()) == null)
conf.addConnector(conn);
if (pm.getPluginDesc(pluginProxy.getId()) == null)
pm.addPluginDesc(pluginProxy);
if (pm.getConnectorMap().get(pluginConnector.getId()) == null)
pm.addConnector(pluginConnector);
boolean b = true;
for (Connector connector : app.getConnectors()) {
// 判断是否有名称重复的Connector,如果有就跳过,防止重复调用 app.addConnector(appConnector);
if (appConnector.getId().equals(connector.getId())){
b = false;
break;
}
}
}
@Override
public LfwView buildWidget(LfwWindow pm, LfwView conf, Map<String, Object> paramMap, String currWidgetId) {
// add plugin & plugout
Application app = AppUtil.getCntApplication();
bindWithFileMgr(app, pm, conf);
// bind events
conf.setControllerClazz(AttachRoleCompController.class.getName());
EventConf beforeShow = DialogEvent.getBeforeShowEvent();
beforeShow.setMethodName("beforeShow");
conf.addEventConf(beforeShow);
String codenode = (String) AppUtil.getAppAttr("nodecode");
AttachGroupVO[] groups = AttachRoleDao.retrieveAttachGroupByNodeCode(codenode);
// add components
for (int i = 0; i < (groups == null ? IAttachRoleCompConstant.MAX_ROLE_GROUP_COUNT : groups.length); i++) {
// GridComp
GridComp gridComp = new GridComp();
gridComp.setId("grid" + i);
gridComp.setView(conf);
gridComp.setShowImageBtn(true);
conf.getViewComponents().addComponent(gridComp);
// Menubar
MenubarComp menubar = new MenubarComp();
menubar.setId("menubar" + i);
menubar.setView(conf);
gridComp.setMenuBar(menubar);
// Menubar item
MenuItem attachBtn = new MenuItem();
attachBtn.setId(menubar.getId() + "_attachbtn");
attachBtn.setView(conf);
attachBtn.setText("查看附件");
attachBtn.setEnabled(false);
menubar.addMenuItem(attachBtn);
EventConf onGridClick = MouseEvent.getOnClickEvent();
onGridClick.setMethodName("onGridClick");
attachBtn.addEventConf(onGridClick);
// Dataset
Dataset ds = genDataset(gridComp.getId() + "_ds");
gridComp.setDataset(ds.getId());
EventConf onAfterRowSelect = DatasetEvent.getOnAfterRowSelectEvent();
onAfterRowSelect.setMethodName("onAfterRoleSelect");
ds.addEventConf(onAfterRowSelect);
conf.getViewModels().addDataset(ds);
// GridColumns
List<IGridColumn> columnList = genGridColumnList();
gridComp.setColumnList(columnList);
}
return conf;
}
}
| 7,101 | 0.730022 | 0.729145 | 230 | 28.76087 | 22.616831 | 134 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.413043 | false | false | 8 |
|
5dedb6fe28befc9df5083c6dc262a57b9a81a6fe | 3,736,621,566,280 | 308580ebbc0910bd19141e11bdc7548464c70b68 | /src/com/sprintqa/java/class23/ConstructorExample2.java | 193c75f36cfee1f80e4116632ff65ef78d5357c3 | [] | no_license | SprintQA/JavaProjects | https://github.com/SprintQA/JavaProjects | 2b3a5ec270338ec8b9d0f8f65df23b385d462f7f | 880a2057667444c00165e645cca07dd06ce065c5 | refs/heads/master | 2021-09-24T11:09:15.233000 | 2021-09-18T12:00:17 | 2021-09-18T12:00:17 | 236,334,022 | 5 | 3 | null | false | 2021-09-18T12:00:18 | 2020-01-26T15:46:35 | 2020-10-05T18:38:29 | 2021-09-18T12:00:17 | 293 | 4 | 1 | 0 | Java | false | false | package com.sprintqa.java.class23;
//prog to write parameterized and default constructors
class ConstructorExample2 {
static String store;
static String products;
static int yearBuilt;
static double avrgCheck;
public ConstructorExample2() { // User Defined Constructor
store = "Aldi";
products = "onions";
yearBuilt = 2017;
avrgCheck = 90.87;
}
public static void main(String[] args) {
ConstructorExample2 a = new ConstructorExample2();
System.out.println(store);
System.out.println(yearBuilt);
System.out.println(products);
System.out.println(avrgCheck);
}
} | UTF-8 | Java | 590 | java | ConstructorExample2.java | Java | [] | null | [] | package com.sprintqa.java.class23;
//prog to write parameterized and default constructors
class ConstructorExample2 {
static String store;
static String products;
static int yearBuilt;
static double avrgCheck;
public ConstructorExample2() { // User Defined Constructor
store = "Aldi";
products = "onions";
yearBuilt = 2017;
avrgCheck = 90.87;
}
public static void main(String[] args) {
ConstructorExample2 a = new ConstructorExample2();
System.out.println(store);
System.out.println(yearBuilt);
System.out.println(products);
System.out.println(avrgCheck);
}
} | 590 | 0.742373 | 0.718644 | 24 | 23.625 | 16.854309 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.791667 | false | false | 8 |
3c729ef4e7bc10b69d9a33c445a41bf22b43cfbb | 12,867,722,033,070 | 99c827f1a7452865ba77fe8d59724404ac21c6f7 | /src/gestionstock/marchandises/Pantalon.java | 1e00abbbe3a7a6932bafefc5ea966ff656d82bbd | [] | no_license | Tom3874/Gestock | https://github.com/Tom3874/Gestock | 89c5ebd95e678027ef695be69d4676606ff45181 | 4628387d458de2c439b1c1d1072794b0e463a63f | refs/heads/master | 2023-03-21T12:54:34.907000 | 2021-03-08T01:35:53 | 2021-03-08T01:35:53 | 345,174,812 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gestionstock.marchandises;
public class Pantalon extends Vetement {
private int taille;
private Stock stock;
public int getTaille() {
return taille;
}
public void setTaille(int taille) {
this.taille = taille;
}
public Pantalon(int a, double q, String c) {
super(a, q, c);
}
public Pantalon(int b, double z, String v, int t) {
this(b,z,v);
this.setTaille(t);
}
public Stock getStock() {
return stock;
}
public String toString() {
String chaine = super.toString();
chaine = chaine + "Pantalon de taille " + this.getTaille() + " et de couleur " + this.getCouleur() ;
return chaine;
}
}
| UTF-8 | Java | 648 | java | Pantalon.java | Java | [] | null | [] | package gestionstock.marchandises;
public class Pantalon extends Vetement {
private int taille;
private Stock stock;
public int getTaille() {
return taille;
}
public void setTaille(int taille) {
this.taille = taille;
}
public Pantalon(int a, double q, String c) {
super(a, q, c);
}
public Pantalon(int b, double z, String v, int t) {
this(b,z,v);
this.setTaille(t);
}
public Stock getStock() {
return stock;
}
public String toString() {
String chaine = super.toString();
chaine = chaine + "Pantalon de taille " + this.getTaille() + " et de couleur " + this.getCouleur() ;
return chaine;
}
}
| 648 | 0.651235 | 0.651235 | 33 | 18.60606 | 21.091345 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.121212 | false | false | 8 |
e177facc1114e1951c25e0cdc7c9f4fdbd3326f4 | 15,728,170,285,071 | bc434fc50889e457d47679919a512b6bbe6b2123 | /poom-services-domain/src/test/java/org/codingmatters/poom/services/domain/repositories/RepositoryIteratorTest.java | efcff8c6a11ea42af3edfa750d24797fd3f7f78f | [
"Apache-2.0"
] | permissive | flexiooss/poom-services | https://github.com/flexiooss/poom-services | c1db2a96a5cc518e8c4b3e184349188d15d674b2 | 873cd0d29db9138bd210ae3d728dc55c1183a48d | refs/heads/master | 2023-08-31T10:04:59.337000 | 2023-08-28T15:45:46 | 2023-08-28T15:45:46 | 93,128,488 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.codingmatters.poom.services.domain.repositories;
import org.codingmatters.poom.services.domain.exceptions.RepositoryException;
import org.codingmatters.poom.services.domain.entities.Entity;
import org.codingmatters.poom.services.domain.entities.ImmutableEntity;
import org.codingmatters.poom.services.domain.entities.PagedEntityList;
import org.junit.Test;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
public class RepositoryIteratorTest {
private LinkedList<PagedEntityList<String>> nextPages = new LinkedList<>();
private LinkedList<Request> requests = new LinkedList<>();
private EntityLister<String, String> lister = new EntityLister<String, String>() {
@Override
public PagedEntityList<String> all(long startIndex, long endIndex) throws RepositoryException {
requests.add(new Request(null, startIndex, endIndex));
return nextPages.removeFirst();
}
@Override
public PagedEntityList<String> search(String query, long startIndex, long endIndex) throws RepositoryException {
requests.add(new Request(query, startIndex, endIndex));
return nextPages.removeFirst();
}
};
@Test
public void whenSearching__thenSearchIsPassedToTheRepository() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 0L, Collections.emptyList()));
RepositoryIterator iterator = RepositoryIterator.search(this.lister, "searched", 10);
assertThat(iterator.hasNext(), is(false));
System.out.println(this.requests);
assertThat(this.requests, contains(new Request("searched", 0L, 9L)));
}
@Test
public void givenRepositoryEmpty__whenIterating__thenNoElement() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 0L, Collections.emptyList()));
RepositoryIterator iterator = RepositoryIterator.all(this.lister, 10);
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(new Request(null, 0L, 9L)));
}
@Test
public void givenRepositoryWithOnePage__whenIterating__thenAllElementsReturned() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 5L, 10L, this.elements(0, 5)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 10L, Collections.emptyList()));
RepositoryIterator<String, String> iterator = RepositoryIterator.all(this.lister, 10);
for (int i = 0; i <= 5; i++) {
assertThat(iterator.hasNext(), is(true));
Entity<String> next = iterator.next();
assertThat(next.value(), is("element-" + i));
}
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 6L, 15L)
));
}
@Test
public void givenRepositoryWithTwoPage__whenIterating__thenAllElementsReturned() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 15L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 14L, 15L, this.elements(10, 14)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 15L, Collections.emptyList()));
RepositoryIterator<String, String> iterator = RepositoryIterator.all(this.lister, 10);
for (int i = 0; i < 15; i++) {
assertThat(iterator.hasNext(), is(true));
Entity<String> next = iterator.next();
assertThat("element " + i, next.value(), is("element-" + i));
}
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 15L, 24L)
));
}
@Test
public void givenRepositoryWithTwoPage__whenStreamingIterating__thenAllElementsAreStreamed() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 15L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 14L, 15L, this.elements(10, 14)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 15L, Collections.emptyList()));
List<Entity<String>> elements = RepositoryIterator.allStreamed(this.lister, 10).collect(Collectors.toList());
assertThat(elements, hasSize(15));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 15L, 24L)
));
}
@Test
public void givenRepositoryWithThreePage__whenStreamingIterating__thenAllElementsAreStreamed() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 25L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 19L, 25L, this.elements(10, 19)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(20L, 24L, 25L, this.elements(20, 24)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 25L, Collections.emptyList()));
List<Entity<String>> elements = RepositoryIterator.allStreamed(this.lister, 10).collect(Collectors.toList());
assertThat(elements, hasSize(25));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 20L, 29L),
new Request(null, 25L, 34L)
));
}
private List<Entity<String>> elements(int start, int end) {
List<Entity<String>> result = new LinkedList<>();
for (int i = start; i <= end ; i++) {
result.add(new ImmutableEntity<>("" + i, BigInteger.ONE, "element-" + i));
}
return result;
}
class Request {
final String query;
final Long startIndex;
final Long endIndex;
public Request(String query, Long startIndex, Long endIndex) {
this.query = query;
this.startIndex = startIndex;
this.endIndex = endIndex;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Request request = (Request) o;
return Objects.equals(query, request.query) &&
Objects.equals(startIndex, request.startIndex) &&
Objects.equals(endIndex, request.endIndex);
}
@Override
public int hashCode() {
return Objects.hash(query, startIndex, endIndex);
}
@Override
public String toString() {
return "Request{" +
"query='" + query + '\'' +
", startIndex=" + startIndex +
", endIndex=" + endIndex +
'}';
}
}
} | UTF-8 | Java | 7,351 | java | RepositoryIteratorTest.java | Java | [] | null | [] | package org.codingmatters.poom.services.domain.repositories;
import org.codingmatters.poom.services.domain.exceptions.RepositoryException;
import org.codingmatters.poom.services.domain.entities.Entity;
import org.codingmatters.poom.services.domain.entities.ImmutableEntity;
import org.codingmatters.poom.services.domain.entities.PagedEntityList;
import org.junit.Test;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
public class RepositoryIteratorTest {
private LinkedList<PagedEntityList<String>> nextPages = new LinkedList<>();
private LinkedList<Request> requests = new LinkedList<>();
private EntityLister<String, String> lister = new EntityLister<String, String>() {
@Override
public PagedEntityList<String> all(long startIndex, long endIndex) throws RepositoryException {
requests.add(new Request(null, startIndex, endIndex));
return nextPages.removeFirst();
}
@Override
public PagedEntityList<String> search(String query, long startIndex, long endIndex) throws RepositoryException {
requests.add(new Request(query, startIndex, endIndex));
return nextPages.removeFirst();
}
};
@Test
public void whenSearching__thenSearchIsPassedToTheRepository() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 0L, Collections.emptyList()));
RepositoryIterator iterator = RepositoryIterator.search(this.lister, "searched", 10);
assertThat(iterator.hasNext(), is(false));
System.out.println(this.requests);
assertThat(this.requests, contains(new Request("searched", 0L, 9L)));
}
@Test
public void givenRepositoryEmpty__whenIterating__thenNoElement() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 0L, Collections.emptyList()));
RepositoryIterator iterator = RepositoryIterator.all(this.lister, 10);
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(new Request(null, 0L, 9L)));
}
@Test
public void givenRepositoryWithOnePage__whenIterating__thenAllElementsReturned() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 5L, 10L, this.elements(0, 5)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 10L, Collections.emptyList()));
RepositoryIterator<String, String> iterator = RepositoryIterator.all(this.lister, 10);
for (int i = 0; i <= 5; i++) {
assertThat(iterator.hasNext(), is(true));
Entity<String> next = iterator.next();
assertThat(next.value(), is("element-" + i));
}
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 6L, 15L)
));
}
@Test
public void givenRepositoryWithTwoPage__whenIterating__thenAllElementsReturned() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 15L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 14L, 15L, this.elements(10, 14)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 15L, Collections.emptyList()));
RepositoryIterator<String, String> iterator = RepositoryIterator.all(this.lister, 10);
for (int i = 0; i < 15; i++) {
assertThat(iterator.hasNext(), is(true));
Entity<String> next = iterator.next();
assertThat("element " + i, next.value(), is("element-" + i));
}
assertThat(iterator.hasNext(), is(false));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 15L, 24L)
));
}
@Test
public void givenRepositoryWithTwoPage__whenStreamingIterating__thenAllElementsAreStreamed() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 15L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 14L, 15L, this.elements(10, 14)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 15L, Collections.emptyList()));
List<Entity<String>> elements = RepositoryIterator.allStreamed(this.lister, 10).collect(Collectors.toList());
assertThat(elements, hasSize(15));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 15L, 24L)
));
}
@Test
public void givenRepositoryWithThreePage__whenStreamingIterating__thenAllElementsAreStreamed() throws Exception {
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(0L, 9L, 25L, this.elements(0, 9)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(10L, 19L, 25L, this.elements(10, 19)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<String>(20L, 24L, 25L, this.elements(20, 24)));
this.nextPages.add(new PagedEntityList.DefaultPagedEntityList<>(0L, 0L, 25L, Collections.emptyList()));
List<Entity<String>> elements = RepositoryIterator.allStreamed(this.lister, 10).collect(Collectors.toList());
assertThat(elements, hasSize(25));
assertThat(this.requests, contains(
new Request(null, 0L, 9L),
new Request(null, 10L, 19L),
new Request(null, 20L, 29L),
new Request(null, 25L, 34L)
));
}
private List<Entity<String>> elements(int start, int end) {
List<Entity<String>> result = new LinkedList<>();
for (int i = start; i <= end ; i++) {
result.add(new ImmutableEntity<>("" + i, BigInteger.ONE, "element-" + i));
}
return result;
}
class Request {
final String query;
final Long startIndex;
final Long endIndex;
public Request(String query, Long startIndex, Long endIndex) {
this.query = query;
this.startIndex = startIndex;
this.endIndex = endIndex;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Request request = (Request) o;
return Objects.equals(query, request.query) &&
Objects.equals(startIndex, request.startIndex) &&
Objects.equals(endIndex, request.endIndex);
}
@Override
public int hashCode() {
return Objects.hash(query, startIndex, endIndex);
}
@Override
public String toString() {
return "Request{" +
"query='" + query + '\'' +
", startIndex=" + startIndex +
", endIndex=" + endIndex +
'}';
}
}
} | 7,351 | 0.643586 | 0.623181 | 179 | 40.072624 | 37.188335 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.189944 | false | false | 8 |
dfd20bd5bc3bcefae9c0e6ef619d516944023429 | 3,805,341,079,637 | a317d7feacbc8234fc17c55b11528a6099f872ed | /springBoot-Nginx/src/main/java/com/lyy/controller/IndexController.java | 56304fa44142e931047095d0f09d5a3dc021ba41 | [] | no_license | liyy320/SpringCloud | https://github.com/liyy320/SpringCloud | 90db14274a1a0c16f9c84cb2c233d0931a94dce9 | 47e87f048346b8fed9b83f1776b972774d36fbd0 | refs/heads/master | 2020-09-09T09:34:21.396000 | 2019-11-28T01:29:53 | 2019-11-28T01:29:53 | 221,412,579 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lyy.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController //修饰的类下的所有方法自动返回json格式
public class IndexController {
@Value("${server.port}")
private int port;
@RequestMapping("/")
public String index() {
return "这是一个SpringBoot项目。端口号:" + port;
}
}
| UTF-8 | Java | 499 | java | IndexController.java | Java | [] | null | [] | package com.lyy.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController //修饰的类下的所有方法自动返回json格式
public class IndexController {
@Value("${server.port}")
private int port;
@RequestMapping("/")
public String index() {
return "这是一个SpringBoot项目。端口号:" + port;
}
}
| 499 | 0.748315 | 0.748315 | 18 | 22.722221 | 21.607111 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false | 8 |
43f42564e8d2220805364dd705aaa662e4e2300d | 19,258,633,388,498 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/5/5_6d803e3ab525d700d1e7d1dc8411b7702dc328d5/JoinDeploymentSupport/5_6d803e3ab525d700d1e7d1dc8411b7702dc328d5_JoinDeploymentSupport_s.java | 9dbc2edc48f6911c187eac475622afc7cab0ead8 | [] | 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 | /*
* This source file is part of CaesarJ
* For the latest info, see http://caesarj.org/
*
* Copyright 2003-2005
* Darmstadt University of Technology, Software Technology Group
* Also see acknowledgements in readme.txt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: JoinDeploymentSupport.java,v 1.5 2006-01-23 18:52:08 gasiunas Exp $
*/
package org.caesarj.compiler.joinpoint;
import org.caesarj.compiler.KjcEnvironment;
import org.caesarj.compiler.ast.phylum.JCompilationUnit;
import org.caesarj.compiler.ast.phylum.declaration.CjClassDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.CjInterfaceDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.CjVirtualClassDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.JTypeDeclaration;
import org.caesarj.compiler.constants.CaesarConstants;
import org.caesarj.compiler.context.CContext;
import org.caesarj.util.PositionedError;
/**
* @author Ostermann
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class JoinDeploymentSupport implements CaesarConstants {
/**
* Generates for every nested crosscutting class the corresponding deployment support classes.
*/
public static void prepareForDynamicDeployment(JCompilationUnit cu) throws PositionedError {
boolean bNewDelarations = false;
CContext ownerCtx = cu.getContext();
for (JTypeDeclaration typeDecl : cu.getInners()) {
if (typeDecl instanceof CjVirtualClassDeclaration) {
CjVirtualClassDeclaration caesarClass =
(CjVirtualClassDeclaration)typeDecl;
if (caesarClass.getRegistryClass() != null) {
// add the deployment support classes to the enclosing class
CjInterfaceDeclaration aspectIfc = caesarClass.getAspectInterface();
CjClassDeclaration registryCls = caesarClass.getRegistryClass();
cu.addInners(new JTypeDeclaration[] { aspectIfc, registryCls});
bNewDelarations = true;
// join the modified and new classes
aspectIfc.join(ownerCtx);
registryCls.join(ownerCtx);
//caesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
if (caesarClass.getInners().length > 0) {
//consider nested types
JoinDeploymentSupport.prepareForDynamicDeployment(caesarClass, cu.getEnvironment());
}
}
}
if (bNewDelarations) {
rejoinMixinInterfaces(cu.getInners(), ownerCtx);
}
}
private static void prepareForDynamicDeployment(CjClassDeclaration cd, KjcEnvironment environment) throws PositionedError
{
boolean bNewInners = false;
CContext ownerCtx = (CContext)cd.getContext();
for (JTypeDeclaration inner : cd.getInners())
{
if (inner instanceof CjVirtualClassDeclaration)
{
//create support classes for each crosscutting inner class
CjVirtualClassDeclaration innerCaesarClass =
(CjVirtualClassDeclaration)inner;
if (innerCaesarClass.getRegistryClass() != null)
{
//add the deployment support classes to the enclosing class
CjInterfaceDeclaration aspectIfc = innerCaesarClass.getAspectInterface();
CjClassDeclaration registryCls = innerCaesarClass.getRegistryClass();
cd.addInners(new JTypeDeclaration[] { aspectIfc, registryCls });
bNewInners = true;
//join the modified and new classes
aspectIfc.join(ownerCtx);
registryCls.join(ownerCtx);
//innerCaesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
//handle the inners of the inners
JTypeDeclaration[] innersInners = innerCaesarClass.getInners();
for (int j = 0; j < innersInners.length; j++)
{
if (innersInners[j] instanceof CjClassDeclaration)
{
CjClassDeclaration currentInnerInner =
(CjClassDeclaration) innersInners[j];
JoinDeploymentSupport.prepareForDynamicDeployment(currentInnerInner, environment);
}
}
}
}
if (bNewInners) {
rejoinMixinInterfaces(cd.getInners(), ownerCtx);
}
}
/**
* Rejoin the mixin interfaces of the crosscutting Caesar classes
*
* @param decl array of type declarations
* @param ownerCtx owner context
*/
private static void rejoinMixinInterfaces(JTypeDeclaration[] decl, CContext ownerCtx) throws PositionedError {
for (int i = 0; i < decl.length; i++) {
if (decl[i] instanceof CjVirtualClassDeclaration) {
CjVirtualClassDeclaration caesarClass = (CjVirtualClassDeclaration)decl[i];
if (caesarClass.isCrosscutting()) {
caesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
}
}
}
}
| UTF-8 | Java | 5,423 | java | 5_6d803e3ab525d700d1e7d1dc8411b7702dc328d5_JoinDeploymentSupport_s.java | Java | [
{
"context": "inDeploymentSupport.java,v 1.5 2006-01-23 18:52:08 gasiunas Exp $\n */\n \n package org.caesarj.compiler.joinpo",
"end": 1037,
"score": 0.9259573221206665,
"start": 1029,
"tag": "USERNAME",
"value": "gasiunas"
},
{
"context": "g.caesarj.util.PositionedError;\n \n /**\n * @author Ostermann\n *\n * To change the template for this generated",
"end": 1667,
"score": 0.9998199939727783,
"start": 1658,
"tag": "NAME",
"value": "Ostermann"
}
] | null | [] | /*
* This source file is part of CaesarJ
* For the latest info, see http://caesarj.org/
*
* Copyright 2003-2005
* Darmstadt University of Technology, Software Technology Group
* Also see acknowledgements in readme.txt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: JoinDeploymentSupport.java,v 1.5 2006-01-23 18:52:08 gasiunas Exp $
*/
package org.caesarj.compiler.joinpoint;
import org.caesarj.compiler.KjcEnvironment;
import org.caesarj.compiler.ast.phylum.JCompilationUnit;
import org.caesarj.compiler.ast.phylum.declaration.CjClassDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.CjInterfaceDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.CjVirtualClassDeclaration;
import org.caesarj.compiler.ast.phylum.declaration.JTypeDeclaration;
import org.caesarj.compiler.constants.CaesarConstants;
import org.caesarj.compiler.context.CContext;
import org.caesarj.util.PositionedError;
/**
* @author Ostermann
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class JoinDeploymentSupport implements CaesarConstants {
/**
* Generates for every nested crosscutting class the corresponding deployment support classes.
*/
public static void prepareForDynamicDeployment(JCompilationUnit cu) throws PositionedError {
boolean bNewDelarations = false;
CContext ownerCtx = cu.getContext();
for (JTypeDeclaration typeDecl : cu.getInners()) {
if (typeDecl instanceof CjVirtualClassDeclaration) {
CjVirtualClassDeclaration caesarClass =
(CjVirtualClassDeclaration)typeDecl;
if (caesarClass.getRegistryClass() != null) {
// add the deployment support classes to the enclosing class
CjInterfaceDeclaration aspectIfc = caesarClass.getAspectInterface();
CjClassDeclaration registryCls = caesarClass.getRegistryClass();
cu.addInners(new JTypeDeclaration[] { aspectIfc, registryCls});
bNewDelarations = true;
// join the modified and new classes
aspectIfc.join(ownerCtx);
registryCls.join(ownerCtx);
//caesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
if (caesarClass.getInners().length > 0) {
//consider nested types
JoinDeploymentSupport.prepareForDynamicDeployment(caesarClass, cu.getEnvironment());
}
}
}
if (bNewDelarations) {
rejoinMixinInterfaces(cu.getInners(), ownerCtx);
}
}
private static void prepareForDynamicDeployment(CjClassDeclaration cd, KjcEnvironment environment) throws PositionedError
{
boolean bNewInners = false;
CContext ownerCtx = (CContext)cd.getContext();
for (JTypeDeclaration inner : cd.getInners())
{
if (inner instanceof CjVirtualClassDeclaration)
{
//create support classes for each crosscutting inner class
CjVirtualClassDeclaration innerCaesarClass =
(CjVirtualClassDeclaration)inner;
if (innerCaesarClass.getRegistryClass() != null)
{
//add the deployment support classes to the enclosing class
CjInterfaceDeclaration aspectIfc = innerCaesarClass.getAspectInterface();
CjClassDeclaration registryCls = innerCaesarClass.getRegistryClass();
cd.addInners(new JTypeDeclaration[] { aspectIfc, registryCls });
bNewInners = true;
//join the modified and new classes
aspectIfc.join(ownerCtx);
registryCls.join(ownerCtx);
//innerCaesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
//handle the inners of the inners
JTypeDeclaration[] innersInners = innerCaesarClass.getInners();
for (int j = 0; j < innersInners.length; j++)
{
if (innersInners[j] instanceof CjClassDeclaration)
{
CjClassDeclaration currentInnerInner =
(CjClassDeclaration) innersInners[j];
JoinDeploymentSupport.prepareForDynamicDeployment(currentInnerInner, environment);
}
}
}
}
if (bNewInners) {
rejoinMixinInterfaces(cd.getInners(), ownerCtx);
}
}
/**
* Rejoin the mixin interfaces of the crosscutting Caesar classes
*
* @param decl array of type declarations
* @param ownerCtx owner context
*/
private static void rejoinMixinInterfaces(JTypeDeclaration[] decl, CContext ownerCtx) throws PositionedError {
for (int i = 0; i < decl.length; i++) {
if (decl[i] instanceof CjVirtualClassDeclaration) {
CjVirtualClassDeclaration caesarClass = (CjVirtualClassDeclaration)decl[i];
if (caesarClass.isCrosscutting()) {
caesarClass.getMixinIfcDeclaration().join(ownerCtx);
}
}
}
}
}
| 5,423 | 0.716762 | 0.709017 | 148 | 35.635136 | 29.559868 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.878378 | false | false | 8 |
d3113a81ed980e3a27034eb7367b3d81803390cd | 32,332,513,853,991 | 234f583eaac3e36dc28326bd79d83ec2c0325d79 | /SpringBootSwagger/src/main/java/com/main/controller/HomeController.java | 9036f3f388d98c949ff7f37d00974782c723860d | [] | no_license | kanekar-atul/java | https://github.com/kanekar-atul/java | 2f14b83ca0bcfac4293fb5a573c403f1eb051abb | 52e719736a668670f93c92a3824a50c8d30d5983 | refs/heads/master | 2022-06-28T13:43:35.760000 | 2019-08-07T03:55:21 | 2019-08-07T03:55:21 | 145,728,715 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.main.controller;
import java.awt.List;
import java.util.ArrayList;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HomeController {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
public String sayHello() {
return "Swagger Hello World";
}
@RequestMapping(method=RequestMethod.POST,value="/val/{id}")
public ArrayList getValue(@PathVariable String id) {
ArrayList l = new ArrayList();
l.add(id);
return l;
}
}
| UTF-8 | Java | 689 | java | HomeController.java | Java | [] | null | [] | package com.main.controller;
import java.awt.List;
import java.util.ArrayList;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HomeController {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
public String sayHello() {
return "Swagger Hello World";
}
@RequestMapping(method=RequestMethod.POST,value="/val/{id}")
public ArrayList getValue(@PathVariable String id) {
ArrayList l = new ArrayList();
l.add(id);
return l;
}
}
| 689 | 0.775036 | 0.775036 | 27 | 24.518518 | 23.697742 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.111111 | false | false | 8 |
5fe8d1f63d5d47ed308e8809359eca7c91265a52 | 27,161,373,210,602 | 9d389d030f22ac348768b777e4c56962eb87dd7c | /WebJdbcExample/src/main/java/ru/itis/dao/UsersDaoJdbcImpl.java | f92ba57d68f2205a51d27520693c119329fff2ad | [] | no_license | DndyDev/JavaItis4 | https://github.com/DndyDev/JavaItis4 | 2ef1fd822fa68d122533b2b5df6c7197376aa39d | dc5baca3c15a5321d84f438bdde692b10e69f834 | refs/heads/master | 2022-03-21T01:46:02.986000 | 2017-05-29T16:47:04 | 2017-05-29T16:47:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.itis.dao;
import ru.itis.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* 15.05.2017
* UsersDaoJdbcImpl
*
* @author Sidikov Marsel (First Software Engineering Platform)
* @version v1.0
*/
public class UsersDaoJdbcImpl implements UsersDao {
private Connection connection;
public UsersDaoJdbcImpl(Connection connection) {
this.connection = connection;
}
//language=SQL
private final String SQL_SELECT_USER_BY_ID =
"SELECT * FROM student WHERE id = ?";
//language=SQL
private final String SQL_SELECT_ALL =
"SELECT * FROM student";
//language=SQL
private final String SQL_SELECT_ALL_BY_AGE =
"SELECT * FROM student WHERE age = ?";
//language=SQL
private final String SQL_INSERT_USER =
"INSERT INTO student(age, name, height, style) VALUES(?, ?, ?, ?)";
public User find(int id) {
try {
// создаем выражение для запроса из коннекта к БД
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_USER_BY_ID);
// положили параметр
statement.setInt(1, id);
// запустили запрос, получили результат - set
ResultSet set = statement.executeQuery();
// магия
set.next();
// из строки вытащили значения
String name = set.getString("name");
int age = set.getInt("age");
int height = set.getInt("height");
String style = set.getString("style");
// создали пользователя, вернули как результат
return new User(id, name, age, height, style);
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public List<User> findAll() {
try {
List<User> users = new ArrayList<User>();
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_ALL);
ResultSet set = statement.executeQuery();
while (set.next()) {
int id = set.getInt("id");
String name = set.getString("name");
int age = set.getInt("age");
int height = set.getInt("height");
String style = set.getString("style");
User newUser = new User(id, name, age, height, style);
users.add(newUser);
}
return users;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public void delete(int id) {
}
public void update(User model) {
}
public int save(User model) {
try {
String generatedColumns[] = { "id" };
PreparedStatement statement = connection.prepareStatement(SQL_INSERT_USER, generatedColumns);
statement.setInt(1, model.getAge());
statement.setString(2, model.getName());
statement.setInt(3, model.getHeight());
statement.setString(4, model.getStyle());
// в insertedRows количество изменненных строк
int insertedRows = statement.executeUpdate();
// получили множество сгенерированных ключей
ResultSet generatedKeys = statement.getGeneratedKeys();
// магия
generatedKeys.next();
int generatedId = generatedKeys.getInt(1);
model.setId(generatedId);
return generatedId;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public List<User> findAllByAge(int age) {
try {
List<User> users = new ArrayList<User>();
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_ALL_BY_AGE);
statement.setInt(1, age);
ResultSet set = statement.executeQuery();
while (set.next()) {
int id = set.getInt("id");
String name = set.getString("name");
int height = set.getInt("height");
String style = set.getString("style");
User newUser = new User(id, name, age, height, style);
users.add(newUser);
}
return users;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
}
| UTF-8 | Java | 4,765 | java | UsersDaoJdbcImpl.java | Java | [
{
"context": "**\n * 15.05.2017\n * UsersDaoJdbcImpl\n *\n * @author Sidikov Marsel (First Software Engineering Platform)\n * @version",
"end": 282,
"score": 0.9998548030853271,
"start": 268,
"tag": "NAME",
"value": "Sidikov Marsel"
}
] | null | [] | package ru.itis.dao;
import ru.itis.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* 15.05.2017
* UsersDaoJdbcImpl
*
* @author <NAME> (First Software Engineering Platform)
* @version v1.0
*/
public class UsersDaoJdbcImpl implements UsersDao {
private Connection connection;
public UsersDaoJdbcImpl(Connection connection) {
this.connection = connection;
}
//language=SQL
private final String SQL_SELECT_USER_BY_ID =
"SELECT * FROM student WHERE id = ?";
//language=SQL
private final String SQL_SELECT_ALL =
"SELECT * FROM student";
//language=SQL
private final String SQL_SELECT_ALL_BY_AGE =
"SELECT * FROM student WHERE age = ?";
//language=SQL
private final String SQL_INSERT_USER =
"INSERT INTO student(age, name, height, style) VALUES(?, ?, ?, ?)";
public User find(int id) {
try {
// создаем выражение для запроса из коннекта к БД
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_USER_BY_ID);
// положили параметр
statement.setInt(1, id);
// запустили запрос, получили результат - set
ResultSet set = statement.executeQuery();
// магия
set.next();
// из строки вытащили значения
String name = set.getString("name");
int age = set.getInt("age");
int height = set.getInt("height");
String style = set.getString("style");
// создали пользователя, вернули как результат
return new User(id, name, age, height, style);
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public List<User> findAll() {
try {
List<User> users = new ArrayList<User>();
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_ALL);
ResultSet set = statement.executeQuery();
while (set.next()) {
int id = set.getInt("id");
String name = set.getString("name");
int age = set.getInt("age");
int height = set.getInt("height");
String style = set.getString("style");
User newUser = new User(id, name, age, height, style);
users.add(newUser);
}
return users;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public void delete(int id) {
}
public void update(User model) {
}
public int save(User model) {
try {
String generatedColumns[] = { "id" };
PreparedStatement statement = connection.prepareStatement(SQL_INSERT_USER, generatedColumns);
statement.setInt(1, model.getAge());
statement.setString(2, model.getName());
statement.setInt(3, model.getHeight());
statement.setString(4, model.getStyle());
// в insertedRows количество изменненных строк
int insertedRows = statement.executeUpdate();
// получили множество сгенерированных ключей
ResultSet generatedKeys = statement.getGeneratedKeys();
// магия
generatedKeys.next();
int generatedId = generatedKeys.getInt(1);
model.setId(generatedId);
return generatedId;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
public List<User> findAllByAge(int age) {
try {
List<User> users = new ArrayList<User>();
PreparedStatement statement =
connection.prepareStatement(SQL_SELECT_ALL_BY_AGE);
statement.setInt(1, age);
ResultSet set = statement.executeQuery();
while (set.next()) {
int id = set.getInt("id");
String name = set.getString("name");
int height = set.getInt("height");
String style = set.getString("style");
User newUser = new User(id, name, age, height, style);
users.add(newUser);
}
return users;
} catch (SQLException e) {
throw new IllegalArgumentException(e);
}
}
}
| 4,757 | 0.563973 | 0.560229 | 146 | 30.102739 | 22.665443 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.60274 | false | false | 8 |
6dcafb7e6b20154cf4aeaeaa1137a964ba7a74b0 | 19,052,474,938,057 | c72ccbe1af2f1477dc9377c6358eb64681d9d4c6 | /VPDT1/app/src/main/java/com/vpdt/vpdt/ui/activity/XuLyGiayMoi/ThongTinGiayMoiDaXuLyActivity.java | 4dc024003f1475fd351087483004dcdb482c2699 | [] | no_license | namtv1997/Vdt | https://github.com/namtv1997/Vdt | 6fefaf3ecafb01dbc964fba75b8a516c8c4f58bd | 82cb043b29873352a32c366245e643b2dd3d6d22 | refs/heads/master | 2021-02-28T01:10:22.020000 | 2020-03-07T14:48:35 | 2020-03-07T14:48:35 | 245,649,933 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vpdt.vpdt.ui.activity.XuLyGiayMoi;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.vpdt.vpdt.R;
import com.vpdt.vpdt.base.BaseActivity;
import com.vpdt.vpdt.model.DetailGiayMoiPhongChuTriChoXuLy;
import com.vpdt.vpdt.model.KetQuaGiaiQuyetPhongPP;
import com.vpdt.vpdt.model.KetQuaGiaiQuyetPhongTL;
import com.vpdt.vpdt.model.TepTinDinhKemPPH;
import com.vpdt.vpdt.model.TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet;
import com.vpdt.vpdt.model.TrinhTuGiaiQuyetPhoiHopTraLai;
import com.vpdt.vpdt.model.TrinhTuHoanThanhCVLuuVet;
import com.vpdt.vpdt.presenter.TTVBGiayMoiPhongChuTriChoXuLyPresenter;
import com.vpdt.vpdt.presenter.TTVBGiayMoiPhongChuTriChoXuLyView;
import com.vpdt.vpdt.presenter.impl.TTVBGiayMoiPhongChuTriChoXuLyPresenterImpl;
import com.vpdt.vpdt.ui.adapter.AdapterKetQuaGiaiQuyetPhongPH;
import com.vpdt.vpdt.ui.adapter.AdapterKetQuaGiaiQuyetPhongTL;
import com.vpdt.vpdt.ui.adapter.AdapterTepTinDinhKemPhongPH;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuGiaiQuyetPhoiHopTraLai;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet;
import com.vpdt.vpdt.util.Util;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class ThongTinGiayMoiDaXuLyActivity extends BaseActivity<TTVBGiayMoiPhongChuTriChoXuLyPresenter> implements TTVBGiayMoiPhongChuTriChoXuLyView,
AdapterTepTinDinhKemPhongPH.OnItemClickListener, AdapterKetQuaGiaiQuyetPhongTL.OnItemketquaGiaiquyetPhongThulyClickListener,
AdapterKetQuaGiaiQuyetPhongPH.OnItemketquaGiaiquyetClickListener {
@BindView(R.id.cbVBQPPL)
CheckBox cbVBQPPL;
@BindView(R.id.cbSTCChuTri)
CheckBox cbSTCChuTri;
@BindView(R.id.cbTBKL)
CheckBox cbTBKL;
@BindView(R.id.imDownThongTinVanBan)
ImageView imDownThongTinVanBan;
@BindView(R.id.imUpThongTinVanBan)
ImageView imUpThongTinVanBan;
@BindView(R.id.imDownTrinhTuGiaiQuyet)
ImageView imDownTrinhTuGiaiQuyet;
@BindView(R.id.imUpTrinhTuGiaiQuyet)
ImageView imUpTrinhTuGiaiQuyet;
@BindView(R.id.imDownTepDinhKem)
ImageView imDownTepDinhKem;
@BindView(R.id.imUpTepDinhKem)
ImageView imUpTepDinhKem;
@BindView(R.id.imDownTruyenNhanLuuViet)
ImageView imDownTruyenNhanLuuViet;
@BindView(R.id.imUpTruyenNhanLuuViet)
ImageView imUpTruyenNhanLuuViet;
@BindView(R.id.imDownKetQuaGiaiQuyetPPH)
ImageView imDownKetQuaGiaiQuyetPPH;
@BindView(R.id.imUpKetQuaGiaiQuyetPPH)
ImageView imUpKetQuaGiaiQuyetPPH;
@BindView(R.id.imDownKetQuaGiaiQuyetPThuLy)
ImageView imDownKetQuaGiaiQuyetPThuLy;
@BindView(R.id.imUpKetQuaGiaiQuyetPThuLy)
ImageView imUpKetQuaGiaiQuyetPThuLy;
@BindView(R.id.imDownTrinhTuHoanThanhCV)
ImageView imDownTrinhTuHoanThanhCV;
@BindView(R.id.imUpTrinhTuHoanThanhCV)
ImageView imUpTrinhTuHoanThanhCV;
@BindView(R.id.rcvTTGQTTVB)
RecyclerView rcvTTGQTTVB;
@BindView(R.id.rcvTTDKTTVB)
RecyclerView rcvTTDKTTVB;
@BindView(R.id.rcvTTTNLVTTVB)
RecyclerView rcvTTTNLVTTVB;
@BindView(R.id.rcvKetQuaGiaiQuyetPThuLy)
RecyclerView rcvKetQuaGiaiQuyetPThuLy;
@BindView(R.id.rcvTrinhTuHoanThanhCV)
RecyclerView rcvTrinhTuHoanThanhCV;
@BindView(R.id.rcvKetQuaGiaiQuyetPPH)
RecyclerView rcvKetQuaGiaiQuyetPPH;
@BindView(R.id.lnThongTinVanBan)
LinearLayout lnThongTinVanBan;
@BindView(R.id.lnTrinhTuGiaiQuyet)
LinearLayout lnTrinhTuGiaiQuyet;
@BindView(R.id.lnTepDinhKem)
LinearLayout lnTepDinhKem;
@BindView(R.id.lnTruyenNhanLuuViet)
LinearLayout lnTruyenNhanLuuViet;
@BindView(R.id.lnKetQuaGiaiQuyetPThuLy)
LinearLayout lnKetQuaGiaiQuyetPThuLy;
@BindView(R.id.lnTrinhTuHoanThanhCV)
LinearLayout lnTrinhTuHoanThanhCV;
@BindView(R.id.lnKetQuaGiaiQuyetPPH)
LinearLayout lnKetQuaGiaiQuyetPPH;
@BindView(R.id.tvHopVaoHoi)
TextView tvHopVaoHoi;
@BindView(R.id.tvPhongGiamDoc)
TextView tvPhongGiamDoc;
@BindView(R.id.tvNoiDung)
TextView tvNoiDung;
@BindView(R.id.tvSoDen)
TextView tvSoDen;
@BindView(R.id.tvKhuVuc)
TextView tvKhuVuc;
@BindView(R.id.tvSoKyHieu)
TextView tvSoKyHieu;
@BindView(R.id.tvLoaiVanBan)
TextView tvLoaiVanBan;
@BindView(R.id.tvTrichYeu)
TextView tvTrichYeu;
@BindView(R.id.tvNguoiKy)
TextView tvNguoiKy;
@BindView(R.id.tvNgayNhan)
TextView tvNgayNhan;
@BindView(R.id.tvSoTrang)
TextView tvSoTrang;
@BindView(R.id.tvDoMat)
TextView tvDoMat;
@BindView(R.id.tvNoiGuiDen)
TextView tvNoiGuiDen;
@BindView(R.id.tvNgayKy)
TextView tvNgayKy;
@BindView(R.id.tvChucVu)
TextView tvChucVu;
@BindView(R.id.tvHanGiaiQuyet)
TextView tvHanGiaiQuyet;
@BindView(R.id.tvDoKhan)
TextView tvDoKhan;
@BindView(R.id.edtKetQuaGiaiQuyet)
TextView edtKetQuaGiaiQuyet;
@BindView(R.id.btnCVDaHoanThanh)
Button btnCVDaHoanThanh;
@BindView(R.id.rlTrinhTuGiaiQuyet)
RelativeLayout rlTrinhTuGiaiQuyet;
@BindView(R.id.rlTepDinhKem)
RelativeLayout rlTepDinhKem;
@BindView(R.id.rlTrinhTuTruyenNhanLuuVet)
RelativeLayout rlTrinhTuTruyenNhanLuuVet;
@BindView(R.id.rlKetQuaGiaiQuyetPhongPhoiHop)
RelativeLayout rlKetQuaGiaiQuyetPhongPhoiHop;
@BindView(R.id.rlKetQuaGiaiQuyetPhongThuLy)
RelativeLayout rlKetQuaGiaiQuyetPhongThuLy;
@BindView(R.id.rlTrinhTuHoanThanhCongViec)
RelativeLayout rlTrinhTuHoanThanhCongViec;
AdapterTrinhTuGiaiQuyetPhoiHopTraLai adapterTrinhTuGiaiQuyetPhoiHopTraLai;
AdapterTepTinDinhKemPhongPH adapterTepTinDinhKemPhongPH;
AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet;
AdapterKetQuaGiaiQuyetPhongTL adapterKetQuaGiaiQuyetPhongTL;
AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet;
AdapterKetQuaGiaiQuyetPhongPH adapterKetQuaGiaiQuyetPhongPH;
int id;
@Override
public int getContentViewId() {
return R.layout.activity_thong_tin_giay_moi_da_xu_ly;
}
@Override
public void initializeComponents() {
ButterKnife.bind(this);
Util.checkConnection(this);
Intent intent = getIntent();
if (intent != null) {
if (intent.hasExtra("idvb")) {
id = intent.getIntExtra("idvb", 0);
getPresenter().getDetailGMChuyenVienChuTriXuLy(id);
}
}
}
@Override
public Context gContext() {
return this;
}
@Override
public void onGetDaTaSuccess(DetailGiayMoiPhongChuTriChoXuLy detailGiayMoiPhongChuTriChoXuLy) {
RecyclerViewTrinhTuGiaiQuyetGiayMoi((ArrayList<TrinhTuGiaiQuyetPhoiHopTraLai>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuGiaiQuyets());
RecyclerViewTrinhTuChuyenNhanLuuVet((ArrayList<TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuChuyenNhanLuuVets());
RecyclerViewTepTinDinhKem((ArrayList<TepTinDinhKemPPH>) detailGiayMoiPhongChuTriChoXuLy.getTepTinDinhKems());
RecyclerViewKetQuaGiaiQuyetPhongThuLy((ArrayList<KetQuaGiaiQuyetPhongTL>) detailGiayMoiPhongChuTriChoXuLy.getKetQuaGiaiQuyetPhongTLs());
RecyclerViewTrinhTuHoanThanhLuuVet((ArrayList<TrinhTuHoanThanhCVLuuVet>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuHoanThanhCVLuuVets());
RecyclerViewKetQuaGiaiQuyetPhongPH((ArrayList<KetQuaGiaiQuyetPhongPP>) detailGiayMoiPhongChuTriChoXuLy.getketQuaGiaiQuyetPhongPHs());
tvHopVaoHoi.setText(detailGiayMoiPhongChuTriChoXuLy.getGiayMoiGio() + " - " + detailGiayMoiPhongChuTriChoXuLy.getGiayMoiNgay());
tvPhongGiamDoc.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getGiayMoiDiaDiem()));
tvNoiDung.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNoiDung()));
tvSoDen.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoDen()));
tvKhuVuc.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getKhuVuc()));
tvSoKyHieu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoKyHieu()));
tvLoaiVanBan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getLoaiVanBan()));
tvTrichYeu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getMoTa()));
tvNguoiKy.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getTenNguoiKy()));
tvNgayNhan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNgayNhan()));
tvSoTrang.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoTrang()));
tvDoMat.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getDoMat()));
tvNoiGuiDen.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNoiGuiDen()));
tvNgayKy.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNgayKy()));
tvChucVu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getChucVu()));
tvHanGiaiQuyet.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getHanGiaiQuyet()));
tvDoKhan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getDoKhan()));
if (detailGiayMoiPhongChuTriChoXuLy.getVBQPPL() == 1) {
cbVBQPPL.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getSTCCT() == 1) {
cbSTCChuTri.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTBKL() == 1) {
cbTBKL.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getShowfromHoanThanh()) {
btnCVDaHoanThanh.setVisibility(View.VISIBLE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuGiaiQuyets().size() == 0) {
rlTrinhTuGiaiQuyet.setVisibility(View.GONE);
lnTrinhTuGiaiQuyet.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTepTinDinhKems().size() == 0) {
rlTepDinhKem.setVisibility(View.GONE);
lnTepDinhKem.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuChuyenNhanLuuVets().size() == 0) {
rlTrinhTuTruyenNhanLuuVet.setVisibility(View.GONE);
lnTruyenNhanLuuViet.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getketQuaGiaiQuyetPhongPHs().size() == 0) {
rlKetQuaGiaiQuyetPhongPhoiHop.setVisibility(View.GONE);
lnKetQuaGiaiQuyetPPH.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getKetQuaGiaiQuyetPhongTLs().size() == 0) {
rlKetQuaGiaiQuyetPhongThuLy.setVisibility(View.GONE);
lnKetQuaGiaiQuyetPThuLy.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuHoanThanhCVLuuVets().size() == 0) {
rlTrinhTuHoanThanhCongViec.setVisibility(View.GONE);
lnTrinhTuHoanThanhCV.setVisibility(View.GONE);
}
}
@Override
public void hoanThanhGMChuyenVienChuTriXuLySuccess() {
Toast.makeText(this, "Xong", Toast.LENGTH_SHORT).show();
finish();
}
@Override
public void xoaKQPhongTLSuccess() {
Toast.makeText(this, "Xong", Toast.LENGTH_SHORT).show();
getPresenter().getDetailGMChuyenVienChuTriXuLy(id);
}
@Override
public TTVBGiayMoiPhongChuTriChoXuLyPresenter createPresenter() {
return new TTVBGiayMoiPhongChuTriChoXuLyPresenterImpl(this);
}
@OnClick({R.id.imvBack, R.id.tvThongTinVanBan, R.id.lnTTVB,
R.id.tvTrinhTuGiaiQuyet, R.id.tvTepDinhKem,
R.id.tvTruyenNhanLuuVet,
R.id.tvKetQuaGiaiQuyetPThuLy, R.id.tvTrinhTuHoanThanhCV, R.id.btnSoanBaoCao, R.id.btnCVDaHoanThanh, R.id.tvKetQuaGiaiQuyetPPH})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.imvBack:
finish();
break;
case R.id.tvThongTinVanBan:
Expand(lnThongTinVanBan, imUpThongTinVanBan, imDownThongTinVanBan);
break;
case R.id.tvTrinhTuGiaiQuyet:
Expand(lnTrinhTuGiaiQuyet, imUpTrinhTuGiaiQuyet, imDownTrinhTuGiaiQuyet);
break;
case R.id.tvTepDinhKem:
Expand(lnTepDinhKem, imUpTepDinhKem, imDownTepDinhKem);
break;
case R.id.tvTruyenNhanLuuVet:
Expand(lnTruyenNhanLuuViet, imUpTruyenNhanLuuViet, imDownTruyenNhanLuuViet);
break;
case R.id.tvKetQuaGiaiQuyetPThuLy:
Expand(lnKetQuaGiaiQuyetPThuLy, imUpKetQuaGiaiQuyetPThuLy, imDownKetQuaGiaiQuyetPThuLy);
break;
case R.id.tvTrinhTuHoanThanhCV:
Expand(lnTrinhTuHoanThanhCV, imUpTrinhTuHoanThanhCV, imDownTrinhTuHoanThanhCV);
break;
case R.id.tvKetQuaGiaiQuyetPPH:
Expand(lnKetQuaGiaiQuyetPPH, imUpKetQuaGiaiQuyetPPH, imDownKetQuaGiaiQuyetPPH);
break;
case R.id.btnSoanBaoCao:
// Intent intent = new Intent(this, SoanBaoCaoActivity.class);
// intent.putExtra("ID_GIAYMOI_CHO_LANHDAO_XULY", id);
// startActivity(intent);
Util.showMessenger("Chức năng đang hoàn thiện", this);
break;
case R.id.btnCVDaHoanThanh:
getPresenter().hoanThanhGMChuyenVienChuTriXuLy(id, edtKetQuaGiaiQuyet.getText().toString(), "");
break;
case R.id.lnTTVB:
closeKeyboard();
break;
}
}
void Expand(LinearLayout linearLayout, ImageView imgGone, ImageView imgVisible) {
if (linearLayout.getVisibility() == View.GONE) {
imgGone.setVisibility(View.VISIBLE);
linearLayout.setVisibility(View.VISIBLE);
imgVisible.setVisibility(View.GONE);
} else {
linearLayout.setVisibility(View.GONE);
imgGone.setVisibility(View.GONE);
imgVisible.setVisibility(View.VISIBLE);
}
}
void RecyclerViewTrinhTuGiaiQuyetGiayMoi(ArrayList<TrinhTuGiaiQuyetPhoiHopTraLai> trinhTuGiaiQuyets) {
adapterTrinhTuGiaiQuyetPhoiHopTraLai = new AdapterTrinhTuGiaiQuyetPhoiHopTraLai(trinhTuGiaiQuyets);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTGQTTVB.setLayoutManager(layoutManager);
rcvTTGQTTVB.setAdapter(adapterTrinhTuGiaiQuyetPhoiHopTraLai);
adapterTrinhTuGiaiQuyetPhoiHopTraLai.notifyDataSetChanged();
}
void RecyclerViewTrinhTuChuyenNhanLuuVet(ArrayList<TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet> trinhTuChuyenNhanLuuVets) {
adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet = new AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet(trinhTuChuyenNhanLuuVets);
LinearLayoutManager layoutManagerTrinhTuChuyenNhanLuuVet = new LinearLayoutManager(this);
layoutManagerTrinhTuChuyenNhanLuuVet.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTTNLVTTVB.setLayoutManager(layoutManagerTrinhTuChuyenNhanLuuVet);
rcvTTTNLVTTVB.setAdapter(adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet);
adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet.notifyDataSetChanged();
}
void RecyclerViewTrinhTuHoanThanhLuuVet(ArrayList<TrinhTuHoanThanhCVLuuVet> trinhTuGiaiQuyetPhongPhoiHops) {
adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet = new AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet(trinhTuGiaiQuyetPhongPhoiHops);
LinearLayoutManager layoutManagerTrinhTuGiaiQuyetPhongPhoiHop = new LinearLayoutManager(this);
layoutManagerTrinhTuGiaiQuyetPhongPhoiHop.setOrientation(LinearLayoutManager.VERTICAL);
rcvTrinhTuHoanThanhCV.setLayoutManager(layoutManagerTrinhTuGiaiQuyetPhongPhoiHop);
rcvTrinhTuHoanThanhCV.setAdapter(adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet);
adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet.notifyDataSetChanged();
}
void RecyclerViewKetQuaGiaiQuyetPhongThuLy(ArrayList<KetQuaGiaiQuyetPhongTL> ketquaGiaiquyetPhongThulies) {
adapterKetQuaGiaiQuyetPhongTL = new AdapterKetQuaGiaiQuyetPhongTL(ketquaGiaiquyetPhongThulies, this);
LinearLayoutManager layoutManagerTrinhTuGiaiQuyetPhongPhoiHop = new LinearLayoutManager(this);
layoutManagerTrinhTuGiaiQuyetPhongPhoiHop.setOrientation(LinearLayoutManager.VERTICAL);
rcvKetQuaGiaiQuyetPThuLy.setLayoutManager(layoutManagerTrinhTuGiaiQuyetPhongPhoiHop);
rcvKetQuaGiaiQuyetPThuLy.setAdapter(adapterKetQuaGiaiQuyetPhongTL);
adapterKetQuaGiaiQuyetPhongTL.notifyDataSetChanged();
}
void RecyclerViewTepTinDinhKem(ArrayList<TepTinDinhKemPPH> tepDinhKems) {
adapterTepTinDinhKemPhongPH = new AdapterTepTinDinhKemPhongPH(tepDinhKems, this);
LinearLayoutManager layoutManagerTepTinDinhKem = new LinearLayoutManager(this);
layoutManagerTepTinDinhKem.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTDKTTVB.setLayoutManager(layoutManagerTepTinDinhKem);
rcvTTDKTTVB.setAdapter(adapterTepTinDinhKemPhongPH);
adapterTepTinDinhKemPhongPH.notifyDataSetChanged();
}
void RecyclerViewKetQuaGiaiQuyetPhongPH(ArrayList<KetQuaGiaiQuyetPhongPP> ketQuaGiaiQuyetPhongPPArrayList) {
adapterKetQuaGiaiQuyetPhongPH = new AdapterKetQuaGiaiQuyetPhongPH(ketQuaGiaiQuyetPhongPPArrayList, this);
LinearLayoutManager layoutManagerTepTinDinhKem = new LinearLayoutManager(this);
layoutManagerTepTinDinhKem.setOrientation(LinearLayoutManager.VERTICAL);
rcvKetQuaGiaiQuyetPPH.setLayoutManager(layoutManagerTepTinDinhKem);
rcvKetQuaGiaiQuyetPPH.setAdapter(adapterKetQuaGiaiQuyetPhongPH);
adapterKetQuaGiaiQuyetPhongPH.notifyDataSetChanged();
}
@Override
public void onItemClick(TepTinDinhKemPPH tepTinDinhKemPPH) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(tepTinDinhKemPPH.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onItemketquaGiaiquyetPhongThulyClick(KetQuaGiaiQuyetPhongTL ketquaGiaiquyetPhongThuly) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(ketquaGiaiquyetPhongThuly.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onItemTacVuClick(KetQuaGiaiQuyetPhongTL ketquaGiaiquyetPhongThuly) {
getPresenter().xoaKQPhongTL(ketquaGiaiquyetPhongThuly.getId());
}
@Override
public void onItemketquaGiaiquyetClick(KetQuaGiaiQuyetPhongPP ketquaGiaiquyetPhongPhoihop) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(ketquaGiaiquyetPhongPhoihop.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
private void closeKeyboard() {
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}
| UTF-8 | Java | 20,023 | java | ThongTinGiayMoiDaXuLyActivity.java | Java | [] | null | [] | package com.vpdt.vpdt.ui.activity.XuLyGiayMoi;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.vpdt.vpdt.R;
import com.vpdt.vpdt.base.BaseActivity;
import com.vpdt.vpdt.model.DetailGiayMoiPhongChuTriChoXuLy;
import com.vpdt.vpdt.model.KetQuaGiaiQuyetPhongPP;
import com.vpdt.vpdt.model.KetQuaGiaiQuyetPhongTL;
import com.vpdt.vpdt.model.TepTinDinhKemPPH;
import com.vpdt.vpdt.model.TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet;
import com.vpdt.vpdt.model.TrinhTuGiaiQuyetPhoiHopTraLai;
import com.vpdt.vpdt.model.TrinhTuHoanThanhCVLuuVet;
import com.vpdt.vpdt.presenter.TTVBGiayMoiPhongChuTriChoXuLyPresenter;
import com.vpdt.vpdt.presenter.TTVBGiayMoiPhongChuTriChoXuLyView;
import com.vpdt.vpdt.presenter.impl.TTVBGiayMoiPhongChuTriChoXuLyPresenterImpl;
import com.vpdt.vpdt.ui.adapter.AdapterKetQuaGiaiQuyetPhongPH;
import com.vpdt.vpdt.ui.adapter.AdapterKetQuaGiaiQuyetPhongTL;
import com.vpdt.vpdt.ui.adapter.AdapterTepTinDinhKemPhongPH;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuGiaiQuyetPhoiHopTraLai;
import com.vpdt.vpdt.ui.adapter.AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet;
import com.vpdt.vpdt.util.Util;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class ThongTinGiayMoiDaXuLyActivity extends BaseActivity<TTVBGiayMoiPhongChuTriChoXuLyPresenter> implements TTVBGiayMoiPhongChuTriChoXuLyView,
AdapterTepTinDinhKemPhongPH.OnItemClickListener, AdapterKetQuaGiaiQuyetPhongTL.OnItemketquaGiaiquyetPhongThulyClickListener,
AdapterKetQuaGiaiQuyetPhongPH.OnItemketquaGiaiquyetClickListener {
@BindView(R.id.cbVBQPPL)
CheckBox cbVBQPPL;
@BindView(R.id.cbSTCChuTri)
CheckBox cbSTCChuTri;
@BindView(R.id.cbTBKL)
CheckBox cbTBKL;
@BindView(R.id.imDownThongTinVanBan)
ImageView imDownThongTinVanBan;
@BindView(R.id.imUpThongTinVanBan)
ImageView imUpThongTinVanBan;
@BindView(R.id.imDownTrinhTuGiaiQuyet)
ImageView imDownTrinhTuGiaiQuyet;
@BindView(R.id.imUpTrinhTuGiaiQuyet)
ImageView imUpTrinhTuGiaiQuyet;
@BindView(R.id.imDownTepDinhKem)
ImageView imDownTepDinhKem;
@BindView(R.id.imUpTepDinhKem)
ImageView imUpTepDinhKem;
@BindView(R.id.imDownTruyenNhanLuuViet)
ImageView imDownTruyenNhanLuuViet;
@BindView(R.id.imUpTruyenNhanLuuViet)
ImageView imUpTruyenNhanLuuViet;
@BindView(R.id.imDownKetQuaGiaiQuyetPPH)
ImageView imDownKetQuaGiaiQuyetPPH;
@BindView(R.id.imUpKetQuaGiaiQuyetPPH)
ImageView imUpKetQuaGiaiQuyetPPH;
@BindView(R.id.imDownKetQuaGiaiQuyetPThuLy)
ImageView imDownKetQuaGiaiQuyetPThuLy;
@BindView(R.id.imUpKetQuaGiaiQuyetPThuLy)
ImageView imUpKetQuaGiaiQuyetPThuLy;
@BindView(R.id.imDownTrinhTuHoanThanhCV)
ImageView imDownTrinhTuHoanThanhCV;
@BindView(R.id.imUpTrinhTuHoanThanhCV)
ImageView imUpTrinhTuHoanThanhCV;
@BindView(R.id.rcvTTGQTTVB)
RecyclerView rcvTTGQTTVB;
@BindView(R.id.rcvTTDKTTVB)
RecyclerView rcvTTDKTTVB;
@BindView(R.id.rcvTTTNLVTTVB)
RecyclerView rcvTTTNLVTTVB;
@BindView(R.id.rcvKetQuaGiaiQuyetPThuLy)
RecyclerView rcvKetQuaGiaiQuyetPThuLy;
@BindView(R.id.rcvTrinhTuHoanThanhCV)
RecyclerView rcvTrinhTuHoanThanhCV;
@BindView(R.id.rcvKetQuaGiaiQuyetPPH)
RecyclerView rcvKetQuaGiaiQuyetPPH;
@BindView(R.id.lnThongTinVanBan)
LinearLayout lnThongTinVanBan;
@BindView(R.id.lnTrinhTuGiaiQuyet)
LinearLayout lnTrinhTuGiaiQuyet;
@BindView(R.id.lnTepDinhKem)
LinearLayout lnTepDinhKem;
@BindView(R.id.lnTruyenNhanLuuViet)
LinearLayout lnTruyenNhanLuuViet;
@BindView(R.id.lnKetQuaGiaiQuyetPThuLy)
LinearLayout lnKetQuaGiaiQuyetPThuLy;
@BindView(R.id.lnTrinhTuHoanThanhCV)
LinearLayout lnTrinhTuHoanThanhCV;
@BindView(R.id.lnKetQuaGiaiQuyetPPH)
LinearLayout lnKetQuaGiaiQuyetPPH;
@BindView(R.id.tvHopVaoHoi)
TextView tvHopVaoHoi;
@BindView(R.id.tvPhongGiamDoc)
TextView tvPhongGiamDoc;
@BindView(R.id.tvNoiDung)
TextView tvNoiDung;
@BindView(R.id.tvSoDen)
TextView tvSoDen;
@BindView(R.id.tvKhuVuc)
TextView tvKhuVuc;
@BindView(R.id.tvSoKyHieu)
TextView tvSoKyHieu;
@BindView(R.id.tvLoaiVanBan)
TextView tvLoaiVanBan;
@BindView(R.id.tvTrichYeu)
TextView tvTrichYeu;
@BindView(R.id.tvNguoiKy)
TextView tvNguoiKy;
@BindView(R.id.tvNgayNhan)
TextView tvNgayNhan;
@BindView(R.id.tvSoTrang)
TextView tvSoTrang;
@BindView(R.id.tvDoMat)
TextView tvDoMat;
@BindView(R.id.tvNoiGuiDen)
TextView tvNoiGuiDen;
@BindView(R.id.tvNgayKy)
TextView tvNgayKy;
@BindView(R.id.tvChucVu)
TextView tvChucVu;
@BindView(R.id.tvHanGiaiQuyet)
TextView tvHanGiaiQuyet;
@BindView(R.id.tvDoKhan)
TextView tvDoKhan;
@BindView(R.id.edtKetQuaGiaiQuyet)
TextView edtKetQuaGiaiQuyet;
@BindView(R.id.btnCVDaHoanThanh)
Button btnCVDaHoanThanh;
@BindView(R.id.rlTrinhTuGiaiQuyet)
RelativeLayout rlTrinhTuGiaiQuyet;
@BindView(R.id.rlTepDinhKem)
RelativeLayout rlTepDinhKem;
@BindView(R.id.rlTrinhTuTruyenNhanLuuVet)
RelativeLayout rlTrinhTuTruyenNhanLuuVet;
@BindView(R.id.rlKetQuaGiaiQuyetPhongPhoiHop)
RelativeLayout rlKetQuaGiaiQuyetPhongPhoiHop;
@BindView(R.id.rlKetQuaGiaiQuyetPhongThuLy)
RelativeLayout rlKetQuaGiaiQuyetPhongThuLy;
@BindView(R.id.rlTrinhTuHoanThanhCongViec)
RelativeLayout rlTrinhTuHoanThanhCongViec;
AdapterTrinhTuGiaiQuyetPhoiHopTraLai adapterTrinhTuGiaiQuyetPhoiHopTraLai;
AdapterTepTinDinhKemPhongPH adapterTepTinDinhKemPhongPH;
AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet;
AdapterKetQuaGiaiQuyetPhongTL adapterKetQuaGiaiQuyetPhongTL;
AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet;
AdapterKetQuaGiaiQuyetPhongPH adapterKetQuaGiaiQuyetPhongPH;
int id;
@Override
public int getContentViewId() {
return R.layout.activity_thong_tin_giay_moi_da_xu_ly;
}
@Override
public void initializeComponents() {
ButterKnife.bind(this);
Util.checkConnection(this);
Intent intent = getIntent();
if (intent != null) {
if (intent.hasExtra("idvb")) {
id = intent.getIntExtra("idvb", 0);
getPresenter().getDetailGMChuyenVienChuTriXuLy(id);
}
}
}
@Override
public Context gContext() {
return this;
}
@Override
public void onGetDaTaSuccess(DetailGiayMoiPhongChuTriChoXuLy detailGiayMoiPhongChuTriChoXuLy) {
RecyclerViewTrinhTuGiaiQuyetGiayMoi((ArrayList<TrinhTuGiaiQuyetPhoiHopTraLai>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuGiaiQuyets());
RecyclerViewTrinhTuChuyenNhanLuuVet((ArrayList<TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuChuyenNhanLuuVets());
RecyclerViewTepTinDinhKem((ArrayList<TepTinDinhKemPPH>) detailGiayMoiPhongChuTriChoXuLy.getTepTinDinhKems());
RecyclerViewKetQuaGiaiQuyetPhongThuLy((ArrayList<KetQuaGiaiQuyetPhongTL>) detailGiayMoiPhongChuTriChoXuLy.getKetQuaGiaiQuyetPhongTLs());
RecyclerViewTrinhTuHoanThanhLuuVet((ArrayList<TrinhTuHoanThanhCVLuuVet>) detailGiayMoiPhongChuTriChoXuLy.getTrinhTuHoanThanhCVLuuVets());
RecyclerViewKetQuaGiaiQuyetPhongPH((ArrayList<KetQuaGiaiQuyetPhongPP>) detailGiayMoiPhongChuTriChoXuLy.getketQuaGiaiQuyetPhongPHs());
tvHopVaoHoi.setText(detailGiayMoiPhongChuTriChoXuLy.getGiayMoiGio() + " - " + detailGiayMoiPhongChuTriChoXuLy.getGiayMoiNgay());
tvPhongGiamDoc.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getGiayMoiDiaDiem()));
tvNoiDung.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNoiDung()));
tvSoDen.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoDen()));
tvKhuVuc.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getKhuVuc()));
tvSoKyHieu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoKyHieu()));
tvLoaiVanBan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getLoaiVanBan()));
tvTrichYeu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getMoTa()));
tvNguoiKy.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getTenNguoiKy()));
tvNgayNhan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNgayNhan()));
tvSoTrang.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getSoTrang()));
tvDoMat.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getDoMat()));
tvNoiGuiDen.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNoiGuiDen()));
tvNgayKy.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getNgayKy()));
tvChucVu.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getChucVu()));
tvHanGiaiQuyet.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getHanGiaiQuyet()));
tvDoKhan.setText(String.valueOf(detailGiayMoiPhongChuTriChoXuLy.getDoKhan()));
if (detailGiayMoiPhongChuTriChoXuLy.getVBQPPL() == 1) {
cbVBQPPL.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getSTCCT() == 1) {
cbSTCChuTri.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTBKL() == 1) {
cbTBKL.setChecked(true);
}
if (detailGiayMoiPhongChuTriChoXuLy.getShowfromHoanThanh()) {
btnCVDaHoanThanh.setVisibility(View.VISIBLE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuGiaiQuyets().size() == 0) {
rlTrinhTuGiaiQuyet.setVisibility(View.GONE);
lnTrinhTuGiaiQuyet.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTepTinDinhKems().size() == 0) {
rlTepDinhKem.setVisibility(View.GONE);
lnTepDinhKem.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuChuyenNhanLuuVets().size() == 0) {
rlTrinhTuTruyenNhanLuuVet.setVisibility(View.GONE);
lnTruyenNhanLuuViet.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getketQuaGiaiQuyetPhongPHs().size() == 0) {
rlKetQuaGiaiQuyetPhongPhoiHop.setVisibility(View.GONE);
lnKetQuaGiaiQuyetPPH.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getKetQuaGiaiQuyetPhongTLs().size() == 0) {
rlKetQuaGiaiQuyetPhongThuLy.setVisibility(View.GONE);
lnKetQuaGiaiQuyetPThuLy.setVisibility(View.GONE);
}
if (detailGiayMoiPhongChuTriChoXuLy.getTrinhTuHoanThanhCVLuuVets().size() == 0) {
rlTrinhTuHoanThanhCongViec.setVisibility(View.GONE);
lnTrinhTuHoanThanhCV.setVisibility(View.GONE);
}
}
@Override
public void hoanThanhGMChuyenVienChuTriXuLySuccess() {
Toast.makeText(this, "Xong", Toast.LENGTH_SHORT).show();
finish();
}
@Override
public void xoaKQPhongTLSuccess() {
Toast.makeText(this, "Xong", Toast.LENGTH_SHORT).show();
getPresenter().getDetailGMChuyenVienChuTriXuLy(id);
}
@Override
public TTVBGiayMoiPhongChuTriChoXuLyPresenter createPresenter() {
return new TTVBGiayMoiPhongChuTriChoXuLyPresenterImpl(this);
}
@OnClick({R.id.imvBack, R.id.tvThongTinVanBan, R.id.lnTTVB,
R.id.tvTrinhTuGiaiQuyet, R.id.tvTepDinhKem,
R.id.tvTruyenNhanLuuVet,
R.id.tvKetQuaGiaiQuyetPThuLy, R.id.tvTrinhTuHoanThanhCV, R.id.btnSoanBaoCao, R.id.btnCVDaHoanThanh, R.id.tvKetQuaGiaiQuyetPPH})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.imvBack:
finish();
break;
case R.id.tvThongTinVanBan:
Expand(lnThongTinVanBan, imUpThongTinVanBan, imDownThongTinVanBan);
break;
case R.id.tvTrinhTuGiaiQuyet:
Expand(lnTrinhTuGiaiQuyet, imUpTrinhTuGiaiQuyet, imDownTrinhTuGiaiQuyet);
break;
case R.id.tvTepDinhKem:
Expand(lnTepDinhKem, imUpTepDinhKem, imDownTepDinhKem);
break;
case R.id.tvTruyenNhanLuuVet:
Expand(lnTruyenNhanLuuViet, imUpTruyenNhanLuuViet, imDownTruyenNhanLuuViet);
break;
case R.id.tvKetQuaGiaiQuyetPThuLy:
Expand(lnKetQuaGiaiQuyetPThuLy, imUpKetQuaGiaiQuyetPThuLy, imDownKetQuaGiaiQuyetPThuLy);
break;
case R.id.tvTrinhTuHoanThanhCV:
Expand(lnTrinhTuHoanThanhCV, imUpTrinhTuHoanThanhCV, imDownTrinhTuHoanThanhCV);
break;
case R.id.tvKetQuaGiaiQuyetPPH:
Expand(lnKetQuaGiaiQuyetPPH, imUpKetQuaGiaiQuyetPPH, imDownKetQuaGiaiQuyetPPH);
break;
case R.id.btnSoanBaoCao:
// Intent intent = new Intent(this, SoanBaoCaoActivity.class);
// intent.putExtra("ID_GIAYMOI_CHO_LANHDAO_XULY", id);
// startActivity(intent);
Util.showMessenger("Chức năng đang hoàn thiện", this);
break;
case R.id.btnCVDaHoanThanh:
getPresenter().hoanThanhGMChuyenVienChuTriXuLy(id, edtKetQuaGiaiQuyet.getText().toString(), "");
break;
case R.id.lnTTVB:
closeKeyboard();
break;
}
}
void Expand(LinearLayout linearLayout, ImageView imgGone, ImageView imgVisible) {
if (linearLayout.getVisibility() == View.GONE) {
imgGone.setVisibility(View.VISIBLE);
linearLayout.setVisibility(View.VISIBLE);
imgVisible.setVisibility(View.GONE);
} else {
linearLayout.setVisibility(View.GONE);
imgGone.setVisibility(View.GONE);
imgVisible.setVisibility(View.VISIBLE);
}
}
void RecyclerViewTrinhTuGiaiQuyetGiayMoi(ArrayList<TrinhTuGiaiQuyetPhoiHopTraLai> trinhTuGiaiQuyets) {
adapterTrinhTuGiaiQuyetPhoiHopTraLai = new AdapterTrinhTuGiaiQuyetPhoiHopTraLai(trinhTuGiaiQuyets);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTGQTTVB.setLayoutManager(layoutManager);
rcvTTGQTTVB.setAdapter(adapterTrinhTuGiaiQuyetPhoiHopTraLai);
adapterTrinhTuGiaiQuyetPhoiHopTraLai.notifyDataSetChanged();
}
void RecyclerViewTrinhTuChuyenNhanLuuVet(ArrayList<TrinhTuChuyenNhanLuuVetChoLanhDaoPhongPheDuyet> trinhTuChuyenNhanLuuVets) {
adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet = new AdapterTrinhTuChuyenNhanLuuVetPhongPheDuyet(trinhTuChuyenNhanLuuVets);
LinearLayoutManager layoutManagerTrinhTuChuyenNhanLuuVet = new LinearLayoutManager(this);
layoutManagerTrinhTuChuyenNhanLuuVet.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTTNLVTTVB.setLayoutManager(layoutManagerTrinhTuChuyenNhanLuuVet);
rcvTTTNLVTTVB.setAdapter(adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet);
adapterTrinhTuChuyenNhanLuuVetPhongPheDuyet.notifyDataSetChanged();
}
void RecyclerViewTrinhTuHoanThanhLuuVet(ArrayList<TrinhTuHoanThanhCVLuuVet> trinhTuGiaiQuyetPhongPhoiHops) {
adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet = new AdapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet(trinhTuGiaiQuyetPhongPhoiHops);
LinearLayoutManager layoutManagerTrinhTuGiaiQuyetPhongPhoiHop = new LinearLayoutManager(this);
layoutManagerTrinhTuGiaiQuyetPhongPhoiHop.setOrientation(LinearLayoutManager.VERTICAL);
rcvTrinhTuHoanThanhCV.setLayoutManager(layoutManagerTrinhTuGiaiQuyetPhongPhoiHop);
rcvTrinhTuHoanThanhCV.setAdapter(adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet);
adapterTrinhTuHoanThanhLuuVetChoPhongPheDuyet.notifyDataSetChanged();
}
void RecyclerViewKetQuaGiaiQuyetPhongThuLy(ArrayList<KetQuaGiaiQuyetPhongTL> ketquaGiaiquyetPhongThulies) {
adapterKetQuaGiaiQuyetPhongTL = new AdapterKetQuaGiaiQuyetPhongTL(ketquaGiaiquyetPhongThulies, this);
LinearLayoutManager layoutManagerTrinhTuGiaiQuyetPhongPhoiHop = new LinearLayoutManager(this);
layoutManagerTrinhTuGiaiQuyetPhongPhoiHop.setOrientation(LinearLayoutManager.VERTICAL);
rcvKetQuaGiaiQuyetPThuLy.setLayoutManager(layoutManagerTrinhTuGiaiQuyetPhongPhoiHop);
rcvKetQuaGiaiQuyetPThuLy.setAdapter(adapterKetQuaGiaiQuyetPhongTL);
adapterKetQuaGiaiQuyetPhongTL.notifyDataSetChanged();
}
void RecyclerViewTepTinDinhKem(ArrayList<TepTinDinhKemPPH> tepDinhKems) {
adapterTepTinDinhKemPhongPH = new AdapterTepTinDinhKemPhongPH(tepDinhKems, this);
LinearLayoutManager layoutManagerTepTinDinhKem = new LinearLayoutManager(this);
layoutManagerTepTinDinhKem.setOrientation(LinearLayoutManager.VERTICAL);
rcvTTDKTTVB.setLayoutManager(layoutManagerTepTinDinhKem);
rcvTTDKTTVB.setAdapter(adapterTepTinDinhKemPhongPH);
adapterTepTinDinhKemPhongPH.notifyDataSetChanged();
}
void RecyclerViewKetQuaGiaiQuyetPhongPH(ArrayList<KetQuaGiaiQuyetPhongPP> ketQuaGiaiQuyetPhongPPArrayList) {
adapterKetQuaGiaiQuyetPhongPH = new AdapterKetQuaGiaiQuyetPhongPH(ketQuaGiaiQuyetPhongPPArrayList, this);
LinearLayoutManager layoutManagerTepTinDinhKem = new LinearLayoutManager(this);
layoutManagerTepTinDinhKem.setOrientation(LinearLayoutManager.VERTICAL);
rcvKetQuaGiaiQuyetPPH.setLayoutManager(layoutManagerTepTinDinhKem);
rcvKetQuaGiaiQuyetPPH.setAdapter(adapterKetQuaGiaiQuyetPhongPH);
adapterKetQuaGiaiQuyetPhongPH.notifyDataSetChanged();
}
@Override
public void onItemClick(TepTinDinhKemPPH tepTinDinhKemPPH) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(tepTinDinhKemPPH.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onItemketquaGiaiquyetPhongThulyClick(KetQuaGiaiQuyetPhongTL ketquaGiaiquyetPhongThuly) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(ketquaGiaiquyetPhongThuly.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onItemTacVuClick(KetQuaGiaiQuyetPhongTL ketquaGiaiquyetPhongThuly) {
getPresenter().xoaKQPhongTL(ketquaGiaiquyetPhongThuly.getId());
}
@Override
public void onItemketquaGiaiquyetClick(KetQuaGiaiQuyetPhongPP ketquaGiaiquyetPhongPhoihop) {
try {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(ketquaGiaiquyetPhongPhoihop.getUrlFile()));
startActivity(browserIntent);
} catch (Exception e) {
Toast.makeText(this, "Lỗi hệ thống!!!", Toast.LENGTH_SHORT).show();
}
}
private void closeKeyboard() {
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}
| 20,023 | 0.745725 | 0.745075 | 445 | 43.939327 | 34.061852 | 167 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.635955 | false | false | 8 |
bfe1ccb97361cbd094e02e7b232b0542820f3e5a | 23,888,608,108,720 | ab5c17f9fdcbeb9ad33b58640d0eb60fc519eec3 | /app/src/main/java/com/taurus/moviedbmvvm/core/di/ActivityBuilderModule.java | 09a743fd719ce27d0e3f4486482417625f926f73 | [] | no_license | eminuluyol/NewArchitectureComponents | https://github.com/eminuluyol/NewArchitectureComponents | 71f1869137c1b5ec5dc4cd401d67177a105885e0 | 808fbafaa96ed805ab3e6475f02000f1aa2aa958 | refs/heads/master | 2021-01-21T14:11:40.630000 | 2017-06-26T14:10:39 | 2017-06-26T14:10:39 | 95,428,206 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.taurus.moviedbmvvm.core.di;
import com.taurus.moviedbmvvm.moviedetail.MovieDetailActivity;
import com.taurus.moviedbmvvm.movielist.MovieListActivity;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
@Module
public abstract class ActivityBuilderModule {
@ContributesAndroidInjector(modules = FragmentBuilderModule.class)
abstract MovieListActivity mainActivity();
@ContributesAndroidInjector
abstract MovieDetailActivity movieDetailActivity();
}
| UTF-8 | Java | 503 | java | ActivityBuilderModule.java | Java | [] | null | [] | package com.taurus.moviedbmvvm.core.di;
import com.taurus.moviedbmvvm.moviedetail.MovieDetailActivity;
import com.taurus.moviedbmvvm.movielist.MovieListActivity;
import dagger.Module;
import dagger.android.ContributesAndroidInjector;
@Module
public abstract class ActivityBuilderModule {
@ContributesAndroidInjector(modules = FragmentBuilderModule.class)
abstract MovieListActivity mainActivity();
@ContributesAndroidInjector
abstract MovieDetailActivity movieDetailActivity();
}
| 503 | 0.831014 | 0.831014 | 19 | 25.473684 | 25.462807 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.368421 | false | false | 8 |
84a7a7e669edcd1438406ec08e995e48ea22d1dc | 19,207,093,788,883 | 8c2a4e7fe7eb53c50cc0a6c1ef78bbce897a50a3 | /src/main/java/coding/challenges/codewar/TimeFormatter.java | badb0425992c6374118e1194616a9f251b674d8c | [] | no_license | ibrahimqandeel/coding-practice | https://github.com/ibrahimqandeel/coding-practice | ee47118cfd57942b2f5e84c6e195cd7b7baddea2 | a537878300853cbbcaf6aaade0482a994c534809 | refs/heads/master | 2023-07-30T15:14:02.986000 | 2021-10-08T13:14:14 | 2021-10-08T13:14:14 | 371,367,924 | 0 | 0 | null | false | 2021-05-27T14:02:11 | 2021-05-27T12:37:01 | 2021-05-27T13:52:22 | 2021-05-27T14:02:10 | 75 | 0 | 0 | 0 | Java | false | false | package coding.challenges.codewar;
/*
* @link https://www.codewars.com/kata/52742f58faf5485cae000b9a
*/
public class TimeFormatter {
public static String formatDuration(int seconds) {
// your code goes here
int secInYear = 31536000;
int secInDay = 86400;
int secInHour = 3600;
int secInMinute = 60;
String output = "";
if (seconds < 1) {
return "now";
}
int yearAsSeconds = getDurationAsSeconds(seconds, secInYear);
int years = yearAsSeconds / secInYear;
output = buildOutput(years, "year");
seconds = getRemainingSeconds(seconds, yearAsSeconds);
int dayAsSeconds = getDurationAsSeconds(seconds, secInDay);
int days = dayAsSeconds / secInDay;
output += output.isEmpty() ? buildOutput(days, "day") : days > 0 ? ", " + buildOutput(days, "day") : "";
seconds = getRemainingSeconds(seconds, dayAsSeconds);
int hourAsSeconds = getDurationAsSeconds(seconds, secInHour);
int hours = hourAsSeconds / secInHour;
output += output.isEmpty() ? buildOutput(hours, "hour") : hours > 0 ? ", " + buildOutput(hours, "hour") : "";
seconds = getRemainingSeconds(seconds, hourAsSeconds);
int minuteAsSeconds = getDurationAsSeconds(seconds, secInMinute);
int minute = minuteAsSeconds / secInMinute;
output += output.isEmpty() ? buildOutput(minute, "minute")
: minute > 0 ? ", " + buildOutput(minute, "minute") : "";
seconds = getRemainingSeconds(seconds, minuteAsSeconds);
output += output.isEmpty() ? buildOutput(seconds, "second")
: seconds > 0 ? ", " + buildOutput(seconds, "second") : "";
int lastIndexOfComma = output.lastIndexOf(',');
if (lastIndexOfComma >= 0) {
output = output.substring(0, output.lastIndexOf(',')) + " and" + output.substring(lastIndexOfComma + 1);
}
return output;
}
private static int getDurationAsSeconds(int seconds, int secInDuration) {
int remainSeconds = seconds % secInDuration;
if (remainSeconds == 0) {
return seconds;
}
return Math.abs(seconds - remainSeconds);
}
private static int getRemainingSeconds(int seconds, int durationAsSeconds) {
if (seconds == durationAsSeconds) {
return 0;
}
return Math.abs(seconds - durationAsSeconds);
}
private static String buildOutput(int number, String period) {
String output = "";
if (number > 0 && number < 2) {
output = number + " " + period;
} else if (number > 1) {
output = number + " " + period + "s";
}
return output;
}
public static String cleverFormatDuration(int seconds) {
String res = "";
int[] units = new int[] { 31536000, 86400, 3600, 60, 1 };
String[] labels = new String[] { "year", "day", "hour", "minute", "second" };
if (seconds == 0)
return "now";
for (int i = 0; i < 5; i++) {
if (seconds >= units[i]) {
int q = seconds / units[i];
seconds = seconds % units[i];
res += (res.equals("") ? "" : (seconds == 0 ? " and " : ", ")) + q + " " + labels[i]
+ (q > 1 ? "s" : "");
}
}
return res;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
| UTF-8 | Java | 3,026 | java | TimeFormatter.java | Java | [] | null | [] | package coding.challenges.codewar;
/*
* @link https://www.codewars.com/kata/52742f58faf5485cae000b9a
*/
public class TimeFormatter {
public static String formatDuration(int seconds) {
// your code goes here
int secInYear = 31536000;
int secInDay = 86400;
int secInHour = 3600;
int secInMinute = 60;
String output = "";
if (seconds < 1) {
return "now";
}
int yearAsSeconds = getDurationAsSeconds(seconds, secInYear);
int years = yearAsSeconds / secInYear;
output = buildOutput(years, "year");
seconds = getRemainingSeconds(seconds, yearAsSeconds);
int dayAsSeconds = getDurationAsSeconds(seconds, secInDay);
int days = dayAsSeconds / secInDay;
output += output.isEmpty() ? buildOutput(days, "day") : days > 0 ? ", " + buildOutput(days, "day") : "";
seconds = getRemainingSeconds(seconds, dayAsSeconds);
int hourAsSeconds = getDurationAsSeconds(seconds, secInHour);
int hours = hourAsSeconds / secInHour;
output += output.isEmpty() ? buildOutput(hours, "hour") : hours > 0 ? ", " + buildOutput(hours, "hour") : "";
seconds = getRemainingSeconds(seconds, hourAsSeconds);
int minuteAsSeconds = getDurationAsSeconds(seconds, secInMinute);
int minute = minuteAsSeconds / secInMinute;
output += output.isEmpty() ? buildOutput(minute, "minute")
: minute > 0 ? ", " + buildOutput(minute, "minute") : "";
seconds = getRemainingSeconds(seconds, minuteAsSeconds);
output += output.isEmpty() ? buildOutput(seconds, "second")
: seconds > 0 ? ", " + buildOutput(seconds, "second") : "";
int lastIndexOfComma = output.lastIndexOf(',');
if (lastIndexOfComma >= 0) {
output = output.substring(0, output.lastIndexOf(',')) + " and" + output.substring(lastIndexOfComma + 1);
}
return output;
}
private static int getDurationAsSeconds(int seconds, int secInDuration) {
int remainSeconds = seconds % secInDuration;
if (remainSeconds == 0) {
return seconds;
}
return Math.abs(seconds - remainSeconds);
}
private static int getRemainingSeconds(int seconds, int durationAsSeconds) {
if (seconds == durationAsSeconds) {
return 0;
}
return Math.abs(seconds - durationAsSeconds);
}
private static String buildOutput(int number, String period) {
String output = "";
if (number > 0 && number < 2) {
output = number + " " + period;
} else if (number > 1) {
output = number + " " + period + "s";
}
return output;
}
public static String cleverFormatDuration(int seconds) {
String res = "";
int[] units = new int[] { 31536000, 86400, 3600, 60, 1 };
String[] labels = new String[] { "year", "day", "hour", "minute", "second" };
if (seconds == 0)
return "now";
for (int i = 0; i < 5; i++) {
if (seconds >= units[i]) {
int q = seconds / units[i];
seconds = seconds % units[i];
res += (res.equals("") ? "" : (seconds == 0 ? " and " : ", ")) + q + " " + labels[i]
+ (q > 1 ? "s" : "");
}
}
return res;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
| 3,026 | 0.651355 | 0.627561 | 99 | 29.565657 | 27.561562 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.474747 | false | false | 8 |
89281caafa63406f285275fedd611fb5d4fddfb7 | 32,547,262,229,700 | 22ca095ac2b4cae31645318e66864e162ef15323 | /Cossystem/src/main/java/com/cossystem/managedbean/PrincipalBean.java | 145adfc6a8e22b0a3d221cb30f276c77743e65ac | [] | no_license | jkarlos1402/CossystemMaven | https://github.com/jkarlos1402/CossystemMaven | 89f7dc6414721ca6d0be07dc04a2b0c28b252eba | 4a282074019a97c552c751dcac32171be59bbb8e | refs/heads/master | 2021-08-23T23:47:56.910000 | 2017-12-07T04:00:09 | 2017-12-07T04:00:09 | 112,812,173 | 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 com.cossystem.managedbean;
import com.cossystem.core.pojos.TblAccesoPantallas;
import com.cossystem.core.pojos.CatUsuarios;
import java.io.File;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.primefaces.context.RequestContext;
/**
*
* @author JC
*/
@ManagedBean
@ViewScoped
public class PrincipalBean implements Serializable {
private CatUsuarios usuarioSesion;
private List<TblAccesoPantallas> menuCompleto;
/**
* Creates a new instance of PrincipalBean
*/
public PrincipalBean() {
HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
usuarioSesion = (CatUsuarios) httpSession.getAttribute("session_user");
menuCompleto = (List<TblAccesoPantallas>) httpSession.getAttribute("accesoPantallas");
}
public CatUsuarios getUsuarioSesion() {
return usuarioSesion;
}
public void setUsuarioSesion(CatUsuarios usuarioSesion) {
this.usuarioSesion = usuarioSesion;
}
public void resetFormulario(String nombreFormulario) {
RequestContext.getCurrentInstance().reset(nombreFormulario);
}
public List<TblAccesoPantallas> getMenuCompleto() {
return menuCompleto;
}
public void setMenuCompleto(List<TblAccesoPantallas> menuCompleto) {
this.menuCompleto = menuCompleto;
}
}
| UTF-8 | Java | 1,795 | java | PrincipalBean.java | Java | [
{
"context": "ces.context.RequestContext;\r\n\r\n/**\r\n *\r\n * @author JC\r\n */\r\n@ManagedBean\r\n@ViewScoped\r\npublic class Pri",
"end": 631,
"score": 0.9918814897537231,
"start": 629,
"tag": "USERNAME",
"value": "JC"
}
] | 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 com.cossystem.managedbean;
import com.cossystem.core.pojos.TblAccesoPantallas;
import com.cossystem.core.pojos.CatUsuarios;
import java.io.File;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import org.primefaces.context.RequestContext;
/**
*
* @author JC
*/
@ManagedBean
@ViewScoped
public class PrincipalBean implements Serializable {
private CatUsuarios usuarioSesion;
private List<TblAccesoPantallas> menuCompleto;
/**
* Creates a new instance of PrincipalBean
*/
public PrincipalBean() {
HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
usuarioSesion = (CatUsuarios) httpSession.getAttribute("session_user");
menuCompleto = (List<TblAccesoPantallas>) httpSession.getAttribute("accesoPantallas");
}
public CatUsuarios getUsuarioSesion() {
return usuarioSesion;
}
public void setUsuarioSesion(CatUsuarios usuarioSesion) {
this.usuarioSesion = usuarioSesion;
}
public void resetFormulario(String nombreFormulario) {
RequestContext.getCurrentInstance().reset(nombreFormulario);
}
public List<TblAccesoPantallas> getMenuCompleto() {
return menuCompleto;
}
public void setMenuCompleto(List<TblAccesoPantallas> menuCompleto) {
this.menuCompleto = menuCompleto;
}
}
| 1,795 | 0.714763 | 0.714763 | 58 | 28.948277 | 27.734221 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413793 | false | false | 8 |
357160e740b0ba74dfc81ba5c870e77aaa3ab071 | 13,958,643,775,632 | 8c4e534e86b0ffcea1db03698c37c5c62d5874d4 | /StringRepeat/src/Conditional/Example15.java | bea5d9e03df9f45f57f31a6c2e836f9247cd7892 | [] | no_license | aaaleksandra1303/JavaRepeat | https://github.com/aaaleksandra1303/JavaRepeat | e5c87717ea515377598a3772c03b4a85b75aa3b4 | 9011248e2f9e75592e45a39e23fa1c31128f865d | refs/heads/master | 2021-01-21T16:15:50.852000 | 2017-05-31T20:38:37 | 2017-05-31T20:38:37 | 91,881,796 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Conditional;
import java.util.Scanner;
public class Example15 {
public static void main(String[] args) {
// sprawdz czy podane imie jest zenskie czy meskie
Scanner sc= new Scanner(System.in);
System.out.println("Enter your name");
String name=sc.next();
name=name.toLowerCase();
if(name.endsWith("a")){
System.out.println("it's a womens name");
}else{
System.out.println("it's a mens name");
}
sc.close();
}
}
| UTF-8 | Java | 472 | java | Example15.java | Java | [] | null | [] | package Conditional;
import java.util.Scanner;
public class Example15 {
public static void main(String[] args) {
// sprawdz czy podane imie jest zenskie czy meskie
Scanner sc= new Scanner(System.in);
System.out.println("Enter your name");
String name=sc.next();
name=name.toLowerCase();
if(name.endsWith("a")){
System.out.println("it's a womens name");
}else{
System.out.println("it's a mens name");
}
sc.close();
}
}
| 472 | 0.644068 | 0.639831 | 28 | 15.857142 | 16.668436 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.857143 | false | false | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.