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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ec00de99ca3aca5914b34c85ac12ba74f6fc182b
| 32,744,830,735,031
|
ec551865c1ed63e36b9ea5f439e8dc6c20834eec
|
/arena-fx/src/controller/ArenaWebBridge.java
|
8e4d1abb7f29af30d5521a81fa55ca2e398e4c37
|
[] |
no_license
|
abegaz/arenaSB
|
https://github.com/abegaz/arenaSB
|
1db3875b692201f9be96778ba2e56ba86e159542
|
8a8f5f3cf78ef2129785aeb81b814fe4cbeb77cc
|
refs/heads/master
| 2021-01-20T02:39:00.973000
| 2017-11-30T17:29:52
| 2017-11-30T17:29:52
| 101,328,619
| 4
| 3
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package controller;
import org.apache.commons.codec.digest.DigestUtils;
import model.DatabaseConnection;
import static org.apache.commons.codec.digest.MessageDigestAlgorithms.SHA_256;
import java.net.URL;
import java.time.LocalTime;
import application.Main;
import javafx.application.Platform;
public class ArenaWebBridge{
DatabaseConnection db = new DatabaseConnection("jdbc:mysql://67.205.191.64/arena","root", "arenasb");
public ArenaWebBridge() {
System.out.println(LocalTime.now() + " Starting ArenaWebBridge");
}
public void createUser(String username, String email, String password) {
System.out.println(LocalTime.now() + " Creating user "+username);
String hashPassword = new DigestUtils(SHA_256).digestAsHex(password);
db.createUser(username, email, hashPassword);
// Gets boolean value to see if the user should be redirected after successful sign up.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Platform.runLater(Main.runRedirect);
/*
Runnable r = () -> {
if(createUser != false) {
URL url = this.getClass().getResource("../view/directory.html");
Main.engine.load(url.toString());
}
};
Thread t = new Thread(r);
t.start();
*/
}
public void loginUser(String username, String password) {
String hashPassword = new DigestUtils(SHA_256).digestAsHex(password);
db.loginUser(username, hashPassword);
}
public void createTeam(String name, String ownerName) {
System.out.println("Team: " +name +"\tOwner name: " + ownerName);
db.createTeam(name, ownerName);
}
public void createGame(String name) {
System.out.println("Game name: " + name);
db.createGame(name);
}
public void createLeague(String name) {
System.out.println("League name: " + name);
db.createLeague(name);
}
public void createTournament(String trnname, String leagueName) {
System.out.println("Tournament name: " + trnname +"\nleague id: " + leagueName);
db.createTournament(trnname, leagueName);
}
}
|
UTF-8
|
Java
| 2,067
|
java
|
ArenaWebBridge.java
|
Java
|
[
{
"context": "nection db = new DatabaseConnection(\"jdbc:mysql://67.205.191.64/arena\",\"root\", \"arenasb\");\n\tpublic ArenaWebBridge",
"end": 405,
"score": 0.9956955313682556,
"start": 392,
"tag": "IP_ADDRESS",
"value": "67.205.191.64"
}
] | null |
[] |
package controller;
import org.apache.commons.codec.digest.DigestUtils;
import model.DatabaseConnection;
import static org.apache.commons.codec.digest.MessageDigestAlgorithms.SHA_256;
import java.net.URL;
import java.time.LocalTime;
import application.Main;
import javafx.application.Platform;
public class ArenaWebBridge{
DatabaseConnection db = new DatabaseConnection("jdbc:mysql://192.168.127.12/arena","root", "arenasb");
public ArenaWebBridge() {
System.out.println(LocalTime.now() + " Starting ArenaWebBridge");
}
public void createUser(String username, String email, String password) {
System.out.println(LocalTime.now() + " Creating user "+username);
String hashPassword = new DigestUtils(SHA_256).digestAsHex(password);
db.createUser(username, email, hashPassword);
// Gets boolean value to see if the user should be redirected after successful sign up.
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Platform.runLater(Main.runRedirect);
/*
Runnable r = () -> {
if(createUser != false) {
URL url = this.getClass().getResource("../view/directory.html");
Main.engine.load(url.toString());
}
};
Thread t = new Thread(r);
t.start();
*/
}
public void loginUser(String username, String password) {
String hashPassword = new DigestUtils(SHA_256).digestAsHex(password);
db.loginUser(username, hashPassword);
}
public void createTeam(String name, String ownerName) {
System.out.println("Team: " +name +"\tOwner name: " + ownerName);
db.createTeam(name, ownerName);
}
public void createGame(String name) {
System.out.println("Game name: " + name);
db.createGame(name);
}
public void createLeague(String name) {
System.out.println("League name: " + name);
db.createLeague(name);
}
public void createTournament(String trnname, String leagueName) {
System.out.println("Tournament name: " + trnname +"\nleague id: " + leagueName);
db.createTournament(trnname, leagueName);
}
}
| 2,068
| 0.714078
| 0.702951
| 68
| 29.397058
| 27.388351
| 102
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.941176
| false
| false
|
13
|
6d97ac5fc4f95cb8ad2cd7f6a8f91a688fc3ae93
| 39,316,130,645,307
|
22277199dc9ab7f68b4ad8c033ccefd5eb6a8c54
|
/bluelist-push-android/src/com/ibm/bluelist/RegisterActivity.java
|
31743585ff85fdf7d8429d258e2e2ef45ded29a8
|
[] |
no_license
|
dakshvar22/Beacons-Messenger
|
https://github.com/dakshvar22/Beacons-Messenger
|
d6b3e9b74f22f70515e15dc431146408e8a4aa3f
|
6e913bd5b0a725fd808f3a61940ab199348820c4
|
refs/heads/master
| 2018-12-29T19:41:16.003000
| 2015-08-19T13:17:10
| 2015-08-19T13:17:10
| 41,034,797
| 0
| 1
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.ibm.bluelist;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.ActionMode;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import com.ibm.mobile.services.cloudcode.IBMCloudCode;
import com.ibm.mobile.services.core.http.IBMHttpResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import bolts.Continuation;
import bolts.Task;
public class RegisterActivity extends Activity {
List<Item> itemList;
BlueListApplication blApplication;
ArrayAdapter<Item> lvArrayAdapter;
ActionMode mActionMode = null;
int listItemPosition;
public static final String CLASS_NAME = "REgisterActivity";
public static Button check;
@Override
/**
* onCreate called when main activity is created.
*
* Sets up the itemList, application, and sets listeners.
*
* @param savedInstanceState
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
/* Use application class to maintain global state. */
blApplication = (BlueListApplication) getApplication();
//itemList = blApplication.getItemList();
/* Set up the array adapter for items list view. */
//ListView itemsLV = (ListView)findViewById(R.id.itemsList);
//lvArrayAdapter = new ArrayAdapter<Item>(this, R.layout.list_item_1, itemList);
//itemsLV.setAdapter(lvArrayAdapter);
/* Refresh the list. */
//listItems();
check = (Button) findViewById(R.id.btnRegister);
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText name = (EditText)findViewById(R.id.name);
EditText email = (EditText)findViewById(R.id.email);
EditText pwd = (EditText)findViewById(R.id.password);
String n = name.getText().toString();
String e = email.getText().toString();
String p = pwd.getText().toString();
final String url = "register?name="+n+"&email="+e+"&pwd="+p;
System.out.println(url);
IBMCloudCode.initializeService();
IBMCloudCode myCloudCodeService = IBMCloudCode.getService();
myCloudCodeService.get(url).continueWith(new Continuation<IBMHttpResponse, Void>() {
@Override
public Void then(Task<IBMHttpResponse> task) throws Exception {
if (task.isCancelled()) {
Log.e(CLASS_NAME, "Exception : Task" + task.isCancelled() + "was cancelled.");
} else if (task.isFaulted()) {
Log.e(CLASS_NAME, "Exception : " + task.getError().getMessage());
} else {
InputStream is = task.getResult().getInputStream();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(is));
String responseString = "";
String myString = "";
while ((myString = in.readLine()) != null)
responseString += myString;
in.close();
Log.i(CLASS_NAME, "Response Body: " + responseString);
} catch (IOException e) {
e.printStackTrace();
}
Log.i(CLASS_NAME, "Response Status from register: " + task.getResult().getHttpResponseCode());
}
return null;
}
});
finish();
}
});
}
}
|
UTF-8
|
Java
| 4,096
|
java
|
RegisterActivity.java
|
Java
|
[] | null |
[] |
package com.ibm.bluelist;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.ActionMode;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import com.ibm.mobile.services.cloudcode.IBMCloudCode;
import com.ibm.mobile.services.core.http.IBMHttpResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import bolts.Continuation;
import bolts.Task;
public class RegisterActivity extends Activity {
List<Item> itemList;
BlueListApplication blApplication;
ArrayAdapter<Item> lvArrayAdapter;
ActionMode mActionMode = null;
int listItemPosition;
public static final String CLASS_NAME = "REgisterActivity";
public static Button check;
@Override
/**
* onCreate called when main activity is created.
*
* Sets up the itemList, application, and sets listeners.
*
* @param savedInstanceState
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
/* Use application class to maintain global state. */
blApplication = (BlueListApplication) getApplication();
//itemList = blApplication.getItemList();
/* Set up the array adapter for items list view. */
//ListView itemsLV = (ListView)findViewById(R.id.itemsList);
//lvArrayAdapter = new ArrayAdapter<Item>(this, R.layout.list_item_1, itemList);
//itemsLV.setAdapter(lvArrayAdapter);
/* Refresh the list. */
//listItems();
check = (Button) findViewById(R.id.btnRegister);
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText name = (EditText)findViewById(R.id.name);
EditText email = (EditText)findViewById(R.id.email);
EditText pwd = (EditText)findViewById(R.id.password);
String n = name.getText().toString();
String e = email.getText().toString();
String p = pwd.getText().toString();
final String url = "register?name="+n+"&email="+e+"&pwd="+p;
System.out.println(url);
IBMCloudCode.initializeService();
IBMCloudCode myCloudCodeService = IBMCloudCode.getService();
myCloudCodeService.get(url).continueWith(new Continuation<IBMHttpResponse, Void>() {
@Override
public Void then(Task<IBMHttpResponse> task) throws Exception {
if (task.isCancelled()) {
Log.e(CLASS_NAME, "Exception : Task" + task.isCancelled() + "was cancelled.");
} else if (task.isFaulted()) {
Log.e(CLASS_NAME, "Exception : " + task.getError().getMessage());
} else {
InputStream is = task.getResult().getInputStream();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(is));
String responseString = "";
String myString = "";
while ((myString = in.readLine()) != null)
responseString += myString;
in.close();
Log.i(CLASS_NAME, "Response Body: " + responseString);
} catch (IOException e) {
e.printStackTrace();
}
Log.i(CLASS_NAME, "Response Status from register: " + task.getResult().getHttpResponseCode());
}
return null;
}
});
finish();
}
});
}
}
| 4,096
| 0.564941
| 0.564697
| 109
| 36.587154
| 28.058659
| 122
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.733945
| false
| false
|
13
|
653553f32471d770424cb3130f016e50539b4d8d
| 36,782,099,959,306
|
9e9e6735e6769acc2f6791d19ea68421fcec7558
|
/src/main/java/com/tangquan/repository/AuthGroupAccessRepository.java
|
35baa02b0390bda801381bf9f9534a332ca7457f
|
[] |
no_license
|
xztzgl/hezu-server
|
https://github.com/xztzgl/hezu-server
|
3a9a3067e05ea27085e8b462ed631fb2b6194c3d
|
ae5a8c8f56194d903676ce5dab08c0df09e7ed13
|
refs/heads/master
| 2020-03-19T11:14:59.535000
| 2018-09-19T14:03:28
| 2018-09-19T14:03:28
| 136,442,458
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.tangquan.repository;
import com.tangquan.model.AuthGroupAccess;
import org.springframework.data.repository.CrudRepository;
/**
* 管理与权限关系操作
* Author: wangfeng
* Date: 17/12/12
* Time: 下午2:46
*/
public interface AuthGroupAccessRepository extends CrudRepository<AuthGroupAccess,Integer> {
}
|
UTF-8
|
Java
| 330
|
java
|
AuthGroupAccessRepository.java
|
Java
|
[
{
"context": "itory.CrudRepository;\n\n/**\n * 管理与权限关系操作\n * Author: wangfeng\n * Date: 17/12/12\n * Time: 下午2:46\n */\npublic inte",
"end": 173,
"score": 0.9994874000549316,
"start": 165,
"tag": "USERNAME",
"value": "wangfeng"
}
] | null |
[] |
package com.tangquan.repository;
import com.tangquan.model.AuthGroupAccess;
import org.springframework.data.repository.CrudRepository;
/**
* 管理与权限关系操作
* Author: wangfeng
* Date: 17/12/12
* Time: 下午2:46
*/
public interface AuthGroupAccessRepository extends CrudRepository<AuthGroupAccess,Integer> {
}
| 330
| 0.785714
| 0.756494
| 14
| 21
| 26.021969
| 92
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.285714
| false
| false
|
13
|
791c7a8790240f3afbe268321d68b015cb8ca644
| 34,909,494,234,443
|
abbf5940dc9df0b7d21a87357f8256e2ef9cdee8
|
/Jvault/src/test/java/org/jvault/vault/ClassVaultTest.java
|
a30f9fc8e538eacdb052069703b76b1ba14d4a00
|
[
"MIT"
] |
permissive
|
devxb/Jvault
|
https://github.com/devxb/Jvault
|
00ecaecd7d89a970496d3a53c2576fbcf19b6736
|
0f607dfa37368c9429218d31934afa7656118b50
|
refs/heads/main
| 2023-03-16T17:16:15.209000
| 2023-03-10T04:19:06
| 2023-03-10T04:19:06
| 559,206,790
| 8
| 0
|
MIT
| false
| 2022-11-16T04:47:56
| 2022-10-29T11:51:44
| 2022-11-15T15:28:30
| 2022-11-16T04:47:55
| 5,866
| 2
| 0
| 0
|
Java
| false
| false
|
package org.jvault.vault;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.jvault.exceptions.DisallowedAccessException;
import org.jvault.factory.TypeVaultFactory;
import org.jvault.factory.buildinfo.AbstractVaultFactoryBuildInfo;
import org.jvault.factory.buildinfo.AnnotationVaultFactoryBuildInfo;
import org.jvault.factory.extensible.Vault;
import org.jvault.factory.extensible.VaultFactoryBuildInfo;
import org.jvault.struct.annotationconfigwithclass.AnnotationConfigWithClass;
import org.jvault.struct.buildvault.BuildVault;
import org.jvault.struct.buildvaultcannotinjectbean.BuildVaultCannotInjectBean;
import org.jvault.struct.buildvaultcannotinjectclass.BuildVaultCannotInjectClass;
import org.jvault.struct.duplicatevault.DuplicateVault;
import org.jvault.struct.genericbean.Generic;
import org.jvault.struct.vaultinjectsingletonbean.AnnotationConfigWithNotScan;
import org.jvault.struct.vaultinjectsingletonbean.AnnotationConfigWithScan;
import org.jvault.struct.vaultinjectsingletonbean.VaultInjectBean;
public class ClassVaultTest {
@Test
public void BUILD_VAULT_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvault.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
public String[] getVaultAccessPackages(){
return new String[]{"org.jvault.struct.buildvault"};
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
BuildVault buildVault = classVault.inject(BuildVault.class);
// then
Assertions.assertEquals("BuildVaultBuildVaultBeanABuildVaultBeanBBuildVaultBeanC", buildVault.imNotBean());
}
@Test
public void BUILD_VAULT_CANNOT_INJECT_CLASS_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvaultcannotinjectclass.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
// then
Assertions.assertThrows(DisallowedAccessException.class, ()-> classVault.inject(BuildVaultCannotInjectClass.class));
}
@Test
public void BUILD_VAULT_CANNOT_INJECT_BEAN_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvaultcannotinjectbean.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
// then
Assertions.assertThrows(DisallowedAccessException.class, ()-> classVault.inject(BuildVaultCannotInjectBean.class));
}
@Test
public void ANNOTATION_CONFIG_WITH_CLASS_CREATE_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.annotationconfigwithclass.AnnotationConfig.class);
// when
ClassVault vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
AnnotationConfigWithClass bean = vault.inject(AnnotationConfigWithClass.class);
// then
Assertions.assertEquals("AnnotationConfigWithClassAnnotationConfigWithClassBean", bean.hello());
}
@Test
public void CHOICE_CONSTRUCTOR_INJECT_CLASS_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.choiceconstructorinject.AnnotationConfig.class);
// then
Assertions.assertThrows(IllegalStateException.class, ()-> vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS));
}
@Test
public void DUPLICATE_VAULT_DETECTED_CLASS_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.AnnotatinConfig.class);
AnnotationVaultFactoryBuildInfo duplicateAnnotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.DuplicatedAnnotationConfig.class);
// when
Vault<Class<?>> vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
ClassVault duplicatedVault = vaultFactory.get(duplicateAnnotationVaultFactoryBuildInfo, VaultType.CLASS);
DuplicateVault duplicateVault = vault.inject(DuplicateVault.class, DuplicateVault.class);
DuplicateVault comparedDuplicatedVault = duplicatedVault.inject(DuplicateVault.class);
// then
Assertions.assertEquals(duplicateVault, comparedDuplicatedVault);
}
@Test
public void DUPLICATE_VAULT_DETECTED_WITH_VAULT_NAME_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.AnnotatinConfig.class);
// when
Vault<Class<?>> vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
ClassVault duplicatedVault = vaultFactory.get("DUPLICATE_VAULT", VaultType.CLASS);
DuplicateVault duplicateVault = vault.inject(DuplicateVault.class, DuplicateVault.class);
DuplicateVault comparedDuplicatedVault = duplicatedVault.inject(DuplicateVault.class);
// then
Assertions.assertEquals(duplicateVault, comparedDuplicatedVault);
}
@Test
public void VAULT_INJECT_SINGLETON_WITH_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(AnnotationConfigWithScan.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
VaultInjectBean vaultInjectBean = vault.inject(VaultInjectBean.class);
VaultInjectBean samePointVaultInjectBean = vault.inject(VaultInjectBean.class);
// then
Assertions.assertEquals(vaultInjectBean, samePointVaultInjectBean);
}
@Test
public void VAULT_INJECT_SINGLETON_WITH_NOT_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(AnnotationConfigWithNotScan.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
VaultInjectBean vaultInjectBean = vault.inject(VaultInjectBean.class);
VaultInjectBean differentPointVaultInjectBean = vault.inject(VaultInjectBean.class);
// then
Assertions.assertNotEquals(vaultInjectBean, differentPointVaultInjectBean);
}
@Test
public void GENERIC_BEAN_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.genericbean.AnnotationConfig.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
Generic generic = vault.inject(Generic.class);
// then
Assertions.assertEquals("Generic", generic.hello());
}
}
|
UTF-8
|
Java
| 9,373
|
java
|
ClassVaultTest.java
|
Java
|
[] | null |
[] |
package org.jvault.vault;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.jvault.exceptions.DisallowedAccessException;
import org.jvault.factory.TypeVaultFactory;
import org.jvault.factory.buildinfo.AbstractVaultFactoryBuildInfo;
import org.jvault.factory.buildinfo.AnnotationVaultFactoryBuildInfo;
import org.jvault.factory.extensible.Vault;
import org.jvault.factory.extensible.VaultFactoryBuildInfo;
import org.jvault.struct.annotationconfigwithclass.AnnotationConfigWithClass;
import org.jvault.struct.buildvault.BuildVault;
import org.jvault.struct.buildvaultcannotinjectbean.BuildVaultCannotInjectBean;
import org.jvault.struct.buildvaultcannotinjectclass.BuildVaultCannotInjectClass;
import org.jvault.struct.duplicatevault.DuplicateVault;
import org.jvault.struct.genericbean.Generic;
import org.jvault.struct.vaultinjectsingletonbean.AnnotationConfigWithNotScan;
import org.jvault.struct.vaultinjectsingletonbean.AnnotationConfigWithScan;
import org.jvault.struct.vaultinjectsingletonbean.VaultInjectBean;
public class ClassVaultTest {
@Test
public void BUILD_VAULT_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvault.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
public String[] getVaultAccessPackages(){
return new String[]{"org.jvault.struct.buildvault"};
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
BuildVault buildVault = classVault.inject(BuildVault.class);
// then
Assertions.assertEquals("BuildVaultBuildVaultBeanABuildVaultBeanBBuildVaultBeanC", buildVault.imNotBean());
}
@Test
public void BUILD_VAULT_CANNOT_INJECT_CLASS_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvaultcannotinjectclass.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
// then
Assertions.assertThrows(DisallowedAccessException.class, ()-> classVault.inject(BuildVaultCannotInjectClass.class));
}
@Test
public void BUILD_VAULT_CANNOT_INJECT_BEAN_CREATE_VAULT_TEST(){
// given
TypeVaultFactory factory = TypeVaultFactory.getInstance();
VaultFactoryBuildInfo buildInfo = new AbstractVaultFactoryBuildInfo() {
@Override
public String getVaultName() {
return "BUILD_VAULT_CREATE_VAULT_TEST";
}
@Override
protected String[] getPackagesImpl() {
return new String[]{"org.jvault.struct.buildvaultcannotinjectbean.*"};
}
@Override
protected String[] getExcludePackagesImpl() {
return new String[0];
}
@Override
protected String[] getClassesImpl() {
return new String[0];
}
};
// when
ClassVault classVault = factory.get(buildInfo, VaultType.CLASS);
// then
Assertions.assertThrows(DisallowedAccessException.class, ()-> classVault.inject(BuildVaultCannotInjectBean.class));
}
@Test
public void ANNOTATION_CONFIG_WITH_CLASS_CREATE_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.annotationconfigwithclass.AnnotationConfig.class);
// when
ClassVault vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
AnnotationConfigWithClass bean = vault.inject(AnnotationConfigWithClass.class);
// then
Assertions.assertEquals("AnnotationConfigWithClassAnnotationConfigWithClassBean", bean.hello());
}
@Test
public void CHOICE_CONSTRUCTOR_INJECT_CLASS_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.choiceconstructorinject.AnnotationConfig.class);
// then
Assertions.assertThrows(IllegalStateException.class, ()-> vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS));
}
@Test
public void DUPLICATE_VAULT_DETECTED_CLASS_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.AnnotatinConfig.class);
AnnotationVaultFactoryBuildInfo duplicateAnnotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.DuplicatedAnnotationConfig.class);
// when
Vault<Class<?>> vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
ClassVault duplicatedVault = vaultFactory.get(duplicateAnnotationVaultFactoryBuildInfo, VaultType.CLASS);
DuplicateVault duplicateVault = vault.inject(DuplicateVault.class, DuplicateVault.class);
DuplicateVault comparedDuplicatedVault = duplicatedVault.inject(DuplicateVault.class);
// then
Assertions.assertEquals(duplicateVault, comparedDuplicatedVault);
}
@Test
public void DUPLICATE_VAULT_DETECTED_WITH_VAULT_NAME_VAULT_TEST(){
// given
TypeVaultFactory vaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo annotationVaultFactoryBuildInfo
= new AnnotationVaultFactoryBuildInfo(org.jvault.struct.duplicatevault.AnnotatinConfig.class);
// when
Vault<Class<?>> vault = vaultFactory.get(annotationVaultFactoryBuildInfo, VaultType.CLASS);
ClassVault duplicatedVault = vaultFactory.get("DUPLICATE_VAULT", VaultType.CLASS);
DuplicateVault duplicateVault = vault.inject(DuplicateVault.class, DuplicateVault.class);
DuplicateVault comparedDuplicatedVault = duplicatedVault.inject(DuplicateVault.class);
// then
Assertions.assertEquals(duplicateVault, comparedDuplicatedVault);
}
@Test
public void VAULT_INJECT_SINGLETON_WITH_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(AnnotationConfigWithScan.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
VaultInjectBean vaultInjectBean = vault.inject(VaultInjectBean.class);
VaultInjectBean samePointVaultInjectBean = vault.inject(VaultInjectBean.class);
// then
Assertions.assertEquals(vaultInjectBean, samePointVaultInjectBean);
}
@Test
public void VAULT_INJECT_SINGLETON_WITH_NOT_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(AnnotationConfigWithNotScan.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
VaultInjectBean vaultInjectBean = vault.inject(VaultInjectBean.class);
VaultInjectBean differentPointVaultInjectBean = vault.inject(VaultInjectBean.class);
// then
Assertions.assertNotEquals(vaultInjectBean, differentPointVaultInjectBean);
}
@Test
public void GENERIC_BEAN_SCAN_TEST(){
// given
TypeVaultFactory typeVaultFactory = TypeVaultFactory.getInstance();
AnnotationVaultFactoryBuildInfo buildInfo = new AnnotationVaultFactoryBuildInfo(org.jvault.struct.genericbean.AnnotationConfig.class);
// when
ClassVault vault = typeVaultFactory.get(buildInfo, VaultType.CLASS);
Generic generic = vault.inject(Generic.class);
// then
Assertions.assertEquals("Generic", generic.hello());
}
}
| 9,373
| 0.694655
| 0.694015
| 234
| 39.055557
| 37.725632
| 178
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.461538
| false
| false
|
13
|
f69cd1ad26719f97ce7374c19b13f15bcc88a232
| 39,676,907,895,898
|
1511ac0ae17a6cb878899e05229eeea32aaf63cd
|
/server/src/main/java/com/jiazhe/alliance/core/server/controller/remote/WorkerCheckRecordRemoteController.java
|
0debc1062bd5f0bc3b00ea13ce78df88773ba8cc
|
[] |
no_license
|
niexiao/jiazhe-alliance-core
|
https://github.com/niexiao/jiazhe-alliance-core
|
bacc9b7adfa4452746a4a898559a11807a20e1f0
|
825747c0e8f20c0f5f377c5e11bb85a7f8a3989f
|
refs/heads/master
| 2020-06-13T07:31:26.593000
| 2020-01-07T08:42:40
| 2020-01-07T08:42:40
| 194,585,276
| 0
| 0
| null | false
| 2020-07-02T01:13:32
| 2019-07-01T02:19:50
| 2020-01-07T08:42:43
| 2020-07-02T01:13:31
| 2,901
| 0
| 0
| 4
|
Java
| false
| false
|
package com.jiazhe.alliance.core.server.controller.remote;
import com.jiazhe.alliance.core.resp.workercheckrecord.ResidueCheckNumRemoteResp;
import com.jiazhe.alliance.core.server.biz.WorkerCheckRecordBiz;
import com.jiazhe.alliance.core.server.domain.vo.req.IdReq;
import com.jiazhe.alliance.core.server.domain.vo.resp.merchantresiduechecknum.ResidueCheckNumResp;
import com.jiazhe.common.vo.rpc.RpcResponse;
import com.jiazhe.common.vo.rpc.RpcResponseFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @author TU
* @description
* @date 2019-12-23.
*/
@RestController
@RequestMapping("/remote/workercheckrecord")
public class WorkerCheckRecordRemoteController {
@Autowired
private WorkerCheckRecordBiz workerCheckRecordBiz;
@ApiOperation(value = "根据商家id查询商家可用剩余背景调查次数", httpMethod = "POST", response = ResidueCheckNumResp.class, notes = "根据商家id查询商家可用剩余背景调查次数")
@RequestMapping(value = "/getresiduechecknumbymerchantid", method = RequestMethod.POST)
public RpcResponse<ResidueCheckNumRemoteResp> getResidueCheckNumByMerchantId(@RequestBody IdReq req) {
Integer num = workerCheckRecordBiz.getResidueCheckNumByMerchantId(req.getId());
ResidueCheckNumRemoteResp resp = new ResidueCheckNumRemoteResp();
resp.setResidueCheckNum(num);
return RpcResponseFactory.buildResponse(resp);
}
}
|
UTF-8
|
Java
| 1,736
|
java
|
WorkerCheckRecordRemoteController.java
|
Java
|
[
{
"context": "eb.bind.annotation.RestController;\n\n/**\n * @author TU\n * @description\n * @date 2019-12-23.\n */\n@RestCon",
"end": 836,
"score": 0.9846824407577515,
"start": 834,
"tag": "NAME",
"value": "TU"
}
] | null |
[] |
package com.jiazhe.alliance.core.server.controller.remote;
import com.jiazhe.alliance.core.resp.workercheckrecord.ResidueCheckNumRemoteResp;
import com.jiazhe.alliance.core.server.biz.WorkerCheckRecordBiz;
import com.jiazhe.alliance.core.server.domain.vo.req.IdReq;
import com.jiazhe.alliance.core.server.domain.vo.resp.merchantresiduechecknum.ResidueCheckNumResp;
import com.jiazhe.common.vo.rpc.RpcResponse;
import com.jiazhe.common.vo.rpc.RpcResponseFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @author TU
* @description
* @date 2019-12-23.
*/
@RestController
@RequestMapping("/remote/workercheckrecord")
public class WorkerCheckRecordRemoteController {
@Autowired
private WorkerCheckRecordBiz workerCheckRecordBiz;
@ApiOperation(value = "根据商家id查询商家可用剩余背景调查次数", httpMethod = "POST", response = ResidueCheckNumResp.class, notes = "根据商家id查询商家可用剩余背景调查次数")
@RequestMapping(value = "/getresiduechecknumbymerchantid", method = RequestMethod.POST)
public RpcResponse<ResidueCheckNumRemoteResp> getResidueCheckNumByMerchantId(@RequestBody IdReq req) {
Integer num = workerCheckRecordBiz.getResidueCheckNumByMerchantId(req.getId());
ResidueCheckNumRemoteResp resp = new ResidueCheckNumRemoteResp();
resp.setResidueCheckNum(num);
return RpcResponseFactory.buildResponse(resp);
}
}
| 1,736
| 0.810697
| 0.805889
| 37
| 43.972973
| 35.027779
| 140
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.594595
| false
| false
|
13
|
f3ac1ab54b893afc2d0a17971220d474ab3d0777
| 35,321,811,097,614
|
171c5711871e0fdef19039f61f8c6ed49a72133e
|
/Lab/lab01/06-complexNumCalculator/ComplexNum.java
|
8d9f403c6ade769965a7dfb5a2b39aa9da2f0d61
|
[] |
no_license
|
aleshark87/OOP-Java
|
https://github.com/aleshark87/OOP-Java
|
a190de37d3758696a1ff6d82d920fd34a6874f42
|
112c9aa77a4a37168cc7a8bca9725026506b1932
|
refs/heads/master
| 2020-08-08T01:24:41.803000
| 2019-12-02T08:34:07
| 2019-12-02T08:34:07
| 213,654,628
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
class ComplexNum {
double re; //real
double im; //imaginary
void build(double re, double im) {
this.re = re;
this.im = im;
}
boolean equal(ComplexNum num) {
if(((this.re) == (num.re))&&(this.im) == (num.im)) return true;
return false;
}
void add(ComplexNum num) {
this.re = this.re + num.re;
this.im = this.im + num.im;
}
String toStringRep() {
String sign=" +";
if(this.im<0) sign = " ";
return this.re + sign + this.im + "i";
}
}
|
UTF-8
|
Java
| 556
|
java
|
ComplexNum.java
|
Java
|
[] | null |
[] |
class ComplexNum {
double re; //real
double im; //imaginary
void build(double re, double im) {
this.re = re;
this.im = im;
}
boolean equal(ComplexNum num) {
if(((this.re) == (num.re))&&(this.im) == (num.im)) return true;
return false;
}
void add(ComplexNum num) {
this.re = this.re + num.re;
this.im = this.im + num.im;
}
String toStringRep() {
String sign=" +";
if(this.im<0) sign = " ";
return this.re + sign + this.im + "i";
}
}
| 556
| 0.489209
| 0.48741
| 33
| 15.848485
| 17.531134
| 71
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.363636
| false
| false
|
13
|
a5e4ccaac415ec536f196ac153a26039a9e3a46e
| 33,878,702,094,805
|
ea175d8d30a3c8566ce62fdd66ac4e7fb7935c37
|
/core/src/test/java/com/orientechnologies/orient/core/storage/index/sbtree/singlevalue/v3/CellBTreeSingleValueV3TestIT.java
|
d07bd2976a3de6b2f5d3ebeebc03ff6021b8bf1b
|
[
"BSD-3-Clause",
"CDDL-1.0",
"Apache-2.0"
] |
permissive
|
orientechnologies/orientdb
|
https://github.com/orientechnologies/orientdb
|
a9aa2708e927cfbd8ba479ed1ceabb1979ba9f65
|
7df5ffa9f691ae752a0abdb45ccf93bc8ae8b9a4
|
refs/heads/develop
| 2023-08-31T12:42:55.842000
| 2023-08-30T13:56:50
| 2023-08-30T13:56:50
| 7,083,240
| 3,932
| 979
|
Apache-2.0
| false
| 2023-09-11T12:49:58
| 2012-12-09T20:33:47
| 2023-09-10T16:23:29
| 2023-09-11T12:49:56
| 253,324
| 4,633
| 880
| 276
|
Java
| false
| false
|
package com.orientechnologies.orient.core.storage.index.sbtree.singlevalue.v3;
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.exception.OHighLevelException;
import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.common.serialization.types.OUTF8Serializer;
import com.orientechnologies.common.util.ORawPair;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperationsManager;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Random;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Stream;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class CellBTreeSingleValueV3TestIT {
private OAtomicOperationsManager atomicOperationsManager;
private CellBTreeSingleValueV3<String> singleValueTree;
private OrientDB orientDB;
private String dbName;
@Before
public void before() throws Exception {
final String buildDirectory =
System.getProperty("buildDirectory", ".")
+ File.separator
+ CellBTreeSingleValueV3TestIT.class.getSimpleName();
dbName = "localSingleBTreeTest";
final File dbDirectory = new File(buildDirectory, dbName);
OFileUtils.deleteRecursively(dbDirectory);
final OrientDBConfig config = OrientDBConfig.builder().build();
orientDB = new OrientDB("plocal:" + buildDirectory, config);
orientDB.execute(
"create database " + dbName + " plocal users ( admin identified by 'admin' role admin)");
OAbstractPaginatedStorage storage;
try (ODatabaseSession databaseDocumentTx = orientDB.open(dbName, "admin", "admin")) {
storage =
(OAbstractPaginatedStorage) ((ODatabaseInternal<?>) databaseDocumentTx).getStorage();
}
singleValueTree = new CellBTreeSingleValueV3<>("singleBTree", ".sbt", ".nbt", storage);
atomicOperationsManager = storage.getAtomicOperationsManager();
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.create(atomicOperation, OUTF8Serializer.INSTANCE, null, 1, null));
}
@After
public void afterMethod() {
orientDB.drop(dbName);
orientDB.close();
}
@Test
public void testKeyPut() throws Exception {
final int keysCount = 1_000_000;
final int rollbackInterval = 100;
String[] lastKey = new String[1];
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int iterationCounter = i;
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final String key = Integer.toString(iterationCounter * rollbackInterval + j);
singleValueTree.put(
atomicOperation,
key,
new ORecordId(
(iterationCounter * rollbackInterval + j) % 32000,
iterationCounter * rollbackInterval + j));
if (rollbackCounter == 1) {
if ((iterationCounter * rollbackInterval + j) % 100_000 == 0) {
System.out.printf(
"%d items loaded out of %d%n",
iterationCounter * rollbackInterval + j, keysCount);
}
if (lastKey[0] == null) {
lastKey[0] = key;
} else if (key.compareTo(lastKey[0]) > 0) {
lastKey[0] = key;
}
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals("0", singleValueTree.firstKey());
Assert.assertEquals(lastKey[0], singleValueTree.lastKey());
}
for (int i = 0; i < keysCount; i++) {
Assert.assertEquals(
i + " key is absent",
new ORecordId(i % 32000, i),
singleValueTree.get(Integer.toString(i)));
if (i % 100_000 == 0) {
System.out.printf("%d items tested out of %d%n", i, keysCount);
}
}
for (int i = keysCount; i < 2 * keysCount; i++) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
}
}
@Test
public void testKeyPutRandomUniform() throws Exception {
final NavigableSet<String> keys = new TreeSet<>();
final Random random = new Random();
final int keysCount = 1_000_000;
final int rollbackRange = 100;
while (keys.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int i = 0; i < rollbackRange; i++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keys.add(key);
}
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
final int val = Integer.parseInt(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
@Test
public void testKeyPutRandomGaussian() throws Exception {
NavigableSet<String> keys = new TreeSet<>();
long seed = System.currentTimeMillis();
System.out.println("testKeyPutRandomGaussian seed : " + seed);
Random random = new Random(seed);
final int keysCount = 1_000_000;
final int rollbackRange = 100;
while (keys.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int i = 0; i < rollbackRange; i++) {
int val;
do {
val = (int) (random.nextGaussian() * Integer.MAX_VALUE / 2 + Integer.MAX_VALUE);
} while (val < 0);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keys.add(key);
}
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
@Test
public void testKeyDeleteRandomUniform() throws Exception {
final int keysCount = 1_000_000;
NavigableSet<String> keys = new TreeSet<>();
for (int i = 0; i < keysCount; i++) {
String key = Integer.toString(i);
final int k = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(atomicOperation, key, new ORecordId(k % 32000, k)));
keys.add(key);
}
final int rollbackInterval = 10;
Iterator<String> keysIterator = keys.iterator();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
if (Integer.parseInt(key) % 3 == 0) {
atomicOperationsManager.executeInsideAtomicOperation(
null, atomicOperation -> singleValueTree.remove(atomicOperation, key));
keysIterator.remove();
}
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
int rollbackCounter = 0;
final Iterator<String> keysDeletionIterator = keys.tailSet(key, false).iterator();
while (keysDeletionIterator.hasNext() && rollbackCounter < rollbackInterval) {
String keyToDelete = keysDeletionIterator.next();
rollbackCounter++;
singleValueTree.remove(atomicOperation, keyToDelete);
}
throw new RollbackException();
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
if (val % 3 == 0) {
Assert.assertNull(singleValueTree.get(key));
} else {
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
}
@Test
public void testKeyDeleteRandomGaussian() throws Exception {
NavigableSet<String> keys = new TreeSet<>();
final int keysCount = 1_000_000;
long seed = System.currentTimeMillis();
System.out.println("testKeyDeleteRandomGaussian seed : " + seed);
Random random = new Random(seed);
while (keys.size() < keysCount) {
int val = (int) (random.nextGaussian() * Integer.MAX_VALUE / 2 + Integer.MAX_VALUE);
if (val < 0) {
continue;
}
String key = Integer.toString(val);
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val)));
keys.add(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
Iterator<String> keysIterator = keys.iterator();
final int rollbackInterval = 10;
while (keysIterator.hasNext()) {
String key = keysIterator.next();
if (Integer.parseInt(key) % 3 == 0) {
atomicOperationsManager.executeInsideAtomicOperation(
null, atomicOperation -> singleValueTree.remove(atomicOperation, key));
keysIterator.remove();
}
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
int rollbackCounter = 0;
final Iterator<String> keysDeletionIterator = keys.tailSet(key, false).iterator();
while (keysDeletionIterator.hasNext() && rollbackCounter < rollbackInterval) {
String keyToDelete = keysDeletionIterator.next();
rollbackCounter++;
singleValueTree.remove(atomicOperation, keyToDelete);
}
throw new RollbackException();
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
if (val % 3 == 0) {
Assert.assertNull(singleValueTree.get(key));
} else {
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
}
@Test
public void testKeyDelete() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int k = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(k), new ORecordId(k % 32000, k)));
}
final int rollbackInterval = 100;
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
final int iterationsCounter = i;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final int key = iterationsCounter * rollbackInterval + j;
if (key % 3 == 0) {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
for (int i = 0; i < keysCount; i++) {
if (i % 3 == 0) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
}
}
@Test
public void testKeyAddDelete() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
final int rollbackInterval = 100;
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
final int iterationsCounter = i;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final int key = iterationsCounter * rollbackInterval + j;
if (key % 3 == 0) {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
}
if (key % 2 == 0) {
singleValueTree.put(
atomicOperation,
Integer.toString(keysCount + key),
new ORecordId((keysCount + key) % 32000, keysCount + key));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
for (int i = 0; i < keysCount; i++) {
if (i % 3 == 0) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
if (i % 2 == 0) {
Assert.assertEquals(
singleValueTree.get(Integer.toString(keysCount + i)),
new ORecordId((keysCount + i) % 32000, keysCount + i));
}
}
}
@Test
public void testKeyAddDeleteAll() throws Exception {
for (int iterations = 0; iterations < 4; iterations++) {
System.out.println("testKeyAddDeleteAll : iteration " + iterations);
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
if (key > 0 && key % 100_000 == 0) {
for (int keyToVerify = 0; keyToVerify < keysCount; keyToVerify++) {
if (keyToVerify > key) {
Assert.assertEquals(
new ORecordId(keyToVerify % 32000, keyToVerify),
singleValueTree.get(Integer.toString(keyToVerify)));
} else {
Assert.assertNull(singleValueTree.get(Integer.toString(keyToVerify)));
}
}
}
});
}
for (int i = 0; i < keysCount; i++) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
}
singleValueTree.assertFreePages(atomicOperationsManager.getCurrentOperation());
}
}
@Test
public void testKeyAddDeleteHalf() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount / 2; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
for (int iterations = 0; iterations < 4; iterations++) {
System.out.println("testKeyAddDeleteHalf : iteration " + iterations);
for (int i = 0; i < keysCount / 2; i++) {
final int key = i + (iterations + 1) * keysCount / 2;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(
singleValueTree.get(Integer.toString(key)), new ORecordId(key % 32000, key));
}
final int offset = iterations * (keysCount / 2);
for (int i = 0; i < keysCount / 2; i++) {
final int key = i + offset;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key)));
}
final int start = (iterations + 1) * (keysCount / 2);
for (int i = 0; i < (iterations + 2) * keysCount / 2; i++) {
if (i < start) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(
new ORecordId(i % 32000, i), singleValueTree.get(Integer.toString(i)));
}
}
singleValueTree.assertFreePages(atomicOperationsManager.getCurrentOperation());
}
}
@Test
public void testKeyCursor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testKeyCursor: " + seed);
Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
final Iterator<String> indexIterator;
try (Stream<String> stream = singleValueTree.keyStream()) {
indexIterator = stream.iterator();
for (String entryKey : keyValues.keySet()) {
final String indexKey = indexIterator.next();
Assert.assertEquals(entryKey, indexKey);
}
}
}
@Test
public void testIterateEntriesMajor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testIterateEntriesMajor: " + seed);
final Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateMajorEntries(keyValues, random, true, true);
assertIterateMajorEntries(keyValues, random, false, true);
assertIterateMajorEntries(keyValues, random, true, false);
assertIterateMajorEntries(keyValues, random, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesMinor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testIterateEntriesMinor: " + seed);
final Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateMinorEntries(keyValues, random, true, true);
assertIterateMinorEntries(keyValues, random, false, true);
assertIterateMinorEntries(keyValues, random, true, false);
assertIterateMinorEntries(keyValues, random, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesBetween() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final Random random = new Random();
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateBetweenEntries(keyValues, random, true, true, true);
assertIterateBetweenEntries(keyValues, random, true, false, true);
assertIterateBetweenEntries(keyValues, random, false, true, true);
assertIterateBetweenEntries(keyValues, random, false, false, true);
assertIterateBetweenEntries(keyValues, random, true, true, false);
assertIterateBetweenEntries(keyValues, random, true, false, false);
assertIterateBetweenEntries(keyValues, random, false, true, false);
assertIterateBetweenEntries(keyValues, random, false, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesBetweenString() throws Exception {
final int keysCount = 10;
final NavigableMap<String, ORID> keyValues = new TreeMap<>();
final Random random = new Random();
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < keysCount; j++) {
final String key = "name" + j;
final int val = random.nextInt(Integer.MAX_VALUE);
final int clusterId = val % 32000;
singleValueTree.put(atomicOperation, key, new ORecordId(clusterId, val));
System.out.println("Added key=" + key + ", value=" + val);
keyValues.put(key, new ORecordId(clusterId, val));
}
});
} catch (final RollbackException ignore) {
Assert.fail();
}
assertIterateBetweenEntriesNonRandom("name5", keyValues, true, true, true, 5);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
private void assertIterateMajorEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean keyInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
final int fromKeyIndex = random.nextInt(keys.length);
String fromKey = keys[fromKeyIndex];
if (random.nextBoolean()) {
fromKey =
fromKey.substring(0, fromKey.length() - 2) + (fromKey.charAt(fromKey.length() - 1) - 1);
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesMajor(fromKey, keyInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator = keyValues.tailMap(fromKey, keyInclusive).entrySet().iterator();
} else {
iterator =
keyValues
.descendingMap()
.subMap(keyValues.lastKey(), true, fromKey, keyInclusive)
.entrySet()
.iterator();
}
while (iterator.hasNext()) {
final ORawPair<String, ORID> indexEntry = indexIterator.next();
final Map.Entry<String, ORID> entry = iterator.next();
Assert.assertEquals(indexEntry.first, entry.getKey());
Assert.assertEquals(indexEntry.second, entry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateMinorEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean keyInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
int toKeyIndex = random.nextInt(keys.length);
String toKey = keys[toKeyIndex];
if (random.nextBoolean()) {
toKey = toKey.substring(0, toKey.length() - 2) + (toKey.charAt(toKey.length() - 1) + 1);
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesMinor(toKey, keyInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator = keyValues.headMap(toKey, keyInclusive).entrySet().iterator();
} else {
iterator = keyValues.headMap(toKey, keyInclusive).descendingMap().entrySet().iterator();
}
while (iterator.hasNext()) {
ORawPair<String, ORID> indexEntry = indexIterator.next();
Map.Entry<String, ORID> entry = iterator.next();
Assert.assertEquals(indexEntry.first, entry.getKey());
Assert.assertEquals(indexEntry.second, entry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateBetweenEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean fromInclusive,
boolean toInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
int fromKeyIndex = random.nextInt(keys.length);
int toKeyIndex = random.nextInt(keys.length);
if (fromKeyIndex > toKeyIndex) {
toKeyIndex = fromKeyIndex;
}
String fromKey = keys[fromKeyIndex];
String toKey = keys[toKeyIndex];
if (random.nextBoolean()) {
fromKey =
fromKey.substring(0, fromKey.length() - 2) + (fromKey.charAt(fromKey.length() - 1) - 1);
}
if (random.nextBoolean()) {
toKey = toKey.substring(0, toKey.length() - 2) + (toKey.charAt(toKey.length() - 1) + 1);
}
if (fromKey.compareTo(toKey) > 0) {
fromKey = toKey;
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesBetween(
fromKey, fromInclusive, toKey, toInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator =
keyValues.subMap(fromKey, fromInclusive, toKey, toInclusive).entrySet().iterator();
} else {
iterator =
keyValues
.descendingMap()
.subMap(toKey, toInclusive, fromKey, fromInclusive)
.entrySet()
.iterator();
}
while (iterator.hasNext()) {
ORawPair<String, ORID> indexEntry = indexIterator.next();
Assert.assertNotNull(indexEntry);
Map.Entry<String, ORID> mapEntry = iterator.next();
Assert.assertEquals(indexEntry.first, mapEntry.getKey());
Assert.assertEquals(indexEntry.second, mapEntry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateBetweenEntriesNonRandom(
final String fromKey,
final NavigableMap<String, ORID> keyValues,
final boolean fromInclusive,
final boolean toInclusive,
final boolean ascSortOrder,
final int startFrom) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (final String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = startFrom; i < keyValues.size(); i++) {
final String toKey = keys[i];
final Iterator<ORawPair<String, ORID>> indexIterator;
try (final Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesBetween(
fromKey, fromInclusive, toKey, toInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Assert.assertTrue(indexIterator.hasNext());
}
}
}
static final class RollbackException extends OException implements OHighLevelException {
@SuppressWarnings("WeakerAccess")
public RollbackException() {
this("");
}
@SuppressWarnings("WeakerAccess")
public RollbackException(String message) {
super(message);
}
@SuppressWarnings("unused")
public RollbackException(RollbackException exception) {
super(exception);
}
}
}
|
UTF-8
|
Java
| 35,731
|
java
|
CellBTreeSingleValueV3TestIT.java
|
Java
|
[
{
"context": "ut() throws Exception {\n final int keysCount = 1_000_000;\n\n final int rollbackInterval = 100;\n Strin",
"end": 2903,
"score": 0.9496237635612488,
"start": 2894,
"tag": "KEY",
"value": "1_000_000"
},
{
"context": "erval; j++) {\n final String key = Integer.toString(iterationCounter * rollbackInterval + j);\n ",
"end": 3406,
"score": 0.9115400314331055,
"start": 3389,
"tag": "KEY",
"value": "Integer.toString("
},
{
"context": " final String key = Integer.toString(iterationCounter * rollbackInterval + j);\n singleValueTree.put(\n ",
"end": 3445,
"score": 0.7793103456497192,
"start": 3406,
"tag": "KEY",
"value": "iterationCounter * rollbackInterval + j"
},
{
"context": "Integer.MAX_VALUE);\n String key = Integer.toString(val);\n singleValueTree.put(atomicOpe",
"end": 5736,
"score": 0.9829180836677551,
"start": 5716,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "} while (val < 0);\n\n String key = Integer.toString(val);\n singleValueTree.put(atomic",
"end": 7435,
"score": 0.9598618745803833,
"start": 7418,
"tag": "KEY",
"value": "Integer.toString("
},
{
"context": "nt i = 0; i < keysCount; i++) {\n String key = Integer.toString(i);\n final int k = i;\n atomicOperations",
"end": 8483,
"score": 0.9887728691101074,
"start": 8467,
"tag": "KEY",
"value": "Integer.toString"
},
{
"context": " 0) {\n continue;\n }\n String key = Integer.toString(val);\n atomicOperationsManager.executeInsideAtom",
"end": 10715,
"score": 0.9916914105415344,
"start": 10695,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "te() throws Exception {\n final int keysCount = 1_000_000;\n\n for (int i = 0; i < keysCount; i++) {\n ",
"end": 12580,
"score": 0.8508514165878296,
"start": 12571,
"tag": "KEY",
"value": "1_000_000"
},
{
"context": "te() throws Exception {\n final int keysCount = 1_000_000;\n\n for (int i = 0; i < keysCount; i++) {\n ",
"end": 14193,
"score": 0.9241548180580139,
"start": 14184,
"tag": "KEY",
"value": "1_000_000"
},
{
"context": "++) {\n final int key = iterationsCounter * rollbackInterval + j;\n\n if (ke",
"end": 15063,
"score": 0.5104365348815918,
"start": 15056,
"tag": "KEY",
"value": "Counter"
},
{
"context": " final int key = iterationsCounter * rollbackInterval + j;\n\n if (key % 3 == 0) {\n ",
"end": 15082,
"score": 0.6702405214309692,
"start": 15066,
"tag": "KEY",
"value": "rollbackInterval"
},
{
"context": "ion \" + iterations);\n\n final int keysCount = 1_000_000;\n\n for (int i = 0; i < keysCount; i++) {\n ",
"end": 16535,
"score": 0.883010983467102,
"start": 16528,
"tag": "KEY",
"value": "1_000_0"
},
{
"context": "lf() throws Exception {\n final int keysCount = 1_000_000;\n\n for (int i = 0; i < keysCount / 2; i++) {\n ",
"end": 18201,
"score": 0.6693187952041626,
"start": 18192,
"tag": "KEY",
"value": "1_000_000"
},
{
"context": "Integer.MAX_VALUE);\n String key = Integer.toString(val);\n\n singleValueTree.put(atomicOp",
"end": 20920,
"score": 0.8365443348884583,
"start": 20900,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "Integer.MAX_VALUE);\n String key = Integer.toString(val);\n\n singleValueTree.put(atomicOp",
"end": 22805,
"score": 0.9501716494560242,
"start": 22785,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "Integer.MAX_VALUE);\n String key = Integer.toString(val);\n\n singleValueTree.put(atomicOp",
"end": 24628,
"score": 0.9863640666007996,
"start": 24608,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "Integer.MAX_VALUE);\n String key = Integer.toString(val);\n\n singleValueTree.put(atomicOp",
"end": 26346,
"score": 0.9459406733512878,
"start": 26326,
"tag": "KEY",
"value": "Integer.toString(val"
},
{
"context": "ysCount; j++) {\n final String key = \"name\" + j;\n final int val = random.nextInt(Int",
"end": 28107,
"score": 0.926042914390564,
"start": 28098,
"tag": "KEY",
"value": "name\" + j"
}
] | null |
[] |
package com.orientechnologies.orient.core.storage.index.sbtree.singlevalue.v3;
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.exception.OHighLevelException;
import com.orientechnologies.common.io.OFileUtils;
import com.orientechnologies.common.serialization.types.OUTF8Serializer;
import com.orientechnologies.common.util.ORawPair;
import com.orientechnologies.orient.core.db.ODatabaseInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperationsManager;
import java.io.File;
import java.util.Iterator;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Random;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Stream;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class CellBTreeSingleValueV3TestIT {
private OAtomicOperationsManager atomicOperationsManager;
private CellBTreeSingleValueV3<String> singleValueTree;
private OrientDB orientDB;
private String dbName;
@Before
public void before() throws Exception {
final String buildDirectory =
System.getProperty("buildDirectory", ".")
+ File.separator
+ CellBTreeSingleValueV3TestIT.class.getSimpleName();
dbName = "localSingleBTreeTest";
final File dbDirectory = new File(buildDirectory, dbName);
OFileUtils.deleteRecursively(dbDirectory);
final OrientDBConfig config = OrientDBConfig.builder().build();
orientDB = new OrientDB("plocal:" + buildDirectory, config);
orientDB.execute(
"create database " + dbName + " plocal users ( admin identified by 'admin' role admin)");
OAbstractPaginatedStorage storage;
try (ODatabaseSession databaseDocumentTx = orientDB.open(dbName, "admin", "admin")) {
storage =
(OAbstractPaginatedStorage) ((ODatabaseInternal<?>) databaseDocumentTx).getStorage();
}
singleValueTree = new CellBTreeSingleValueV3<>("singleBTree", ".sbt", ".nbt", storage);
atomicOperationsManager = storage.getAtomicOperationsManager();
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.create(atomicOperation, OUTF8Serializer.INSTANCE, null, 1, null));
}
@After
public void afterMethod() {
orientDB.drop(dbName);
orientDB.close();
}
@Test
public void testKeyPut() throws Exception {
final int keysCount = 1_000_000;
final int rollbackInterval = 100;
String[] lastKey = new String[1];
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int iterationCounter = i;
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final String key = Integer.toString(iterationCounter * rollbackInterval + j);
singleValueTree.put(
atomicOperation,
key,
new ORecordId(
(iterationCounter * rollbackInterval + j) % 32000,
iterationCounter * rollbackInterval + j));
if (rollbackCounter == 1) {
if ((iterationCounter * rollbackInterval + j) % 100_000 == 0) {
System.out.printf(
"%d items loaded out of %d%n",
iterationCounter * rollbackInterval + j, keysCount);
}
if (lastKey[0] == null) {
lastKey[0] = key;
} else if (key.compareTo(lastKey[0]) > 0) {
lastKey[0] = key;
}
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals("0", singleValueTree.firstKey());
Assert.assertEquals(lastKey[0], singleValueTree.lastKey());
}
for (int i = 0; i < keysCount; i++) {
Assert.assertEquals(
i + " key is absent",
new ORecordId(i % 32000, i),
singleValueTree.get(Integer.toString(i)));
if (i % 100_000 == 0) {
System.out.printf("%d items tested out of %d%n", i, keysCount);
}
}
for (int i = keysCount; i < 2 * keysCount; i++) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
}
}
@Test
public void testKeyPutRandomUniform() throws Exception {
final NavigableSet<String> keys = new TreeSet<>();
final Random random = new Random();
final int keysCount = 1_000_000;
final int rollbackRange = 100;
while (keys.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int i = 0; i < rollbackRange; i++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keys.add(key);
}
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
final int val = Integer.parseInt(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
@Test
public void testKeyPutRandomGaussian() throws Exception {
NavigableSet<String> keys = new TreeSet<>();
long seed = System.currentTimeMillis();
System.out.println("testKeyPutRandomGaussian seed : " + seed);
Random random = new Random(seed);
final int keysCount = 1_000_000;
final int rollbackRange = 100;
while (keys.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int i = 0; i < rollbackRange; i++) {
int val;
do {
val = (int) (random.nextGaussian() * Integer.MAX_VALUE / 2 + Integer.MAX_VALUE);
} while (val < 0);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keys.add(key);
}
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
@Test
public void testKeyDeleteRandomUniform() throws Exception {
final int keysCount = 1_000_000;
NavigableSet<String> keys = new TreeSet<>();
for (int i = 0; i < keysCount; i++) {
String key = Integer.toString(i);
final int k = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(atomicOperation, key, new ORecordId(k % 32000, k)));
keys.add(key);
}
final int rollbackInterval = 10;
Iterator<String> keysIterator = keys.iterator();
while (keysIterator.hasNext()) {
String key = keysIterator.next();
if (Integer.parseInt(key) % 3 == 0) {
atomicOperationsManager.executeInsideAtomicOperation(
null, atomicOperation -> singleValueTree.remove(atomicOperation, key));
keysIterator.remove();
}
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
int rollbackCounter = 0;
final Iterator<String> keysDeletionIterator = keys.tailSet(key, false).iterator();
while (keysDeletionIterator.hasNext() && rollbackCounter < rollbackInterval) {
String keyToDelete = keysDeletionIterator.next();
rollbackCounter++;
singleValueTree.remove(atomicOperation, keyToDelete);
}
throw new RollbackException();
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
if (val % 3 == 0) {
Assert.assertNull(singleValueTree.get(key));
} else {
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
}
@Test
public void testKeyDeleteRandomGaussian() throws Exception {
NavigableSet<String> keys = new TreeSet<>();
final int keysCount = 1_000_000;
long seed = System.currentTimeMillis();
System.out.println("testKeyDeleteRandomGaussian seed : " + seed);
Random random = new Random(seed);
while (keys.size() < keysCount) {
int val = (int) (random.nextGaussian() * Integer.MAX_VALUE / 2 + Integer.MAX_VALUE);
if (val < 0) {
continue;
}
String key = Integer.toString(val);
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val)));
keys.add(key);
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
Iterator<String> keysIterator = keys.iterator();
final int rollbackInterval = 10;
while (keysIterator.hasNext()) {
String key = keysIterator.next();
if (Integer.parseInt(key) % 3 == 0) {
atomicOperationsManager.executeInsideAtomicOperation(
null, atomicOperation -> singleValueTree.remove(atomicOperation, key));
keysIterator.remove();
}
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
int rollbackCounter = 0;
final Iterator<String> keysDeletionIterator = keys.tailSet(key, false).iterator();
while (keysDeletionIterator.hasNext() && rollbackCounter < rollbackInterval) {
String keyToDelete = keysDeletionIterator.next();
rollbackCounter++;
singleValueTree.remove(atomicOperation, keyToDelete);
}
throw new RollbackException();
});
} catch (RollbackException ignore) {
}
}
Assert.assertEquals(singleValueTree.firstKey(), keys.first());
Assert.assertEquals(singleValueTree.lastKey(), keys.last());
for (String key : keys) {
int val = Integer.parseInt(key);
if (val % 3 == 0) {
Assert.assertNull(singleValueTree.get(key));
} else {
Assert.assertEquals(singleValueTree.get(key), new ORecordId(val % 32000, val));
}
}
}
@Test
public void testKeyDelete() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int k = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(k), new ORecordId(k % 32000, k)));
}
final int rollbackInterval = 100;
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
final int iterationsCounter = i;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final int key = iterationsCounter * rollbackInterval + j;
if (key % 3 == 0) {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
for (int i = 0; i < keysCount; i++) {
if (i % 3 == 0) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
}
}
@Test
public void testKeyAddDelete() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
final int rollbackInterval = 100;
for (int i = 0; i < keysCount / rollbackInterval; i++) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
final int iterationsCounter = i;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
final int key = iterationsCounter * rollbackInterval + j;
if (key % 3 == 0) {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
}
if (key % 2 == 0) {
singleValueTree.put(
atomicOperation,
Integer.toString(keysCount + key),
new ORecordId((keysCount + key) % 32000, keysCount + key));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
}
for (int i = 0; i < keysCount; i++) {
if (i % 3 == 0) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
if (i % 2 == 0) {
Assert.assertEquals(
singleValueTree.get(Integer.toString(keysCount + i)),
new ORecordId((keysCount + i) % 32000, keysCount + i));
}
}
}
@Test
public void testKeyAddDeleteAll() throws Exception {
for (int iterations = 0; iterations < 4; iterations++) {
System.out.println("testKeyAddDeleteAll : iteration " + iterations);
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
for (int i = 0; i < keysCount; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key));
if (key > 0 && key % 100_000 == 0) {
for (int keyToVerify = 0; keyToVerify < keysCount; keyToVerify++) {
if (keyToVerify > key) {
Assert.assertEquals(
new ORecordId(keyToVerify % 32000, keyToVerify),
singleValueTree.get(Integer.toString(keyToVerify)));
} else {
Assert.assertNull(singleValueTree.get(Integer.toString(keyToVerify)));
}
}
}
});
}
for (int i = 0; i < keysCount; i++) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
}
singleValueTree.assertFreePages(atomicOperationsManager.getCurrentOperation());
}
}
@Test
public void testKeyAddDeleteHalf() throws Exception {
final int keysCount = 1_000_000;
for (int i = 0; i < keysCount / 2; i++) {
final int key = i;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(singleValueTree.get(Integer.toString(i)), new ORecordId(i % 32000, i));
}
for (int iterations = 0; iterations < 4; iterations++) {
System.out.println("testKeyAddDeleteHalf : iteration " + iterations);
for (int i = 0; i < keysCount / 2; i++) {
final int key = i + (iterations + 1) * keysCount / 2;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
singleValueTree.put(
atomicOperation, Integer.toString(key), new ORecordId(key % 32000, key)));
Assert.assertEquals(
singleValueTree.get(Integer.toString(key)), new ORecordId(key % 32000, key));
}
final int offset = iterations * (keysCount / 2);
for (int i = 0; i < keysCount / 2; i++) {
final int key = i + offset;
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation ->
Assert.assertEquals(
singleValueTree.remove(atomicOperation, Integer.toString(key)),
new ORecordId(key % 32000, key)));
}
final int start = (iterations + 1) * (keysCount / 2);
for (int i = 0; i < (iterations + 2) * keysCount / 2; i++) {
if (i < start) {
Assert.assertNull(singleValueTree.get(Integer.toString(i)));
} else {
Assert.assertEquals(
new ORecordId(i % 32000, i), singleValueTree.get(Integer.toString(i)));
}
}
singleValueTree.assertFreePages(atomicOperationsManager.getCurrentOperation());
}
}
@Test
public void testKeyCursor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testKeyCursor: " + seed);
Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
final Iterator<String> indexIterator;
try (Stream<String> stream = singleValueTree.keyStream()) {
indexIterator = stream.iterator();
for (String entryKey : keyValues.keySet()) {
final String indexKey = indexIterator.next();
Assert.assertEquals(entryKey, indexKey);
}
}
}
@Test
public void testIterateEntriesMajor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testIterateEntriesMajor: " + seed);
final Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateMajorEntries(keyValues, random, true, true);
assertIterateMajorEntries(keyValues, random, false, true);
assertIterateMajorEntries(keyValues, random, true, false);
assertIterateMajorEntries(keyValues, random, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesMinor() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final long seed = System.nanoTime();
System.out.println("testIterateEntriesMinor: " + seed);
final Random random = new Random(seed);
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateMinorEntries(keyValues, random, true, true);
assertIterateMinorEntries(keyValues, random, false, true);
assertIterateMinorEntries(keyValues, random, true, false);
assertIterateMinorEntries(keyValues, random, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesBetween() throws Exception {
final int keysCount = 1_000_000;
NavigableMap<String, ORID> keyValues = new TreeMap<>();
final Random random = new Random();
final int rollbackInterval = 100;
int printCounter = 0;
while (keyValues.size() < keysCount) {
for (int n = 0; n < 2; n++) {
final int rollbackCounter = n;
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < rollbackInterval; j++) {
int val = random.nextInt(Integer.MAX_VALUE);
String key = Integer.toString(val);
singleValueTree.put(atomicOperation, key, new ORecordId(val % 32000, val));
if (rollbackCounter == 1) {
keyValues.put(key, new ORecordId(val % 32000, val));
}
}
if (rollbackCounter == 0) {
throw new RollbackException();
}
});
} catch (RollbackException ignore) {
}
}
if (keyValues.size() > printCounter * 100_000) {
System.out.println(keyValues.size() + " entries were added.");
printCounter++;
}
}
assertIterateBetweenEntries(keyValues, random, true, true, true);
assertIterateBetweenEntries(keyValues, random, true, false, true);
assertIterateBetweenEntries(keyValues, random, false, true, true);
assertIterateBetweenEntries(keyValues, random, false, false, true);
assertIterateBetweenEntries(keyValues, random, true, true, false);
assertIterateBetweenEntries(keyValues, random, true, false, false);
assertIterateBetweenEntries(keyValues, random, false, true, false);
assertIterateBetweenEntries(keyValues, random, false, false, false);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
@Test
public void testIterateEntriesBetweenString() throws Exception {
final int keysCount = 10;
final NavigableMap<String, ORID> keyValues = new TreeMap<>();
final Random random = new Random();
try {
atomicOperationsManager.executeInsideAtomicOperation(
null,
atomicOperation -> {
for (int j = 0; j < keysCount; j++) {
final String key = "name" + j;
final int val = random.nextInt(Integer.MAX_VALUE);
final int clusterId = val % 32000;
singleValueTree.put(atomicOperation, key, new ORecordId(clusterId, val));
System.out.println("Added key=" + key + ", value=" + val);
keyValues.put(key, new ORecordId(clusterId, val));
}
});
} catch (final RollbackException ignore) {
Assert.fail();
}
assertIterateBetweenEntriesNonRandom("name5", keyValues, true, true, true, 5);
Assert.assertEquals(singleValueTree.firstKey(), keyValues.firstKey());
Assert.assertEquals(singleValueTree.lastKey(), keyValues.lastKey());
}
private void assertIterateMajorEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean keyInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
final int fromKeyIndex = random.nextInt(keys.length);
String fromKey = keys[fromKeyIndex];
if (random.nextBoolean()) {
fromKey =
fromKey.substring(0, fromKey.length() - 2) + (fromKey.charAt(fromKey.length() - 1) - 1);
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesMajor(fromKey, keyInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator = keyValues.tailMap(fromKey, keyInclusive).entrySet().iterator();
} else {
iterator =
keyValues
.descendingMap()
.subMap(keyValues.lastKey(), true, fromKey, keyInclusive)
.entrySet()
.iterator();
}
while (iterator.hasNext()) {
final ORawPair<String, ORID> indexEntry = indexIterator.next();
final Map.Entry<String, ORID> entry = iterator.next();
Assert.assertEquals(indexEntry.first, entry.getKey());
Assert.assertEquals(indexEntry.second, entry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateMinorEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean keyInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
int toKeyIndex = random.nextInt(keys.length);
String toKey = keys[toKeyIndex];
if (random.nextBoolean()) {
toKey = toKey.substring(0, toKey.length() - 2) + (toKey.charAt(toKey.length() - 1) + 1);
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesMinor(toKey, keyInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator = keyValues.headMap(toKey, keyInclusive).entrySet().iterator();
} else {
iterator = keyValues.headMap(toKey, keyInclusive).descendingMap().entrySet().iterator();
}
while (iterator.hasNext()) {
ORawPair<String, ORID> indexEntry = indexIterator.next();
Map.Entry<String, ORID> entry = iterator.next();
Assert.assertEquals(indexEntry.first, entry.getKey());
Assert.assertEquals(indexEntry.second, entry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateBetweenEntries(
NavigableMap<String, ORID> keyValues,
Random random,
boolean fromInclusive,
boolean toInclusive,
boolean ascSortOrder) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = 0; i < 100; i++) {
int fromKeyIndex = random.nextInt(keys.length);
int toKeyIndex = random.nextInt(keys.length);
if (fromKeyIndex > toKeyIndex) {
toKeyIndex = fromKeyIndex;
}
String fromKey = keys[fromKeyIndex];
String toKey = keys[toKeyIndex];
if (random.nextBoolean()) {
fromKey =
fromKey.substring(0, fromKey.length() - 2) + (fromKey.charAt(fromKey.length() - 1) - 1);
}
if (random.nextBoolean()) {
toKey = toKey.substring(0, toKey.length() - 2) + (toKey.charAt(toKey.length() - 1) + 1);
}
if (fromKey.compareTo(toKey) > 0) {
fromKey = toKey;
}
final Iterator<ORawPair<String, ORID>> indexIterator;
try (Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesBetween(
fromKey, fromInclusive, toKey, toInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Iterator<Map.Entry<String, ORID>> iterator;
if (ascSortOrder) {
iterator =
keyValues.subMap(fromKey, fromInclusive, toKey, toInclusive).entrySet().iterator();
} else {
iterator =
keyValues
.descendingMap()
.subMap(toKey, toInclusive, fromKey, fromInclusive)
.entrySet()
.iterator();
}
while (iterator.hasNext()) {
ORawPair<String, ORID> indexEntry = indexIterator.next();
Assert.assertNotNull(indexEntry);
Map.Entry<String, ORID> mapEntry = iterator.next();
Assert.assertEquals(indexEntry.first, mapEntry.getKey());
Assert.assertEquals(indexEntry.second, mapEntry.getValue());
}
//noinspection ConstantConditions
Assert.assertFalse(iterator.hasNext());
Assert.assertFalse(indexIterator.hasNext());
}
}
}
private void assertIterateBetweenEntriesNonRandom(
final String fromKey,
final NavigableMap<String, ORID> keyValues,
final boolean fromInclusive,
final boolean toInclusive,
final boolean ascSortOrder,
final int startFrom) {
String[] keys = new String[keyValues.size()];
int index = 0;
for (final String key : keyValues.keySet()) {
keys[index] = key;
index++;
}
for (int i = startFrom; i < keyValues.size(); i++) {
final String toKey = keys[i];
final Iterator<ORawPair<String, ORID>> indexIterator;
try (final Stream<ORawPair<String, ORID>> stream =
singleValueTree.iterateEntriesBetween(
fromKey, fromInclusive, toKey, toInclusive, ascSortOrder)) {
indexIterator = stream.iterator();
Assert.assertTrue(indexIterator.hasNext());
}
}
}
static final class RollbackException extends OException implements OHighLevelException {
@SuppressWarnings("WeakerAccess")
public RollbackException() {
this("");
}
@SuppressWarnings("WeakerAccess")
public RollbackException(String message) {
super(message);
}
@SuppressWarnings("unused")
public RollbackException(RollbackException exception) {
super(exception);
}
}
}
| 35,731
| 0.589292
| 0.574403
| 1,014
| 34.237671
| 26.686871
| 112
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.762327
| false
| false
|
13
|
00d01edbe761a7ea4557029c4780dae547eb8236
| 34,127,810,191,449
|
95b00c631f32e478b861f5d5efb198ea041d0276
|
/src/fr/enzomallard/app/DaoFactory.java
|
2a193d20465a89cb7e886c94e5534741b42156ce
|
[] |
no_license
|
EnzDev/JEESales
|
https://github.com/EnzDev/JEESales
|
9b0a92fc3c5f60e9e76d22fc565cabb7da76d8a5
|
407184d14cb3557161b486dd6df96d8fa73fe5e8
|
refs/heads/master
| 2021-04-26T22:15:15.968000
| 2018-08-22T12:21:31
| 2018-08-22T12:21:31
| 124,053,657
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package fr.enzomallard.app;
import fr.enzomallard.app.dao.ISaleDao;
import fr.enzomallard.app.dao.IUserDao;
import fr.enzomallard.app.dao.SqlSaleDao;
import fr.enzomallard.app.dao.SqlUserDao;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DaoFactory {
private static final Logger logger = LogManager.getLogger(DaoFactory.class);
private static final String DB_URL = "jdbc:hsqldb:hsql://localhost:9003/";
private static final String DB_DRIVER = "org.hsqldb.jdbcDriver";
private static DaoFactory instance;
public static DaoFactory getInstance() {
if (instance == null) instance = new DaoFactory();
return instance;
}
public Connection getConnection() {
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
logger.error("Couldn't find the SQL driver in the classpath", e);
}
try {
return DriverManager.getConnection(DB_URL, "SA", "");
} catch (SQLException e) {
logger.error("Couldn't connect to the Database", e);
throw new Error();
}
}
public IUserDao getUserDao() {
return new SqlUserDao(this);
}
public ISaleDao getSaleDao() {
return new SqlSaleDao(this);
}
}
|
UTF-8
|
Java
| 1,415
|
java
|
DaoFactory.java
|
Java
|
[] | null |
[] |
package fr.enzomallard.app;
import fr.enzomallard.app.dao.ISaleDao;
import fr.enzomallard.app.dao.IUserDao;
import fr.enzomallard.app.dao.SqlSaleDao;
import fr.enzomallard.app.dao.SqlUserDao;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DaoFactory {
private static final Logger logger = LogManager.getLogger(DaoFactory.class);
private static final String DB_URL = "jdbc:hsqldb:hsql://localhost:9003/";
private static final String DB_DRIVER = "org.hsqldb.jdbcDriver";
private static DaoFactory instance;
public static DaoFactory getInstance() {
if (instance == null) instance = new DaoFactory();
return instance;
}
public Connection getConnection() {
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
logger.error("Couldn't find the SQL driver in the classpath", e);
}
try {
return DriverManager.getConnection(DB_URL, "SA", "");
} catch (SQLException e) {
logger.error("Couldn't connect to the Database", e);
throw new Error();
}
}
public IUserDao getUserDao() {
return new SqlUserDao(this);
}
public ISaleDao getSaleDao() {
return new SqlSaleDao(this);
}
}
| 1,415
| 0.666431
| 0.662191
| 49
| 27.87755
| 23.325235
| 80
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.55102
| false
| false
|
13
|
dcc9cdd8c411946aa0ab6bb2dee54e26b2e04b47
| 39,625,368,287,299
|
c1ca647590984ab6ad4fe567c28fde7e0ea89107
|
/backoff-sim/src/Sim.java
|
a2119eb99148cb79e1d82bbbbfe267384c272750
|
[] |
no_license
|
AInoob/java
|
https://github.com/AInoob/java
|
340f0019afc3de8ff22c8cd1643ecd182473320f
|
db410c8a04fae84b7d3f124c1f065d8ac3a4a4b9
|
refs/heads/master
| 2016-05-21T16:11:44.981000
| 2015-11-11T18:00:20
| 2015-11-11T18:00:20
| 45,999,466
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
//Main file for simulator to illustrate exponential backoff (and other backoff schemes)
import java.util.*;
public class Sim {
//Simulation parameters:
public static final int USERS = 100; //number of users
public static final double COMM_PROBABILITY = 0.02; //probability that a user tries to communicate in 1 time step
public static final int DURATION = 2000; //number of time steps to run for
public static Random rand = new Random(); //random number generator
private int createdMess=0;
private int sentMess=0;
private List<User> users; //list of users
public Sim() {
users = new ArrayList<User>();
for(int i=0; i<USERS; i++) {
users.add(new User(COMM_PROBABILITY));
}
}
class AInoob{
public int waiting,created,sent;
AInoob(int waiting,int created,int sent){
this.waiting=waiting;
this.created=created;
this.sent=sent;
}
public String toString(){
return waiting+"\t"+created+"\t"+sent;
}
}
public double run(int duration, ArrayList<AInoob> numWaiting) {
//run the simulation for given number of steps
//returns number of messages delivered
//fills numWaiting (assumed initially empty) with the number waiting after each time step
TreeSet<Message> waitingMesgs = new TreeSet<Message>(); //set of messages to send
double delivered = 0,failed=0; //number of messages delivered
for(int i=0; i<duration; i++) {
createdMess=0;
//see if users add messages
for(User u : users) {
Message m = u.step(i);
if(m != null){
waitingMesgs.add(m);
createdMess++;
System.out.println("Created\tMess"+m.id()+"\t"+m.nextTime());
}
}
//pull out all messages that want to try sending now
ArrayList<Message> now = new ArrayList<Message>(); //list of them
while(!waitingMesgs.isEmpty() &&
(waitingMesgs.first().nextTime() == i)) {
Message m = waitingMesgs.first();
now.add(m);
waitingMesgs.remove(m);
}
for(Message m:waitingMesgs){
System.out.println("Mess "+"\t"+m.id()+"\t"+m.nextTime());
}
if(now.size() == 1) {
sentMess=1;
delivered++; //if 1 mesg wants now, it can send
Message m=now.get(0);
System.out.println("!!!Done Mess "+"\t"+m.id()+"\t"+m.nextTime());
} else if(now.size() > 1) { //if more than one, then collide
sentMess=0;
for(Message m : now) {
if(m.collide()){
System.out.println("Mess "+"\t"+m.id()+"\t"+m.nextTime());
waitingMesgs.add(m); //put it back in list of waiting messages
}
else{
failed++;
System.out.println("Revmove Mess "+"\t"+m.id()+"\t"+m.nextTime());
}
}
}
numWaiting.add(new AInoob(waitingMesgs.size(),createdMess,sentMess));
System.out.println(i+" !!!\t"+createdMess+"\t" +sentMess+"\n===========================================");
}
return failed/(failed+delivered);
}
public int createdMess(){
return createdMess;
}
public int sentMess(){
return sentMess;
}
public static void main(String[] args) {
Sim sim = new Sim();
ArrayList<AInoob> waiting = new ArrayList<AInoob>();
double missedRatio = sim.run(DURATION, waiting);
System.out.println("missedRatio " + missedRatio);
System.out.println("Number of waiting jobs after each time step:");
for(int i=0; i<waiting.size(); i++)
System.out.println(i + "\t" + waiting.get(i));
System.out.println("missedRatio " + missedRatio);
}
}
|
UTF-8
|
Java
| 3,445
|
java
|
Sim.java
|
Java
|
[] | null |
[] |
//Main file for simulator to illustrate exponential backoff (and other backoff schemes)
import java.util.*;
public class Sim {
//Simulation parameters:
public static final int USERS = 100; //number of users
public static final double COMM_PROBABILITY = 0.02; //probability that a user tries to communicate in 1 time step
public static final int DURATION = 2000; //number of time steps to run for
public static Random rand = new Random(); //random number generator
private int createdMess=0;
private int sentMess=0;
private List<User> users; //list of users
public Sim() {
users = new ArrayList<User>();
for(int i=0; i<USERS; i++) {
users.add(new User(COMM_PROBABILITY));
}
}
class AInoob{
public int waiting,created,sent;
AInoob(int waiting,int created,int sent){
this.waiting=waiting;
this.created=created;
this.sent=sent;
}
public String toString(){
return waiting+"\t"+created+"\t"+sent;
}
}
public double run(int duration, ArrayList<AInoob> numWaiting) {
//run the simulation for given number of steps
//returns number of messages delivered
//fills numWaiting (assumed initially empty) with the number waiting after each time step
TreeSet<Message> waitingMesgs = new TreeSet<Message>(); //set of messages to send
double delivered = 0,failed=0; //number of messages delivered
for(int i=0; i<duration; i++) {
createdMess=0;
//see if users add messages
for(User u : users) {
Message m = u.step(i);
if(m != null){
waitingMesgs.add(m);
createdMess++;
System.out.println("Created\tMess"+m.id()+"\t"+m.nextTime());
}
}
//pull out all messages that want to try sending now
ArrayList<Message> now = new ArrayList<Message>(); //list of them
while(!waitingMesgs.isEmpty() &&
(waitingMesgs.first().nextTime() == i)) {
Message m = waitingMesgs.first();
now.add(m);
waitingMesgs.remove(m);
}
for(Message m:waitingMesgs){
System.out.println("Mess "+"\t"+m.id()+"\t"+m.nextTime());
}
if(now.size() == 1) {
sentMess=1;
delivered++; //if 1 mesg wants now, it can send
Message m=now.get(0);
System.out.println("!!!Done Mess "+"\t"+m.id()+"\t"+m.nextTime());
} else if(now.size() > 1) { //if more than one, then collide
sentMess=0;
for(Message m : now) {
if(m.collide()){
System.out.println("Mess "+"\t"+m.id()+"\t"+m.nextTime());
waitingMesgs.add(m); //put it back in list of waiting messages
}
else{
failed++;
System.out.println("Revmove Mess "+"\t"+m.id()+"\t"+m.nextTime());
}
}
}
numWaiting.add(new AInoob(waitingMesgs.size(),createdMess,sentMess));
System.out.println(i+" !!!\t"+createdMess+"\t" +sentMess+"\n===========================================");
}
return failed/(failed+delivered);
}
public int createdMess(){
return createdMess;
}
public int sentMess(){
return sentMess;
}
public static void main(String[] args) {
Sim sim = new Sim();
ArrayList<AInoob> waiting = new ArrayList<AInoob>();
double missedRatio = sim.run(DURATION, waiting);
System.out.println("missedRatio " + missedRatio);
System.out.println("Number of waiting jobs after each time step:");
for(int i=0; i<waiting.size(); i++)
System.out.println(i + "\t" + waiting.get(i));
System.out.println("missedRatio " + missedRatio);
}
}
| 3,445
| 0.630769
| 0.623512
| 113
| 29.486725
| 27.311094
| 115
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 3.017699
| false
| false
|
13
|
a38d17e20ec84d7f5c0ba170579b073def8d1145
| 37,941,741,124,605
|
01d3f57ca79c02c5e67aaccf4eb8a54a9e294212
|
/src/main/java/com/ken/mall/web/admin/auth/UserRealm.java
|
72cc6625bf534eab965b315c3109b96c824bd917
|
[] |
no_license
|
a236813207/e-mall
|
https://github.com/a236813207/e-mall
|
884e0a90187b0e2f184d7b42be7881bc21d8d7fe
|
001cf35fafc82f479959e76f9a8df65fdc857596
|
refs/heads/master
| 2022-09-13T02:52:55.407000
| 2020-08-19T08:22:32
| 2020-08-19T08:22:32
| 182,767,016
| 2
| 0
| null | false
| 2022-09-01T23:05:45
| 2019-04-22T11:19:44
| 2021-09-17T13:12:17
| 2022-09-01T23:05:42
| 5,582
| 1
| 0
| 4
|
Java
| false
| false
|
package com.ken.mall.web.admin.auth;
import com.ken.mall.entity.rbac.SysUser;
import com.ken.mall.service.rbac.SysUserService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;
public class UserRealm extends AuthorizingRealm {
@Autowired
private SysUserService userService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
String username = (String)principals.getPrimaryPrincipal();
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
authorizationInfo.setRoles(userService.findRoleNames(username));
authorizationInfo.setStringPermissions(userService.findPermissions(username));
return authorizationInfo;
}
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
String username = (String)token.getPrincipal();
SysUser user = userService.findByUsername(username);
if(user == null) {
throw new UnknownAccountException("账号不存在");//没找到帐号
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
user, //用户
user.getPassword(), //密码
ByteSource.Util.bytes(user.getSalt()),//salt=username+salt
getName() //realm name
);
return authenticationInfo;
}
}
|
UTF-8
|
Java
| 1,734
|
java
|
UserRealm.java
|
Java
|
[] | null |
[] |
package com.ken.mall.web.admin.auth;
import com.ken.mall.entity.rbac.SysUser;
import com.ken.mall.service.rbac.SysUserService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;
public class UserRealm extends AuthorizingRealm {
@Autowired
private SysUserService userService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
String username = (String)principals.getPrimaryPrincipal();
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
authorizationInfo.setRoles(userService.findRoleNames(username));
authorizationInfo.setStringPermissions(userService.findPermissions(username));
return authorizationInfo;
}
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
String username = (String)token.getPrincipal();
SysUser user = userService.findByUsername(username);
if(user == null) {
throw new UnknownAccountException("账号不存在");//没找到帐号
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
user, //用户
user.getPassword(), //密码
ByteSource.Util.bytes(user.getSalt()),//salt=username+salt
getName() //realm name
);
return authenticationInfo;
}
}
| 1,734
| 0.732708
| 0.732708
| 46
| 36.086956
| 29.901888
| 116
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.521739
| false
| false
|
13
|
e4fc9ddd646a9870aaf7a68a3ad75e2b06aae686
| 13,202,729,496,189
|
92be3c2c6574b3929be0937b27fd196fd28a981b
|
/src/Java1/HelloWorld.java
|
d78f3c50fc9b465973bcc6bc9338b8648ba94fea
|
[] |
no_license
|
rcortezk9/codeup-java-exercises
|
https://github.com/rcortezk9/codeup-java-exercises
|
69ea56e8c0c0753648629543cfd1a38ecaa97bad
|
cc5af881cf8e3f437adbbe5742e82d57e1965374
|
refs/heads/master
| 2021-01-23T21:03:25.667000
| 2017-05-26T14:36:26
| 2017-05-26T14:36:26
| 90,673,564
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package Java1;
/**
* Created by renecortez on 5/8/17.
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Pinnacle!");
// int myFavoritNumber = 7;
// System.out.println(myFavoritNumber);
//
// String myString = "This is my String!";
// //myString = 'A';
// //myString = '3.14159';
// System.out.println(myString);
//
// long myNumber = 123l;
// System.out.println(myNumber);
}
}
|
UTF-8
|
Java
| 501
|
java
|
HelloWorld.java
|
Java
|
[
{
"context": "package Java1;\n\n/**\n * Created by renecortez on 5/8/17.\n */\npublic class HelloWorld {\n publ",
"end": 44,
"score": 0.9947143793106079,
"start": 34,
"tag": "USERNAME",
"value": "renecortez"
}
] | null |
[] |
package Java1;
/**
* Created by renecortez on 5/8/17.
*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Pinnacle!");
// int myFavoritNumber = 7;
// System.out.println(myFavoritNumber);
//
// String myString = "This is my String!";
// //myString = 'A';
// //myString = '3.14159';
// System.out.println(myString);
//
// long myNumber = 123l;
// System.out.println(myNumber);
}
}
| 501
| 0.562874
| 0.532934
| 21
| 22.761906
| 17.94676
| 49
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.47619
| false
| false
|
13
|
be9595f4f3286895dc76472a4276108dfcbcf46b
| 27,968,827,087,392
|
e4393e467d0da61567621b280471640b875204ae
|
/src/main/java/com/myproject/e_emlak/entity/Customer.java
|
08d09d04ffc672fdc6efc1390f2a1482871ed13f
|
[] |
no_license
|
bagraercan/e-emlak
|
https://github.com/bagraercan/e-emlak
|
15b3c2ce14bc63d9dcb00278af3a71ec83571bc8
|
d9e06baff9f86e438b7d047b2f31aaca79a1b2a5
|
refs/heads/master
| 2020-05-25T08:13:14.277000
| 2020-05-15T02:32:51
| 2020-05-15T02:32:51
| 187,704,425
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.myproject.e_emlak.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "customers")
@EqualsAndHashCode(callSuper = false)
public class Customer extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.AUTO )
private Long customerID;
private int numberOfFollowed;
@JoinColumn(name = "personId",unique = true)
@OneToOne(optional = false,fetch = FetchType.LAZY)
private Person personId;
}
|
UTF-8
|
Java
| 611
|
java
|
Customer.java
|
Java
|
[] | null |
[] |
package com.myproject.e_emlak.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "customers")
@EqualsAndHashCode(callSuper = false)
public class Customer extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.AUTO )
private Long customerID;
private int numberOfFollowed;
@JoinColumn(name = "personId",unique = true)
@OneToOne(optional = false,fetch = FetchType.LAZY)
private Person personId;
}
| 611
| 0.765957
| 0.765957
| 27
| 21.629629
| 17.299429
| 54
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.407407
| false
| false
|
13
|
df88fff5dc4bec871590b667d431ecac569511cf
| 24,129,126,290,721
|
5ce01578e0a384f603e872ddb2d58b768c963915
|
/common-admin/src/main/java/com/itsure/admin/entity/Article.java
|
90156545fb6188cb4ab930a488acea83d381cb2e
|
[] |
no_license
|
loveblog1314/blog-slice
|
https://github.com/loveblog1314/blog-slice
|
802d854b1b512240a734f4faa9ee5be117cd2287
|
1b3958fca93a7603059fde71a95a67c4775733d7
|
refs/heads/master
| 2022-06-26T22:06:55.785000
| 2019-08-18T06:13:11
| 2019-08-18T06:13:11
| 197,292,576
| 1
| 0
| null | false
| 2022-06-21T01:29:42
| 2019-07-17T01:31:34
| 2020-05-22T08:42:31
| 2022-06-21T01:29:39
| 5,874
| 1
| 0
| 4
|
Roff
| false
| false
|
package com.itsure.admin.entity;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 用户文章
*
* @author itsure
* @email 494471788@qq.com
* @date 2019-07-08 13:01:19
*/
@TableName("sys_article")
public class Article extends Model<Article> {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value="id", type= IdType.AUTO)
private Integer id;
/**
*
*/
@TableField("menu_id")
private Integer menuId;
/**
*
*/
@TableField("title")
private String title;
@TableField("desc")
private String desc;
/**
*
*/
@TableField("content")
private String content;
/**
*
*/
@TableField("create_time")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
/**
*
*/
@TableField("thumb")
private String thumb;
/**
*
*/
@TableField("origin_type")
private Integer originType;
/**
*
*/
@TableField("author")
private String author;
@TableField("skill_stack")
private String skillStack;
/**
*
*/
@TableField("hits")
private Integer hits;
@TableField("status")
private Integer status;
/**
*
*/
@TableField("update_time")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date updateTime;
@TableField("word_count")
private Integer wordCount;
@TableField("code_url")
private String codeUrl;
@TableField("reference_url")
private String referenceUrl;
/**
* 设置:
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取:
*/
public Integer getId() {
return id;
}
/**
* 设置:
*/
public void setMenuId(Integer menuId) {
this.menuId = menuId;
}
/**
* 获取:
*/
public Integer getMenuId() {
return menuId;
}
/**
* 设置:
*/
public void setTitle(String title) {
this.title = title;
}
/**
* 获取:
*/
public String getTitle() {
return title;
}
/**
* 设置:
*/
public void setContent(String content) {
this.content = content;
}
/**
* 获取:
*/
public String getContent() {
return content;
}
/**
* 设置:
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:
*/
public void setThumb(String thumb) {
this.thumb = thumb;
}
/**
* 获取:
*/
public String getThumb() {
return thumb;
}
/**
* 设置:
*/
public void setOriginType(Integer originType) {
this.originType = originType;
}
/**
* 获取:
*/
public Integer getOriginType() {
return originType;
}
/**
* 设置:
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* 获取:
*/
public String getAuthor() {
return author;
}
/**
* 设置:
*/
public void setHits(Integer hits) {
this.hits = hits;
}
/**
* 获取:
*/
public Integer getHits() {
return hits;
}
/**
* 设置:
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:
*/
public Date getUpdateTime() {
return updateTime;
}
@Override
protected Serializable pkVal() {
return this.id;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getSkillStack() {
return skillStack;
}
public void setSkillStack(String skillStack) {
this.skillStack = skillStack;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getWordCount() {
return wordCount;
}
public void setWordCount(Integer wordCount) {
this.wordCount = wordCount;
}
public String getCodeUrl() {
return codeUrl;
}
public void setCodeUrl(String codeUrl) {
this.codeUrl = codeUrl;
}
public String getReferenceUrl() {
return referenceUrl;
}
public void setReferenceUrl(String referenceUrl) {
this.referenceUrl = referenceUrl;
}
@java.lang.Override
public java.lang.String toString() {
return "Article{" +
"id=" + id +
", menuId=" + menuId +
", title='" + title + '\'' +
", desc='" + desc + '\'' +
", content='" + content + '\'' +
", createTime=" + createTime +
", thumb='" + thumb + '\'' +
", originType=" + originType +
", author='" + author + '\'' +
", skillStack='" + skillStack + '\'' +
", hits=" + hits +
", status=" + status +
", updateTime=" + updateTime +
", wordCount=" + wordCount +
", codeUrl='" + codeUrl + '\'' +
", referenceUrl='" + referenceUrl + '\'' +
'}';
}
}
|
UTF-8
|
Java
| 5,024
|
java
|
Article.java
|
Java
|
[
{
"context": "import java.util.Date;\n\n/**\n * 用户文章\n * \n * @author itsure\n * @email 494471788@qq.com\n * @date 2019-07-08 13",
"end": 484,
"score": 0.9995906352996826,
"start": 478,
"tag": "USERNAME",
"value": "itsure"
},
{
"context": "ate;\n\n/**\n * 用户文章\n * \n * @author itsure\n * @email 494471788@qq.com\n * @date 2019-07-08 13:01:19\n */\n@TableName(\"sys_",
"end": 511,
"score": 0.9998295307159424,
"start": 495,
"tag": "EMAIL",
"value": "494471788@qq.com"
},
{
"context": "\t\", originType=\" + originType +\n\t\t\t\t\", author='\" + author + '\\'' +\n\t\t\t\t\", skillStack='\" + skillStack + '\\''",
"end": 4628,
"score": 0.797060489654541,
"start": 4622,
"tag": "NAME",
"value": "author"
}
] | null |
[] |
package com.itsure.admin.entity;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 用户文章
*
* @author itsure
* @email <EMAIL>
* @date 2019-07-08 13:01:19
*/
@TableName("sys_article")
public class Article extends Model<Article> {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value="id", type= IdType.AUTO)
private Integer id;
/**
*
*/
@TableField("menu_id")
private Integer menuId;
/**
*
*/
@TableField("title")
private String title;
@TableField("desc")
private String desc;
/**
*
*/
@TableField("content")
private String content;
/**
*
*/
@TableField("create_time")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date createTime;
/**
*
*/
@TableField("thumb")
private String thumb;
/**
*
*/
@TableField("origin_type")
private Integer originType;
/**
*
*/
@TableField("author")
private String author;
@TableField("skill_stack")
private String skillStack;
/**
*
*/
@TableField("hits")
private Integer hits;
@TableField("status")
private Integer status;
/**
*
*/
@TableField("update_time")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date updateTime;
@TableField("word_count")
private Integer wordCount;
@TableField("code_url")
private String codeUrl;
@TableField("reference_url")
private String referenceUrl;
/**
* 设置:
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取:
*/
public Integer getId() {
return id;
}
/**
* 设置:
*/
public void setMenuId(Integer menuId) {
this.menuId = menuId;
}
/**
* 获取:
*/
public Integer getMenuId() {
return menuId;
}
/**
* 设置:
*/
public void setTitle(String title) {
this.title = title;
}
/**
* 获取:
*/
public String getTitle() {
return title;
}
/**
* 设置:
*/
public void setContent(String content) {
this.content = content;
}
/**
* 获取:
*/
public String getContent() {
return content;
}
/**
* 设置:
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取:
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置:
*/
public void setThumb(String thumb) {
this.thumb = thumb;
}
/**
* 获取:
*/
public String getThumb() {
return thumb;
}
/**
* 设置:
*/
public void setOriginType(Integer originType) {
this.originType = originType;
}
/**
* 获取:
*/
public Integer getOriginType() {
return originType;
}
/**
* 设置:
*/
public void setAuthor(String author) {
this.author = author;
}
/**
* 获取:
*/
public String getAuthor() {
return author;
}
/**
* 设置:
*/
public void setHits(Integer hits) {
this.hits = hits;
}
/**
* 获取:
*/
public Integer getHits() {
return hits;
}
/**
* 设置:
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取:
*/
public Date getUpdateTime() {
return updateTime;
}
@Override
protected Serializable pkVal() {
return this.id;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getSkillStack() {
return skillStack;
}
public void setSkillStack(String skillStack) {
this.skillStack = skillStack;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getWordCount() {
return wordCount;
}
public void setWordCount(Integer wordCount) {
this.wordCount = wordCount;
}
public String getCodeUrl() {
return codeUrl;
}
public void setCodeUrl(String codeUrl) {
this.codeUrl = codeUrl;
}
public String getReferenceUrl() {
return referenceUrl;
}
public void setReferenceUrl(String referenceUrl) {
this.referenceUrl = referenceUrl;
}
@java.lang.Override
public java.lang.String toString() {
return "Article{" +
"id=" + id +
", menuId=" + menuId +
", title='" + title + '\'' +
", desc='" + desc + '\'' +
", content='" + content + '\'' +
", createTime=" + createTime +
", thumb='" + thumb + '\'' +
", originType=" + originType +
", author='" + author + '\'' +
", skillStack='" + skillStack + '\'' +
", hits=" + hits +
", status=" + status +
", updateTime=" + updateTime +
", wordCount=" + wordCount +
", codeUrl='" + codeUrl + '\'' +
", referenceUrl='" + referenceUrl + '\'' +
'}';
}
}
| 5,015
| 0.609681
| 0.604371
| 291
| 15.828178
| 15.285081
| 67
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.501718
| false
| false
|
13
|
b9c00345d148ad2c241a69aff43e632b45433002
| 352,187,350,448
|
eb5af3e0f13a059749b179c988c4c2f5815feb0f
|
/wnxa38_spring/spring_04_integratembatis/src/test/java/com/woniu/AppTest.java
|
bc855443a0f1a0f1c3a1f293a0c96d8d44543a05
|
[] |
no_license
|
xiakai007/wokniuxcode
|
https://github.com/xiakai007/wokniuxcode
|
ae686753da5ec3dd607b0246ec45fb11cf6b8968
|
d9918fb349bc982f0ee9d3ea3bf7537e11d062a2
|
refs/heads/master
| 2023-04-13T02:54:15.675000
| 2021-05-02T05:09:47
| 2021-05-02T05:09:47
| 363,570,147
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.woniu;
import static org.junit.Assert.assertTrue;
import com.alibaba.druid.pool.DruidDataSource;
import com.woniu.mapper.DeptMapper;
import com.woniu.pojo.Dept;
import com.woniu.service.DeptService;
import lombok.extern.log4j.Log4j2;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
public class AppTest
{
@Test
public void testDatasource(){
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//DruidDataSource dataSource = (DruidDataSource) context.getBean("dataSource");
//System.out.println("初始连接池数量:"+dataSource.getInitialSize());
//log.info("初始连接池数量:"+dataSource.getInitialSize());
//DeptMapper deptMapper=(DeptMapper) context.getBean("deptMapper");
//List<Dept> deptList = deptMapper.selectDeptAll();
DeptService deptService = (DeptService) context.getBean("deptServiceImpl");
List<Dept> deptList=deptService.findDeptAll();
for(Dept dept:deptList){
System.out.println(dept.getId()+"\t"+dept.getDname());
}
}
}
|
UTF-8
|
Java
| 1,235
|
java
|
AppTest.java
|
Java
|
[] | null |
[] |
package com.woniu;
import static org.junit.Assert.assertTrue;
import com.alibaba.druid.pool.DruidDataSource;
import com.woniu.mapper.DeptMapper;
import com.woniu.pojo.Dept;
import com.woniu.service.DeptService;
import lombok.extern.log4j.Log4j2;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
public class AppTest
{
@Test
public void testDatasource(){
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//DruidDataSource dataSource = (DruidDataSource) context.getBean("dataSource");
//System.out.println("初始连接池数量:"+dataSource.getInitialSize());
//log.info("初始连接池数量:"+dataSource.getInitialSize());
//DeptMapper deptMapper=(DeptMapper) context.getBean("deptMapper");
//List<Dept> deptList = deptMapper.selectDeptAll();
DeptService deptService = (DeptService) context.getBean("deptServiceImpl");
List<Dept> deptList=deptService.findDeptAll();
for(Dept dept:deptList){
System.out.println(dept.getId()+"\t"+dept.getDname());
}
}
}
| 1,235
| 0.732336
| 0.729842
| 32
| 36.59375
| 28.766148
| 98
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.625
| false
| false
|
13
|
d1a38182bed33a7a6bcc1bc952514d888d3e40b4
| 19,765,439,523,596
|
688a9051495b72ced622a7f1d128bf277659917f
|
/crm-core/src/main/java/com/chinahanjiang/crm/pojo/Groups.java
|
ed624d936bac75ec57754369d43ec5f9f88d2a26
|
[] |
no_license
|
ChinaHanjiang/hj-crm-project
|
https://github.com/ChinaHanjiang/hj-crm-project
|
4c930e70ad565e3ad9da4627537a828803d949a8
|
a332eda0b01aa91ce70618a581d479543c69ac98
|
refs/heads/master
| 2020-05-21T21:01:13.341000
| 2017-07-20T07:11:46
| 2017-07-20T07:11:46
| 65,654,658
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.chinahanjiang.crm.pojo;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
* 集团
*
* @author tree
*
*/
@Entity
@Table(name = "Groups")
public class Groups {
private int id;
private String name;
private String code; // 集团编码
private int isDelete;
private Timestamp createTime;
private Timestamp updateTime;
private User user;
private String remarks;
public Groups() {
this.isDelete = 1;
}
public Groups(int id, String name, String code, int isDelete,
Timestamp createTime, Timestamp updateTime, User user,
String remarks) {
super();
this.id = id;
this.name = name;
this.code = code;
this.isDelete = isDelete;
this.createTime = createTime;
this.updateTime = updateTime;
this.user = user;
this.remarks = remarks;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "g_id", unique = true, nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "g_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "g_code")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Column(name = "g_isDelete")
public int getIsDelete() {
return isDelete;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
@Column(name = "g_createTime")
public Timestamp getCreateTime() {
return createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
@Column(name = "g_updateTime")
public Timestamp getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Timestamp updateTime) {
this.updateTime = updateTime;
}
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "g_uid", referencedColumnName = "u_id")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Column(name = "g_remarks")
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}
|
UTF-8
|
Java
| 2,553
|
java
|
Groups.java
|
Java
|
[
{
"context": ".persistence.Table;\r\n\r\n/**\r\n * 集团\r\n * \r\n * @author tree\r\n *\r\n */\r\n@Entity\r\n@Table(name = \"Groups\")\r\npubli",
"end": 429,
"score": 0.9986757636070251,
"start": 425,
"tag": "USERNAME",
"value": "tree"
}
] | null |
[] |
package com.chinahanjiang.crm.pojo;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
/**
* 集团
*
* @author tree
*
*/
@Entity
@Table(name = "Groups")
public class Groups {
private int id;
private String name;
private String code; // 集团编码
private int isDelete;
private Timestamp createTime;
private Timestamp updateTime;
private User user;
private String remarks;
public Groups() {
this.isDelete = 1;
}
public Groups(int id, String name, String code, int isDelete,
Timestamp createTime, Timestamp updateTime, User user,
String remarks) {
super();
this.id = id;
this.name = name;
this.code = code;
this.isDelete = isDelete;
this.createTime = createTime;
this.updateTime = updateTime;
this.user = user;
this.remarks = remarks;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "g_id", unique = true, nullable = false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name = "g_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "g_code")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Column(name = "g_isDelete")
public int getIsDelete() {
return isDelete;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
@Column(name = "g_createTime")
public Timestamp getCreateTime() {
return createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
@Column(name = "g_updateTime")
public Timestamp getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Timestamp updateTime) {
this.updateTime = updateTime;
}
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "g_uid", referencedColumnName = "u_id")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Column(name = "g_remarks")
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
}
| 2,553
| 0.666273
| 0.66588
| 134
| 16.962687
| 15.865294
| 62
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.253731
| false
| false
|
13
|
ea34363038d6a1a1909d0b8daf943bf17a7fdf90
| 11,398,843,217,735
|
51ed7fee3b295b9ff2d4155a970a0e682f672d79
|
/src/main/java/com/pzc/stocknet/datamodel/Currency.java
|
924d302cbc5b879af409fa981671f660bb9a4ffd
|
[] |
no_license
|
papaz1/stocknet
|
https://github.com/papaz1/stocknet
|
00593d5e5d08a07ad51e95e3304d5e44bdb36eab
|
0bc6f13d828c080abdc733097ae2856b2ad2f971
|
refs/heads/master
| 2021-07-11T08:16:01.111000
| 2020-06-02T17:13:52
| 2020-06-02T17:13:52
| 147,523,571
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.pzc.stocknet.datamodel;
public enum Currency {
SEK, USD
}
|
UTF-8
|
Java
| 77
|
java
|
Currency.java
|
Java
|
[] | null |
[] |
package com.pzc.stocknet.datamodel;
public enum Currency {
SEK, USD
}
| 77
| 0.701299
| 0.701299
| 5
| 13.4
| 13.365627
| 35
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.6
| false
| false
|
13
|
bbad535739ca37a7ccf2d0553c83f18b983ec0b8
| 31,112,743,096,996
|
19ad1c5637c54a43cb13cb88e23a240f6bd46333
|
/src/test/java/com/github/ninerules/NineRulesValidatorTest.java
|
b30dd9b0c258cd2d8d715b934ff542e429cf34c6
|
[
"Apache-2.0"
] |
permissive
|
tamada/9rules
|
https://github.com/tamada/9rules
|
4f46717b7b08affbff6d3b127bd29a41ac3eda13
|
f79070f59b7020109595bc6494a5c74d83edf8d3
|
refs/heads/master
| 2021-08-17T15:26:48.673000
| 2021-01-02T05:46:50
| 2021-01-02T05:46:50
| 66,689,530
| 6
| 4
|
Apache-2.0
| false
| 2021-01-02T05:46:51
| 2016-08-27T01:36:49
| 2020-12-23T06:54:47
| 2021-01-02T05:46:51
| 1,554
| 1
| 4
| 6
|
Java
| false
| false
|
package com.github.ninerules;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import com.github.ninerules.entities.Context;
import org.junit.Before;
import org.junit.Test;
import com.github.ninerules.entities.FileName;
import com.github.ninerules.entities.LineCountsBuilder;
import com.github.ninerules.parameters.NullParameter;
import com.github.ninerules.rules.accessor.NoAccessorValidator;
import com.github.ninerules.rules.results.Results;
import com.github.ninerules.rules.violations.Violation;
import com.github.ninerules.rules.violations.ViolationType;
import com.github.ninerules.traverser.Traverser;
public class NineRulesValidatorTest {
private Path path = Paths.get("src/test/resources/hello/src/main/java");
private List<Path> list;
@Before
public void setUp(){
Traverser traverser = new Traverser((name, attributes) -> name.toString().endsWith(".java"));
list = traverser.stream(path)
.collect(Collectors.toList());
}
@Test
public void testBasic(){
NineRulesValidator validator = new NineRulesValidator(new Context(StrictLevel.STRICT, false));
Results results = validator.validate(list);
assertThat(results.contains(
new FileName(path.resolve("sample/hello/HelloWorld.java")),
new Violation(new ViolationType(NoAccessorValidator.SETTER, NullParameter.parameter()),
LineCountsBuilder.builder().of(10).build())
), is(true));
assertThat(results.contains(
new FileName(path.resolve("sample/hello/HelloWorld.java")),
new Violation(new ViolationType(NoAccessorValidator.GETTER, NullParameter.parameter()),
LineCountsBuilder.builder().of(14).build())
), is(true));
}
}
|
UTF-8
|
Java
| 1,932
|
java
|
NineRulesValidatorTest.java
|
Java
|
[] | null |
[] |
package com.github.ninerules;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import com.github.ninerules.entities.Context;
import org.junit.Before;
import org.junit.Test;
import com.github.ninerules.entities.FileName;
import com.github.ninerules.entities.LineCountsBuilder;
import com.github.ninerules.parameters.NullParameter;
import com.github.ninerules.rules.accessor.NoAccessorValidator;
import com.github.ninerules.rules.results.Results;
import com.github.ninerules.rules.violations.Violation;
import com.github.ninerules.rules.violations.ViolationType;
import com.github.ninerules.traverser.Traverser;
public class NineRulesValidatorTest {
private Path path = Paths.get("src/test/resources/hello/src/main/java");
private List<Path> list;
@Before
public void setUp(){
Traverser traverser = new Traverser((name, attributes) -> name.toString().endsWith(".java"));
list = traverser.stream(path)
.collect(Collectors.toList());
}
@Test
public void testBasic(){
NineRulesValidator validator = new NineRulesValidator(new Context(StrictLevel.STRICT, false));
Results results = validator.validate(list);
assertThat(results.contains(
new FileName(path.resolve("sample/hello/HelloWorld.java")),
new Violation(new ViolationType(NoAccessorValidator.SETTER, NullParameter.parameter()),
LineCountsBuilder.builder().of(10).build())
), is(true));
assertThat(results.contains(
new FileName(path.resolve("sample/hello/HelloWorld.java")),
new Violation(new ViolationType(NoAccessorValidator.GETTER, NullParameter.parameter()),
LineCountsBuilder.builder().of(14).build())
), is(true));
}
}
| 1,932
| 0.719979
| 0.717909
| 51
| 36.882355
| 28.528381
| 102
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.705882
| false
| false
|
13
|
ecce7ed2221f80ae8d20527a1ba70c1878394282
| 26,534,307,974,296
|
519b53b6252afe41b81c93fef2c22480cbfb1123
|
/Tree/LowestCommonAncesstorOfBinarySearchTree.java
|
588ded59cf83fd92772efe2977a0f529149c7b92
|
[] |
no_license
|
AtefeMsb/LeetCode
|
https://github.com/AtefeMsb/LeetCode
|
66a489363a010beb80624e5d01331dc52c7ac2a9
|
95a686c028784c265d2dfde623cc58fb93a71c92
|
refs/heads/master
| 2022-07-11T09:44:04.816000
| 2022-06-08T19:35:20
| 2022-06-08T19:35:20
| 211,967,972
| 3
| 2
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package Tree;
// in this answer we are looking for spilit point
/**
* recursive
* time: O(n)
* space: O(n) recursion stack
*/
class Solution {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
// both p and q less than root
if (p.val < root.val && q.val < root.val) {
return lowestCommonAncestor(root.left, p, q);
}
// both p and q more than root
if (p.val > root.val && q.val > root.val) {
return lowestCommonAncestor(root.right, p, q);
}
// We have found the split point, i.e. the LCA node
return root;
}
}
// --------------------------------------------------------
/**
* iterative
* time: O(n)
* space: O(1)
*/
class Solution2 {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
while (root != null) {
// If both p and q are smaller than parent
if (p.val < root.val && q.val < root.val) {
root = root.left;
// If both p and q are greater than parent
} else if (p.val > root.val && q.val > root.val) {
root = root.right;
// We have found the split point, i.e. the LCA node.
} else {
return root;
}
}
return null;
}
}
|
UTF-8
|
Java
| 1,373
|
java
|
LowestCommonAncesstorOfBinarySearchTree.java
|
Java
|
[] | null |
[] |
package Tree;
// in this answer we are looking for spilit point
/**
* recursive
* time: O(n)
* space: O(n) recursion stack
*/
class Solution {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
// both p and q less than root
if (p.val < root.val && q.val < root.val) {
return lowestCommonAncestor(root.left, p, q);
}
// both p and q more than root
if (p.val > root.val && q.val > root.val) {
return lowestCommonAncestor(root.right, p, q);
}
// We have found the split point, i.e. the LCA node
return root;
}
}
// --------------------------------------------------------
/**
* iterative
* time: O(n)
* space: O(1)
*/
class Solution2 {
public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
while (root != null) {
// If both p and q are smaller than parent
if (p.val < root.val && q.val < root.val) {
root = root.left;
// If both p and q are greater than parent
} else if (p.val > root.val && q.val > root.val) {
root = root.right;
// We have found the split point, i.e. the LCA node.
} else {
return root;
}
}
return null;
}
}
| 1,373
| 0.497451
| 0.495994
| 49
| 27.040817
| 23.269459
| 81
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.367347
| false
| false
|
13
|
8909a41e845ddba26675d7882d2da242e372df03
| 17,025,250,420,751
|
dade6a1c7fe633e0e41d992517c10cb7522ff1b1
|
/src/main/java/jp/co/rpg/dao/EnemyDao.java
|
3087b93b4432af6c75a6a2916bc67f4e8d1485b9
|
[] |
no_license
|
s14333591/rpgrpg
|
https://github.com/s14333591/rpgrpg
|
dcb7bfbfc92565381f9aba2890884b6754a7f8cf
|
96234dec015be432df1e99433eafddfdfc538ca5
|
refs/heads/master
| 2021-02-04T09:59:09.494000
| 2020-02-28T06:37:44
| 2020-02-28T06:37:44
| 243,653,291
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package jp.co.rpg.dao;
import java.util.List;
import jp.co.rpg.entity.Enemy;
import jp.co.rpg.entity.User;
public interface EnemyDao {
List<Enemy> findAppear(User user);
List<Enemy> findBoss();
}
|
UTF-8
|
Java
| 205
|
java
|
EnemyDao.java
|
Java
|
[] | null |
[] |
package jp.co.rpg.dao;
import java.util.List;
import jp.co.rpg.entity.Enemy;
import jp.co.rpg.entity.User;
public interface EnemyDao {
List<Enemy> findAppear(User user);
List<Enemy> findBoss();
}
| 205
| 0.726829
| 0.726829
| 15
| 12.666667
| 13.743686
| 35
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.533333
| false
| false
|
13
|
9ae7410a7bb2eea4f22fd9ef26a68ad664e37efb
| 7,567,732,385,149
|
58c5ba99e927e6696f96ddf9d325a868dc2f36a9
|
/src/main/java/playingcards/CardsFactory.java
|
2c2e239663c8c33de40c5e665b28e1226a248e9a
|
[] |
no_license
|
ggarunchik/SolitaireSimulator
|
https://github.com/ggarunchik/SolitaireSimulator
|
de2b1dc514e99572a344f1013cb837997860ae2a
|
85341d09639c5dfcc24ad081496e275ec8b71f4d
|
refs/heads/master
| 2023-03-14T17:22:16.998000
| 2021-03-22T21:13:33
| 2021-03-22T21:13:33
| 344,784,716
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package playingcards;
public interface CardsFactory {
Card createCard(String cardCode) throws InvalidCardException;
Card createRandomCard() throws InvalidCardException;
}
|
UTF-8
|
Java
| 181
|
java
|
CardsFactory.java
|
Java
|
[] | null |
[] |
package playingcards;
public interface CardsFactory {
Card createCard(String cardCode) throws InvalidCardException;
Card createRandomCard() throws InvalidCardException;
}
| 181
| 0.80663
| 0.80663
| 7
| 24.857143
| 25.181787
| 65
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.428571
| false
| false
|
13
|
5704167fae65d9a7954c57840cf911d894190ecb
| 19,559,281,069,007
|
991076a2a2938c249e913d4a183235affc6ef78f
|
/src/main/java/com/wolsx/summarize/proxy/proxywithadvice/CunstomClass.java
|
5363c4d0430434a8f202eda93005869a86a99eba
|
[] |
no_license
|
hysgit/summarize
|
https://github.com/hysgit/summarize
|
5c0ace07ba7ca23706299fb6db5c56592d69e571
|
95aa0818ba3157fead2fbefa2f21233ab792f8cf
|
refs/heads/master
| 2022-06-24T19:07:04.582000
| 2019-07-09T03:40:04
| 2019-07-09T03:40:04
| 55,577,580
| 0
| 0
| null | false
| 2022-06-21T00:49:26
| 2016-04-06T05:14:03
| 2019-07-09T03:40:55
| 2022-06-21T00:49:23
| 140
| 0
| 0
| 4
|
Java
| false
| false
|
package com.wolsx.summarize.proxy.proxywithadvice;
/**
* Created by hy on 6/29/16.
*/
public class CunstomClass {
@Override
public boolean equals(Object obj) {
return (this.hashCode() == obj.hashCode());
}
}
|
UTF-8
|
Java
| 231
|
java
|
CunstomClass.java
|
Java
|
[
{
"context": "ummarize.proxy.proxywithadvice;\n\n/**\n * Created by hy on 6/29/16.\n */\npublic class CunstomClass {\n @",
"end": 72,
"score": 0.9363254308700562,
"start": 70,
"tag": "USERNAME",
"value": "hy"
}
] | null |
[] |
package com.wolsx.summarize.proxy.proxywithadvice;
/**
* Created by hy on 6/29/16.
*/
public class CunstomClass {
@Override
public boolean equals(Object obj) {
return (this.hashCode() == obj.hashCode());
}
}
| 231
| 0.649351
| 0.627706
| 11
| 20
| 18.944897
| 51
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.181818
| false
| false
|
13
|
2df7be32d42c7e642a1c9c9c874bcc71212f3462
| 20,942,260,540,319
|
4682fc504653d2c73945d71509ccb36950a30713
|
/src/sort/MergeSort.java
|
a770c94b7c428163bc0c8b0521cdea5d4041c22c
|
[] |
no_license
|
caihuazhj/AlgoExercise
|
https://github.com/caihuazhj/AlgoExercise
|
1cf5ae153fcf1224c635b7e4ba5d1828f6035a65
|
fd9b6ef6bacc5f5acb1dfbb0ab3353b9c23a6bee
|
refs/heads/master
| 2021-04-03T05:26:10.311000
| 2018-09-03T09:18:59
| 2018-09-03T09:18:59
| 125,063,283
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package sort;
import java.util.Arrays;
public class MergeSort {
public static void mergeSort(int[] a){
int[] temp = new int[a.length]; //开辟原始数组空间,避免频繁开辟空间,长度与a相同
MergeSortIteration(a,a.length,temp);
// devideSort(a,0,a.length-1,temp);
}
//递归实现的归并排序
public static void devideSort(int[]a,int left,int right,int[] temp){
if(left<right){
int mid = (left+right)/2;
devideSort(a,left,mid,temp);
devideSort(a,mid+1,right,temp);
merge(a,left,mid,right,temp);
}
}
//合并方法
public static void merge(int[]a,int left,int mid,int right,int[] temp){
int i =left; //左序列指针
int j = mid+1; //右序列指针
int t=0;//temp指针
//比较左右两序列的值,填入temp
while (i<=mid &&j<=right){
if(a[i]<=a[j]){
temp[t++] = a[i++];
}else{
temp[t++] = a[j++];
}
}
//将左序列剩余元素全部填入temp
while (i<=mid){
temp[t++] = a[i++];
}
//将右序列剩余元素全部填入temp
while (j<=right){
temp[t++] = a[j++];
}
t= 0;
//将有序数据填回原数组
while (left<=right){
a[left++] = temp[t++];
}
}
//非递归实现归并排序
public static void MergeSortIteration(int A[], int len,int[] temp){
int left, mid, right;// 子数组索引,前一个为A[left...mid],后一个子数组为A[mid+1...right]
for (int i = 1; i < len; i *= 2) // 子数组的大小i初始为1,每轮翻倍
{
left = 0;
while (left + i < len) // 后一个子数组存在(需要归并)
{
mid = left + i - 1;
right = mid + i < len ? mid + i : len - 1;// 后一个子数组大小可能不够
merge(A, left, mid, right,temp);
left = right + 1; // 前一个子数组索引向后移动
}
}
}
public static void main(String[] args) {
int[] a = {4,2,6,150,7,9,12,5,123,3};
mergeSort(a);
System.out.println(Arrays.toString(a));
}
}
|
UTF-8
|
Java
| 2,360
|
java
|
MergeSort.java
|
Java
|
[] | null |
[] |
package sort;
import java.util.Arrays;
public class MergeSort {
public static void mergeSort(int[] a){
int[] temp = new int[a.length]; //开辟原始数组空间,避免频繁开辟空间,长度与a相同
MergeSortIteration(a,a.length,temp);
// devideSort(a,0,a.length-1,temp);
}
//递归实现的归并排序
public static void devideSort(int[]a,int left,int right,int[] temp){
if(left<right){
int mid = (left+right)/2;
devideSort(a,left,mid,temp);
devideSort(a,mid+1,right,temp);
merge(a,left,mid,right,temp);
}
}
//合并方法
public static void merge(int[]a,int left,int mid,int right,int[] temp){
int i =left; //左序列指针
int j = mid+1; //右序列指针
int t=0;//temp指针
//比较左右两序列的值,填入temp
while (i<=mid &&j<=right){
if(a[i]<=a[j]){
temp[t++] = a[i++];
}else{
temp[t++] = a[j++];
}
}
//将左序列剩余元素全部填入temp
while (i<=mid){
temp[t++] = a[i++];
}
//将右序列剩余元素全部填入temp
while (j<=right){
temp[t++] = a[j++];
}
t= 0;
//将有序数据填回原数组
while (left<=right){
a[left++] = temp[t++];
}
}
//非递归实现归并排序
public static void MergeSortIteration(int A[], int len,int[] temp){
int left, mid, right;// 子数组索引,前一个为A[left...mid],后一个子数组为A[mid+1...right]
for (int i = 1; i < len; i *= 2) // 子数组的大小i初始为1,每轮翻倍
{
left = 0;
while (left + i < len) // 后一个子数组存在(需要归并)
{
mid = left + i - 1;
right = mid + i < len ? mid + i : len - 1;// 后一个子数组大小可能不够
merge(A, left, mid, right,temp);
left = right + 1; // 前一个子数组索引向后移动
}
}
}
public static void main(String[] args) {
int[] a = {4,2,6,150,7,9,12,5,123,3};
mergeSort(a);
System.out.println(Arrays.toString(a));
}
}
| 2,360
| 0.457921
| 0.443069
| 73
| 26.671232
| 21.327873
| 79
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.945205
| false
| false
|
13
|
427bf3da3c5caee3d1e70d8c97f207f28df373f3
| 1,614,907,721,228
|
e94347d1a9adeaba41f46e858c28adb30b07952d
|
/src/main/java/FunctionLayer/entities/Shed.java
|
736476497d5117d2d21a5f5882fc1e5008f81590
|
[] |
no_license
|
Perlten/FogCarport
|
https://github.com/Perlten/FogCarport
|
5dab6a83d21d19db8171fe32191921c5903f4391
|
6d382f1c4c3184813c884ef405031bb981d2d3b0
|
refs/heads/master
| 2021-07-14T17:29:49.361000
| 2018-06-13T00:35:17
| 2018-06-13T00:35:17
| 130,669,452
| 1
| 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 FunctionLayer.entities;
/**
* Holds the specifications of a shed
*
* @author adamlass
*/
public class Shed {
private int length;
private int width;
public Shed(int length, int width) {
this.length = length;
this.width = width;
}
public int getLength() {
return length;
}
public int getWidth() {
return width;
}
public void setLength(int length) {
this.length = length;
}
public void setWidth(int width) {
this.width = width;
}
@Override
public String toString() {
return "Shed{" + "length=" + length + ", width=" + width + '}';
}
@Override
public int hashCode() {
int hash = 3;
hash = 71 * hash + this.length;
hash = 71 * hash + this.width;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Shed other = (Shed) obj;
if (this.length != other.length) {
return false;
}
if (this.width != other.width) {
return false;
}
return true;
}
}
|
UTF-8
|
Java
| 1,507
|
java
|
Shed.java
|
Java
|
[
{
"context": "* Holds the specifications of a shed\n *\n * @author adamlass\n */\npublic class Shed {\n\n private int length;\n",
"end": 282,
"score": 0.9994022846221924,
"start": 274,
"tag": "USERNAME",
"value": "adamlass"
}
] | 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 FunctionLayer.entities;
/**
* Holds the specifications of a shed
*
* @author adamlass
*/
public class Shed {
private int length;
private int width;
public Shed(int length, int width) {
this.length = length;
this.width = width;
}
public int getLength() {
return length;
}
public int getWidth() {
return width;
}
public void setLength(int length) {
this.length = length;
}
public void setWidth(int width) {
this.width = width;
}
@Override
public String toString() {
return "Shed{" + "length=" + length + ", width=" + width + '}';
}
@Override
public int hashCode() {
int hash = 3;
hash = 71 * hash + this.length;
hash = 71 * hash + this.width;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Shed other = (Shed) obj;
if (this.length != other.length) {
return false;
}
if (this.width != other.width) {
return false;
}
return true;
}
}
| 1,507
| 0.530192
| 0.526875
| 73
| 19.643835
| 17.203352
| 79
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.356164
| false
| false
|
13
|
8da5a8d345e0991519f5c113753b1773f21b32e9
| 28,295,244,582,862
|
c5bf625335545aa6eb80af096bd1fb9adad3917d
|
/src/sample/Ship.java
|
605112754a4a889cb64fa6874e22bfb341d7d04e
|
[] |
no_license
|
secretsurvivor/Battleships
|
https://github.com/secretsurvivor/Battleships
|
10cd0a94f490e6ddcafe27dfc9c4f1e5d9d3d61b
|
5de851ccb6a0befd4aa52f6f212a8a3d0e3cfa5c
|
refs/heads/main
| 2023-05-18T05:45:20.657000
| 2021-06-09T15:56:52
| 2021-06-09T15:56:52
| 375,403,659
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package sample;
import java.util.Arrays;
import java.util.Vector;
public class Ship {
final public int size;
final public Vector<String> positions;
public Ship(Vector<String> positions) {
this.positions = positions;
this.size = positions.size();
}
public Ship(String[] positions) {
this.positions = new Vector<>();
this.positions.addAll(Arrays.asList(positions));
this.size = this.positions.size();
}
}
|
UTF-8
|
Java
| 475
|
java
|
Ship.java
|
Java
|
[] | null |
[] |
package sample;
import java.util.Arrays;
import java.util.Vector;
public class Ship {
final public int size;
final public Vector<String> positions;
public Ship(Vector<String> positions) {
this.positions = positions;
this.size = positions.size();
}
public Ship(String[] positions) {
this.positions = new Vector<>();
this.positions.addAll(Arrays.asList(positions));
this.size = this.positions.size();
}
}
| 475
| 0.64
| 0.64
| 20
| 22.75
| 17.614979
| 56
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| false
| false
|
13
|
c09dc54fea58d3558d9987b4ba20d644e2d9119a
| 4,183,298,215,543
|
6bbb8eab7286c67282730534312e9b2bd469bb17
|
/app/src/main/java/www/knowledgeshare/com/knowledgeshare/utils/MyEditText.java
|
4adfa94f8af499d840b7a6eaede0497341a39f09
|
[] |
no_license
|
SYYP/knowledgeshare
|
https://github.com/SYYP/knowledgeshare
|
799025d1ec91bd6c914d6b6d46d1abc286b56a65
|
9e4de38234fb0f0b02ccf7c681e6dd3897e411fc
|
refs/heads/master
| 2018-09-09T00:35:48.916000
| 2018-06-05T02:55:26
| 2018-06-05T02:55:26
| 111,055,503
| 1
| 1
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package www.knowledgeshare.com.knowledgeshare.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.widget.EditText;
import android.widget.TextView;
@SuppressLint("AppCompatCustomView")
public class MyEditText extends TextView{
public MyEditText(Context context) {
super(context);
}
public MyEditText(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MyEditText(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback) {
super.setCustomSelectionActionModeCallback(actionModeCallback);
}
}
|
UTF-8
|
Java
| 892
|
java
|
MyEditText.java
|
Java
|
[] | null |
[] |
package www.knowledgeshare.com.knowledgeshare.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.widget.EditText;
import android.widget.TextView;
@SuppressLint("AppCompatCustomView")
public class MyEditText extends TextView{
public MyEditText(Context context) {
super(context);
}
public MyEditText(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MyEditText(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback) {
super.setCustomSelectionActionModeCallback(actionModeCallback);
}
}
| 892
| 0.767937
| 0.767937
| 31
| 27.806452
| 26.500662
| 94
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.580645
| false
| false
|
13
|
f69833d4e27a12f5f722831aee04b8b78dd86a77
| 26,860,725,490,770
|
3e7a4b4206b97a07ef536c9243696af2e17d253e
|
/src/main/java/com/cimstd/hbys/service/PatientService.java
|
c9e7944546f403824e3f750ba64871f035db17f0
|
[] |
no_license
|
cbidici/CIMHbys
|
https://github.com/cbidici/CIMHbys
|
ed770d0634bca1d9e3cf09f56606b2660a370d9f
|
58d2d039b522af344b1d8bdd3c7b7b5db68ad0a5
|
refs/heads/master
| 2021-01-19T13:31:51.177000
| 2017-04-12T21:51:47
| 2017-04-12T21:51:47
| 88,099,370
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.cimstd.hbys.service;
public interface PatientService {
}
|
UTF-8
|
Java
| 71
|
java
|
PatientService.java
|
Java
|
[] | null |
[] |
package com.cimstd.hbys.service;
public interface PatientService {
}
| 71
| 0.788732
| 0.788732
| 5
| 13.2
| 15.765786
| 33
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| false
| false
|
13
|
cad0b79e8b000671f27d107dc87c766a19996885
| 12,644,383,760,927
|
cd3dad1c0a33f809708fb6ccf76b9581d1dec2fc
|
/HMS 28 dec/HMS_&/HMS/src/frmPatChkotSearch.java
|
1e8878432db837fdc03b2a06fd0a1eec01326b5a
|
[] |
no_license
|
cur1ousss/HMS_New
|
https://github.com/cur1ousss/HMS_New
|
f65cbafbb667065d453d39c899d74594d7bc5f67
|
4cd564f896642aaaec8b7ea3b41048f51eca174b
|
refs/heads/main
| 2023-03-01T16:50:26.645000
| 2021-02-04T16:53:22
| 2021-02-04T16:53:22
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Lab5
*/
public class frmPatChkotSearch extends javax.swing.JFrame {
/**
* Creates new form frmPatChkotSearch
*/
public frmPatChkotSearch() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
cmb_dateout = new javax.swing.JComboBox();
jScrollPane2 = new javax.swing.JScrollPane();
tbl_patchkot = new javax.swing.JTable();
b_go = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Patient Checkout Search");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
getContentPane().setLayout(null);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Maiandra GD", 1, 36)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Search Checkout");
jLabel1.setOpaque(true);
getContentPane().add(jLabel1);
jLabel1.setBounds(230, 20, 330, 50);
cmb_dateout.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
cmb_dateout.setModel(new DefaultComboBoxModel());
cmb_dateout.setOpaque(false);
cmb_dateout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmb_dateoutActionPerformed(evt);
}
});
getContentPane().add(cmb_dateout);
cmb_dateout.setBounds(290, 100, 188, 40);
tbl_patchkot.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
tbl_patchkot.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Patient Name", "Registration Date", "Date Out", "Room Number", "Total Amount"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
tbl_patchkot.setOpaque(false);
jScrollPane2.setViewportView(tbl_patchkot);
getContentPane().add(jScrollPane2);
jScrollPane2.setBounds(20, 170, 790, 210);
b_go.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
b_go.setText("Go...!!!");
b_go.setOpaque(false);
b_go.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b_goActionPerformed(evt);
}
});
getContentPane().add(b_go);
b_go.setBounds(560, 102, 146, 50);
jLabel3.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
jLabel3.setText("Select Date ");
getContentPane().add(jLabel3);
jLabel3.setBounds(70, 110, 171, 30);
jLabel2.setIcon(new javax.swing.ImageIcon("C:\\Users\\SAMSUNG\\Documents\\NetBeansProjects\\HMS\\HMS 28 dec\\HMS_&\\projct OMAGES\\patchjkotsearch.jpg")); // NOI18N
getContentPane().add(jLabel2);
jLabel2.setBounds(-20, -10, 870, 530);
jLabel4.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
jLabel4.setText("Select Date ");
getContentPane().add(jLabel4);
jLabel4.setBounds(70, 110, 171, 30);
pack();
}// </editor-fold>//GEN-END:initComponents
Connection con=null;
Statement stmt=null;
Statement stmtpat=null;
Statement stmtdate=null;
String dr="java.sql.Driver";
String url="jdbc:mysql://localhost:3306/hms?zeroDateTimeBehavior=convertToNull";
String usr="root";
String pwd="";
String qry="";
ResultSet rs=null;
ResultSet rspat=null;
ResultSet rsdate=null;
int patid;
private void b_goActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_goActionPerformed
// TODO add your handling code here:
try{
DefaultTableModel tbl_mdl=(DefaultTableModel)tbl_patchkot.getModel();
qry="select PatNm,Checkout.RegDt,DateOut,TotalAmt,RoomNbr from Checkout,Registration,RoomInfo where Checkout.RoomId=RoomInfo.RoomId and Checkout.PatId=Registration.PatId and DateOut='"+cmb_dateout.getSelectedItem()+"'";
rs=stmt.executeQuery(qry);
tbl_mdl.setRowCount(0);
while(rs.next())
tbl_mdl.addRow(new Object[]{rs.getString("PatNm"),rs.getDate("RegDt"),rs.getDate("DateOut"),rs.getString("RoomNbr"),rs.getInt("TotalAmt")});
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "failed" + e);
}
}//GEN-LAST:event_b_goActionPerformed
private void cmb_dateoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_dateoutActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cmb_dateoutActionPerformed
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
this.setBounds(240, 120, 858, 507);
try{
Class.forName(dr);
con=DriverManager.getConnection(url, usr, pwd);
stmt=con.createStatement();
stmtpat=con.createStatement();
stmtdate=con.createStatement();
qry="select DateOut from checkout";
rsdate=stmtdate.executeQuery(qry);
DefaultComboBoxModel cmdate_mdl=(DefaultComboBoxModel)cmb_dateout.getModel();
while(rsdate.next())
cmdate_mdl.addElement(rsdate.getDate("DateOut"));
cmdate_mdl.insertElementAt("--Select--", 0);
cmb_dateout.setSelectedIndex(0);
DefaultTableModel tbl_mdl=(DefaultTableModel)tbl_patchkot.getModel();
qry="select PatNm,Checkout.RegDt,DateOut,TotalAmt,RoomNbr from Checkout,Registration,RoomInfo where Checkout.RoomId=RoomInfo.RoomId and Checkout.PatId=Registration.PatId";
rs=stmt.executeQuery(qry);
while(rs.next())
tbl_mdl.addRow(new Object[]{rs.getString("PatNm"),rs.getDate("RegDt"),rs.getDate("DateOut"),rs.getString("RoomNbr"),rs.getInt("TotalAmt")});
}catch(Exception e){JOptionPane.showMessageDialog(rootPane, "failed"+e);}
}//GEN-LAST:event_formWindowOpened
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
// TODO add your handling code here:
}//GEN-LAST:event_formWindowClosed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmPatChkotSearch().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton b_go;
private javax.swing.JComboBox cmb_dateout;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable tbl_patchkot;
// End of variables declaration//GEN-END:variables
}
|
UTF-8
|
Java
| 10,250
|
java
|
frmPatChkotSearch.java
|
Java
|
[
{
"context": "the template in the editor.\n */\n\n/**\n *\n * @author Lab5\n */\npublic class frmPatChkotSearch extends javax.",
"end": 440,
"score": 0.9995321035385132,
"start": 436,
"tag": "USERNAME",
"value": "Lab5"
},
{
"context": "oDateTimeBehavior=convertToNull\";\n String usr=\"root\";\n String pwd=\"\";\n String qry=\"\";\n Resul",
"end": 5002,
"score": 0.8293623924255371,
"start": 4998,
"tag": "USERNAME",
"value": "root"
}
] | null |
[] |
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Lab5
*/
public class frmPatChkotSearch extends javax.swing.JFrame {
/**
* Creates new form frmPatChkotSearch
*/
public frmPatChkotSearch() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
cmb_dateout = new javax.swing.JComboBox();
jScrollPane2 = new javax.swing.JScrollPane();
tbl_patchkot = new javax.swing.JTable();
b_go = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Patient Checkout Search");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
getContentPane().setLayout(null);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Maiandra GD", 1, 36)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Search Checkout");
jLabel1.setOpaque(true);
getContentPane().add(jLabel1);
jLabel1.setBounds(230, 20, 330, 50);
cmb_dateout.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
cmb_dateout.setModel(new DefaultComboBoxModel());
cmb_dateout.setOpaque(false);
cmb_dateout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmb_dateoutActionPerformed(evt);
}
});
getContentPane().add(cmb_dateout);
cmb_dateout.setBounds(290, 100, 188, 40);
tbl_patchkot.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
tbl_patchkot.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Patient Name", "Registration Date", "Date Out", "Room Number", "Total Amount"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
tbl_patchkot.setOpaque(false);
jScrollPane2.setViewportView(tbl_patchkot);
getContentPane().add(jScrollPane2);
jScrollPane2.setBounds(20, 170, 790, 210);
b_go.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
b_go.setText("Go...!!!");
b_go.setOpaque(false);
b_go.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b_goActionPerformed(evt);
}
});
getContentPane().add(b_go);
b_go.setBounds(560, 102, 146, 50);
jLabel3.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
jLabel3.setText("Select Date ");
getContentPane().add(jLabel3);
jLabel3.setBounds(70, 110, 171, 30);
jLabel2.setIcon(new javax.swing.ImageIcon("C:\\Users\\SAMSUNG\\Documents\\NetBeansProjects\\HMS\\HMS 28 dec\\HMS_&\\projct OMAGES\\patchjkotsearch.jpg")); // NOI18N
getContentPane().add(jLabel2);
jLabel2.setBounds(-20, -10, 870, 530);
jLabel4.setFont(new java.awt.Font("Maiandra GD", 1, 24)); // NOI18N
jLabel4.setText("Select Date ");
getContentPane().add(jLabel4);
jLabel4.setBounds(70, 110, 171, 30);
pack();
}// </editor-fold>//GEN-END:initComponents
Connection con=null;
Statement stmt=null;
Statement stmtpat=null;
Statement stmtdate=null;
String dr="java.sql.Driver";
String url="jdbc:mysql://localhost:3306/hms?zeroDateTimeBehavior=convertToNull";
String usr="root";
String pwd="";
String qry="";
ResultSet rs=null;
ResultSet rspat=null;
ResultSet rsdate=null;
int patid;
private void b_goActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_goActionPerformed
// TODO add your handling code here:
try{
DefaultTableModel tbl_mdl=(DefaultTableModel)tbl_patchkot.getModel();
qry="select PatNm,Checkout.RegDt,DateOut,TotalAmt,RoomNbr from Checkout,Registration,RoomInfo where Checkout.RoomId=RoomInfo.RoomId and Checkout.PatId=Registration.PatId and DateOut='"+cmb_dateout.getSelectedItem()+"'";
rs=stmt.executeQuery(qry);
tbl_mdl.setRowCount(0);
while(rs.next())
tbl_mdl.addRow(new Object[]{rs.getString("PatNm"),rs.getDate("RegDt"),rs.getDate("DateOut"),rs.getString("RoomNbr"),rs.getInt("TotalAmt")});
}catch(Exception e){
JOptionPane.showMessageDialog(rootPane, "failed" + e);
}
}//GEN-LAST:event_b_goActionPerformed
private void cmb_dateoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmb_dateoutActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cmb_dateoutActionPerformed
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
// TODO add your handling code here:
this.setBounds(240, 120, 858, 507);
try{
Class.forName(dr);
con=DriverManager.getConnection(url, usr, pwd);
stmt=con.createStatement();
stmtpat=con.createStatement();
stmtdate=con.createStatement();
qry="select DateOut from checkout";
rsdate=stmtdate.executeQuery(qry);
DefaultComboBoxModel cmdate_mdl=(DefaultComboBoxModel)cmb_dateout.getModel();
while(rsdate.next())
cmdate_mdl.addElement(rsdate.getDate("DateOut"));
cmdate_mdl.insertElementAt("--Select--", 0);
cmb_dateout.setSelectedIndex(0);
DefaultTableModel tbl_mdl=(DefaultTableModel)tbl_patchkot.getModel();
qry="select PatNm,Checkout.RegDt,DateOut,TotalAmt,RoomNbr from Checkout,Registration,RoomInfo where Checkout.RoomId=RoomInfo.RoomId and Checkout.PatId=Registration.PatId";
rs=stmt.executeQuery(qry);
while(rs.next())
tbl_mdl.addRow(new Object[]{rs.getString("PatNm"),rs.getDate("RegDt"),rs.getDate("DateOut"),rs.getString("RoomNbr"),rs.getInt("TotalAmt")});
}catch(Exception e){JOptionPane.showMessageDialog(rootPane, "failed"+e);}
}//GEN-LAST:event_formWindowOpened
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
// TODO add your handling code here:
}//GEN-LAST:event_formWindowClosed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(frmPatChkotSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmPatChkotSearch().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton b_go;
private javax.swing.JComboBox cmb_dateout;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable tbl_patchkot;
// End of variables declaration//GEN-END:variables
}
| 10,250
| 0.630927
| 0.614537
| 253
| 39.50988
| 35.685783
| 229
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.786561
| false
| false
|
13
|
e93d1bf3ed37fdfc468bd27aa49244a80ed16f03
| 23,854,248,403,783
|
142a2b5a838b165156f827e7407ed3151943883d
|
/top10/Kadane.java
|
06d36d18ee2fda70ea1b42f42fa52bb26481c29b
|
[] |
no_license
|
acharjeeanirban/programming-questions
|
https://github.com/acharjeeanirban/programming-questions
|
a761818007daaa0c15d9b2a703253ccbdd58da59
|
c3ce06c2c2f34d94041c69cd76b3b20790ebc8e5
|
refs/heads/master
| 2021-01-19T05:44:25.495000
| 2017-02-12T06:55:55
| 2017-02-12T06:55:55
| 65,065,603
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
class Kadane {
public static int getKadane(int arr[]) {
int maxTillNow = 0;
int sumtillNow = 0;
int leastNeg = arr[0];
boolean allNeg = true;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
if (arr[i] > leastNeg) {
leastNeg = arr[i];
}
} else {
allNeg = false;
break;
}
}
if (allNeg) {
return leastNeg;
}
for (int i = 0; i < arr.length; i++) {
maxTillNow += arr[i];
if (maxTillNow < 0) {
maxTillNow = 0;
} else if (maxTillNow > sumtillNow) {
sumtillNow = maxTillNow;
}
}
return sumtillNow;
}
public static void main(String[] args) {
//int arr[] = {-2,-3,-5,1,2,312,-100,2,3,5};
int arr[] = {-2,-3,-5,-1,-2,-312,-100,-2,-3,-5};
System.out.println(getKadane(arr));
}
}
|
UTF-8
|
Java
| 765
|
java
|
Kadane.java
|
Java
|
[] | null |
[] |
class Kadane {
public static int getKadane(int arr[]) {
int maxTillNow = 0;
int sumtillNow = 0;
int leastNeg = arr[0];
boolean allNeg = true;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
if (arr[i] > leastNeg) {
leastNeg = arr[i];
}
} else {
allNeg = false;
break;
}
}
if (allNeg) {
return leastNeg;
}
for (int i = 0; i < arr.length; i++) {
maxTillNow += arr[i];
if (maxTillNow < 0) {
maxTillNow = 0;
} else if (maxTillNow > sumtillNow) {
sumtillNow = maxTillNow;
}
}
return sumtillNow;
}
public static void main(String[] args) {
//int arr[] = {-2,-3,-5,1,2,312,-100,2,3,5};
int arr[] = {-2,-3,-5,-1,-2,-312,-100,-2,-3,-5};
System.out.println(getKadane(arr));
}
}
| 765
| 0.538562
| 0.491503
| 39
| 18.641026
| 14.760459
| 50
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 3.153846
| false
| false
|
13
|
fcefc312694f3a1d0509478289cff566e4c2724e
| 11,708,080,872,108
|
893c8c1f798b47e3fa4e04127deefb0a120123f1
|
/src/main/java/cn/jade/rjzxjjh/controller/LoginController.java
|
afacac07338c436b0e3aa9d19aa1f1bf21e0ee5c
|
[] |
no_license
|
anjadeluo/rj365zxjjh
|
https://github.com/anjadeluo/rj365zxjjh
|
db67abc83146b4dd43a7dfa734dd26b8aa1d537b
|
96f6614fb2c85ed69a1e558c7365342ca2ee360b
|
refs/heads/master
| 2022-12-23T14:24:54.379000
| 2019-04-08T17:41:10
| 2019-04-08T17:41:10
| 162,604,664
| 1
| 0
| null | false
| 2022-12-16T09:53:29
| 2018-12-20T16:28:26
| 2020-06-03T19:30:17
| 2022-12-16T09:53:27
| 4,993
| 1
| 0
| 18
|
JavaScript
| false
| false
|
package cn.jade.rjzxjjh.controller;
import cn.jade.rjzxjjh.exception.MyException;
import cn.jade.rjzxjjh.model.User;
import cn.jade.rjzxjjh.service.UserService;
import cn.jade.rjzxjjh.utils.UserUtils;
import org.apache.commons.lang3.StringUtils;
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.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by yhsk on 2017/7/27.
* 用户统一认证
*/
@Controller
@RequestMapping("${rootPath}")
public class LoginController extends BaseController {
@Autowired
private UserService userService;
/**
* 用户登陆
* <p>
* 1. /login 登录页面的常规显示
* 2. /login?error 登录验证失败的展示
* 3. /login?logout 注销登录的处理
*
* @param error
* @param logout
* @return
*/
@RequestMapping(value = "/loginPage")
public String loginPage(@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout,
Model model, HttpServletRequest request, HttpServletResponse response) {
if (error != null) {
model.addAttribute("msg", "用户名或密码错误,请重新输入");
}
if (logout != null) {
model.addAttribute("msg", "成功退出系统");
}
return "login";
}
@RequestMapping(value = {"/", "/main"})
public String main(Model model, HttpServletRequest request) {
model.addAttribute("user", UserUtils.getCurrentUser());
return "main";
}
@RequestMapping("/menu")
public String menu(Model model, HttpServletRequest request) {
model.addAttribute("user", UserUtils.getCurrentUser());
return "mainbody";
}
}
|
UTF-8
|
Java
| 2,066
|
java
|
LoginController.java
|
Java
|
[
{
"context": "rvlet.http.HttpServletResponse;\n\n/**\n * Created by yhsk on 2017/7/27.\n * 用户统一认证\n */\n@Controller\n@RequestM",
"end": 638,
"score": 0.9995178580284119,
"start": 634,
"tag": "USERNAME",
"value": "yhsk"
}
] | null |
[] |
package cn.jade.rjzxjjh.controller;
import cn.jade.rjzxjjh.exception.MyException;
import cn.jade.rjzxjjh.model.User;
import cn.jade.rjzxjjh.service.UserService;
import cn.jade.rjzxjjh.utils.UserUtils;
import org.apache.commons.lang3.StringUtils;
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.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by yhsk on 2017/7/27.
* 用户统一认证
*/
@Controller
@RequestMapping("${rootPath}")
public class LoginController extends BaseController {
@Autowired
private UserService userService;
/**
* 用户登陆
* <p>
* 1. /login 登录页面的常规显示
* 2. /login?error 登录验证失败的展示
* 3. /login?logout 注销登录的处理
*
* @param error
* @param logout
* @return
*/
@RequestMapping(value = "/loginPage")
public String loginPage(@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout,
Model model, HttpServletRequest request, HttpServletResponse response) {
if (error != null) {
model.addAttribute("msg", "用户名或密码错误,请重新输入");
}
if (logout != null) {
model.addAttribute("msg", "成功退出系统");
}
return "login";
}
@RequestMapping(value = {"/", "/main"})
public String main(Model model, HttpServletRequest request) {
model.addAttribute("user", UserUtils.getCurrentUser());
return "main";
}
@RequestMapping("/menu")
public String menu(Model model, HttpServletRequest request) {
model.addAttribute("user", UserUtils.getCurrentUser());
return "mainbody";
}
}
| 2,066
| 0.668712
| 0.663088
| 66
| 28.636364
| 25.042774
| 100
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.515152
| false
| false
|
13
|
a3a448f835ec6dcfd11d4f654b7f485d249736c6
| 12,137,577,601,544
|
dc1f8ebc05b8f3992c599721c012e31c8fc8c068
|
/ThirdDemo/src/test/java/com/softserve/edu/opencart/pages/right/UnsuccessfulLoginPage.java
|
c725ec1f7e85d0a3a80ba126009cd09d973ed9c6
|
[] |
no_license
|
AltairKuchiki/HomeTesting
|
https://github.com/AltairKuchiki/HomeTesting
|
349c68d34064e55e21a31e6198f76b5439f766c8
|
1d45d28d15dc93f2f0a3d11f459ede46db4429b9
|
refs/heads/master
| 2020-04-10T00:01:01.998000
| 2018-12-26T14:49:34
| 2018-12-26T14:49:34
| 157,882,257
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.softserve.edu.opencart.pages.right;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class UnsuccessfulLoginPage extends LoginPage {
public final String EXPECTED_WARNING_LOGIN = "Warning: No match for E-Mail Address and/or Password.";
private WebElement alertMessage;
public UnsuccessfulLoginPage(WebDriver driver) {
super(driver);
initElements();
}
private void initElements() {
alertMessage = driver.findElement(By.cssSelector(".alert"));
}
// PageObject Atomic Operation
// alertMessage
public WebElement getAlertMessage() {
return alertMessage;
}
public String getAlertMessageText() {
return getAlertMessage().getText();
}
// PageObject Atomic Operation
// Business Logic
}
|
UTF-8
|
Java
| 863
|
java
|
UnsuccessfulLoginPage.java
|
Java
|
[] | null |
[] |
package com.softserve.edu.opencart.pages.right;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class UnsuccessfulLoginPage extends LoginPage {
public final String EXPECTED_WARNING_LOGIN = "Warning: No match for E-Mail Address and/or Password.";
private WebElement alertMessage;
public UnsuccessfulLoginPage(WebDriver driver) {
super(driver);
initElements();
}
private void initElements() {
alertMessage = driver.findElement(By.cssSelector(".alert"));
}
// PageObject Atomic Operation
// alertMessage
public WebElement getAlertMessage() {
return alertMessage;
}
public String getAlertMessageText() {
return getAlertMessage().getText();
}
// PageObject Atomic Operation
// Business Logic
}
| 863
| 0.699884
| 0.699884
| 37
| 22.351351
| 24.001369
| 105
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.297297
| false
| false
|
13
|
9e9d00badb493499a7b7731bcee748a584c35d13
| 16,561,393,901,167
|
e15e5feeae553e50a6143a9585d98bc87cd77e77
|
/src/dangcat-persistence/src/test/java/org/dangcat/persistence/domain/EntityParams.java
|
bb07668099a02c4fcfaef30b5ed83189a8822f9a
|
[] |
no_license
|
BonnieTang/dangcat
|
https://github.com/BonnieTang/dangcat
|
fef0c62dc71a5247bc7aa3d0d8b6c80df937e361
|
0618384f18c40588b7fab5eee19e7e9dcc12479f
|
refs/heads/master
| 2021-01-20T22:45:09.045000
| 2016-06-24T02:04:39
| 2016-06-24T02:04:39
| 61,852,194
| 1
| 0
| null | true
| 2016-06-24T02:48:25
| 2016-06-24T02:48:25
| 2016-06-23T16:15:30
| 2016-06-24T02:05:05
| 11,893
| 0
| 0
| 0
| null | null | null |
package org.dangcat.persistence.domain;
import org.dangcat.persistence.annotation.Column;
import org.dangcat.persistence.annotation.Param;
import org.dangcat.persistence.annotation.Params;
import org.dangcat.persistence.annotation.Table;
import java.util.Date;
@Table
public class EntityParams {
@Column(isPrimaryKey = true, isAutoIncrement = true)
@Param(name = "idParams1", value = "1000", classType = Integer.class)
private Integer id;
@Column(displaySize = 40)
@Params({@Param(name = "nameParams1", value = "nameParams1-value"), @Param(name = "nameParams2", value = "2012-12-25", classType = Date.class),
@Param(name = "nameParams3", value = "true", classType = Boolean.class)})
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
|
UTF-8
|
Java
| 1,034
|
java
|
EntityParams.java
|
Java
|
[] | null |
[] |
package org.dangcat.persistence.domain;
import org.dangcat.persistence.annotation.Column;
import org.dangcat.persistence.annotation.Param;
import org.dangcat.persistence.annotation.Params;
import org.dangcat.persistence.annotation.Table;
import java.util.Date;
@Table
public class EntityParams {
@Column(isPrimaryKey = true, isAutoIncrement = true)
@Param(name = "idParams1", value = "1000", classType = Integer.class)
private Integer id;
@Column(displaySize = 40)
@Params({@Param(name = "nameParams1", value = "nameParams1-value"), @Param(name = "nameParams2", value = "2012-12-25", classType = Date.class),
@Param(name = "nameParams3", value = "true", classType = Boolean.class)})
private String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| 1,034
| 0.643133
| 0.624758
| 37
| 25.945946
| 29.729361
| 147
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.594595
| false
| false
|
13
|
301b1787a64eb8c7a49db087013f99045aa49e73
| 21,973,052,711,304
|
43e2b3c69b7ef3a6dd3c70125c4b70ee4d0a2f37
|
/app/src/main/java/com/lilang/passionlife/ui/PropertyServiceMainActivity.java
|
a89d54502f1b69cd3012d76ebeb10015bea3d56f
|
[] |
no_license
|
JokerStive/nanpingpush
|
https://github.com/JokerStive/nanpingpush
|
b2d4dabe36b9c93e9971308c7a3bf3c6526ee09e
|
92a4579eb1a8cdd75c081ba05a490b48f713500c
|
refs/heads/master
| 2016-09-22T16:19:56
| 2016-05-31T01:08:42
| 2016-05-31T01:08:42
| 59,821,063
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.lilang.passionlife.ui;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.lilang.passionlife.R;
import com.lilang.passionlife.ui.base.ProjBaseActivity;
import butterknife.InjectView;
import butterknife.OnClick;
public class PropertyServiceMainActivity extends ProjBaseActivity {
private PropertyAnnouncementFragment announcementFragment;
private CommunityAnnouncementFragment communityAnnouncementFragment;
private MyAnnouncementFragment myAnnouncementFragment;
private FragmentManager fm;
private FragmentTransaction ft;
private PayPropertyServiceFragment payPropertyServiceFragment;
@InjectView(R.id.activity_name)
TextView activityName;
@OnClick(R.id.return_back)
public void back(){
finish();
}
@InjectView(R.id.free_bt)
Button freeBt;
@InjectView(R.id.pay_bt)
Button payBt;
@InjectView(R.id.pay_severce_fragment)
FrameLayout payFragment;
@InjectView(R.id.free_severce_fragment)
FrameLayout freeFragment;
@OnClick(R.id.free_bt)
public void freeMethod(){
freeBt.setBackgroundResource(R.drawable.free_severce_on);
payBt.setBackgroundResource(R.drawable.pay_severce_off);
freeFragment.setVisibility(View.VISIBLE);
payFragment.setVisibility(View.GONE);
FreeRapairsInfoFragment fragment0 = new FreeRapairsInfoFragment();
fm = this.getSupportFragmentManager();
ft = fm.beginTransaction();
ft.replace(R.id.free_severce_fragment, fragment0);
ft.commit();
}
@OnClick(R.id.pay_bt)
public void payMethod(){
freeBt.setBackgroundResource(R.drawable.free_severce_off);
payBt.setBackgroundResource(R.drawable.pay_severce_on);
freeFragment.setVisibility(View.GONE);
payFragment.setVisibility(View.VISIBLE);
fm = this.getSupportFragmentManager();
ft = fm.beginTransaction();
ft.replace(R.id.pay_severce_fragment, payPropertyServiceFragment);
ft.commit();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_property_severce_main);
activityName.setText("物业服务");
announcementFragment = new PropertyAnnouncementFragment();
myAnnouncementFragment = new MyAnnouncementFragment();
payPropertyServiceFragment =new PayPropertyServiceFragment();
freeMethod();
}
}
|
UTF-8
|
Java
| 2,657
|
java
|
PropertyServiceMainActivity.java
|
Java
|
[] | null |
[] |
package com.lilang.passionlife.ui;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.lilang.passionlife.R;
import com.lilang.passionlife.ui.base.ProjBaseActivity;
import butterknife.InjectView;
import butterknife.OnClick;
public class PropertyServiceMainActivity extends ProjBaseActivity {
private PropertyAnnouncementFragment announcementFragment;
private CommunityAnnouncementFragment communityAnnouncementFragment;
private MyAnnouncementFragment myAnnouncementFragment;
private FragmentManager fm;
private FragmentTransaction ft;
private PayPropertyServiceFragment payPropertyServiceFragment;
@InjectView(R.id.activity_name)
TextView activityName;
@OnClick(R.id.return_back)
public void back(){
finish();
}
@InjectView(R.id.free_bt)
Button freeBt;
@InjectView(R.id.pay_bt)
Button payBt;
@InjectView(R.id.pay_severce_fragment)
FrameLayout payFragment;
@InjectView(R.id.free_severce_fragment)
FrameLayout freeFragment;
@OnClick(R.id.free_bt)
public void freeMethod(){
freeBt.setBackgroundResource(R.drawable.free_severce_on);
payBt.setBackgroundResource(R.drawable.pay_severce_off);
freeFragment.setVisibility(View.VISIBLE);
payFragment.setVisibility(View.GONE);
FreeRapairsInfoFragment fragment0 = new FreeRapairsInfoFragment();
fm = this.getSupportFragmentManager();
ft = fm.beginTransaction();
ft.replace(R.id.free_severce_fragment, fragment0);
ft.commit();
}
@OnClick(R.id.pay_bt)
public void payMethod(){
freeBt.setBackgroundResource(R.drawable.free_severce_off);
payBt.setBackgroundResource(R.drawable.pay_severce_on);
freeFragment.setVisibility(View.GONE);
payFragment.setVisibility(View.VISIBLE);
fm = this.getSupportFragmentManager();
ft = fm.beginTransaction();
ft.replace(R.id.pay_severce_fragment, payPropertyServiceFragment);
ft.commit();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_property_severce_main);
activityName.setText("物业服务");
announcementFragment = new PropertyAnnouncementFragment();
myAnnouncementFragment = new MyAnnouncementFragment();
payPropertyServiceFragment =new PayPropertyServiceFragment();
freeMethod();
}
}
| 2,657
| 0.734617
| 0.733107
| 72
| 35.791668
| 20.999958
| 74
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.694444
| false
| false
|
13
|
96e45a478e92b544c7414bce403acbebdad42e38
| 9,732,395,933,457
|
0a4a70fbab56dc29b099d8811bb33e32f501e4b9
|
/token-bucket/src/main/java/io/github/wanghuayao/jutils/tokenbucket/FixRateTokenBucket.java
|
6193689b5b2599ef4bb347e1cf7a9fb2273f6e6d
|
[
"Apache-2.0"
] |
permissive
|
wanghuayao/jcommon
|
https://github.com/wanghuayao/jcommon
|
4b2b3d605defc6ecb94d11580a2e48039558f94c
|
438b1714c63238379a135e390813a2b7d5df84a4
|
refs/heads/master
| 2020-07-01T20:05:46.493000
| 2016-11-20T07:49:10
| 2016-11-20T07:49:10
| 74,260,007
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package io.github.wanghuayao.jutils.tokenbucket;
import io.github.wanghuayao.jutil.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* TokenBucket 实现类(固定周期)
*
* @author wanghuayao
*/
public class FixRateTokenBucket implements TokenBucket {
private final static Logger LOG = LoggerFactory.getLogger(FixRateTokenBucket.class);
/**
* 桶的大小
*/
private AtomicLong size = new AtomicLong();
private final ReentrantLock locker = new ReentrantLock();
/**
* 时间间隔(纳秒)
*/
private final long intervalInNanos;
/**
* 时间间隔(毫秒)
*/
private final long timeWaitForTokens;
/**
* 每个时间周期生成的token数
*/
private long tokensPerPeriod;
/**
* 此容器容量
*/
private long capacity;
/**
* 追后一次更新桶大小的时间
*/
private long lastRefillTime = 0;
/**
* 取得tokens的进程
*/
private List<Thread> threads = Collections.synchronizedList(new ArrayList<Thread>());
/**
* 构造函数
*
* @param capacity 容量
* @param tokensPerPeriod 每个时间周期生成Token的个数
* @param interval 间隔时间
* @param timeUnit 间隔时间的单位
*/
public FixRateTokenBucket(long capacity, long tokensPerPeriod, long interval, TimeUnit timeUnit) {
if (interval < 1 || !this.resize(capacity, tokensPerPeriod)) {
throw new RuntimeException("参数不正确,要求:capacity >= tokensPerPeriod >= 1, interval >= 1");
}
this.intervalInNanos = timeUnit.toNanos(interval);
// 最低1毫秒
this.timeWaitForTokens = Math.max(timeUnit.toMillis(interval * 2), 1);
this.lastRefillTime = System.nanoTime();
size.set(0);
createTokenThread.setDaemon(true);
createTokenThread.start();
}
@Override
public boolean resize(long capacity, long tokensPerPeriod) {
if (tokensPerPeriod < 1) {
return false;
}
if (capacity < tokensPerPeriod) {
return false;
}
this.capacity = capacity;
this.tokensPerPeriod = tokensPerPeriod;
long curSize = size.get();
while (curSize > capacity) {
if (size.compareAndSet(curSize, capacity)) {
break;
}
curSize = size.get();
}
return true;
}
@Override
public void consume() {
}
@Override
public void consume(long tockenCount) {
while (!tryConsume(tockenCount)) {
Thread currentThread = Thread.currentThread();
threads.add(currentThread);
createTokenThread.interrupt();
if (ThreadUtils.sleepAndCachedInterruptedException(timeWaitForTokens, TimeUnit.MILLISECONDS)) {
LOG.debug("自己睡醒了。");
}
}
}
/**
* 尝试取得consume大小的
*/
@Override
public boolean tryConsume(long tockenCount) {
if (tockenCount <= 0) {
return true;
}
if (tockenCount <= this.capacity) {
do {
long currentSize = size.get();
long postSize = currentSize - tockenCount;
if (postSize >= 0) {
if (size.compareAndSet(currentSize, postSize)) {
return true;
} else {
Thread.yield();
}
} else {
// 木有的话,生成一下看看
if (!createToken(true)) {
break;
}
}
} while (true);
return false;
} else {
throw new RuntimeException("the request size[" + tockenCount + "] is greater then bucket capacity["
+ capacity + "]");
}
}
/**
* 生成token thread
*/
//@formatter:off
private Thread createTokenThread = new Thread() {
public void run() {
this.setName("tockent-bucket");
// sleep
ThreadUtils.endlessSleep();
while (true) {
// 生成token,可以等待
createToken(false);
// 成功生成新的token后通知各线程
while (!threads.isEmpty()) {
Thread t = threads.remove(0);
t.interrupt();
}
ThreadUtils.endlessSleep();
}
};
};
//@formatter:on
// 生成token
private boolean createToken(boolean noWait) {
if (!locker.tryLock()) {
// 没有锁上
if (noWait) {
// 不可等的
return false;
} else {
locker.lock();
}
}
try {
long dueryFromLast = System.nanoTime() - lastRefillTime;
long numPeriods;
if (dueryFromLast < intervalInNanos) {
if (noWait) {
return false;
}
// 深睡眠
ThreadUtils.deepSleep(intervalInNanos - dueryFromLast, TimeUnit.NANOSECONDS);
// 只经历了一个周期
numPeriods = 1;
} else {
// 从上次调用到现在为止经过了几个时间周期
numPeriods = dueryFromLast / intervalInNanos;
}
// 本次生成到几点为止的时间
lastRefillTime += numPeriods * intervalInNanos;
long newSize = Math.min(numPeriods * tokensPerPeriod + size.get(), capacity);
size.set(newSize);
return true;
} finally {
locker.unlock();
}
}
}
|
UTF-8
|
Java
| 6,505
|
java
|
FixRateTokenBucket.java
|
Java
|
[
{
"context": "anghuayao.jutils.tokenbucket;\r\n\r\nimport io.github.wanghuayao.jutil.utils.ThreadUtils;\r\n\r\nimport java.util.Arra",
"end": 79,
"score": 0.7566854953765869,
"start": 69,
"tag": "USERNAME",
"value": "wanghuayao"
},
{
"context": "\r\n\r\n/**\r\n * TokenBucket 实现类(固定周期)\r\n * \r\n * @author wanghuayao\r\n */\r\npublic class FixRateTokenBucket implements ",
"end": 449,
"score": 0.9996562004089355,
"start": 439,
"tag": "USERNAME",
"value": "wanghuayao"
}
] | null |
[] |
package io.github.wanghuayao.jutils.tokenbucket;
import io.github.wanghuayao.jutil.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* TokenBucket 实现类(固定周期)
*
* @author wanghuayao
*/
public class FixRateTokenBucket implements TokenBucket {
private final static Logger LOG = LoggerFactory.getLogger(FixRateTokenBucket.class);
/**
* 桶的大小
*/
private AtomicLong size = new AtomicLong();
private final ReentrantLock locker = new ReentrantLock();
/**
* 时间间隔(纳秒)
*/
private final long intervalInNanos;
/**
* 时间间隔(毫秒)
*/
private final long timeWaitForTokens;
/**
* 每个时间周期生成的token数
*/
private long tokensPerPeriod;
/**
* 此容器容量
*/
private long capacity;
/**
* 追后一次更新桶大小的时间
*/
private long lastRefillTime = 0;
/**
* 取得tokens的进程
*/
private List<Thread> threads = Collections.synchronizedList(new ArrayList<Thread>());
/**
* 构造函数
*
* @param capacity 容量
* @param tokensPerPeriod 每个时间周期生成Token的个数
* @param interval 间隔时间
* @param timeUnit 间隔时间的单位
*/
public FixRateTokenBucket(long capacity, long tokensPerPeriod, long interval, TimeUnit timeUnit) {
if (interval < 1 || !this.resize(capacity, tokensPerPeriod)) {
throw new RuntimeException("参数不正确,要求:capacity >= tokensPerPeriod >= 1, interval >= 1");
}
this.intervalInNanos = timeUnit.toNanos(interval);
// 最低1毫秒
this.timeWaitForTokens = Math.max(timeUnit.toMillis(interval * 2), 1);
this.lastRefillTime = System.nanoTime();
size.set(0);
createTokenThread.setDaemon(true);
createTokenThread.start();
}
@Override
public boolean resize(long capacity, long tokensPerPeriod) {
if (tokensPerPeriod < 1) {
return false;
}
if (capacity < tokensPerPeriod) {
return false;
}
this.capacity = capacity;
this.tokensPerPeriod = tokensPerPeriod;
long curSize = size.get();
while (curSize > capacity) {
if (size.compareAndSet(curSize, capacity)) {
break;
}
curSize = size.get();
}
return true;
}
@Override
public void consume() {
}
@Override
public void consume(long tockenCount) {
while (!tryConsume(tockenCount)) {
Thread currentThread = Thread.currentThread();
threads.add(currentThread);
createTokenThread.interrupt();
if (ThreadUtils.sleepAndCachedInterruptedException(timeWaitForTokens, TimeUnit.MILLISECONDS)) {
LOG.debug("自己睡醒了。");
}
}
}
/**
* 尝试取得consume大小的
*/
@Override
public boolean tryConsume(long tockenCount) {
if (tockenCount <= 0) {
return true;
}
if (tockenCount <= this.capacity) {
do {
long currentSize = size.get();
long postSize = currentSize - tockenCount;
if (postSize >= 0) {
if (size.compareAndSet(currentSize, postSize)) {
return true;
} else {
Thread.yield();
}
} else {
// 木有的话,生成一下看看
if (!createToken(true)) {
break;
}
}
} while (true);
return false;
} else {
throw new RuntimeException("the request size[" + tockenCount + "] is greater then bucket capacity["
+ capacity + "]");
}
}
/**
* 生成token thread
*/
//@formatter:off
private Thread createTokenThread = new Thread() {
public void run() {
this.setName("tockent-bucket");
// sleep
ThreadUtils.endlessSleep();
while (true) {
// 生成token,可以等待
createToken(false);
// 成功生成新的token后通知各线程
while (!threads.isEmpty()) {
Thread t = threads.remove(0);
t.interrupt();
}
ThreadUtils.endlessSleep();
}
};
};
//@formatter:on
// 生成token
private boolean createToken(boolean noWait) {
if (!locker.tryLock()) {
// 没有锁上
if (noWait) {
// 不可等的
return false;
} else {
locker.lock();
}
}
try {
long dueryFromLast = System.nanoTime() - lastRefillTime;
long numPeriods;
if (dueryFromLast < intervalInNanos) {
if (noWait) {
return false;
}
// 深睡眠
ThreadUtils.deepSleep(intervalInNanos - dueryFromLast, TimeUnit.NANOSECONDS);
// 只经历了一个周期
numPeriods = 1;
} else {
// 从上次调用到现在为止经过了几个时间周期
numPeriods = dueryFromLast / intervalInNanos;
}
// 本次生成到几点为止的时间
lastRefillTime += numPeriods * intervalInNanos;
long newSize = Math.min(numPeriods * tokensPerPeriod + size.get(), capacity);
size.set(newSize);
return true;
} finally {
locker.unlock();
}
}
}
| 6,505
| 0.492066
| 0.489612
| 214
| 26.56542
| 23.351498
| 111
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.38785
| false
| false
|
13
|
264fcb1516e1f511f32c666740ddbc539c5b1d44
| 17,867,063,966,208
|
35862a965830fb75f6f07022aaf112e858feb65c
|
/palmaSafeArea/localMod/src/ext/thales/palma/load/imp/LoadPalmaECP.java
|
88de0413f9d5684fd2f516c86b1b61f1a0c6d06d
|
[] |
no_license
|
phernaca/palma-tasb
|
https://github.com/phernaca/palma-tasb
|
6ccadcdddf8dec11b7f22e5c35b30a155d0a50d1
|
a186e7d44d0d8bfe5c5ecedbc9d6aa6d671c7521
|
refs/heads/master
| 2016-09-05T12:39:57.769000
| 2013-06-03T19:37:22
| 2013-06-03T19:37:22
| 10,075,948
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
/*
* Copyright (c) 2009 THALES
* 18 avenue du Marechal Juin, Meudon La Foret (92), FRANCE.
* All rights reserved.
*
* This software is the confidential and proprietary information of
* THALES. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with THALES.
*/
package ext.thales.palma.load.imp;
import java.sql.Timestamp;
import java.util.Hashtable;
import java.util.Vector;
import wt.doc.WTDocument;
import wt.iba.definition.litedefinition.AttributeDefDefaultView;
import wt.iba.definition.litedefinition.BooleanDefView;
import wt.iba.definition.litedefinition.StringDefView;
import wt.iba.definition.litedefinition.TimestampDefView;
import wt.iba.definition.service.IBADefinitionHelper;
import wt.iba.value.DefaultAttributeContainer;
import wt.iba.value.litevalue.AbstractValueView;
import wt.iba.value.litevalue.BooleanValueDefaultView;
import wt.iba.value.litevalue.StringValueDefaultView;
import wt.iba.value.litevalue.TimestampValueDefaultView;
import wt.load.LoadServerHelper;
import wt.util.WTException;
import ext.thales.palma.enterprise.DocumentType;
import ext.thales.palma.enterprise.InstanceBasedAttributeIF;
import ext.thales.palma.util.service.PalmaIBAHelper;
/**
* Engineering Change Proposal loader.
*
* <br><br>
* @author Nicolas
* @version 3.0 4 janv. 2010
* <br><br>
* <pre>
* +-----------------+---------------------------+------------------+
* | PR Number | Method Name | Build Number(*) |
* +-----------------+---------------------------+------------------+
* | | | |
* | | | |
*
* (C) Create (U) Update (D) Delete
* (*) Build Number is mandatory for delivery purpose.
* </pre>
*/
public class LoadPalmaECP extends LoadPalmaDocument {
/* TAS BEGIN SDD-TASB.CHG.0140
Use LoadPalmaDocument as SuperClass in order to take into account "11version" attribute
TAS END */
//CHECKSTYLE:OFF-BEGIN PALMA_CORE CODE
/**
* FULL LOG PATH VARIABLE
*/
private static String szFullLogPath;
/**
* FULL FAILURES PATH VARIABLE
*/
private static String szFullFailuresPath;
/**
* KEYWORD FOR ECP LOADER
*/
private static final String KEYWORD = "CreatePalmaECP";
/**
* CSV column name for ECP Class
*/
private static final String ECP_CLASS_CVS_NAME = "21ECPClass";
/**
* CSV column name for askingForCustomerApproval
*/
private static final String ASKING_CUSTOMER_APPROVAL_CVS_NAME = "22askingForCustomerApproval";
/**
* CSV column name for customerName
*/
private static final String CUSTOMER_NAME_CVS_NAME = "23customerName";
/**
* CSV column name for customerApprovalDate
*/
private static final String CUSTOMER_APPROVAL_DATE_CVS_NAME = "24customerApprovalDate";
/**
* CSV column name for askingForOfficialServicesApproval
*/
private static final String ASKING_OFFICIAL_SERVICE_APPROVAL_CVS_NAME = "25askingForOfficialServicesApproval";
/**
* CSV column name for officialServicesApprovalName
*/
private static final String OFFICIAL_SERVICE_APPROVAL_NAME_CVS_NAME = "26officialServicesApprovalName";
/**
* CSV column name for officialServicesApprovalDate
*/
private static final String OFFICIAL_SERVICE_APPROVAL_DATE_CVS_NAME = "27officialServicesApprovalDate";
static {
try {
szFullLogPath = getLogFilePath(KEYWORD);
szFullFailuresPath = getFailuresFilePath(KEYWORD);
}
// CHECKSTYLE:OFF-IllegalCatchCheck - extends
catch (Exception e) {
e.printStackTrace(); // NOPMD
LoadServerHelper.printMessage("Error while initializing LoadPalmaECP : "
+ e.getLocalizedMessage());
}
}
// CHECKSTYLE:ON-IllegalCatchCheck - extends
/**
* LoadPalmaECP Constructor
* @param attrTable
* @param cmdLine
*/
public LoadPalmaECP(
Hashtable<String, String> attrTable, // NOPMD
Hashtable<String, String> cmdLine) { // NOPMD
super(attrTable, cmdLine);
}
// CHECKSTYLE:OFF-IllegalTypeCheck
/**
* method called to load ECP in csvmapfile
* @param attrTable
* @param cmd_line
* @param return_objects
* @return
*/
public static boolean createECP(
Hashtable<String, String> attrTable, // NOPMD
Hashtable<String, String> cmd_line, // NOPMD
Vector return_objects)
{
LoadPalmaECP loader =
new LoadPalmaECP(attrTable, cmd_line);
return loader.createECP();
}
// CHECKSTYLE:ON-IllegalTypeCheck
/**
* Create a new ECP with characteristics specified in {@link this#attr_table}.
*
* @return creation status: <tt>false</tt> means failure.
*/
protected boolean createECP() {
boolean success = false;
try {
// Set the soft type
attr_table.put(SOFT_TYPE, DocumentType.ECP.getDisplay());
success = super.createDocument();
}
// CHECKSTYLE:OFF-IllegalCatchCheck - extends
catch (Exception e) {
String szNumber = LoadServerHelper.getValue(
NUMBER, attr_table, cmd_line, LoadServerHelper.REQUIRED);
logError(e, szNumber, attr_table,
szFullLogPath, szFullFailuresPath, KEYWORD);
}
// CHECKSTYLE:ON-IllegalCatchCheck - extends
return success;
}
/**
* Method to return the attrContainer
* @param attrContainer
* @param ecpDoc
* @return
* @throws WTException
*/
private static DefaultAttributeContainer getAttrContainer (DefaultAttributeContainer attrContainer, WTDocument doc) throws WTException{
DefaultAttributeContainer szAttrContainer = attrContainer ;
WTDocument ecpDoc = null ;
if (szAttrContainer == null){
ecpDoc = (WTDocument) PalmaIBAHelper.service.refresh(doc);
szAttrContainer = (DefaultAttributeContainer) ecpDoc.getAttributeContainer();
}
return szAttrContainer ;
}
/**
* @return the szFullLogPath
*/
public String getSzFullLogPath() {
return szFullLogPath;
}
/**
* @return the szFullFailuresPath
*/
public String getSzFullFailuresPath() {
return szFullFailuresPath;
}
// CHECKSTYLE:OFF-IllegalTypeCheck
@Override
protected void setSpecificIBAs(WTDocument doc) throws Exception { // NOPMD
DefaultAttributeContainer attrContainer =
(DefaultAttributeContainer) doc.getAttributeContainer();
attrContainer = getAttrContainer(attrContainer, doc);
String szCtd = LoadServerHelper.getValue(
CTD, attr_table, cmd_line, LoadServerHelper.REQUIRED);
/*String szCage = LoadServerHelper.getValue(
CAGE, attr_table, cmd_line, LoadServerHelper.REQUIRED);*/
// ECP Class
String szECPClass = LoadServerHelper.getValue(
ECP_CLASS_CVS_NAME, attr_table, cmd_line, LoadServerHelper.REQUIRED);
// Asking Customer Aproval
String szAskingCustomerApproval = LoadServerHelper.getValue(
ASKING_CUSTOMER_APPROVAL_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Customer Name
String szCustomerName = LoadServerHelper.getValue(
CUSTOMER_NAME_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Expected customer approval date
String szCustomerApprovalDate = LoadServerHelper.getValue(
CUSTOMER_APPROVAL_DATE_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Asking Offcicial Services Aproval
String szAskingOfficialServiceApproval = LoadServerHelper.getValue(
ASKING_OFFICIAL_SERVICE_APPROVAL_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Official Services Approval Name
String szOfficialServiceApprovalName = LoadServerHelper.getValue(
OFFICIAL_SERVICE_APPROVAL_NAME_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Expected customer approval date
String szOfficialServiceApprovalDate = LoadServerHelper.getValue(
OFFICIAL_SERVICE_APPROVAL_DATE_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
AbstractValueView attrValueView = null;
AttributeDefDefaultView attrDefinizerView = null;
// CTD
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(
InstanceBasedAttributeIF.CTD_IBA_NAME);
attrValueView = new StringValueDefaultView(
(StringDefView) attrDefinizerView, szCtd);
attrContainer.deleteAttributeValues(attrDefinizerView);
attrContainer.addAttributeValue(attrValueView);
// ECP Class
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(
InstanceBasedAttributeIF.ECP_CLASS_IBA_NAME);
AbstractValueView attrValueViewECP = new StringValueDefaultView(
(StringDefView) attrDefinizerView, szECPClass);
attrContainer.deleteAttributeValues(attrDefinizerView);
attrContainer.addAttributeValue(attrValueViewECP);
// Asking Customer Aproval
if(szAskingCustomerApproval != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.ASKING_FOR_CUSTOMER_APPROVAL_IBA_NAME);
attrValueView = new BooleanValueDefaultView((BooleanDefView) attrDefinizerView, "1".equals(szAskingCustomerApproval));
attrContainer.addAttributeValue(attrValueView);
}
// Customer Name
if(szCustomerName != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( InstanceBasedAttributeIF.CUSTOMER_NAME_IBA_NAME);
attrValueView = new StringValueDefaultView((StringDefView) attrDefinizerView, szCustomerName);
attrContainer.addAttributeValue(attrValueView);
}
// Customer Aproval Date
if (szCustomerApprovalDate != null) {
Timestamp createTimestamp = new Timestamp(sdf.parse(szCustomerApprovalDate).getTime());
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.CUSTOMER_APPROVAL_DATE_IBA_NAME);
attrValueView = new TimestampValueDefaultView((TimestampDefView) attrDefinizerView, createTimestamp);
attrContainer.addAttributeValue(attrValueView);
}
// Asking Official Service Aproval
if(szAskingOfficialServiceApproval != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.ASKING_FOR_OFFICIAL_SERVICES_APPROVAL_IBA_NAME);
attrValueView = new BooleanValueDefaultView((BooleanDefView) attrDefinizerView, "1".equals(szAskingOfficialServiceApproval));
attrContainer.addAttributeValue(attrValueView);
}
// Official Services Approval Name
if(szOfficialServiceApprovalName != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( InstanceBasedAttributeIF.OFFICIAL_SERVICES_APPROVAL_NAME_IBA_NAME);
attrValueView = new StringValueDefaultView((StringDefView) attrDefinizerView, szOfficialServiceApprovalName);
attrContainer.addAttributeValue(attrValueView);
}
// Official Service Aproval Date
if (szOfficialServiceApprovalDate != null) {
Timestamp createTimestamp = new Timestamp(sdf.parse(szOfficialServiceApprovalDate).getTime());
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.OFFICIAL_SERVICES_APPROVAL_DATE_IBA_NAME);
attrValueView = new TimestampValueDefaultView((TimestampDefView) attrDefinizerView, createTimestamp);
attrContainer.addAttributeValue(attrValueView);
}
}
// CHECKSTYLE:ON-IllegalTypeCheck
/**
* Trace error into log file and rewrite failed line
* into failures file.
*
* @param nv
* @param cmd_line
* @param return_objects
* @return
*/
@Override
//CHECKSTYLE:OFF-IllegalType
protected void logError(
Exception e,
String szIdentifier,
Hashtable<String, String> attrTable,//NOPMD
String szLogPath,
String szFailuresPath,
String szClassName) {
//CHECKSTYLE:ON-IllegalType
super.logError(e, szIdentifier, attrTable, getSzFullLogPath(), getSzFullFailuresPath(), KEYWORD);
}
}
|
UTF-8
|
Java
| 11,896
|
java
|
LoadPalmaECP.java
|
Java
|
[
{
"context": "/*\n * Copyright (c) 2009 THALES\n * 18 avenue du Marechal Juin, Meudon La Foret (92), FRANCE.\n * All rights rese",
"end": 61,
"score": 0.9993739128112793,
"start": 48,
"tag": "NAME",
"value": "Marechal Juin"
},
{
"context": "ght (c) 2009 THALES\n * 18 avenue du Marechal Juin, Meudon La Foret (92), FRANCE.\n * All rights reserved.\n *\n * This ",
"end": 78,
"score": 0.9998564720153809,
"start": 63,
"tag": "NAME",
"value": "Meudon La Foret"
},
{
"context": "ange Proposal loader.\n * \n * <br><br>\n * @author\t\tNicolas\n * @version\t\t3.0\t\t4 janv. 2010\n * <br><br>\n * <pr",
"end": 1398,
"score": 0.9997789859771729,
"start": 1391,
"tag": "NAME",
"value": "Nicolas"
}
] | null |
[] |
/*
* Copyright (c) 2009 THALES
* 18 avenue du <NAME>, <NAME> (92), FRANCE.
* All rights reserved.
*
* This software is the confidential and proprietary information of
* THALES. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with THALES.
*/
package ext.thales.palma.load.imp;
import java.sql.Timestamp;
import java.util.Hashtable;
import java.util.Vector;
import wt.doc.WTDocument;
import wt.iba.definition.litedefinition.AttributeDefDefaultView;
import wt.iba.definition.litedefinition.BooleanDefView;
import wt.iba.definition.litedefinition.StringDefView;
import wt.iba.definition.litedefinition.TimestampDefView;
import wt.iba.definition.service.IBADefinitionHelper;
import wt.iba.value.DefaultAttributeContainer;
import wt.iba.value.litevalue.AbstractValueView;
import wt.iba.value.litevalue.BooleanValueDefaultView;
import wt.iba.value.litevalue.StringValueDefaultView;
import wt.iba.value.litevalue.TimestampValueDefaultView;
import wt.load.LoadServerHelper;
import wt.util.WTException;
import ext.thales.palma.enterprise.DocumentType;
import ext.thales.palma.enterprise.InstanceBasedAttributeIF;
import ext.thales.palma.util.service.PalmaIBAHelper;
/**
* Engineering Change Proposal loader.
*
* <br><br>
* @author Nicolas
* @version 3.0 4 janv. 2010
* <br><br>
* <pre>
* +-----------------+---------------------------+------------------+
* | PR Number | Method Name | Build Number(*) |
* +-----------------+---------------------------+------------------+
* | | | |
* | | | |
*
* (C) Create (U) Update (D) Delete
* (*) Build Number is mandatory for delivery purpose.
* </pre>
*/
public class LoadPalmaECP extends LoadPalmaDocument {
/* TAS BEGIN SDD-TASB.CHG.0140
Use LoadPalmaDocument as SuperClass in order to take into account "11version" attribute
TAS END */
//CHECKSTYLE:OFF-BEGIN PALMA_CORE CODE
/**
* FULL LOG PATH VARIABLE
*/
private static String szFullLogPath;
/**
* FULL FAILURES PATH VARIABLE
*/
private static String szFullFailuresPath;
/**
* KEYWORD FOR ECP LOADER
*/
private static final String KEYWORD = "CreatePalmaECP";
/**
* CSV column name for ECP Class
*/
private static final String ECP_CLASS_CVS_NAME = "21ECPClass";
/**
* CSV column name for askingForCustomerApproval
*/
private static final String ASKING_CUSTOMER_APPROVAL_CVS_NAME = "22askingForCustomerApproval";
/**
* CSV column name for customerName
*/
private static final String CUSTOMER_NAME_CVS_NAME = "23customerName";
/**
* CSV column name for customerApprovalDate
*/
private static final String CUSTOMER_APPROVAL_DATE_CVS_NAME = "24customerApprovalDate";
/**
* CSV column name for askingForOfficialServicesApproval
*/
private static final String ASKING_OFFICIAL_SERVICE_APPROVAL_CVS_NAME = "25askingForOfficialServicesApproval";
/**
* CSV column name for officialServicesApprovalName
*/
private static final String OFFICIAL_SERVICE_APPROVAL_NAME_CVS_NAME = "26officialServicesApprovalName";
/**
* CSV column name for officialServicesApprovalDate
*/
private static final String OFFICIAL_SERVICE_APPROVAL_DATE_CVS_NAME = "27officialServicesApprovalDate";
static {
try {
szFullLogPath = getLogFilePath(KEYWORD);
szFullFailuresPath = getFailuresFilePath(KEYWORD);
}
// CHECKSTYLE:OFF-IllegalCatchCheck - extends
catch (Exception e) {
e.printStackTrace(); // NOPMD
LoadServerHelper.printMessage("Error while initializing LoadPalmaECP : "
+ e.getLocalizedMessage());
}
}
// CHECKSTYLE:ON-IllegalCatchCheck - extends
/**
* LoadPalmaECP Constructor
* @param attrTable
* @param cmdLine
*/
public LoadPalmaECP(
Hashtable<String, String> attrTable, // NOPMD
Hashtable<String, String> cmdLine) { // NOPMD
super(attrTable, cmdLine);
}
// CHECKSTYLE:OFF-IllegalTypeCheck
/**
* method called to load ECP in csvmapfile
* @param attrTable
* @param cmd_line
* @param return_objects
* @return
*/
public static boolean createECP(
Hashtable<String, String> attrTable, // NOPMD
Hashtable<String, String> cmd_line, // NOPMD
Vector return_objects)
{
LoadPalmaECP loader =
new LoadPalmaECP(attrTable, cmd_line);
return loader.createECP();
}
// CHECKSTYLE:ON-IllegalTypeCheck
/**
* Create a new ECP with characteristics specified in {@link this#attr_table}.
*
* @return creation status: <tt>false</tt> means failure.
*/
protected boolean createECP() {
boolean success = false;
try {
// Set the soft type
attr_table.put(SOFT_TYPE, DocumentType.ECP.getDisplay());
success = super.createDocument();
}
// CHECKSTYLE:OFF-IllegalCatchCheck - extends
catch (Exception e) {
String szNumber = LoadServerHelper.getValue(
NUMBER, attr_table, cmd_line, LoadServerHelper.REQUIRED);
logError(e, szNumber, attr_table,
szFullLogPath, szFullFailuresPath, KEYWORD);
}
// CHECKSTYLE:ON-IllegalCatchCheck - extends
return success;
}
/**
* Method to return the attrContainer
* @param attrContainer
* @param ecpDoc
* @return
* @throws WTException
*/
private static DefaultAttributeContainer getAttrContainer (DefaultAttributeContainer attrContainer, WTDocument doc) throws WTException{
DefaultAttributeContainer szAttrContainer = attrContainer ;
WTDocument ecpDoc = null ;
if (szAttrContainer == null){
ecpDoc = (WTDocument) PalmaIBAHelper.service.refresh(doc);
szAttrContainer = (DefaultAttributeContainer) ecpDoc.getAttributeContainer();
}
return szAttrContainer ;
}
/**
* @return the szFullLogPath
*/
public String getSzFullLogPath() {
return szFullLogPath;
}
/**
* @return the szFullFailuresPath
*/
public String getSzFullFailuresPath() {
return szFullFailuresPath;
}
// CHECKSTYLE:OFF-IllegalTypeCheck
@Override
protected void setSpecificIBAs(WTDocument doc) throws Exception { // NOPMD
DefaultAttributeContainer attrContainer =
(DefaultAttributeContainer) doc.getAttributeContainer();
attrContainer = getAttrContainer(attrContainer, doc);
String szCtd = LoadServerHelper.getValue(
CTD, attr_table, cmd_line, LoadServerHelper.REQUIRED);
/*String szCage = LoadServerHelper.getValue(
CAGE, attr_table, cmd_line, LoadServerHelper.REQUIRED);*/
// ECP Class
String szECPClass = LoadServerHelper.getValue(
ECP_CLASS_CVS_NAME, attr_table, cmd_line, LoadServerHelper.REQUIRED);
// Asking Customer Aproval
String szAskingCustomerApproval = LoadServerHelper.getValue(
ASKING_CUSTOMER_APPROVAL_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Customer Name
String szCustomerName = LoadServerHelper.getValue(
CUSTOMER_NAME_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Expected customer approval date
String szCustomerApprovalDate = LoadServerHelper.getValue(
CUSTOMER_APPROVAL_DATE_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Asking Offcicial Services Aproval
String szAskingOfficialServiceApproval = LoadServerHelper.getValue(
ASKING_OFFICIAL_SERVICE_APPROVAL_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Official Services Approval Name
String szOfficialServiceApprovalName = LoadServerHelper.getValue(
OFFICIAL_SERVICE_APPROVAL_NAME_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
// Expected customer approval date
String szOfficialServiceApprovalDate = LoadServerHelper.getValue(
OFFICIAL_SERVICE_APPROVAL_DATE_CVS_NAME, attr_table, cmd_line, LoadServerHelper.NOT_REQUIRED);
AbstractValueView attrValueView = null;
AttributeDefDefaultView attrDefinizerView = null;
// CTD
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(
InstanceBasedAttributeIF.CTD_IBA_NAME);
attrValueView = new StringValueDefaultView(
(StringDefView) attrDefinizerView, szCtd);
attrContainer.deleteAttributeValues(attrDefinizerView);
attrContainer.addAttributeValue(attrValueView);
// ECP Class
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(
InstanceBasedAttributeIF.ECP_CLASS_IBA_NAME);
AbstractValueView attrValueViewECP = new StringValueDefaultView(
(StringDefView) attrDefinizerView, szECPClass);
attrContainer.deleteAttributeValues(attrDefinizerView);
attrContainer.addAttributeValue(attrValueViewECP);
// Asking Customer Aproval
if(szAskingCustomerApproval != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.ASKING_FOR_CUSTOMER_APPROVAL_IBA_NAME);
attrValueView = new BooleanValueDefaultView((BooleanDefView) attrDefinizerView, "1".equals(szAskingCustomerApproval));
attrContainer.addAttributeValue(attrValueView);
}
// Customer Name
if(szCustomerName != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( InstanceBasedAttributeIF.CUSTOMER_NAME_IBA_NAME);
attrValueView = new StringValueDefaultView((StringDefView) attrDefinizerView, szCustomerName);
attrContainer.addAttributeValue(attrValueView);
}
// Customer Aproval Date
if (szCustomerApprovalDate != null) {
Timestamp createTimestamp = new Timestamp(sdf.parse(szCustomerApprovalDate).getTime());
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.CUSTOMER_APPROVAL_DATE_IBA_NAME);
attrValueView = new TimestampValueDefaultView((TimestampDefView) attrDefinizerView, createTimestamp);
attrContainer.addAttributeValue(attrValueView);
}
// Asking Official Service Aproval
if(szAskingOfficialServiceApproval != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.ASKING_FOR_OFFICIAL_SERVICES_APPROVAL_IBA_NAME);
attrValueView = new BooleanValueDefaultView((BooleanDefView) attrDefinizerView, "1".equals(szAskingOfficialServiceApproval));
attrContainer.addAttributeValue(attrValueView);
}
// Official Services Approval Name
if(szOfficialServiceApprovalName != null)
{
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath( InstanceBasedAttributeIF.OFFICIAL_SERVICES_APPROVAL_NAME_IBA_NAME);
attrValueView = new StringValueDefaultView((StringDefView) attrDefinizerView, szOfficialServiceApprovalName);
attrContainer.addAttributeValue(attrValueView);
}
// Official Service Aproval Date
if (szOfficialServiceApprovalDate != null) {
Timestamp createTimestamp = new Timestamp(sdf.parse(szOfficialServiceApprovalDate).getTime());
attrDefinizerView = IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(InstanceBasedAttributeIF.OFFICIAL_SERVICES_APPROVAL_DATE_IBA_NAME);
attrValueView = new TimestampValueDefaultView((TimestampDefView) attrDefinizerView, createTimestamp);
attrContainer.addAttributeValue(attrValueView);
}
}
// CHECKSTYLE:ON-IllegalTypeCheck
/**
* Trace error into log file and rewrite failed line
* into failures file.
*
* @param nv
* @param cmd_line
* @param return_objects
* @return
*/
@Override
//CHECKSTYLE:OFF-IllegalType
protected void logError(
Exception e,
String szIdentifier,
Hashtable<String, String> attrTable,//NOPMD
String szLogPath,
String szFailuresPath,
String szClassName) {
//CHECKSTYLE:ON-IllegalType
super.logError(e, szIdentifier, attrTable, getSzFullLogPath(), getSzFullFailuresPath(), KEYWORD);
}
}
| 11,880
| 0.738315
| 0.735205
| 347
| 33.282421
| 32.727253
| 157
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.144092
| false
| false
|
13
|
e874d1588bd5d56b8bc6e4835da0e4acc7ce88e5
| 22,522,808,501,988
|
b7afdefb33180cd7ec807ad88cd49c282f930fac
|
/src/basics/Cities.java
|
5214087a63c3a8aa2d45f37c0f6ac2688fab144f
|
[] |
no_license
|
jekj2015/Java-Basics
|
https://github.com/jekj2015/Java-Basics
|
4e9ecd00241743005055783fa66ac09b93c3b893
|
f2453d2f35f9a29add5fd45acdb9c69698bb1e00
|
refs/heads/master
| 2021-05-01T07:44:56.484000
| 2018-02-18T20:00:48
| 2018-02-18T20:00:48
| 121,164,004
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package basics;
public class Cities {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] cities = {"New York" , "Dallas","Miami"};
System.out.println("First city is " + cities[0]);
String[] states = new String[5];
states[0] = "California";
states[1] = "Utah";
states[2] = "Nevada";
states[3] = "Alaska";
states[4] = "Florida";
for(int i=0;i<5;i++)
{
System.out.println("State is "+states[i]);
}
String[] Countries;
Countries = new String[5];
Countries[0] = "India";
Countries[1] = "USA";
Countries[2] = "Canada";
Countries[3] = "UK";
Countries[4] = "Bhutan";
boolean countryfound = false;
int j = 0;
while(!countryfound )
{
System.out.println("Country is "+Countries[j]);
if(Countries[j]== "Bhutan");
{
countryfound = true;
System.out.println("Country Found ");
}
j++;
}
for (int i = 0; i< 5 ;i ++)
{
System.out.println("Country from FOR is "+Countries[i]);
}
}
}
|
UTF-8
|
Java
| 1,101
|
java
|
Cities.java
|
Java
|
[] | null |
[] |
package basics;
public class Cities {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] cities = {"New York" , "Dallas","Miami"};
System.out.println("First city is " + cities[0]);
String[] states = new String[5];
states[0] = "California";
states[1] = "Utah";
states[2] = "Nevada";
states[3] = "Alaska";
states[4] = "Florida";
for(int i=0;i<5;i++)
{
System.out.println("State is "+states[i]);
}
String[] Countries;
Countries = new String[5];
Countries[0] = "India";
Countries[1] = "USA";
Countries[2] = "Canada";
Countries[3] = "UK";
Countries[4] = "Bhutan";
boolean countryfound = false;
int j = 0;
while(!countryfound )
{
System.out.println("Country is "+Countries[j]);
if(Countries[j]== "Bhutan");
{
countryfound = true;
System.out.println("Country Found ");
}
j++;
}
for (int i = 0; i< 5 ;i ++)
{
System.out.println("Country from FOR is "+Countries[i]);
}
}
}
| 1,101
| 0.531335
| 0.514986
| 59
| 17.661016
| 16.169243
| 61
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 3.355932
| false
| false
|
13
|
b6d4577a637512ac17ab73706c993a3145d9cc6c
| 28,106,266,007,525
|
701bd1482fad0466a12afe353eb19a810ac98454
|
/SpringBoot/案例/SpringBoot2/src/main/java/com/sw/entity/YmalEntity.java
|
618c811fa04d8b0f1881b8dcc1e2a69920216af6
|
[] |
no_license
|
zhaoshanwu/Note
|
https://github.com/zhaoshanwu/Note
|
b03c390538b2e5533a4e9639bc3e1e8d920c0d3c
|
1decd3ff2506401908801b9af1728a02bb73da05
|
refs/heads/master
| 2022-12-13T21:27:15.988000
| 2020-09-16T06:14:20
| 2020-09-16T06:14:20
| 291,425,775
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.sw.entity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Component // 加入到Ioc容器
@ConfigurationProperties(prefix = "yaml.level") // 读取配置中前缀为yaml下的数据
public class YmalEntity {
private String star;
private String SpecialStr;
private int num;
private double Dnum;
private Date birth;
private List<String> list;
private Set set;
private Map<String,String> map;
private User user;
@Override
public String toString() {
return "YmalEntity{" +
"star='" + star + '\'' +
", SpecialStr='" + SpecialStr + '\'' +
", num=" + num +
", Dnum=" + Dnum +
", birth=" + birth +
", list=" + list +
", set=" + set +
", map=" + map +
", user=" + user +
'}';
}
public String getStar() {
return star;
}
public void setStar(String star) {
this.star = star;
}
public String getSpecialStr() {
return SpecialStr;
}
public void setSpecialStr(String specialStr) {
SpecialStr = specialStr;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public double getDnum() {
return Dnum;
}
public void setDnum(double dnum) {
Dnum = dnum;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
public Set getSet() {
return set;
}
public void setSet(Set set) {
this.set = set;
}
public Map<String, String> getMap() {
return map;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
|
UTF-8
|
Java
| 2,276
|
java
|
YmalEntity.java
|
Java
|
[] | null |
[] |
package com.sw.entity;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Component // 加入到Ioc容器
@ConfigurationProperties(prefix = "yaml.level") // 读取配置中前缀为yaml下的数据
public class YmalEntity {
private String star;
private String SpecialStr;
private int num;
private double Dnum;
private Date birth;
private List<String> list;
private Set set;
private Map<String,String> map;
private User user;
@Override
public String toString() {
return "YmalEntity{" +
"star='" + star + '\'' +
", SpecialStr='" + SpecialStr + '\'' +
", num=" + num +
", Dnum=" + Dnum +
", birth=" + birth +
", list=" + list +
", set=" + set +
", map=" + map +
", user=" + user +
'}';
}
public String getStar() {
return star;
}
public void setStar(String star) {
this.star = star;
}
public String getSpecialStr() {
return SpecialStr;
}
public void setSpecialStr(String specialStr) {
SpecialStr = specialStr;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public double getDnum() {
return Dnum;
}
public void setDnum(double dnum) {
Dnum = dnum;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
public Set getSet() {
return set;
}
public void setSet(Set set) {
this.set = set;
}
public Map<String, String> getMap() {
return map;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
| 2,276
| 0.539251
| 0.539251
| 110
| 19.381819
| 16.107582
| 75
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.418182
| false
| false
|
13
|
9acc5510e48240b83e67284cdcb6dc33be602c88
| 31,739,808,350,036
|
eb032d1031d7e3562c2f00431bf18d6ca204cfdd
|
/src/pl/igore/shop/DAO/TransactionDAO.java
|
34cf9ab424d66f9d03c6275c9182d502ea0fe6b0
|
[] |
no_license
|
szczepkowski/Shop
|
https://github.com/szczepkowski/Shop
|
10d46274e96d76b9b0e2ccb1368107d436b483e7
|
b93db899ab8d01ea0986bc31017fda22f2b2b248
|
refs/heads/master
| 2020-06-08T23:24:15.525000
| 2013-04-05T17:54:46
| 2013-04-05T17:54:46
| 9,099,610
| 2
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package pl.igore.shop.DAO;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import pl.igore.shop.POJO.Offer;
import pl.igore.shop.POJO.Transaction;
import pl.igore.shop.POJO.User;
public class TransactionDAO extends DAO{
public static final TransactionDAO instance = new TransactionDAO();
public TransactionDAO(){}
public Transaction create(Offer offer) throws AdException{
Transaction trans = new Transaction(offer);
try{
begin();
getSession().save(trans);
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not create transaction from offer named = "+offer.getName(),e);
}
finally{
close();
}
return trans;
}
public void save(Transaction trans) throws AdException{
try{
begin();
getSession().save(trans);
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not save transaction from offer named = "+trans.getOffer().getName(),e);
}
finally{
close();
}
}
public List<Transaction> getById(int id) throws AdException{
List<Transaction> trans = null;
try{
begin();
Query query = getSession().createQuery("from Transaction where id=:id");
query.setParameter("id", id);
trans=query.list();
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not get Transasction with id = "+id,e);
}
return trans;
}
public List<Transaction>listByUser(String user){
Criteria crit = getSession().createCriteria(Transaction.class);
Criteria offerCrit = crit.createCriteria("offer");
Criteria userCrit = offerCrit.createCriteria("buyer");
userCrit.add(Restrictions.eq("name", user));
List<Transaction>list=crit.list();
return list;
}
public List<Transaction> list() throws AdException{
List<Transaction> list = null;
try{
begin();
Query query = getSession().createQuery("from Transaction");
list=query.list();
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not get Transaction list ",e);
}
return list;
}
}
|
UTF-8
|
Java
| 2,273
|
java
|
TransactionDAO.java
|
Java
|
[
{
"context": "a(\"buyer\");\n\t\tuserCrit.add(Restrictions.eq(\"name\", user));\n\t\tList<Transaction>list=crit.list();\n\n\t\t\n\t\tret",
"end": 1866,
"score": 0.6399165987968445,
"start": 1862,
"tag": "USERNAME",
"value": "user"
}
] | null |
[] |
package pl.igore.shop.DAO;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import pl.igore.shop.POJO.Offer;
import pl.igore.shop.POJO.Transaction;
import pl.igore.shop.POJO.User;
public class TransactionDAO extends DAO{
public static final TransactionDAO instance = new TransactionDAO();
public TransactionDAO(){}
public Transaction create(Offer offer) throws AdException{
Transaction trans = new Transaction(offer);
try{
begin();
getSession().save(trans);
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not create transaction from offer named = "+offer.getName(),e);
}
finally{
close();
}
return trans;
}
public void save(Transaction trans) throws AdException{
try{
begin();
getSession().save(trans);
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not save transaction from offer named = "+trans.getOffer().getName(),e);
}
finally{
close();
}
}
public List<Transaction> getById(int id) throws AdException{
List<Transaction> trans = null;
try{
begin();
Query query = getSession().createQuery("from Transaction where id=:id");
query.setParameter("id", id);
trans=query.list();
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not get Transasction with id = "+id,e);
}
return trans;
}
public List<Transaction>listByUser(String user){
Criteria crit = getSession().createCriteria(Transaction.class);
Criteria offerCrit = crit.createCriteria("offer");
Criteria userCrit = offerCrit.createCriteria("buyer");
userCrit.add(Restrictions.eq("name", user));
List<Transaction>list=crit.list();
return list;
}
public List<Transaction> list() throws AdException{
List<Transaction> list = null;
try{
begin();
Query query = getSession().createQuery("from Transaction");
list=query.list();
commit();
}
catch(HibernateException e){
rollback();
throw new AdException("Could not get Transaction list ",e);
}
return list;
}
}
| 2,273
| 0.696436
| 0.696436
| 96
| 22.677084
| 23.24081
| 104
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.5
| false
| false
|
13
|
7852b443fd44ca5a080ad4ba28b552f15ca064b3
| 30,915,174,621,377
|
6c9ad96037832323caad18f212c9c1a4707c8d7e
|
/src/main/java/pl/tomekreda/library/utils/Utils.java
|
3db68e707e973ffbdea41a2380c6083189241bae
|
[] |
no_license
|
TomaszReda/library
|
https://github.com/TomaszReda/library
|
647595891c8514deffa41b772a046ac07880e638
|
df848ed4287b344705a7c85b753403b1b11f7466
|
refs/heads/master
| 2021-11-28T10:16:40.639000
| 2020-04-29T19:59:48
| 2020-04-29T19:59:48
| 154,558,142
| 0
| 1
| null | false
| 2020-04-29T05:48:54
| 2018-10-24T19:32:40
| 2020-04-29T05:47:15
| 2020-04-29T05:48:52
| 2,281
| 0
| 1
| 10
|
Java
| false
| false
|
package pl.tomekreda.library.utils;
import lombok.extern.slf4j.Slf4j;
import pl.tomekreda.library.model.book.Book;
import pl.tomekreda.library.model.book.BookState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public final class Utils {
private Utils() {
//not caled
}
public static String convert(BookState bookState) {
String state = "";
if (bookState.equals(BookState.BOOKED)) {
state = "Zarezerwowana";
} else if (bookState.equals(BookState.CONFIRMED)) {
state = "Wyporzyczona";
} else if (bookState.equals(BookState.NOTRESERVED)) {
state = "Dostępna";
} else {
state = "Usunieta";
}
return state;
}
public static List<Map<String, Object>> createBookList(List<Book> bookList) {
List<Map<String, Object>> listLibrary = new ArrayList<>();
for (Book b : bookList) {
Map<String, Object> map = new HashMap<>();
map.put("author", b.getAuthor());
map.put("title", b.getTitle());
map.put("publisher", b.getPublisher());
map.put("libraryId", b.getLibrary().getId());
map.put("bookState", Utils.convert(b.getBookState()));
map.put("quant", b.getQuant());
map.put("bookId", b.getId());
listLibrary.add(map);
}
return listLibrary;
}
public static List<Map<String, Object>> createBookListForUserOwner(List<Book> bookList) throws NoSuchFieldException {
List<Map<String, Object>> mapArrayList = new ArrayList<>();
for (Book b : bookList) {
Map<String, Object> tmp = new HashMap<>();
tmp.put(Book.class.getDeclaredField("author").getName(), b.getAuthor());
tmp.put(Book.class.getDeclaredField("title").getName(), b.getTitle());
tmp.put(Book.class.getDeclaredField("publisher").getName(), b.getPublisher());
tmp.put(Book.class.getDeclaredField("date").getName(), b.getDate());
tmp.put(Book.class.getDeclaredField("quant").getName(), b.getQuant());
tmp.put(Book.class.getDeclaredField("isbn").getName(), b.getIsbn());
tmp.put("bookId", b.getId());
tmp.put("libraryName", b.getLibrary().getName());
mapArrayList.add(tmp);
}
return mapArrayList;
}
}
|
UTF-8
|
Java
| 2,444
|
java
|
Utils.java
|
Java
|
[] | null |
[] |
package pl.tomekreda.library.utils;
import lombok.extern.slf4j.Slf4j;
import pl.tomekreda.library.model.book.Book;
import pl.tomekreda.library.model.book.BookState;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public final class Utils {
private Utils() {
//not caled
}
public static String convert(BookState bookState) {
String state = "";
if (bookState.equals(BookState.BOOKED)) {
state = "Zarezerwowana";
} else if (bookState.equals(BookState.CONFIRMED)) {
state = "Wyporzyczona";
} else if (bookState.equals(BookState.NOTRESERVED)) {
state = "Dostępna";
} else {
state = "Usunieta";
}
return state;
}
public static List<Map<String, Object>> createBookList(List<Book> bookList) {
List<Map<String, Object>> listLibrary = new ArrayList<>();
for (Book b : bookList) {
Map<String, Object> map = new HashMap<>();
map.put("author", b.getAuthor());
map.put("title", b.getTitle());
map.put("publisher", b.getPublisher());
map.put("libraryId", b.getLibrary().getId());
map.put("bookState", Utils.convert(b.getBookState()));
map.put("quant", b.getQuant());
map.put("bookId", b.getId());
listLibrary.add(map);
}
return listLibrary;
}
public static List<Map<String, Object>> createBookListForUserOwner(List<Book> bookList) throws NoSuchFieldException {
List<Map<String, Object>> mapArrayList = new ArrayList<>();
for (Book b : bookList) {
Map<String, Object> tmp = new HashMap<>();
tmp.put(Book.class.getDeclaredField("author").getName(), b.getAuthor());
tmp.put(Book.class.getDeclaredField("title").getName(), b.getTitle());
tmp.put(Book.class.getDeclaredField("publisher").getName(), b.getPublisher());
tmp.put(Book.class.getDeclaredField("date").getName(), b.getDate());
tmp.put(Book.class.getDeclaredField("quant").getName(), b.getQuant());
tmp.put(Book.class.getDeclaredField("isbn").getName(), b.getIsbn());
tmp.put("bookId", b.getId());
tmp.put("libraryName", b.getLibrary().getName());
mapArrayList.add(tmp);
}
return mapArrayList;
}
}
| 2,444
| 0.596398
| 0.59517
| 68
| 34.926472
| 27.832649
| 121
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.852941
| false
| false
|
13
|
727156349431d0c3e6cdcf1413de2a1063ffbcc4
| 8,942,121,946,253
|
678a3d58c110afd1e9ce195d2f20b2531d45a2e0
|
/sources/com/airbnb/android/lib/fragments/DeclineInquiryFragment$$Lambda$2.java
|
c8a49b3864d15cbe9fb908494df2c42faab754de
|
[] |
no_license
|
jasonnth/AirCode
|
https://github.com/jasonnth/AirCode
|
d1c37fb9ba3d8087efcdd9fa2103fb85d13735d5
|
d37db1baa493fca56f390c4205faf5c9bbe36604
|
refs/heads/master
| 2020-07-03T08:35:24.902000
| 2019-08-12T03:34:56
| 2019-08-12T03:34:56
| 201,842,970
| 0
| 2
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.airbnb.android.lib.fragments;
import com.airbnb.airrequest.AirRequestNetworkException;
import p032rx.functions.Action1;
final /* synthetic */ class DeclineInquiryFragment$$Lambda$2 implements Action1 {
private final DeclineInquiryFragment arg$1;
private DeclineInquiryFragment$$Lambda$2(DeclineInquiryFragment declineInquiryFragment) {
this.arg$1 = declineInquiryFragment;
}
public static Action1 lambdaFactory$(DeclineInquiryFragment declineInquiryFragment) {
return new DeclineInquiryFragment$$Lambda$2(declineInquiryFragment);
}
public void call(Object obj) {
DeclineInquiryFragment.lambda$new$1(this.arg$1, (AirRequestNetworkException) obj);
}
}
|
UTF-8
|
Java
| 719
|
java
|
DeclineInquiryFragment$$Lambda$2.java
|
Java
|
[] | null |
[] |
package com.airbnb.android.lib.fragments;
import com.airbnb.airrequest.AirRequestNetworkException;
import p032rx.functions.Action1;
final /* synthetic */ class DeclineInquiryFragment$$Lambda$2 implements Action1 {
private final DeclineInquiryFragment arg$1;
private DeclineInquiryFragment$$Lambda$2(DeclineInquiryFragment declineInquiryFragment) {
this.arg$1 = declineInquiryFragment;
}
public static Action1 lambdaFactory$(DeclineInquiryFragment declineInquiryFragment) {
return new DeclineInquiryFragment$$Lambda$2(declineInquiryFragment);
}
public void call(Object obj) {
DeclineInquiryFragment.lambda$new$1(this.arg$1, (AirRequestNetworkException) obj);
}
}
| 719
| 0.771905
| 0.753825
| 20
| 34.950001
| 34.492718
| 93
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.4
| false
| false
|
13
|
184790f51cf22eaf1e81cd9ad75c86c54638a38b
| 8,942,121,944,606
|
79929b8288783de096723c0751f249264752ffee
|
/app/src/main/java/com/nipponit/fiportal/commentActivity.java
|
92d9a60c1dc48718e6a854e81be84f177e924d2a
|
[] |
no_license
|
manojmadhuran/NPLK.FI.PORTAL
|
https://github.com/manojmadhuran/NPLK.FI.PORTAL
|
915efe7bb22f8902db46fd8d836aa10e15e8d2bf
|
107605049c18dde3f81da933aa781abd84af663c
|
refs/heads/main
| 2023-02-27T03:50:58.902000
| 2021-02-09T09:34:47
| 2021-02-09T09:34:47
| 337,354,869
| 0
| 0
| null | true
| 2021-02-09T09:35:47
| 2021-02-09T09:35:47
| 2021-02-09T09:26:37
| 2021-02-09T09:26:34
| 0
| 0
| 0
| 0
| null | false
| false
|
package com.nipponit.fiportal;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.app.role.RoleManager;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import com.nipponit.fiportal.db.dbconnection;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
public class commentActivity extends AppCompatActivity {
ListView lstcomments;
Button btnNeedEnh, btnNoNeedEnh;
ArrayList<commentModel> datamodel;
commentAdapter adapter;
private static String ROLE = "Role", NAME = "Name", name = "", REQUEST_ID = "ReqID",CUSTOMER_NAME = "cusName",ReqID = "",cusName="",
RTYPE = "RType", rtype = "",REQUEST_TYPE = "reqType";
String files = "";
private static int role = 0;
private int CurLevel = 0, EHS_ = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comment);
ReqID = getIntent().getStringExtra(REQUEST_ID);
cusName = getIntent().getStringExtra(CUSTOMER_NAME);
name = getIntent().getStringExtra(NAME);
role = getIntent().getIntExtra(ROLE,0);
rtype = getIntent().getStringExtra(RTYPE);
lstcomments = (ListView) findViewById(R.id.lstComments);
btnNeedEnh = (Button)findViewById(R.id.btn_enhance);
btnNoNeedEnh = (Button)findViewById(R.id.btn_no_enhance);
btnNeedEnh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = null;
if(role > 2){
intent = new Intent(commentActivity.this, asm_rm_Activity.class);
}else{
intent = new Intent(commentActivity.this, enhanceActivity.class);
}
intent.putExtra(REQUEST_ID,ReqID);
intent.putExtra(CUSTOMER_NAME,cusName);
intent.putExtra(NAME,name);
intent.putExtra(ROLE,role);
intent.putExtra(RTYPE,rtype);
intent.putExtra(REQUEST_TYPE, 1);
startActivityForResult(intent,1);
}
});
btnNoNeedEnh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(commentActivity.this, noEnhanceActivity.class);
intent.putExtra(REQUEST_ID, ReqID);
intent.putExtra(CUSTOMER_NAME,cusName);
intent.putExtra(NAME,name);
intent.putExtra(ROLE,role);
intent.putExtra(RTYPE,rtype);
startActivityForResult(intent,1);
}
});
if(role == 2){
btnNeedEnh.setEnabled(true);
btnNoNeedEnh.setEnabled(true);
btnNeedEnh.setText("Need Enhancement");
btnNoNeedEnh.setText("No Need Enhancement");
}
else if(role > 2){
btnNeedEnh.setEnabled(true);
btnNeedEnh.setText("Proceed Request");
}
new AsyncCommentData().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.requests,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.attachment:
if( files != null ) {
openAttachment();
}else{
Toast.makeText(this, "No attachment", Toast.LENGTH_SHORT).show();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void openAttachment() {
String baseURL = "http://192.168.101.131/cmp/Content/uploaded/";
String url = baseURL + files;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// Verify that the intent will resolve to an activity
if (intent.resolveActivity(getPackageManager()) != null) {
// Here we use an intent without a Chooser unlike the next example
startActivity(intent);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 1){
new AsyncCommentData().execute();
}
}
class AsyncCommentData extends AsyncTask<Integer,Integer,Integer>{
ProgressDialog prgdialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
datamodel = new ArrayList<>();
prgdialog= new ProgressDialog(commentActivity.this);
prgdialog.setMessage("Downloading comment data,Please wait..!");
prgdialog.setCancelable(false);
prgdialog.show();
}
@Override
protected Integer doInBackground(Integer... integers) {
dbconnection connection = new dbconnection();
datamodel = connection.DownloadCommentData(ReqID);
if( datamodel != null && datamodel.size() > 0) {
CurLevel = datamodel.get(0).getCurLevel();
files = datamodel.get(0).getAttachment();
//EHS_ = Integer.parseInt(datamodel.get(0).getENS());
}
return 1;
}
@Override
protected void onPostExecute(Integer integer) {
super.onPostExecute(integer);
if(datamodel != null) {
adapter = new commentAdapter(getApplicationContext(), datamodel);
lstcomments.setAdapter(adapter);
if(CurLevel != role){
// btnNeedEnh.setVisibility(View.INVISIBLE);
// btnNoNeedEnh.setVisibility(View.INVISIBLE);
btnNeedEnh.setEnabled(false);
btnNoNeedEnh.setEnabled(false);
}
//IF NO NEED ENHANCEMENT REVERT TO MAIN SCREEN.
//COMMENTED BY REQUEST
// if(EHS_ == 2){
// finish();
// }
}
prgdialog.dismiss();
}
}
}
|
UTF-8
|
Java
| 6,802
|
java
|
commentActivity.java
|
Java
|
[
{
"context": "me = \"\", REQUEST_ID = \"ReqID\",CUSTOMER_NAME = \"cusName\",ReqID = \"\",cusName=\"\",\n RTYPE = \"RTyp",
"end": 973,
"score": 0.9063284397125244,
"start": 969,
"tag": "USERNAME",
"value": "Name"
},
{
"context": "ME,cusName);\n intent.putExtra(NAME,name);\n intent.putExtra(ROLE,role);\n ",
"end": 2352,
"score": 0.6755707263946533,
"start": 2348,
"tag": "NAME",
"value": "name"
},
{
"context": "achment() {\n\n String baseURL = \"http://192.168.101.131/cmp/Content/uploaded/\";\n String url = ",
"end": 4289,
"score": 0.9996868968009949,
"start": 4274,
"tag": "IP_ADDRESS",
"value": "192.168.101.131"
}
] | null |
[] |
package com.nipponit.fiportal;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.app.role.RoleManager;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import com.nipponit.fiportal.db.dbconnection;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
public class commentActivity extends AppCompatActivity {
ListView lstcomments;
Button btnNeedEnh, btnNoNeedEnh;
ArrayList<commentModel> datamodel;
commentAdapter adapter;
private static String ROLE = "Role", NAME = "Name", name = "", REQUEST_ID = "ReqID",CUSTOMER_NAME = "cusName",ReqID = "",cusName="",
RTYPE = "RType", rtype = "",REQUEST_TYPE = "reqType";
String files = "";
private static int role = 0;
private int CurLevel = 0, EHS_ = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_comment);
ReqID = getIntent().getStringExtra(REQUEST_ID);
cusName = getIntent().getStringExtra(CUSTOMER_NAME);
name = getIntent().getStringExtra(NAME);
role = getIntent().getIntExtra(ROLE,0);
rtype = getIntent().getStringExtra(RTYPE);
lstcomments = (ListView) findViewById(R.id.lstComments);
btnNeedEnh = (Button)findViewById(R.id.btn_enhance);
btnNoNeedEnh = (Button)findViewById(R.id.btn_no_enhance);
btnNeedEnh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = null;
if(role > 2){
intent = new Intent(commentActivity.this, asm_rm_Activity.class);
}else{
intent = new Intent(commentActivity.this, enhanceActivity.class);
}
intent.putExtra(REQUEST_ID,ReqID);
intent.putExtra(CUSTOMER_NAME,cusName);
intent.putExtra(NAME,name);
intent.putExtra(ROLE,role);
intent.putExtra(RTYPE,rtype);
intent.putExtra(REQUEST_TYPE, 1);
startActivityForResult(intent,1);
}
});
btnNoNeedEnh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(commentActivity.this, noEnhanceActivity.class);
intent.putExtra(REQUEST_ID, ReqID);
intent.putExtra(CUSTOMER_NAME,cusName);
intent.putExtra(NAME,name);
intent.putExtra(ROLE,role);
intent.putExtra(RTYPE,rtype);
startActivityForResult(intent,1);
}
});
if(role == 2){
btnNeedEnh.setEnabled(true);
btnNoNeedEnh.setEnabled(true);
btnNeedEnh.setText("Need Enhancement");
btnNoNeedEnh.setText("No Need Enhancement");
}
else if(role > 2){
btnNeedEnh.setEnabled(true);
btnNeedEnh.setText("Proceed Request");
}
new AsyncCommentData().execute();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.requests,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.attachment:
if( files != null ) {
openAttachment();
}else{
Toast.makeText(this, "No attachment", Toast.LENGTH_SHORT).show();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void openAttachment() {
String baseURL = "http://192.168.101.131/cmp/Content/uploaded/";
String url = baseURL + files;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// Verify that the intent will resolve to an activity
if (intent.resolveActivity(getPackageManager()) != null) {
// Here we use an intent without a Chooser unlike the next example
startActivity(intent);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 1){
new AsyncCommentData().execute();
}
}
class AsyncCommentData extends AsyncTask<Integer,Integer,Integer>{
ProgressDialog prgdialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
datamodel = new ArrayList<>();
prgdialog= new ProgressDialog(commentActivity.this);
prgdialog.setMessage("Downloading comment data,Please wait..!");
prgdialog.setCancelable(false);
prgdialog.show();
}
@Override
protected Integer doInBackground(Integer... integers) {
dbconnection connection = new dbconnection();
datamodel = connection.DownloadCommentData(ReqID);
if( datamodel != null && datamodel.size() > 0) {
CurLevel = datamodel.get(0).getCurLevel();
files = datamodel.get(0).getAttachment();
//EHS_ = Integer.parseInt(datamodel.get(0).getENS());
}
return 1;
}
@Override
protected void onPostExecute(Integer integer) {
super.onPostExecute(integer);
if(datamodel != null) {
adapter = new commentAdapter(getApplicationContext(), datamodel);
lstcomments.setAdapter(adapter);
if(CurLevel != role){
// btnNeedEnh.setVisibility(View.INVISIBLE);
// btnNoNeedEnh.setVisibility(View.INVISIBLE);
btnNeedEnh.setEnabled(false);
btnNoNeedEnh.setEnabled(false);
}
//IF NO NEED ENHANCEMENT REVERT TO MAIN SCREEN.
//COMMENTED BY REQUEST
// if(EHS_ == 2){
// finish();
// }
}
prgdialog.dismiss();
}
}
}
| 6,802
| 0.587915
| 0.583652
| 203
| 32.507389
| 24.953033
| 136
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.689655
| false
| false
|
13
|
b43ff20d81f63f2a2d8d799fe762e6607bfce084
| 8,976,481,680,104
|
09b3c9c9ee533edaaea9bbff053890333f64258b
|
/eBudgeting/src/main/java/biz/thaicom/eBudgeting/repositories/UserRepository.java
|
cd87c555a108f5295ea5ae6791852fda4348759d
|
[] |
no_license
|
BloomingLotus/orraf
|
https://github.com/BloomingLotus/orraf
|
5807514285d032286b5165b4986626e2d210c0a9
|
e49267b65fe83eed73416f0cd2fd54077dbe9a3a
|
refs/heads/master
| 2021-01-18T06:54:00.333000
| 2012-12-19T14:54:36
| 2012-12-19T14:54:36
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package biz.thaicom.eBudgeting.repositories;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import biz.thaicom.security.models.User;
public interface UserRepository extends PagingAndSortingRepository<User, Long>,
JpaSpecificationExecutor<User> {
public User findByUsernameAndPassword(String userName, String password);
public User findByUsername(String username);
}
|
UTF-8
|
Java
| 487
|
java
|
UserRepository.java
|
Java
|
[] | null |
[] |
package biz.thaicom.eBudgeting.repositories;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import biz.thaicom.security.models.User;
public interface UserRepository extends PagingAndSortingRepository<User, Long>,
JpaSpecificationExecutor<User> {
public User findByUsernameAndPassword(String userName, String password);
public User findByUsername(String username);
}
| 487
| 0.823409
| 0.823409
| 14
| 32.785713
| 30.850281
| 79
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| false
| false
|
13
|
a0654d3dbb42ccefad8e02a86b4bc0dc7465ba98
| 26,353,919,364,830
|
d8b985e57199c07cdb2ba0d6616461cd2404493d
|
/src/java/hard/matrix/DungeonGame.java
|
28e2fad578b938218b7a700ab23cf70092c0ebd3
|
[] |
no_license
|
zorrowang/LeetCode
|
https://github.com/zorrowang/LeetCode
|
a872627b0477242ff2cefac5e7b02fd044a7243f
|
0954bde87881735b3f662e5374e247ebc7a88bd7
|
refs/heads/master
| 2023-02-22T12:20:54.452000
| 2021-01-27T09:46:29
| 2021-01-27T09:46:29
| 10,343,411
| 6
| 2
| null | false
| 2020-02-17T21:03:12
| 2013-05-28T19:19:48
| 2020-02-17T20:03:11
| 2020-02-17T21:03:11
| 156
| 1
| 1
| 0
|
Java
| false
| false
|
package src.java.hard.matrix;
import java.util.ArrayList;
import java.util.List;
public class DungeonGame {
// Backtracking - TLE
public int calculateMinimumHP(int[][] dungeon) {
List<Integer> list = new ArrayList<>();
list.add(dungeon[0][0]);
int ret = dfs(dungeon, 0, 0, list);
if (ret >= 0) return 1;
else return -ret+1;
}
private int dfs(int[][] dungeon, int m, int n, List<Integer> list) {
if (m==dungeon.length-1 && n==dungeon[m].length-1) {
int sum = 0, ret = 0;
for (int i=0; i<list.size(); i++) {
sum += list.get(i);
if (ret > sum) ret = sum;
}
return ret;
}
int max = Integer.MIN_VALUE;
int[][] dirs = {{0, 1}, {1, 0}};
for (int i=0; i<dirs.length; i++) {
int newM = m + dirs[i][0];
int newN = n + dirs[i][1];
if (newM < dungeon.length && newN < dungeon[0].length) {
list.add(dungeon[newM][newN]);
int curMin = dfs(dungeon, newM, newN, list);
list.remove(list.size()-1);
max = Math.max(max, curMin);
}
}
return max;
}
// DP solution
public int calculateMinimumHP2(int[][] dungeon) {
//dp[i][j] = minimum health level required to reach the princess when entering (i, j)
// dp[i][j] = max{min{dp[i-1][j], dp[i][j-1]} - dungeon[i][j], 0}
int m = dungeon.length;
int n = m == 0 ? 0 : dungeon[0].length;
int[][] dp = new int[m+1][n+1];
for(int i=0; i<=m; i++) dp[i][n] = Integer.MAX_VALUE;
for(int i=0; i<=n; i++) dp[m][i] = Integer.MAX_VALUE;
dp[m-1][n] = 0;
dp[m][n-1] = 0;
for (int i=m-1; i>=0; i--) {
for (int j=n-1; j>=0; j--) {
dp[i][j] = Math.max(Math.min(dp[i+1][j], dp[i][j+1]) - dungeon[i][j], 0);
}
}
return dp[0][0]+1;
}
}
|
UTF-8
|
Java
| 2,028
|
java
|
DungeonGame.java
|
Java
|
[] | null |
[] |
package src.java.hard.matrix;
import java.util.ArrayList;
import java.util.List;
public class DungeonGame {
// Backtracking - TLE
public int calculateMinimumHP(int[][] dungeon) {
List<Integer> list = new ArrayList<>();
list.add(dungeon[0][0]);
int ret = dfs(dungeon, 0, 0, list);
if (ret >= 0) return 1;
else return -ret+1;
}
private int dfs(int[][] dungeon, int m, int n, List<Integer> list) {
if (m==dungeon.length-1 && n==dungeon[m].length-1) {
int sum = 0, ret = 0;
for (int i=0; i<list.size(); i++) {
sum += list.get(i);
if (ret > sum) ret = sum;
}
return ret;
}
int max = Integer.MIN_VALUE;
int[][] dirs = {{0, 1}, {1, 0}};
for (int i=0; i<dirs.length; i++) {
int newM = m + dirs[i][0];
int newN = n + dirs[i][1];
if (newM < dungeon.length && newN < dungeon[0].length) {
list.add(dungeon[newM][newN]);
int curMin = dfs(dungeon, newM, newN, list);
list.remove(list.size()-1);
max = Math.max(max, curMin);
}
}
return max;
}
// DP solution
public int calculateMinimumHP2(int[][] dungeon) {
//dp[i][j] = minimum health level required to reach the princess when entering (i, j)
// dp[i][j] = max{min{dp[i-1][j], dp[i][j-1]} - dungeon[i][j], 0}
int m = dungeon.length;
int n = m == 0 ? 0 : dungeon[0].length;
int[][] dp = new int[m+1][n+1];
for(int i=0; i<=m; i++) dp[i][n] = Integer.MAX_VALUE;
for(int i=0; i<=n; i++) dp[m][i] = Integer.MAX_VALUE;
dp[m-1][n] = 0;
dp[m][n-1] = 0;
for (int i=m-1; i>=0; i--) {
for (int j=n-1; j>=0; j--) {
dp[i][j] = Math.max(Math.min(dp[i+1][j], dp[i][j+1]) - dungeon[i][j], 0);
}
}
return dp[0][0]+1;
}
}
| 2,028
| 0.457594
| 0.434911
| 60
| 32.816666
| 22.00946
| 93
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.016667
| false
| false
|
13
|
af6226a89ad67918fef82580db73098782c8fe8d
| 18,468,359,408,434
|
d16f1bd8aaa946b7a8afbb9e58668fd3cf3d7f20
|
/src/main/java/com/github/manolo8/darkbot/core/utils/Location.java
|
3fdd33f5229aa810e9185f8cd868fed2992a5c5f
|
[] |
no_license
|
DarkEvil80/DarkBot
|
https://github.com/DarkEvil80/DarkBot
|
18542beffc99e1253227ebfac3a36105a652d584
|
34397befdd0088cff8363df224667013b76048b9
|
refs/heads/master
| 2020-09-07T09:12:01.576000
| 2020-01-16T01:33:57
| 2020-01-16T01:33:57
| 220,734,404
| 0
| 0
| null | true
| 2019-11-10T03:08:00
| 2019-11-10T03:07:59
| 2019-10-15T18:11:40
| 2019-11-10T02:05:51
| 3,868
| 0
| 0
| 0
| null | false
| false
|
package com.github.manolo8.darkbot.core.utils;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
import static java.lang.StrictMath.atan2;
public class Location {
public double x;
public double y;
public Location() {
}
public Location(double x, double y) {
this.x = x;
this.y = y;
}
public double distance(double ox, double oy) {
return sqrt(pow(x - ox, 2) + pow(y - oy, 2));
}
public double distance(Location o) {
return sqrt(pow(x - o.x, 2) + pow(y - o.y, 2));
}
public double angle(Location o) {
return atan2(y - o.y, x - o.x);
}
public Location copy() {
return new Location(x, y);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Location) {
Location location = (Location) obj;
return location.x == x && location.y == y;
}
return false;
}
}
|
UTF-8
|
Java
| 958
|
java
|
Location.java
|
Java
|
[
{
"context": "package com.github.manolo8.darkbot.core.utils;\n\nimport static java.lang.Math",
"end": 26,
"score": 0.9979895949363708,
"start": 19,
"tag": "USERNAME",
"value": "manolo8"
}
] | null |
[] |
package com.github.manolo8.darkbot.core.utils;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
import static java.lang.StrictMath.atan2;
public class Location {
public double x;
public double y;
public Location() {
}
public Location(double x, double y) {
this.x = x;
this.y = y;
}
public double distance(double ox, double oy) {
return sqrt(pow(x - ox, 2) + pow(y - oy, 2));
}
public double distance(Location o) {
return sqrt(pow(x - o.x, 2) + pow(y - o.y, 2));
}
public double angle(Location o) {
return atan2(y - o.y, x - o.x);
}
public Location copy() {
return new Location(x, y);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Location) {
Location location = (Location) obj;
return location.x == x && location.y == y;
}
return false;
}
}
| 958
| 0.56785
| 0.560543
| 46
| 19.826086
| 18.616617
| 55
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.5
| false
| false
|
13
|
9f4b75372b22e70b342baf5d44210c2f2ee4b68e
| 20,675,972,585,771
|
98e2b7835c7e774aeb101ed57804c695ebc66f2d
|
/src/Shower.java
|
7b453cab963a1b761314d992c317206f79cfdc23
|
[] |
no_license
|
arkan382382/PhotoCollage
|
https://github.com/arkan382382/PhotoCollage
|
6a84e53a02344948f9cbb92df1519bbe1e89f9a7
|
4e7a167bea0ea839aec97279f94b0ea77fa64b07
|
refs/heads/master
| 2021-01-01T04:52:13.235000
| 2017-09-06T18:49:41
| 2017-09-06T18:49:41
| 97,259,741
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import static java.awt.SystemColor.window;
/**
* Created by arkan on 05.09.2017.
*/
//public class Shower extends JPanel {
// public void paintComponent(Graphics g){}
/* StorageOfSmallPictures small = new StorageOfSmallPictures();
private BufferedImage diskImage;
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage();
}
}
/* FinalPicture finalForValues = new FinalPicture();
JFrame b[][] = new JFrame[finalForValues.getCellsVertically()][finalForValues.getCellsHorizontally()];
public Shower(String title, JFrame window){
super(title);
setLayout(new GridLayout(finalForValues.getCellsVertically(), finalForValues.getCellsHorizontally(), 1,1));
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
window.setSize((int)finalForValues.getHeightOfFinalPicture(), (int)finalForValues.getWidthOfFinalPicture());
}
public void run(){
}
/*JPanel panel;
JFrame window;
FinalPicture finalForValues = new FinalPicture();
public Setup(Starter start, JFrame window){
window.setSize((int)finalForValues.getHeightOfFinalPicture(), (int)finalForValues.getWidthOfFinalPicture());
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
panel = new Display(start);
this.window = window;
}
public void run(){
window.getContentPane().add(panel);
window.setBackground(Color.BLACK);
window.setVisible(true);
} } //new Display(start) startuje jpanel
*/
|
UTF-8
|
Java
| 1,712
|
java
|
Shower.java
|
Java
|
[
{
"context": "c java.awt.SystemColor.window;\n\n/**\n * Created by arkan on 05.09.2017.\n */\n//public class Shower extends ",
"end": 146,
"score": 0.992011308670044,
"start": 141,
"tag": "USERNAME",
"value": "arkan"
}
] | null |
[] |
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import static java.awt.SystemColor.window;
/**
* Created by arkan on 05.09.2017.
*/
//public class Shower extends JPanel {
// public void paintComponent(Graphics g){}
/* StorageOfSmallPictures small = new StorageOfSmallPictures();
private BufferedImage diskImage;
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage();
}
}
/* FinalPicture finalForValues = new FinalPicture();
JFrame b[][] = new JFrame[finalForValues.getCellsVertically()][finalForValues.getCellsHorizontally()];
public Shower(String title, JFrame window){
super(title);
setLayout(new GridLayout(finalForValues.getCellsVertically(), finalForValues.getCellsHorizontally(), 1,1));
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
window.setSize((int)finalForValues.getHeightOfFinalPicture(), (int)finalForValues.getWidthOfFinalPicture());
}
public void run(){
}
/*JPanel panel;
JFrame window;
FinalPicture finalForValues = new FinalPicture();
public Setup(Starter start, JFrame window){
window.setSize((int)finalForValues.getHeightOfFinalPicture(), (int)finalForValues.getWidthOfFinalPicture());
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
panel = new Display(start);
this.window = window;
}
public void run(){
window.getContentPane().add(panel);
window.setBackground(Color.BLACK);
window.setVisible(true);
} } //new Display(start) startuje jpanel
*/
| 1,712
| 0.67757
| 0.669393
| 49
| 33.918365
| 31.636221
| 116
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.673469
| false
| false
|
13
|
ecccbd019f38dea3a31e9d79e1eb69c7eefd56bf
| 919,123,057,806
|
aef4d117b8c29525c60672d623365239c6f892bd
|
/openiam-idm/openiam-idm-services/src/main/java/org/openiam/dozer/ProvisionDozerUtils.java
|
01d7708971a128f286f48d0086677c90b5d296d8
|
[] |
no_license
|
OpenIAM/iam-services-3
|
https://github.com/OpenIAM/iam-services-3
|
958c8bab5a96f28656078f2420e092f3f5adc0f3
|
d19867f871bc4307f9b4d11269ee90d02ae86676
|
refs/heads/master
| 2018-04-10T23:01:15.827000
| 2017-10-23T11:45:19
| 2017-10-23T11:45:19
| 79,580,543
| 3
| 1
| null | false
| 2018-06-27T12:28:34
| 2017-01-20T17:24:17
| 2018-03-02T02:28:44
| 2018-06-27T12:28:34
| 30,918
| 3
| 0
| 1
|
Java
| false
| null |
package org.openiam.dozer;
import org.dozer.DozerBeanMapper;
import org.openiam.provision.dto.ProvisionUser;
import org.springframework.beans.factory.annotation.Required;
public class ProvisionDozerUtils {
private DozerBeanMapper deepMapper;
private DozerBeanMapper shallowMapper;
@Required
public void setDeepMapper(final DozerBeanMapper deepMapper) {
this.deepMapper = deepMapper;
}
@Required
public void setShallowMapper(final DozerBeanMapper shallowMapper) {
this.shallowMapper = shallowMapper;
}
public ProvisionUser getDozerDeepedMappedProvisionUser(final ProvisionUser provisionUser) {
ProvisionUser retVal = null;
if(provisionUser != null) {
retVal = deepMapper.map(provisionUser, ProvisionUser.class);
}
return retVal;
}
}
|
UTF-8
|
Java
| 765
|
java
|
ProvisionDozerUtils.java
|
Java
|
[] | null |
[] |
package org.openiam.dozer;
import org.dozer.DozerBeanMapper;
import org.openiam.provision.dto.ProvisionUser;
import org.springframework.beans.factory.annotation.Required;
public class ProvisionDozerUtils {
private DozerBeanMapper deepMapper;
private DozerBeanMapper shallowMapper;
@Required
public void setDeepMapper(final DozerBeanMapper deepMapper) {
this.deepMapper = deepMapper;
}
@Required
public void setShallowMapper(final DozerBeanMapper shallowMapper) {
this.shallowMapper = shallowMapper;
}
public ProvisionUser getDozerDeepedMappedProvisionUser(final ProvisionUser provisionUser) {
ProvisionUser retVal = null;
if(provisionUser != null) {
retVal = deepMapper.map(provisionUser, ProvisionUser.class);
}
return retVal;
}
}
| 765
| 0.8
| 0.8
| 28
| 26.321428
| 25.158148
| 92
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.428571
| false
| false
|
13
|
545297337a13c6af627f20e61ef3ec6cac5dd45d
| 31,044,023,673,553
|
3c500ad85f13411f3a99d784c7185a6a1acea9c1
|
/thunder-framework/src/main/java/com/nepxion/thunder/protocol/mq/MQConnectionHierachy.java
|
37461dc8acacdce535d17ddda6ead773da105aea
|
[
"Apache-2.0"
] |
permissive
|
Nepxion/Thunder
|
https://github.com/Nepxion/Thunder
|
767c6e651f58437b3fe64346c8045dafe5f42d95
|
c8d8f77ddefbe6ade2b8c86ee3bc8f29962f524a
|
refs/heads/master
| 2023-04-13T14:15:13.717000
| 2023-04-09T12:29:24
| 2023-04-09T12:29:24
| 48,207,333
| 236
| 100
|
Apache-2.0
| false
| 2021-06-23T06:37:49
| 2015-12-18T01:24:44
| 2021-06-23T06:30:32
| 2021-06-23T06:30:26
| 14,102
| 203
| 87
| 0
|
Java
| false
| false
|
package com.nepxion.thunder.protocol.mq;
/**
* <p>Title: Nepxion Thunder</p>
* <p>Description: Nepxion Thunder For Distribution</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import javax.jms.ConnectionFactory;
import org.springframework.beans.factory.InitializingBean;
import com.nepxion.thunder.common.constant.ThunderConstant;
import com.nepxion.thunder.common.util.ClassUtil;
public class MQConnectionHierachy extends MQHierachy {
@SuppressWarnings("incomplete-switch")
@Override
public void initialize() throws Exception {
super.initialize();
String initialConnectionFactoryClass = mqPropertyEntity.getMQEntity().getInitialConnectionFactoryClass();
String url = mqPropertyEntity.getString(ThunderConstant.MQ_URL_ATTRIBUTE_NAME);
String userName = mqPropertyEntity.getString(ThunderConstant.MQ_USER_NAME_ATTRIBUTE_NAME);
String password = mqPropertyEntity.getString(ThunderConstant.MQ_PASSWORD_ATTRIBUTE_NAME);
ConnectionFactory targetConnectionFactory = ClassUtil.createInstance(initialConnectionFactoryClass);
switch (protocolType) {
case ACTIVE_MQ:
ClassUtil.invoke(targetConnectionFactory, "setBrokerURL", new Class<?>[] { String.class }, new Object[] { url });
ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
ClassUtil.invoke(targetConnectionFactory, "setPassword", new Class<?>[] { String.class }, new Object[] { password });
break;
case TIBCO:
ClassUtil.invoke(targetConnectionFactory, "setServerUrl", new Class<?>[] { String.class }, new Object[] { url });
ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
ClassUtil.invoke(targetConnectionFactory, "setUserPassword", new Class<?>[] { String.class }, new Object[] { password });
break;
}
if (targetConnectionFactory instanceof InitializingBean) {
InitializingBean initializingBean = (InitializingBean) targetConnectionFactory;
initializingBean.afterPropertiesSet();
}
setTargetConnectionFactory(targetConnectionFactory);
afterPropertiesSet();
}
}
|
UTF-8
|
Java
| 2,419
|
java
|
MQConnectionHierachy.java
|
Java
|
[
{
"context": "017-2050</p>\n * <p>Company: Nepxion</p>\n * @author Haojun Ren\n * @version 1.0\n */\n\nimport javax.jms.ConnectionF",
"end": 228,
"score": 0.9998164176940918,
"start": 218,
"tag": "NAME",
"value": "Haojun Ren"
},
{
"context": "\", new Class<?>[] { String.class }, new Object[] { userName });\n ClassUtil.invoke(targetConnec",
"end": 1477,
"score": 0.7176467180252075,
"start": 1469,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "\", new Class<?>[] { String.class }, new Object[] { userName });\n ClassUtil.invoke(targetConnec",
"end": 1922,
"score": 0.9371597766876221,
"start": 1914,
"tag": "USERNAME",
"value": "userName"
}
] | null |
[] |
package com.nepxion.thunder.protocol.mq;
/**
* <p>Title: Nepxion Thunder</p>
* <p>Description: Nepxion Thunder For Distribution</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author <NAME>
* @version 1.0
*/
import javax.jms.ConnectionFactory;
import org.springframework.beans.factory.InitializingBean;
import com.nepxion.thunder.common.constant.ThunderConstant;
import com.nepxion.thunder.common.util.ClassUtil;
public class MQConnectionHierachy extends MQHierachy {
@SuppressWarnings("incomplete-switch")
@Override
public void initialize() throws Exception {
super.initialize();
String initialConnectionFactoryClass = mqPropertyEntity.getMQEntity().getInitialConnectionFactoryClass();
String url = mqPropertyEntity.getString(ThunderConstant.MQ_URL_ATTRIBUTE_NAME);
String userName = mqPropertyEntity.getString(ThunderConstant.MQ_USER_NAME_ATTRIBUTE_NAME);
String password = mqPropertyEntity.getString(ThunderConstant.MQ_PASSWORD_ATTRIBUTE_NAME);
ConnectionFactory targetConnectionFactory = ClassUtil.createInstance(initialConnectionFactoryClass);
switch (protocolType) {
case ACTIVE_MQ:
ClassUtil.invoke(targetConnectionFactory, "setBrokerURL", new Class<?>[] { String.class }, new Object[] { url });
ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
ClassUtil.invoke(targetConnectionFactory, "setPassword", new Class<?>[] { String.class }, new Object[] { password });
break;
case TIBCO:
ClassUtil.invoke(targetConnectionFactory, "setServerUrl", new Class<?>[] { String.class }, new Object[] { url });
ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
ClassUtil.invoke(targetConnectionFactory, "setUserPassword", new Class<?>[] { String.class }, new Object[] { password });
break;
}
if (targetConnectionFactory instanceof InitializingBean) {
InitializingBean initializingBean = (InitializingBean) targetConnectionFactory;
initializingBean.afterPropertiesSet();
}
setTargetConnectionFactory(targetConnectionFactory);
afterPropertiesSet();
}
}
| 2,415
| 0.688714
| 0.68458
| 55
| 43
| 43.608589
| 137
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.745455
| false
| false
|
13
|
641c2e353ae13278c7adc087968da8d9e8b4d8c7
| 21,174,188,794,600
|
bd8408923b9e42be1cf36908df6dda351ab19d48
|
/Math/HappyNumber.java
|
c52dcaeacf89aa0979f0e3aea310863f8dc1928c
|
[] |
no_license
|
erictang06/shuati
|
https://github.com/erictang06/shuati
|
f10edd17b6a7887e612045bff613ad04cccbe23b
|
7599c775a32d4714c3be337bb079684edec44a7f
|
refs/heads/master
| 2020-03-21T23:58:53.508000
| 2018-06-30T03:57:48
| 2018-06-30T03:57:48
| 139,217,187
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package shuati.Math;
/**
*
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer,
replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay),
or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
*/
/**
* Lesson learned: for anything indifinte loop, try think of the fast/slow pointer approach
*/
public class HappyNumber {
public boolean isHappy(int n) {
int slow = n;
int fast = n;
do {
slow = digitSum(slow);
fast = digitSum(fast);
fast = digitSum(fast);
} while (slow != fast);
if (slow == 1) {
return true;
}
return false;
}
private int digitSum(int n) {
int sum = 0;
int tmp = 0;
while (n > 0) {
tmp = n % 10;
sum += tmp * tmp;
n /= 10;
}
return sum;
}
}
|
UTF-8
|
Java
| 1,016
|
java
|
HappyNumber.java
|
Java
|
[] | null |
[] |
package shuati.Math;
/**
*
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer,
replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay),
or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
*/
/**
* Lesson learned: for anything indifinte loop, try think of the fast/slow pointer approach
*/
public class HappyNumber {
public boolean isHappy(int n) {
int slow = n;
int fast = n;
do {
slow = digitSum(slow);
fast = digitSum(fast);
fast = digitSum(fast);
} while (slow != fast);
if (slow == 1) {
return true;
}
return false;
}
private int digitSum(int n) {
int sum = 0;
int tmp = 0;
while (n > 0) {
tmp = n % 10;
sum += tmp * tmp;
n /= 10;
}
return sum;
}
}
| 1,016
| 0.625984
| 0.615157
| 45
| 21.577778
| 30.845486
| 131
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.422222
| false
| false
|
13
|
db003ca74ebb16ab06f258c450d3aae6a1755655
| 12,601,434,088,346
|
fed61775fa1a33365df6c9d1adcbfbbb6178dce2
|
/src/ru/javawebinar/basejava/storage/SortedArrayStorage.java
|
f2bc022195176b9db474f50bfb0b3ff14d17d093
|
[] |
no_license
|
sirius-devel/basejava
|
https://github.com/sirius-devel/basejava
|
98b3df8d74c05032c4f5d2f91f687fc3943c43e2
|
15b25aafd0ec24d85924e2850145239e37cf641a
|
refs/heads/master
| 2022-12-04T22:23:22.041000
| 2020-08-30T18:50:04
| 2020-08-30T18:50:04
| 273,193,234
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package ru.javawebinar.basejava.storage;
import ru.javawebinar.basejava.model.Resume;
import java.util.Arrays;
import java.util.Comparator;
public class SortedArrayStorage extends AbstractArrayStorage {
/*
private static class ResumeComparator implements Comparator<Resume> {
@Override
public int compare(Resume o1, Resume o2) {
return o1.getUuid().compareTo(o2.getUuid());
}
}
*/
/*private static final Comparator<Resume> RESUME_COMPARATOR = new Comparator<Resume>() {
@Override
public int compare(Resume o1, Resume o2) {
return o1.getUuid().compareTo(o2.getUuid());
}
};*/
private static final Comparator<Resume> RESUME_COMPARATOR = Comparator.comparing(Resume::getUuid);
@Override
protected void insertElement(Resume resume, Integer index) {
int insertionPoint = -index - 1;
System.arraycopy(storage, insertionPoint, storage, insertionPoint+1, size - 1 - insertionPoint);
storage[insertionPoint] = resume;
}
@Override
protected void removeElement(Integer index) {
System.arraycopy(storage, index + 1, storage, index, size - 1 - index);
}
@Override
protected Integer getSearchKey(String uuid) {
Resume resume = new Resume(uuid, "dummy");
return Arrays.binarySearch(storage, 0, size, resume, RESUME_COMPARATOR);
}
}
|
UTF-8
|
Java
| 1,410
|
java
|
SortedArrayStorage.java
|
Java
|
[] | null |
[] |
package ru.javawebinar.basejava.storage;
import ru.javawebinar.basejava.model.Resume;
import java.util.Arrays;
import java.util.Comparator;
public class SortedArrayStorage extends AbstractArrayStorage {
/*
private static class ResumeComparator implements Comparator<Resume> {
@Override
public int compare(Resume o1, Resume o2) {
return o1.getUuid().compareTo(o2.getUuid());
}
}
*/
/*private static final Comparator<Resume> RESUME_COMPARATOR = new Comparator<Resume>() {
@Override
public int compare(Resume o1, Resume o2) {
return o1.getUuid().compareTo(o2.getUuid());
}
};*/
private static final Comparator<Resume> RESUME_COMPARATOR = Comparator.comparing(Resume::getUuid);
@Override
protected void insertElement(Resume resume, Integer index) {
int insertionPoint = -index - 1;
System.arraycopy(storage, insertionPoint, storage, insertionPoint+1, size - 1 - insertionPoint);
storage[insertionPoint] = resume;
}
@Override
protected void removeElement(Integer index) {
System.arraycopy(storage, index + 1, storage, index, size - 1 - index);
}
@Override
protected Integer getSearchKey(String uuid) {
Resume resume = new Resume(uuid, "dummy");
return Arrays.binarySearch(storage, 0, size, resume, RESUME_COMPARATOR);
}
}
| 1,410
| 0.670213
| 0.660284
| 45
| 30.333334
| 30.704325
| 104
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.666667
| false
| false
|
13
|
3e46e504c2eccab4eb14aeed8f96d6edca6354f3
| 35,519,379,557,093
|
9ec96b45fca441216956bc91afcc5cbb6e8b7ef8
|
/PRJ311x_02_VN/TodoList/src/com/timbuchalka/todolist/DialogController.java
|
931e3eb87ffc00d613279f8ce7ba971adef01a1c
|
[] |
no_license
|
le-trung-cu/sub-funix-cc3
|
https://github.com/le-trung-cu/sub-funix-cc3
|
4477ff73e5669f4595016420a916333802a5c5cb
|
faf7cadb079814e41d8f3b9d18471d99aebaa639
|
refs/heads/main
| 2023-04-20T05:02:44.762000
| 2021-04-27T14:32:38
| 2021-04-27T14:32:38
| 345,246,214
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.timbuchalka.todolist;
import com.timbuchalka.todolist.datamodel.TodoData;
import com.timbuchalka.todolist.datamodel.TodoItem;
import javafx.fxml.FXML;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import java.time.LocalDate;
public class DialogController {
@FXML
private TextField shortDescriptionFiled;
@FXML
private TextArea detailsArea;
@FXML
private DatePicker deadlinePicker;
public TodoItem processResults(){
String shortDescription = shortDescriptionFiled.getText();
String details = detailsArea.getText();
LocalDate deadlineValue = deadlinePicker.getValue();
TodoItem todoItem = new TodoItem(shortDescription, details, deadlineValue);
TodoData.getInstance().addTodoItem(todoItem);
return todoItem;
}
}
|
UTF-8
|
Java
| 877
|
java
|
DialogController.java
|
Java
|
[] | null |
[] |
package com.timbuchalka.todolist;
import com.timbuchalka.todolist.datamodel.TodoData;
import com.timbuchalka.todolist.datamodel.TodoItem;
import javafx.fxml.FXML;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import java.time.LocalDate;
public class DialogController {
@FXML
private TextField shortDescriptionFiled;
@FXML
private TextArea detailsArea;
@FXML
private DatePicker deadlinePicker;
public TodoItem processResults(){
String shortDescription = shortDescriptionFiled.getText();
String details = detailsArea.getText();
LocalDate deadlineValue = deadlinePicker.getValue();
TodoItem todoItem = new TodoItem(shortDescription, details, deadlineValue);
TodoData.getInstance().addTodoItem(todoItem);
return todoItem;
}
}
| 877
| 0.754846
| 0.754846
| 28
| 30.321428
| 22.115046
| 83
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.678571
| false
| false
|
13
|
bcc30f82f4a1e2cbae8aea88f218ebc4fbbd31dd
| 18,588,618,507,715
|
bebf48193c07eda8bcf89568d37060b4909e912c
|
/Ficha_11_e_12/Pratical_Worksheet_11/Additional Player Functionalities/src/player/IFile.java
|
c9c5b941769f9cdda6ce3a5f242f224d3b81658f
|
[] |
no_license
|
samuelcunha28/PP
|
https://github.com/samuelcunha28/PP
|
6262d739492ec628c49a15d722b2b6bdb53241b6
|
fe65eb74599789a29e8355b2dc1d1ca2a0d0c90f
|
refs/heads/master
| 2021-07-07T00:14:21.998000
| 2020-09-04T10:44:54
| 2020-09-04T10:44:54
| 176,917,901
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package player;
public interface IFile {
/**
* Gets the attribute name
*
* @return The file name
*/
public String getName();
/**
* Gets the attribute extension
*
* @return The file extension
*/
public String getExtension();
/**
* Gets the attribute sizeKB
*
* @return The size in KB
*/
public int getSizeKB();
/**
* Gets the attribute durationSecs
*
* @return The file duration in seconds
*/
public int getDurationSecs();
/**
* Returns a string representation of the object. In general, the toString
* method returns a string that "textually represents" this object. The
* result should be a concise but informative representation that is easy
* for a person to read
*
* @return A string representation of the object
*/
@Override
public String toString();
/**
* Indicates whether some other object is "equal to" this one, that is, if
* the other object is an instance of <code>File</code> and all its asttributes
* are the same as this object
*
* @param obj The reference object with which to compare
* @return <code>true</code>if this object is "the same" as the
* <code>obj</code>, <code>false</code> otherwise
*/
@Override
public boolean equals(Object obj);
}
|
UTF-8
|
Java
| 1,382
|
java
|
IFile.java
|
Java
|
[] | null |
[] |
package player;
public interface IFile {
/**
* Gets the attribute name
*
* @return The file name
*/
public String getName();
/**
* Gets the attribute extension
*
* @return The file extension
*/
public String getExtension();
/**
* Gets the attribute sizeKB
*
* @return The size in KB
*/
public int getSizeKB();
/**
* Gets the attribute durationSecs
*
* @return The file duration in seconds
*/
public int getDurationSecs();
/**
* Returns a string representation of the object. In general, the toString
* method returns a string that "textually represents" this object. The
* result should be a concise but informative representation that is easy
* for a person to read
*
* @return A string representation of the object
*/
@Override
public String toString();
/**
* Indicates whether some other object is "equal to" this one, that is, if
* the other object is an instance of <code>File</code> and all its asttributes
* are the same as this object
*
* @param obj The reference object with which to compare
* @return <code>true</code>if this object is "the same" as the
* <code>obj</code>, <code>false</code> otherwise
*/
@Override
public boolean equals(Object obj);
}
| 1,382
| 0.615051
| 0.615051
| 54
| 24.592592
| 23.829268
| 83
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.203704
| false
| false
|
13
|
bd0590a0c32b951398d4ca51319adad7451c9bd4
| 24,275,155,207,129
|
a8da1cde999b42e81aebe312d9eff2f89dcf70cd
|
/pstsql/src/main/java/com/richie/pstsql/controller/MainController.java
|
f881bbcf6d97a2b6593a9311144e023743a42134
|
[] |
no_license
|
RichieZhl/AllDemo
|
https://github.com/RichieZhl/AllDemo
|
ec0d5970dc21de7ea4e09cbe7df737ea98e138b8
|
13c5c477da0c6c5b50c1e622c210459768d69481
|
refs/heads/master
| 2022-09-15T22:29:08.731000
| 2019-05-28T08:31:08
| 2019-05-28T08:31:08
| 188,383,234
| 0
| 0
| null | false
| 2022-09-08T01:00:06
| 2019-05-24T08:25:31
| 2019-05-28T08:31:19
| 2022-09-08T01:00:05
| 675
| 0
| 0
| 10
|
Java
| false
| false
|
package com.richie.pstsql.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.richie.pstsql.entity.User;
import com.richie.pstsql.repository.UserRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* pstsql
* <p>
* Created by lylaut on 2019-05-17
*/
@RestController
@RequestMapping("/api")
public class MainController {
@Autowired
private UserRepository userRepository;
@Autowired
private ObjectMapper objectMapper;
@RequestMapping("/all")
public List<User> getAllUsers() throws JsonProcessingException {
return userRepository.findAll();
}
}
|
UTF-8
|
Java
| 846
|
java
|
MainController.java
|
Java
|
[
{
"context": "estController;\n\n/**\n * pstsql\n * <p>\n * Created by lylaut on 2019-05-17\n */\n@RestController\n@RequestMapping",
"end": 496,
"score": 0.9997299313545227,
"start": 490,
"tag": "USERNAME",
"value": "lylaut"
}
] | null |
[] |
package com.richie.pstsql.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.richie.pstsql.entity.User;
import com.richie.pstsql.repository.UserRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* pstsql
* <p>
* Created by lylaut on 2019-05-17
*/
@RestController
@RequestMapping("/api")
public class MainController {
@Autowired
private UserRepository userRepository;
@Autowired
private ObjectMapper objectMapper;
@RequestMapping("/all")
public List<User> getAllUsers() throws JsonProcessingException {
return userRepository.findAll();
}
}
| 846
| 0.777778
| 0.768322
| 33
| 24.636364
| 22.533232
| 68
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.363636
| false
| false
|
13
|
201352028282936f56bf7c424b22064b1e620f86
| 34,308,198,790,896
|
207c55af06d08b05dab889874c739b904af62fc0
|
/pure-web/src/test/java/org/lzy/test/dao/DaoTest.java
|
10cd643b297bbbd0f24576bf2c28ab258af609a3
|
[] |
no_license
|
lizhiyong1218/pure-web
|
https://github.com/lizhiyong1218/pure-web
|
998e79c95b821f2574feffcaf2cb517aedd55a6e
|
73a33582b27b8021555154f3c28d0a6a2f805932
|
refs/heads/master
| 2021-01-01T20:41:25.382000
| 2015-03-20T08:53:50
| 2015-03-20T08:53:50
| 32,367,507
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.lzy.test.dao;
/**
* 使用测试的时候,要将原来带的java ee5给remove掉,换成uer library j2ee
* defaultRollback=true 不会往数据库中插入数据
*/
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.lzy.api.model.Channel;
import org.lzy.api.model.Classify;
import org.lzy.api.model.Media;
import org.lzy.core.common.Pagination;
import org.lzy.core.common.QueryCondition;
import org.lzy.core.service.IBaseService;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml",
"classpath:dispatcher-servlet.xml"
})
@TransactionConfiguration(transactionManager="txManager",defaultRollback=false)
public class DaoTest extends AbstractTransactionalJUnit4SpringContextTests {
@Resource(name="baseService")
private IBaseService baseService;
/**
* 增
*/
@Test
public void testSave() {
Channel channel=new Channel();
channel.setName("123");
channel.setCruser("lzy");
baseService.save(channel);
System.out.println(1);
}
/**
* 批量增加同类型对象
*/
@Test
public void testbatchSave() {
Channel channel=baseService.getById(Channel.class, (long)1);
Classify classify=baseService.getById(Classify.class, (long)1);
List<Media> ens=new ArrayList<Media>();
for(int i=0;i<10;i++){
Media media=new Media();
media.setTitle("M"+i);
media.setChannel(channel);
media.setClassify(classify);
ens.add(media);
}
baseService.batchSave(ens);
}
/**
* 批量增加不同类型对象
*/
@Test
public void testBatchSave() {
Channel channel=new Channel();
channel.setName("新闻");
channel.setCruser("lzy");
Classify classify=new Classify();
classify.setName("国内");
classify.setCruser("lzy");
List<Object> objects=new ArrayList<Object>();
objects.add(channel);
objects.add(classify);
baseService.batchSave(objects);
}
/**
* 删
*/
@Test
public void testDelete(){
System.out.println(baseService.delete(Classify.class, (long)10));
}
/**
* 通过ID批量删除
*/
@Test
public void testBatchDelete(){
Object[] ids={(long)153,(long)154};
System.out.println(baseService.batchDelete(Media.class, ids));
}
/**
* 改
*/
@Test
public void testUpdate(){
Media media=baseService.getById(Media.class, (long)155);
media.setTitle("新修改!");
baseService.update(media);
}
/**
* 批量修改
*/
public void testBatchUpdate(){
String jpql="update Media m set m.status = 10 where m.id in ('156','157')";
System.out.println("共修改"+baseService.executeJpql(jpql)+"条数据");
}
/**
* 查询所有
*/
@Test
public void testGetAll(){
List<Media> list= baseService.getAll(Media.class);
for (Media media : list) {
System.out.println("title:"+media.getTitle());
}
}
/**
* 同过ID批量查
*/
@Test
public void testGetByIds(){
Object[] ids={(long)155,(long)156};
List<Media> list= baseService.getByIds(Media.class, ids);
for (Media media : list) {
System.out.println("title:"+media.getTitle());
}
}
/**
* 查询分页对象
*/
@Test
public void testGetPagination(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
//和上面写法一样
// String customJPQL="o.title like '%M%'";
// queryConditions.add(new QueryCondition(customJPQL));
String orderBy="order by id desc";
Pagination<Media> pagination= baseService.getPagination(Media.class, queryConditions, orderBy, 1, 2);
System.out.println("size:"+pagination.getRecordList().size());
}
/**
* 通过条件查询单个对象
*/
@Test
public void testGetSingleResult(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("id", QueryCondition.EQ, (long)156));
Media media=(Media)baseService.getSingleResult(Media.class, queryConditions);
System.out.println("id:"+media.getId());
}
/**
* 通过jpql查询单个对象
*/
@Test
public void testGetSingleResultByJpql(){
//要加上select m不然会报错
String jpql="select m from Media m join m.channel c where c.name=? and m.title=?";
Media media=(Media)baseService.getSingleResultByJpql(jpql,"新闻","M3");
System.out.println("id:"+media.getId());
}
/**
* 查询所有符合条件的对象
*/
@Test
public void testGetlistbyconditions(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
List<Media> list=baseService.getListByconditions(Media.class, queryConditions);
System.out.println("size:"+list.size());
}
/**
* 查询所有符合条件的对象
* 排序
*/
@Test
public void testGetlistbyconditions2(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
String orderBy="order by id desc ";
List<Media> list=baseService.getListByConditions(Media.class, queryConditions, orderBy);
System.out.println("size:"+list.size());
}
/**
* 查询所有符合条件的对象
* 排序
* 分页
*/
@Test
public void testGetlistbyconditions3(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
int pageNow=1;
int pageSize=10;
String orderBy="order by id desc ";
List<Media> list=baseService.getListByConditions(Media.class, queryConditions, orderBy,pageNow,pageSize);
System.out.println("size:"+list.size());
}
/**
* 根据jpql查询列表
*/
@Test
public void testGetlistbyjpql(){
String jpql="from Media m join m.channel c where c.name=?";
List<Media> list=baseService.getListByJpql(jpql, "新闻");
System.out.println("size:"+list.size());
}
/**
* 根据jpql查询列表
* 分页
*/
@Test
public void testGetlistbyjpql2(){
String jpql="from Media m join m.channel c where c.name=?";
int pageNow=1;
int pageSize=10;
List<Media> list=baseService.getListByJpql(Media.class,pageNow,pageSize,jpql, "新闻");
System.out.println("size:"+list.size());
}
/**
* 执行jpql语句
*/
@Test
public void testExecuteJpql(){
String jpql="update Media m set m.status = 10 where m.id in ('15','15')";
System.out.println("共修改"+baseService.executeJpql(jpql)+"条数据");
}
/**
* 测试多表查询
*/
@Test
public void testmultitablequery(){
String jpql="select m from Media m join m.channel ch join m.classify lx where ch.id=? and lx.id=?";
List<Media> mList= baseService.getListByJpql(Media.class,1, 10, jpql, (long)13,(long)1);
System.out.println("size:!!!!!!!!!!!!!!!!!!!!!!!!!!!"+mList.size());
}
}
|
UTF-8
|
Java
| 7,432
|
java
|
DaoTest.java
|
Java
|
[] | null |
[] |
package org.lzy.test.dao;
/**
* 使用测试的时候,要将原来带的java ee5给remove掉,换成uer library j2ee
* defaultRollback=true 不会往数据库中插入数据
*/
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.lzy.api.model.Channel;
import org.lzy.api.model.Classify;
import org.lzy.api.model.Media;
import org.lzy.core.common.Pagination;
import org.lzy.core.common.QueryCondition;
import org.lzy.core.service.IBaseService;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml",
"classpath:dispatcher-servlet.xml"
})
@TransactionConfiguration(transactionManager="txManager",defaultRollback=false)
public class DaoTest extends AbstractTransactionalJUnit4SpringContextTests {
@Resource(name="baseService")
private IBaseService baseService;
/**
* 增
*/
@Test
public void testSave() {
Channel channel=new Channel();
channel.setName("123");
channel.setCruser("lzy");
baseService.save(channel);
System.out.println(1);
}
/**
* 批量增加同类型对象
*/
@Test
public void testbatchSave() {
Channel channel=baseService.getById(Channel.class, (long)1);
Classify classify=baseService.getById(Classify.class, (long)1);
List<Media> ens=new ArrayList<Media>();
for(int i=0;i<10;i++){
Media media=new Media();
media.setTitle("M"+i);
media.setChannel(channel);
media.setClassify(classify);
ens.add(media);
}
baseService.batchSave(ens);
}
/**
* 批量增加不同类型对象
*/
@Test
public void testBatchSave() {
Channel channel=new Channel();
channel.setName("新闻");
channel.setCruser("lzy");
Classify classify=new Classify();
classify.setName("国内");
classify.setCruser("lzy");
List<Object> objects=new ArrayList<Object>();
objects.add(channel);
objects.add(classify);
baseService.batchSave(objects);
}
/**
* 删
*/
@Test
public void testDelete(){
System.out.println(baseService.delete(Classify.class, (long)10));
}
/**
* 通过ID批量删除
*/
@Test
public void testBatchDelete(){
Object[] ids={(long)153,(long)154};
System.out.println(baseService.batchDelete(Media.class, ids));
}
/**
* 改
*/
@Test
public void testUpdate(){
Media media=baseService.getById(Media.class, (long)155);
media.setTitle("新修改!");
baseService.update(media);
}
/**
* 批量修改
*/
public void testBatchUpdate(){
String jpql="update Media m set m.status = 10 where m.id in ('156','157')";
System.out.println("共修改"+baseService.executeJpql(jpql)+"条数据");
}
/**
* 查询所有
*/
@Test
public void testGetAll(){
List<Media> list= baseService.getAll(Media.class);
for (Media media : list) {
System.out.println("title:"+media.getTitle());
}
}
/**
* 同过ID批量查
*/
@Test
public void testGetByIds(){
Object[] ids={(long)155,(long)156};
List<Media> list= baseService.getByIds(Media.class, ids);
for (Media media : list) {
System.out.println("title:"+media.getTitle());
}
}
/**
* 查询分页对象
*/
@Test
public void testGetPagination(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
//和上面写法一样
// String customJPQL="o.title like '%M%'";
// queryConditions.add(new QueryCondition(customJPQL));
String orderBy="order by id desc";
Pagination<Media> pagination= baseService.getPagination(Media.class, queryConditions, orderBy, 1, 2);
System.out.println("size:"+pagination.getRecordList().size());
}
/**
* 通过条件查询单个对象
*/
@Test
public void testGetSingleResult(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("id", QueryCondition.EQ, (long)156));
Media media=(Media)baseService.getSingleResult(Media.class, queryConditions);
System.out.println("id:"+media.getId());
}
/**
* 通过jpql查询单个对象
*/
@Test
public void testGetSingleResultByJpql(){
//要加上select m不然会报错
String jpql="select m from Media m join m.channel c where c.name=? and m.title=?";
Media media=(Media)baseService.getSingleResultByJpql(jpql,"新闻","M3");
System.out.println("id:"+media.getId());
}
/**
* 查询所有符合条件的对象
*/
@Test
public void testGetlistbyconditions(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
List<Media> list=baseService.getListByconditions(Media.class, queryConditions);
System.out.println("size:"+list.size());
}
/**
* 查询所有符合条件的对象
* 排序
*/
@Test
public void testGetlistbyconditions2(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
String orderBy="order by id desc ";
List<Media> list=baseService.getListByConditions(Media.class, queryConditions, orderBy);
System.out.println("size:"+list.size());
}
/**
* 查询所有符合条件的对象
* 排序
* 分页
*/
@Test
public void testGetlistbyconditions3(){
List<QueryCondition> queryConditions=new ArrayList<QueryCondition>();
queryConditions.add(new QueryCondition("title", QueryCondition.LK, "M"));
int pageNow=1;
int pageSize=10;
String orderBy="order by id desc ";
List<Media> list=baseService.getListByConditions(Media.class, queryConditions, orderBy,pageNow,pageSize);
System.out.println("size:"+list.size());
}
/**
* 根据jpql查询列表
*/
@Test
public void testGetlistbyjpql(){
String jpql="from Media m join m.channel c where c.name=?";
List<Media> list=baseService.getListByJpql(jpql, "新闻");
System.out.println("size:"+list.size());
}
/**
* 根据jpql查询列表
* 分页
*/
@Test
public void testGetlistbyjpql2(){
String jpql="from Media m join m.channel c where c.name=?";
int pageNow=1;
int pageSize=10;
List<Media> list=baseService.getListByJpql(Media.class,pageNow,pageSize,jpql, "新闻");
System.out.println("size:"+list.size());
}
/**
* 执行jpql语句
*/
@Test
public void testExecuteJpql(){
String jpql="update Media m set m.status = 10 where m.id in ('15','15')";
System.out.println("共修改"+baseService.executeJpql(jpql)+"条数据");
}
/**
* 测试多表查询
*/
@Test
public void testmultitablequery(){
String jpql="select m from Media m join m.channel ch join m.classify lx where ch.id=? and lx.id=?";
List<Media> mList= baseService.getListByJpql(Media.class,1, 10, jpql, (long)13,(long)1);
System.out.println("size:!!!!!!!!!!!!!!!!!!!!!!!!!!!"+mList.size());
}
}
| 7,432
| 0.680966
| 0.671165
| 261
| 24.973181
| 26.075546
| 107
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.816092
| false
| false
|
13
|
5166cd0401ec874144601bdfb4b094c1e9edf76f
| 34,780,645,175,351
|
da8e3c6a7536aed1ccbba858b2bde4fd1442c302
|
/micro-sell-api/src/main/java/com/wancient/springcloud/api/vo/PageModel.java
|
d5e2c1ad27c13a60552607898b5300f9913160c3
|
[] |
no_license
|
wucain/micro-sell
|
https://github.com/wucain/micro-sell
|
21ee4c0447f241c7a06b758b6c0de7df2351b9e0
|
5ee8072b9229d0ae995da1ee453611c5cbcda89e
|
refs/heads/master
| 2022-07-27T12:01:36.296000
| 2020-06-29T07:04:57
| 2020-06-29T07:04:57
| 165,969,689
| 0
| 0
| null | false
| 2022-06-21T03:45:36
| 2019-01-16T03:51:36
| 2020-06-29T07:25:40
| 2022-06-21T03:45:34
| 67,333
| 0
| 0
| 8
|
JavaScript
| false
| false
|
package com.wancient.springcloud.api.vo;
import lombok.Data;
import javax.persistence.Transient;
import java.io.Serializable;
/**
* @author: Wancient
* @date: 2018/6/7
* @time: 23:16
*/
@Data
public class PageModel implements Serializable {
/**
* 页码
*/
@Transient
private int pageNum;
/**
* 每页数据
*/
@Transient
private int pageSize;
/**
* 排序列
*/
@Transient
private String orderSort;
/**
* 排序方向
*/
@Transient
private String orderDirection;
/**
* 开始时间
*/
@Transient
private String startTime;
/**
* 结束时间
*/
@Transient
private String endTime;
}
|
UTF-8
|
Java
| 727
|
java
|
PageModel.java
|
Java
|
[
{
"context": "ent;\nimport java.io.Serializable;\n\n/**\n * @author: Wancient\n * @date: 2018/6/7\n * @time: 23:16\n */\n@Data\npubl",
"end": 153,
"score": 0.9996076226234436,
"start": 145,
"tag": "USERNAME",
"value": "Wancient"
}
] | null |
[] |
package com.wancient.springcloud.api.vo;
import lombok.Data;
import javax.persistence.Transient;
import java.io.Serializable;
/**
* @author: Wancient
* @date: 2018/6/7
* @time: 23:16
*/
@Data
public class PageModel implements Serializable {
/**
* 页码
*/
@Transient
private int pageNum;
/**
* 每页数据
*/
@Transient
private int pageSize;
/**
* 排序列
*/
@Transient
private String orderSort;
/**
* 排序方向
*/
@Transient
private String orderDirection;
/**
* 开始时间
*/
@Transient
private String startTime;
/**
* 结束时间
*/
@Transient
private String endTime;
}
| 727
| 0.560584
| 0.545985
| 51
| 12.431373
| 11.360846
| 48
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.196078
| false
| false
|
13
|
160af64f952e7ab9194973becf846ee56962edfa
| 34,402,688,075,512
|
8fa84350ea8207d5e24dcb07d4150e4535b52e46
|
/src/com/spark/test/Main.java
|
9b5d326d32271723282b6fc233b687331b0aafea
|
[] |
no_license
|
shantanusood/InvestmentStrategies
|
https://github.com/shantanusood/InvestmentStrategies
|
34040e8ec36c69e7ecb64fb0d373ace3e5e85ead
|
54b691c2fbd3f2b604d0d46e0799ddfa0b3cc591
|
refs/heads/master
| 2022-09-21T13:58:12.735000
| 2020-03-29T19:59:51
| 2020-03-29T19:59:51
| 169,824,015
| 0
| 0
| null | false
| 2022-09-01T23:21:56
| 2019-02-09T02:25:53
| 2020-03-29T19:59:58
| 2022-09-01T23:21:55
| 3,453
| 0
| 0
| 4
|
Java
| false
| false
|
package com.spark.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.function.MapFunction;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Encoders;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.RowFactory;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
@Component
public class Main {
/*
* private static final String CSV_SEPARATOR = ",";
*
* @Autowired private SparkSession sparkSession;
*/
public String main(int start, int end) throws IOException {
SparkConf conf = new SparkConf().set("spark.master", "local[*]");
SparkSession spark = SparkSession.builder().config(conf).appName("PrimeApp").getOrCreate();
List<String> rawData = readData().subList(start, end);
List<Row> dataR = new ArrayList<>();
for(String st : rawData) {
dataR.add(RowFactory.create(st));
}
StructType schema = new StructType(new StructField[] {
new StructField("st", DataTypes.StringType, false, Metadata.empty())
});
Dataset<Row> data = spark.createDataFrame(dataR, schema);
Dataset<OutputData> out = data.map(new mainTest(), Encoders.bean(OutputData.class));
return formatIt(new Gson().toJson(out.toDF().collect()));
}
public String formatIt(String unformatter) throws JsonParseException, JsonMappingException, IOException {
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jn = objectMapper.readTree(unformatter);
Map<String, ArrayList<String>> dataMap = new HashMap<>();
JsonNode fields = jn.get(0).get("schema").get("fields");
dataMap.put("ticker", new ArrayList<String>());
for(int j=0;j<fields.size();j++) {
if(!fields.get(j).get("name").asText().equals("ticker"))
dataMap.get("ticker").add(fields.get(j).get("name").asText());
}
for(int i=0;i<jn.size();i++) {
ArrayList<String> lt = new ArrayList<String>();
JsonNode j = jn.get(i).get("values");
for(int k=0;k<j.size();k++) {
lt.add(j.get(k).asText());
}
dataMap.put(lt.get(lt.size()-1), new ArrayList<String>(lt.subList(0, lt.size()-1)));
}
return new Gson().toJson(dataMap);
}
//For reading from local file system
public List<String> readData() throws IOException {
String file = "./Ticker.csv";
List<String> content = new ArrayList<>();
try(BufferedReader br = new BufferedReader(new FileReader(file))) {
String line = "";
while ((line = br.readLine()) != null) {
content.add(line.replaceFirst(",", ""));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
content.remove(0);
return content;
}
}
class mainTest implements MapFunction<Row, OutputData>{
@Override
public OutputData call(Row ticker) throws Exception {
OutputData outData = new OutputData();
outData.setTicker(ticker.get(0).toString());
try {
Document doc = Jsoup.connect("https://research.tdameritrade.com/grid/public/etfs/profile/profile.asp?symbol="+ticker.get(0).toString()).get();
Elements ele_etfName = doc.body().select("h2[id=\"companyName\"]");
Elements ele_etfPrice = doc.body().select("div[class*=\"primaryQuote\"] > div[class=\"fLeft\"]");
Elements ele_etfExp = doc.body().select("div[class=\"dataTable\"] > div:nth-child(1)[class*=\"hasLayout\"] > div[class=\"fright\"]");
Elements ele_etfYield = doc.body().select("div[class=\"dataTable\"] > div:nth-child(5)[class*=\"hasLayout\"] > span[class=\"fright\"]");
Elements ele_etfOneMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(1) > td:nth-child(3) ");
Elements ele_etfThreeMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(2) > td:nth-child(3) ");
Elements ele_etfSixMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(3) > td:nth-child(3) ");
Elements ele_etfYtd = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(4) > td:nth-child(3) ");
Elements ele_etfOneYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(5) > td:nth-child(3) ");
Elements ele_etfThreeYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(6) > td:nth-child(3) ");
Elements ele_etfFiveYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(7) > td:nth-child(3) ");
Elements ele_etfTenYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(8) > td:nth-child(3) ");
Elements ele_etfInception = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(9) > td:nth-child(3) ");
outData.setStr_etfName(ele_etfName.text().trim());
outData.setStr_etfPrice(ele_etfPrice.text().trim());
outData.setStr_etfExp(ele_etfExp.text().trim());
outData.setStr_etfYield(ele_etfYield.text().trim());
outData.setStr_etfOneMonth(ele_etfOneMonth.text().trim());
outData.setStr_etfThreeMonth(ele_etfThreeMonth.text().trim());
outData.setStr_etfSixMonth(ele_etfSixMonth.text().trim());
outData.setStr_etfYtd(ele_etfYtd.text().trim());
outData.setStr_etfOneYear(ele_etfOneYear.text().trim());
outData.setStr_etfThreeYear(ele_etfThreeYear.text().trim());
outData.setStr_etfFiveYear(ele_etfFiveYear.text().trim());
outData.setStr_etfTenYear(ele_etfTenYear.text().trim());
outData.setStr_etfInception(ele_etfInception.text().trim());
}catch(Exception e) {
}
return outData;
}
}
|
UTF-8
|
Java
| 6,922
|
java
|
Main.java
|
Java
|
[] | null |
[] |
package com.spark.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.function.MapFunction;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Encoders;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.RowFactory;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.types.DataTypes;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
@Component
public class Main {
/*
* private static final String CSV_SEPARATOR = ",";
*
* @Autowired private SparkSession sparkSession;
*/
public String main(int start, int end) throws IOException {
SparkConf conf = new SparkConf().set("spark.master", "local[*]");
SparkSession spark = SparkSession.builder().config(conf).appName("PrimeApp").getOrCreate();
List<String> rawData = readData().subList(start, end);
List<Row> dataR = new ArrayList<>();
for(String st : rawData) {
dataR.add(RowFactory.create(st));
}
StructType schema = new StructType(new StructField[] {
new StructField("st", DataTypes.StringType, false, Metadata.empty())
});
Dataset<Row> data = spark.createDataFrame(dataR, schema);
Dataset<OutputData> out = data.map(new mainTest(), Encoders.bean(OutputData.class));
return formatIt(new Gson().toJson(out.toDF().collect()));
}
public String formatIt(String unformatter) throws JsonParseException, JsonMappingException, IOException {
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jn = objectMapper.readTree(unformatter);
Map<String, ArrayList<String>> dataMap = new HashMap<>();
JsonNode fields = jn.get(0).get("schema").get("fields");
dataMap.put("ticker", new ArrayList<String>());
for(int j=0;j<fields.size();j++) {
if(!fields.get(j).get("name").asText().equals("ticker"))
dataMap.get("ticker").add(fields.get(j).get("name").asText());
}
for(int i=0;i<jn.size();i++) {
ArrayList<String> lt = new ArrayList<String>();
JsonNode j = jn.get(i).get("values");
for(int k=0;k<j.size();k++) {
lt.add(j.get(k).asText());
}
dataMap.put(lt.get(lt.size()-1), new ArrayList<String>(lt.subList(0, lt.size()-1)));
}
return new Gson().toJson(dataMap);
}
//For reading from local file system
public List<String> readData() throws IOException {
String file = "./Ticker.csv";
List<String> content = new ArrayList<>();
try(BufferedReader br = new BufferedReader(new FileReader(file))) {
String line = "";
while ((line = br.readLine()) != null) {
content.add(line.replaceFirst(",", ""));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
content.remove(0);
return content;
}
}
class mainTest implements MapFunction<Row, OutputData>{
@Override
public OutputData call(Row ticker) throws Exception {
OutputData outData = new OutputData();
outData.setTicker(ticker.get(0).toString());
try {
Document doc = Jsoup.connect("https://research.tdameritrade.com/grid/public/etfs/profile/profile.asp?symbol="+ticker.get(0).toString()).get();
Elements ele_etfName = doc.body().select("h2[id=\"companyName\"]");
Elements ele_etfPrice = doc.body().select("div[class*=\"primaryQuote\"] > div[class=\"fLeft\"]");
Elements ele_etfExp = doc.body().select("div[class=\"dataTable\"] > div:nth-child(1)[class*=\"hasLayout\"] > div[class=\"fright\"]");
Elements ele_etfYield = doc.body().select("div[class=\"dataTable\"] > div:nth-child(5)[class*=\"hasLayout\"] > span[class=\"fright\"]");
Elements ele_etfOneMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(1) > td:nth-child(3) ");
Elements ele_etfThreeMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(2) > td:nth-child(3) ");
Elements ele_etfSixMonth = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(3) > td:nth-child(3) ");
Elements ele_etfYtd = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(4) > td:nth-child(3) ");
Elements ele_etfOneYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(5) > td:nth-child(3) ");
Elements ele_etfThreeYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(6) > td:nth-child(3) ");
Elements ele_etfFiveYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(7) > td:nth-child(3) ");
Elements ele_etfTenYear = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(8) > td:nth-child(3) ");
Elements ele_etfInception = doc.body().select("div[id=\"module-trailingTotalReturns\"] >table[id=\"table-trailingTotalReturnsTable\"] > tbody > tr:nth-child(9) > td:nth-child(3) ");
outData.setStr_etfName(ele_etfName.text().trim());
outData.setStr_etfPrice(ele_etfPrice.text().trim());
outData.setStr_etfExp(ele_etfExp.text().trim());
outData.setStr_etfYield(ele_etfYield.text().trim());
outData.setStr_etfOneMonth(ele_etfOneMonth.text().trim());
outData.setStr_etfThreeMonth(ele_etfThreeMonth.text().trim());
outData.setStr_etfSixMonth(ele_etfSixMonth.text().trim());
outData.setStr_etfYtd(ele_etfYtd.text().trim());
outData.setStr_etfOneYear(ele_etfOneYear.text().trim());
outData.setStr_etfThreeYear(ele_etfThreeYear.text().trim());
outData.setStr_etfFiveYear(ele_etfFiveYear.text().trim());
outData.setStr_etfTenYear(ele_etfTenYear.text().trim());
outData.setStr_etfInception(ele_etfInception.text().trim());
}catch(Exception e) {
}
return outData;
}
}
| 6,922
| 0.683906
| 0.679428
| 157
| 42.10191
| 45.160744
| 185
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.178344
| false
| false
|
13
|
f50cc0ef170dcff005e95dd5ccda152369864b8c
| 33,913,061,809,985
|
8adc1fde3be8bf9201e41a1b63f826ed5f386650
|
/src/main/java/br/com/app/entity/Endereco.java
|
57c8e82b22af4e69271d0228e0872cd64f2845d5
|
[] |
no_license
|
wandersonSantiago/gestaoConstrucaoCivil
|
https://github.com/wandersonSantiago/gestaoConstrucaoCivil
|
b06f158c06da1db5bbfea112363997ee070e58ab
|
cb6988f99910cf546df697e8dfa6e715bde5d2d0
|
refs/heads/master
| 2022-11-17T15:38:19.046000
| 2019-07-06T21:54:47
| 2019-07-06T21:54:47
| 61,765,808
| 6
| 9
| null | false
| 2019-07-06T21:55:57
| 2016-06-23T02:13:29
| 2019-07-06T21:54:51
| 2019-07-06T21:55:32
| 19,915
| 2
| 2
| 17
|
HTML
| false
| false
|
package br.com.app.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import lombok.Data;
@Data
@Entity
@SequenceGenerator(name = "endereco_id_seq", sequenceName = "endereco_id_seq",allocationSize = 1,schema="communs")
@Table(name = "endereco" , schema = "communs")
public class Endereco implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "endereco_id_seq")
private Long id;
@Column(nullable = false,length = 50)
private String logradouro;
@Column(nullable = false,length = 50)
private String bairro;
@Column(nullable = false,length = 50)
private String localidade;
@Column(nullable = false)
private Integer numero;
@Column(nullable = false)
private String uf;
@Column(nullable = false,length = 9)
private String cep;
@Column(nullable = true,length = 50)
private String complemento;
}
|
UTF-8
|
Java
| 1,146
|
java
|
Endereco.java
|
Java
|
[] | null |
[] |
package br.com.app.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import lombok.Data;
@Data
@Entity
@SequenceGenerator(name = "endereco_id_seq", sequenceName = "endereco_id_seq",allocationSize = 1,schema="communs")
@Table(name = "endereco" , schema = "communs")
public class Endereco implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "endereco_id_seq")
private Long id;
@Column(nullable = false,length = 50)
private String logradouro;
@Column(nullable = false,length = 50)
private String bairro;
@Column(nullable = false,length = 50)
private String localidade;
@Column(nullable = false)
private Integer numero;
@Column(nullable = false)
private String uf;
@Column(nullable = false,length = 9)
private String cep;
@Column(nullable = true,length = 50)
private String complemento;
}
| 1,146
| 0.767016
| 0.757417
| 42
| 26.285715
| 22.500038
| 114
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.190476
| false
| false
|
13
|
fb6193dc6eaf4491cd837d8898e90138f123a4f7
| 37,254,546,342,642
|
ada6e640ea4477f6d287aaab7fff07f3e4b983ba
|
/SemantikosKernelEJB/src/cl/minsal/semantikos/model/Description.java
|
d4711aa9ea44f1c708f2e08e746d33d6af0ca736
|
[] |
no_license
|
MedicalTrends/semantikos
|
https://github.com/MedicalTrends/semantikos
|
5ac3e309c74973d7b791cb2c4a73fcf059851ffe
|
1200f1dfc061586204f43d93f32ad7930f2a5d90
|
refs/heads/master
| 2020-04-04T07:14:02.676000
| 2016-11-07T17:26:42
| 2016-11-07T17:26:42
| 63,108,520
| 0
| 1
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package cl.minsal.semantikos.model;
import cl.minsal.semantikos.kernel.daos.DAO;
import cl.minsal.semantikos.model.audit.AuditableEntity;
import java.sql.Timestamp;
import static java.lang.System.currentTimeMillis;
/**
* @author Andrés Farías on 08-07-16.
*/
public class Description extends PersistentEntity implements AuditableEntity {
/** El término que representa esta descripción */
private String term;
/** El DESCRIPTION_ID (valor de negocio) de la descripción */
private String descriptionID;
private boolean isCaseSensitive;
private boolean autogeneratedName;
private boolean isPublished;
/** El tipo de descriptor */
private DescriptionType descriptionType;
/** El estado del descriptor */
private boolean modeled;
/** La descripción es Vigente (válida) hasta la fecha... */
private Timestamp validityUntil;
/** La fecha de creación */
private Timestamp creationDate;
/** Usuario que creo la descripción */
private User creatorUser;
/** Cantidad de usos de la descripción */
private long uses;
/** El concepto al cuál está asociada la descripción */
private ConceptSMTK conceptSMTK;
/**
* @param id Identificador único de la base de datos.
* @param descriptionID El valor del DESCRIPTION_ID.
* @param descriptionType El tipo de la descripción.
* @param term El término de la descripción.
* @param isCaseSensitive Si es sensible a caracteres.
* @param isAutoGenerated Si es auto-generado.
* @param isPublished Si está publicado.
* @param validityUntil Fecha tope de vigencia.
*/
public Description(long id, ConceptSMTK conceptSMTK, String descriptionID, DescriptionType descriptionType, String term, boolean isCaseSensitive, boolean isAutoGenerated, boolean isPublished, Timestamp validityUntil, Timestamp creationDate, User creatorUser, boolean isModeled) {
super(id);
this.conceptSMTK = conceptSMTK;
this.descriptionID = descriptionID;
this.term = term;
this.descriptionType = descriptionType;
this.isCaseSensitive = isCaseSensitive;
this.autogeneratedName = isAutoGenerated;
this.isPublished = isPublished;
this.validityUntil = validityUntil;
this.creationDate = creationDate;
this.creatorUser = creatorUser;
this.modeled= isModeled;
}
/**
* Este es el constructor para crear no Descripciones no persistentes.
*
* @param conceptSMTK El concepto al cual está asociada la descripción.
* @param descriptionID El valor del DESCRIPTION_ID.
* @param descriptionType El tipo de la descripción.
* @param term El término de la descripción.
* @param isCaseSensitive Si es sensible a caracteres.
* @param isAutoGenerated Si es auto-generado.
* @param isPublished Si está publicado.
* @param validityUntil Fecha tope de vigencia.
*/
public Description(ConceptSMTK conceptSMTK, String descriptionID, DescriptionType descriptionType, String term, boolean isCaseSensitive, boolean isAutoGenerated, boolean isPublished, Timestamp validityUntil, Timestamp creationDate, User creatorUser, boolean isModeled) {
this(DAO.NON_PERSISTED_ID, conceptSMTK, descriptionID, descriptionType, term, isCaseSensitive, isAutoGenerated, isPublished, validityUntil, creationDate, creatorUser,isModeled);
}
/**
* Un constructor minimalista para la Descripción.
*
* @param term El término de la descripción.
* @param descriptionType El tipo de la descripción.
*/
public Description(ConceptSMTK conceptSMTK, String term, DescriptionType descriptionType) {
this(-1, conceptSMTK, "NULL", descriptionType, term, false, false, false, null, new Timestamp(currentTimeMillis()), User.getDummyUser(), false);
}
public String getDescriptionId() {
return descriptionID;
}
public void setDescriptionId(String idDescription) {
this.descriptionID = idDescription;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term;
if (this.getDescriptionType().equals(DescriptionType.FSN)) {
this.term = this.term + (conceptSMTK == null ? "" : " (" + conceptSMTK.getTagSMTK() + ")");
}
}
public boolean isCaseSensitive() {
return isCaseSensitive;
}
public void setCaseSensitive(boolean caseSensitive) {
this.isCaseSensitive = caseSensitive;
}
public boolean isAutogeneratedName() {
return autogeneratedName;
}
public void setAutogeneratedName(boolean autogeneratedName) {
this.autogeneratedName = autogeneratedName;
}
public boolean isPublished() {
return isPublished;
}
public void setPublished(boolean published) {
isPublished = published;
}
public DescriptionType getDescriptionType() {
return descriptionType;
}
public void setDescriptionType(DescriptionType descriptionType) {
this.descriptionType = descriptionType;
}
public Timestamp getValidityUntil() {
return validityUntil;
}
public void setValidityUntil(Timestamp validityUntil) {
this.validityUntil = validityUntil;
}
public long getUses() {
return uses;
}
public void setUses(long uses) {
this.uses = uses;
}
public boolean isModeled() {
return modeled;
}
public void setModeled(boolean modeled) {
this.modeled = modeled;
}
/**
* Este método es responsable de determinar si esta descripción es válida
*
* @return <code>true</code> si es válida y <code>false</code> si no lo es.
*/
public boolean isValid() {
return (getValidityUntil() == null || getValidityUntil().after(new Timestamp(currentTimeMillis())));
}
public ConceptSMTK getConceptSMTK() {
return conceptSMTK;
}
public void setConceptSMTK(ConceptSMTK conceptSMTK) {
this.conceptSMTK = conceptSMTK;
}
public Timestamp getCreationDate() {
return creationDate;
}
public void setCreationDate(Timestamp creationDate) {
this.creationDate = creationDate;
}
public User getCreatorUser() {
return creatorUser;
}
public void setCreatorUser(User creatorUser) {
this.creatorUser = creatorUser;
}
/**
* Este método es responsable de dar la representación de la descripción.
* En particular, hay una BR que indica que para las descripciones FSN siempre se debe mostrar concatenado con el
* Tag Semántikos.
*
* @return La representación literal de la descripción.
*/
@Override
public String toString() {
if (this.getDescriptionType().equals(DescriptionType.FSN)) {
String tagSMTKParenthesis = "(" + conceptSMTK.getTagSMTK().getName().toLowerCase() + ")";
String descTerm = term.toLowerCase();
if (!descTerm.endsWith(tagSMTKParenthesis)) {
return this.term + (conceptSMTK == null ? "" : " (" + conceptSMTK.getTagSMTK() + ")");
}
}
return this.term;
}
}
|
UTF-8
|
Java
| 7,349
|
java
|
Description.java
|
Java
|
[
{
"context": "ava.lang.System.currentTimeMillis;\n\n/**\n * @author Andrés Farías on 08-07-16.\n */\npublic class Description extends",
"end": 247,
"score": 0.9998628497123718,
"start": 234,
"tag": "NAME",
"value": "Andrés Farías"
}
] | null |
[] |
package cl.minsal.semantikos.model;
import cl.minsal.semantikos.kernel.daos.DAO;
import cl.minsal.semantikos.model.audit.AuditableEntity;
import java.sql.Timestamp;
import static java.lang.System.currentTimeMillis;
/**
* @author <NAME> on 08-07-16.
*/
public class Description extends PersistentEntity implements AuditableEntity {
/** El término que representa esta descripción */
private String term;
/** El DESCRIPTION_ID (valor de negocio) de la descripción */
private String descriptionID;
private boolean isCaseSensitive;
private boolean autogeneratedName;
private boolean isPublished;
/** El tipo de descriptor */
private DescriptionType descriptionType;
/** El estado del descriptor */
private boolean modeled;
/** La descripción es Vigente (válida) hasta la fecha... */
private Timestamp validityUntil;
/** La fecha de creación */
private Timestamp creationDate;
/** Usuario que creo la descripción */
private User creatorUser;
/** Cantidad de usos de la descripción */
private long uses;
/** El concepto al cuál está asociada la descripción */
private ConceptSMTK conceptSMTK;
/**
* @param id Identificador único de la base de datos.
* @param descriptionID El valor del DESCRIPTION_ID.
* @param descriptionType El tipo de la descripción.
* @param term El término de la descripción.
* @param isCaseSensitive Si es sensible a caracteres.
* @param isAutoGenerated Si es auto-generado.
* @param isPublished Si está publicado.
* @param validityUntil Fecha tope de vigencia.
*/
public Description(long id, ConceptSMTK conceptSMTK, String descriptionID, DescriptionType descriptionType, String term, boolean isCaseSensitive, boolean isAutoGenerated, boolean isPublished, Timestamp validityUntil, Timestamp creationDate, User creatorUser, boolean isModeled) {
super(id);
this.conceptSMTK = conceptSMTK;
this.descriptionID = descriptionID;
this.term = term;
this.descriptionType = descriptionType;
this.isCaseSensitive = isCaseSensitive;
this.autogeneratedName = isAutoGenerated;
this.isPublished = isPublished;
this.validityUntil = validityUntil;
this.creationDate = creationDate;
this.creatorUser = creatorUser;
this.modeled= isModeled;
}
/**
* Este es el constructor para crear no Descripciones no persistentes.
*
* @param conceptSMTK El concepto al cual está asociada la descripción.
* @param descriptionID El valor del DESCRIPTION_ID.
* @param descriptionType El tipo de la descripción.
* @param term El término de la descripción.
* @param isCaseSensitive Si es sensible a caracteres.
* @param isAutoGenerated Si es auto-generado.
* @param isPublished Si está publicado.
* @param validityUntil Fecha tope de vigencia.
*/
public Description(ConceptSMTK conceptSMTK, String descriptionID, DescriptionType descriptionType, String term, boolean isCaseSensitive, boolean isAutoGenerated, boolean isPublished, Timestamp validityUntil, Timestamp creationDate, User creatorUser, boolean isModeled) {
this(DAO.NON_PERSISTED_ID, conceptSMTK, descriptionID, descriptionType, term, isCaseSensitive, isAutoGenerated, isPublished, validityUntil, creationDate, creatorUser,isModeled);
}
/**
* Un constructor minimalista para la Descripción.
*
* @param term El término de la descripción.
* @param descriptionType El tipo de la descripción.
*/
public Description(ConceptSMTK conceptSMTK, String term, DescriptionType descriptionType) {
this(-1, conceptSMTK, "NULL", descriptionType, term, false, false, false, null, new Timestamp(currentTimeMillis()), User.getDummyUser(), false);
}
public String getDescriptionId() {
return descriptionID;
}
public void setDescriptionId(String idDescription) {
this.descriptionID = idDescription;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term;
if (this.getDescriptionType().equals(DescriptionType.FSN)) {
this.term = this.term + (conceptSMTK == null ? "" : " (" + conceptSMTK.getTagSMTK() + ")");
}
}
public boolean isCaseSensitive() {
return isCaseSensitive;
}
public void setCaseSensitive(boolean caseSensitive) {
this.isCaseSensitive = caseSensitive;
}
public boolean isAutogeneratedName() {
return autogeneratedName;
}
public void setAutogeneratedName(boolean autogeneratedName) {
this.autogeneratedName = autogeneratedName;
}
public boolean isPublished() {
return isPublished;
}
public void setPublished(boolean published) {
isPublished = published;
}
public DescriptionType getDescriptionType() {
return descriptionType;
}
public void setDescriptionType(DescriptionType descriptionType) {
this.descriptionType = descriptionType;
}
public Timestamp getValidityUntil() {
return validityUntil;
}
public void setValidityUntil(Timestamp validityUntil) {
this.validityUntil = validityUntil;
}
public long getUses() {
return uses;
}
public void setUses(long uses) {
this.uses = uses;
}
public boolean isModeled() {
return modeled;
}
public void setModeled(boolean modeled) {
this.modeled = modeled;
}
/**
* Este método es responsable de determinar si esta descripción es válida
*
* @return <code>true</code> si es válida y <code>false</code> si no lo es.
*/
public boolean isValid() {
return (getValidityUntil() == null || getValidityUntil().after(new Timestamp(currentTimeMillis())));
}
public ConceptSMTK getConceptSMTK() {
return conceptSMTK;
}
public void setConceptSMTK(ConceptSMTK conceptSMTK) {
this.conceptSMTK = conceptSMTK;
}
public Timestamp getCreationDate() {
return creationDate;
}
public void setCreationDate(Timestamp creationDate) {
this.creationDate = creationDate;
}
public User getCreatorUser() {
return creatorUser;
}
public void setCreatorUser(User creatorUser) {
this.creatorUser = creatorUser;
}
/**
* Este método es responsable de dar la representación de la descripción.
* En particular, hay una BR que indica que para las descripciones FSN siempre se debe mostrar concatenado con el
* Tag Semántikos.
*
* @return La representación literal de la descripción.
*/
@Override
public String toString() {
if (this.getDescriptionType().equals(DescriptionType.FSN)) {
String tagSMTKParenthesis = "(" + conceptSMTK.getTagSMTK().getName().toLowerCase() + ")";
String descTerm = term.toLowerCase();
if (!descTerm.endsWith(tagSMTKParenthesis)) {
return this.term + (conceptSMTK == null ? "" : " (" + conceptSMTK.getTagSMTK() + ")");
}
}
return this.term;
}
}
| 7,340
| 0.669676
| 0.668718
| 230
| 30.786957
| 37.25182
| 283
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.473913
| false
| false
|
13
|
58860e90ecbdbffde822f80957d091d15d468058
| 33,251,636,868,045
|
335660ec0c30612906dca6935088b3d958f8a50c
|
/src/addressBook/SortByName.java
|
952764b58707ceeed15c42f1f7ab84db18413272
|
[] |
no_license
|
kalyangoud145/AddressBook
|
https://github.com/kalyangoud145/AddressBook
|
736fa5a4ba5d6253a24e915bf0f5438c13d01e2e
|
6696aacbd02ae4f28a4c11151b1cac1e38c0de9f
|
refs/heads/master
| 2022-12-05T11:43:29.772000
| 2020-08-25T06:53:08
| 2020-08-25T06:53:08
| 289,625,220
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package addressBook;
import java.util.Comparator;
/*Sorting of data by using Firstname in address book*/
public class SortByName implements Comparator<Person>{
/*
* Compares the data and returns 0 if the data is same
* and 1 if first data is greater
* and -1 if second data is greater
*/
public int compare(Person personOne, Person personTwo) {
if(personOne.getFirstName().equals(personTwo.getFirstName()))
return 0;
else {
if(personOne.getFirstName().compareTo(personTwo.getFirstName())>0) {
return 1;
}else {
return -1;
}
}
}
}
|
UTF-8
|
Java
| 572
|
java
|
SortByName.java
|
Java
|
[] | null |
[] |
package addressBook;
import java.util.Comparator;
/*Sorting of data by using Firstname in address book*/
public class SortByName implements Comparator<Person>{
/*
* Compares the data and returns 0 if the data is same
* and 1 if first data is greater
* and -1 if second data is greater
*/
public int compare(Person personOne, Person personTwo) {
if(personOne.getFirstName().equals(personTwo.getFirstName()))
return 0;
else {
if(personOne.getFirstName().compareTo(personTwo.getFirstName())>0) {
return 1;
}else {
return -1;
}
}
}
}
| 572
| 0.699301
| 0.687063
| 22
| 25
| 23.422987
| 71
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.772727
| false
| false
|
13
|
36814cca45501d0071ea2e2e3cf0faa77c70f7b0
| 29,076,928,631,806
|
15da3f5ad3100944fdd452c9131bc02b78d17774
|
/src/exe10/Principal.java
|
4732b2140d38d5e69c93dbcba53db327a3136677
|
[] |
no_license
|
DanielaKlitzke/Eclipse
|
https://github.com/DanielaKlitzke/Eclipse
|
e98fb063447fd8b5592bc26dfaef29d00f1d3e2c
|
60c7d5312580fbc29b49e86c86e64b99fc9f3cd2
|
refs/heads/master
| 2020-03-17T19:07:30.228000
| 2018-05-18T20:23:56
| 2018-05-18T20:23:56
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package exe10;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Principal {
public static void main(String[] args) {
JFrame cofre = new JFrame("Cofre");
cofre.setSize(500, 400);
cofre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cofre.setLocationRelativeTo(null);
cofre.setLayout(null);
JLabel um = new JLabel("00,01");
um.setBounds(10, 10, 50, 20);
JLabel cinco = new JLabel("00,05");
cinco.setBounds(10, 30, 50, 20);
JLabel dez = new JLabel("00,10");
dez.setBounds(10, 50, 50, 20);
JLabel vinteCinco = new JLabel("00,25");
vinteCinco.setBounds(10, 70, 50, 20);
JLabel cinquenta = new JLabel("00,50");
cinquenta.setBounds(10, 90, 50, 20);
JLabel umReal = new JLabel("01,00");
umReal.setBounds(10, 110, 50, 20);
JTextField campo1 = new JTextField();
campo1.setBounds(80, 10, 50, 20);
JTextField campo5 = new JTextField();
campo5.setBounds(80, 30, 50, 20);
JTextField campo10 = new JTextField();
campo10.setBounds(80, 50, 50, 20);
JTextField campo25= new JTextField();
campo25.setBounds(80, 70, 50, 20);
JTextField campo50 = new JTextField();
campo50.setBounds(80, 90, 50, 20);
JTextField campo1R = new JTextField();
campo1R.setBounds(80, 110, 50, 20);
JButton botao = new JButton("Clique Aqui para somar!");
botao.setBounds(100, 200, 200, 20);
botao.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
double m1 = Double.parseDouble(campo1.getText());
double m5 = Double.parseDouble(campo5.getText());
double m10 = Double.parseDouble(campo10.getText());
double m25 = Double.parseDouble(campo25.getText());
double m50 = Double.parseDouble(campo50.getText());
double m1R = Double.parseDouble(campo1R.getText());
double um, cinco, dez;
JOptionPane.showMessageDialog(null, "00,01 X "+m1+" = "+String.format("%.2f", m1*0.01)
+"\n00,05 X "+m5+" = "+String.format("%.2f", m5*0.05)
+"\n00,10 X "+m10+" = "+String.format("%.2f", m10*0.10)
+"\n00,25 X "+m25+" = "+String.format("%.2f", m25*0.25)
+"\n00,50 X "+m50+" = "+String.format("%.2f", m50*0.50)
+"\n01,00 X "+m1R+" = "+String.format("%.2f", m1R*1.0)+"\nO total é ");
campo1.setText("");
campo5.setText("");
campo10.setText("");
campo25.setText("");
campo50.setText("");
campo1R.setText("");
campo1.requestFocus();
}
});
cofre.add(um);
cofre.add(cinco);
cofre.add(dez);
cofre.add(vinteCinco);
cofre.add(cinquenta);
cofre.add(umReal);
cofre.add(campo1);
cofre.add(campo5);
cofre.add(campo10);
cofre.add(campo25);
cofre.add(campo50);
cofre.add(campo1R);
cofre.add(botao);
cofre.repaint();
cofre.setVisible(true);
}
}
|
WINDOWS-1252
|
Java
| 3,119
|
java
|
Principal.java
|
Java
|
[] | null |
[] |
package exe10;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Principal {
public static void main(String[] args) {
JFrame cofre = new JFrame("Cofre");
cofre.setSize(500, 400);
cofre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cofre.setLocationRelativeTo(null);
cofre.setLayout(null);
JLabel um = new JLabel("00,01");
um.setBounds(10, 10, 50, 20);
JLabel cinco = new JLabel("00,05");
cinco.setBounds(10, 30, 50, 20);
JLabel dez = new JLabel("00,10");
dez.setBounds(10, 50, 50, 20);
JLabel vinteCinco = new JLabel("00,25");
vinteCinco.setBounds(10, 70, 50, 20);
JLabel cinquenta = new JLabel("00,50");
cinquenta.setBounds(10, 90, 50, 20);
JLabel umReal = new JLabel("01,00");
umReal.setBounds(10, 110, 50, 20);
JTextField campo1 = new JTextField();
campo1.setBounds(80, 10, 50, 20);
JTextField campo5 = new JTextField();
campo5.setBounds(80, 30, 50, 20);
JTextField campo10 = new JTextField();
campo10.setBounds(80, 50, 50, 20);
JTextField campo25= new JTextField();
campo25.setBounds(80, 70, 50, 20);
JTextField campo50 = new JTextField();
campo50.setBounds(80, 90, 50, 20);
JTextField campo1R = new JTextField();
campo1R.setBounds(80, 110, 50, 20);
JButton botao = new JButton("Clique Aqui para somar!");
botao.setBounds(100, 200, 200, 20);
botao.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
double m1 = Double.parseDouble(campo1.getText());
double m5 = Double.parseDouble(campo5.getText());
double m10 = Double.parseDouble(campo10.getText());
double m25 = Double.parseDouble(campo25.getText());
double m50 = Double.parseDouble(campo50.getText());
double m1R = Double.parseDouble(campo1R.getText());
double um, cinco, dez;
JOptionPane.showMessageDialog(null, "00,01 X "+m1+" = "+String.format("%.2f", m1*0.01)
+"\n00,05 X "+m5+" = "+String.format("%.2f", m5*0.05)
+"\n00,10 X "+m10+" = "+String.format("%.2f", m10*0.10)
+"\n00,25 X "+m25+" = "+String.format("%.2f", m25*0.25)
+"\n00,50 X "+m50+" = "+String.format("%.2f", m50*0.50)
+"\n01,00 X "+m1R+" = "+String.format("%.2f", m1R*1.0)+"\nO total é ");
campo1.setText("");
campo5.setText("");
campo10.setText("");
campo25.setText("");
campo50.setText("");
campo1R.setText("");
campo1.requestFocus();
}
});
cofre.add(um);
cofre.add(cinco);
cofre.add(dez);
cofre.add(vinteCinco);
cofre.add(cinquenta);
cofre.add(umReal);
cofre.add(campo1);
cofre.add(campo5);
cofre.add(campo10);
cofre.add(campo25);
cofre.add(campo50);
cofre.add(campo1R);
cofre.add(botao);
cofre.repaint();
cofre.setVisible(true);
}
}
| 3,119
| 0.613534
| 0.529827
| 119
| 24.201681
| 19.703934
| 90
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 3.403361
| false
| false
|
13
|
70353ada739d08d720189e14c40bc64952f047e3
| 19,086,834,718,249
|
371aa41d066156b697b32e06195ba18223641304
|
/rbpserver/src/main/java/ru/bitec/remotebloop/rbpserver/RbpHtmlServerHtml.java
|
44682599b4be3ec8faace094207413d5d5885f64
|
[
"Apache-2.0"
] |
permissive
|
global-system/remotebloop
|
https://github.com/global-system/remotebloop
|
806616ce5012f3b22b042d3fd511e5486c12b934
|
836074cfbc6b4c706bd82cfc6702ee38b1c9dc77
|
refs/heads/master
| 2021-02-18T06:49:27.291000
| 2020-07-31T23:06:17
| 2020-07-31T23:06:17
| 245,172,397
| 0
| 0
| null | false
| 2020-03-20T12:47:53
| 2020-03-05T13:37:14
| 2020-03-20T12:45:42
| 2020-03-20T12:47:52
| 57
| 0
| 0
| 0
|
Scala
| false
| false
|
package ru.bitec.remotebloop.rbpserver;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.InputStream;
@Path("html/{path:.+}")
public class RbpHtmlServerHtml {
@GET
@Produces({MediaType.TEXT_HTML})
public InputStream getPrinter(@PathParam("path") String path) {
String rootPath = "ru/bitec/remotebloop/rbpserver/"+path;
InputStream is = getClass().getClassLoader().getResourceAsStream(rootPath);
return is;
}
}
|
UTF-8
|
Java
| 580
|
java
|
RbpHtmlServerHtml.java
|
Java
|
[] | null |
[] |
package ru.bitec.remotebloop.rbpserver;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.InputStream;
@Path("html/{path:.+}")
public class RbpHtmlServerHtml {
@GET
@Produces({MediaType.TEXT_HTML})
public InputStream getPrinter(@PathParam("path") String path) {
String rootPath = "ru/bitec/remotebloop/rbpserver/"+path;
InputStream is = getClass().getClassLoader().getResourceAsStream(rootPath);
return is;
}
}
| 580
| 0.693103
| 0.693103
| 19
| 28.526316
| 22.408571
| 83
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.526316
| false
| false
|
13
|
09905720eb5fc8e6b4a75c91db969ad030492e17
| 6,382,321,444,245
|
762fb2c2431671cb47acaa8d8851ee99982be69e
|
/app/src/main/java/com/keithmackay/games/androidgames/_2048/SixteenBlockGrid.java
|
73d7f19d91def1ae2056492ae208d4aba9383d9b
|
[] |
no_license
|
kamackay/AndroidGames
|
https://github.com/kamackay/AndroidGames
|
5e1fee53fb653372db9917ec1efb62a8b449fa01
|
3f4bacf823a39ef98b786752f521e65a9601a447
|
refs/heads/master
| 2021-01-20T15:33:45.341000
| 2018-01-24T15:54:59
| 2018-01-24T15:54:59
| 65,042,859
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.keithmackay.games.androidgames._2048;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
import com.keithmackay.games.androidgames.R;
import com.keithmackay.games.androidgames.common.ScoreChangeHandler;
import java.util.ArrayList;
/**
* Sixteen Block Grid
*/
public class SixteenBlockGrid extends View {
Runnable onGameOver;
ScoreChangeHandler scoreChangeHandler;
/**
* Use to print things in white
*/
private Paint white;
private Paint p;
private Tile[] tiles;
private SwipeHandler swipeHandler;
public SixteenBlockGrid(Context context) {
super(context);
init(context);
}
public SixteenBlockGrid(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SixteenBlockGrid(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
public static int getContrastColor(int color) {
double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000;
return y >= 128 ? Color.BLACK : Color.WHITE;
}
public void init(final Context c) {
SwipeListener swipeListener = new SwipeListener() {
@Override
public void onSwipe(Details details) {
switch (details.getDirection()) {
case Left:
if (canSwipeLeft()) {
swipeLeft();
generateTile();
if (swipeHandler != null) swipeHandler.onLeftSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Right:
if (canSwipeRight()) {
swipeRight();
generateTile();
if (swipeHandler != null) swipeHandler.onRightSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Up:
if (canSwipeUp()) {
swipeUp();
generateTile();
if (swipeHandler != null) swipeHandler.onUpSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Down:
if (canSwipeDown()) {
swipeDown();
generateTile();
if (swipeHandler != null) swipeHandler.onDownSwipe();
//if (onGameOver != null) onGameOver.run();
} else checkForGameOver();
postInvalidate();
}
}
};
swipeListener.setSwipeLength(PreferenceManager.getDefaultSharedPreferences(c)
.getInt(c.getString(R.string.settings_swipeLen), 3));
this.setOnTouchListener(swipeListener);
white = new Paint();
white.setColor(Color.WHITE);
white.setTextSize(150);
white.setTextAlign(Paint.Align.CENTER);
p = new Paint();
p.setTextSize(150);
p.setTextAlign(Paint.Align.CENTER);
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "calibri.ttf");
if (tf != null) {
p.setTypeface(tf);
white.setTypeface(tf);
}
tiles = new Tile[16];
for (int i = 0; i < 16; i++) tiles[i] = new Tile();
}
private void swipeUp() {
for (int i = 0; i < 4; i++) {
for (int j = i; j < 16; j += 4) {
if (!tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeDown() {
for (int i = 0; i < 4; i++) {
for (int j = i + 12; j > 0; j -= 4) {
if (!tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeLeft() {
for (int i = 0; i < 16; i += 4) {
for (int j = i; j < i + 4; j++) {
if (!tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeRight() {
for (int i = 3; i < 16; i += 4) {
for (int j = i; j > i - 4; j--) {
if (!tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
public void checkForGameOver() {
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (getValueAt(i, j) == -10) return;
if (!canSwipeDown() && !canSwipeLeft() && !canSwipeRight() && !canSwipeUp())
onGameOver.run();
}
public void generateTile() {
final ArrayList<Integer> emptyTiles = new ArrayList<>();
for (int i = 0; i < 16; i++)
if (!tiles[i].hasValue())
emptyTiles.add(i);
int newValue = 2;
if (Math.random() >= 0.9) newValue = 4;
int idx = (int) (Math.random() * (emptyTiles.size() - 1));
final int idx2 = emptyTiles.get(idx);
final int finalNewValue = newValue;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
tiles[idx2].setValue(finalNewValue);
postInvalidate();//== 1 &&
checkForGameOver();
} catch (Exception e) {
//I don't know how to manage this
}
}
}).start();
}
private boolean canSwipeUp() {
for (int i = 0; i < 4; i++) {
for (int j = i; j < 16; j += 4) {
if (!tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
return true;
}
break;
}
}
}
}
}
return false;
}
private boolean canSwipeDown() {
for (int i = 0; i < 4; i++) {
for (int j = i + 12; j > 0; j -= 4) {
if (!tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
private boolean canSwipeLeft() {
for (int i = 0; i < 16; i += 4) {
for (int j = i; j < i + 4; j++) {
if (!tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
private boolean canSwipeRight() {
for (int i = 3; i < 16; i += 4) {
for (int j = i; j > i - 4; j--) {
if (!tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--)
if (tiles[k].hasValue()) return true;
} else {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
@Override
protected void onDraw(Canvas c) {
super.onDraw(c);
int width = getMeasuredWidth(), height = getMeasuredHeight();
float i = (float) (((width > height) ? height : width) * .24);
float top = (height / 2) - (i * 2), left = (width / 2) - (i * 2),
right = (width / 2) + (i * 2), bottom = (height / 2) + (i * 2);
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
int n = x * 4 + y;
int a = (int) (left + i * y), b = (int) (top + x * i);
tiles[n].setBounds(a, b, (int) (a + i), (int) (b + i));
Tile t = tiles[n];
if (t.hasValue()) {
int color = t.getBackColor();
p.setColor(color);
c.drawRect(t.getBounds(), p);
p.setColor(getContrastColor(color));
String s = String.valueOf(t.getValue());
if (s.length() > 5) p.setTextSize(50);
else if (s.length() == 5) p.setTextSize(60);
else if (s.length() == 4) p.setTextSize(75);
else if (s.length() == 3) p.setTextSize(100);
else p.setTextSize(150);
c.drawText(s, t.getLeft() + i / 2,
t.getBottom() - i / 2 + (p.getTextSize() / 3), p);
}
}
}
c.drawRect(left, top, right, top + 4, white);
c.drawRect(left, bottom - 4, right, bottom, white);
c.drawRect(left, top, left + 4, bottom, white);
c.drawRect(right - 4, top, right, bottom, white);
c.drawRect(left + i - 2, top, left + i + 2, bottom, white);
c.drawRect(right - i - 2, top, right - i + 2, bottom, white);
c.drawRect(left + i * 2 - 2, top, left + i * 2 + 2, bottom, white);
c.drawRect(left, top + i - 2, right, top + i + 2, white);
c.drawRect(left, top + i * 2 - 2, right, top + i * 2 + 2, white);
c.drawRect(left, bottom - i - 2, right, bottom - i + 2, white);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
this.setMeasuredDimension(parentWidth, parentHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void setGridTileValue(int x, int y, int value) {
if (tiles[y * 4 + x] != null) tiles[y * 4 + x].setValue(value);
this.invalidate();
}
public void setOnSwipeHandler(SwipeHandler swipeHandler) {
this.swipeHandler = swipeHandler;
}
public int getValueAt(int x, int y) {
return tiles[y * 4 + x].getValue();
}
public void setOnGameOver(Runnable onGameOver) {
this.onGameOver = onGameOver;
}
public Tile at(int i) {
return tiles[i];
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (i != 0 && j != 0) sb.append(", ");
sb.append(String.valueOf(getValueAt(i, j)));
}
}
return sb.toString();
}
public void setOnScoreChangeHandler(ScoreChangeHandler handler) {
scoreChangeHandler = handler;
}
}
|
UTF-8
|
Java
| 16,154
|
java
|
SixteenBlockGrid.java
|
Java
|
[] | null |
[] |
package com.keithmackay.games.androidgames._2048;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
import com.keithmackay.games.androidgames.R;
import com.keithmackay.games.androidgames.common.ScoreChangeHandler;
import java.util.ArrayList;
/**
* Sixteen Block Grid
*/
public class SixteenBlockGrid extends View {
Runnable onGameOver;
ScoreChangeHandler scoreChangeHandler;
/**
* Use to print things in white
*/
private Paint white;
private Paint p;
private Tile[] tiles;
private SwipeHandler swipeHandler;
public SixteenBlockGrid(Context context) {
super(context);
init(context);
}
public SixteenBlockGrid(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SixteenBlockGrid(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
public static int getContrastColor(int color) {
double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000;
return y >= 128 ? Color.BLACK : Color.WHITE;
}
public void init(final Context c) {
SwipeListener swipeListener = new SwipeListener() {
@Override
public void onSwipe(Details details) {
switch (details.getDirection()) {
case Left:
if (canSwipeLeft()) {
swipeLeft();
generateTile();
if (swipeHandler != null) swipeHandler.onLeftSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Right:
if (canSwipeRight()) {
swipeRight();
generateTile();
if (swipeHandler != null) swipeHandler.onRightSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Up:
if (canSwipeUp()) {
swipeUp();
generateTile();
if (swipeHandler != null) swipeHandler.onUpSwipe();
} else checkForGameOver();
postInvalidate();
break;
case Down:
if (canSwipeDown()) {
swipeDown();
generateTile();
if (swipeHandler != null) swipeHandler.onDownSwipe();
//if (onGameOver != null) onGameOver.run();
} else checkForGameOver();
postInvalidate();
}
}
};
swipeListener.setSwipeLength(PreferenceManager.getDefaultSharedPreferences(c)
.getInt(c.getString(R.string.settings_swipeLen), 3));
this.setOnTouchListener(swipeListener);
white = new Paint();
white.setColor(Color.WHITE);
white.setTextSize(150);
white.setTextAlign(Paint.Align.CENTER);
p = new Paint();
p.setTextSize(150);
p.setTextAlign(Paint.Align.CENTER);
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "calibri.ttf");
if (tf != null) {
p.setTypeface(tf);
white.setTypeface(tf);
}
tiles = new Tile[16];
for (int i = 0; i < 16; i++) tiles[i] = new Tile();
}
private void swipeUp() {
for (int i = 0; i < 4; i++) {
for (int j = i; j < 16; j += 4) {
if (!tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeDown() {
for (int i = 0; i < 4; i++) {
for (int j = i + 12; j > 0; j -= 4) {
if (!tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeLeft() {
for (int i = 0; i < 16; i += 4) {
for (int j = i; j < i + 4; j++) {
if (!tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
private void swipeRight() {
for (int i = 3; i < 16; i += 4) {
for (int j = i; j > i - 4; j--) {
if (!tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
tiles[j].setValue(tiles[k].getValue());
tiles[k].removeValue();
break;
}
}
}
if (tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
tiles[j].doubleValue();
if (scoreChangeHandler != null)
scoreChangeHandler.onScoreChange(tiles[j].getValue());
tiles[k].removeValue();
}
break;
}
}
}
}
}
}
public void checkForGameOver() {
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (getValueAt(i, j) == -10) return;
if (!canSwipeDown() && !canSwipeLeft() && !canSwipeRight() && !canSwipeUp())
onGameOver.run();
}
public void generateTile() {
final ArrayList<Integer> emptyTiles = new ArrayList<>();
for (int i = 0; i < 16; i++)
if (!tiles[i].hasValue())
emptyTiles.add(i);
int newValue = 2;
if (Math.random() >= 0.9) newValue = 4;
int idx = (int) (Math.random() * (emptyTiles.size() - 1));
final int idx2 = emptyTiles.get(idx);
final int finalNewValue = newValue;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(100);
tiles[idx2].setValue(finalNewValue);
postInvalidate();//== 1 &&
checkForGameOver();
} catch (Exception e) {
//I don't know how to manage this
}
}
}).start();
}
private boolean canSwipeUp() {
for (int i = 0; i < 4; i++) {
for (int j = i; j < 16; j += 4) {
if (!tiles[j].hasValue()) {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j + 4; k < 16; k += 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue()) {
return true;
}
break;
}
}
}
}
}
return false;
}
private boolean canSwipeDown() {
for (int i = 0; i < 4; i++) {
for (int j = i + 12; j > 0; j -= 4) {
if (!tiles[j].hasValue()) {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j - 4; k >= 0; k -= 4) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
private boolean canSwipeLeft() {
for (int i = 0; i < 16; i += 4) {
for (int j = i; j < i + 4; j++) {
if (!tiles[j].hasValue()) {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
return true;
}
}
} else {
for (int k = j + 1; k < i + 4; k++) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
private boolean canSwipeRight() {
for (int i = 3; i < 16; i += 4) {
for (int j = i; j > i - 4; j--) {
if (!tiles[j].hasValue()) {
for (int k = j - 1; k > i - 4; k--)
if (tiles[k].hasValue()) return true;
} else {
for (int k = j - 1; k > i - 4; k--) {
if (tiles[k].hasValue()) {
if (tiles[j].getValue() == tiles[k].getValue())
return true;
break;
}
}
}
}
}
return false;
}
@Override
protected void onDraw(Canvas c) {
super.onDraw(c);
int width = getMeasuredWidth(), height = getMeasuredHeight();
float i = (float) (((width > height) ? height : width) * .24);
float top = (height / 2) - (i * 2), left = (width / 2) - (i * 2),
right = (width / 2) + (i * 2), bottom = (height / 2) + (i * 2);
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
int n = x * 4 + y;
int a = (int) (left + i * y), b = (int) (top + x * i);
tiles[n].setBounds(a, b, (int) (a + i), (int) (b + i));
Tile t = tiles[n];
if (t.hasValue()) {
int color = t.getBackColor();
p.setColor(color);
c.drawRect(t.getBounds(), p);
p.setColor(getContrastColor(color));
String s = String.valueOf(t.getValue());
if (s.length() > 5) p.setTextSize(50);
else if (s.length() == 5) p.setTextSize(60);
else if (s.length() == 4) p.setTextSize(75);
else if (s.length() == 3) p.setTextSize(100);
else p.setTextSize(150);
c.drawText(s, t.getLeft() + i / 2,
t.getBottom() - i / 2 + (p.getTextSize() / 3), p);
}
}
}
c.drawRect(left, top, right, top + 4, white);
c.drawRect(left, bottom - 4, right, bottom, white);
c.drawRect(left, top, left + 4, bottom, white);
c.drawRect(right - 4, top, right, bottom, white);
c.drawRect(left + i - 2, top, left + i + 2, bottom, white);
c.drawRect(right - i - 2, top, right - i + 2, bottom, white);
c.drawRect(left + i * 2 - 2, top, left + i * 2 + 2, bottom, white);
c.drawRect(left, top + i - 2, right, top + i + 2, white);
c.drawRect(left, top + i * 2 - 2, right, top + i * 2 + 2, white);
c.drawRect(left, bottom - i - 2, right, bottom - i + 2, white);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
this.setMeasuredDimension(parentWidth, parentHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public void setGridTileValue(int x, int y, int value) {
if (tiles[y * 4 + x] != null) tiles[y * 4 + x].setValue(value);
this.invalidate();
}
public void setOnSwipeHandler(SwipeHandler swipeHandler) {
this.swipeHandler = swipeHandler;
}
public int getValueAt(int x, int y) {
return tiles[y * 4 + x].getValue();
}
public void setOnGameOver(Runnable onGameOver) {
this.onGameOver = onGameOver;
}
public Tile at(int i) {
return tiles[i];
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (i != 0 && j != 0) sb.append(", ");
sb.append(String.valueOf(getValueAt(i, j)));
}
}
return sb.toString();
}
public void setOnScoreChangeHandler(ScoreChangeHandler handler) {
scoreChangeHandler = handler;
}
}
| 16,154
| 0.393896
| 0.381454
| 440
| 35.713634
| 22.312038
| 104
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.718182
| false
| false
|
13
|
6441d5615d7a50b4cc30d327265aaaffd5983045
| 24,421,184,052,918
|
887018e28c3cc0efe441517bc65f0e87b9993744
|
/src/main/java/kr/co/saramin/itsDailyReport/module/RestHttpClient.java
|
b33c6c8ea86e3434c797381f7b9460e263ed5a22
|
[] |
no_license
|
ksh293/itsDailyReport
|
https://github.com/ksh293/itsDailyReport
|
8489a56498ba32173cb87c662e2e0d1eeaab455d
|
feaba9cb13f232081a06462dd43ec48c1ba780e0
|
refs/heads/master
| 2021-01-13T06:14:24.148000
| 2017-06-23T08:12:55
| 2017-06-23T08:12:55
| 95,075,198
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package kr.co.saramin.itsDailyReport.module;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Properties;
import javax.ws.rs.core.MediaType;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.json.JSONConfiguration;
/**
* <pre>
* 파 일 명 : RestHttpClient.java
* 설 명 : Rest API를 호출하기 위한 HttpClient 모듈 (Jersey Client)
* 작 성 자 : 김소현
* 작 성 일 : 2017.06.22
* 버 전 : 1.0
* 수정이력 :
* 기타사항 :
* </pre>
*/
public class RestHttpClient {
private ClientConfig clientConfig;
private Client client;
private WebResource webResource;
private Properties properties;
private final static String CONFIG_FILE = "-rest-client.properties";
/**
* Client 객체 생성 시 호스트 인증 정보 세팅을 위해 파라미터를 넘겨받는다
* apiRequest : jira, confluence
* 인자값에 따라 JIRA / Confluence 설정
* @param apiRequest
* @throws Exception
*/
public RestHttpClient(String apiRequest) throws Exception {
properties = new Properties();
InputStream fis = getClass().getClassLoader().getResourceAsStream(apiRequest+CONFIG_FILE);
properties.load(new BufferedInputStream(fis));
clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.FALSE);
client = Client.create(clientConfig);
client.addFilter(new LoggingFilter());
HTTPBasicAuthFilter auth = new HTTPBasicAuthFilter(properties.getProperty("user.id"), properties.getProperty("user.pwd"));
client.addFilter(auth);
}
/**
* 호출할 URL을 Client에 세팅한다.
* @param resourceName
*/
public void setResourceName(String resourceName) {
webResource = client.resource(properties.getProperty("server.url") + resourceName);
}
/**
* GET 메소드 호출
* Type : application/json
* @return
*/
public ClientResponse get() {
ClientResponse response = webResource.accept("application/json").type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
return checkStatus(response);
}
/**
* POST 메소드 호출
* Type : application/json
* json 형식으로 작성된 데이터를 인자로 받아 설정된 URL로 POST 메소드를 호출한다.
* @param json
* @return
*/
public ClientResponse post(String json) {
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, json);
return checkStatus(response);
}
private ClientResponse checkStatus(ClientResponse response) {
if(response.getStatus() != Status.OK.getStatusCode() && response.getStatus() != Status.CREATED.getStatusCode()) {
throw new ClientHandlerException("Failed : HTTP error code : " + response.getStatus());
}
return response;
}
}
|
UTF-8
|
Java
| 3,455
|
java
|
RestHttpClient.java
|
Java
|
[] | null |
[] |
package kr.co.saramin.itsDailyReport.module;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.Properties;
import javax.ws.rs.core.MediaType;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.api.client.filter.LoggingFilter;
import com.sun.jersey.api.json.JSONConfiguration;
/**
* <pre>
* 파 일 명 : RestHttpClient.java
* 설 명 : Rest API를 호출하기 위한 HttpClient 모듈 (Jersey Client)
* 작 성 자 : 김소현
* 작 성 일 : 2017.06.22
* 버 전 : 1.0
* 수정이력 :
* 기타사항 :
* </pre>
*/
public class RestHttpClient {
private ClientConfig clientConfig;
private Client client;
private WebResource webResource;
private Properties properties;
private final static String CONFIG_FILE = "-rest-client.properties";
/**
* Client 객체 생성 시 호스트 인증 정보 세팅을 위해 파라미터를 넘겨받는다
* apiRequest : jira, confluence
* 인자값에 따라 JIRA / Confluence 설정
* @param apiRequest
* @throws Exception
*/
public RestHttpClient(String apiRequest) throws Exception {
properties = new Properties();
InputStream fis = getClass().getClassLoader().getResourceAsStream(apiRequest+CONFIG_FILE);
properties.load(new BufferedInputStream(fis));
clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.FALSE);
client = Client.create(clientConfig);
client.addFilter(new LoggingFilter());
HTTPBasicAuthFilter auth = new HTTPBasicAuthFilter(properties.getProperty("user.id"), properties.getProperty("user.pwd"));
client.addFilter(auth);
}
/**
* 호출할 URL을 Client에 세팅한다.
* @param resourceName
*/
public void setResourceName(String resourceName) {
webResource = client.resource(properties.getProperty("server.url") + resourceName);
}
/**
* GET 메소드 호출
* Type : application/json
* @return
*/
public ClientResponse get() {
ClientResponse response = webResource.accept("application/json").type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
return checkStatus(response);
}
/**
* POST 메소드 호출
* Type : application/json
* json 형식으로 작성된 데이터를 인자로 받아 설정된 URL로 POST 메소드를 호출한다.
* @param json
* @return
*/
public ClientResponse post(String json) {
ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, json);
return checkStatus(response);
}
private ClientResponse checkStatus(ClientResponse response) {
if(response.getStatus() != Status.OK.getStatusCode() && response.getStatus() != Status.CREATED.getStatusCode()) {
throw new ClientHandlerException("Failed : HTTP error code : " + response.getStatus());
}
return response;
}
}
| 3,455
| 0.700775
| 0.697674
| 121
| 24.652893
| 29.698683
| 141
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.355372
| false
| false
|
13
|
f12a56d90f5021214f968cfbafb329b9de01d550
| 19,327,352,878,605
|
e5e11a404b211ecdfe9f4f632ae159720469f614
|
/onlinereg-webgwt/src/main/java/org/onlinereg/webgwt/client/register/RegisterFooter.java
|
b54786a11c24e6deb67f39c598637be1054b3035
|
[] |
no_license
|
olegbezk/registration
|
https://github.com/olegbezk/registration
|
b535078deac7468d1b55bb46725427a7de331740
|
e8c45742b72b6f98f451d27d2690d3a679709466
|
refs/heads/master
| 2021-03-12T22:58:12.643000
| 2014-10-03T18:52:32
| 2014-10-03T18:52:32
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.onlinereg.webgwt.client.register;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
/**
* This class represents the footer of the register view.
*
* @author Oleg Bezkorovajniy
*/
public class RegisterFooter extends Composite {
/** The main panel of the footer */
private HorizontalPanel hpanel = new HorizontalPanel();
public RegisterFooter() {
hpanel.setHeight("100px");
hpanel.setWidth("600px");
}
/**
* Returns the main panel of the footer
*
* @return The main panel of the footer
* */
public HorizontalPanel getHpanel() {
return hpanel;
}
}
|
UTF-8
|
Java
| 672
|
java
|
RegisterFooter.java
|
Java
|
[
{
"context": " the footer of the register view.\r\n * \r\n * @author Oleg Bezkorovajniy\r\n */\r\npublic class RegisterFooter extends Composi",
"end": 253,
"score": 0.9998632073402405,
"start": 235,
"tag": "NAME",
"value": "Oleg Bezkorovajniy"
}
] | null |
[] |
package org.onlinereg.webgwt.client.register;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
/**
* This class represents the footer of the register view.
*
* @author <NAME>
*/
public class RegisterFooter extends Composite {
/** The main panel of the footer */
private HorizontalPanel hpanel = new HorizontalPanel();
public RegisterFooter() {
hpanel.setHeight("100px");
hpanel.setWidth("600px");
}
/**
* Returns the main panel of the footer
*
* @return The main panel of the footer
* */
public HorizontalPanel getHpanel() {
return hpanel;
}
}
| 660
| 0.686012
| 0.677083
| 30
| 20.4
| 20.336502
| 57
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.8
| false
| false
|
13
|
60da0d2eeb44d8e22baa5d8d78af241b78345d5e
| 19,146,964,216,578
|
526022a005c7c25b5b9cd8264b9f2596e3bbd3f6
|
/EpamTaskTwo/src/main/java/by/tc/task01/service/validation/Parser.java
|
8a41379ce57df0ce107847a1f32f88a21aa3cd4c
|
[] |
no_license
|
Kirsan1777/JWD_Task02
|
https://github.com/Kirsan1777/JWD_Task02
|
d6158ead0a5cfc29c0856b8e3b6e4ba19e54ad90
|
e086bdf0c308dbc43bdcd458d650b199a3cff952
|
refs/heads/main
| 2023-02-03T09:27:20.531000
| 2020-12-22T13:54:21
| 2020-12-22T13:54:21
| 323,638,173
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package by.tc.task01.service.validation;
public class Parser {
public double parseDouble(String number){
double resultDouble;
resultDouble = Double.parseDouble(number);
return resultDouble;
}
public int parseInt(String number){
int resultInt;
resultInt = Integer.parseInt(number);
return resultInt;
}
}
|
UTF-8
|
Java
| 384
|
java
|
Parser.java
|
Java
|
[] | null |
[] |
package by.tc.task01.service.validation;
public class Parser {
public double parseDouble(String number){
double resultDouble;
resultDouble = Double.parseDouble(number);
return resultDouble;
}
public int parseInt(String number){
int resultInt;
resultInt = Integer.parseInt(number);
return resultInt;
}
}
| 384
| 0.632813
| 0.627604
| 15
| 23.6
| 17.292772
| 50
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.466667
| false
| false
|
13
|
4e19f6c42aebeee3e4864a4b3c14283c310fe396
| 22,832,046,210,365
|
98bfd38fdb10ea15c312194e670d4bbfa7452a8b
|
/src/lesson16/student/StudentDemo.java
|
48b269763c557704063a76b49e2b6a7751a6bc26
|
[] |
no_license
|
shellysnake/hometasks
|
https://github.com/shellysnake/hometasks
|
91288b4df14870041d39fd97d9581cd8600aa94f
|
17a3c51cc3e797cd939be0d18a378ee4c200cbfc
|
refs/heads/master
| 2020-04-11T21:02:35.054000
| 2019-02-14T11:59:47
| 2019-02-14T11:59:47
| 162,092,750
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package lesson16.student;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class StudentDemo {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student("Student1", "group1", 3, Arrays.asList(5, 5, 5, 3, 5)));
students.add(new Student("Student2", "group2", 1, Arrays.asList(2, 1, 2, 3, 3)));
students.add(new Student("Student3", "group3", 2, Arrays.asList(5, 4, 5, 3, 3)));
students.add(new Student("Student4", "group1", 3, Arrays.asList(5, 1, 1, 1, 1)));
students.add(new Student("Student5", "group2", 1, Arrays.asList(5, 1, 1, 3, 2)));
Iterator<Student> iterator = students.iterator();
while (iterator.hasNext()) {
Student student = iterator.next();
if (student.isExpelled()) {
iterator.remove();
}
}
for (Student student : students) {
System.out.print(student + " \n");
}
Student.printStudents(students, 3);
}
}
|
UTF-8
|
Java
| 1,100
|
java
|
StudentDemo.java
|
Java
|
[] | null |
[] |
package lesson16.student;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class StudentDemo {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student("Student1", "group1", 3, Arrays.asList(5, 5, 5, 3, 5)));
students.add(new Student("Student2", "group2", 1, Arrays.asList(2, 1, 2, 3, 3)));
students.add(new Student("Student3", "group3", 2, Arrays.asList(5, 4, 5, 3, 3)));
students.add(new Student("Student4", "group1", 3, Arrays.asList(5, 1, 1, 1, 1)));
students.add(new Student("Student5", "group2", 1, Arrays.asList(5, 1, 1, 3, 2)));
Iterator<Student> iterator = students.iterator();
while (iterator.hasNext()) {
Student student = iterator.next();
if (student.isExpelled()) {
iterator.remove();
}
}
for (Student student : students) {
System.out.print(student + " \n");
}
Student.printStudents(students, 3);
}
}
| 1,100
| 0.588182
| 0.549091
| 30
| 35.666668
| 28.964729
| 89
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.733333
| false
| false
|
13
|
83f234836dc386d9a3944a10960b1edb72be8a3c
| 18,399,639,947,076
|
051f7c749812acc5618506bc0922aa456921c20c
|
/okapi-core/src/main/java/org/folio/okapi/bean/NodeDescriptor.java
|
b1bbd74ca0a6c2bf21c2a912a50d6dec87dd71f2
|
[
"Apache-2.0"
] |
permissive
|
folio-org/okapi
|
https://github.com/folio-org/okapi
|
0a6fc2f5577478ea05a8bf80370455d113124781
|
906321a81658a585f19a35480dae539838ec4ca6
|
refs/heads/master
| 2023-07-19T23:16:21.480000
| 2023-06-21T13:31:39
| 2023-06-21T13:31:39
| 49,057,615
| 136
| 113
|
Apache-2.0
| false
| 2023-03-30T20:04:02
| 2016-01-05T09:59:37
| 2023-03-24T16:56:48
| 2023-03-30T20:04:02
| 9,416
| 112
| 83
| 15
|
Java
| false
| false
|
package org.folio.okapi.bean;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Description of a node in the Okapi cluster.
*/
@JsonInclude(Include.NON_NULL)
public class NodeDescriptor {
private String nodeId;
private String url;
private String nodeName;
/**
* Return node name.
*
* @return node name
*/
public String getNodeName() {
return nodeName;
}
/**
* Set the node name.
*
* @param nodeName new value of nodeName
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
/**
* get node ID.
* @return node ID string
*/
public String getNodeId() {
return nodeId;
}
/**
* set node ID.
* @param id node ID
*/
public void setNodeId(String id) {
if (id == null || id.isEmpty()) {
id = null;
}
this.nodeId = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
|
UTF-8
|
Java
| 1,023
|
java
|
NodeDescriptor.java
|
Java
|
[] | null |
[] |
package org.folio.okapi.bean;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Description of a node in the Okapi cluster.
*/
@JsonInclude(Include.NON_NULL)
public class NodeDescriptor {
private String nodeId;
private String url;
private String nodeName;
/**
* Return node name.
*
* @return node name
*/
public String getNodeName() {
return nodeName;
}
/**
* Set the node name.
*
* @param nodeName new value of nodeName
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
/**
* get node ID.
* @return node ID string
*/
public String getNodeId() {
return nodeId;
}
/**
* set node ID.
* @param id node ID
*/
public void setNodeId(String id) {
if (id == null || id.isEmpty()) {
id = null;
}
this.nodeId = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
| 1,023
| 0.620723
| 0.620723
| 61
| 15.770492
| 15.14346
| 60
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.245902
| false
| false
|
13
|
b50fa1f614efa758e89cd5f0fe4d60aa44690033
| 26,250,840,163,507
|
bc1648a8c27a71141ed9b333be97357a0620d404
|
/MagicRecipe/app/src/main/java/recipes/varuna/com/magicrecipe/adapter/RecipeAdapter.java
|
d7c273e7002ed2f1014d7a15298a8a6eac0a10b6
|
[] |
no_license
|
varunagp/Magic-Recipe
|
https://github.com/varunagp/Magic-Recipe
|
9964ff5813859b44a723bc84bfa2cc51e5bf62d5
|
5aefaa9c02ed3000a7295da5d91fa79622f0620d
|
refs/heads/master
| 2021-01-10T02:07:27.326000
| 2016-01-07T20:05:05
| 2016-01-07T20:05:05
| 49,228,250
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package recipes.varuna.com.magicrecipe.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import recipes.varuna.com.magicrecipe.R;
import recipes.varuna.com.magicrecipe.model.Result;
public class RecipeAdapter extends BaseAdapter {
List<Result> myList = new ArrayList<Result>();
LayoutInflater inflater;
Context context;
public RecipeAdapter(Context context, List<Result> myList) {
this.myList = myList;
this.context = context;
inflater = LayoutInflater.from(this.context);
}
@Override
public int getCount() {
return myList.size();
}
@Override
public Result getItem(int position) {
return myList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyViewHolder mViewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.recipe_list_item, parent, false);
mViewHolder = new MyViewHolder(convertView);
convertView.setTag(mViewHolder);
} else {
mViewHolder = (MyViewHolder) convertView.getTag();
}
Result currentListData = getItem(position);
mViewHolder.tvTitle.setText(currentListData.getTitle());
mViewHolder.tvDesc.setText(currentListData.getIngredients());
if (currentListData.getThumbnail() != null && !currentListData.getThumbnail().equalsIgnoreCase("")) {
loadBitmap(mViewHolder.imageView, currentListData);
}
return convertView;
}
public void loadBitmap(ImageView imageView, Result currentListData) {
Picasso.with(this.context).load(currentListData.getThumbnail())
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.ic_launcher).tag(this.context).into(imageView);
}
private class MyViewHolder {
TextView tvTitle, tvDesc;
ImageView imageView;
public MyViewHolder(View item) {
tvTitle = (TextView) item.findViewById(R.id.title_value);
tvDesc = (TextView) item.findViewById(R.id.ingredients_value);
imageView = (ImageView) item.findViewById(R.id.image);
}
}
}
|
UTF-8
|
Java
| 2,651
|
java
|
RecipeAdapter.java
|
Java
|
[] | null |
[] |
package recipes.varuna.com.magicrecipe.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import recipes.varuna.com.magicrecipe.R;
import recipes.varuna.com.magicrecipe.model.Result;
public class RecipeAdapter extends BaseAdapter {
List<Result> myList = new ArrayList<Result>();
LayoutInflater inflater;
Context context;
public RecipeAdapter(Context context, List<Result> myList) {
this.myList = myList;
this.context = context;
inflater = LayoutInflater.from(this.context);
}
@Override
public int getCount() {
return myList.size();
}
@Override
public Result getItem(int position) {
return myList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyViewHolder mViewHolder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.recipe_list_item, parent, false);
mViewHolder = new MyViewHolder(convertView);
convertView.setTag(mViewHolder);
} else {
mViewHolder = (MyViewHolder) convertView.getTag();
}
Result currentListData = getItem(position);
mViewHolder.tvTitle.setText(currentListData.getTitle());
mViewHolder.tvDesc.setText(currentListData.getIngredients());
if (currentListData.getThumbnail() != null && !currentListData.getThumbnail().equalsIgnoreCase("")) {
loadBitmap(mViewHolder.imageView, currentListData);
}
return convertView;
}
public void loadBitmap(ImageView imageView, Result currentListData) {
Picasso.with(this.context).load(currentListData.getThumbnail())
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.ic_launcher).tag(this.context).into(imageView);
}
private class MyViewHolder {
TextView tvTitle, tvDesc;
ImageView imageView;
public MyViewHolder(View item) {
tvTitle = (TextView) item.findViewById(R.id.title_value);
tvDesc = (TextView) item.findViewById(R.id.ingredients_value);
imageView = (ImageView) item.findViewById(R.id.image);
}
}
}
| 2,651
| 0.650698
| 0.650321
| 87
| 28.471264
| 25.949482
| 109
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.528736
| false
| false
|
13
|
20eab3e59401bb84b44ee31de790f1c2c6926898
| 4,329,327,065,979
|
0b436fa7be6050bbfade8527b0264cfa36e15ab7
|
/src/java/main/com/youngbook/action/customer/CustomerProtectionQAAction.java
|
5cd0a29400d5d90e2a7a7e8be2be43f4d22c5d53
|
[] |
no_license
|
dengyingjie123/-
|
https://github.com/dengyingjie123/-
|
6f3429dc68ab98f8754794f10c6e3ad175feb903
|
a7eacfe6dac07f7f872dcffc4b9f8fc8f9c6d29a
|
refs/heads/master
| 2020-04-18T02:17:01.155000
| 2019-01-06T09:48:23
| 2019-01-06T09:48:23
| 167,156,349
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.youngbook.action.customer;
import com.youngbook.action.BaseAction;
import com.youngbook.annotation.Security;
import com.youngbook.common.MyException;
import com.youngbook.common.Pager;
import com.youngbook.common.ReturnObject;
import com.youngbook.common.ReturnObjectCode;
import com.youngbook.common.utils.HttpUtils;
import com.youngbook.common.utils.StringUtils;
import com.youngbook.entity.po.customer.CustomerAuthenticationStatus;
import com.youngbook.service.customer.CustomerAuthenticationStatusService;
import com.youngbook.service.customer.CustomerProtectionQAService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.sql.Connection;
public class CustomerProtectionQAAction extends BaseAction {
@Autowired
CustomerAuthenticationStatusService customerAuthenticationStatusService;
@Autowired
CustomerProtectionQAService customerProtectionQAService;
/**
* 获取安全保护问题
*
* 说明:如果传入了 customerId,则返回该客户设置的安全密保问题和答案
* 如果 customerId 没有传或为空,则返回系统定义的安全保护问题,供下拉菜单使用
*
* 作者:邓超
* 内容:创建代码
* 时间:2015年12月14日
*
* @return
* @throws Exception
*/
@Security(needToken = true)
public String getQA() throws Exception {
// 获取请求对象、数据库连接
HttpServletRequest request = this.getRequest();
Connection conn = this.getConnection();
// 获取参数
String customerId = HttpUtils.getParameter(request, "customerId");
// 如果客户 ID 参数不为空,那么查询该客户设置过的安全密保问题
if(StringUtils.isEmpty(customerId) || customerId.length() != 32) {
Pager pager = customerProtectionQAService.getQuestions(conn);
this.getResult().setReturnValue(pager);
}
// 否则查询系统在 KV 里配置好的安全密保问题,供客户设置
else {
Pager pager = customerProtectionQAService.getQAByCustomerId(customerId, conn);
this.getResult().setReturnValue(pager);
}
return SUCCESS;
}
/**
* 保存客户的安全密保问题和答案
*
* 作者:邓超
* 内容:创建代码
* 时间:2015年12月14日
*
* @return
* @throws Exception
*/
@Security(needToken = true)
public String save() throws Exception {
// 获取请求对象和连接
HttpServletRequest request = this.getRequest();
Connection conn = this.getConnection();
// 获取客户 ID
String customerId = HttpUtils.getParameter(request, "customerId");
// 获取客户选择的问题
String q1 = HttpUtils.getParameter(request, "q1");
String q2 = HttpUtils.getParameter(request, "q2");
String q3 = HttpUtils.getParameter(request, "q3");
// 获取客户的答案
String a1 = HttpUtils.getParameter(request, "a1");
String a2 = HttpUtils.getParameter(request, "a2");
String a3 = HttpUtils.getParameter(request, "a3");
// 校验参数
if(StringUtils.isEmpty(customerId) || customerId.length() != 32) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_COMPLETE, "参数不完整").throwException();
}
if(StringUtils.isEmpty(a1) || StringUtils.isEmpty(a2) || StringUtils.isEmpty(a3) || StringUtils.isEmpty(q1) || StringUtils.isEmpty(q2) || StringUtils.isEmpty(q3)) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_COMPLETE, "参数不完整").throwException();
}
// 参数双边去空
q1 = q1.trim();
q2 = q2.trim();
q3 = q3.trim();
a1 = a1.trim();
a2 = a2.trim();
a3 = a3.trim();
// 检查问题是否存在于系统中
if(!customerProtectionQAService.isQuestionExist(q1, conn) || !customerProtectionQAService.isQuestionExist(q2, conn) || !customerProtectionQAService.isQuestionExist(q3, conn)) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_CORRECT, "参数不正确").throwException();
}
// 保存安全密保问题与答案
Integer count = customerProtectionQAService.saveQA(customerId, q1, a1, q2, a2, q3, a3, conn);
if(count != 1) {
MyException.newInstance(ReturnObject.CODE_DB_EXCEPTION, "您的数据保存失败,请稍候重试").throwException();
}
// 设置安全密保问题的认证状态
customerAuthenticationStatusService.saveAuthenticationStatus(customerId, CustomerAuthenticationStatus.AUTH_TYPE_QA, conn);
return SUCCESS;
}
}
|
UTF-8
|
Java
| 4,859
|
java
|
CustomerProtectionQAAction.java
|
Java
|
[
{
"context": "Id 没有传或为空,则返回系统定义的安全保护问题,供下拉菜单使用\n *\n * 作者:邓超\n * 内容:创建代码\n * 时间:2015年12月14日\n *\n ",
"end": 1108,
"score": 0.7257087826728821,
"start": 1106,
"tag": "NAME",
"value": "邓超"
},
{
"context": "}\n\n /**\n * 保存客户的安全密保问题和答案\n *\n * 作者:邓超\n * 内容:创建代码\n * 时间:2015年12月14日\n *\n ",
"end": 2044,
"score": 0.9677891731262207,
"start": 2042,
"tag": "NAME",
"value": "邓超"
}
] | null |
[] |
package com.youngbook.action.customer;
import com.youngbook.action.BaseAction;
import com.youngbook.annotation.Security;
import com.youngbook.common.MyException;
import com.youngbook.common.Pager;
import com.youngbook.common.ReturnObject;
import com.youngbook.common.ReturnObjectCode;
import com.youngbook.common.utils.HttpUtils;
import com.youngbook.common.utils.StringUtils;
import com.youngbook.entity.po.customer.CustomerAuthenticationStatus;
import com.youngbook.service.customer.CustomerAuthenticationStatusService;
import com.youngbook.service.customer.CustomerProtectionQAService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.sql.Connection;
public class CustomerProtectionQAAction extends BaseAction {
@Autowired
CustomerAuthenticationStatusService customerAuthenticationStatusService;
@Autowired
CustomerProtectionQAService customerProtectionQAService;
/**
* 获取安全保护问题
*
* 说明:如果传入了 customerId,则返回该客户设置的安全密保问题和答案
* 如果 customerId 没有传或为空,则返回系统定义的安全保护问题,供下拉菜单使用
*
* 作者:邓超
* 内容:创建代码
* 时间:2015年12月14日
*
* @return
* @throws Exception
*/
@Security(needToken = true)
public String getQA() throws Exception {
// 获取请求对象、数据库连接
HttpServletRequest request = this.getRequest();
Connection conn = this.getConnection();
// 获取参数
String customerId = HttpUtils.getParameter(request, "customerId");
// 如果客户 ID 参数不为空,那么查询该客户设置过的安全密保问题
if(StringUtils.isEmpty(customerId) || customerId.length() != 32) {
Pager pager = customerProtectionQAService.getQuestions(conn);
this.getResult().setReturnValue(pager);
}
// 否则查询系统在 KV 里配置好的安全密保问题,供客户设置
else {
Pager pager = customerProtectionQAService.getQAByCustomerId(customerId, conn);
this.getResult().setReturnValue(pager);
}
return SUCCESS;
}
/**
* 保存客户的安全密保问题和答案
*
* 作者:邓超
* 内容:创建代码
* 时间:2015年12月14日
*
* @return
* @throws Exception
*/
@Security(needToken = true)
public String save() throws Exception {
// 获取请求对象和连接
HttpServletRequest request = this.getRequest();
Connection conn = this.getConnection();
// 获取客户 ID
String customerId = HttpUtils.getParameter(request, "customerId");
// 获取客户选择的问题
String q1 = HttpUtils.getParameter(request, "q1");
String q2 = HttpUtils.getParameter(request, "q2");
String q3 = HttpUtils.getParameter(request, "q3");
// 获取客户的答案
String a1 = HttpUtils.getParameter(request, "a1");
String a2 = HttpUtils.getParameter(request, "a2");
String a3 = HttpUtils.getParameter(request, "a3");
// 校验参数
if(StringUtils.isEmpty(customerId) || customerId.length() != 32) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_COMPLETE, "参数不完整").throwException();
}
if(StringUtils.isEmpty(a1) || StringUtils.isEmpty(a2) || StringUtils.isEmpty(a3) || StringUtils.isEmpty(q1) || StringUtils.isEmpty(q2) || StringUtils.isEmpty(q3)) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_COMPLETE, "参数不完整").throwException();
}
// 参数双边去空
q1 = q1.trim();
q2 = q2.trim();
q3 = q3.trim();
a1 = a1.trim();
a2 = a2.trim();
a3 = a3.trim();
// 检查问题是否存在于系统中
if(!customerProtectionQAService.isQuestionExist(q1, conn) || !customerProtectionQAService.isQuestionExist(q2, conn) || !customerProtectionQAService.isQuestionExist(q3, conn)) {
MyException.newInstance(ReturnObjectCode.PUBLIC_PARAMETER_NOT_CORRECT, "参数不正确").throwException();
}
// 保存安全密保问题与答案
Integer count = customerProtectionQAService.saveQA(customerId, q1, a1, q2, a2, q3, a3, conn);
if(count != 1) {
MyException.newInstance(ReturnObject.CODE_DB_EXCEPTION, "您的数据保存失败,请稍候重试").throwException();
}
// 设置安全密保问题的认证状态
customerAuthenticationStatusService.saveAuthenticationStatus(customerId, CustomerAuthenticationStatus.AUTH_TYPE_QA, conn);
return SUCCESS;
}
}
| 4,859
| 0.671179
| 0.657176
| 127
| 32.740158
| 34.311497
| 184
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.708661
| false
| false
|
13
|
ce3b58a666aefe8fa6ccb6d0b0c80fb1c49360d4
| 16,028,817,995,664
|
22fe2d41528416108ef0abbe78433d9ae9bb3a21
|
/src/main/java/pw/io/booker/model/Token.java
|
7aae8a5b1673204023ff3b209e6ad4fc53766e02
|
[] |
no_license
|
Illaoiiiiii/BookerServiceAuth
|
https://github.com/Illaoiiiiii/BookerServiceAuth
|
c19cfe3b48075d6ecc834655fc007a9e29a3b9bc
|
8d4abb457064f96000b0a335d4112acb4e810aab
|
refs/heads/master
| 2020-03-27T21:32:37.822000
| 2018-09-03T09:13:28
| 2018-09-03T09:13:28
| 147,154,691
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package pw.io.booker.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
public class Token {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int tokenId;
private String tokenString;
@JsonIgnore
@OneToOne
@JoinColumn(name="customerId")
private Customer customer;
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public int getTokenId() {
return tokenId;
}
public void setTokenId(int tokenId) {
this.tokenId = tokenId;
}
public String getTokenString() {
return tokenString;
}
public void setTokenString(String tokenString) {
this.tokenString = tokenString;
}
}
|
UTF-8
|
Java
| 926
|
java
|
Token.java
|
Java
|
[] | null |
[] |
package pw.io.booker.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
public class Token {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int tokenId;
private String tokenString;
@JsonIgnore
@OneToOne
@JoinColumn(name="customerId")
private Customer customer;
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public int getTokenId() {
return tokenId;
}
public void setTokenId(int tokenId) {
this.tokenId = tokenId;
}
public String getTokenString() {
return tokenString;
}
public void setTokenString(String tokenString) {
this.tokenString = tokenString;
}
}
| 926
| 0.769978
| 0.769978
| 47
| 18.702127
| 16.412132
| 51
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.12766
| false
| false
|
13
|
780b75a0fa7abcceec2cc396be914b00c44eb094
| 32,100,585,634,676
|
3f4284b3f18273ed952d44319f36ae436f56b5f7
|
/grade-horaria/src/br/edu/faculdadeprojecao/teste/cadastro/TesteCadastroFichaDocente.java
|
28139a1978d4438ee7087b4e551621839b62a893
|
[] |
no_license
|
marlonpessoa/grade-hor
|
https://github.com/marlonpessoa/grade-hor
|
ad4b23e2fb4637b19e3bb525cc07fab434ece957
|
415e3609105b1afb326946dc33961a0845e34972
|
refs/heads/master
| 2018-01-10T05:30:04.493000
| 2013-03-06T14:14:25
| 2013-03-06T14:14:25
| 45,052,151
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package br.edu.faculdadeprojecao.teste.cadastro;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import br.edu.faculdadeprojecao.DAO.ProfessorDAO;
import br.edu.faculdadeprojecao.DAO.UsuarioDAO;
import br.edu.faculdadeprojecao.enuns.TipoTelefone;
import br.edu.faculdadeprojecao.infra.JPAUtil;
import br.edu.faculdadeprojecao.modelo.Endereco;
import br.edu.faculdadeprojecao.modelo.ExperienciaDocente;
import br.edu.faculdadeprojecao.modelo.ExperienciaProfissional;
import br.edu.faculdadeprojecao.modelo.Formacao;
import br.edu.faculdadeprojecao.modelo.Publicacao;
import br.edu.faculdadeprojecao.modelo.Telefone;
import br.edu.faculdadeprojecao.modelo.TipoFormacao;
import br.edu.faculdadeprojecao.modelo.Usuario;
public class TesteCadastroFichaDocente {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
EntityManager em = new JPAUtil().getEntityManager();
em.getTransaction().begin();
UsuarioDAO daoU = new UsuarioDAO();
Usuario usuario = daoU.busca(2);
//System.out.println("teset "+usuario.getEndereco().getLogradouro());
Publicacao publicacao = new Publicacao();
publicacao.setTitulo("Primeira Publicação");
publicacao.setDescricao("Esse texto se refere a publicação");
publicacao.setUsuario(usuario);
em.persist(publicacao);
Telefone telefone = new Telefone();
telefone.setNumero("6134656333");
telefone.setTipo(TipoTelefone.fixo);
telefone.setUsuario(usuario);
em.persist(telefone);
Endereco endereco = new Endereco();
endereco.setBairro("Estrutural");
endereco.setCidade("Brasília");
endereco.setLogradouro("Qd 03 Cj 01 Lt 01/02 Setor Oeste");
endereco.setTipo_logradouro("Quadra");
endereco.setUf("DF");
endereco.setCep("71255705");
endereco.setUsuario(usuario);
em.persist(endereco);
SimpleDateFormat sp = new SimpleDateFormat("dd/MM/yyyy");
Date date = sp.parse("01/11/1986");
ExperienciaDocente docente = new ExperienciaDocente();
docente.setDisciplinaLecionada("Filosofia");
docente.setInicio(date);
docente.setInstituicaoDeEnsino("UCB");
docente.setTermino(date);
docente.setUsuario(usuario);
em.persist(docente);
date = sp.parse("20/04/2007");
ExperienciaProfissional experienciaProfissional = new ExperienciaProfissional();
experienciaProfissional.setEmpresa("00");
experienciaProfissional.setFuncao("00 de Projeto");
experienciaProfissional.setInicio(date);
experienciaProfissional.setTermino(date);
experienciaProfissional.setUsuario(usuario);
em.persist(experienciaProfissional);
TipoFormacao formacao = new TipoFormacao();
formacao.setDescricao("Graduação");
em.persist(formacao);
TipoFormacao formacao2 = new TipoFormacao();
formacao2.setDescricao("Pós Graduação");
em.persist(formacao2);
Formacao formacao01 = new Formacao();
formacao01.setTipoFormacao(em.find(TipoFormacao.class, 1));
formacao01.setAnoConclusao(date);
formacao01.setDescricao("BLABLA");
formacao01.setInstituicaoDeEnsino("UPIS");
formacao01.setUsuario(usuario);
em.persist(formacao01);
em.getTransaction().commit();
em.close();
}
}
|
ISO-8859-1
|
Java
| 3,464
|
java
|
TesteCadastroFichaDocente.java
|
Java
|
[] | null |
[] |
package br.edu.faculdadeprojecao.teste.cadastro;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.persistence.EntityManager;
import javax.persistence.EnumType;
import br.edu.faculdadeprojecao.DAO.ProfessorDAO;
import br.edu.faculdadeprojecao.DAO.UsuarioDAO;
import br.edu.faculdadeprojecao.enuns.TipoTelefone;
import br.edu.faculdadeprojecao.infra.JPAUtil;
import br.edu.faculdadeprojecao.modelo.Endereco;
import br.edu.faculdadeprojecao.modelo.ExperienciaDocente;
import br.edu.faculdadeprojecao.modelo.ExperienciaProfissional;
import br.edu.faculdadeprojecao.modelo.Formacao;
import br.edu.faculdadeprojecao.modelo.Publicacao;
import br.edu.faculdadeprojecao.modelo.Telefone;
import br.edu.faculdadeprojecao.modelo.TipoFormacao;
import br.edu.faculdadeprojecao.modelo.Usuario;
public class TesteCadastroFichaDocente {
/**
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
EntityManager em = new JPAUtil().getEntityManager();
em.getTransaction().begin();
UsuarioDAO daoU = new UsuarioDAO();
Usuario usuario = daoU.busca(2);
//System.out.println("teset "+usuario.getEndereco().getLogradouro());
Publicacao publicacao = new Publicacao();
publicacao.setTitulo("Primeira Publicação");
publicacao.setDescricao("Esse texto se refere a publicação");
publicacao.setUsuario(usuario);
em.persist(publicacao);
Telefone telefone = new Telefone();
telefone.setNumero("6134656333");
telefone.setTipo(TipoTelefone.fixo);
telefone.setUsuario(usuario);
em.persist(telefone);
Endereco endereco = new Endereco();
endereco.setBairro("Estrutural");
endereco.setCidade("Brasília");
endereco.setLogradouro("Qd 03 Cj 01 Lt 01/02 Setor Oeste");
endereco.setTipo_logradouro("Quadra");
endereco.setUf("DF");
endereco.setCep("71255705");
endereco.setUsuario(usuario);
em.persist(endereco);
SimpleDateFormat sp = new SimpleDateFormat("dd/MM/yyyy");
Date date = sp.parse("01/11/1986");
ExperienciaDocente docente = new ExperienciaDocente();
docente.setDisciplinaLecionada("Filosofia");
docente.setInicio(date);
docente.setInstituicaoDeEnsino("UCB");
docente.setTermino(date);
docente.setUsuario(usuario);
em.persist(docente);
date = sp.parse("20/04/2007");
ExperienciaProfissional experienciaProfissional = new ExperienciaProfissional();
experienciaProfissional.setEmpresa("00");
experienciaProfissional.setFuncao("00 de Projeto");
experienciaProfissional.setInicio(date);
experienciaProfissional.setTermino(date);
experienciaProfissional.setUsuario(usuario);
em.persist(experienciaProfissional);
TipoFormacao formacao = new TipoFormacao();
formacao.setDescricao("Graduação");
em.persist(formacao);
TipoFormacao formacao2 = new TipoFormacao();
formacao2.setDescricao("Pós Graduação");
em.persist(formacao2);
Formacao formacao01 = new Formacao();
formacao01.setTipoFormacao(em.find(TipoFormacao.class, 1));
formacao01.setAnoConclusao(date);
formacao01.setDescricao("BLABLA");
formacao01.setInstituicaoDeEnsino("UPIS");
formacao01.setUsuario(usuario);
em.persist(formacao01);
em.getTransaction().commit();
em.close();
}
}
| 3,464
| 0.744354
| 0.725536
| 114
| 28.298246
| 20.828005
| 82
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.929825
| false
| false
|
13
|
a25c0c86376bcc3099e2f564d211d3c3472289da
| 24,996,709,665,660
|
59837921c3f1a93569428382717860800ebdb684
|
/MatrixScalarMultiplication/MatrixScalarMultiplication.java
|
3204612143ea1a87be0ce86aafe07262a8bce5a2
|
[] |
no_license
|
chao-ji/learn_hadoop
|
https://github.com/chao-ji/learn_hadoop
|
1f4f1f9d841713ec09915a5073573621646fbe84
|
7c50d27063cdffd5165a126bfc6cde3e3eeb59c8
|
refs/heads/master
| 2021-01-15T08:57:41.715000
| 2016-08-23T01:41:54
| 2016-08-23T01:41:54
| 58,338,108
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class MatrixScalarMultiplication
{
public static class Mapper1 extends Mapper<Object, Text, Text, Text>
{
public void map(Object key, Text value, Context context) throws IOException, InterruptedException
{
String line = value.toString();
String[] tsv = line.split("\t");
String matrixID = tsv[0].substring(0, 1);
String rowID = tsv[0].substring(1);
for (int i = 1; i < tsv.length; i++)
{
String colID = Integer.toString(i);
String outputKey = matrixID + rowID;
String outputVal = tsv[i] + ":" + colID;
context.write(new Text(outputKey), new Text(outputVal));
}
}
}
public static class Reducer1 extends Reducer<Text, Text, Text, Text>
{
double scalar;
public void setup(Context context) throws IOException, InterruptedException
{
scalar = Double.parseDouble(context.getConfiguration().get("scalar"));
}
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException
{
List<String> list = new ArrayList<String>();
for (Text val : values)
list.add(val.toString());
KeyComparator kc = new KeyComparator();
Collections.sort(list, kc);
StringBuilder row = new StringBuilder();
for (int i = 0; i < list.size(); i++)
{
String[] csv = list.get(i).split(":");
double val = scalar * Double.parseDouble(csv[0]);
if (i < list.size() - 1)
row.append(Double.toString(val) + "\t");
else
row.append(Double.toString(val));
}
context.write(key, new Text(row.toString()));
}
}
static class KeyComparator implements Comparator<String>
{
public int compare(String s1, String s2)
{
String[] parts1 = s1.split(":");
String[] parts2 = s2.split(":");
return Integer.parseInt(parts1[1]) - Integer.parseInt(parts2[1]);
}
}
public static void main(String[] args) throws Exception
{
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2)
{
System.err.println("Usage: MatrixScalarMultiplication <scalar> <in> <out>");
}
conf.set("scalar", otherArgs[0]);
String input = otherArgs[1];
String output = otherArgs[2];
Job job = Job.getInstance(conf, "MatrixScalarMultiplication");
job.setJarByClass(MatrixScalarMultiplication.class);
job.setMapperClass(Mapper1.class);
job.setReducerClass(Reducer1.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(input));
FileOutputFormat.setOutputPath(job, new Path(output));
job.waitForCompletion(true);
}
}
|
UTF-8
|
Java
| 3,177
|
java
|
MatrixScalarMultiplication.java
|
Java
|
[] | null |
[] |
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
public class MatrixScalarMultiplication
{
public static class Mapper1 extends Mapper<Object, Text, Text, Text>
{
public void map(Object key, Text value, Context context) throws IOException, InterruptedException
{
String line = value.toString();
String[] tsv = line.split("\t");
String matrixID = tsv[0].substring(0, 1);
String rowID = tsv[0].substring(1);
for (int i = 1; i < tsv.length; i++)
{
String colID = Integer.toString(i);
String outputKey = matrixID + rowID;
String outputVal = tsv[i] + ":" + colID;
context.write(new Text(outputKey), new Text(outputVal));
}
}
}
public static class Reducer1 extends Reducer<Text, Text, Text, Text>
{
double scalar;
public void setup(Context context) throws IOException, InterruptedException
{
scalar = Double.parseDouble(context.getConfiguration().get("scalar"));
}
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException
{
List<String> list = new ArrayList<String>();
for (Text val : values)
list.add(val.toString());
KeyComparator kc = new KeyComparator();
Collections.sort(list, kc);
StringBuilder row = new StringBuilder();
for (int i = 0; i < list.size(); i++)
{
String[] csv = list.get(i).split(":");
double val = scalar * Double.parseDouble(csv[0]);
if (i < list.size() - 1)
row.append(Double.toString(val) + "\t");
else
row.append(Double.toString(val));
}
context.write(key, new Text(row.toString()));
}
}
static class KeyComparator implements Comparator<String>
{
public int compare(String s1, String s2)
{
String[] parts1 = s1.split(":");
String[] parts2 = s2.split(":");
return Integer.parseInt(parts1[1]) - Integer.parseInt(parts2[1]);
}
}
public static void main(String[] args) throws Exception
{
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2)
{
System.err.println("Usage: MatrixScalarMultiplication <scalar> <in> <out>");
}
conf.set("scalar", otherArgs[0]);
String input = otherArgs[1];
String output = otherArgs[2];
Job job = Job.getInstance(conf, "MatrixScalarMultiplication");
job.setJarByClass(MatrixScalarMultiplication.class);
job.setMapperClass(Mapper1.class);
job.setReducerClass(Reducer1.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(input));
FileOutputFormat.setOutputPath(job, new Path(output));
job.waitForCompletion(true);
}
}
| 3,177
| 0.710104
| 0.701605
| 107
| 28.691589
| 25.666594
| 111
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.448598
| false
| false
|
13
|
b9184b87ffbcd10671e841b888593106cb0000ce
| 3,040,836,897,543
|
4d3bca01bcc3675b6c7fea9e5c3564d35f35a69a
|
/src/main/java/org/idreambox/action/UploadAction.java
|
1357c42fa0707be2f3dde28bcf34a814de8a72e0
|
[
"Apache-2.0"
] |
permissive
|
DoubleRound/iDreambox-java
|
https://github.com/DoubleRound/iDreambox-java
|
e1990ec51dd2bb144dadbe27148ed3f7846a3aae
|
81e8bea0e48689da05303e054d2549999aeebafc
|
HEAD
| 2016-09-09T20:37:02.237000
| 2015-04-02T05:21:20
| 2015-04-02T05:21:20
| 22,087,783
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package org.idreambox.action;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class UploadAction extends ActionSupport {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(UploadAction.class);
private static final long serialVersionUID = -4227778982276464812L;
private File file;
private String fileFileName;
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String execute() throws Exception {
logger.info("执行了upload");
// 实现上传
InputStream is = new FileInputStream(file);
String root = ServletActionContext.getServletContext().getRealPath("upload");
File deskFile = new File(root, this.getFileFileName());
OutputStream os = new FileOutputStream(deskFile);
byte[] bytefer = new byte[1024];
int length = 0;
while ((length = is.read(bytefer)) != -1) {
os.write(bytefer, 0, length);
}
os.close();
is.close();
return "success";
}
}
|
UTF-8
|
Java
| 1,571
|
java
|
UploadAction.java
|
Java
|
[] | null |
[] |
package org.idreambox.action;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class UploadAction extends ActionSupport {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(UploadAction.class);
private static final long serialVersionUID = -4227778982276464812L;
private File file;
private String fileFileName;
private String fileContentType;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String execute() throws Exception {
logger.info("执行了upload");
// 实现上传
InputStream is = new FileInputStream(file);
String root = ServletActionContext.getServletContext().getRealPath("upload");
File deskFile = new File(root, this.getFileFileName());
OutputStream os = new FileOutputStream(deskFile);
byte[] bytefer = new byte[1024];
int length = 0;
while ((length = is.read(bytefer)) != -1) {
os.write(bytefer, 0, length);
}
os.close();
is.close();
return "success";
}
}
| 1,571
| 0.743738
| 0.725112
| 69
| 21.57971
| 20.835035
| 79
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.405797
| false
| false
|
13
|
1043741cf0adbea30090523996c2acb10e1d4107
| 3,040,836,894,351
|
369249230e40e0f56db0533c40675ba203292e58
|
/javaMap/property/property/src/main/java/com/xiaochen/service/Impl/LCostServiceImpl.java
|
6eec0c8f7bc9a03a658747cd4cd86d81c4d369dc
|
[] |
no_license
|
pandasbeatles/javaSE-EE
|
https://github.com/pandasbeatles/javaSE-EE
|
eb0629cd29c5ba03642f6ea55ba26112e1d4e525
|
8c3cdcba575f54a99f86ed1db7867a6b5b6e07c2
|
refs/heads/master
| 2020-09-29T19:31:36.568000
| 2019-12-10T12:03:16
| 2019-12-10T12:03:16
| 227,106,033
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.xiaochen.service.Impl;
import com.xiaochen.mapper.CostMapper;
import com.xiaochen.pojo.Cost;
import com.xiaochen.service.LCostService;
import com.xiaochen.util.Tojsons;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("LCostService")
public class LCostServiceImpl implements LCostService {
@Autowired
private CostMapper costMapper;
@Override
public JSONObject selectcostlist(Map map) {
List<Cost> selectcostlist = costMapper.selectcostlist(map);
JSONObject jsons;
Integer a = 0;
List list = new ArrayList();
for (Cost c : selectcostlist) {
Map<String, Object> maps = new HashMap<>();
maps.put("userId", c.getUser().getUserId());
maps.put("userName", c.getUser().getUserName());
maps.put("userPhonenumber", c.getUser().getUserPhonenumber());
maps.put("userDress", c.getUser().getUserDress());
maps.put("userSize", c.getUser().getUserSize());
maps.put("userType", c.getUser().getUserType());
maps.put("costId", c.getCostId());
/*费用类型*/
maps.put("costType", "水费-电费-燃气费-空调费-其他费用");
maps.put("costWtate", c.getCostWater());
maps.put("costGas", c.getCostGas());
maps.put("costPower", c.getCostPower());
maps.put("costAir", c.getCostAir());
maps.put("costOther", c.getCostOther());
maps.put("costDate", new SimpleDateFormat("yyyy-MM-dd").format(c.getCostDate()));
/* maps.put("costState", c.getCostState());*/
maps.put("costState", "否");
a = Integer.parseInt(c.getCostAir()) + Integer.parseInt(c.getCostWater()) + Integer.parseInt(c.getCostGas()) + Integer.parseInt(c.getCostOther()) + Integer.parseInt(c.getCostPower());
maps.put("sumCost", a);
list.add(maps);
}
jsons = Tojsons.layuiJson((int)map.get("rows"), list);
return jsons;
}
@Override
public JSONObject selectcostsuccess(int id) {
List<Cost> selectcostsuccess = costMapper.selectcostsuccess(id);
JSONObject jsons;
Integer a = 0;
List list = new ArrayList();
for (Cost c : selectcostsuccess) {
Map<String, Object> maps = new HashMap<>();
maps.put("userId", c.getUser().getUserId());
maps.put("costId", c.getCostId());
maps.put("userName", c.getUser().getUserName());
maps.put("userSize", c.getUser().getUserSize());
maps.put("userPhonenumber", c.getUser().getUserPhonenumber());
maps.put("userDress", c.getUser().getUserDress());
maps.put("userType", c.getUser().getUserType());
/*费用类型*/
maps.put("costType", "水费-电费-燃气费-空调费-其他费用");
maps.put("costPower", c.getCostPower());
maps.put("costAir", c.getCostAir());
maps.put("costOther", c.getCostOther());
maps.put("costDate", new SimpleDateFormat("yyyy-MM-dd").format(c.getCostDate()));
maps.put("costStates", c.getCostState());
maps.put("costState", "是");
maps.put("costWtate", c.getCostWater());
maps.put("costGas", c.getCostGas());
a = Integer.parseInt(c.getCostAir()) + Integer.parseInt(c.getCostWater()) + Integer.parseInt(c.getCostGas()) + Integer.parseInt(c.getCostOther()) + Integer.parseInt(c.getCostPower());
maps.put("sumCost", a);
list.add(maps);
}
jsons = Tojsons.layuiJson(list.size(), list);
return jsons;
}
@Override
public int updateCostState(int id) {
Cost cost = new Cost();
cost.setCostId(id);
cost.setCostState(1);
return costMapper.updateByPrimaryKeySelective(cost);
}
}
|
UTF-8
|
Java
| 4,129
|
java
|
LCostServiceImpl.java
|
Java
|
[] | null |
[] |
package com.xiaochen.service.Impl;
import com.xiaochen.mapper.CostMapper;
import com.xiaochen.pojo.Cost;
import com.xiaochen.service.LCostService;
import com.xiaochen.util.Tojsons;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("LCostService")
public class LCostServiceImpl implements LCostService {
@Autowired
private CostMapper costMapper;
@Override
public JSONObject selectcostlist(Map map) {
List<Cost> selectcostlist = costMapper.selectcostlist(map);
JSONObject jsons;
Integer a = 0;
List list = new ArrayList();
for (Cost c : selectcostlist) {
Map<String, Object> maps = new HashMap<>();
maps.put("userId", c.getUser().getUserId());
maps.put("userName", c.getUser().getUserName());
maps.put("userPhonenumber", c.getUser().getUserPhonenumber());
maps.put("userDress", c.getUser().getUserDress());
maps.put("userSize", c.getUser().getUserSize());
maps.put("userType", c.getUser().getUserType());
maps.put("costId", c.getCostId());
/*费用类型*/
maps.put("costType", "水费-电费-燃气费-空调费-其他费用");
maps.put("costWtate", c.getCostWater());
maps.put("costGas", c.getCostGas());
maps.put("costPower", c.getCostPower());
maps.put("costAir", c.getCostAir());
maps.put("costOther", c.getCostOther());
maps.put("costDate", new SimpleDateFormat("yyyy-MM-dd").format(c.getCostDate()));
/* maps.put("costState", c.getCostState());*/
maps.put("costState", "否");
a = Integer.parseInt(c.getCostAir()) + Integer.parseInt(c.getCostWater()) + Integer.parseInt(c.getCostGas()) + Integer.parseInt(c.getCostOther()) + Integer.parseInt(c.getCostPower());
maps.put("sumCost", a);
list.add(maps);
}
jsons = Tojsons.layuiJson((int)map.get("rows"), list);
return jsons;
}
@Override
public JSONObject selectcostsuccess(int id) {
List<Cost> selectcostsuccess = costMapper.selectcostsuccess(id);
JSONObject jsons;
Integer a = 0;
List list = new ArrayList();
for (Cost c : selectcostsuccess) {
Map<String, Object> maps = new HashMap<>();
maps.put("userId", c.getUser().getUserId());
maps.put("costId", c.getCostId());
maps.put("userName", c.getUser().getUserName());
maps.put("userSize", c.getUser().getUserSize());
maps.put("userPhonenumber", c.getUser().getUserPhonenumber());
maps.put("userDress", c.getUser().getUserDress());
maps.put("userType", c.getUser().getUserType());
/*费用类型*/
maps.put("costType", "水费-电费-燃气费-空调费-其他费用");
maps.put("costPower", c.getCostPower());
maps.put("costAir", c.getCostAir());
maps.put("costOther", c.getCostOther());
maps.put("costDate", new SimpleDateFormat("yyyy-MM-dd").format(c.getCostDate()));
maps.put("costStates", c.getCostState());
maps.put("costState", "是");
maps.put("costWtate", c.getCostWater());
maps.put("costGas", c.getCostGas());
a = Integer.parseInt(c.getCostAir()) + Integer.parseInt(c.getCostWater()) + Integer.parseInt(c.getCostGas()) + Integer.parseInt(c.getCostOther()) + Integer.parseInt(c.getCostPower());
maps.put("sumCost", a);
list.add(maps);
}
jsons = Tojsons.layuiJson(list.size(), list);
return jsons;
}
@Override
public int updateCostState(int id) {
Cost cost = new Cost();
cost.setCostId(id);
cost.setCostState(1);
return costMapper.updateByPrimaryKeySelective(cost);
}
}
| 4,129
| 0.604984
| 0.604244
| 97
| 40.783504
| 31.112442
| 195
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.113402
| false
| false
|
13
|
85f9dbd1228c6430bc2c13b15105e35ce84a910e
| 28,707,561,451,728
|
c691edf5024c87e32581f4391c9b0a2d3ea1cf50
|
/mycollab-app-ondemand/src/main/java/com/getlocalization/SyncFiles.java
|
5b42197222b90162af996b3679aff3f8de3a94d1
|
[] |
no_license
|
haiphucnguyen/mycollab2
|
https://github.com/haiphucnguyen/mycollab2
|
5b33274eb37fe1e71c00b15abe825647d75f9d86
|
4709ec024101f61c7ffdfd40f2ab98b876ec0228
|
refs/heads/master
| 2022-09-11T12:27:43.067000
| 2019-09-20T01:21:07
| 2019-09-20T01:21:07
| 215,659,359
| 0
| 0
| null | false
| 2022-09-01T23:14:12
| 2019-10-16T23:01:08
| 2019-10-16T23:16:06
| 2022-09-01T23:14:09
| 812,983
| 0
| 0
| 4
|
Java
| false
| false
|
package com.getlocalization;
import com.getlocalization.api.GLProject;
import com.getlocalization.api.files.FileFormat;
import com.getlocalization.api.files.GLMasterFile;
import java.io.File;
/**
* @author MyCollab Ltd
* @since 5.3.3
*/
public class SyncFiles {
public static void main(String[] args) throws Exception {
GLProject project = new GLProject("mycollab", "haiphucnguyen@gmail.com", "=5EqGRN5Y=<%`tbX");
project.setLanguageId("en-US");
File parentFolder = new File("target/staging/i18n");
File[] files = parentFolder.listFiles();
for (File file : files) {
if (file.getName().endsWith("_en-US.properties")) {
GLMasterFile masterFile = new GLMasterFile(project, file.getAbsolutePath(), FileFormat
.javaproperties);
masterFile.push();
}
}
}
}
|
UTF-8
|
Java
| 894
|
java
|
SyncFiles.java
|
Java
|
[
{
"context": " GLProject project = new GLProject(\"mycollab\", \"haiphucnguyen@gmail.com\", \"=5EqGRN5Y=<%`tbX\");\n project.setLanguag",
"end": 408,
"score": 0.9999233484268188,
"start": 385,
"tag": "EMAIL",
"value": "haiphucnguyen@gmail.com"
}
] | null |
[] |
package com.getlocalization;
import com.getlocalization.api.GLProject;
import com.getlocalization.api.files.FileFormat;
import com.getlocalization.api.files.GLMasterFile;
import java.io.File;
/**
* @author MyCollab Ltd
* @since 5.3.3
*/
public class SyncFiles {
public static void main(String[] args) throws Exception {
GLProject project = new GLProject("mycollab", "<EMAIL>", "=5EqGRN5Y=<%`tbX");
project.setLanguageId("en-US");
File parentFolder = new File("target/staging/i18n");
File[] files = parentFolder.listFiles();
for (File file : files) {
if (file.getName().endsWith("_en-US.properties")) {
GLMasterFile masterFile = new GLMasterFile(project, file.getAbsolutePath(), FileFormat
.javaproperties);
masterFile.push();
}
}
}
}
| 878
| 0.634228
| 0.626398
| 29
| 29.827587
| 28.246536
| 102
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.517241
| false
| false
|
13
|
1ea7696930bbd10553e5dc6b7e41e7143d4d69b6
| 5,274,219,892,429
|
42d746cc03f6fb639cb5f4d3382893fa9a55c114
|
/login-common/src/main/java/com/huntkey/rx/sceo/common/utils/DynamicDataSourceUtil.java
|
ea4817dee3d130a4459aa203978248d2399b7244
|
[] |
no_license
|
hahaxiaowei/spring-boot-login
|
https://github.com/hahaxiaowei/spring-boot-login
|
91cd60896ab8a1b484af76f1449887168179a187
|
1949f2fbc44f5b2fe509e0cd3e547ea9231309be
|
refs/heads/master
| 2021-05-04T17:07:18.366000
| 2018-02-05T06:41:54
| 2018-02-05T06:41:54
| 120,265,177
| 4
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.huntkey.rx.sceo.common.utils;
import com.huntkey.rx.commons.utils.string.StringUtil;
import com.huntkey.rx.sceo.common.constant.Constant;
import com.huntkey.rx.sceo.orm.config.DynamicDataSourceContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 数据源切换辅助类
* <p>
* 统一管理
* Created by lulx on 2018/1/2 0002 下午 17:39
*/
public class DynamicDataSourceUtil {
private static Logger logger = LoggerFactory.getLogger(DynamicDataSourceUtil.class);
/**
* 设置默认数据源
*/
public static void setDefaultDataSource() {
try {
//DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("exec createEmployee, dbName : {}; dbList: {}", Constant.ECO_DATABASE_KEY, getDataSourceIds());
DynamicDataSourceContextHolder.setDataSourceType(Constant.ECO_DATABASE_KEY);
} catch (Exception e) {
logger.error("setDefaultDataSource exec error : " + e.getMessage(), e);
throw new RuntimeException("setDefaultDataSource exec error : " + e.getMessage(), e);
}
}
/**
* 根据传入的企业url设置数据源
*
* @param sceoUrl
*/
public static void setDataSource(String sceoUrl) {
if (StringUtil.isNullOrEmpty(sceoUrl)) {
logger.info("根据传入的企业url设置数据源: sceoUrl is null");
DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("set defult dataSource success");
return;
}
try {
logger.info("sceoUrl : {}", sceoUrl);
String dbName = StringUtils.getEnterpriseDbName(sceoUrl);
if(Constant.EDM_DATABASE_KEY.equals(dbName)){
DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("set defult dataSource success");
return;
}
logger.info("exec setDataSource, dbName : {}; dbList: {}", dbName, getDataSourceIds());
DynamicDataSourceContextHolder.setDataSourceType(dbName);
logger.info("set {} dataSource success", dbName);
} catch (Exception e) {
logger.error("setDataSource exec error : " + e.getMessage(), e);
throw new RuntimeException("setDataSource exec error : " + e.getMessage(), e);
}
}
public static List<String> getDataSourceIds(){
try {
List<String> dataSourceIds = DynamicDataSourceContextHolder.dataSourceIds;
return dataSourceIds;
} catch (Exception e) {
logger.error("getDataSourceIds exec error : " + e.getMessage(), e);
throw new RuntimeException("getDataSourceIds exec error : " + e.getMessage(), e);
}
}
}
|
UTF-8
|
Java
| 2,811
|
java
|
DynamicDataSourceUtil.java
|
Java
|
[
{
"context": "ist;\n\n/**\n * 数据源切换辅助类\n * <p>\n * 统一管理\n * Created by lulx on 2018/1/2 0002 下午 17:39\n */\npublic class Dynami",
"end": 352,
"score": 0.9996415972709656,
"start": 348,
"tag": "USERNAME",
"value": "lulx"
}
] | null |
[] |
package com.huntkey.rx.sceo.common.utils;
import com.huntkey.rx.commons.utils.string.StringUtil;
import com.huntkey.rx.sceo.common.constant.Constant;
import com.huntkey.rx.sceo.orm.config.DynamicDataSourceContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* 数据源切换辅助类
* <p>
* 统一管理
* Created by lulx on 2018/1/2 0002 下午 17:39
*/
public class DynamicDataSourceUtil {
private static Logger logger = LoggerFactory.getLogger(DynamicDataSourceUtil.class);
/**
* 设置默认数据源
*/
public static void setDefaultDataSource() {
try {
//DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("exec createEmployee, dbName : {}; dbList: {}", Constant.ECO_DATABASE_KEY, getDataSourceIds());
DynamicDataSourceContextHolder.setDataSourceType(Constant.ECO_DATABASE_KEY);
} catch (Exception e) {
logger.error("setDefaultDataSource exec error : " + e.getMessage(), e);
throw new RuntimeException("setDefaultDataSource exec error : " + e.getMessage(), e);
}
}
/**
* 根据传入的企业url设置数据源
*
* @param sceoUrl
*/
public static void setDataSource(String sceoUrl) {
if (StringUtil.isNullOrEmpty(sceoUrl)) {
logger.info("根据传入的企业url设置数据源: sceoUrl is null");
DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("set defult dataSource success");
return;
}
try {
logger.info("sceoUrl : {}", sceoUrl);
String dbName = StringUtils.getEnterpriseDbName(sceoUrl);
if(Constant.EDM_DATABASE_KEY.equals(dbName)){
DynamicDataSourceContextHolder.clearDataSourceType();
logger.info("set defult dataSource success");
return;
}
logger.info("exec setDataSource, dbName : {}; dbList: {}", dbName, getDataSourceIds());
DynamicDataSourceContextHolder.setDataSourceType(dbName);
logger.info("set {} dataSource success", dbName);
} catch (Exception e) {
logger.error("setDataSource exec error : " + e.getMessage(), e);
throw new RuntimeException("setDataSource exec error : " + e.getMessage(), e);
}
}
public static List<String> getDataSourceIds(){
try {
List<String> dataSourceIds = DynamicDataSourceContextHolder.dataSourceIds;
return dataSourceIds;
} catch (Exception e) {
logger.error("getDataSourceIds exec error : " + e.getMessage(), e);
throw new RuntimeException("getDataSourceIds exec error : " + e.getMessage(), e);
}
}
}
| 2,811
| 0.634057
| 0.628172
| 72
| 36.763889
| 31.687052
| 119
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.652778
| false
| false
|
13
|
fc8356a5ba7886244227ece281992f1aa5148285
| 3,075,196,621,761
|
dfc103b6eb695324f535972c3700fe1ff3997f6e
|
/spring-hibernate-jpa/src/main/java/com/example/springhibernatejpa/model/Student.java
|
81aa2ee46177993cb690b30602a8d102de8ea8d7
|
[] |
no_license
|
atharva-jahagirdar/lrproject
|
https://github.com/atharva-jahagirdar/lrproject
|
04b77e753050fa556a5ba507286d32bf3bd2639d
|
c1621af157c6f32d7998672327813c87d07d6ebc
|
refs/heads/master
| 2021-03-10T23:08:43.641000
| 2020-03-11T06:34:02
| 2020-03-11T06:34:02
| 246,493,584
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.springhibernatejpa.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="student")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String subject;
private Integer marks;
private String teacher_name;
public String getTeacher_name() {
return teacher_name;
}
public void setTeacher_name(String teacher_name) {
this.teacher_name = teacher_name;
}
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public Integer getMarks() {
return marks;
}
public void setMarks(Integer marks) {
this.marks = marks;
}
}
|
UTF-8
|
Java
| 1,112
|
java
|
Student.java
|
Java
|
[] | null |
[] |
package com.example.springhibernatejpa.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="student")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String subject;
private Integer marks;
private String teacher_name;
public String getTeacher_name() {
return teacher_name;
}
public void setTeacher_name(String teacher_name) {
this.teacher_name = teacher_name;
}
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public Integer getMarks() {
return marks;
}
public void setMarks(Integer marks) {
this.marks = marks;
}
}
| 1,112
| 0.726619
| 0.726619
| 56
| 18.857143
| 14.778639
| 51
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.375
| false
| false
|
13
|
6dbcd51dab145ad35bb2e4c95dc8fd0af8c210fe
| 25,555,055,461,001
|
c53d06b3e52ff9c5ad138ae8f89f43212427a990
|
/backend-bank/src/main/java/com/silalahi/valentinus/app/controller/CustomerController.java
|
f50dd62f306ccdd6d916ef533b7a06f141fcdbe6
|
[] |
no_license
|
valentinusilalahi/app-rest
|
https://github.com/valentinusilalahi/app-rest
|
6a19c191f12143eab1efd4882efe0655bda09c49
|
6fb82c815f733462d4d92235ec42ae2a2b7ad06b
|
refs/heads/master
| 2020-03-31T08:04:47.169000
| 2018-10-23T06:54:51
| 2018-10-23T06:54:51
| 152,044,808
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.silalahi.valentinus.app.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.silalahi.valentinus.app.dao.CustomerDao;
import com.silalahi.valentinus.app.entity.Customer;
import com.silalahi.valentinus.app.hateoas.CustomerResource;
@RestController
@RequestMapping("/api/customer")
public class CustomerController {
private static Logger LOGGER = LoggerFactory.getLogger(CustomerController.class);
@Value("${upload.folder}")
String uploadFolder;
@Autowired
private CustomerDao customerDao;
@CrossOrigin
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/")
public Page<Customer> findCustomer(Pageable page) {
return customerDao.findAll(page);
}
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/{customer}")
public Customer findCustomerById(@PathVariable Customer customer) {
return customer;
}
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/{customer}/resource")
public CustomerResource findCustomerResource(@PathVariable Customer customer) {
return new CustomerResource(customer);
}
@PreAuthorize("hashAuthority('EDIT_TRANSAKSI')")
@PostMapping("/")
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody @Valid Customer customer, HttpServletRequest request,
HttpServletResponse response) {
customerDao.save(customer);
String id = customer.getId();
String currentUrl = request.getRequestURL().append(id).toString();
response.setHeader("Location", currentUrl);
}
@PreAuthorize("hashAuthority('APPROVE_TRANSAKSI')")
@DeleteMapping("/{customer}")
public void delete(@PathVariable Customer customer) {
File photo = filePhoto(customer.getPhoto());
photo.delete();
customerDao.delete(customer);
}
private File filePhoto(String fileName) {
// TODO Auto-generated method stub
return new File(uploadFolder + File.separator + fileName);
}
@PutMapping("/{customer}")
public void update(@PathVariable("customer") Customer old, @RequestBody @Valid Customer newData) {
newData.setId(old.getId());
customerDao.save(newData);
}
@PutMapping("/{customer}/photo")
public void setPhoto(@PathVariable Customer customer, MultipartFile photo) throws IOException {
String destFileName = customer.getId() + ".jpg";
new File(uploadFolder).mkdirs();
File destFile = filePhoto(destFileName);
photo.transferTo(destFile);
customer.setPhoto(destFileName);
customerDao.save(customer);
}
public ResponseEntity<Resource> downloadPhoto(@PathVariable Customer customer) {
try {
File photo = filePhoto(customer.getPhoto());
InputStreamResource resource;
resource = new InputStreamResource(new FileInputStream(photo));
return ResponseEntity.ok().contentLength(photo.length()).contentType(MediaType.IMAGE_JPEG).body(resource);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return ResponseEntity.notFound().build();
}
}
}
|
UTF-8
|
Java
| 4,369
|
java
|
CustomerController.java
|
Java
|
[] | null |
[] |
package com.silalahi.valentinus.app.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.silalahi.valentinus.app.dao.CustomerDao;
import com.silalahi.valentinus.app.entity.Customer;
import com.silalahi.valentinus.app.hateoas.CustomerResource;
@RestController
@RequestMapping("/api/customer")
public class CustomerController {
private static Logger LOGGER = LoggerFactory.getLogger(CustomerController.class);
@Value("${upload.folder}")
String uploadFolder;
@Autowired
private CustomerDao customerDao;
@CrossOrigin
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/")
public Page<Customer> findCustomer(Pageable page) {
return customerDao.findAll(page);
}
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/{customer}")
public Customer findCustomerById(@PathVariable Customer customer) {
return customer;
}
@PreAuthorize("hasAuthority('VIEW_TRANSAKSI')")
@GetMapping("/{customer}/resource")
public CustomerResource findCustomerResource(@PathVariable Customer customer) {
return new CustomerResource(customer);
}
@PreAuthorize("hashAuthority('EDIT_TRANSAKSI')")
@PostMapping("/")
@ResponseStatus(HttpStatus.CREATED)
public void create(@RequestBody @Valid Customer customer, HttpServletRequest request,
HttpServletResponse response) {
customerDao.save(customer);
String id = customer.getId();
String currentUrl = request.getRequestURL().append(id).toString();
response.setHeader("Location", currentUrl);
}
@PreAuthorize("hashAuthority('APPROVE_TRANSAKSI')")
@DeleteMapping("/{customer}")
public void delete(@PathVariable Customer customer) {
File photo = filePhoto(customer.getPhoto());
photo.delete();
customerDao.delete(customer);
}
private File filePhoto(String fileName) {
// TODO Auto-generated method stub
return new File(uploadFolder + File.separator + fileName);
}
@PutMapping("/{customer}")
public void update(@PathVariable("customer") Customer old, @RequestBody @Valid Customer newData) {
newData.setId(old.getId());
customerDao.save(newData);
}
@PutMapping("/{customer}/photo")
public void setPhoto(@PathVariable Customer customer, MultipartFile photo) throws IOException {
String destFileName = customer.getId() + ".jpg";
new File(uploadFolder).mkdirs();
File destFile = filePhoto(destFileName);
photo.transferTo(destFile);
customer.setPhoto(destFileName);
customerDao.save(customer);
}
public ResponseEntity<Resource> downloadPhoto(@PathVariable Customer customer) {
try {
File photo = filePhoto(customer.getPhoto());
InputStreamResource resource;
resource = new InputStreamResource(new FileInputStream(photo));
return ResponseEntity.ok().contentLength(photo.length()).contentType(MediaType.IMAGE_JPEG).body(resource);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return ResponseEntity.notFound().build();
}
}
}
| 4,369
| 0.794461
| 0.794003
| 124
| 34.233871
| 25.149908
| 109
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.403226
| false
| false
|
13
|
77dd8eaecfb7b5bd79be6c1138cdfd0c59f6e1e2
| 25,555,055,461,199
|
68f4c7614ac236a9d75f07ce48f8a9d5fb5a7e71
|
/misc/BitMAPSearchOSM/src/Node.java
|
14d6d755909b869f7bd200b939dc0bb0fc3d98f0
|
[
"MIT"
] |
permissive
|
julien-ur/BA_PerfectPlace
|
https://github.com/julien-ur/BA_PerfectPlace
|
d68eea520916da6c68aa1cdb055a8b5efc1d2a94
|
98f07cb4754022da48802946de97d08222722f3f
|
refs/heads/master
| 2021-05-24T04:46:06.554000
| 2017-08-28T15:13:20
| 2017-08-28T15:13:20
| 45,869,650
| 0
| 1
| null | false
| 2015-11-14T17:06:46
| 2015-11-09T22:00:22
| 2015-11-09T22:14:57
| 2015-11-14T17:06:46
| 0
| 0
| 1
| 2
|
JavaScript
| null | null |
import java.util.ArrayList;
/**
* Each defined Element in OpenStreetMap contains Nodes. Either there are Nodes
* with describing tags, or ways with several nodes and tags. Nodes have some
* information. Only those, which are important for the program, are saved in
* this Node-Class. The id is needed for the WayNodes, which use the ids as
* reference. The latitude and the longitude are the essential variables, as
* they are used to visualize the Nodes in the map-image(after the are converted
* to pixel).
*
* @author Judith Höreth
*
*/
public class Node {
String id;
boolean visible;
float lat, lon;
private ArrayList<Tag> allTags;
public Node() {
}
public Node(String id, boolean visible, float lat, float lon,
ArrayList<Tag> allTags) {
this.id = id;
this.visible = visible;
this.lat = lat;
this.lon = lon;
this.allTags = allTags;
allTags = new ArrayList<Tag>();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLon() {
return lon;
}
public void setLon(float lon) {
this.lon = lon;
}
public void setTags(ArrayList<Tag> allTags) {
this.allTags = allTags;
}
public ArrayList<Tag> getAllTags() {
return allTags;
}
}
|
ISO-8859-1
|
Java
| 1,543
|
java
|
Node.java
|
Java
|
[
{
"context": " the are converted\r\n * to pixel).\r\n * \r\n * @author Judith Höreth\r\n * \r\n */\r\npublic class Node {\r\n\tString id;\r\n\tboo",
"end": 556,
"score": 0.9998689293861389,
"start": 543,
"tag": "NAME",
"value": "Judith Höreth"
}
] | null |
[] |
import java.util.ArrayList;
/**
* Each defined Element in OpenStreetMap contains Nodes. Either there are Nodes
* with describing tags, or ways with several nodes and tags. Nodes have some
* information. Only those, which are important for the program, are saved in
* this Node-Class. The id is needed for the WayNodes, which use the ids as
* reference. The latitude and the longitude are the essential variables, as
* they are used to visualize the Nodes in the map-image(after the are converted
* to pixel).
*
* @author <NAME>
*
*/
public class Node {
String id;
boolean visible;
float lat, lon;
private ArrayList<Tag> allTags;
public Node() {
}
public Node(String id, boolean visible, float lat, float lon,
ArrayList<Tag> allTags) {
this.id = id;
this.visible = visible;
this.lat = lat;
this.lon = lon;
this.allTags = allTags;
allTags = new ArrayList<Tag>();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public float getLat() {
return lat;
}
public void setLat(float lat) {
this.lat = lat;
}
public float getLon() {
return lon;
}
public void setLon(float lon) {
this.lon = lon;
}
public void setTags(ArrayList<Tag> allTags) {
this.allTags = allTags;
}
public ArrayList<Tag> getAllTags() {
return allTags;
}
}
| 1,535
| 0.653696
| 0.653696
| 76
| 18.289474
| 21.780493
| 80
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.236842
| false
| false
|
13
|
4738ed7da66441945911cde22f3848c76e0e9d14
| 15,659,450,765,819
|
f8d95802f811315bb24a47983fad0c277af1ad97
|
/src/main/java/com/retailStore/user/dto/package-info.java
|
799b385c1f29be13014e3e909ced199b79ef470f
|
[] |
no_license
|
satyavrat49/retailStore
|
https://github.com/satyavrat49/retailStore
|
f3891f48ed1b72991422298bab3779e7b5f7c12f
|
2b73535ab698f10f64ef5fbbfeda42f3e32933e4
|
refs/heads/master
| 2020-11-25T12:22:43.152000
| 2019-12-17T16:47:03
| 2019-12-17T16:47:03
| 228,657,696
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.retailStore.user.dto;
|
UTF-8
|
Java
| 33
|
java
|
package-info.java
|
Java
|
[] | null |
[] |
package com.retailStore.user.dto;
| 33
| 0.848485
| 0.848485
| 1
| 33
| 0
| 33
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| false
| false
|
13
|
2e9b97a796d59ec35873e92cd1918b74b63a6bba
| 10,127,532,888,376
|
f7972241ebffa5bbc5c7bbfcb879a52cbd2c89e1
|
/acol-scada-manage/src/main/java/cn/acol/scada/domain/Record.java
|
bb7126a43286b4d0372e5134acadcd6ca2421e86
|
[] |
no_license
|
acolscada/javaRepository
|
https://github.com/acolscada/javaRepository
|
62e1d41c99b174cfe1d116d87b55fc7faaf6d7b0
|
012d47538e632a53c14defe9702d420f2b6fcf69
|
refs/heads/master
| 2020-04-27T15:33:42.064000
| 2019-03-08T02:41:08
| 2019-03-08T02:41:08
| 174,450,759
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.acol.scada.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import cn.acol.scada.core.domain.BaseDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 采集器系统从生产到销毁的记录信息
* @author DaveZhang
*
*/
@Entity
@Data
@EqualsAndHashCode(callSuper=false)
public class Record extends BaseDomain{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String people;//处理人
private String handle;//处理方式
private String reason;//原因
private float press;//压力值
private float temp;//温度值
private double sfmSum;//小芯版显示总量
private double fmSum;//大芯板标总
@Column(name="sEnergy")
private int signal;//信号强度
private int scaMinColNum;//采集数
private int scaMinUpNum;//上传数
private String event;
}
|
UTF-8
|
Java
| 1,010
|
java
|
Record.java
|
Java
|
[
{
"context": "dHashCode;\r\n\r\n/**\r\n * 采集器系统从生产到销毁的记录信息\r\n * @author DaveZhang\r\n *\r\n */\r\n@Entity\r\n@Data\r\n@EqualsAndHashCode(call",
"end": 366,
"score": 0.9993173480033875,
"start": 357,
"tag": "NAME",
"value": "DaveZhang"
}
] | null |
[] |
package cn.acol.scada.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import cn.acol.scada.core.domain.BaseDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 采集器系统从生产到销毁的记录信息
* @author DaveZhang
*
*/
@Entity
@Data
@EqualsAndHashCode(callSuper=false)
public class Record extends BaseDomain{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String people;//处理人
private String handle;//处理方式
private String reason;//原因
private float press;//压力值
private float temp;//温度值
private double sfmSum;//小芯版显示总量
private double fmSum;//大芯板标总
@Column(name="sEnergy")
private int signal;//信号强度
private int scaMinColNum;//采集数
private int scaMinUpNum;//上传数
private String event;
}
| 1,010
| 0.753319
| 0.753319
| 37
| 22.432432
| 13.853559
| 50
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.972973
| false
| false
|
13
|
ff8293997d578e41b6ce0fd9686956ed477d45e4
| 14,173,392,147,744
|
3e32df055027c751de161a9d978ad4823f46a38c
|
/character-generator/src/main/java/nz/co/fitnet/characterGenerator/data/equipment/weapons/Glaive.java
|
e4c6652d7a936fa2c388d10736302be5ebe855a1
|
[] |
no_license
|
williamanzac/dnd-tools
|
https://github.com/williamanzac/dnd-tools
|
11d28c7130c6cfcc3f8050085f0d7da663c192d3
|
aeb6530920a5c7aba095f1944a49a2d98bc5f9c1
|
refs/heads/master
| 2023-08-16T05:42:49.673000
| 2023-03-30T19:28:10
| 2023-03-30T19:28:10
| 123,676,485
| 0
| 0
| null | false
| 2023-08-15T14:59:43
| 2018-03-03T09:09:13
| 2021-11-19T03:47:57
| 2023-08-15T14:59:43
| 326
| 0
| 0
| 5
|
Java
| false
| false
|
package nz.co.fitnet.characterGenerator.data.equipment.weapons;
import static nz.co.fitnet.characterGenerator.api.DamageType.Slashing;
import static nz.co.fitnet.characterGenerator.api.equipment.AttackType.Melee;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.Heavy;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.Reach;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.TwoHanded;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponType.Martial;
import nz.co.fitnet.characterGenerator.api.equipment.Weapon;
public class Glaive extends Weapon {
public Glaive() {
super(6, Martial, Melee, Slashing, "1d10", null, 20, Heavy, Reach, TwoHanded);
}
}
|
UTF-8
|
Java
| 765
|
java
|
Glaive.java
|
Java
|
[] | null |
[] |
package nz.co.fitnet.characterGenerator.data.equipment.weapons;
import static nz.co.fitnet.characterGenerator.api.DamageType.Slashing;
import static nz.co.fitnet.characterGenerator.api.equipment.AttackType.Melee;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.Heavy;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.Reach;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponProperty.TwoHanded;
import static nz.co.fitnet.characterGenerator.api.equipment.WeaponType.Martial;
import nz.co.fitnet.characterGenerator.api.equipment.Weapon;
public class Glaive extends Weapon {
public Glaive() {
super(6, Martial, Melee, Slashing, "1d10", null, 20, Heavy, Reach, TwoHanded);
}
}
| 765
| 0.807843
| 0.8
| 16
| 45.8125
| 34.848274
| 85
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.375
| false
| false
|
13
|
09a355d961ac2401c8b4892fb4e1df23a150c54f
| 18,391,050,004,834
|
dd06f55461e7dc13f844416846c65b7eb4fe82c9
|
/src/Constants.java
|
5655fd50f8647f8808233eb4dad918379aefc4b2
|
[] |
no_license
|
sambathdev/openssl
|
https://github.com/sambathdev/openssl
|
d7693c4f98130ae6b50c2cf6977888045f3c464d
|
5a12ea8635cc93bcb23753fc065fac444debbcf8
|
refs/heads/main
| 2023-03-02T13:25:03.342000
| 2021-02-09T05:42:21
| 2021-02-09T05:42:21
| 337,304,256
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Constants {
public static final String PROTOCOL_VERSION = "STFMP/1.0";
}
|
UTF-8
|
Java
| 92
|
java
|
Constants.java
|
Java
|
[] | null |
[] |
public class Constants {
public static final String PROTOCOL_VERSION = "STFMP/1.0";
}
| 92
| 0.706522
| 0.684783
| 3
| 28
| 23.846733
| 59
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.666667
| false
| false
|
13
|
8c452f022c4da999c9775e8b621f01b72c75df39
| 25,812,753,466,403
|
23fc1f91ede9ec78c534dbab1c335a96a8bd04ee
|
/examenFisico/src/main/java/com/example/demo/Controlador/ControladorGeneral.java
|
09b08a63d3c0c0ecb608b5d4d14a6da989b0b571
|
[] |
no_license
|
Cristian602/examenfisico
|
https://github.com/Cristian602/examenfisico
|
c52b5916afbc6b95195a42b7db84747a22409a7a
|
556373b1ed2f36b1d022eb500900461135c2a74d
|
refs/heads/master
| 2022-11-15T10:10:00.131000
| 2020-07-13T02:27:13
| 2020-07-13T02:27:13
| 278,927,137
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.demo.Controlador;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.Modelo.Corporal;
import com.example.demo.Modelo.Examen;
import com.example.demo.Modelo.MedidasAntropometricas;
import com.example.demo.Modelo.Neurologico;
import com.example.demo.Modelo.PielCabeza;
import com.example.demo.Modelo.SignosVitales;
@Controller
public class ControladorGeneral {
@Autowired
ExamenControlador examenControlador;
@Autowired
SignosVitalesControlador signosVitalesControlador;
@Autowired
CorporalControlador corporalControlador;
@Autowired
InsumosControlador insumosControlador;
@Autowired
MedidasAntropometricasControlador medidasAntropometricasControlador;
@Autowired
NeurologicoControlador neurologicoControlador;
@Autowired
PielCabezaControlador pielCabezaControlador;
@Autowired
ProveedorControlador proveedorControlador;
@Autowired
RegistroInsumosControlador registroInsumosControlador;
// Reconocimiento de la imagen (escudo de la universidad).
@GetMapping("/ucuenca")
public String logoU() {
return "ucuenca";
}
// Metodo para acceder al elemento "acerca de"
@GetMapping("/acerca")
public String acercaDe() {
return "acerca";
}
@GetMapping("/proveedores")
public String uiProveedores() {
return "proovedor";
}
@GetMapping("/insumos")
public String uiRegistrarInsumo() {
return "insumos";
}
@GetMapping("/peticionInsumo")
public String uiConsumo() {
return "consumo";
}
// Metodos para la pagina principal (registro de un examen toma de datos)
@GetMapping({ "/", "/index" })
public String index(Model modelo) {
modelo.addAttribute("examForm", new Examen());
modelo.addAttribute("examList", examenControlador.getAll());
return "index";
}
@PostMapping({ "/", "/index" })
public String createExam(@ModelAttribute("examForm") Examen examen, BindingResult result, ModelMap modelo) {
if (result.hasErrors()) {
modelo.addAttribute("examForm", examen);
} else {
try {
examenControlador.guardar(examen);
} catch (Exception e) {
modelo.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/signosVitales/" + examen.getId();
}
// Metodo para generar vista de signos vitales y subir un nuevo examen
@GetMapping("/signosVitales/{id}")
public String cargarDatosExamGeneral(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examVit", new SignosVitales());
modelo.addAttribute("examForm", examen);
return "signosVitales";
}
@PostMapping("/signosVitales/{id}")
public String createVitales(@ModelAttribute("examVit") SignosVitales signosVitales, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examVit", signosVitales);
} else {
try {
signosVitalesControlador.guardar(signosVitales);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/medidas/" + examen.getId();
}
// Metodo para generar vista de examen MedidasAntropometricas y subir un nuevo examen
@GetMapping("/medidas/{id}")
public String cEAntropometricas(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new MedidasAntropometricas());
modelo.addAttribute("examForm", examen);
return "antropometricas";
}
@PostMapping("/medidas/{id}")
public String createMedidas(@ModelAttribute("examSub") MedidasAntropometricas exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
medidasAntropometricasControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/corporal/" + examen.getId();
}
// Metodo para generar vista de examen corporal y subir un nuevo examen
@GetMapping("/corporal/{id}")
public String cECoropral(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new Corporal());
modelo.addAttribute("examForm", examen);
return "corporal";
}
@PostMapping("/corporal/{id}")
public String createCorporal(@ModelAttribute("examSub") Corporal exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
corporalControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/neurologico/" + examen.getId();
}
// Metodo para generar vista de examen neurologico y subir un nuevo examen
@GetMapping("/neurologico/{id}")
public String cENeurologico(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new Neurologico());
modelo.addAttribute("examForm", examen);
return "neurologico";
}
@PostMapping("/neurologico/{id}")
public String createNeurologico(@ModelAttribute("examSub") Neurologico exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
neurologicoControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/piel/" + examen.getId();
}
// Metodo para generar vista de examen PielCabeza y subir un nuevo examen
@GetMapping("/piel/{id}")
public String cEPielCabeza(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new PielCabeza());
modelo.addAttribute("examForm", examen);
return "piel";
}
@PostMapping("/piel/{id}")
public String createPielCabeza(@ModelAttribute("examSub") PielCabeza exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
pielCabezaControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/index";
}
}
|
UTF-8
|
Java
| 7,792
|
java
|
ControladorGeneral.java
|
Java
|
[] | null |
[] |
package com.example.demo.Controlador;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.Modelo.Corporal;
import com.example.demo.Modelo.Examen;
import com.example.demo.Modelo.MedidasAntropometricas;
import com.example.demo.Modelo.Neurologico;
import com.example.demo.Modelo.PielCabeza;
import com.example.demo.Modelo.SignosVitales;
@Controller
public class ControladorGeneral {
@Autowired
ExamenControlador examenControlador;
@Autowired
SignosVitalesControlador signosVitalesControlador;
@Autowired
CorporalControlador corporalControlador;
@Autowired
InsumosControlador insumosControlador;
@Autowired
MedidasAntropometricasControlador medidasAntropometricasControlador;
@Autowired
NeurologicoControlador neurologicoControlador;
@Autowired
PielCabezaControlador pielCabezaControlador;
@Autowired
ProveedorControlador proveedorControlador;
@Autowired
RegistroInsumosControlador registroInsumosControlador;
// Reconocimiento de la imagen (escudo de la universidad).
@GetMapping("/ucuenca")
public String logoU() {
return "ucuenca";
}
// Metodo para acceder al elemento "acerca de"
@GetMapping("/acerca")
public String acercaDe() {
return "acerca";
}
@GetMapping("/proveedores")
public String uiProveedores() {
return "proovedor";
}
@GetMapping("/insumos")
public String uiRegistrarInsumo() {
return "insumos";
}
@GetMapping("/peticionInsumo")
public String uiConsumo() {
return "consumo";
}
// Metodos para la pagina principal (registro de un examen toma de datos)
@GetMapping({ "/", "/index" })
public String index(Model modelo) {
modelo.addAttribute("examForm", new Examen());
modelo.addAttribute("examList", examenControlador.getAll());
return "index";
}
@PostMapping({ "/", "/index" })
public String createExam(@ModelAttribute("examForm") Examen examen, BindingResult result, ModelMap modelo) {
if (result.hasErrors()) {
modelo.addAttribute("examForm", examen);
} else {
try {
examenControlador.guardar(examen);
} catch (Exception e) {
modelo.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/signosVitales/" + examen.getId();
}
// Metodo para generar vista de signos vitales y subir un nuevo examen
@GetMapping("/signosVitales/{id}")
public String cargarDatosExamGeneral(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examVit", new SignosVitales());
modelo.addAttribute("examForm", examen);
return "signosVitales";
}
@PostMapping("/signosVitales/{id}")
public String createVitales(@ModelAttribute("examVit") SignosVitales signosVitales, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examVit", signosVitales);
} else {
try {
signosVitalesControlador.guardar(signosVitales);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/medidas/" + examen.getId();
}
// Metodo para generar vista de examen MedidasAntropometricas y subir un nuevo examen
@GetMapping("/medidas/{id}")
public String cEAntropometricas(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new MedidasAntropometricas());
modelo.addAttribute("examForm", examen);
return "antropometricas";
}
@PostMapping("/medidas/{id}")
public String createMedidas(@ModelAttribute("examSub") MedidasAntropometricas exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
medidasAntropometricasControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/corporal/" + examen.getId();
}
// Metodo para generar vista de examen corporal y subir un nuevo examen
@GetMapping("/corporal/{id}")
public String cECoropral(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new Corporal());
modelo.addAttribute("examForm", examen);
return "corporal";
}
@PostMapping("/corporal/{id}")
public String createCorporal(@ModelAttribute("examSub") Corporal exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
corporalControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/neurologico/" + examen.getId();
}
// Metodo para generar vista de examen neurologico y subir un nuevo examen
@GetMapping("/neurologico/{id}")
public String cENeurologico(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new Neurologico());
modelo.addAttribute("examForm", examen);
return "neurologico";
}
@PostMapping("/neurologico/{id}")
public String createNeurologico(@ModelAttribute("examSub") Neurologico exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
neurologicoControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/piel/" + examen.getId();
}
// Metodo para generar vista de examen PielCabeza y subir un nuevo examen
@GetMapping("/piel/{id}")
public String cEPielCabeza(Model modelo, @PathVariable(name = "id") Integer id) throws Exception {
Examen examen = examenControlador.getById(id);
modelo.addAttribute("examSub", new PielCabeza());
modelo.addAttribute("examForm", examen);
return "piel";
}
@PostMapping("/piel/{id}")
public String createPielCabeza(@ModelAttribute("examSub") PielCabeza exaEspecific, BindingResult result,
ModelMap modelput, @PathVariable(name = "id") Integer id, Model modelget) {
Examen examen = examenControlador.getById(id);
modelget.addAttribute("examForm", examen);
modelput.addAttribute("examForm", examen);
if (result.hasErrors()) {
modelput.addAttribute("examSub", exaEspecific);
} else {
try {
pielCabezaControlador.guardar(exaEspecific);
} catch (Exception e) {
modelput.addAttribute("erroMessage", e.getMessage());
}
}
return "redirect:/index";
}
}
| 7,792
| 0.746022
| 0.746022
| 224
| 33.79018
| 27.193514
| 114
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.254464
| false
| false
|
13
|
2c1a76936f2b4052ccf629954ba1242c1b55bf1d
| 7,301,444,407,101
|
3afbc5f7ba9180ed4e3421b4a3a36d264aa223c3
|
/avatar-modules-api/grampus-client-api/src/main/java/cn/com/tiza/api/GrampusApiService.java
|
8a361c3620b1edab90bb92f743b2880442317269
|
[] |
no_license
|
bellmit/demo-7
|
https://github.com/bellmit/demo-7
|
e93ab9b5f785dff864cec97259b34e804b72b746
|
c90c48b68137603d2b911be670710cab7c863647
|
refs/heads/master
| 2022-12-29T03:22:56.395000
| 2020-06-09T15:24:43
| 2020-06-09T15:48:10
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package cn.com.tiza.api;
/**
* 查询Api Key
* @author tiza
*/
public interface GrampusApiService {
/**
* 根据终端类型查询api key
* @param terminalType
* @return
*/
String getApiKey(String terminalType);
}
|
UTF-8
|
Java
| 248
|
java
|
GrampusApiService.java
|
Java
|
[
{
"context": "kage cn.com.tiza.api;\n\n/**\n * 查询Api Key\n * @author tiza\n */\npublic interface GrampusApiService {\n\n /**",
"end": 58,
"score": 0.9994816780090332,
"start": 54,
"tag": "USERNAME",
"value": "tiza"
}
] | null |
[] |
package cn.com.tiza.api;
/**
* 查询Api Key
* @author tiza
*/
public interface GrampusApiService {
/**
* 根据终端类型查询api key
* @param terminalType
* @return
*/
String getApiKey(String terminalType);
}
| 248
| 0.609649
| 0.609649
| 16
| 13.25
| 12.915591
| 42
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.125
| false
| false
|
13
|
05c070f9191a1d93ff09c213d1a1dccc7e916488
| 10,385,230,944,894
|
ea1d91d656ecdf1eb0fa1f0a5ea48760aca5d836
|
/creational/fabric_factory/app/src/main/java/com/example/fabric_factory/cars/BMW.java
|
118fe3e1f5f4186ae97e13ea5c0221e80f31cad9
|
[] |
no_license
|
afluttershy/laba3_patterns
|
https://github.com/afluttershy/laba3_patterns
|
44b673299eae4341d3c1f62a4be48089fbc2a5db
|
5c2c2fe33603114a00123d863a28fe899ab03acd
|
refs/heads/master
| 2020-12-11T21:08:17.145000
| 2020-01-15T00:04:52
| 2020-01-15T00:04:52
| 233,470,721
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.example.fabric_factory.cars;
public class BMW implements Car{
public void goBack() {
System.out.println("BMW едет назад");
}
public void goForward() {
System.out.println("BMW едет вперед");
}
}
|
UTF-8
|
Java
| 259
|
java
|
BMW.java
|
Java
|
[] | null |
[] |
package com.example.fabric_factory.cars;
public class BMW implements Car{
public void goBack() {
System.out.println("BMW едет назад");
}
public void goForward() {
System.out.println("BMW едет вперед");
}
}
| 259
| 0.6375
| 0.6375
| 11
| 20.818182
| 18.004131
| 46
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.272727
| false
| false
|
13
|
eb279a0d0d5a86035af613d62d2d4d689cbee18c
| 18,313,740,560,836
|
66796bec456f6b96e29cff3909ec62c4d19ead90
|
/app/src/main/java/com/prashant/mywikipediaapp/Model/RandomArticles.java
|
02af8771a0907c8f415d17390a9e15b9de4a047a
|
[] |
no_license
|
pintu0012/MyWikiPediaApp
|
https://github.com/pintu0012/MyWikiPediaApp
|
148a9060afb2a255468d6b0e869669a5ebe6f71a
|
525472fdd174e01cc7a8585c37d7a80739132232
|
refs/heads/master
| 2023-01-29T21:53:15.376000
| 2020-12-10T10:19:18
| 2020-12-10T10:19:18
| 318,862,069
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.prashant.mywikipediaapp.Model;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
public class RandomArticles {
private String pageId;
private String title;
private String type;
private String extract;
private List<ImageInfo> imageInfoList;
private ArrayList<AllCategories> categoryModelArrayList;
private String category;
private String imageUrl;
private boolean isSaved;
private byte[] imageByte;
public RandomArticles(String pageId, String title, String type, String imageUrl, String category, String extract, boolean isSaved) {
this.pageId = pageId;
this.title = title;
this.type = type;
this.imageUrl = imageUrl;
this.category = category;
this.extract = extract;
this.isSaved = isSaved;
}
public byte[] getImageByte() {
return imageByte;
}
public void setImageByte(byte[] imageByte) {
this.imageByte = imageByte;
}
public boolean isSaved() {
return isSaved;
}
public void setSaved(boolean saved) {
isSaved = saved;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public ArrayList<AllCategories> getCategoryModelArrayList() {
return categoryModelArrayList;
}
public void setCategoryModelArrayList(ArrayList<AllCategories> categoryModelArrayList) {
this.categoryModelArrayList = categoryModelArrayList;
}
public List<ImageInfo> getImageInfoList() {
return imageInfoList;
}
public void setImageInfoList(List<ImageInfo> imageInfoList) {
this.imageInfoList = imageInfoList;
}
public String getExtract() {
return extract;
}
public void setExtract(String extract) {
this.extract = extract;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public RandomArticles() {
}
public String getPageId() {
return pageId;
}
public void setPageId(String pageId) {
this.pageId = pageId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
|
UTF-8
|
Java
| 2,527
|
java
|
RandomArticles.java
|
Java
|
[] | null |
[] |
package com.prashant.mywikipediaapp.Model;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;
public class RandomArticles {
private String pageId;
private String title;
private String type;
private String extract;
private List<ImageInfo> imageInfoList;
private ArrayList<AllCategories> categoryModelArrayList;
private String category;
private String imageUrl;
private boolean isSaved;
private byte[] imageByte;
public RandomArticles(String pageId, String title, String type, String imageUrl, String category, String extract, boolean isSaved) {
this.pageId = pageId;
this.title = title;
this.type = type;
this.imageUrl = imageUrl;
this.category = category;
this.extract = extract;
this.isSaved = isSaved;
}
public byte[] getImageByte() {
return imageByte;
}
public void setImageByte(byte[] imageByte) {
this.imageByte = imageByte;
}
public boolean isSaved() {
return isSaved;
}
public void setSaved(boolean saved) {
isSaved = saved;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public ArrayList<AllCategories> getCategoryModelArrayList() {
return categoryModelArrayList;
}
public void setCategoryModelArrayList(ArrayList<AllCategories> categoryModelArrayList) {
this.categoryModelArrayList = categoryModelArrayList;
}
public List<ImageInfo> getImageInfoList() {
return imageInfoList;
}
public void setImageInfoList(List<ImageInfo> imageInfoList) {
this.imageInfoList = imageInfoList;
}
public String getExtract() {
return extract;
}
public void setExtract(String extract) {
this.extract = extract;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public RandomArticles() {
}
public String getPageId() {
return pageId;
}
public void setPageId(String pageId) {
this.pageId = pageId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
| 2,527
| 0.643451
| 0.643451
| 114
| 21.166666
| 21.461477
| 136
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.412281
| false
| false
|
13
|
900652f5f0e96d5c67a696aa83b6fb3ab4c18f2a
| 2,628,519,997,869
|
2cff662eca2b4561daa1205bc9689cfec7ba1b0c
|
/workspace/parent-project/econtacts/src/main/java/org/thymeleaf/econtacts/web/controller/LoginController.java
|
10f0a425f84c0ba457b792db525cd3ee167f69d7
|
[] |
no_license
|
elhamasiaei13/old-project
|
https://github.com/elhamasiaei13/old-project
|
4044352f333765f6612630944153700dcd3dcf64
|
75bdca9f1ccdfe849569a60afbff83434ae751d8
|
refs/heads/master
| 2022-12-24T17:12:46.673000
| 2020-01-21T05:52:07
| 2020-01-21T05:52:07
| 235,265,560
| 0
| 0
| null | false
| 2022-12-16T00:44:44
| 2020-01-21T05:48:05
| 2022-12-09T23:20:51
| 2022-12-16T00:44:41
| 205,282
| 1
| 0
| 35
|
JavaScript
| false
| false
|
package org.thymeleaf.econtacts.web.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.econtacts.web.domain.User;
import org.thymeleaf.econtacts.web.service.UserService;
import javax.servlet.http.HttpSession;
@Controller
public class LoginController {
@Autowired
UserService userService;
@RequestMapping({ "/", "/login" })
public String showLoginPage() {
return "login";
}
@RequestMapping(value = "/home", method = RequestMethod.POST)
public String showUserHomePage(@ModelAttribute User user, Model model,
HttpSession session) {
System.out.println("UserName" + user.getName() + "Password:"
+ user.getPassword());
model.addAttribute("templateName", "/table");
session.setAttribute("userId", user);
userService.save(user);
return "home";
}
}
|
UTF-8
|
Java
| 1,132
|
java
|
LoginController.java
|
Java
|
[] | null |
[] |
package org.thymeleaf.econtacts.web.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.econtacts.web.domain.User;
import org.thymeleaf.econtacts.web.service.UserService;
import javax.servlet.http.HttpSession;
@Controller
public class LoginController {
@Autowired
UserService userService;
@RequestMapping({ "/", "/login" })
public String showLoginPage() {
return "login";
}
@RequestMapping(value = "/home", method = RequestMethod.POST)
public String showUserHomePage(@ModelAttribute User user, Model model,
HttpSession session) {
System.out.println("UserName" + user.getName() + "Password:"
+ user.getPassword());
model.addAttribute("templateName", "/table");
session.setAttribute("userId", user);
userService.save(user);
return "home";
}
}
| 1,132
| 0.75265
| 0.75265
| 37
| 28.594595
| 23.560686
| 71
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.351351
| false
| false
|
13
|
9042bf12e9368ff79580d12ed5c29984cdfd48a4
| 4,398,046,538,526
|
c2f42717ff31ce9a34e0f0d58dd381b866dc8af9
|
/hrms/src/main/java/backend/hrms/adapters/mernis/MernisVerificationService.java
|
967fbbc695e7ece9c48a645dad04e78200eecfe6
|
[] |
no_license
|
aslanemirhan/HRMS
|
https://github.com/aslanemirhan/HRMS
|
e1980badc5509cee49138e0416d4dc6f8ca15cfe
|
5a3587ec5106ffe6215e147b1784d64c21c75237
|
refs/heads/main
| 2023-06-26T19:00:56.027000
| 2021-08-03T17:25:31
| 2021-08-03T17:25:31
| 377,268,783
| 1
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package backend.hrms.adapters.mernis;
import backend.hrms.core.utilities.results.Result;
import backend.hrms.entities.concretes.Candidate;
public interface MernisVerificationService {
Result checkIfRealPerson(Candidate candidate);
}
|
UTF-8
|
Java
| 239
|
java
|
MernisVerificationService.java
|
Java
|
[] | null |
[] |
package backend.hrms.adapters.mernis;
import backend.hrms.core.utilities.results.Result;
import backend.hrms.entities.concretes.Candidate;
public interface MernisVerificationService {
Result checkIfRealPerson(Candidate candidate);
}
| 239
| 0.832636
| 0.832636
| 10
| 22.9
| 22.744011
| 50
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.6
| false
| false
|
13
|
9eb80622086ccbb86645a77c8b4bb0dd3d884924
| 30,743,375,923,318
|
4ff0c6fd8e0a3f941b02ea8a28a8771e16243c9f
|
/VieA/src/affichage/Graph.java
|
6b7cfad83e1b21da6bf9fd412f1a7e8085b893eb
|
[] |
no_license
|
FaustXVI/refactor-me-if-you-dare
|
https://github.com/FaustXVI/refactor-me-if-you-dare
|
8e3dd0a47904b48e1be2bc531cf3f015c80fefb2
|
91b09ddcff8d4829cb8c1a1a3b21b3423895e361
|
refs/heads/master
| 2020-06-22T06:50:49.007000
| 2016-11-25T11:09:59
| 2016-11-25T11:09:59
| 74,751,706
| 1
| 1
| null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
*/
package affichage;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Observable;
import java.util.Observer;
import param.Parametres;
import environnement.Environnement;
/**
* @author detantxavi
*
*/
public class Graph extends ChartPanel implements Observer, VueLourde {
/**
*
*/
private static final long serialVersionUID = -5756228374378724894L;
/**
* Le nom de la courbe des plantes
*/
private final String strPlantes;
/**
* L'historique du nombre de plantes
*/
private ArrayList<Point2D.Double> nbPlantes;
/**
* Le nom de la courbe des gaines
*/
private final String strGraines;
/**
* L'historique du nombre de graines
*/
private ArrayList<Point2D.Double> nbGraines;
/**
* Le nom de la courbe de vitesse des vaches
*/
private final String strVitesseVaches;
/**
* L'historique de la vitesse de vaches
*/
private ArrayList<Point2D.Double> vitesseVaches;
/**
* Le nom de la courbe d'esperance des vaches
*/
private final String strEsperanceVaches;
/**
* L'historique de l'esperance des vaches
*/
private ArrayList<Point2D.Double> esperanceVaches;
/**
* Le nom de la courbe des vaches
*/
private final String strVaches;
/**
* L'historique du nombre de vaches
*/
private ArrayList<Point2D.Double> nbVaches;
/**
* Le nom de la courbe de vitesse des loups
*/
private final String strVitesseLoups;
/**
* L'historique de la vitesse de loups
*/
private ArrayList<Point2D.Double> vitesseLoups;
/**
* Le nom de la courbe d'esperance des loups
*/
private final String strEsperanceLoups;
/**
* L'historique de l'esperance des loups
*/
private ArrayList<Point2D.Double> esperanceLoups;
/**
* Le nom de la courbe des loups
*/
private final String strLoups;
/**
* L'historique du nombre de loups
*/
private ArrayList<Point2D.Double> nbLoups;
/**
* Vrai si on doit raffraichir l'affichage
*/
public volatile boolean vueActive = true;
/**
* Creation du graph
*/
public Graph() {
super(new Hashtable<String, Chart>());
// on observe l'environnement
Environnement.getEnvironnement().addObserver(this);
this.strPlantes = "Nombre Plantes";
this.strGraines = "Nombre Graines";
this.strVaches = "Nombre Vaches";
this.strVitesseVaches = "Vitesse des vaches";
this.strEsperanceVaches = "Esperance de vie des vaches";
this.strLoups = "Nombre Loups";
this.strVitesseLoups = "Vitesse des loups";
this.strEsperanceLoups = "Esperance de vie des loups";
// on initialise tout
this.init();
// on place le panel correctement
this.setPreferredSize(new Dimension(Environnement.getEnvironnement()
.getTailleX()
* Parametres.COTE_CASES, Environnement.getEnvironnement()
.getTailleY()
* Parametres.COTE_CASES));
this.scale(0.1 * (Parametres.COTE_CASES / 4.0),
1 * (Parametres.COTE_CASES / 4.0));
this.center(3000, 350);
}
/**
* Ajoute les infos du graphe
*/
private void addInfos() {
// on verifie la taille de l'historique
this.limiterHistorique();
final Environnement env = Environnement.getEnvironnement();
// on ajoute un point pour les plantes
this.nbPlantes.add(new Point2D.Double(env.getAge(), env.getPlantes()
.size()));
// un pour les graines
this.nbGraines
.add(new Point2D.Double(env.getAge(), env.getNbGraines()));
// un pour les vaches
this.nbVaches.add(new Point2D.Double(env.getAge(), env.getVaches()
.size()));
// un pour la vitesse moyenne des vaches
this.vitesseVaches.add(new Point2D.Double(env.getAge(), env
.getVitesseMoyVaches() * 10));
// un pour l'esperance moyenne des vahces
this.esperanceVaches.add(new Point2D.Double(env.getAge(), env
.getEsperanceMoyVaches() / 10));
// un pour les loups
this.nbLoups
.add(new Point2D.Double(env.getAge(), env.getLoups().size()));
// un pour la vitesse moyenne des loups
this.vitesseLoups.add(new Point2D.Double(env.getAge(), env
.getVitesseMoyLoups() * 10));
// un pour l'esperance moyenne des loups
this.esperanceLoups.add(new Point2D.Double(env.getAge(), env
.getEsperanceMoyLoups() / 10));
}
/**
*
*
* @author Detant Xavier <xavier.detant@gmail.com>
* @date 9 avr. 2010
*/
public void init() {
// on initialise les plantes
this.nbPlantes = new ArrayList<Point2D.Double>();
this.add(this.strPlantes, this.nbPlantes);
this.color(this.strPlantes, Color.GREEN);
// on initialise les graines
this.nbGraines = new ArrayList<Point2D.Double>();
this.add(this.strGraines, this.nbGraines);
this.color(this.strGraines, Color.ORANGE);
// on initialise les vaches
this.nbVaches = new ArrayList<Point2D.Double>();
this.add(this.strVaches, this.nbVaches);
this.color(this.strVaches, Color.RED);
// on initialise leur vitesse
this.vitesseVaches = new ArrayList<Point2D.Double>();
this.add(this.strVitesseVaches, this.vitesseVaches);
this.color(this.strVitesseVaches, new Color(0xAA0000));
this.width(this.strVitesseVaches, 2);
// on initialise leur esperance
this.esperanceVaches = new ArrayList<Point2D.Double>();
this.add(this.strEsperanceVaches, this.esperanceVaches);
this.color(this.strEsperanceVaches, new Color(0xCC0000));
this.width(this.strEsperanceVaches, 2);
// on initialise les loups
this.nbLoups = new ArrayList<Point2D.Double>();
this.add(this.strLoups, this.nbLoups);
this.color(this.strLoups, Color.BLUE);
// on initialise leur vitesse
this.vitesseLoups = new ArrayList<Point2D.Double>();
this.add(this.strVitesseLoups, this.vitesseLoups);
this.color(this.strVitesseLoups, new Color(0x0000AA));
this.width(this.strVitesseLoups, 2);
// on initialise leur esperance
this.esperanceLoups = new ArrayList<Point2D.Double>();
this.add(this.strEsperanceLoups, this.esperanceLoups);
this.color(this.strEsperanceLoups, new Color(0x0000CC));
this.width(this.strEsperanceLoups, 2);
// on ajoute les infos de depart
this.addInfos();
}
/*
* (non-Javadoc)
*
* @see affichage.VueLourde#isActif()
*/
public boolean isActif() {
return this.vueActive;
}
/**
* Permet de limiter la taille de l'historique
*/
private void limiterHistorique() {
// si on a trop d'infos
if (this.nbPlantes.size() > Parametres.TAILLE_HISTORIQUE) {
// on supprimer les infos les plus anciennes
this.nbPlantes.remove(0);
this.nbGraines.remove(0);
this.vitesseVaches.remove(0);
this.esperanceVaches.remove(0);
this.nbVaches.remove(0);
this.nbLoups.remove(0);
this.vitesseLoups.remove(0);
this.esperanceLoups.remove(0);
// on decale tous les points de 1
/*
* for (int i = 0; i < nbPlantes.size(); i++) {
* nbPlantes.get(i).x--; nbGraines.get(i).x--;
* vitesseVaches.get(i).x--; esperanceVaches.get(i).x--;
* nbVaches.get(i).x--; nbLoups.get(i).x--; vitesseLoups.get(i).x--;
* esperanceLoups.get(i).x--; }
*/
}
}
/*
* (non-Javadoc)
*
* @see affichage.VueLourde#setActif(boolean)
*/
public void setActif(final boolean actif) {
this.vueActive = actif;
}
public void update(final Observable arg0, final Object arg1) {
// on recupère les infos
this.addInfos();
// si on est actif
if (this.vueActive) {
// on repaint le tout
this.repaint();
}
}
}
|
ISO-8859-1
|
Java
| 7,353
|
java
|
Graph.java
|
Java
|
[
{
"context": "mport environnement.Environnement;\n\n/**\n * @author detantxavi\n * \n */\npublic class Graph extends ChartPanel imp",
"end": 312,
"score": 0.9991258382797241,
"start": 302,
"tag": "USERNAME",
"value": "detantxavi"
},
{
"context": "eMoyLoups() / 10));\n\t}\n\n\t/**\n\t * \n\t * \n\t * @author Detant Xavier <xavier.detant@gmail.com>\n\t * @date 9 avr. 2010\n\t",
"end": 4265,
"score": 0.9998780488967896,
"start": 4252,
"tag": "NAME",
"value": "Detant Xavier"
},
{
"context": "));\n\t}\n\n\t/**\n\t * \n\t * \n\t * @author Detant Xavier <xavier.detant@gmail.com>\n\t * @date 9 avr. 2010\n\t */\n\tpublic void init() {",
"end": 4290,
"score": 0.9999340772628784,
"start": 4267,
"tag": "EMAIL",
"value": "xavier.detant@gmail.com"
}
] | null |
[] |
/**
*
*/
package affichage;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Observable;
import java.util.Observer;
import param.Parametres;
import environnement.Environnement;
/**
* @author detantxavi
*
*/
public class Graph extends ChartPanel implements Observer, VueLourde {
/**
*
*/
private static final long serialVersionUID = -5756228374378724894L;
/**
* Le nom de la courbe des plantes
*/
private final String strPlantes;
/**
* L'historique du nombre de plantes
*/
private ArrayList<Point2D.Double> nbPlantes;
/**
* Le nom de la courbe des gaines
*/
private final String strGraines;
/**
* L'historique du nombre de graines
*/
private ArrayList<Point2D.Double> nbGraines;
/**
* Le nom de la courbe de vitesse des vaches
*/
private final String strVitesseVaches;
/**
* L'historique de la vitesse de vaches
*/
private ArrayList<Point2D.Double> vitesseVaches;
/**
* Le nom de la courbe d'esperance des vaches
*/
private final String strEsperanceVaches;
/**
* L'historique de l'esperance des vaches
*/
private ArrayList<Point2D.Double> esperanceVaches;
/**
* Le nom de la courbe des vaches
*/
private final String strVaches;
/**
* L'historique du nombre de vaches
*/
private ArrayList<Point2D.Double> nbVaches;
/**
* Le nom de la courbe de vitesse des loups
*/
private final String strVitesseLoups;
/**
* L'historique de la vitesse de loups
*/
private ArrayList<Point2D.Double> vitesseLoups;
/**
* Le nom de la courbe d'esperance des loups
*/
private final String strEsperanceLoups;
/**
* L'historique de l'esperance des loups
*/
private ArrayList<Point2D.Double> esperanceLoups;
/**
* Le nom de la courbe des loups
*/
private final String strLoups;
/**
* L'historique du nombre de loups
*/
private ArrayList<Point2D.Double> nbLoups;
/**
* Vrai si on doit raffraichir l'affichage
*/
public volatile boolean vueActive = true;
/**
* Creation du graph
*/
public Graph() {
super(new Hashtable<String, Chart>());
// on observe l'environnement
Environnement.getEnvironnement().addObserver(this);
this.strPlantes = "Nombre Plantes";
this.strGraines = "Nombre Graines";
this.strVaches = "Nombre Vaches";
this.strVitesseVaches = "Vitesse des vaches";
this.strEsperanceVaches = "Esperance de vie des vaches";
this.strLoups = "Nombre Loups";
this.strVitesseLoups = "Vitesse des loups";
this.strEsperanceLoups = "Esperance de vie des loups";
// on initialise tout
this.init();
// on place le panel correctement
this.setPreferredSize(new Dimension(Environnement.getEnvironnement()
.getTailleX()
* Parametres.COTE_CASES, Environnement.getEnvironnement()
.getTailleY()
* Parametres.COTE_CASES));
this.scale(0.1 * (Parametres.COTE_CASES / 4.0),
1 * (Parametres.COTE_CASES / 4.0));
this.center(3000, 350);
}
/**
* Ajoute les infos du graphe
*/
private void addInfos() {
// on verifie la taille de l'historique
this.limiterHistorique();
final Environnement env = Environnement.getEnvironnement();
// on ajoute un point pour les plantes
this.nbPlantes.add(new Point2D.Double(env.getAge(), env.getPlantes()
.size()));
// un pour les graines
this.nbGraines
.add(new Point2D.Double(env.getAge(), env.getNbGraines()));
// un pour les vaches
this.nbVaches.add(new Point2D.Double(env.getAge(), env.getVaches()
.size()));
// un pour la vitesse moyenne des vaches
this.vitesseVaches.add(new Point2D.Double(env.getAge(), env
.getVitesseMoyVaches() * 10));
// un pour l'esperance moyenne des vahces
this.esperanceVaches.add(new Point2D.Double(env.getAge(), env
.getEsperanceMoyVaches() / 10));
// un pour les loups
this.nbLoups
.add(new Point2D.Double(env.getAge(), env.getLoups().size()));
// un pour la vitesse moyenne des loups
this.vitesseLoups.add(new Point2D.Double(env.getAge(), env
.getVitesseMoyLoups() * 10));
// un pour l'esperance moyenne des loups
this.esperanceLoups.add(new Point2D.Double(env.getAge(), env
.getEsperanceMoyLoups() / 10));
}
/**
*
*
* @author <NAME> <<EMAIL>>
* @date 9 avr. 2010
*/
public void init() {
// on initialise les plantes
this.nbPlantes = new ArrayList<Point2D.Double>();
this.add(this.strPlantes, this.nbPlantes);
this.color(this.strPlantes, Color.GREEN);
// on initialise les graines
this.nbGraines = new ArrayList<Point2D.Double>();
this.add(this.strGraines, this.nbGraines);
this.color(this.strGraines, Color.ORANGE);
// on initialise les vaches
this.nbVaches = new ArrayList<Point2D.Double>();
this.add(this.strVaches, this.nbVaches);
this.color(this.strVaches, Color.RED);
// on initialise leur vitesse
this.vitesseVaches = new ArrayList<Point2D.Double>();
this.add(this.strVitesseVaches, this.vitesseVaches);
this.color(this.strVitesseVaches, new Color(0xAA0000));
this.width(this.strVitesseVaches, 2);
// on initialise leur esperance
this.esperanceVaches = new ArrayList<Point2D.Double>();
this.add(this.strEsperanceVaches, this.esperanceVaches);
this.color(this.strEsperanceVaches, new Color(0xCC0000));
this.width(this.strEsperanceVaches, 2);
// on initialise les loups
this.nbLoups = new ArrayList<Point2D.Double>();
this.add(this.strLoups, this.nbLoups);
this.color(this.strLoups, Color.BLUE);
// on initialise leur vitesse
this.vitesseLoups = new ArrayList<Point2D.Double>();
this.add(this.strVitesseLoups, this.vitesseLoups);
this.color(this.strVitesseLoups, new Color(0x0000AA));
this.width(this.strVitesseLoups, 2);
// on initialise leur esperance
this.esperanceLoups = new ArrayList<Point2D.Double>();
this.add(this.strEsperanceLoups, this.esperanceLoups);
this.color(this.strEsperanceLoups, new Color(0x0000CC));
this.width(this.strEsperanceLoups, 2);
// on ajoute les infos de depart
this.addInfos();
}
/*
* (non-Javadoc)
*
* @see affichage.VueLourde#isActif()
*/
public boolean isActif() {
return this.vueActive;
}
/**
* Permet de limiter la taille de l'historique
*/
private void limiterHistorique() {
// si on a trop d'infos
if (this.nbPlantes.size() > Parametres.TAILLE_HISTORIQUE) {
// on supprimer les infos les plus anciennes
this.nbPlantes.remove(0);
this.nbGraines.remove(0);
this.vitesseVaches.remove(0);
this.esperanceVaches.remove(0);
this.nbVaches.remove(0);
this.nbLoups.remove(0);
this.vitesseLoups.remove(0);
this.esperanceLoups.remove(0);
// on decale tous les points de 1
/*
* for (int i = 0; i < nbPlantes.size(); i++) {
* nbPlantes.get(i).x--; nbGraines.get(i).x--;
* vitesseVaches.get(i).x--; esperanceVaches.get(i).x--;
* nbVaches.get(i).x--; nbLoups.get(i).x--; vitesseLoups.get(i).x--;
* esperanceLoups.get(i).x--; }
*/
}
}
/*
* (non-Javadoc)
*
* @see affichage.VueLourde#setActif(boolean)
*/
public void setActif(final boolean actif) {
this.vueActive = actif;
}
public void update(final Observable arg0, final Object arg1) {
// on recupère les infos
this.addInfos();
// si on est actif
if (this.vueActive) {
// on repaint le tout
this.repaint();
}
}
}
| 7,330
| 0.694097
| 0.679543
| 299
| 23.588629
| 20.96999
| 71
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.755853
| false
| false
|
13
|
741af35579db75f95f19c1b4cb0b1af0ccb538dc
| 31,516,470,085,232
|
223571cf50b7043e21f27c872f7574f91b6eb65c
|
/RMA_LV1_Inspiring_persons/src/hr/nemamdomenu/rasturi/InspiringPerson.java
|
8c4edfeec0de7d30ef6b07b8ac86781b6def5cd5
|
[] |
no_license
|
Firtzberg/Android-Workouts
|
https://github.com/Firtzberg/Android-Workouts
|
c96f3556d1e391e7370ac572d04a403e47f2a165
|
5ef53e383537061568f35cf112a2c6d3503f0c53
|
refs/heads/master
| 2021-01-13T01:36:20.259000
| 2014-12-17T23:01:00
| 2014-12-17T23:01:00
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package hr.nemamdomenu.rasturi;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class InspiringPerson extends RelativeLayout implements View.OnClickListener{
public final static int pictureSize = 85;
private final TextView nameView;
private Date dateOfBirth;
private Date dateOfDeath;
private java.text.DateFormat dateFormat;
private final TextView datesView;
private final TextView CVView;
private final ImageView imageView;
private static int freeId = 63428;
public final ArrayList<String> citations = new ArrayList<String>();
private static final Random random = new Random();
public InspiringPerson(Context context) {
super(context);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
this.setLayoutParams(lp);
this.setPadding(0, 7, 0, 0);
this.setOnClickListener(this);
//initialize views with layout params
RelativeLayout.LayoutParams rlp;
//initialize imageView
this.imageView = new ImageView(context);
this.imageView.setId(freeId++);
this.imageView.setAdjustViewBounds(true);
this.imageView.setScaleType(ScaleType.FIT_CENTER);
//adding to layout
rlp = new RelativeLayout.LayoutParams(pictureSize, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.ALIGN_LEFT);
rlp.addRule(RelativeLayout.ALIGN_TOP);
rlp.setMargins(0, 0, 5, 0);
this.addView(this.imageView, rlp);
//initialize nameView
this.nameView = new TextView(context);
this.nameView.setId(freeId++);
this.nameView.setTypeface(null, Typeface.BOLD);
this.nameView.setTextColor(Color.BLACK);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.ALIGN_TOP);
this.addView(this.nameView, rlp);
//initialize datesView
this.datesView = new TextView(context);
this.datesView.setId(freeId++);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.BELOW, this.nameView.getId());
this.addView(this.datesView, rlp);
//initialize CVView
this.CVView = new TextView(context);
this.CVView.setId(freeId++);
this.CVView.setTextColor(Color.BLACK);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.BELOW, this.datesView.getId());
this.addView(this.CVView, rlp);
this.dateFormat = java.text.DateFormat.getDateInstance();
}
public String getName() {
return (String) nameView.getText();
}
public void setName(String name) {
this.nameView.setText(name);
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
this.refreshDatesView();
}
public Date getDateOfDeath() {
return dateOfDeath;
}
public void setDateOfDeath(Date dateOfDeath) {
this.dateOfDeath = dateOfDeath;
this.refreshDatesView();
}
private void refreshDatesView() {
String s = "";
if(this.dateOfBirth != null)
s+= this.dateFormat.format(this.dateOfBirth);
else s += "...";
s += " - ";
if(this.dateOfDeath != null)
s+= this.dateFormat.format(this.dateOfDeath);
else s += "...";
this.datesView.setText(s);
}
public String getCV() {
return (String) CVView.getText();
}
public void setCV(String cV) {
CVView.setText(cV);
}
public Drawable getImage(){
return this.imageView.getDrawable();
}
public void setImage(Drawable drawable){
this.imageView.setImageDrawable(drawable);
}
@Override
public void onClick(View v) {
if(this.citations.size() < 1)return;
Toast.makeText(this.getContext(), this.citations.get(random.nextInt(this.citations.size())), Toast.LENGTH_SHORT).show();
}
}
|
UTF-8
|
Java
| 4,668
|
java
|
InspiringPerson.java
|
Java
|
[] | null |
[] |
package hr.nemamdomenu.rasturi;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class InspiringPerson extends RelativeLayout implements View.OnClickListener{
public final static int pictureSize = 85;
private final TextView nameView;
private Date dateOfBirth;
private Date dateOfDeath;
private java.text.DateFormat dateFormat;
private final TextView datesView;
private final TextView CVView;
private final ImageView imageView;
private static int freeId = 63428;
public final ArrayList<String> citations = new ArrayList<String>();
private static final Random random = new Random();
public InspiringPerson(Context context) {
super(context);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
this.setLayoutParams(lp);
this.setPadding(0, 7, 0, 0);
this.setOnClickListener(this);
//initialize views with layout params
RelativeLayout.LayoutParams rlp;
//initialize imageView
this.imageView = new ImageView(context);
this.imageView.setId(freeId++);
this.imageView.setAdjustViewBounds(true);
this.imageView.setScaleType(ScaleType.FIT_CENTER);
//adding to layout
rlp = new RelativeLayout.LayoutParams(pictureSize, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.ALIGN_LEFT);
rlp.addRule(RelativeLayout.ALIGN_TOP);
rlp.setMargins(0, 0, 5, 0);
this.addView(this.imageView, rlp);
//initialize nameView
this.nameView = new TextView(context);
this.nameView.setId(freeId++);
this.nameView.setTypeface(null, Typeface.BOLD);
this.nameView.setTextColor(Color.BLACK);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.ALIGN_TOP);
this.addView(this.nameView, rlp);
//initialize datesView
this.datesView = new TextView(context);
this.datesView.setId(freeId++);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.BELOW, this.nameView.getId());
this.addView(this.datesView, rlp);
//initialize CVView
this.CVView = new TextView(context);
this.CVView.setId(freeId++);
this.CVView.setTextColor(Color.BLACK);
//adding to layout
rlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rlp.addRule(RelativeLayout.RIGHT_OF, this.imageView.getId());
rlp.addRule(RelativeLayout.ALIGN_RIGHT);
rlp.addRule(RelativeLayout.BELOW, this.datesView.getId());
this.addView(this.CVView, rlp);
this.dateFormat = java.text.DateFormat.getDateInstance();
}
public String getName() {
return (String) nameView.getText();
}
public void setName(String name) {
this.nameView.setText(name);
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
this.refreshDatesView();
}
public Date getDateOfDeath() {
return dateOfDeath;
}
public void setDateOfDeath(Date dateOfDeath) {
this.dateOfDeath = dateOfDeath;
this.refreshDatesView();
}
private void refreshDatesView() {
String s = "";
if(this.dateOfBirth != null)
s+= this.dateFormat.format(this.dateOfBirth);
else s += "...";
s += " - ";
if(this.dateOfDeath != null)
s+= this.dateFormat.format(this.dateOfDeath);
else s += "...";
this.datesView.setText(s);
}
public String getCV() {
return (String) CVView.getText();
}
public void setCV(String cV) {
CVView.setText(cV);
}
public Drawable getImage(){
return this.imageView.getDrawable();
}
public void setImage(Drawable drawable){
this.imageView.setImageDrawable(drawable);
}
@Override
public void onClick(View v) {
if(this.citations.size() < 1)return;
Toast.makeText(this.getContext(), this.citations.get(random.nextInt(this.citations.size())), Toast.LENGTH_SHORT).show();
}
}
| 4,668
| 0.718937
| 0.71551
| 148
| 29.540541
| 22.948055
| 122
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.45946
| false
| false
|
13
|
0639f091d9be42238c3f387ff316e58a43535016
| 31,121,333,072,100
|
5abb5d0e2bd899bc6087e90e452ff15ea4258069
|
/app/src/main/java/pe/edu/esan/appesan2/NotificationView.java
|
a272d62928e1dcc23342202147813c524d141e90
|
[] |
no_license
|
diegoflg/AppEsan2
|
https://github.com/diegoflg/AppEsan2
|
90215b0b614c390370a10e649563d3d67c56f19f
|
4ce9bf960ba3391e109864479f27c04c9dc886c3
|
refs/heads/master
| 2016-09-06T12:27:24.198000
| 2015-10-16T14:45:45
| 2015-10-16T14:45:45
| 38,979,926
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package pe.edu.esan.appesan2;
import android.app.Activity;
import android.os.Bundle;
/**
* Clase que se creo para mostrar avisos fuera de la aplicacion, actualmente no se usa
*/
public class NotificationView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.notification);
}
}
|
UTF-8
|
Java
| 397
|
java
|
NotificationView.java
|
Java
|
[] | null |
[] |
package pe.edu.esan.appesan2;
import android.app.Activity;
import android.os.Bundle;
/**
* Clase que se creo para mostrar avisos fuera de la aplicacion, actualmente no se usa
*/
public class NotificationView extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.notification);
}
}
| 397
| 0.738035
| 0.735516
| 15
| 25.466667
| 24.635656
| 86
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.4
| false
| false
|
13
|
a4404eb88d9edf90ee363ef1a5f3a2efa7de07ff
| 25,958,782,374,812
|
c9e82da6b4949a6a498a6230ff726c59ac68b9cd
|
/app/src/main/java/com/newegg/www/annotationandbutterknifeneweggs/showAnnotation.java
|
7c1b35799e265333122af27bc2513918162fae52
|
[] |
no_license
|
YAYA9527/annotationandbutterknifeneweggs
|
https://github.com/YAYA9527/annotationandbutterknifeneweggs
|
30021fc8e23f6898bfb88adf40cd17918d119e8e
|
3d685b08713dd13043e52ac4a37ed4f33e90bb80
|
refs/heads/master
| 2016-08-05T16:35:59.046000
| 2015-06-29T05:20:57
| 2015-06-29T05:20:57
| 38,227,148
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.newegg.www.annotationandbutterknifeneweggs;
public class showAnnotation {
@MyAnnotation(
name = "YAYA",
age = 25
)
public void test(){
}
}
|
UTF-8
|
Java
| 191
|
java
|
showAnnotation.java
|
Java
|
[
{
"context": "notation {\n @MyAnnotation(\n name = \"YAYA\",\n age = 25\n )\n public void test",
"end": 130,
"score": 0.9984116554260254,
"start": 126,
"tag": "NAME",
"value": "YAYA"
}
] | null |
[] |
package com.newegg.www.annotationandbutterknifeneweggs;
public class showAnnotation {
@MyAnnotation(
name = "YAYA",
age = 25
)
public void test(){
}
}
| 191
| 0.596859
| 0.586387
| 10
| 18.200001
| 15.917286
| 55
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.2
| false
| false
|
13
|
c52ce0cdb6299a3035595c026f9457fa5ed17cf8
| 7,060,926,235,038
|
f2adc9006f2bd6259ddb7ad2f16ca9a99abea935
|
/Partsbody/src/Belly.java
|
7e4fbe7cb5d64224ac5b10e332921dda002d49fd
|
[] |
no_license
|
Sultanyam/Partsbody6
|
https://github.com/Sultanyam/Partsbody6
|
fba4c44d3fd7e90d24328e06bcad80aa06c02f6c
|
db51b3e33e60f61f66af437728c3840c9c316c09
|
refs/heads/main
| 2023-04-03T08:14:03.356000
| 2021-04-16T22:46:59
| 2021-04-16T22:46:59
| 358,735,842
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Belly extends Partsbody {
public void Kind () {
System.out.println("i'm the middle");
}
}
|
UTF-8
|
Java
| 121
|
java
|
Belly.java
|
Java
|
[] | null |
[] |
public class Belly extends Partsbody {
public void Kind () {
System.out.println("i'm the middle");
}
}
| 121
| 0.603306
| 0.603306
| 8
| 13.125
| 16.127907
| 39
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1
| false
| false
|
13
|
18a12a577b7fa58ce614ae30f75828e6c88ef233
| 1,494,648,633,549
|
d0f0e6ad7ee94fcece8307b55b253bfbbb171236
|
/src/test/OrmRun.java
|
97a57788e24294154d0ebc28ac739b6df97c42c7
|
[] |
no_license
|
jaakan/j2eeDemo
|
https://github.com/jaakan/j2eeDemo
|
1b321cb873d5472d0ad7bc5f88b9c9a6b874b4ad
|
6c9f38e16f729903e2b3845ec24529005c3cc9f3
|
refs/heads/master
| 2016-08-06T10:15:12.490000
| 2013-05-31T16:11:49
| 2013-05-31T16:11:49
| null | 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package test;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import pojos.j2eedemo.TB_Person;
import test.dao.IPersonDao;
public class OrmRun {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
IPersonDao personDao=(IPersonDao) context.getBean("personDao");
TB_Person person=new TB_Person();
person.setName("sunkai");
person.setAge("26");
person.setSex("M");
personDao.createPerson(person);
List<TB_Person> list=personDao.getPersons();
for(TB_Person p:list){
System.out.println("ÄÚÈÝ:"+p.getName());
}
}
}
|
WINDOWS-1252
|
Java
| 821
|
java
|
OrmRun.java
|
Java
|
[
{
"context": "Person person=new TB_Person();\r\n\t\tperson.setName(\"sunkai\");\r\n\t\tperson.setAge(\"26\");\r\n\t\tperson.setSex(\"M\");",
"end": 597,
"score": 0.9955459237098694,
"start": 591,
"tag": "NAME",
"value": "sunkai"
}
] | null |
[] |
package test;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import pojos.j2eedemo.TB_Person;
import test.dao.IPersonDao;
public class OrmRun {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
IPersonDao personDao=(IPersonDao) context.getBean("personDao");
TB_Person person=new TB_Person();
person.setName("sunkai");
person.setAge("26");
person.setSex("M");
personDao.createPerson(person);
List<TB_Person> list=personDao.getPersons();
for(TB_Person p:list){
System.out.println("ÄÚÈÝ:"+p.getName());
}
}
}
| 821
| 0.718482
| 0.71481
| 31
| 24.354839
| 23.37154
| 90
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.451613
| false
| false
|
13
|
f7e29797727bcd936da0952dba5043ceed8f3560
| 21,397,527,079,054
|
cf1376481c6fa0e076480b40752fa36d0f606007
|
/mad104outillage/src/main/java/fr/laposte/disfe/mad104tool/beans/JenkinsModification.java
|
32d82e297402c63cc6eed865a7baafc80c48fcae
|
[] |
no_license
|
Newstarstart/mad104outillage
|
https://github.com/Newstarstart/mad104outillage
|
5b20261f77f44a52d1c3da33a600fdac268c37db
|
0aa7b86b80fc9e15a88379b9fd2242c0cb60dd47
|
refs/heads/master
| 2019-03-21T03:28:12.923000
| 2018-03-14T17:04:59
| 2018-03-14T17:04:59
| 124,113,813
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package fr.laposte.disfe.mad104tool.beans;
import java.io.Serializable;
/**
* @author Atos
*
* Cette classe contient les informations des jobs Jenkins à modifier
* Les informations qu'elle contient sont les suivantes:
* 1) nomJob: nom du job
* 2) typeJob: COMPOSANT_APPLICATIF, MODULE_APPLICATIF, ACCESSEUR, OBJET_METIER, TRAITEMENT, MODLE_ASSEMBLAGE
*
* Cette classe est à rejeter car la classe Jenkins contient un attribut de plus (la brance par défaut)
* qui ne sert qu'à la création du job et qui peut être ignorer pour le cas des jobs à modifier
*
*/
public class JenkinsModification implements Serializable {
private static final long serialVersionUID = 1L;
private String nomJob;
private String typeJob;
public JenkinsModification() {
super();
}
public String getNomJob() {
return nomJob;
}
public void setNomJob(String nomJob) {
this.nomJob = nomJob;
}
public String getTypeJob() {
return typeJob;
}
public void setTypeJob(String typeJob) {
this.typeJob = typeJob;
}
}
|
ISO-8859-1
|
Java
| 1,124
|
java
|
JenkinsModification.java
|
Java
|
[
{
"context": "\n\r\nimport java.io.Serializable;\r\n\r\n/**\r\n * @author Atos\r\n * \r\n * Cette classe contient les inform",
"end": 98,
"score": 0.9986295104026794,
"start": 94,
"tag": "NAME",
"value": "Atos"
}
] | null |
[] |
package fr.laposte.disfe.mad104tool.beans;
import java.io.Serializable;
/**
* @author Atos
*
* Cette classe contient les informations des jobs Jenkins à modifier
* Les informations qu'elle contient sont les suivantes:
* 1) nomJob: nom du job
* 2) typeJob: COMPOSANT_APPLICATIF, MODULE_APPLICATIF, ACCESSEUR, OBJET_METIER, TRAITEMENT, MODLE_ASSEMBLAGE
*
* Cette classe est à rejeter car la classe Jenkins contient un attribut de plus (la brance par défaut)
* qui ne sert qu'à la création du job et qui peut être ignorer pour le cas des jobs à modifier
*
*/
public class JenkinsModification implements Serializable {
private static final long serialVersionUID = 1L;
private String nomJob;
private String typeJob;
public JenkinsModification() {
super();
}
public String getNomJob() {
return nomJob;
}
public void setNomJob(String nomJob) {
this.nomJob = nomJob;
}
public String getTypeJob() {
return typeJob;
}
public void setTypeJob(String typeJob) {
this.typeJob = typeJob;
}
}
| 1,124
| 0.675918
| 0.670546
| 38
| 27.394737
| 31.317171
| 117
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.052632
| false
| false
|
13
|
3b815591891e7a2aca315f8887458524a726614e
| 31,293,131,771,891
|
660ec4a10870f77291e9280db0325744648c4a71
|
/Java/GeeksForGeeks/src/binarytree/PrintAllPaths.java
|
3d88a166b15d44ca762d7a9179fd88a99b64ab39
|
[] |
no_license
|
uniquephase/myspace
|
https://github.com/uniquephase/myspace
|
9fd8f6552de00484595be6b79a234e627147e147
|
32a07bcfecf0cbc323f1363ccde8f03f01aaf7a1
|
refs/heads/master
| 2021-05-24T03:48:40.950000
| 2021-05-12T12:34:14
| 2021-05-12T12:34:14
| 32,258,755
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package binarytree;
public class PrintAllPaths {
private static Node root;
public static void main(String[] args) {
root = new Node();
Node node1 = new Node(1);
Node node2 = new Node(2);
Node node3 = new Node(3);
Node node4 = new Node(4);
Node node5 = new Node(5);
Node node6 = new Node(6);
Node node7 = new Node(7);
Node node8 = new Node(8);
Node node9 = new Node(9);
root.setLeft(node1);
root.setRight(node2);
node1.setLeft(node3);
node1.setRight(node4);
node2.setLeft(node5);
node2.setRight(node6);
node5.setLeft(node7);
node5.setRight(node9);
node7.setRight(node8);
printPath(root);
}
private static void printPath(Node node) {
int pathArr[] = new int[1000];
printPathRec(node, pathArr, 0);
}
private static void printPathRec(Node node, int[] pathArr, int currentIndex) {
if (node == null)
return;
pathArr[currentIndex] = node.getData();
if (node.getLeft() == null && node.getRight() == null)
printArr(pathArr, currentIndex);
else {
printPathRec(node.getLeft(), pathArr, currentIndex + 1);
printPathRec(node.getRight(), pathArr, currentIndex + 1);
}
}
private static void printArr(int[] pathArr, int lastIndex) {
for (int i = 0; i <= lastIndex; i++) {
System.out.print(pathArr[i] + " ");
}
System.out.println();
}
}
|
UTF-8
|
Java
| 1,312
|
java
|
PrintAllPaths.java
|
Java
|
[] | null |
[] |
package binarytree;
public class PrintAllPaths {
private static Node root;
public static void main(String[] args) {
root = new Node();
Node node1 = new Node(1);
Node node2 = new Node(2);
Node node3 = new Node(3);
Node node4 = new Node(4);
Node node5 = new Node(5);
Node node6 = new Node(6);
Node node7 = new Node(7);
Node node8 = new Node(8);
Node node9 = new Node(9);
root.setLeft(node1);
root.setRight(node2);
node1.setLeft(node3);
node1.setRight(node4);
node2.setLeft(node5);
node2.setRight(node6);
node5.setLeft(node7);
node5.setRight(node9);
node7.setRight(node8);
printPath(root);
}
private static void printPath(Node node) {
int pathArr[] = new int[1000];
printPathRec(node, pathArr, 0);
}
private static void printPathRec(Node node, int[] pathArr, int currentIndex) {
if (node == null)
return;
pathArr[currentIndex] = node.getData();
if (node.getLeft() == null && node.getRight() == null)
printArr(pathArr, currentIndex);
else {
printPathRec(node.getLeft(), pathArr, currentIndex + 1);
printPathRec(node.getRight(), pathArr, currentIndex + 1);
}
}
private static void printArr(int[] pathArr, int lastIndex) {
for (int i = 0; i <= lastIndex; i++) {
System.out.print(pathArr[i] + " ");
}
System.out.println();
}
}
| 1,312
| 0.660061
| 0.628049
| 55
| 22.854546
| 18.162317
| 79
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 2.309091
| false
| false
|
13
|
88625509a145613da7d2965bc4a7eafb9c0aff9f
| 5,746,666,293,081
|
a36c986969f07f7d9e2a0daffffb89616dd8a333
|
/src/main/java/com/blog/platform/model/param/BlogBasicParam.java
|
44633e8fec243aeec90c848089b2ef881ac17e8c
|
[] |
no_license
|
guoyuncong/blog-platform
|
https://github.com/guoyuncong/blog-platform
|
17fed8618060dcf25cdae97f8bc0f8f02c4f6a28
|
925f74104d1748ccbe5b06e814213997ffbaa502
|
refs/heads/master
| 2020-09-10T22:32:06.819000
| 2020-06-13T08:00:40
| 2020-06-13T08:00:40
| 221,853,160
| 0
| 0
| null | false
| 2020-07-02T03:21:26
| 2019-11-15T05:48:15
| 2020-06-13T08:00:55
| 2020-07-02T03:21:24
| 40
| 0
| 0
| 1
|
Java
| false
| false
|
package com.blog.platform.model.param;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* 基本信息表
*/
@Getter
@Setter
@ToString
public class BlogBasicParam {
/**
* 主键 ID
*/
private String blogId;
/**
* 博客名称
*/
@NotBlank(message = "博客名称不能为空")
@Size(max = 20, message = "博客名称的字符长度不能超过 {max}")
private String blogName;
/**
* 博客描述
*/
@NotBlank(message = "博客名称不能为空")
@Size(max = 100, message = "博客名称的字符长度不能超过 {max}")
private String blogDescription;
/**
* 博主姓名
*/
@Size(max = 20, message = "博主姓名的字符长度不能超过 {max}")
private String bloggerName;
/**
* 博主昵称
*/
@Size(max = 20, message = "博主昵称的字符长度不能超过 {max}")
private String bloggerNickName;
/**
* 博主生日
*/
private Date bloggerBirthday;
/**
* 博主手机号
*/
@Size(max = 13, message = "博主手机号的字符长度不能超过 {max}")
private String bloggerMobile;
/**
* 博主邮箱
*/
@Size(max = 30, message = "博主邮箱的字符长度不能超过 {max}")
private String bloggerEmail;
/**
* 头像地址
*/
@Size(max = 50, message = "头像地址的字符长度不能超过 {max}")
private String headPortraitUrl;
/**
* 首页页脚
*/
@Size(max = 100, message = "首页页脚的字符长度不能超过 {max}")
private String homePageFooter;
/**
* 内容页脚
*/
@Size(max = 100, message = "内容页脚的字符长度不能超过 {max}")
private String contentPageFooter;
}
|
UTF-8
|
Java
| 1,904
|
java
|
BlogBasicParam.java
|
Java
|
[] | null |
[] |
package com.blog.platform.model.param;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* 基本信息表
*/
@Getter
@Setter
@ToString
public class BlogBasicParam {
/**
* 主键 ID
*/
private String blogId;
/**
* 博客名称
*/
@NotBlank(message = "博客名称不能为空")
@Size(max = 20, message = "博客名称的字符长度不能超过 {max}")
private String blogName;
/**
* 博客描述
*/
@NotBlank(message = "博客名称不能为空")
@Size(max = 100, message = "博客名称的字符长度不能超过 {max}")
private String blogDescription;
/**
* 博主姓名
*/
@Size(max = 20, message = "博主姓名的字符长度不能超过 {max}")
private String bloggerName;
/**
* 博主昵称
*/
@Size(max = 20, message = "博主昵称的字符长度不能超过 {max}")
private String bloggerNickName;
/**
* 博主生日
*/
private Date bloggerBirthday;
/**
* 博主手机号
*/
@Size(max = 13, message = "博主手机号的字符长度不能超过 {max}")
private String bloggerMobile;
/**
* 博主邮箱
*/
@Size(max = 30, message = "博主邮箱的字符长度不能超过 {max}")
private String bloggerEmail;
/**
* 头像地址
*/
@Size(max = 50, message = "头像地址的字符长度不能超过 {max}")
private String headPortraitUrl;
/**
* 首页页脚
*/
@Size(max = 100, message = "首页页脚的字符长度不能超过 {max}")
private String homePageFooter;
/**
* 内容页脚
*/
@Size(max = 100, message = "内容页脚的字符长度不能超过 {max}")
private String contentPageFooter;
}
| 1,904
| 0.582468
| 0.568831
| 84
| 17.333334
| 17.0415
| 53
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.321429
| false
| false
|
13
|
41e196d00734442c85771d995fb4e5ce8a9c7738
| 10,900,627,019,105
|
5707536bdaffe1c0de2abfa838111cabb287c452
|
/components/org.wso2.carbon.identity.oauth.ui/src/main/java/org/wso2/carbon/identity/oauth/ui/client/OAuthAdminClient.java
|
61d9a90be28c95000f73cadb655e59ae31aa7322
|
[
"Apache-2.0"
] |
permissive
|
wso2-extensions/identity-inbound-auth-oauth
|
https://github.com/wso2-extensions/identity-inbound-auth-oauth
|
1ea5481d0595e56fdf972c1bc6e6bd1c61bd7d82
|
d153b3dd2ae065df135566cb6e8951ac8c1a8645
|
refs/heads/master
| 2023-09-01T08:58:09.127000
| 2023-09-01T05:37:33
| 2023-09-01T05:37:33
| 52,758,721
| 28
| 410
|
Apache-2.0
| false
| 2023-09-14T12:13:20
| 2016-02-29T02:41:06
| 2023-07-05T11:10:32
| 2023-09-14T11:53:39
| 32,368
| 21
| 351
| 69
|
Java
| false
| false
|
/*
* Copyright (c) 2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.identity.oauth.ui.client;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.lang.ArrayUtils;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceIdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthIDTokenAlgorithmDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthRevocationRequestDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthRevocationResponseDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthTokenExpiryTimeDTO;
import org.wso2.carbon.identity.oauth.stub.dto.ScopeDTO;
import org.wso2.carbon.identity.oauth.stub.dto.TokenBindingMetaDataDTO;
import java.rmi.RemoteException;
/**
* Admin client for OAuth service.
*/
public class OAuthAdminClient {
private static String[] allowedGrantTypes = null;
private static String[] scopeValidators = null;
private String[] supportedTokenTypes = ArrayUtils.EMPTY_STRING_ARRAY;
private OAuthAdminServiceStub stub;
/**
* Instantiates OAuthAdminClient
*
* @param cookie For session management
* @param backendServerURL URL of the back end server where OAuthAdminService is running.
* @param configCtx ConfigurationContext
* @throws org.apache.axis2.AxisFault
*/
public OAuthAdminClient(String cookie, String backendServerURL, ConfigurationContext configCtx)
throws AxisFault {
String serviceURL = backendServerURL + "OAuthAdminService";
stub = new OAuthAdminServiceStub(configCtx, serviceURL);
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
public OAuthConsumerAppDTO[] getAllOAuthApplicationData() throws Exception {
return stub.getAllOAuthApplicationData();
}
public OAuthConsumerAppDTO getOAuthApplicationData(String consumerkey) throws Exception {
return stub.getOAuthApplicationData(consumerkey);
}
public OAuthConsumerAppDTO getOAuthApplicationDataByAppName(String appName) throws Exception {
return stub.getOAuthApplicationDataByAppName(appName);
}
// TODO : this method should return app data
public void registerOAuthApplicationData(OAuthConsumerAppDTO application) throws Exception {
stub.registerOAuthApplicationData(application);
}
/**
* Registers an OAuth consumer application and retrieve application details.
*
* @param application <code>OAuthConsumerAppDTO</code> with application information.
* @return OAuthConsumerAppDTO Created OAuth application details.
* @throws Exception Error while registering an application.
*/
public OAuthConsumerAppDTO registerAndRetrieveOAuthApplicationData(OAuthConsumerAppDTO application)
throws Exception {
return stub.registerAndRetrieveOAuthApplicationData(application);
}
// TODO : this method should be removed once above is done
public OAuthConsumerAppDTO getOAuthApplicationDataByName(String applicationName) throws Exception {
OAuthConsumerAppDTO[] dtos = stub.getAllOAuthApplicationData();
if (dtos != null && dtos.length > 0) {
for (OAuthConsumerAppDTO dto : dtos) {
if (applicationName.equals(dto.getApplicationName())) {
return dto;
}
}
}
return null;
}
public void removeOAuthApplicationData(String consumerkey) throws Exception {
stub.removeOAuthApplicationData(consumerkey);
}
public void updateOAuthApplicationData(OAuthConsumerAppDTO consumerAppDTO) throws Exception {
stub.updateConsumerApplication(consumerAppDTO);
}
public OAuthConsumerAppDTO[] getAppsAuthorizedByUser() throws Exception {
return stub.getAppsAuthorizedByUser();
}
public OAuthRevocationResponseDTO revokeAuthzForAppsByRessourceOwner(OAuthRevocationRequestDTO reqDTO)
throws Exception {
return stub.revokeAuthzForAppsByResoureOwner(reqDTO);
}
public boolean isPKCESupportedEnabled() throws Exception {
return stub.isPKCESupportEnabled();
}
/**
* Check whether hashing oauth keys (consumer secret, access token, refresh token and authorization code)
* configuration is disabled or not in identity.xml file.
*
* @return Whether hash feature is disabled or not.
* @throws Exception Error while getting the oAuth configuration.
*/
public boolean isHashDisabled() throws Exception {
return stub.isHashDisabled();
}
public String[] getAllowedOAuthGrantTypes() throws Exception {
if (allowedGrantTypes == null) {
allowedGrantTypes = stub.getAllowedGrantTypes();
}
return allowedGrantTypes;
}
public void regenerateSecretKey(String consumerkey) throws Exception {
stub.updateOauthSecretKey(consumerkey);
}
/**
* Regenerate consumer secret for the application and retrieve application details.
*
* @param consumerKey Consumer key for the application.
* @return OAuthConsumerAppDTO oAuth application details.
* @throws Exception Error while regenerating the consumer secret.
*/
public OAuthConsumerAppDTO regenerateAndRetrieveOauthSecretKey(String consumerKey) throws Exception {
return stub.updateAndRetrieveOauthSecretKey(consumerKey);
}
public String getOauthApplicationState(String consumerKey) throws Exception {
return stub.getOauthApplicationState(consumerKey);
}
public void updateOauthApplicationState(String consumerKey, String newState) throws Exception {
stub.updateConsumerAppState(consumerKey, newState);
}
public OAuthTokenExpiryTimeDTO getOAuthTokenExpiryTimeDTO() throws RemoteException {
return stub.getTokenExpiryTimes();
}
/**
* To add oidc scopes and claims
*
* @param scope an OIDC scope
* @throws RemoteException if an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when adding scopes or claims
*/
public void addScope(String scope, String[] claims) throws RemoteException,
OAuthAdminServiceIdentityOAuthAdminException {
stub.addScope(scope, claims);
}
/**
* To retrieve all persisted oidc scopes with mapped claims.
*
* @return all persisted scopes and claims
* @throws RemoteException if an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when loading scopes and claims.
*/
public ScopeDTO[] getScopes() throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getScopes();
}
/**
* To retrieve all persisted oidc scopes.
*
* @return list of scopes persisted.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when loading oidc scopes.
* @throws RemoteException if an exception occured during remote call.
*/
public String[] getScopeNames() throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getScopeNames();
}
/**
* To retrieve oidc claims mapped to an oidc scope.
*
* @param scope scope name
* @return list of claims which are mapped to the oidc scope.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when lading oidc claims.
* @throws RemoteException if an exception occured during remote call.
*/
public String[] getClaims(String scope) throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getClaims(scope);
}
/**
* To load scope id.
*
* @param scope scope name
* @return oidc scope id
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs while loading scope id.
* @throws RemoteException if an exception occured during remote call.
*/
public boolean isScopeExist(String scope) throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException {
return stub.isScopeExist(scope);
}
/**
* To remove persisted scopes and claims.
*
* @param scope
* @throws OAuthAdminServiceIdentityOAuthAdminException If an error occurs when deleting scopes and claims.
* @throws RemoteException If an exception occured during remote call.
*/
public void deleteScope(String scope)
throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException {
stub.deleteScope(scope);
}
/**
* To add new claims for an existing scope.
*
* @param scope scope name
* @param addClaims addClaims
* @throws RemoteException If an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException If an error occurs when adding new claims for scope.
*/
public void updateScope(String scope, String[] addClaims, String[] deleteClaims) throws RemoteException,
OAuthAdminServiceIdentityOAuthAdminException {
stub.updateScope(scope, addClaims, deleteClaims);
}
/**
* Get the registered scope validators from OAuth server configuration file.
*
* @return list of string containing simple names of the registered validator class
* @throws RemoteException exception occured during remote call
*/
public String[] getAllowedScopeValidators() throws RemoteException {
if (scopeValidators == null) {
scopeValidators = stub.getAllowedScopeValidators();
if (scopeValidators == null) {
scopeValidators = new String[0];
}
}
return scopeValidators;
}
/**
* Get the registered oauth token types from OAuth server configuration file.
*
* @return List of supported oauth token types
* @throws RemoteException exception occured during remote call
*/
public String[] getSupportedTokenTypes() throws RemoteException {
if (stub.getSupportedTokenTypes() != null) {
supportedTokenTypes = stub.getSupportedTokenTypes();
}
return supportedTokenTypes;
}
/**
* Return supported algorithms read from identity.xml configuration file.
*
* @return OAuthIDTokenAlgorithmDTO object.
* @throws RemoteException
*/
public OAuthIDTokenAlgorithmDTO getSupportedIDTokenAlgorithms() throws RemoteException {
return stub.getSupportedIDTokenAlgorithms();
}
/**
* Return renew refresh token property value read from identity.xml configuration file.
*
* @return boolean renew refresh token property value
* @throws RemoteException
*/
public boolean isRefreshTokenRenewalEnabled() throws RemoteException {
return stub.isRefreshTokenRenewalEnabled();
}
/**
* Get supported token bindings metadata.
*
* @return Array of TokenBindingMetaDataDTOs.
* @throws RemoteException remote exception.
*/
public TokenBindingMetaDataDTO[] getSupportedTokenBindingsMetaData() throws RemoteException {
return stub.getSupportedTokenBindingsMetaData();
}
}
|
UTF-8
|
Java
| 12,591
|
java
|
OAuthAdminClient.java
|
Java
|
[] | null |
[] |
/*
* Copyright (c) 2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.identity.oauth.ui.client;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.lang.ArrayUtils;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceIdentityOAuthAdminException;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthIDTokenAlgorithmDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthRevocationRequestDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthRevocationResponseDTO;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthTokenExpiryTimeDTO;
import org.wso2.carbon.identity.oauth.stub.dto.ScopeDTO;
import org.wso2.carbon.identity.oauth.stub.dto.TokenBindingMetaDataDTO;
import java.rmi.RemoteException;
/**
* Admin client for OAuth service.
*/
public class OAuthAdminClient {
private static String[] allowedGrantTypes = null;
private static String[] scopeValidators = null;
private String[] supportedTokenTypes = ArrayUtils.EMPTY_STRING_ARRAY;
private OAuthAdminServiceStub stub;
/**
* Instantiates OAuthAdminClient
*
* @param cookie For session management
* @param backendServerURL URL of the back end server where OAuthAdminService is running.
* @param configCtx ConfigurationContext
* @throws org.apache.axis2.AxisFault
*/
public OAuthAdminClient(String cookie, String backendServerURL, ConfigurationContext configCtx)
throws AxisFault {
String serviceURL = backendServerURL + "OAuthAdminService";
stub = new OAuthAdminServiceStub(configCtx, serviceURL);
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
}
public OAuthConsumerAppDTO[] getAllOAuthApplicationData() throws Exception {
return stub.getAllOAuthApplicationData();
}
public OAuthConsumerAppDTO getOAuthApplicationData(String consumerkey) throws Exception {
return stub.getOAuthApplicationData(consumerkey);
}
public OAuthConsumerAppDTO getOAuthApplicationDataByAppName(String appName) throws Exception {
return stub.getOAuthApplicationDataByAppName(appName);
}
// TODO : this method should return app data
public void registerOAuthApplicationData(OAuthConsumerAppDTO application) throws Exception {
stub.registerOAuthApplicationData(application);
}
/**
* Registers an OAuth consumer application and retrieve application details.
*
* @param application <code>OAuthConsumerAppDTO</code> with application information.
* @return OAuthConsumerAppDTO Created OAuth application details.
* @throws Exception Error while registering an application.
*/
public OAuthConsumerAppDTO registerAndRetrieveOAuthApplicationData(OAuthConsumerAppDTO application)
throws Exception {
return stub.registerAndRetrieveOAuthApplicationData(application);
}
// TODO : this method should be removed once above is done
public OAuthConsumerAppDTO getOAuthApplicationDataByName(String applicationName) throws Exception {
OAuthConsumerAppDTO[] dtos = stub.getAllOAuthApplicationData();
if (dtos != null && dtos.length > 0) {
for (OAuthConsumerAppDTO dto : dtos) {
if (applicationName.equals(dto.getApplicationName())) {
return dto;
}
}
}
return null;
}
public void removeOAuthApplicationData(String consumerkey) throws Exception {
stub.removeOAuthApplicationData(consumerkey);
}
public void updateOAuthApplicationData(OAuthConsumerAppDTO consumerAppDTO) throws Exception {
stub.updateConsumerApplication(consumerAppDTO);
}
public OAuthConsumerAppDTO[] getAppsAuthorizedByUser() throws Exception {
return stub.getAppsAuthorizedByUser();
}
public OAuthRevocationResponseDTO revokeAuthzForAppsByRessourceOwner(OAuthRevocationRequestDTO reqDTO)
throws Exception {
return stub.revokeAuthzForAppsByResoureOwner(reqDTO);
}
public boolean isPKCESupportedEnabled() throws Exception {
return stub.isPKCESupportEnabled();
}
/**
* Check whether hashing oauth keys (consumer secret, access token, refresh token and authorization code)
* configuration is disabled or not in identity.xml file.
*
* @return Whether hash feature is disabled or not.
* @throws Exception Error while getting the oAuth configuration.
*/
public boolean isHashDisabled() throws Exception {
return stub.isHashDisabled();
}
public String[] getAllowedOAuthGrantTypes() throws Exception {
if (allowedGrantTypes == null) {
allowedGrantTypes = stub.getAllowedGrantTypes();
}
return allowedGrantTypes;
}
public void regenerateSecretKey(String consumerkey) throws Exception {
stub.updateOauthSecretKey(consumerkey);
}
/**
* Regenerate consumer secret for the application and retrieve application details.
*
* @param consumerKey Consumer key for the application.
* @return OAuthConsumerAppDTO oAuth application details.
* @throws Exception Error while regenerating the consumer secret.
*/
public OAuthConsumerAppDTO regenerateAndRetrieveOauthSecretKey(String consumerKey) throws Exception {
return stub.updateAndRetrieveOauthSecretKey(consumerKey);
}
public String getOauthApplicationState(String consumerKey) throws Exception {
return stub.getOauthApplicationState(consumerKey);
}
public void updateOauthApplicationState(String consumerKey, String newState) throws Exception {
stub.updateConsumerAppState(consumerKey, newState);
}
public OAuthTokenExpiryTimeDTO getOAuthTokenExpiryTimeDTO() throws RemoteException {
return stub.getTokenExpiryTimes();
}
/**
* To add oidc scopes and claims
*
* @param scope an OIDC scope
* @throws RemoteException if an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when adding scopes or claims
*/
public void addScope(String scope, String[] claims) throws RemoteException,
OAuthAdminServiceIdentityOAuthAdminException {
stub.addScope(scope, claims);
}
/**
* To retrieve all persisted oidc scopes with mapped claims.
*
* @return all persisted scopes and claims
* @throws RemoteException if an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when loading scopes and claims.
*/
public ScopeDTO[] getScopes() throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getScopes();
}
/**
* To retrieve all persisted oidc scopes.
*
* @return list of scopes persisted.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when loading oidc scopes.
* @throws RemoteException if an exception occured during remote call.
*/
public String[] getScopeNames() throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getScopeNames();
}
/**
* To retrieve oidc claims mapped to an oidc scope.
*
* @param scope scope name
* @return list of claims which are mapped to the oidc scope.
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs when lading oidc claims.
* @throws RemoteException if an exception occured during remote call.
*/
public String[] getClaims(String scope) throws OAuthAdminServiceIdentityOAuthAdminException,
RemoteException {
return stub.getClaims(scope);
}
/**
* To load scope id.
*
* @param scope scope name
* @return oidc scope id
* @throws OAuthAdminServiceIdentityOAuthAdminException if an error occurs while loading scope id.
* @throws RemoteException if an exception occured during remote call.
*/
public boolean isScopeExist(String scope) throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException {
return stub.isScopeExist(scope);
}
/**
* To remove persisted scopes and claims.
*
* @param scope
* @throws OAuthAdminServiceIdentityOAuthAdminException If an error occurs when deleting scopes and claims.
* @throws RemoteException If an exception occured during remote call.
*/
public void deleteScope(String scope)
throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException {
stub.deleteScope(scope);
}
/**
* To add new claims for an existing scope.
*
* @param scope scope name
* @param addClaims addClaims
* @throws RemoteException If an exception occured during remote call.
* @throws OAuthAdminServiceIdentityOAuthAdminException If an error occurs when adding new claims for scope.
*/
public void updateScope(String scope, String[] addClaims, String[] deleteClaims) throws RemoteException,
OAuthAdminServiceIdentityOAuthAdminException {
stub.updateScope(scope, addClaims, deleteClaims);
}
/**
* Get the registered scope validators from OAuth server configuration file.
*
* @return list of string containing simple names of the registered validator class
* @throws RemoteException exception occured during remote call
*/
public String[] getAllowedScopeValidators() throws RemoteException {
if (scopeValidators == null) {
scopeValidators = stub.getAllowedScopeValidators();
if (scopeValidators == null) {
scopeValidators = new String[0];
}
}
return scopeValidators;
}
/**
* Get the registered oauth token types from OAuth server configuration file.
*
* @return List of supported oauth token types
* @throws RemoteException exception occured during remote call
*/
public String[] getSupportedTokenTypes() throws RemoteException {
if (stub.getSupportedTokenTypes() != null) {
supportedTokenTypes = stub.getSupportedTokenTypes();
}
return supportedTokenTypes;
}
/**
* Return supported algorithms read from identity.xml configuration file.
*
* @return OAuthIDTokenAlgorithmDTO object.
* @throws RemoteException
*/
public OAuthIDTokenAlgorithmDTO getSupportedIDTokenAlgorithms() throws RemoteException {
return stub.getSupportedIDTokenAlgorithms();
}
/**
* Return renew refresh token property value read from identity.xml configuration file.
*
* @return boolean renew refresh token property value
* @throws RemoteException
*/
public boolean isRefreshTokenRenewalEnabled() throws RemoteException {
return stub.isRefreshTokenRenewalEnabled();
}
/**
* Get supported token bindings metadata.
*
* @return Array of TokenBindingMetaDataDTOs.
* @throws RemoteException remote exception.
*/
public TokenBindingMetaDataDTO[] getSupportedTokenBindingsMetaData() throws RemoteException {
return stub.getSupportedTokenBindingsMetaData();
}
}
| 12,591
| 0.703042
| 0.700739
| 351
| 34.871796
| 34.244022
| 116
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.253561
| false
| false
|
13
|
1c3e20e64e4184bb82a5a04db8f4d2bee0c8d6f2
| 4,294,967,362,008
|
a8164e7eec0987604fbbdc2675fd5da2495fe2da
|
/src/lessons/lesson2/CustomShop.java
|
5ea5e04a9029666429ba04756d403d73d8a8038d
|
[] |
no_license
|
TarasLesh/MyFirstJavaProject
|
https://github.com/TarasLesh/MyFirstJavaProject
|
c1de55cb222bb078bb7cb17c9a21bf1d7ab178d3
|
99ffce0ef5fb982f50ffd89882bff3da788341b5
|
refs/heads/master
| 2022-11-12T03:57:17.154000
| 2020-07-09T13:49:11
| 2020-07-09T13:49:11
| 266,579,326
| 0
| 0
| null | false
| 2020-07-09T13:58:43
| 2020-05-24T16:21:54
| 2020-07-09T13:49:16
| 2020-07-09T13:57:24
| 46
| 0
| 0
| 0
|
Java
| false
| false
|
package lessons.lesson2;
//5. Створити клас Ательє, який має полем масив об'єктів Одяг (тобто в ньому можуть бути об'єкти усіх класів-нащадків),
// та 2 методи - чоловічий вибір (повертає увесь ЧОЛОВІЧИЙ одяг (підказка: instanceof оператор поможе))
// та жіночий вибір (повертає увесь ЖІНОЧИЙ одяг).
public class CustomShop {
private Clothes[] clothes = new Clothes[10];
// через Clothes
public Clothes[] womanClothes() {
Clothes[] womanClothes = new Clothes[clothes.length];
int i = 0;
for (Clothes clothe : clothes) {
if (clothe instanceof WomanClothes) {
womanClothes[i] = clothe;
i++;
}
}
return womanClothes;
}
// через ManClothes
public ManClothes[] manClothes() {
ManClothes[] manClothes = new ManClothes[clothes.length];
int i = 0;
for (Clothes clothe : clothes) {
if (clothe instanceof ManClothes) {
manClothes[i] = (ManClothes) clothe;
i++;
}
}
return manClothes;
}
}
|
UTF-8
|
Java
| 1,315
|
java
|
CustomShop.java
|
Java
|
[
{
"context": "package lessons.lesson2;\n\n//5. Створити клас Ательє, який має полем масив об'єктів Одяг (тобто в ньом",
"end": 51,
"score": 0.7972862720489502,
"start": 45,
"tag": "NAME",
"value": "Ательє"
}
] | null |
[] |
package lessons.lesson2;
//5. Створити клас Ательє, який має полем масив об'єктів Одяг (тобто в ньому можуть бути об'єкти усіх класів-нащадків),
// та 2 методи - чоловічий вибір (повертає увесь ЧОЛОВІЧИЙ одяг (підказка: instanceof оператор поможе))
// та жіночий вибір (повертає увесь ЖІНОЧИЙ одяг).
public class CustomShop {
private Clothes[] clothes = new Clothes[10];
// через Clothes
public Clothes[] womanClothes() {
Clothes[] womanClothes = new Clothes[clothes.length];
int i = 0;
for (Clothes clothe : clothes) {
if (clothe instanceof WomanClothes) {
womanClothes[i] = clothe;
i++;
}
}
return womanClothes;
}
// через ManClothes
public ManClothes[] manClothes() {
ManClothes[] manClothes = new ManClothes[clothes.length];
int i = 0;
for (Clothes clothe : clothes) {
if (clothe instanceof ManClothes) {
manClothes[i] = (ManClothes) clothe;
i++;
}
}
return manClothes;
}
}
| 1,315
| 0.585895
| 0.579566
| 39
| 27.358974
| 27.233545
| 119
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.358974
| false
| false
|
13
|
5b417c8fd2541df343c1d74d34d29f57ed8c3051
| 3,779,571,222,491
|
6fbededa7fb439fc9cf660391067ffe9bd03fcca
|
/app/src/main/java/com/filenber/chainshop/personal_profile/Business_Model.java
|
3accfb39f2bfb03102bc1c32eb62ffed80ba3e10
|
[] |
no_license
|
dawitephrem565/ChainShop
|
https://github.com/dawitephrem565/ChainShop
|
13c80b3c561bb079f7071c5ade13160e76f016f8
|
cdf67adc48633fe517de6518e5e366c9b3718e70
|
refs/heads/master
| 2023-03-31T03:57:31.738000
| 2021-03-19T11:07:51
| 2021-03-19T11:07:51
| 349,392,974
| 0
| 0
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.filenber.chainshop.personal_profile;
public class Business_Model {
String Username;
String Qoute_Descr;
String Profile_Img;
public Business_Model() {
}
public Business_Model(String username, String qoute_Descr, String profile_Img) {
Username = username;
Qoute_Descr = qoute_Descr;
Profile_Img = profile_Img;
}
public String getUsername() {
return Username;
}
public void setUsername(String username) {
Username = username;
}
public String getQoute_Descr() {
return Qoute_Descr;
}
public void setQoute_Descr(String qoute_Descr) {
Qoute_Descr = qoute_Descr;
}
public String getProfile_Img() {
return Profile_Img;
}
public void setProfile_Img(String profile_Img) {
Profile_Img = profile_Img;
}
}
|
UTF-8
|
Java
| 789
|
java
|
Business_Model.java
|
Java
|
[
{
"context": " qoute_Descr, String profile_Img) {\n Username = username;\n Qoute_Descr = qoute_Descr;\n Profile_Img =",
"end": 284,
"score": 0.9821125864982605,
"start": 276,
"tag": "USERNAME",
"value": "username"
},
{
"context": "void setUsername(String username) {\n Username = username;\n }\n\n public String getQoute_Descr() {\n retu",
"end": 479,
"score": 0.6280726790428162,
"start": 471,
"tag": "USERNAME",
"value": "username"
}
] | null |
[] |
package com.filenber.chainshop.personal_profile;
public class Business_Model {
String Username;
String Qoute_Descr;
String Profile_Img;
public Business_Model() {
}
public Business_Model(String username, String qoute_Descr, String profile_Img) {
Username = username;
Qoute_Descr = qoute_Descr;
Profile_Img = profile_Img;
}
public String getUsername() {
return Username;
}
public void setUsername(String username) {
Username = username;
}
public String getQoute_Descr() {
return Qoute_Descr;
}
public void setQoute_Descr(String qoute_Descr) {
Qoute_Descr = qoute_Descr;
}
public String getProfile_Img() {
return Profile_Img;
}
public void setProfile_Img(String profile_Img) {
Profile_Img = profile_Img;
}
}
| 789
| 0.684411
| 0.684411
| 41
| 18.243902
| 18.90255
| 82
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 0.365854
| false
| false
|
13
|
1ac0a96fd2996d31bf37564d60526ea42a21695b
| 25,013,889,586,548
|
04c8e7c42ae3b798e820b721b84f0eb582fab8aa
|
/src/main/java/com/mosso/deimos/common/web/springmvc/PlatformMappingExceptionResolver.java
|
29f03f61f9ae6d6e41009828ae21532203912488
|
[] |
no_license
|
sunnykaka/deimos
|
https://github.com/sunnykaka/deimos
|
2c1cfcf85f5fc7386020cf8ad50ad8ee8059a997
|
0c5389ea9953e130fdd054511717a5cad5ca815f
|
refs/heads/master
| 2021-01-19T13:46:29.175000
| 2012-02-15T11:16:20
| 2012-02-15T11:16:20
| 2,853,951
| 9
| 5
| null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.mosso.deimos.common.web.springmvc;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
/**
* @author liubin
*
*/
public class PlatformMappingExceptionResolver extends SimpleMappingExceptionResolver {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 记录错误日志
*/
@Override
protected ModelAndView doResolveException(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
if(ex != null) {
logger.error(ex.getMessage(), ex);
}
return super.doResolveException(request, response, handler, ex);
}
}
|
UTF-8
|
Java
| 831
|
java
|
PlatformMappingExceptionResolver.java
|
Java
|
[
{
"context": "er.SimpleMappingExceptionResolver;\n\n/**\n * @author liubin\n *\n */\npublic class PlatformMappingExceptionResol",
"end": 353,
"score": 0.9993817806243896,
"start": 347,
"tag": "USERNAME",
"value": "liubin"
}
] | null |
[] |
package com.mosso.deimos.common.web.springmvc;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
/**
* @author liubin
*
*/
public class PlatformMappingExceptionResolver extends SimpleMappingExceptionResolver {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 记录错误日志
*/
@Override
protected ModelAndView doResolveException(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
if(ex != null) {
logger.error(ex.getMessage(), ex);
}
return super.doResolveException(request, response, handler, ex);
}
}
| 831
| 0.781441
| 0.778999
| 33
| 23.818182
| 27.293528
| 86
| false
| false
| 0
| 0
| 0
| 0
| 0
| 0
| 1.181818
| false
| false
|
13
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.