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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
70218e7e9e51d9190e4180a6fbc89cb2bf78e054 | 3,315,714,776,790 | 6ca29e31058f21613b47ae30f52750f54a12ed74 | /src/chapterThreeExercises/BikeApplication.java | 3f7d2dc4a4fde6aab4326d99b52d4671731aa4c8 | [] | no_license | isholajanet/setAndGet | https://github.com/isholajanet/setAndGet | a11a1095d23dbc211c27f9b559c2e0bc02fd0efd | ddd72f6e40d858e8e65826f1a80b736257f4f9ca | refs/heads/main | 2023-07-02T15:16:43.611000 | 2021-08-04T01:34:53 | 2021-08-04T01:34:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package chapterThreeExercises;
import java.util.Scanner;
public class BikeApplication {
public static void main(String[] args) {
Bike okada = new Bike();
int userInput;
do {
String prompt = """
Enter 1 for Turn on
Enter 2 for Accelerate
Enter 3 for Decelerate
Enter 4 to Turn Off / Exit Application
""";
Scanner inputCollector = new Scanner(System.in);
System.out.println(prompt);
userInput = inputCollector.nextInt();
switch (userInput) {
case 1:
okada.setOn(true);
System.out.println("Bike is On");
break;
case 2:
okada.speedUp();
System.out.println("Bike is On");
System.out.println("Current Speed" + okada.getSpeedInKmPerHour());
System.out.println("Current gear" + okada.getCurrentGearNumber());
break;
case 3:
okada.slowDown();
System.out.println("Bike is on");
System.out.println("Current speed" + okada.getSpeedInKmPerHour());
System.out.println("Current gear" + okada.getCurrentGearNumber());
break;
case 4:
okada.setOn(false);
break;
}
}while (userInput != 4);
}
}
| UTF-8 | Java | 1,450 | java | BikeApplication.java | Java | [] | null | [] | package chapterThreeExercises;
import java.util.Scanner;
public class BikeApplication {
public static void main(String[] args) {
Bike okada = new Bike();
int userInput;
do {
String prompt = """
Enter 1 for Turn on
Enter 2 for Accelerate
Enter 3 for Decelerate
Enter 4 to Turn Off / Exit Application
""";
Scanner inputCollector = new Scanner(System.in);
System.out.println(prompt);
userInput = inputCollector.nextInt();
switch (userInput) {
case 1:
okada.setOn(true);
System.out.println("Bike is On");
break;
case 2:
okada.speedUp();
System.out.println("Bike is On");
System.out.println("Current Speed" + okada.getSpeedInKmPerHour());
System.out.println("Current gear" + okada.getCurrentGearNumber());
break;
case 3:
okada.slowDown();
System.out.println("Bike is on");
System.out.println("Current speed" + okada.getSpeedInKmPerHour());
System.out.println("Current gear" + okada.getCurrentGearNumber());
break;
case 4:
okada.setOn(false);
break;
}
}while (userInput != 4);
}
}
| 1,450 | 0.5 | 0.493793 | 43 | 32.720932 | 21.776161 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.55814 | false | false | 10 |
6df8743aff001edba8a92120c1d578246f80e521 | 22,256,520,533,126 | 6baf1fe00541560788e78de5244ae17a7a2b375a | /hollywood/com.oculus.browser-base/sources/defpackage/AbstractC3519lF.java | a5de120d8b851b72200c9b5ccf9a0ea5a03d40ed | [] | no_license | phwd/quest-tracker | https://github.com/phwd/quest-tracker | 286e605644fc05f00f4904e51f73d77444a78003 | 3d46fbb467ba11bee5827f7cae7dfeabeb1fd2ba | refs/heads/main | 2023-03-29T20:33:10.959000 | 2021-04-10T22:14:11 | 2021-04-10T22:14:11 | 357,185,040 | 4 | 2 | null | true | 2021-04-12T12:28:09 | 2021-04-12T12:28:08 | 2021-04-10T22:15:44 | 2021-04-10T22:15:39 | 116,441 | 0 | 0 | 0 | null | false | false | package defpackage;
/* renamed from: lF reason: default package and case insensitive filesystem */
/* compiled from: chromium-OculusBrowser.apk-stable-281887347 */
public abstract class AbstractC3519lF {
/* renamed from: a reason: collision with root package name */
public static final AbstractC2630g30 f10334a = new C2323eF();
}
| UTF-8 | Java | 343 | java | AbstractC3519lF.java | Java | [] | null | [] | package defpackage;
/* renamed from: lF reason: default package and case insensitive filesystem */
/* compiled from: chromium-OculusBrowser.apk-stable-281887347 */
public abstract class AbstractC3519lF {
/* renamed from: a reason: collision with root package name */
public static final AbstractC2630g30 f10334a = new C2323eF();
}
| 343 | 0.755102 | 0.673469 | 9 | 37.111111 | 30.802036 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 10 |
b7cd4869e449c45b425611752b245b9e2d590783 | 27,367,531,655,492 | ea6be046b588cb78619d6c6bff69f273deafbeb8 | /toasthub-security/src/main/java/org/toasthub/security/application/ApplicationDaoImpl.java | 48f94d4c2baa78e7034c71cb6119524138d05948 | [] | no_license | seufster71/toasthub-security | https://github.com/seufster71/toasthub-security | 8c505e0244c4964f38a844caa8dfe86014632eea | d13195d3346b021984b3b1814c9a24023e0d7f15 | refs/heads/develop | 2023-05-26T16:15:52.570000 | 2022-10-21T15:24:50 | 2022-10-21T15:24:50 | 149,046,051 | 0 | 0 | null | false | 2022-10-21T15:25:29 | 2018-09-16T23:52:34 | 2022-01-16T15:44:21 | 2022-10-21T15:25:28 | 192 | 0 | 0 | 0 | Java | false | false | /*
* Copyright (C) 2016 The ToastHub Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.toasthub.security.application;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.toasthub.core.common.EntityManagerSecuritySvc;
import org.toasthub.core.common.UtilSvc;
import org.toasthub.core.general.model.GlobalConstant;
import org.toasthub.core.general.model.RestRequest;
import org.toasthub.core.general.model.RestResponse;
import org.toasthub.security.model.Application;
@Repository("ApplicationDao")
@Transactional("TransactionManagerSecurity")
public class ApplicationDaoImpl implements ApplicationDao {
@Autowired
protected EntityManagerSecuritySvc entityManagerSecuritySvc;
@Autowired
protected UtilSvc utilSvc;
@Override
public void items(RestRequest request, RestResponse response) throws Exception {
String queryStr = "SELECT DISTINCT a FROM Application AS a JOIN FETCH a.title AS t JOIN FETCH t.langTexts as lt WHERE lt.lang =:lang ";
if (request.containsParam(GlobalConstant.ACTIVE)) {
queryStr += "a.active =:active ";
}
// search
ArrayList<LinkedHashMap<String,String>> searchCriteria = null;
if (request.containsParam(GlobalConstant.SEARCHCRITERIA) && !request.getParam(GlobalConstant.SEARCHCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.SEARCHCRITERIA) instanceof Map) {
searchCriteria = new ArrayList<>();
searchCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.SEARCHCRITERIA));
} else {
searchCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.SEARCHCRITERIA);
}
// Loop through all the criteria
boolean or = false;
String lookupStr = "";
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (or) { lookupStr += " OR "; }
lookupStr += "lt.lang =:lang AND lt.text LIKE :titleValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (or) { lookupStr += " OR "; }
lookupStr += "a.code LIKE :codeValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (or) { lookupStr += " OR "; }
lookupStr += "a.active LIKE :statusValue";
or = true;
}
}
}
if (!"".equals(lookupStr)) {
queryStr += " AND ( " + lookupStr + " ) ";
}
}
// order by
ArrayList<LinkedHashMap<String,String>> orderCriteria = null;
StringBuilder orderItems = new StringBuilder();
if (request.containsParam(GlobalConstant.ORDERCRITERIA) && !request.getParam(GlobalConstant.ORDERCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.ORDERCRITERIA) instanceof Map) {
orderCriteria = new ArrayList<>();
orderCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.ORDERCRITERIA));
} else {
orderCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.ORDERCRITERIA);
}
// Loop through all the criteria
boolean comma = false;
for (LinkedHashMap<String,String> item : orderCriteria) {
if (item.containsKey(GlobalConstant.ORDERCOLUMN) && item.containsKey(GlobalConstant.ORDERDIR)) {
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (comma) { orderItems.append(","); }
orderItems.append("lt.text ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (comma) { orderItems.append(","); }
orderItems.append("a.code ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (comma) { orderItems.append(","); }
orderItems.append("a.active ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
}
}
}
if (!"".equals(orderItems.toString())) {
queryStr += " ORDER BY ".concat(orderItems.toString());
} else {
// default order
queryStr += " ORDER BY lt.text";
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (searchCriteria != null){
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
query.setParameter("titleValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
query.setParameter("codeValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if ("active".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", true);
} else if ("disabled".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", false);
}
}
}
}
}
if (request.containsParam(GlobalConstant.LISTLIMIT) && (Integer) request.getParam(GlobalConstant.LISTLIMIT) != 0){
query.setFirstResult((Integer) request.getParam(GlobalConstant.LISTSTART));
query.setMaxResults((Integer) request.getParam(GlobalConstant.LISTLIMIT));
}
List<?> applications = query.getResultList();
response.addParam(GlobalConstant.ITEMS, (List<Application>) applications);
}
@Override
public void itemCount(RestRequest request, RestResponse response) throws Exception {
String queryStr = "SELECT COUNT(DISTINCT a) FROM Application as a JOIN a.title AS t JOIN t.langTexts as lt ";
boolean and = false;
if (request.containsParam(GlobalConstant.ACTIVE)) {
if (!and) { queryStr += " WHERE "; }
queryStr += "a.active =:active ";
and = true;
}
ArrayList<LinkedHashMap<String,String>> searchCriteria = null;
if (request.containsParam(GlobalConstant.SEARCHCRITERIA) && !request.getParam(GlobalConstant.SEARCHCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.SEARCHCRITERIA) instanceof Map) {
searchCriteria = new ArrayList<>();
searchCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.SEARCHCRITERIA));
} else {
searchCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.SEARCHCRITERIA);
}
// Loop through all the criteria
boolean or = false;
String lookupStr = "";
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (or) { lookupStr += " OR "; }
lookupStr += "lt.lang =:lang AND lt.text LIKE :titleValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (or) { lookupStr += " OR "; }
lookupStr += "m.code LIKE :codeValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (or) { lookupStr += " OR "; }
lookupStr += "m.active LIKE :statusValue";
or = true;
}
}
}
if (!"".equals(lookupStr)) {
if (!and) {
queryStr += " WHERE ( " + lookupStr + " ) ";
} else {
queryStr += " AND ( " + lookupStr + " ) ";
}
}
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (searchCriteria != null){
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
query.setParameter("titleValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
query.setParameter("codeValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if ("active".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", true);
} else if ("disabled".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", false);
}
}
}
}
}
Long count = (Long) query.getSingleResult();
if (count == null){
count = 0l;
}
response.addParam(GlobalConstant.ITEMCOUNT, count);
}
@Override
public void item(RestRequest request, RestResponse response) throws Exception {
if (request.containsParam(GlobalConstant.ITEMID) && !"".equals(request.getParam(GlobalConstant.ITEMID))) {
String queryStr = "SELECT a FROM Application AS a JOIN FETCH a.title AS t JOIN FETCH t.langTexts WHERE a.id =:id";
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("id", request.getParamLong(GlobalConstant.ITEMID));
Application application = (Application) query.getSingleResult();
response.addParam(GlobalConstant.ITEM, application);
} else {
utilSvc.addStatus(RestResponse.ERROR, RestResponse.ACTIONFAILED, "Missing ID", response);
}
}
@Override
public void selectList(RestRequest request, RestResponse response) throws Exception {
List<Map<String,Object>> applications = new ArrayList<Map<String,Object>>();
String queryStr = "SELECT a.id, lt.text, t.defaultText FROM Application AS a JOIN a.title AS t JOIN t.langTexts as lt WHERE lt.lang =:lang ";
if (request.containsParam(GlobalConstant.ACTIVE)) {
queryStr += "a.active =:active ";
}
if (request.containsParam(GlobalConstant.SEARCHVALUE) && !request.getParam(GlobalConstant.SEARCHVALUE).equals("")){
queryStr += "lt.lang =:lang AND lt.text LIKE :searchValue";
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (request.containsParam(GlobalConstant.SEARCHVALUE) && !request.getParam(GlobalConstant.SEARCHVALUE).equals("")){
query.setParameter("searchValue", "%"+((String)request.getParam(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
@SuppressWarnings("unchecked")
List<Object[]> results = query.getResultList();
for (Object[] result : results) {
Map<String,Object> r = new HashMap<String,Object>();
r.put("value", result[0]);
r.put("text", result[1]);
r.put("defaultText", result[2]);
applications.add(r);
}
response.addParam("applicationSelectList", applications);
}
}
| UTF-8 | Java | 12,783 | java | ApplicationDaoImpl.java | Java | [] | null | [] | /*
* Copyright (C) 2016 The ToastHub Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.toasthub.security.application;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.toasthub.core.common.EntityManagerSecuritySvc;
import org.toasthub.core.common.UtilSvc;
import org.toasthub.core.general.model.GlobalConstant;
import org.toasthub.core.general.model.RestRequest;
import org.toasthub.core.general.model.RestResponse;
import org.toasthub.security.model.Application;
@Repository("ApplicationDao")
@Transactional("TransactionManagerSecurity")
public class ApplicationDaoImpl implements ApplicationDao {
@Autowired
protected EntityManagerSecuritySvc entityManagerSecuritySvc;
@Autowired
protected UtilSvc utilSvc;
@Override
public void items(RestRequest request, RestResponse response) throws Exception {
String queryStr = "SELECT DISTINCT a FROM Application AS a JOIN FETCH a.title AS t JOIN FETCH t.langTexts as lt WHERE lt.lang =:lang ";
if (request.containsParam(GlobalConstant.ACTIVE)) {
queryStr += "a.active =:active ";
}
// search
ArrayList<LinkedHashMap<String,String>> searchCriteria = null;
if (request.containsParam(GlobalConstant.SEARCHCRITERIA) && !request.getParam(GlobalConstant.SEARCHCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.SEARCHCRITERIA) instanceof Map) {
searchCriteria = new ArrayList<>();
searchCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.SEARCHCRITERIA));
} else {
searchCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.SEARCHCRITERIA);
}
// Loop through all the criteria
boolean or = false;
String lookupStr = "";
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (or) { lookupStr += " OR "; }
lookupStr += "lt.lang =:lang AND lt.text LIKE :titleValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (or) { lookupStr += " OR "; }
lookupStr += "a.code LIKE :codeValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (or) { lookupStr += " OR "; }
lookupStr += "a.active LIKE :statusValue";
or = true;
}
}
}
if (!"".equals(lookupStr)) {
queryStr += " AND ( " + lookupStr + " ) ";
}
}
// order by
ArrayList<LinkedHashMap<String,String>> orderCriteria = null;
StringBuilder orderItems = new StringBuilder();
if (request.containsParam(GlobalConstant.ORDERCRITERIA) && !request.getParam(GlobalConstant.ORDERCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.ORDERCRITERIA) instanceof Map) {
orderCriteria = new ArrayList<>();
orderCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.ORDERCRITERIA));
} else {
orderCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.ORDERCRITERIA);
}
// Loop through all the criteria
boolean comma = false;
for (LinkedHashMap<String,String> item : orderCriteria) {
if (item.containsKey(GlobalConstant.ORDERCOLUMN) && item.containsKey(GlobalConstant.ORDERDIR)) {
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (comma) { orderItems.append(","); }
orderItems.append("lt.text ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (comma) { orderItems.append(","); }
orderItems.append("a.code ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
if (item.get(GlobalConstant.ORDERCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (comma) { orderItems.append(","); }
orderItems.append("a.active ").append(item.get(GlobalConstant.ORDERDIR));
comma = true;
}
}
}
}
if (!"".equals(orderItems.toString())) {
queryStr += " ORDER BY ".concat(orderItems.toString());
} else {
// default order
queryStr += " ORDER BY lt.text";
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (searchCriteria != null){
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
query.setParameter("titleValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
query.setParameter("codeValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if ("active".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", true);
} else if ("disabled".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", false);
}
}
}
}
}
if (request.containsParam(GlobalConstant.LISTLIMIT) && (Integer) request.getParam(GlobalConstant.LISTLIMIT) != 0){
query.setFirstResult((Integer) request.getParam(GlobalConstant.LISTSTART));
query.setMaxResults((Integer) request.getParam(GlobalConstant.LISTLIMIT));
}
List<?> applications = query.getResultList();
response.addParam(GlobalConstant.ITEMS, (List<Application>) applications);
}
@Override
public void itemCount(RestRequest request, RestResponse response) throws Exception {
String queryStr = "SELECT COUNT(DISTINCT a) FROM Application as a JOIN a.title AS t JOIN t.langTexts as lt ";
boolean and = false;
if (request.containsParam(GlobalConstant.ACTIVE)) {
if (!and) { queryStr += " WHERE "; }
queryStr += "a.active =:active ";
and = true;
}
ArrayList<LinkedHashMap<String,String>> searchCriteria = null;
if (request.containsParam(GlobalConstant.SEARCHCRITERIA) && !request.getParam(GlobalConstant.SEARCHCRITERIA).equals("")) {
if (request.getParam(GlobalConstant.SEARCHCRITERIA) instanceof Map) {
searchCriteria = new ArrayList<>();
searchCriteria.add((LinkedHashMap<String, String>) request.getParam(GlobalConstant.SEARCHCRITERIA));
} else {
searchCriteria = (ArrayList<LinkedHashMap<String, String>>) request.getParam(GlobalConstant.SEARCHCRITERIA);
}
// Loop through all the criteria
boolean or = false;
String lookupStr = "";
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
if (or) { lookupStr += " OR "; }
lookupStr += "lt.lang =:lang AND lt.text LIKE :titleValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
if (or) { lookupStr += " OR "; }
lookupStr += "m.code LIKE :codeValue";
or = true;
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if (or) { lookupStr += " OR "; }
lookupStr += "m.active LIKE :statusValue";
or = true;
}
}
}
if (!"".equals(lookupStr)) {
if (!and) {
queryStr += " WHERE ( " + lookupStr + " ) ";
} else {
queryStr += " AND ( " + lookupStr + " ) ";
}
}
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (searchCriteria != null){
for (LinkedHashMap<String,String> item : searchCriteria) {
if (item.containsKey(GlobalConstant.SEARCHVALUE) && !"".equals(item.get(GlobalConstant.SEARCHVALUE)) && item.containsKey(GlobalConstant.SEARCHCOLUMN)) {
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_NAME")){
query.setParameter("titleValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_CODE")){
query.setParameter("codeValue", "%"+((String)item.get(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
if (item.get(GlobalConstant.SEARCHCOLUMN).equals("SYSTEM_APPLICATION_TABLE_STATUS")){
if ("active".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", true);
} else if ("disabled".equalsIgnoreCase((String)item.get(GlobalConstant.SEARCHVALUE))) {
query.setParameter("statusValue", false);
}
}
}
}
}
Long count = (Long) query.getSingleResult();
if (count == null){
count = 0l;
}
response.addParam(GlobalConstant.ITEMCOUNT, count);
}
@Override
public void item(RestRequest request, RestResponse response) throws Exception {
if (request.containsParam(GlobalConstant.ITEMID) && !"".equals(request.getParam(GlobalConstant.ITEMID))) {
String queryStr = "SELECT a FROM Application AS a JOIN FETCH a.title AS t JOIN FETCH t.langTexts WHERE a.id =:id";
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("id", request.getParamLong(GlobalConstant.ITEMID));
Application application = (Application) query.getSingleResult();
response.addParam(GlobalConstant.ITEM, application);
} else {
utilSvc.addStatus(RestResponse.ERROR, RestResponse.ACTIONFAILED, "Missing ID", response);
}
}
@Override
public void selectList(RestRequest request, RestResponse response) throws Exception {
List<Map<String,Object>> applications = new ArrayList<Map<String,Object>>();
String queryStr = "SELECT a.id, lt.text, t.defaultText FROM Application AS a JOIN a.title AS t JOIN t.langTexts as lt WHERE lt.lang =:lang ";
if (request.containsParam(GlobalConstant.ACTIVE)) {
queryStr += "a.active =:active ";
}
if (request.containsParam(GlobalConstant.SEARCHVALUE) && !request.getParam(GlobalConstant.SEARCHVALUE).equals("")){
queryStr += "lt.lang =:lang AND lt.text LIKE :searchValue";
}
Query query = entityManagerSecuritySvc.getInstance().createQuery(queryStr);
query.setParameter("lang",request.getParam(GlobalConstant.LANG));
if (request.containsParam(GlobalConstant.ACTIVE)) {
query.setParameter("active", (Boolean) request.getParam(GlobalConstant.ACTIVE));
}
if (request.containsParam(GlobalConstant.SEARCHVALUE) && !request.getParam(GlobalConstant.SEARCHVALUE).equals("")){
query.setParameter("searchValue", "%"+((String)request.getParam(GlobalConstant.SEARCHVALUE)).toLowerCase()+"%");
}
@SuppressWarnings("unchecked")
List<Object[]> results = query.getResultList();
for (Object[] result : results) {
Map<String,Object> r = new HashMap<String,Object>();
r.put("value", result[0]);
r.put("text", result[1]);
r.put("defaultText", result[2]);
applications.add(r);
}
response.addParam("applicationSelectList", applications);
}
}
| 12,783 | 0.70539 | 0.704373 | 317 | 39.324921 | 38.125046 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.378549 | false | false | 10 |
516063ac0d6b8efacee233d5cc86d7f6737894f0 | 7,507,602,902,520 | afe1842f7c0bdf2a244b0877d17b8d6dc80da9b3 | /day0930/IfElseTest.java | 2fe979c23483ec9c34b976e041bb9c64f0ca1e77 | [] | no_license | envayu/javaStudy | https://github.com/envayu/javaStudy | 51a90d2c2e61b95c7ed1491ef1e54b437d100026 | 10fd77be7e87b4458516449f26f45d2714fe82a4 | refs/heads/main | 2023-08-03T20:44:56.960000 | 2021-09-30T03:09:39 | 2021-09-30T03:09:39 | 411,869,923 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | //연습)사용자한테 임의의 수N을 입력받아 N이 양수이면 그 수에 100을 더한값을 출력한 뒤 "작업종료"를 출력
//음수이면 그 수의 제곱을 출력한다음 "작업종료"를 출력
import java.util.Scanner;
class IfElseTest
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System. in);
int n;
System.out.print("n을 입력해주세요");
n = sc.nextInt();
if ( n >= 0)
System.out.print(n+100);
else
System.out.print(n*n);
System.out.print("작업종료");
}
}
| UHC | Java | 557 | java | IfElseTest.java | Java | [] | null | [] | //연습)사용자한테 임의의 수N을 입력받아 N이 양수이면 그 수에 100을 더한값을 출력한 뒤 "작업종료"를 출력
//음수이면 그 수의 제곱을 출력한다음 "작업종료"를 출력
import java.util.Scanner;
class IfElseTest
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System. in);
int n;
System.out.print("n을 입력해주세요");
n = sc.nextInt();
if ( n >= 0)
System.out.print(n+100);
else
System.out.print(n*n);
System.out.print("작업종료");
}
}
| 557 | 0.622871 | 0.605839 | 21 | 18.571428 | 16.386904 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.428571 | false | false | 10 |
72c6605e49d3b96b6504beb7996e2d0d6b464bc3 | 9,732,395,947,237 | 0fbc8e9d5b15f1515e8db216766f4288eacf06fa | /devtools-deps-eclipse/devtools-deps-eclipse-ui/src/cern/devtools/deps/eclipse/ui/tree/TreeBuilder.java | d12223420214b799369a8351723f5859d4a70b00 | [] | no_license | donat/cern-deps | https://github.com/donat/cern-deps | da187798105bb6b857944adb4248daa22427bb61 | 889a34bb5e5f4ee725484d1b40f00f1b429ba5e5 | refs/heads/master | 2020-05-15T12:11:34.336000 | 2013-06-09T18:07:28 | 2013-06-09T18:07:28 | 6,605,676 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /***********************************************************************************************************************
* © Copyright 2013 CERN. This software is distributed under the terms of the GNU General Public Licence version 3 (GPL
* Version 3), copied verbatim in the file "COPYING". In applying this licence, CERN does not waive the privileges and
* immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any
* jurisdiction.
*
* If you modify this Program, or any covered work, by linking or combining it with the Eclipse Integrated Development
* Environment Plugin libraries (or a modified version of these libraries), containing parts covered by the terms of EPL
* (Eclipse Public licence), the licensors of this Program grant you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination shall include the source code for the parts of
* Eclipse Integrated Development Environment Plugin libraries used as well as that of the covered work.
**********************************************************************************************************************/
package cern.devtools.deps.eclipse.ui.tree;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import cern.devtools.deps.domain.ApiClass;
import cern.devtools.deps.domain.CodeElement;
import cern.devtools.deps.domain.Dependency;
import cern.devtools.deps.domain.DependencyType;
import cern.devtools.deps.domain.Method;
import cern.devtools.deps.domain.Product;
import cern.devtools.deps.domain.TransitiveDependency;
import cern.devtools.deps.eclipse.ui.LoggingUtil;
import cern.devtools.deps.eclipse.ui.views.GroupingOptions;
public class TreeBuilder {
/**
* Builds the tree for the view.
*
* @param objectToAnalyse The queried object.
* @param dependencies The result set returned by the server.
* @param grouping
* @return The reference of the tree item, which is displayable by the treeViewer.
*
* @author Donat Csikos <dcsikos@cern.ch>
*/
public static TreeItem buildTree(CodeElement objectToAnalyse, Collection<Dependency> dependencies,
GroupingOptions grouping) {
// Create root node. This node won't be displayed.
TreeItem root = TreeItem.createNewNode(TreeItemType.ROOT, null);
// If no dependencies exist then only add the special NO_DEPENDENCIES node.
if (dependencies.size() == 0) {
TreeItem.createNewNode(TreeItemType.NO_DEPENDENCIES, root, objectToAnalyse);
}
// Else build the dependency tree.
else {
// Add a visible root which shows which item was queried for incoming dependencies.
TreeItem subRoot = TreeItem.createNewNode(TreeItemType.ROOT, root, objectToAnalyse);
buildTree(dependencies, subRoot, grouping);
}
// Return the root of the node hierarchy.
return root;
}
/**
* Builds The tree based on the grouping options.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTree(Collection<Dependency> dependencies, TreeItem root, GroupingOptions grouping) {
switch (grouping) {
case GROUP_BY_DEPENDENCY_TYPE:
buildTreeDepGrouped(dependencies, root);
break;
case GROUP_BY_PRODUCT:
buildTreeProductGrouped(dependencies, root);
break;
default:
throw new RuntimeException("No TreeBuilder strategy defined for: " + grouping);
}
}
/**
* Builds The tree with associated with the {@link GroupingOptions#GROUP_BY_DEPENDENCY_TYPE}.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTreeDepGrouped(Collection<Dependency> dependencies, TreeItem root) {
// Categorise dependencies by type to display.
Map<DependencyType, List<Dependency>> typedDeps = new HashMap<DependencyType, List<Dependency>>();
for (Dependency d : dependencies) {
List<Dependency> deps = typedDeps.get(d.getType());
if (deps == null) {
deps = new LinkedList<Dependency>();
typedDeps.put(d.getType(), deps);
}
deps.add(d);
}
// Add the dependencies to the tree by types.
for (DependencyType type : typedDeps.keySet()) {
// Subroot for each type of dependencies
TreeItem dependencyNode = TreeItem.createNewNode(TreeItemType.DEPENDENCY_TYPE, root, type);
// Gather the different package names from the result.
Set<String> packageSet = new HashSet<String>();
Set<ApiClass> apiClassSet = new HashSet<ApiClass>();
Set<Method> methodSet = new HashSet<Method>();
for (Dependency d : typedDeps.get(type)) {
CodeElement ce = d.getFrom();
if (ce instanceof ApiClass) {
ApiClass ac = (ApiClass) ce;
packageSet.add(ac.getPackageName());
apiClassSet.add(ac);
} else if (ce instanceof Method) {
Method m = (Method) ce;
packageSet.add(m.getApiClass().getPackageName());
methodSet.add(m);
} else if (ce instanceof Product) {
TreeItem.createNewNode(TreeItemType.PRODUCT, dependencyNode, ce);
} else {
throw new RuntimeException("Dependency contains a wrong element: " + ce);
}
}
// Put the sets to a list and sort it.
List<String> packageList = new LinkedList<String>(packageSet);
Collections.sort(packageList);
// Create a node for each package and cache it.
Map<String, TreeItem> packageNodeCache = new HashMap<String, TreeItem>();
for (String p : packageList) {
TreeItem subSubNode = TreeItem.createNewNode(TreeItemType.PACKAGE, dependencyNode, p);
packageNodeCache.put(p, subSubNode);
}
// Add the dependencies below the package nodes.
for (Dependency d : typedDeps.get(type)) {
// Reference for the node lies on the lowest level. Used for adding the transitive dependencies.
TreeItem leafNode = null;
if (d.getFrom() instanceof Method) {
Method m = (Method) d.getFrom();
// Find proper package node which will be the parent of the method.
TreeItem packageNode = packageNodeCache.get(m.getApiClass().getPackageName());
// Find if it is already added to the list
TreeItem classNode = null;
for (TreeItem ti : packageNode.getChildren()) {
ApiClassTreeItem acti = (ApiClassTreeItem) ti;
if (acti.getValue().equals(m.getApiClass())) {
classNode = ti;
break;
}
}
// If the class node is not yet added, then create it.
if (classNode == null) {
classNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, m.getApiClass(), "PRO");
}
// First add the container class below the package, then add the method itself as the leaf node.
leafNode = TreeItem.createNewNode(TreeItemType.METHOD, classNode, d.getFrom(), "PRO");
} else if (d.getFrom() instanceof ApiClass) {
ApiClass ac = (ApiClass) d.getFrom();
// Find proper package node which will be the parent of the class.
TreeItem packageNode = packageNodeCache.get(ac.getPackageName());
// Add the class node as the leaf node.
leafNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, d.getFrom(), "PRO");
} else if (d.getFrom() instanceof Product) {
} else {
throw new RuntimeException("Not legal type for this level of hierarchy: " + d.getFrom().getClass());
}
// If the current dependency is a transitive one, the build a subtree about the dependency structure
// using the previouslt defined leaf node as the new root.
if (d instanceof TransitiveDependency) {
buildTree(((TransitiveDependency) d).getTransitiveFrom(), leafNode,
GroupingOptions.GROUP_BY_DEPENDENCY_TYPE);
}
}
}
}
/**
* Builds The tree with associated with the {@link GroupingOptions#GROUP_BY_PRODUCT}.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTreeProductGrouped(Collection<Dependency> dependencies, TreeItem root) {
// Gather all product involved in the dependencies.
Set<Product> products = new HashSet<Product>();
Map<CodeElement, Dependency> dependencyCache = new HashMap<CodeElement, Dependency>();
for (Object dO : dependencies) {
Dependency d = (Dependency)dO;
CodeElement ce = d.getFrom();
dependencyCache.put(ce, d);
if (ApiClass.class.isAssignableFrom(ce.getClass())) {
products.add(((ApiClass) ce).getProduct());
} else if (Method.class.isAssignableFrom(ce.getClass())) {
products.add(((Method) ce).getApiClass().getProduct());
} else if (Product.class.isAssignableFrom(ce.getClass())) {
products.add((Product) ce);
} else {
// do not throw an exception, because we want the editor to stay intact.
LoggingUtil.warnAndLog("TreeItem type is not displayable " + ce.getClass(), new RuntimeException());
}
}
// Sort the products
List<Product> productList = new LinkedList<Product>(products);
Collections.sort(productList, new Comparator<Product>() {
@Override
public int compare(Product o1, Product o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (final Product p : productList) {
// Gather the different package names from the result.
Set<String> packageSet = new HashSet<String>();
for (ApiClass ac : p.getClasses()) {
packageSet.add(ac.getPackageName());
}
// Put the package to the list and sort it.
List<String> packageList = new LinkedList<String>(packageSet);
Collections.sort(packageList);
// Create product node.
TreeItem productNode = TreeItem.createNewNode(TreeItemType.PRODUCT, root, p);
// Create version nodes below and index them.
// Map<String, TreeItem> versionNodeCache = new HashMap<String, TreeItem>();
for (final String version : p.getVersions()) {
TreeItem versionNode = TreeItem.createNewNode(TreeItemType.VERSION, productNode, version);
// versionNodeCache.put(version, versionNode);
// Create a node for each package and cache it.
Map<String, TreeItem> packageNodeCache = new HashMap<String, TreeItem>();
for (String pkg : packageList) {
TreeItem packageNode = TreeItem.createNewNode(TreeItemType.PACKAGE, versionNode, pkg);
packageNodeCache.put(pkg, packageNode);
// for each package add all of the contained classes and methods
for (ApiClass ac : p.getClasses()) {
if (ac.getPackageName().equals(pkg) && ac.getVersions().contains(version)) {
// Create apiclass node if not exists.
TreeItem classNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, ac, version);
// If it is a transitive dependency, then recursively build the tree..
Dependency d = dependencyCache.get(ac);
if (d != null && d instanceof TransitiveDependency) {
TreeItem transRootNode = TreeItem.createNewNode(TreeItemType.ROOT, classNode, ac);
buildTreeProductGrouped(((TransitiveDependency) d).getTransitiveFrom(), transRootNode);
}
// Do the same with the method nodes.
for (Method m : ac.getMethods()) {
if (m.getVersions().contains(version)) {
TreeItem methodNode = TreeItem.createNewNode(TreeItemType.METHOD, classNode, m,
version);
d = dependencyCache.get(m);
if (d != null && d instanceof TransitiveDependency) {
TreeItem transRootNode = TreeItem.createNewNode(TreeItemType.ROOT, methodNode,
m);
buildTreeProductGrouped(((TransitiveDependency) d).getTransitiveFrom(),
transRootNode);
}
}
}
}
}
// if the current version does not contain any packages, then remove it
if (packageNode.getChildren().size() == 0) {
// Same as versionNode.getChildren().remove(packageNode);.
packageNode.getParent().getChildren().remove(packageNode);
}
}
}
}
}
}
| UTF-8 | Java | 14,537 | java | TreeBuilder.java | Java | [
{
"context": "playable by the treeViewer.\n * \n * @author Donat Csikos <dcsikos@cern.ch>\n */\n public static TreeI",
"end": 2252,
"score": 0.9977461695671082,
"start": 2240,
"tag": "NAME",
"value": "Donat Csikos"
},
{
"context": " treeViewer.\n * \n * @author... | null | [] | /***********************************************************************************************************************
* © Copyright 2013 CERN. This software is distributed under the terms of the GNU General Public Licence version 3 (GPL
* Version 3), copied verbatim in the file "COPYING". In applying this licence, CERN does not waive the privileges and
* immunities granted to it by virtue of its status as an Intergovernmental Organization or submit itself to any
* jurisdiction.
*
* If you modify this Program, or any covered work, by linking or combining it with the Eclipse Integrated Development
* Environment Plugin libraries (or a modified version of these libraries), containing parts covered by the terms of EPL
* (Eclipse Public licence), the licensors of this Program grant you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination shall include the source code for the parts of
* Eclipse Integrated Development Environment Plugin libraries used as well as that of the covered work.
**********************************************************************************************************************/
package cern.devtools.deps.eclipse.ui.tree;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import cern.devtools.deps.domain.ApiClass;
import cern.devtools.deps.domain.CodeElement;
import cern.devtools.deps.domain.Dependency;
import cern.devtools.deps.domain.DependencyType;
import cern.devtools.deps.domain.Method;
import cern.devtools.deps.domain.Product;
import cern.devtools.deps.domain.TransitiveDependency;
import cern.devtools.deps.eclipse.ui.LoggingUtil;
import cern.devtools.deps.eclipse.ui.views.GroupingOptions;
public class TreeBuilder {
/**
* Builds the tree for the view.
*
* @param objectToAnalyse The queried object.
* @param dependencies The result set returned by the server.
* @param grouping
* @return The reference of the tree item, which is displayable by the treeViewer.
*
* @author <NAME> <<EMAIL>>
*/
public static TreeItem buildTree(CodeElement objectToAnalyse, Collection<Dependency> dependencies,
GroupingOptions grouping) {
// Create root node. This node won't be displayed.
TreeItem root = TreeItem.createNewNode(TreeItemType.ROOT, null);
// If no dependencies exist then only add the special NO_DEPENDENCIES node.
if (dependencies.size() == 0) {
TreeItem.createNewNode(TreeItemType.NO_DEPENDENCIES, root, objectToAnalyse);
}
// Else build the dependency tree.
else {
// Add a visible root which shows which item was queried for incoming dependencies.
TreeItem subRoot = TreeItem.createNewNode(TreeItemType.ROOT, root, objectToAnalyse);
buildTree(dependencies, subRoot, grouping);
}
// Return the root of the node hierarchy.
return root;
}
/**
* Builds The tree based on the grouping options.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTree(Collection<Dependency> dependencies, TreeItem root, GroupingOptions grouping) {
switch (grouping) {
case GROUP_BY_DEPENDENCY_TYPE:
buildTreeDepGrouped(dependencies, root);
break;
case GROUP_BY_PRODUCT:
buildTreeProductGrouped(dependencies, root);
break;
default:
throw new RuntimeException("No TreeBuilder strategy defined for: " + grouping);
}
}
/**
* Builds The tree with associated with the {@link GroupingOptions#GROUP_BY_DEPENDENCY_TYPE}.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTreeDepGrouped(Collection<Dependency> dependencies, TreeItem root) {
// Categorise dependencies by type to display.
Map<DependencyType, List<Dependency>> typedDeps = new HashMap<DependencyType, List<Dependency>>();
for (Dependency d : dependencies) {
List<Dependency> deps = typedDeps.get(d.getType());
if (deps == null) {
deps = new LinkedList<Dependency>();
typedDeps.put(d.getType(), deps);
}
deps.add(d);
}
// Add the dependencies to the tree by types.
for (DependencyType type : typedDeps.keySet()) {
// Subroot for each type of dependencies
TreeItem dependencyNode = TreeItem.createNewNode(TreeItemType.DEPENDENCY_TYPE, root, type);
// Gather the different package names from the result.
Set<String> packageSet = new HashSet<String>();
Set<ApiClass> apiClassSet = new HashSet<ApiClass>();
Set<Method> methodSet = new HashSet<Method>();
for (Dependency d : typedDeps.get(type)) {
CodeElement ce = d.getFrom();
if (ce instanceof ApiClass) {
ApiClass ac = (ApiClass) ce;
packageSet.add(ac.getPackageName());
apiClassSet.add(ac);
} else if (ce instanceof Method) {
Method m = (Method) ce;
packageSet.add(m.getApiClass().getPackageName());
methodSet.add(m);
} else if (ce instanceof Product) {
TreeItem.createNewNode(TreeItemType.PRODUCT, dependencyNode, ce);
} else {
throw new RuntimeException("Dependency contains a wrong element: " + ce);
}
}
// Put the sets to a list and sort it.
List<String> packageList = new LinkedList<String>(packageSet);
Collections.sort(packageList);
// Create a node for each package and cache it.
Map<String, TreeItem> packageNodeCache = new HashMap<String, TreeItem>();
for (String p : packageList) {
TreeItem subSubNode = TreeItem.createNewNode(TreeItemType.PACKAGE, dependencyNode, p);
packageNodeCache.put(p, subSubNode);
}
// Add the dependencies below the package nodes.
for (Dependency d : typedDeps.get(type)) {
// Reference for the node lies on the lowest level. Used for adding the transitive dependencies.
TreeItem leafNode = null;
if (d.getFrom() instanceof Method) {
Method m = (Method) d.getFrom();
// Find proper package node which will be the parent of the method.
TreeItem packageNode = packageNodeCache.get(m.getApiClass().getPackageName());
// Find if it is already added to the list
TreeItem classNode = null;
for (TreeItem ti : packageNode.getChildren()) {
ApiClassTreeItem acti = (ApiClassTreeItem) ti;
if (acti.getValue().equals(m.getApiClass())) {
classNode = ti;
break;
}
}
// If the class node is not yet added, then create it.
if (classNode == null) {
classNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, m.getApiClass(), "PRO");
}
// First add the container class below the package, then add the method itself as the leaf node.
leafNode = TreeItem.createNewNode(TreeItemType.METHOD, classNode, d.getFrom(), "PRO");
} else if (d.getFrom() instanceof ApiClass) {
ApiClass ac = (ApiClass) d.getFrom();
// Find proper package node which will be the parent of the class.
TreeItem packageNode = packageNodeCache.get(ac.getPackageName());
// Add the class node as the leaf node.
leafNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, d.getFrom(), "PRO");
} else if (d.getFrom() instanceof Product) {
} else {
throw new RuntimeException("Not legal type for this level of hierarchy: " + d.getFrom().getClass());
}
// If the current dependency is a transitive one, the build a subtree about the dependency structure
// using the previouslt defined leaf node as the new root.
if (d instanceof TransitiveDependency) {
buildTree(((TransitiveDependency) d).getTransitiveFrom(), leafNode,
GroupingOptions.GROUP_BY_DEPENDENCY_TYPE);
}
}
}
}
/**
* Builds The tree with associated with the {@link GroupingOptions#GROUP_BY_PRODUCT}.
*
* @param dependencies The result set returned by the server.
* @param root The parent node for the created items.
*/
private static void buildTreeProductGrouped(Collection<Dependency> dependencies, TreeItem root) {
// Gather all product involved in the dependencies.
Set<Product> products = new HashSet<Product>();
Map<CodeElement, Dependency> dependencyCache = new HashMap<CodeElement, Dependency>();
for (Object dO : dependencies) {
Dependency d = (Dependency)dO;
CodeElement ce = d.getFrom();
dependencyCache.put(ce, d);
if (ApiClass.class.isAssignableFrom(ce.getClass())) {
products.add(((ApiClass) ce).getProduct());
} else if (Method.class.isAssignableFrom(ce.getClass())) {
products.add(((Method) ce).getApiClass().getProduct());
} else if (Product.class.isAssignableFrom(ce.getClass())) {
products.add((Product) ce);
} else {
// do not throw an exception, because we want the editor to stay intact.
LoggingUtil.warnAndLog("TreeItem type is not displayable " + ce.getClass(), new RuntimeException());
}
}
// Sort the products
List<Product> productList = new LinkedList<Product>(products);
Collections.sort(productList, new Comparator<Product>() {
@Override
public int compare(Product o1, Product o2) {
return o1.getName().compareTo(o2.getName());
}
});
for (final Product p : productList) {
// Gather the different package names from the result.
Set<String> packageSet = new HashSet<String>();
for (ApiClass ac : p.getClasses()) {
packageSet.add(ac.getPackageName());
}
// Put the package to the list and sort it.
List<String> packageList = new LinkedList<String>(packageSet);
Collections.sort(packageList);
// Create product node.
TreeItem productNode = TreeItem.createNewNode(TreeItemType.PRODUCT, root, p);
// Create version nodes below and index them.
// Map<String, TreeItem> versionNodeCache = new HashMap<String, TreeItem>();
for (final String version : p.getVersions()) {
TreeItem versionNode = TreeItem.createNewNode(TreeItemType.VERSION, productNode, version);
// versionNodeCache.put(version, versionNode);
// Create a node for each package and cache it.
Map<String, TreeItem> packageNodeCache = new HashMap<String, TreeItem>();
for (String pkg : packageList) {
TreeItem packageNode = TreeItem.createNewNode(TreeItemType.PACKAGE, versionNode, pkg);
packageNodeCache.put(pkg, packageNode);
// for each package add all of the contained classes and methods
for (ApiClass ac : p.getClasses()) {
if (ac.getPackageName().equals(pkg) && ac.getVersions().contains(version)) {
// Create apiclass node if not exists.
TreeItem classNode = TreeItem.createNewNode(TreeItemType.CLASS, packageNode, ac, version);
// If it is a transitive dependency, then recursively build the tree..
Dependency d = dependencyCache.get(ac);
if (d != null && d instanceof TransitiveDependency) {
TreeItem transRootNode = TreeItem.createNewNode(TreeItemType.ROOT, classNode, ac);
buildTreeProductGrouped(((TransitiveDependency) d).getTransitiveFrom(), transRootNode);
}
// Do the same with the method nodes.
for (Method m : ac.getMethods()) {
if (m.getVersions().contains(version)) {
TreeItem methodNode = TreeItem.createNewNode(TreeItemType.METHOD, classNode, m,
version);
d = dependencyCache.get(m);
if (d != null && d instanceof TransitiveDependency) {
TreeItem transRootNode = TreeItem.createNewNode(TreeItemType.ROOT, methodNode,
m);
buildTreeProductGrouped(((TransitiveDependency) d).getTransitiveFrom(),
transRootNode);
}
}
}
}
}
// if the current version does not contain any packages, then remove it
if (packageNode.getChildren().size() == 0) {
// Same as versionNode.getChildren().remove(packageNode);.
packageNode.getParent().getChildren().remove(packageNode);
}
}
}
}
}
}
| 14,523 | 0.57478 | 0.573954 | 293 | 48.61092 | 35.188503 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.614334 | false | false | 10 |
8cccd93eaad0edc9c894b2dc11767dca8fbd0f0b | 9,732,395,947,724 | 1b66dedf7cd4fa83d820319474165ce868d59d73 | /ch7/Exercise7_18/Robot.java | 781f6ae4fd6968a8c12c20ce5bd087bfb18a0bf9 | [] | no_license | Kimsuhhee/javajungsuk3 | https://github.com/Kimsuhhee/javajungsuk3 | 87b6b2e28474f03a8a183205404d738096b2d97d | 092b970ca21c6938778a82e6d4633fe178e4495d | refs/heads/master | 2023-04-03T06:41:37.394000 | 2021-04-11T07:23:24 | 2021-04-11T07:23:24 | 353,034,321 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package basic_practiceCH7.Exercise7_18;
public class Robot {
}
| UTF-8 | Java | 64 | java | Robot.java | Java | [] | null | [] | package basic_practiceCH7.Exercise7_18;
public class Robot {
}
| 64 | 0.78125 | 0.71875 | 4 | 15 | 15.984367 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 10 |
59d923e455388d54efa959bda1d913719c336112 | 14,181,982,031,808 | 17f8e10ca3f53e39fc7f80934c1434b0dcbc2192 | /999-Dev/Stock/StockAnalysis-Yahoo/src/main/java/com/techoffice/yahoo/finance/stock/batch/StockReader.java | afa5ef31f26c5d578938e6de7e1e32c3847836c3 | [] | no_license | wangchaogitname/TechOffice-Java | https://github.com/wangchaogitname/TechOffice-Java | a9f5f379c7c55b427347418d2be228ebfbf818a3 | 7724296d6ac46706a02ba580014a2a114335ed20 | refs/heads/master | 2021-01-20T04:09:53.596000 | 2017-04-26T09:45:42 | 2017-04-26T09:45:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.techoffice.yahoo.finance.stock.batch;
import java.util.List;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import com.techoffice.hkex.csvimport.stock.model.Stock;
public class StockReader implements ItemReader<Stock>{
private List<Stock> stockList;
public Stock read() {
if (!stockList.isEmpty()){
Stock stock = stockList.remove(0);
System.out.println("Now Reading: " + stock.getStockCode());
return stock;
}
return null;
}
public List<Stock> getStockList() {
return stockList;
}
public void setStockList(List<Stock> stockList) {
this.stockList = stockList;
}
}
| UTF-8 | Java | 805 | java | StockReader.java | Java | [] | null | [] | package com.techoffice.yahoo.finance.stock.batch;
import java.util.List;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import com.techoffice.hkex.csvimport.stock.model.Stock;
public class StockReader implements ItemReader<Stock>{
private List<Stock> stockList;
public Stock read() {
if (!stockList.isEmpty()){
Stock stock = stockList.remove(0);
System.out.println("Now Reading: " + stock.getStockCode());
return stock;
}
return null;
}
public List<Stock> getStockList() {
return stockList;
}
public void setStockList(List<Stock> stockList) {
this.stockList = stockList;
}
}
| 805 | 0.763975 | 0.762733 | 35 | 22 | 23.083698 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.2 | false | false | 10 |
63681950efb98a58b1f08fdc2cd11524e8f0ed3c | 12,266,426,664,464 | 2c40f6a2a0bd714eaec17e6df82044e5797d1825 | /src/main/java/com/ztesoft/web/cache/service/IAmUserTmpService.java | 00472fa108c85a43dc2fe81d5ab0f81fa4ba8243 | [] | no_license | xishuai392/info | https://github.com/xishuai392/info | d56bf2ab7dc8bc14c869b7b8ef0fcea670300d3a | 8df5f015c8aff4d3d79943705b74e03f0c818d4f | refs/heads/master | 2020-05-21T23:33:40.378000 | 2016-12-04T16:01:57 | 2016-12-04T16:01:57 | 39,788,628 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package com.ztesoft.web.cache.service;
import java.math.*;
import java.util.*;
import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.web.cache.db.po.AmUserTmpPO;
/**
* <Description> <br>
*
* @author codeCreater<br>
* @version 1.0<br>
* @taskId <br>
* @CreateDate 2014年11月11日 <br>
* @since V1.0<br>
* @see com.ztesoft.web.cache.service <br>
*/
public interface IAmUserTmpService {
AmUserTmpPO selectByPrimaryKey(Integer key) throws BaseAppException;
List<AmUserTmpPO> selectByArg(AmUserTmpPO record) throws BaseAppException;
Page<AmUserTmpPO> selectByArgAndPage(AmUserTmpPO record, Page<AmUserTmpPO> resultPage)
throws BaseAppException;
int add(AmUserTmpPO record) throws BaseAppException;
int update(AmUserTmpPO record) throws BaseAppException;
int delete(AmUserTmpPO record) throws BaseAppException;
}
| UTF-8 | Java | 978 | java | IAmUserTmpService.java | Java | [
{
"context": "PO;\r\n\r\n/**\r\n * <Description> <br>\r\n * \r\n * @author codeCreater<br>\r\n * @version 1.0<br>\r\n * @taskId <br>\r\n * @Cr",
"end": 305,
"score": 0.9996713995933533,
"start": 294,
"tag": "USERNAME",
"value": "codeCreater"
}
] | null | [] | /**
*
*/
package com.ztesoft.web.cache.service;
import java.math.*;
import java.util.*;
import com.ztesoft.core.common.Page;
import com.ztesoft.framework.exception.BaseAppException;
import com.ztesoft.web.cache.db.po.AmUserTmpPO;
/**
* <Description> <br>
*
* @author codeCreater<br>
* @version 1.0<br>
* @taskId <br>
* @CreateDate 2014年11月11日 <br>
* @since V1.0<br>
* @see com.ztesoft.web.cache.service <br>
*/
public interface IAmUserTmpService {
AmUserTmpPO selectByPrimaryKey(Integer key) throws BaseAppException;
List<AmUserTmpPO> selectByArg(AmUserTmpPO record) throws BaseAppException;
Page<AmUserTmpPO> selectByArgAndPage(AmUserTmpPO record, Page<AmUserTmpPO> resultPage)
throws BaseAppException;
int add(AmUserTmpPO record) throws BaseAppException;
int update(AmUserTmpPO record) throws BaseAppException;
int delete(AmUserTmpPO record) throws BaseAppException;
}
| 978 | 0.708848 | 0.696502 | 40 | 22.299999 | 25.387201 | 90 | true | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.325 | false | false | 10 |
a7bf85b550369bf678971c9d0e9252c5595763b7 | 28,862,180,266,911 | 1588095d9c1dcfd9c7d8b8ed7e3173b921266ac5 | /java/javaPJT_4/src/Main/J0727_1.java | a9928637a83763b3a1a2a4bc9361cf460f29e602 | [] | no_license | GWANHYEONGLEE/jsl_43_gwanhyeonglee_java | https://github.com/GWANHYEONGLEE/jsl_43_gwanhyeonglee_java | 5fdce2f16046bf6ec9a63fbb9e00ca22e45921ed | 8ae994d145c74a3a1c9737e1510691fdc04be7c6 | refs/heads/master | 2022-11-29T21:35:29.860000 | 2020-08-07T03:02:03 | 2020-08-07T03:02:03 | 271,703,290 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Main;
public class J0727_1 {
public int getTotal(String a, String b) {
int result = 0;
try {
result = Integer.parseInt(a) +
Integer.parseInt(b);
}catch(Exception e) {
System.out.println(" 형변환 오류~~~");
result = -1;
}
return result;
}
}
| UHC | Java | 280 | java | J0727_1.java | Java | [] | null | [] | package Main;
public class J0727_1 {
public int getTotal(String a, String b) {
int result = 0;
try {
result = Integer.parseInt(a) +
Integer.parseInt(b);
}catch(Exception e) {
System.out.println(" 형변환 오류~~~");
result = -1;
}
return result;
}
}
| 280 | 0.611111 | 0.585185 | 16 | 15.875 | 13.009011 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 10 |
0e00109a3afd90dc2c73bccac615d8bc02026521 | 8,074,538,534,236 | a9edc830002e5d7dce26dc860849d636c147233c | /src/main/java/com/projetloki/genesis/Transition.java | 538bfbce7b06e038518729b66f9b92d3bbc99f6e | [] | no_license | Lonzak/genesis | https://github.com/Lonzak/genesis | e28c0ec82f9fa0e4b5fc1ee2eb4181546e39efab | 1c667e12f79d8b525f9b0ff687d8823d8791b768 | refs/heads/master | 2021-03-15T15:09:04.015000 | 2020-03-13T13:21:41 | 2020-03-13T13:21:41 | 246,860,008 | 0 | 0 | null | true | 2020-03-12T14:49:24 | 2020-03-12T14:49:23 | 2017-11-09T15:39:07 | 2013-04-16T13:51:35 | 2,008 | 0 | 0 | 0 | null | false | false | package com.projetloki.genesis;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
/**
* Transitions, which are part of the CSS3 set of specifications, provide a way
* to control animation speed when changing CSS properties. Instead of having
* property changes take effect immediately, you can cause the changes in a
* property to take place over a period of time. For example, if you change the
* color of an element from white to black, usually the change is instantaneous.
* With CSS transitions enabled, changes occur at time intervals that follow an
* acceleration curve, all of which can be customized.
*
* <p>
* Animations that involve transitioning between two states are often called
* implicit transitions as the states in between the start and final states are
* implicitly defined by the browser.</p>
*
* <p>Example:
* <pre><code> void configure(CssBuilder out) {
* out.addRule(".box", Properties.builder()
* .setWidthPx(100)
* .setTransition(Transition.onProperty("width")
* .delaySeconds(0.5)
* .durationSeconds(3)));
*
* // When the pointing device is on the box, the box will grow
* // horizontally with a nice transition effect
* out.addRule(".box:hover", Properties.builder()
* .setWidthPx(200));
* }
* </code></pre>
* </p>
*
* <p>
* Transitions are immutable. Methods such as {@link #durationSeconds(double)}
* perform a copy of the instance they are called on, modify the copy and return
* it. The original instance is left unchanged.</p>
*
* @see Animation
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_transitions">MDN</a>
* @see <a href="http://caniuse.com/css-transitions">Browser support</a>
*
* @author Clément Roux
*/
public final class Transition extends AppendableToNoContext {
/**
* Returns a transition for the given CSS property.
* The delay and the duration are both zero (no animation occurs), and the
* timing function is {@linkplain TimingFunction#EASE ease}.
* @throws IllegalArgumentException if the given property is not
* a valid CSS identifier
*/
public static Transition onProperty(String property) {
Util.checkIdentifier(property);
return new Transition(property);
}
private final String property;
private String duration;
private TimingFunction timingFunction;
private String delay;
private Transition(String property) {
this.property = checkNotNull(property);
this.duration = "0";
this.timingFunction = TimingFunction.EASE;
this.delay = "0";
}
private Transition(Transition copyFrom) {
this.property = copyFrom.property;
this.duration = copyFrom.duration;
this.timingFunction = copyFrom.timingFunction;
this.delay = copyFrom.delay;
}
/**
* Returns a new transition similar to {@code this}, with the duration
* property set to the given value.
* Specifies the time the transition animation should take to complete.
* Expressed in seconds.
* @throws IllegalArgumentException if the duration is negative
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-duration">MDN</a>
*/
public Transition durationSeconds(double seconds) {
Transition result = new Transition(this);
result.duration = Format.formatSeconds(seconds);
return result;
}
/**
* Returns a new transition similar to {@code this}, with the timing-function
* property set to the given value.
* Describe how the intermediate values of the CSS properties being affected
* by a transition effect are calculated.
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-timing-function">MDN</a>
*/
public Transition timingFunction(TimingFunction function) {
Transition result = new Transition(this);
result.timingFunction = checkNotNull(function);
return result;
}
/**
* Returns a new transition similar to {@code this}, with the delay property
* set to the given value.
* Specifies the amount of time to wait between a change being requested to a
* property that is to be transitioned and the start of the transition effect.
* Expressed in seconds.
* @throws IllegalArgumentException if the duration is negative
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-delay">MDN</a>
*/
public Transition delaySeconds(double seconds) {
Transition result = new Transition(this);
result.delay = Format.formatSeconds(seconds);
return result;
}
@Override void appendTo(StringBuilder out) {
out.append(property);
if (!duration.equals("0") || !delay.equals("0")) {
out.append(' ');
out.append(duration);
}
if (timingFunction != TimingFunction.EASE) {
out.append(' ');
out.append(timingFunction);
}
if (!delay.equals("0")) {
out.append(' ');
out.append(delay);
}
}
@Override public boolean equals(Object object) {
if (object == this) {
return true;
} else if (object instanceof Transition) {
Transition that = (Transition) object;
return property.equals(that.property) &&
duration.equals(that.duration) &&
timingFunction.equals(that.timingFunction) &&
delay.equals(that.delay);
}
return false;
}
@Override public int hashCode() {
return Objects.hashCode(property, duration, timingFunction, delay);
}
}
| UTF-8 | Java | 5,542 | java | Transition.java | Java | [
{
"context": "css-transitions\">Browser support</a>\n *\n * @author Clément Roux\n */\npublic final class Transition extends Appenda",
"end": 1834,
"score": 0.9998686909675598,
"start": 1822,
"tag": "NAME",
"value": "Clément Roux"
}
] | null | [] | package com.projetloki.genesis;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
/**
* Transitions, which are part of the CSS3 set of specifications, provide a way
* to control animation speed when changing CSS properties. Instead of having
* property changes take effect immediately, you can cause the changes in a
* property to take place over a period of time. For example, if you change the
* color of an element from white to black, usually the change is instantaneous.
* With CSS transitions enabled, changes occur at time intervals that follow an
* acceleration curve, all of which can be customized.
*
* <p>
* Animations that involve transitioning between two states are often called
* implicit transitions as the states in between the start and final states are
* implicitly defined by the browser.</p>
*
* <p>Example:
* <pre><code> void configure(CssBuilder out) {
* out.addRule(".box", Properties.builder()
* .setWidthPx(100)
* .setTransition(Transition.onProperty("width")
* .delaySeconds(0.5)
* .durationSeconds(3)));
*
* // When the pointing device is on the box, the box will grow
* // horizontally with a nice transition effect
* out.addRule(".box:hover", Properties.builder()
* .setWidthPx(200));
* }
* </code></pre>
* </p>
*
* <p>
* Transitions are immutable. Methods such as {@link #durationSeconds(double)}
* perform a copy of the instance they are called on, modify the copy and return
* it. The original instance is left unchanged.</p>
*
* @see Animation
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_transitions">MDN</a>
* @see <a href="http://caniuse.com/css-transitions">Browser support</a>
*
* @author <NAME>
*/
public final class Transition extends AppendableToNoContext {
/**
* Returns a transition for the given CSS property.
* The delay and the duration are both zero (no animation occurs), and the
* timing function is {@linkplain TimingFunction#EASE ease}.
* @throws IllegalArgumentException if the given property is not
* a valid CSS identifier
*/
public static Transition onProperty(String property) {
Util.checkIdentifier(property);
return new Transition(property);
}
private final String property;
private String duration;
private TimingFunction timingFunction;
private String delay;
private Transition(String property) {
this.property = checkNotNull(property);
this.duration = "0";
this.timingFunction = TimingFunction.EASE;
this.delay = "0";
}
private Transition(Transition copyFrom) {
this.property = copyFrom.property;
this.duration = copyFrom.duration;
this.timingFunction = copyFrom.timingFunction;
this.delay = copyFrom.delay;
}
/**
* Returns a new transition similar to {@code this}, with the duration
* property set to the given value.
* Specifies the time the transition animation should take to complete.
* Expressed in seconds.
* @throws IllegalArgumentException if the duration is negative
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-duration">MDN</a>
*/
public Transition durationSeconds(double seconds) {
Transition result = new Transition(this);
result.duration = Format.formatSeconds(seconds);
return result;
}
/**
* Returns a new transition similar to {@code this}, with the timing-function
* property set to the given value.
* Describe how the intermediate values of the CSS properties being affected
* by a transition effect are calculated.
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-timing-function">MDN</a>
*/
public Transition timingFunction(TimingFunction function) {
Transition result = new Transition(this);
result.timingFunction = checkNotNull(function);
return result;
}
/**
* Returns a new transition similar to {@code this}, with the delay property
* set to the given value.
* Specifies the amount of time to wait between a change being requested to a
* property that is to be transitioned and the start of the transition effect.
* Expressed in seconds.
* @throws IllegalArgumentException if the duration is negative
* @see <a target="_blank" href="https://developer.mozilla.org/en-US/docs/CSS/transition-delay">MDN</a>
*/
public Transition delaySeconds(double seconds) {
Transition result = new Transition(this);
result.delay = Format.formatSeconds(seconds);
return result;
}
@Override void appendTo(StringBuilder out) {
out.append(property);
if (!duration.equals("0") || !delay.equals("0")) {
out.append(' ');
out.append(duration);
}
if (timingFunction != TimingFunction.EASE) {
out.append(' ');
out.append(timingFunction);
}
if (!delay.equals("0")) {
out.append(' ');
out.append(delay);
}
}
@Override public boolean equals(Object object) {
if (object == this) {
return true;
} else if (object instanceof Transition) {
Transition that = (Transition) object;
return property.equals(that.property) &&
duration.equals(that.duration) &&
timingFunction.equals(that.timingFunction) &&
delay.equals(that.delay);
}
return false;
}
@Override public int hashCode() {
return Objects.hashCode(property, duration, timingFunction, delay);
}
}
| 5,535 | 0.698249 | 0.695542 | 154 | 34.980518 | 28.428646 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.38961 | false | false | 10 |
4e0302f6199bfbe19b67caa2ee01e69a3ab7984d | 20,744,692,040,669 | 6c561f4604400138f9f5e87840590f69591b7f25 | /src/main/java/com/foscam/test/net/study/Dgram.java | 2a21bd0a245a04050aec9114ac617ef262afbe9d | [] | no_license | husel-test/test-server | https://github.com/husel-test/test-server | 2b7811a9e42bd583e37eb2cfa478aa3fcc064f56 | 25ba4368eed6530c813beadea55c8d209f9947d0 | refs/heads/master | 2021-01-20T21:08:53.468000 | 2016-05-30T09:13:58 | 2016-05-30T09:13:58 | 59,995,010 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.foscam.test.net.study;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.Arrays;
public class Dgram {
private final static String UTF8 = "UTF-8";
public static DatagramPacket toDatagram(String s, InetAddress destIA,
int destPort) throws UnsupportedEncodingException {
byte[] buf = s.getBytes(UTF8);
return new DatagramPacket(buf, buf.length, destIA, destPort);
}
public static String toString(DatagramPacket p) throws UnsupportedEncodingException {
return new String(p.getData(), 0, p.getLength(),UTF8);
}
public static void main(String[] args) {
String s = "a_1总";
try {
DatagramPacket dataPacket = toDatagram(s, InetAddress.getLocalHost(), 9989);
System.out.println(dataPacket.toString());
System.out.println(dataPacket.getLength());
System.out.println(Arrays.toString(dataPacket.getData()));
System.out.println(URLEncoder.encode(s, UTF8));
byte[] buf = dataPacket.getData();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
System.out.println(Integer.toHexString(c));
}
for (int i = 0; i < buf.length; i++) {
System.out.println(Integer.toHexString(buf[i]));
}
//Integer.toHexString();
System.out.println("===========================");
System.out.println(toString(dataPacket));
} catch (Exception e) {
e.printStackTrace();
}
}
} | UTF-8 | Java | 1,558 | java | Dgram.java | Java | [] | null | [] | package com.foscam.test.net.study;
import java.io.UnsupportedEncodingException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.Arrays;
public class Dgram {
private final static String UTF8 = "UTF-8";
public static DatagramPacket toDatagram(String s, InetAddress destIA,
int destPort) throws UnsupportedEncodingException {
byte[] buf = s.getBytes(UTF8);
return new DatagramPacket(buf, buf.length, destIA, destPort);
}
public static String toString(DatagramPacket p) throws UnsupportedEncodingException {
return new String(p.getData(), 0, p.getLength(),UTF8);
}
public static void main(String[] args) {
String s = "a_1总";
try {
DatagramPacket dataPacket = toDatagram(s, InetAddress.getLocalHost(), 9989);
System.out.println(dataPacket.toString());
System.out.println(dataPacket.getLength());
System.out.println(Arrays.toString(dataPacket.getData()));
System.out.println(URLEncoder.encode(s, UTF8));
byte[] buf = dataPacket.getData();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
System.out.println(Integer.toHexString(c));
}
for (int i = 0; i < buf.length; i++) {
System.out.println(Integer.toHexString(buf[i]));
}
//Integer.toHexString();
System.out.println("===========================");
System.out.println(toString(dataPacket));
} catch (Exception e) {
e.printStackTrace();
}
}
} | 1,558 | 0.663882 | 0.655527 | 53 | 27.396227 | 23.449938 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.603774 | false | false | 10 |
cae426ccc2678d560eedf7790b27c8c45ad9b0a5 | 9,637,906,649,644 | da4e2c3feb835d492c9c179b4b064e68edd1d5da | /Hash Table/WordPattern.java | c329a5ee73123d37ee84d7dd0b182e66f6cfa68f | [] | no_license | zaileon/LeetCode | https://github.com/zaileon/LeetCode | df8ae0d09531fdaa6d1db31ed1929c9a1f03e0cb | d2ee944351cb62fef83f06f4a941648d5b8eb273 | refs/heads/master | 2021-05-04T07:05:57.443000 | 2017-02-24T18:13:06 | 2017-02-24T18:13:06 | 69,170,699 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.HashMap;
import java.util.Map;
public class WordPattern {
public boolean wordPattern(String pattern, String str) {
String[] words = str.split(" ");
if (words.length != pattern.length())
return false;
Map<Object, Integer> index = new HashMap<>();
for (Integer i=0; i<words.length; ++i)
// use int return false when putting d=129 and t=129, both return Integer of 128, but not the same one (exceed Java Integer constant pool)
// Integer i1 = 127, i2 = 127; i1==i2;//true, call Integer.valueOf(127)
// Integer i1 = 128, i2 = 128; i1==i2;//false
// Integer i1 = new Integer(127), i2 = new Integer(127); i1==i2; //false
if (index.put(pattern.charAt(i), i) != index.put(words[i], i))
return false;
return true;
}
public static void main(String[] args) {
WordPattern wp = new WordPattern();
System.out.println(wp.wordPattern("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccdd", "s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s t t"));
System.out.println(wp.wordPattern("ab", "dog dog"));
System.out.println(wp.wordPattern("abba", "dog cat cat dog"));
System.out.println(wp.wordPattern("abba", "dog cat cat fish"));
System.out.println(wp.wordPattern("aaaa", "dog cat cat dog"));
System.out.println(wp.wordPattern("abba", "dog dog dog dog"));
}
}
| UTF-8 | Java | 1,645 | java | WordPattern.java | Java | [] | null | [] | import java.util.HashMap;
import java.util.Map;
public class WordPattern {
public boolean wordPattern(String pattern, String str) {
String[] words = str.split(" ");
if (words.length != pattern.length())
return false;
Map<Object, Integer> index = new HashMap<>();
for (Integer i=0; i<words.length; ++i)
// use int return false when putting d=129 and t=129, both return Integer of 128, but not the same one (exceed Java Integer constant pool)
// Integer i1 = 127, i2 = 127; i1==i2;//true, call Integer.valueOf(127)
// Integer i1 = 128, i2 = 128; i1==i2;//false
// Integer i1 = new Integer(127), i2 = new Integer(127); i1==i2; //false
if (index.put(pattern.charAt(i), i) != index.put(words[i], i))
return false;
return true;
}
public static void main(String[] args) {
WordPattern wp = new WordPattern();
System.out.println(wp.wordPattern("ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccdd", "s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s s t t"));
System.out.println(wp.wordPattern("ab", "dog dog"));
System.out.println(wp.wordPattern("abba", "dog cat cat dog"));
System.out.println(wp.wordPattern("abba", "dog cat cat fish"));
System.out.println(wp.wordPattern("aaaa", "dog cat cat dog"));
System.out.println(wp.wordPattern("abba", "dog dog dog dog"));
}
}
| 1,645 | 0.648632 | 0.622492 | 31 | 52.064518 | 76.411423 | 434 | false | false | 0 | 0 | 0 | 0 | 130 | 0.079027 | 2.387097 | false | false | 10 |
4acc19050a7704fd46e9e15f07d9d75d438ba1e9 | 26,757,646,290,164 | 3cf9cda3d4ae4096b9bf34342ba2737f2c046c4f | /Cloud-Api/src/main/java/com/proxy/service/api/multidex/SourceDex.java | a319ac4dfea449352aa06da2f4a8d59be03fdcbd | [
"Apache-2.0"
] | permissive | season654239/Android-Cloud | https://github.com/season654239/Android-Cloud | ea7a608711e00478ed795f81ae92bf1b3e908353 | 3682f571c3afd72f310869695813f717a1eda4ee | refs/heads/master | 2023-06-18T18:45:20.159000 | 2021-05-31T13:20:47 | 2021-05-31T13:20:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.proxy.service.api.multidex;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import com.proxy.service.api.BuildConfig;
import com.proxy.service.api.utils.Logger;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* dex资源相关
*
* @author: cangHX
* on 2020/06/22 13:57
*/
class SourceDex {
private static final String EXTRACTED_NAME_EXT = ".classes";
private static final String EXTRACTED_SUFFIX = ".zip";
private static final String SECONDARY_FOLDER_NAME = "code_cache" + File.separator + "secondary-dexes";
private static final String PREFS_FILE = "multidex.version";
private static final String KEY_DEX_NUMBER = "dex.number";
/**
* 获取dex文件路径
*
* @param context : 上下文环境
* @return dex文件路径集合
* @version: 1.0
* @author: cangHX
* @date: 2020-06-22 13:58
*/
static List<String> getDexPaths(Context context) {
List<String> dexPaths = new ArrayList<>();
PackageManager packageManager = null;
try {
packageManager = context.getPackageManager();
} catch (Throwable ignored) {
}
if (packageManager == null) {
return dexPaths;
}
ApplicationInfo applicationInfo = null;
try {
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
} catch (Throwable ignored) {
}
if (applicationInfo == null) {
return dexPaths;
}
dexPaths.add(applicationInfo.sourceDir);
File sourceApk = new File(applicationInfo.sourceDir);
String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
if (!VmMultiDex.isVmMultiDexCapable()) {
int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);
for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
File extractedFile = new File(dexDir, fileName);
if (!extractedFile.isFile()) {
Logger.Error("Missing extracted secondary dex file '" + extractedFile.getPath() + "'");
dexPaths.clear();
return dexPaths;
}
dexPaths.add(extractedFile.getAbsolutePath());
}
}
if (BuildConfig.DEBUG) {
dexPaths.addAll(tryLoadInstantRunDexFile(applicationInfo));
}
return dexPaths;
}
@SuppressWarnings({"unchecked", "ConstantConditions"})
private static List<String> tryLoadInstantRunDexFile(ApplicationInfo applicationInfo) {
List<String> instantRunDexPaths = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && applicationInfo.splitSourceDirs != null) {
instantRunDexPaths.addAll(Arrays.asList(applicationInfo.splitSourceDirs));
Logger.Debug("Found InstantRun support");
return instantRunDexPaths;
}
try {
@SuppressLint("PrivateApi") Class pathsByInstantRun = Class.forName("com.android.tools.fd.runtime.Paths");
Method getDexFileDirectory = pathsByInstantRun.getMethod("getDexFileDirectory", String.class);
String instantRunDexPath = (String) getDexFileDirectory.invoke(null, applicationInfo.packageName);
File instantRunFilePath = new File(instantRunDexPath);
if (!instantRunFilePath.exists() || !instantRunFilePath.isDirectory()) {
return instantRunDexPaths;
}
File[] dexFile = instantRunFilePath.listFiles();
for (File file : dexFile) {
if (file == null) {
continue;
}
if (file.exists()) {
continue;
}
if (file.isFile()) {
continue;
}
if (file.getName().endsWith(".dex")) {
continue;
}
instantRunDexPaths.add(file.getAbsolutePath());
}
Logger.Debug("Found InstantRun support");
} catch (Throwable e) {
Logger.Debug("InstantRun support error, ", e);
}
return instantRunDexPaths;
}
private static SharedPreferences getMultiDexPreferences(Context context) {
return context.getSharedPreferences(PREFS_FILE, Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? Context.MODE_PRIVATE : Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
}
}
| UTF-8 | Java | 5,015 | java | SourceDex.java | Java | [
{
"context": "ort java.util.List;\n\n/**\n * dex资源相关\n *\n * @author: cangHX\n * on 2020/06/22 13:57\n */\nclass SourceDex {\n\n ",
"end": 519,
"score": 0.9996013045310974,
"start": 513,
"tag": "USERNAME",
"value": "cangHX"
},
{
"context": "urn dex文件路径集合\n * @version: 1.0\n ... | null | [] | package com.proxy.service.api.multidex;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import com.proxy.service.api.BuildConfig;
import com.proxy.service.api.utils.Logger;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* dex资源相关
*
* @author: cangHX
* on 2020/06/22 13:57
*/
class SourceDex {
private static final String EXTRACTED_NAME_EXT = ".classes";
private static final String EXTRACTED_SUFFIX = ".zip";
private static final String SECONDARY_FOLDER_NAME = "code_cache" + File.separator + "secondary-dexes";
private static final String PREFS_FILE = "multidex.version";
private static final String KEY_DEX_NUMBER = "dex.number";
/**
* 获取dex文件路径
*
* @param context : 上下文环境
* @return dex文件路径集合
* @version: 1.0
* @author: cangHX
* @date: 2020-06-22 13:58
*/
static List<String> getDexPaths(Context context) {
List<String> dexPaths = new ArrayList<>();
PackageManager packageManager = null;
try {
packageManager = context.getPackageManager();
} catch (Throwable ignored) {
}
if (packageManager == null) {
return dexPaths;
}
ApplicationInfo applicationInfo = null;
try {
applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
} catch (Throwable ignored) {
}
if (applicationInfo == null) {
return dexPaths;
}
dexPaths.add(applicationInfo.sourceDir);
File sourceApk = new File(applicationInfo.sourceDir);
String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;
if (!VmMultiDex.isVmMultiDexCapable()) {
int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);
for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
File extractedFile = new File(dexDir, fileName);
if (!extractedFile.isFile()) {
Logger.Error("Missing extracted secondary dex file '" + extractedFile.getPath() + "'");
dexPaths.clear();
return dexPaths;
}
dexPaths.add(extractedFile.getAbsolutePath());
}
}
if (BuildConfig.DEBUG) {
dexPaths.addAll(tryLoadInstantRunDexFile(applicationInfo));
}
return dexPaths;
}
@SuppressWarnings({"unchecked", "ConstantConditions"})
private static List<String> tryLoadInstantRunDexFile(ApplicationInfo applicationInfo) {
List<String> instantRunDexPaths = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && applicationInfo.splitSourceDirs != null) {
instantRunDexPaths.addAll(Arrays.asList(applicationInfo.splitSourceDirs));
Logger.Debug("Found InstantRun support");
return instantRunDexPaths;
}
try {
@SuppressLint("PrivateApi") Class pathsByInstantRun = Class.forName("com.android.tools.fd.runtime.Paths");
Method getDexFileDirectory = pathsByInstantRun.getMethod("getDexFileDirectory", String.class);
String instantRunDexPath = (String) getDexFileDirectory.invoke(null, applicationInfo.packageName);
File instantRunFilePath = new File(instantRunDexPath);
if (!instantRunFilePath.exists() || !instantRunFilePath.isDirectory()) {
return instantRunDexPaths;
}
File[] dexFile = instantRunFilePath.listFiles();
for (File file : dexFile) {
if (file == null) {
continue;
}
if (file.exists()) {
continue;
}
if (file.isFile()) {
continue;
}
if (file.getName().endsWith(".dex")) {
continue;
}
instantRunDexPaths.add(file.getAbsolutePath());
}
Logger.Debug("Found InstantRun support");
} catch (Throwable e) {
Logger.Debug("InstantRun support error, ", e);
}
return instantRunDexPaths;
}
private static SharedPreferences getMultiDexPreferences(Context context) {
return context.getSharedPreferences(PREFS_FILE, Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? Context.MODE_PRIVATE : Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
}
}
| 5,015 | 0.619546 | 0.613714 | 137 | 35.299271 | 32.520485 | 186 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.532847 | false | false | 10 |
e86e6c06cdc229fa221b17734ccc512210da3281 | 32,478,542,729,204 | 05a5bb2f14da29e67a086d0a0beb0863978663e9 | /src/main/java/net/imglib2/display/projector/volatiles/Volatile2DRandomAccessibleProjector.java | 53dbe498a3af50a4efb3f146b8afdff999852d9b | [
"BSD-2-Clause"
] | permissive | imglib/imglib2 | https://github.com/imglib/imglib2 | 8239153419a862149cc8317ca27a185dbe07aeec | 0f83262f6a1db0b131341fe28ec1d4f495c65a7a | refs/heads/master | 2023-08-18T10:50:51.702000 | 2023-02-06T17:59:32 | 2023-07-14T12:01:47 | 2,996,011 | 260 | 79 | NOASSERTION | false | 2023-09-12T12:26:59 | 2011-12-16T16:36:19 | 2023-08-26T04:53:37 | 2023-09-12T12:26:58 | 44,960 | 275 | 91 | 55 | Java | false | false | /*
* #%L
* ImgLib2: a general-purpose, multidimensional image processing library.
* %%
* Copyright (C) 2009 - 2023 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld,
* John Bogovic, Albert Cardona, Barry DeZonia, Christian Dietz, Jan Funke,
* Aivar Grislis, Jonathan Hale, Grant Harris, Stefan Helfrich, Mark Hiner,
* Martin Horn, Steffen Jaensch, Lee Kamentsky, Larry Lindsey, Melissa Linkert,
* Mark Longair, Brian Northan, Nick Perry, Curtis Rueden, Johannes Schindelin,
* Jean-Yves Tinevez and Michael Zinsmaier.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.display.projector.volatiles;
import net.imglib2.Cursor;
import net.imglib2.FinalInterval;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccess;
import net.imglib2.RandomAccessible;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.Volatile;
import net.imglib2.converter.Converter;
import net.imglib2.display.projector.IterableIntervalProjector2D;
import net.imglib2.view.Views;
/**
* {@link IterableIntervalProjector2D} for {@link Volatile} input. After each
* {@link #map()} call, the projector has a {@link #isValid() state} that
* signalizes whether all projected pixels were valid.
*
* @author Stephan Saalfeld
*/
public class Volatile2DRandomAccessibleProjector< T, A extends Volatile< T >, B > extends IterableIntervalProjector2D< A, B >
{
protected boolean valid = false;
public Volatile2DRandomAccessibleProjector( final int dimX, final int dimY, final RandomAccessible< A > source, final RandomAccessibleInterval< B > target, final Converter< ? super A, B > converter )
{
super( dimX, dimY, source, Views.iterable( target ), converter );
}
/**
* @return true if all mapped pixels were {@link Volatile#isValid() valid}.
*/
public boolean isValid()
{
return valid;
}
/**
* projects data from the source to the target and applies the former
* specified {@link Converter} e.g. for normalization.
*/
@Override
public void map()
{
// fix interval for all dimensions
for ( int d = 0; d < position.length; ++d )
min[ d ] = max[ d ] = position[ d ];
min[ 0 ] = target.min( 0 );
min[ 1 ] = target.min( 1 );
max[ 0 ] = target.max( 0 );
max[ 1 ] = target.max( 1 );
final IterableInterval< A > srcIterable = Views.iterable( Views.interval( source, new FinalInterval( min, max ) ) );
final Cursor< B > targetCursor = target.localizingCursor();
if ( target.iterationOrder().equals( srcIterable.iterationOrder() ) )
{
// use cursors
final Cursor< A > sourceCursor = srcIterable.cursor();
while ( targetCursor.hasNext() )
{
converter.convert( sourceCursor.next(), targetCursor.next() );
}
}
else
{
// use localizing cursor
final RandomAccess< A > sourceRandomAccess = source.randomAccess();
while ( targetCursor.hasNext() )
{
final B b = targetCursor.next();
sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 );
sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 );
converter.convert( sourceRandomAccess.get(), b );
}
}
}
}
| UTF-8 | Java | 4,377 | java | Volatile2DRandomAccessibleProjector.java | Java | [
{
"context": "essing library.\n * %%\n * Copyright (C) 2009 - 2023 Tobias Pietzsch, Stephan Preibisch, Stephan Saalfeld,\n * John Bog",
"end": 134,
"score": 0.9998170733451843,
"start": 119,
"tag": "NAME",
"value": "Tobias Pietzsch"
},
{
"context": "* %%\n * Copyright (C) 2009 - 2023... | null | [] | /*
* #%L
* ImgLib2: a general-purpose, multidimensional image processing library.
* %%
* Copyright (C) 2009 - 2023 <NAME>, <NAME>, <NAME>,
* <NAME>, <NAME>, <NAME>, <NAME>, <NAME>,
* <NAME>, <NAME>, <NAME>, <NAME>, <NAME>,
* <NAME>, <NAME>, <NAME>, <NAME>, <NAME>,
* <NAME>, <NAME>, <NAME>, <NAME>, <NAME>,
* <NAME> and <NAME>.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.display.projector.volatiles;
import net.imglib2.Cursor;
import net.imglib2.FinalInterval;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccess;
import net.imglib2.RandomAccessible;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.Volatile;
import net.imglib2.converter.Converter;
import net.imglib2.display.projector.IterableIntervalProjector2D;
import net.imglib2.view.Views;
/**
* {@link IterableIntervalProjector2D} for {@link Volatile} input. After each
* {@link #map()} call, the projector has a {@link #isValid() state} that
* signalizes whether all projected pixels were valid.
*
* @author <NAME>
*/
public class Volatile2DRandomAccessibleProjector< T, A extends Volatile< T >, B > extends IterableIntervalProjector2D< A, B >
{
protected boolean valid = false;
public Volatile2DRandomAccessibleProjector( final int dimX, final int dimY, final RandomAccessible< A > source, final RandomAccessibleInterval< B > target, final Converter< ? super A, B > converter )
{
super( dimX, dimY, source, Views.iterable( target ), converter );
}
/**
* @return true if all mapped pixels were {@link Volatile#isValid() valid}.
*/
public boolean isValid()
{
return valid;
}
/**
* projects data from the source to the target and applies the former
* specified {@link Converter} e.g. for normalization.
*/
@Override
public void map()
{
// fix interval for all dimensions
for ( int d = 0; d < position.length; ++d )
min[ d ] = max[ d ] = position[ d ];
min[ 0 ] = target.min( 0 );
min[ 1 ] = target.min( 1 );
max[ 0 ] = target.max( 0 );
max[ 1 ] = target.max( 1 );
final IterableInterval< A > srcIterable = Views.iterable( Views.interval( source, new FinalInterval( min, max ) ) );
final Cursor< B > targetCursor = target.localizingCursor();
if ( target.iterationOrder().equals( srcIterable.iterationOrder() ) )
{
// use cursors
final Cursor< A > sourceCursor = srcIterable.cursor();
while ( targetCursor.hasNext() )
{
converter.convert( sourceCursor.next(), targetCursor.next() );
}
}
else
{
// use localizing cursor
final RandomAccess< A > sourceRandomAccess = source.randomAccess();
while ( targetCursor.hasNext() )
{
final B b = targetCursor.next();
sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 );
sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 );
converter.convert( sourceRandomAccess.get(), b );
}
}
}
}
| 4,175 | 0.730409 | 0.72127 | 113 | 37.734512 | 35.290958 | 200 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.752212 | false | false | 10 |
68d1c3d78629207797f35be0dc1d474df835ebb9 | 4,922,032,557,907 | d9832e0c0eb46511d1d43e1ee50d290fb4219bb6 | /src/main/java/relationShips/Person.java | 0bb50ff83f43dd00805bc58350c0204ade73652b | [] | no_license | Instl11/JPA-Hibernate | https://github.com/Instl11/JPA-Hibernate | e0ca011060a92cb623e69901708c7d13e2264c52 | 8ae1d55861f6e098ab2cb09c0cb5dc5d54c9512e | refs/heads/master | 2022-10-17T08:38:13.932000 | 2019-08-25T12:16:21 | 2019-08-25T12:16:21 | 204,289,782 | 0 | 0 | null | false | 2022-09-08T01:02:24 | 2019-08-25T12:15:40 | 2019-08-25T12:16:51 | 2022-09-08T01:02:23 | 23 | 0 | 0 | 3 | Java | false | false | package relationShips;
import lombok.*;
import javax.persistence.*;
import java.util.List;
@Entity
@Data
@NoArgsConstructor @RequiredArgsConstructor
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@NonNull
private String name;
// @OneToMany(fetch = FetchType.LAZY)
// @NonNull
// private List<Hobbies> hobbies;
}
| UTF-8 | Java | 394 | java | Person.java | Java | [] | null | [] | package relationShips;
import lombok.*;
import javax.persistence.*;
import java.util.List;
@Entity
@Data
@NoArgsConstructor @RequiredArgsConstructor
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@NonNull
private String name;
// @OneToMany(fetch = FetchType.LAZY)
// @NonNull
// private List<Hobbies> hobbies;
}
| 394 | 0.71066 | 0.71066 | 23 | 16.130434 | 15.576751 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304348 | false | false | 10 |
e7e7c94d82d9f01d9cefbb460d876179b0c2c547 | 30,107,720,757,569 | 69c299731b5b7db45972460ae51a7cb5579804f8 | /src/hibernate_sql/User_ip.java | 9d3690c16ad27515f7222d892ebda5dd1cd94aaf | [] | no_license | yaogenum/book | https://github.com/yaogenum/book | 9d60d484a1b388293bddb3de29d76833e8593f28 | 3a7d1d786c1feb4024cddbb2a9ceb7ff93167e45 | refs/heads/master | 2021-01-16T21:16:32.395000 | 2015-02-05T11:11:21 | 2015-02-05T11:11:21 | 21,815,973 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hibernate_sql;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import hibernate.HibernateSessionFactory;
import hibernate.UsersLog;
import hibernate.UsersLogDAO;
public class User_ip {
public void set_ip(String ip){
UsersLog user=new UsersLog();
UsersLogDAO dao=new UsersLogDAO();
Session session=dao.getSession();
Transaction trans=session.beginTransaction();
String sql="select com_time from users_log where com_id=? ";
List<String> list=session.createSQLQuery(sql).addScalar("com_time").setString(0, ip).list();
if(list.isEmpty()){
user.setComId(ip);
user.setComTime( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()) );
user.setComAgain("0");
session.save(user);
}
else{
user=dao.findById(ip);
user.setComAgain( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
session.save(user);
}
trans.commit();
session.close();
}
}
| UTF-8 | Java | 1,088 | java | User_ip.java | Java | [] | null | [] | package hibernate_sql;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import hibernate.HibernateSessionFactory;
import hibernate.UsersLog;
import hibernate.UsersLogDAO;
public class User_ip {
public void set_ip(String ip){
UsersLog user=new UsersLog();
UsersLogDAO dao=new UsersLogDAO();
Session session=dao.getSession();
Transaction trans=session.beginTransaction();
String sql="select com_time from users_log where com_id=? ";
List<String> list=session.createSQLQuery(sql).addScalar("com_time").setString(0, ip).list();
if(list.isEmpty()){
user.setComId(ip);
user.setComTime( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()) );
user.setComAgain("0");
session.save(user);
}
else{
user=dao.findById(ip);
user.setComAgain( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
session.save(user);
}
trans.commit();
session.close();
}
}
| 1,088 | 0.714154 | 0.712316 | 46 | 22.652174 | 21.126141 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.021739 | false | false | 10 |
ceb4816fb5a3c1eb4ad4e5f23bb193761fef18eb | 8,624,294,362,635 | e8c5562af2dd74147a1f16f1900435f67f68a191 | /a2oj/YoungPhysicist.java | cb14e925c6f7340e0dc3f8636265b3897b93d1bc | [] | no_license | mnorbi/algo-practice | https://github.com/mnorbi/algo-practice | 580e31a0c4a063e7b5f444ed5261c565cbbdbe68 | f6c111e3806cafe774c771227b68376182e53077 | refs/heads/master | 2021-06-20T16:48:17.215000 | 2021-03-02T18:34:57 | 2021-03-02T18:34:57 | 36,954,467 | 4 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
import java.io.*;
class Solver{
public static void main(String[]args)throws Exception{
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
String line = br.readLine();
int n = Integer.valueOf(line);
int x = 0, y = 0, z = 0;
while(n-->0){
int[] arr = Arrays.stream(br.readLine().split("\\s+")).mapToInt(Integer::valueOf).toArray();
x += arr[0]; y += arr[1]; z += arr[2];
}
if (x == 0 && y == 0 && z == 0) System.out.println("YES");
else System.out.println("NO");
}
}
}
| UTF-8 | Java | 586 | java | YoungPhysicist.java | Java | [] | null | [] | import java.util.*;
import java.io.*;
class Solver{
public static void main(String[]args)throws Exception{
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
String line = br.readLine();
int n = Integer.valueOf(line);
int x = 0, y = 0, z = 0;
while(n-->0){
int[] arr = Arrays.stream(br.readLine().split("\\s+")).mapToInt(Integer::valueOf).toArray();
x += arr[0]; y += arr[1]; z += arr[2];
}
if (x == 0 && y == 0 && z == 0) System.out.println("YES");
else System.out.println("NO");
}
}
}
| 586 | 0.564846 | 0.547782 | 18 | 31.555555 | 27.948807 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.722222 | false | false | 10 |
f6f3d4154c48d281064cc6ec0f8fded6d573e97c | 32,882,269,661,264 | fb482c6f628829963384994d0c3f648db0967a82 | /src/lesson4/Exercise3.java | 4cd86c2353ec5905fe37736dd2ecabfffa5428d4 | [] | no_license | GreatUrsa/HomeWork | https://github.com/GreatUrsa/HomeWork | 616283b91b5c21c327901ee8d3b511d4924fd0dd | 66c9ec519b8bde23833d0bb26497911f7b1a072d | refs/heads/master | 2021-08-31T17:44:15.395000 | 2017-12-22T08:43:40 | 2017-12-22T08:43:40 | 107,969,953 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package lesson4;
/**
* Вычислить среднее значение вещественных чисел передаваемых на вход программы в качестве аргументов.
* Используйте цикл for, пример. Для преобразования из String в double используйте метод Double.parseDouble(String s).
*/
public class Exercise3 {
public static void main(String[] args) {
int len = args.length;
double sum = 0;
for (String str : args) {
sum += Double.parseDouble(str);
}
if (len == 0) {
System.out.println("Не заданы аргументы");
} else {
System.out.println("Среднее значение = " + sum / len);
}
}
}
| UTF-8 | Java | 818 | java | Exercise3.java | Java | [] | null | [] | package lesson4;
/**
* Вычислить среднее значение вещественных чисел передаваемых на вход программы в качестве аргументов.
* Используйте цикл for, пример. Для преобразования из String в double используйте метод Double.parseDouble(String s).
*/
public class Exercise3 {
public static void main(String[] args) {
int len = args.length;
double sum = 0;
for (String str : args) {
sum += Double.parseDouble(str);
}
if (len == 0) {
System.out.println("Не заданы аргументы");
} else {
System.out.println("Среднее значение = " + sum / len);
}
}
}
| 818 | 0.610592 | 0.604361 | 20 | 31.1 | 31.923189 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35 | false | false | 10 |
ac2f8fd912289c7ff7a3fb1c90403d5aa5951921 | 27,358,941,702,114 | 822e8268fb17256dd3b2aa71eb81323a8a66b27f | /gemfirexd/tools/src/test-ddlutils/java/org/apache/ddlutils/platform/TestPlatformUtils.java | 3d1100a2895af7cc8dd23fe0e328ac506519a58b | [
"LGPL-2.1-only",
"LicenseRef-scancode-other-permissive",
"Apache-1.1",
"GPL-2.0-only",
"Plexus",
"JSON",
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-generic-cla"
] | permissive | gemxd/gemfirexd-oss | https://github.com/gemxd/gemfirexd-oss | 3d096b2de5cd49f787e65d4ee65bb51cd35cab4b | d89cad2b075df92fc3acce09b9f8dc7b30be2445 | refs/heads/master | 2020-12-28T04:41:41.641000 | 2020-11-18T03:39:41 | 2020-11-18T03:39:41 | 48,769,190 | 13 | 9 | Apache-2.0 | false | 2018-10-12T07:42:55 | 2015-12-29T22:07:26 | 2018-06-17T22:03:24 | 2018-10-11T16:53:51 | 112,345 | 11 | 19 | 0 | Java | false | null | package org.apache.ddlutils.platform;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import junit.framework.TestCase;
import org.apache.ddlutils.PlatformUtils;
import org.apache.ddlutils.platform.axion.AxionPlatform;
import org.apache.ddlutils.platform.cloudscape.CloudscapePlatform;
import org.apache.ddlutils.platform.db2.Db2Platform;
import org.apache.ddlutils.platform.derby.DerbyPlatform;
import org.apache.ddlutils.platform.firebird.FirebirdPlatform;
import org.apache.ddlutils.platform.hsqldb.HsqlDbPlatform;
import org.apache.ddlutils.platform.interbase.InterbasePlatform;
import org.apache.ddlutils.platform.mckoi.MckoiPlatform;
import org.apache.ddlutils.platform.mssql.MSSqlPlatform;
import org.apache.ddlutils.platform.mysql.MySqlPlatform;
import org.apache.ddlutils.platform.oracle.Oracle8Platform;
import org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform;
import org.apache.ddlutils.platform.sapdb.SapDbPlatform;
import org.apache.ddlutils.platform.sybase.SybasePlatform;
/**
* Tests the {@link org.apache.ddlutils.PlatformUtils} class.
*
* @version $Revision: 279421 $
*/
public class TestPlatformUtils extends TestCase
{
/** The tested platform utils object. */
private PlatformUtils _platformUtils;
/**
* {@inheritDoc}
*/
protected void setUp() throws Exception
{
_platformUtils = new PlatformUtils();
}
/**
* {@inheritDoc}
*/
protected void tearDown() throws Exception
{
_platformUtils = null;
}
/**
* Tests the determination of the Axion platform via its JDBC driver.
*/
public void testAxionDriver()
{
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.axiondb.jdbc.AxionDriver", null));
}
/**
* Tests the determination of the Axion platform via JDBC connection urls.
*/
public void testAxionUrl()
{
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:axiondb:testdb"));
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:axiondb:testdb:/tmp/testdbdir"));
}
/**
* Tests the determination of the Db2 platform via its JDBC drivers.
*/
public void testDb2Driver()
{
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ibm.db2.jcc.DB2Driver", null));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver", null));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("COM.ibm.db2.jdbc.app.DB2Driver", null));
// DataDirect Connect
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.db2.DB2Driver", null));
// i-net
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.drda.DRDADriver", null));
}
/**
* Tests the determination of the Db2 platform via JDBC connection urls.
*/
public void testDb2Url()
{
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2://sysmvs1.stl.ibm.com:5021/san_jose"));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2os390://sysmvs1.stl.ibm.com:5021/san_jose"));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2os390sqlj://sysmvs1.stl.ibm.com:5021/san_jose"));
// DataDirect Connect
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:db2://server1:50000;DatabaseName=jdbc;User=test;Password=secret"));
// i-net
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdb2://server1:50000"));
}
/**
* Tests the determination of the Cloudscape platform via JDBC connection urls.
*/
public void testCloudscapeUrl()
{
assertEquals(CloudscapePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2j:net:database"));
assertEquals(CloudscapePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:cloudscape:net:database"));
}
/**
* Tests the determination of the Derby platform via its JDBC drivers.
*/
public void testDerbyDriver()
{
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.apache.derby.jdbc.ClientDriver", null));
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.apache.derby.jdbc.EmbeddedDriver", null));
}
/**
* Tests the determination of the Derby platform via JDBC connection urls.
*/
public void testDerbyUrl()
{
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:derby:sample"));
}
/**
* Tests the determination of the Firebird platform via its JDBC driver.
*/
public void testFirebirdDriver()
{
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.firebirdsql.jdbc.FBDriver", null));
}
/**
* Tests the determination of the Firebird platform via JDBC connection urls.
*/
public void testFirebirdUrl()
{
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql://localhost:8080/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:native:localhost/8080:/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:local://localhost:8080:/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:embedded:localhost/8080:/path/to/db.fdb"));
}
/**
* Tests the determination of the HsqlDb platform via its JDBC driver.
*/
public void testHsqldbDriver()
{
assertEquals(HsqlDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.hsqldb.jdbcDriver", null));
}
/**
* Tests the determination of the HsqlDb platform via JDBC connection urls.
*/
public void testHsqldbUrl()
{
assertEquals(HsqlDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:hsqldb:/opt/db/testdb"));
}
/**
* Tests the determination of the Interbase platform via its JDBC driver.
*/
public void testInterbaseDriver()
{
assertEquals(InterbasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("interbase.interclient.Driver", null));
}
/**
* Tests the determination of the Interbase platform via JDBC connection urls.
*/
public void testInterbaseUrl()
{
assertEquals(InterbasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:interbase://localhost/e:/testbed/database/employee.gdb"));
}
/**
* Tests the determination of the McKoi platform via its JDBC driver.
*/
public void testMckoiDriver()
{
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.mckoi.JDBCDriver", null));
}
/**
* Tests the determination of the McKoi platform via JDBC connection urls.
*/
public void testMckoiUrl()
{
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mckoi:local://./db.conf"));
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mckoi://db.myhost.org/"));
}
/**
* Tests the determination of the Microsoft Sql Server platform via its JDBC drivers.
*/
public void testMsSqlDriver()
{
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.microsoft.jdbc.sqlserver.SQLServerDriver", null));
// DataDirect Connect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.sqlserver.SQLServerDriver", null));
// JNetDirect JSQLConnect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.jnetdirect.jsql.JSQLDriver", null));
// i-net
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.tds.TdsDriver", null));
}
/**
* Tests the determination of the Microsoft Sql Server platform via JDBC connection urls.
*/
public void testMsSqlUrl()
{
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:microsoft:sqlserver://localhost:1433"));
// DataDirect Connect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:sqlserver://server1:1433;User=test;Password=secret"));
// JNetDirect JSQLConnect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:JSQLConnect://localhost/database=master/user=sa/sqlVersion=6"));
// i-net
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae:210.1.164.19:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae6:[2002:d201:a413::d201:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae7a://MyServer/pipe/sql/query"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae:210.1.164.19:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae6:[2002:d201:a413::d201:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae7a://MyServer/pipe/sql/query"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae:210.1.164.19:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae6:[2002:d201:a413::d201:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae7a://MyServer/pipe/sql/query"));
// jTDS
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:jtds:sqlserver://localhost:8080/test"));
}
/**
* Tests the determination of the MySql platform via its JDBC drivers.
*/
public void testMySqlDriver()
{
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.mysql.jdbc.Driver", null));
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.gjt.mm.mysql.Driver", null));
}
/**
* Tests the determination of the MySql platform via JDBC connection urls.
*/
public void testMySqlUrl()
{
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mysql://localhost:1234/test"));
}
/**
* Tests the determination of the Oracle 8 platform via its JDBC drivers.
*/
public void testOracleDriver()
{
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("oracle.jdbc.driver.OracleDriver", null));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("oracle.jdbc.dnlddriver.OracleDriver", null));
// DataDirect Connect
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.oracle.OracleDriver", null));
// i-net
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.ora.OraDriver", null));
}
/**
* Tests the determination of the Oracle 8 platform via JDBC connection urls.
*/
public void testOracleUrl()
{
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:thin:@myhost:1521:orcl"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:oci8:@(description=(address=(host=myhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:dnldthin:@myhost:1521:orcl"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:dnldthin:@myhost:1521:orcl"));
// DataDirect Connect
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:oracle://server3:1521;ServiceName=ORCL;User=test;Password=secret"));
// i-net
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetora:www.inetsoftware.de:1521:orcl?traceLevel=2"));
}
/**
* Tests the determination of the PostgreSql platform via its JDBC driver.
*/
public void testPostgreSqlDriver()
{
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.postgresql.Driver", null));
}
/**
* Tests the determination of the PostgreSql platform via JDBC connection urls.
*/
public void testPostgreSqlUrl()
{
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:postgresql://localhost:1234/test"));
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:postgresql://[::1]:5740/accounting"));
}
/**
* Tests the determination of the SapDb platform via its JDBC driver.
*/
public void testSapDbDriver()
{
assertEquals(SapDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sap.dbtech.jdbc.DriverSapDB", null));
}
/**
* Tests the determination of the SapDb platform via JDBC connection urls.
*/
public void testSapDbUrl()
{
assertEquals(SapDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:sapdb://servermachine:9876/TST"));
}
/**
* Tests the determination of the Sybase platform via its JDBC drivers.
*/
public void testSybaseDriver()
{
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sybase.jdbc.SybDriver", null));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sybase.jdbc2.jdbc.SybDriver", null));
// DataDirect Connect
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.sybase.SybaseDriver", null));
// i-net
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.syb.SybDriver", null));
}
/**
* Tests the determination of the Sybase platform via JDBC connection urls.
*/
public void testSybaseUrl()
{
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:sybase:Tds:xyz:3767orjdbc:sybase:Tds:130.214.90.27:3767"));
// DataDirect Connect
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:sybase://server2:5000;User=test;Password=secret"));
// i-net
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetsyb:www.inetsoftware.de:3333"));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetsyb:www.inetsoftware.de:3333"));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetsyb:www.inetsoftware.de:3333"));
// jTDS
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:jtds:sybase://localhost:8080/test"));
}
}
| UTF-8 | Java | 18,979 | java | TestPlatformUtils.java | Java | [
{
"context": "erver1:50000;DatabaseName=jdbc;User=test;Password=secret\"));\n // i-net\n assertEquals(Db2Plat",
"end": 4745,
"score": 0.9993195533752441,
"start": 4739,
"tag": "PASSWORD",
"value": "secret"
},
{
"context": "ype(null, \"jdbc:microsoft:sqlserver://localhos... | null | [] | package org.apache.ddlutils.platform;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import junit.framework.TestCase;
import org.apache.ddlutils.PlatformUtils;
import org.apache.ddlutils.platform.axion.AxionPlatform;
import org.apache.ddlutils.platform.cloudscape.CloudscapePlatform;
import org.apache.ddlutils.platform.db2.Db2Platform;
import org.apache.ddlutils.platform.derby.DerbyPlatform;
import org.apache.ddlutils.platform.firebird.FirebirdPlatform;
import org.apache.ddlutils.platform.hsqldb.HsqlDbPlatform;
import org.apache.ddlutils.platform.interbase.InterbasePlatform;
import org.apache.ddlutils.platform.mckoi.MckoiPlatform;
import org.apache.ddlutils.platform.mssql.MSSqlPlatform;
import org.apache.ddlutils.platform.mysql.MySqlPlatform;
import org.apache.ddlutils.platform.oracle.Oracle8Platform;
import org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform;
import org.apache.ddlutils.platform.sapdb.SapDbPlatform;
import org.apache.ddlutils.platform.sybase.SybasePlatform;
/**
* Tests the {@link org.apache.ddlutils.PlatformUtils} class.
*
* @version $Revision: 279421 $
*/
public class TestPlatformUtils extends TestCase
{
/** The tested platform utils object. */
private PlatformUtils _platformUtils;
/**
* {@inheritDoc}
*/
protected void setUp() throws Exception
{
_platformUtils = new PlatformUtils();
}
/**
* {@inheritDoc}
*/
protected void tearDown() throws Exception
{
_platformUtils = null;
}
/**
* Tests the determination of the Axion platform via its JDBC driver.
*/
public void testAxionDriver()
{
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.axiondb.jdbc.AxionDriver", null));
}
/**
* Tests the determination of the Axion platform via JDBC connection urls.
*/
public void testAxionUrl()
{
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:axiondb:testdb"));
assertEquals(AxionPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:axiondb:testdb:/tmp/testdbdir"));
}
/**
* Tests the determination of the Db2 platform via its JDBC drivers.
*/
public void testDb2Driver()
{
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ibm.db2.jcc.DB2Driver", null));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver", null));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("COM.ibm.db2.jdbc.app.DB2Driver", null));
// DataDirect Connect
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.db2.DB2Driver", null));
// i-net
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.drda.DRDADriver", null));
}
/**
* Tests the determination of the Db2 platform via JDBC connection urls.
*/
public void testDb2Url()
{
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2://sysmvs1.stl.ibm.com:5021/san_jose"));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2os390://sysmvs1.stl.ibm.com:5021/san_jose"));
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2os390sqlj://sysmvs1.stl.ibm.com:5021/san_jose"));
// DataDirect Connect
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:db2://server1:50000;DatabaseName=jdbc;User=test;Password=<PASSWORD>"));
// i-net
assertEquals(Db2Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdb2://server1:50000"));
}
/**
* Tests the determination of the Cloudscape platform via JDBC connection urls.
*/
public void testCloudscapeUrl()
{
assertEquals(CloudscapePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:db2j:net:database"));
assertEquals(CloudscapePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:cloudscape:net:database"));
}
/**
* Tests the determination of the Derby platform via its JDBC drivers.
*/
public void testDerbyDriver()
{
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.apache.derby.jdbc.ClientDriver", null));
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.apache.derby.jdbc.EmbeddedDriver", null));
}
/**
* Tests the determination of the Derby platform via JDBC connection urls.
*/
public void testDerbyUrl()
{
assertEquals(DerbyPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:derby:sample"));
}
/**
* Tests the determination of the Firebird platform via its JDBC driver.
*/
public void testFirebirdDriver()
{
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.firebirdsql.jdbc.FBDriver", null));
}
/**
* Tests the determination of the Firebird platform via JDBC connection urls.
*/
public void testFirebirdUrl()
{
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql://localhost:8080/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:native:localhost/8080:/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:local://localhost:8080:/path/to/db.fdb"));
assertEquals(FirebirdPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:firebirdsql:embedded:localhost/8080:/path/to/db.fdb"));
}
/**
* Tests the determination of the HsqlDb platform via its JDBC driver.
*/
public void testHsqldbDriver()
{
assertEquals(HsqlDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.hsqldb.jdbcDriver", null));
}
/**
* Tests the determination of the HsqlDb platform via JDBC connection urls.
*/
public void testHsqldbUrl()
{
assertEquals(HsqlDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:hsqldb:/opt/db/testdb"));
}
/**
* Tests the determination of the Interbase platform via its JDBC driver.
*/
public void testInterbaseDriver()
{
assertEquals(InterbasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("interbase.interclient.Driver", null));
}
/**
* Tests the determination of the Interbase platform via JDBC connection urls.
*/
public void testInterbaseUrl()
{
assertEquals(InterbasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:interbase://localhost/e:/testbed/database/employee.gdb"));
}
/**
* Tests the determination of the McKoi platform via its JDBC driver.
*/
public void testMckoiDriver()
{
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.mckoi.JDBCDriver", null));
}
/**
* Tests the determination of the McKoi platform via JDBC connection urls.
*/
public void testMckoiUrl()
{
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mckoi:local://./db.conf"));
assertEquals(MckoiPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mckoi://db.myhost.org/"));
}
/**
* Tests the determination of the Microsoft Sql Server platform via its JDBC drivers.
*/
public void testMsSqlDriver()
{
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.microsoft.jdbc.sqlserver.SQLServerDriver", null));
// DataDirect Connect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.sqlserver.SQLServerDriver", null));
// JNetDirect JSQLConnect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.jnetdirect.jsql.JSQLDriver", null));
// i-net
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.tds.TdsDriver", null));
}
/**
* Tests the determination of the Microsoft Sql Server platform via JDBC connection urls.
*/
public void testMsSqlUrl()
{
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:microsoft:sqlserver://localhost:1433"));
// DataDirect Connect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:sqlserver://server1:1433;User=test;Password=<PASSWORD>"));
// JNetDirect JSQLConnect
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:JSQLConnect://localhost/database=master/user=sa/sqlVersion=6"));
// i-net
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae:172.16.17.32:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae6:[fc00:e968:6179::de52:7100:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetdae7a://MyServer/pipe/sql/query"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae:172.16.17.32:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae6:[fc00:e968:6179::de52:7100:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetdae7a://MyServer/pipe/sql/query"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae:172.16.17.32:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae6:[fc00:e968:6179::de52:7100:a413]:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae7:localHost:1433"));
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetdae7a://MyServer/pipe/sql/query"));
// jTDS
assertEquals(MSSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:jtds:sqlserver://localhost:8080/test"));
}
/**
* Tests the determination of the MySql platform via its JDBC drivers.
*/
public void testMySqlDriver()
{
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.mysql.jdbc.Driver", null));
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.gjt.mm.mysql.Driver", null));
}
/**
* Tests the determination of the MySql platform via JDBC connection urls.
*/
public void testMySqlUrl()
{
assertEquals(MySqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:mysql://localhost:1234/test"));
}
/**
* Tests the determination of the Oracle 8 platform via its JDBC drivers.
*/
public void testOracleDriver()
{
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("oracle.jdbc.driver.OracleDriver", null));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("oracle.jdbc.dnlddriver.OracleDriver", null));
// DataDirect Connect
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.oracle.OracleDriver", null));
// i-net
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.ora.OraDriver", null));
}
/**
* Tests the determination of the Oracle 8 platform via JDBC connection urls.
*/
public void testOracleUrl()
{
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:thin:@myhost:1521:orcl"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:oci8:@(description=(address=(host=myhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:dnldthin:@myhost:1521:orcl"));
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:oracle:dnldthin:@myhost:1521:orcl"));
// DataDirect Connect
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:oracle://server3:1521;ServiceName=ORCL;User=test;Password=<PASSWORD>"));
// i-net
assertEquals(Oracle8Platform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetora:www.inetsoftware.de:1521:orcl?traceLevel=2"));
}
/**
* Tests the determination of the PostgreSql platform via its JDBC driver.
*/
public void testPostgreSqlDriver()
{
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("org.postgresql.Driver", null));
}
/**
* Tests the determination of the PostgreSql platform via JDBC connection urls.
*/
public void testPostgreSqlUrl()
{
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:postgresql://localhost:1234/test"));
assertEquals(PostgreSqlPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:postgresql://[::1]:5740/accounting"));
}
/**
* Tests the determination of the SapDb platform via its JDBC driver.
*/
public void testSapDbDriver()
{
assertEquals(SapDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sap.dbtech.jdbc.DriverSapDB", null));
}
/**
* Tests the determination of the SapDb platform via JDBC connection urls.
*/
public void testSapDbUrl()
{
assertEquals(SapDbPlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:sapdb://servermachine:9876/TST"));
}
/**
* Tests the determination of the Sybase platform via its JDBC drivers.
*/
public void testSybaseDriver()
{
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sybase.jdbc.SybDriver", null));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.sybase.jdbc2.jdbc.SybDriver", null));
// DataDirect Connect
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.ddtek.jdbc.sybase.SybaseDriver", null));
// i-net
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType("com.inet.syb.SybDriver", null));
}
/**
* Tests the determination of the Sybase platform via JDBC connection urls.
*/
public void testSybaseUrl()
{
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:sybase:Tds:xyz:3767orjdbc:sybase:Tds:172.16.31.10:3767"));
// DataDirect Connect
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:datadirect:sybase://server2:5000;User=test;Password=<PASSWORD>"));
// i-net
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetsyb:www.inetsoftware.de:3333"));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:inetsyb:www.inetsoftware.de:3333"));
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:inetpool:jdbc:inetsyb:www.inetsoftware.de:3333"));
// jTDS
assertEquals(SybasePlatform.DATABASENAME,
_platformUtils.determineDatabaseType(null, "jdbc:jtds:sybase://localhost:8080/test"));
}
}
| 19,009 | 0.670162 | 0.653143 | 430 | 43.137211 | 38.71809 | 174 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625581 | false | false | 10 |
293a9aa802e96b23d5b5f2bbfcbfdd686f49e02e | 29,111,288,371,219 | f8c31ce80dcbcbd621d67f50ae5d352580f851d5 | /src/main/java/io/machinecode/tools/build/Main.java | 706ec2303c31dc61d9935cf30e64d52435a60e98 | [] | no_license | BrentDouglas/tools | https://github.com/BrentDouglas/tools | b690b11fa9ccea92e6720b00042a638c02e48468 | a63b1a3c63bf84df90109bf3f4d2f3c91415f4fb | refs/heads/master | 2023-05-11T22:53:10.560000 | 2023-04-26T19:48:01 | 2023-04-26T19:48:01 | 181,468,694 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (C) 2018 Brent Douglas and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.machinecode.tools.build;
import gnu.getopt.Getopt;
import gnu.getopt.LongOpt;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Map;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile;
import org.stringtemplate.v4.STWriter;
import org.stringtemplate.v4.misc.ErrorBuffer;
import org.yaml.snakeyaml.Yaml;
/**
* @author <a href="mailto:brent.n.douglas@gmail.com">Brent Douglas</a>
*/
public class Main {
public static void main(final String... args) throws Exception {
final Getopt opt =
new Getopt(
"template",
args,
"m:t:o:v:",
new LongOpt[] {
new LongOpt("model", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
new LongOpt("template", LongOpt.REQUIRED_ARGUMENT, null, 't'),
new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
new LongOpt("version", LongOpt.REQUIRED_ARGUMENT, null, 'v'),
});
Path model = null;
Path template = null;
Path output = null;
String version = null;
int c;
while ((c = opt.getopt()) != -1) {
switch (c) {
case 'm':
model = Paths.get(opt.getOptarg());
break;
case 't':
template = Paths.get(opt.getOptarg());
break;
case 'o':
output = Paths.get(opt.getOptarg());
break;
case 'v':
version = opt.getOptarg();
break;
default:
throw new IllegalArgumentException("Invalid option");
}
}
generate(model, template, output, version);
}
private static void generate(
final Path model, final Path template, final Path output, final String version)
throws IOException {
final ErrorBuffer errors = new ErrorBuffer();
final STGroup group =
new STGroupFile(template.toAbsolutePath().toString(), StandardCharsets.UTF_8.name());
group.setListener(errors);
if (!errors.errors.isEmpty()) {
throw new IllegalArgumentException(errors.toString());
}
final ST st = group.getInstanceOf("test");
final Yaml yaml = new Yaml();
try (final Reader reader = Files.newBufferedReader(model)) {
final Map<String, Object> values = yaml.loadAs(reader, Map.class);
values.forEach(st::add);
}
write(st, output.toFile(), errors);
}
private static void write(final ST st, final File out, final ErrorBuffer errors)
throws IllegalArgumentException {
try {
st.write(out, errors, StandardCharsets.UTF_8.name(), Locale.ENGLISH, STWriter.NO_WRAP);
if (!errors.errors.isEmpty()) {
throw new IllegalArgumentException(errors.toString());
}
} catch (final IOException e) {
throw new IllegalArgumentException("Could not write file " + out.getAbsolutePath(), e);
}
}
}
| UTF-8 | Java | 3,741 | java | Main.java | Java | [
{
"context": "/*\n * Copyright (C) 2018 Brent Douglas and other contributors\n * as indicated by the @au",
"end": 38,
"score": 0.9998347163200378,
"start": 25,
"tag": "NAME",
"value": "Brent Douglas"
},
{
"context": "l.snakeyaml.Yaml;\n\n/**\n * @author <a href=\"mailto:brent.n.dougl... | null | [] | /*
* Copyright (C) 2018 <NAME> and other contributors
* as indicated by the @author tags. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.machinecode.tools.build;
import gnu.getopt.Getopt;
import gnu.getopt.LongOpt;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Map;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroup;
import org.stringtemplate.v4.STGroupFile;
import org.stringtemplate.v4.STWriter;
import org.stringtemplate.v4.misc.ErrorBuffer;
import org.yaml.snakeyaml.Yaml;
/**
* @author <a href="mailto:<EMAIL>"><NAME></a>
*/
public class Main {
public static void main(final String... args) throws Exception {
final Getopt opt =
new Getopt(
"template",
args,
"m:t:o:v:",
new LongOpt[] {
new LongOpt("model", LongOpt.REQUIRED_ARGUMENT, null, 'm'),
new LongOpt("template", LongOpt.REQUIRED_ARGUMENT, null, 't'),
new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
new LongOpt("version", LongOpt.REQUIRED_ARGUMENT, null, 'v'),
});
Path model = null;
Path template = null;
Path output = null;
String version = null;
int c;
while ((c = opt.getopt()) != -1) {
switch (c) {
case 'm':
model = Paths.get(opt.getOptarg());
break;
case 't':
template = Paths.get(opt.getOptarg());
break;
case 'o':
output = Paths.get(opt.getOptarg());
break;
case 'v':
version = opt.getOptarg();
break;
default:
throw new IllegalArgumentException("Invalid option");
}
}
generate(model, template, output, version);
}
private static void generate(
final Path model, final Path template, final Path output, final String version)
throws IOException {
final ErrorBuffer errors = new ErrorBuffer();
final STGroup group =
new STGroupFile(template.toAbsolutePath().toString(), StandardCharsets.UTF_8.name());
group.setListener(errors);
if (!errors.errors.isEmpty()) {
throw new IllegalArgumentException(errors.toString());
}
final ST st = group.getInstanceOf("test");
final Yaml yaml = new Yaml();
try (final Reader reader = Files.newBufferedReader(model)) {
final Map<String, Object> values = yaml.loadAs(reader, Map.class);
values.forEach(st::add);
}
write(st, output.toFile(), errors);
}
private static void write(final ST st, final File out, final ErrorBuffer errors)
throws IllegalArgumentException {
try {
st.write(out, errors, StandardCharsets.UTF_8.name(), Locale.ENGLISH, STWriter.NO_WRAP);
if (!errors.errors.isEmpty()) {
throw new IllegalArgumentException(errors.toString());
}
} catch (final IOException e) {
throw new IllegalArgumentException("Could not write file " + out.getAbsolutePath(), e);
}
}
}
| 3,709 | 0.654905 | 0.650628 | 112 | 32.401787 | 25.052608 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.785714 | false | false | 10 |
d3a3e7eb09d602f3571a6a807f0d9874b345eac5 | 25,589,415,196,197 | 021e2fc718afb0e40e72c2ca7c3ec46fa95e99e2 | /avro-java/producer/src/main/java/clients/Subscriber.java | 590a00e162c2428497e7cf9274d4108ba4b7d23b | [
"Apache-2.0"
] | permissive | barrosef/kafka-learn | https://github.com/barrosef/kafka-learn | 9e26e3360d3e4357c534509a1a7c643bad54050e | 90af16f5af8720c8180e316731c48eec767c3a06 | refs/heads/main | 2023-08-31T06:11:23.468000 | 2021-10-24T01:51:32 | 2021-10-24T01:51:32 | 419,156,861 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package clients;
import java.io.IOException;
import java.util.UUID;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import clients.VehiclePosition.VehicleValues;
import solution.model.PositionKey;
import solution.model.PositionValue;
public class Subscriber implements MqttCallback {
private final int qos = 1;
private String host = "ssl://mqtt.hsl.fi:8883";
private String clientId = "MQTT-Java-Example";
private String topic = "/hfp/v2/journey/ongoing/vp/#";
private String kafka_topic = "vehicle-positions-avro";
private MqttClient client;
private KafkaProducer<PositionKey, PositionValue> producer;
public Subscriber(KafkaProducer<PositionKey, PositionValue> producer) {
this.producer = producer;
}
public void start() throws MqttException {
MqttConnectOptions conOpt = new MqttConnectOptions();
conOpt.setCleanSession(true);
final String uuid = UUID.randomUUID().toString().replace("-", "");
String clientId = this.clientId + "-" + uuid;
this.client = new MqttClient(this.host, clientId, new MemoryPersistence());
this.client.setCallback(this);
this.client.connect(conOpt);
this.client.subscribe(this.topic, this.qos);
}
public void connectionLost(Throwable cause) {
System.out.println("Connection lost because: " + cause);
System.exit(1);
}
public void deliveryComplete(IMqttDeliveryToken token) {
}
public void messageArrived(String topic, MqttMessage message) throws MqttException {
try {
System.out.println(String.format("[%s] %s", topic, new String(message.getPayload())));
final PositionKey key = new PositionKey(topic);
final PositionValue value = getPositionValue(message.getPayload());
final ProducerRecord<PositionKey, PositionValue> record = new ProducerRecord<>(this.kafka_topic, key, value);
producer.send(record);
} catch (Exception e) {
}
}
private PositionValue getPositionValue(byte[] payload) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String json = new String(payload);
VehiclePosition pos = mapper.readValue(json, VehiclePosition.class);
VehicleValues vv = pos.VP;
return new PositionValue(vv.desi, vv.dir, vv.oper, vv.veh, vv.tst, vv.tsi, vv.spd, vv.hdg, vv.lat, vv.longitude,
vv.acc, vv.dl, vv.odo, vv.drst, vv.oday, vv.jrn, vv.line, vv.start, vv.loc, vv.stop, vv.route, vv.occu,
vv.seq);
}
}
| UTF-8 | Java | 2,811 | java | Subscriber.java | Java | [] | null | [] | package clients;
import java.io.IOException;
import java.util.UUID;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import clients.VehiclePosition.VehicleValues;
import solution.model.PositionKey;
import solution.model.PositionValue;
public class Subscriber implements MqttCallback {
private final int qos = 1;
private String host = "ssl://mqtt.hsl.fi:8883";
private String clientId = "MQTT-Java-Example";
private String topic = "/hfp/v2/journey/ongoing/vp/#";
private String kafka_topic = "vehicle-positions-avro";
private MqttClient client;
private KafkaProducer<PositionKey, PositionValue> producer;
public Subscriber(KafkaProducer<PositionKey, PositionValue> producer) {
this.producer = producer;
}
public void start() throws MqttException {
MqttConnectOptions conOpt = new MqttConnectOptions();
conOpt.setCleanSession(true);
final String uuid = UUID.randomUUID().toString().replace("-", "");
String clientId = this.clientId + "-" + uuid;
this.client = new MqttClient(this.host, clientId, new MemoryPersistence());
this.client.setCallback(this);
this.client.connect(conOpt);
this.client.subscribe(this.topic, this.qos);
}
public void connectionLost(Throwable cause) {
System.out.println("Connection lost because: " + cause);
System.exit(1);
}
public void deliveryComplete(IMqttDeliveryToken token) {
}
public void messageArrived(String topic, MqttMessage message) throws MqttException {
try {
System.out.println(String.format("[%s] %s", topic, new String(message.getPayload())));
final PositionKey key = new PositionKey(topic);
final PositionValue value = getPositionValue(message.getPayload());
final ProducerRecord<PositionKey, PositionValue> record = new ProducerRecord<>(this.kafka_topic, key, value);
producer.send(record);
} catch (Exception e) {
}
}
private PositionValue getPositionValue(byte[] payload) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String json = new String(payload);
VehiclePosition pos = mapper.readValue(json, VehiclePosition.class);
VehicleValues vv = pos.VP;
return new PositionValue(vv.desi, vv.dir, vv.oper, vv.veh, vv.tst, vv.tsi, vv.spd, vv.hdg, vv.lat, vv.longitude,
vv.acc, vv.dl, vv.odo, vv.drst, vv.oday, vv.jrn, vv.line, vv.start, vv.loc, vv.stop, vv.route, vv.occu,
vv.seq);
}
}
| 2,811 | 0.683387 | 0.680185 | 74 | 36.986488 | 31.86097 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 10 |
ed1357c2302d87c5a8f0337ad8e9f1ac511ddd4d | 15,341,623,224,626 | 3b91ed788572b6d5ac4db1bee814a74560603578 | /com/tencent/mm/plugin/appbrand/jsapi/j/e$b$4.java | ba20168c7941412a174bc7e1a10327602fe26aec | [] | no_license | linsir6/WeChat_java | https://github.com/linsir6/WeChat_java | a1deee3035b555fb35a423f367eb5e3e58a17cb0 | 32e52b88c012051100315af6751111bfb6697a29 | refs/heads/master | 2020-05-31T05:40:17.161000 | 2018-08-28T02:07:02 | 2018-08-28T02:07:02 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tencent.mm.plugin.appbrand.jsapi.j;
import com.tencent.mm.plugin.appbrand.jsapi.c;
import com.tencent.mm.plugin.appbrand.jsapi.j.e.a;
import com.tencent.mm.plugin.appbrand.jsapi.j.e.b;
import com.tencent.mm.plugin.appbrand.page.p;
import com.tencent.mm.plugin.appbrand.widget.picker.d$b;
import java.util.HashMap;
import java.util.Map;
class e$b$4 implements d$b<int[]> {
final /* synthetic */ b fXl;
e$b$4(b bVar) {
this.fXl = bVar;
}
public final /* synthetic */ void bl(Object obj) {
c cVar;
int[] iArr = (int[]) obj;
int i = iArr[0];
int i2 = iArr[1];
a aVar = new a((byte) 0);
Map hashMap = new HashMap(2);
hashMap.put("errMsg", "ok");
hashMap.put("column", Integer.valueOf(i));
hashMap.put("current", Integer.valueOf(i2));
aVar.x(hashMap);
b bVar = this.fXl;
if (bVar.mPageRef == null) {
cVar = null;
} else {
p cVar2 = (p) bVar.mPageRef.get();
}
if (cVar2 != null) {
aVar.a(cVar2).h(new int[]{cVar2.hashCode()});
}
}
}
| UTF-8 | Java | 1,134 | java | e$b$4.java | Java | [] | null | [] | package com.tencent.mm.plugin.appbrand.jsapi.j;
import com.tencent.mm.plugin.appbrand.jsapi.c;
import com.tencent.mm.plugin.appbrand.jsapi.j.e.a;
import com.tencent.mm.plugin.appbrand.jsapi.j.e.b;
import com.tencent.mm.plugin.appbrand.page.p;
import com.tencent.mm.plugin.appbrand.widget.picker.d$b;
import java.util.HashMap;
import java.util.Map;
class e$b$4 implements d$b<int[]> {
final /* synthetic */ b fXl;
e$b$4(b bVar) {
this.fXl = bVar;
}
public final /* synthetic */ void bl(Object obj) {
c cVar;
int[] iArr = (int[]) obj;
int i = iArr[0];
int i2 = iArr[1];
a aVar = new a((byte) 0);
Map hashMap = new HashMap(2);
hashMap.put("errMsg", "ok");
hashMap.put("column", Integer.valueOf(i));
hashMap.put("current", Integer.valueOf(i2));
aVar.x(hashMap);
b bVar = this.fXl;
if (bVar.mPageRef == null) {
cVar = null;
} else {
p cVar2 = (p) bVar.mPageRef.get();
}
if (cVar2 != null) {
aVar.a(cVar2).h(new int[]{cVar2.hashCode()});
}
}
}
| 1,134 | 0.567901 | 0.557319 | 39 | 28.076923 | 17.632116 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 10 |
0d30abb5846732113316b91d0aedf2a99f826999 | 16,896,401,396,307 | 00a991264898ffa85db4dc076d1ac1e030eee6a6 | /app/src/main/java/com/example/hc/chat/MyApplication.java | 5b0f0f5dedfe3767913df05c259e2a4c9f52f471 | [] | no_license | coffeehu/Chat | https://github.com/coffeehu/Chat | bb9bc5ef7403e62ef5eeb8457ca93ec42279cdc0 | 34369984055e6d1f9d6a80c4bf0f80b3a0212edf | refs/heads/master | 2021-01-11T16:59:41.439000 | 2018-03-29T02:05:18 | 2018-03-29T02:05:18 | 68,822,062 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.hc.chat;
import android.app.Application;
import com.example.hc.chat.data.Friend;
import com.example.hc.chat.data.MyMessage;
import com.example.hc.chat.util.ConnectionThread;
import java.util.HashMap;
import java.util.List;
/**
* Created by hc on 2016/8/31.
*/
public class MyApplication extends Application {
private String id;
private ConnectionThread connectionThread;
private List<Friend> friends;
private List<Friend> watchList;
private List<Friend> fansList;
private HashMap<String, List<MyMessage>> messagesMap = new HashMap<>();
private int softKeyboardHeight;
public void setId(String id) {
this.id = id;
}
public void setConnectionThread(ConnectionThread connectionThread) {
this.connectionThread = connectionThread;
}
public void setFriends(List<Friend> friends) {
this.friends = friends;
}
public void setFansList(List<Friend> fansList) {
this.fansList = fansList;
}
public void setWatchList(List<Friend> watchList) {
this.watchList = watchList;
}
public void setMessagesMap(HashMap<String, List<MyMessage>> messagesMap) {
this.messagesMap = messagesMap;
}
public void setSoftKeyboardHeight(int softKeyboardHeight) {
this.softKeyboardHeight = softKeyboardHeight;
}
public String getId() {
return id;
}
public ConnectionThread getConnectionThread() {
return connectionThread;
}
public List<Friend> getFriends() {
return friends;
}
public List<Friend> getFansList() {
return fansList;
}
public List<Friend> getWatchList() {
return watchList;
}
public HashMap<String, List<MyMessage>> getMessagesMap() {
return messagesMap;
}
public int getSoftKeyboardHeight() {
return softKeyboardHeight;
}
}
| UTF-8 | Java | 1,894 | java | MyApplication.java | Java | [
{
"context": "HashMap;\nimport java.util.List;\n\n/**\n * Created by hc on 2016/8/31.\n */\npublic class MyApplication exte",
"end": 267,
"score": 0.5604971647262573,
"start": 265,
"tag": "USERNAME",
"value": "hc"
}
] | null | [] | package com.example.hc.chat;
import android.app.Application;
import com.example.hc.chat.data.Friend;
import com.example.hc.chat.data.MyMessage;
import com.example.hc.chat.util.ConnectionThread;
import java.util.HashMap;
import java.util.List;
/**
* Created by hc on 2016/8/31.
*/
public class MyApplication extends Application {
private String id;
private ConnectionThread connectionThread;
private List<Friend> friends;
private List<Friend> watchList;
private List<Friend> fansList;
private HashMap<String, List<MyMessage>> messagesMap = new HashMap<>();
private int softKeyboardHeight;
public void setId(String id) {
this.id = id;
}
public void setConnectionThread(ConnectionThread connectionThread) {
this.connectionThread = connectionThread;
}
public void setFriends(List<Friend> friends) {
this.friends = friends;
}
public void setFansList(List<Friend> fansList) {
this.fansList = fansList;
}
public void setWatchList(List<Friend> watchList) {
this.watchList = watchList;
}
public void setMessagesMap(HashMap<String, List<MyMessage>> messagesMap) {
this.messagesMap = messagesMap;
}
public void setSoftKeyboardHeight(int softKeyboardHeight) {
this.softKeyboardHeight = softKeyboardHeight;
}
public String getId() {
return id;
}
public ConnectionThread getConnectionThread() {
return connectionThread;
}
public List<Friend> getFriends() {
return friends;
}
public List<Friend> getFansList() {
return fansList;
}
public List<Friend> getWatchList() {
return watchList;
}
public HashMap<String, List<MyMessage>> getMessagesMap() {
return messagesMap;
}
public int getSoftKeyboardHeight() {
return softKeyboardHeight;
}
}
| 1,894 | 0.677402 | 0.673706 | 79 | 22.974684 | 21.523008 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.392405 | false | false | 10 |
8b4e236313f0e0aaa79c00a4f323b5392f3692ef | 18,047,452,598,728 | d8a46359a86300a37e04196129c4b0f447164311 | /src/main/java/com/liu/personalblog/DAO/LoginTicketDao.java | 24e9d4365768c2fcfd8210ec57bce07c9821a693 | [] | no_license | liuwenyushan/liu-sBlog | https://github.com/liuwenyushan/liu-sBlog | 50885b9a90f578708680597444cf1c1809f05410 | 1cbb5a5115b6ba9074221d22ec79b757ffb90b18 | refs/heads/master | 2020-03-18T19:21:49.465000 | 2018-05-28T13:41:31 | 2018-05-28T13:41:31 | 135,149,875 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.liu.personalblog.DAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.liu.personalblog.Entity.LoginTicket;
import com.liu.personalblog.Repository.LoginTicketRepository;
@Component
public class LoginTicketDao {
@Autowired
LoginTicketRepository loginTicketRespository;
public void insertLoginTicket(LoginTicket loginTicket) {
loginTicketRespository.save(loginTicket);
}
public LoginTicket selectById(int id) {
return loginTicketRespository.findOne(id);
}
public LoginTicket selectByTicket(String ticket) {
return null;
}
public void updateStatus(String ticket, int status) {
}
public void deleteById(int id) {
loginTicketRespository.delete(id);
}
}
| UTF-8 | Java | 764 | java | LoginTicketDao.java | Java | [] | null | [] | package com.liu.personalblog.DAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.liu.personalblog.Entity.LoginTicket;
import com.liu.personalblog.Repository.LoginTicketRepository;
@Component
public class LoginTicketDao {
@Autowired
LoginTicketRepository loginTicketRespository;
public void insertLoginTicket(LoginTicket loginTicket) {
loginTicketRespository.save(loginTicket);
}
public LoginTicket selectById(int id) {
return loginTicketRespository.findOne(id);
}
public LoginTicket selectByTicket(String ticket) {
return null;
}
public void updateStatus(String ticket, int status) {
}
public void deleteById(int id) {
loginTicketRespository.delete(id);
}
}
| 764 | 0.803665 | 0.803665 | 34 | 21.470589 | 22.638119 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.911765 | false | false | 10 |
9b0f0e4ad0d3125931199ead4ff413cfd39cada1 | 7,026,566,516,169 | 3adfccc78cac4fe98c73704c058cd43ff54d67e5 | /src/main/java/ae/rta/dls/backend/service/mapper/prd/DrivingLicenseMapper.java | 052832e6a8b5d992bdd4f1b3cb9c44b100cdab50 | [] | no_license | BulkSecurityGeneratorProject/dls-backend-aman | https://github.com/BulkSecurityGeneratorProject/dls-backend-aman | 3c566400006879cbc7599f9f2e1b2ea1ce6ef820 | 3dec9e6a9d1a06432ab6b7fb9f4663d3018b5cb7 | refs/heads/master | 2022-12-23T15:07:07.192000 | 2020-07-28T15:00:57 | 2020-07-28T15:00:57 | 296,604,162 | 0 | 0 | null | true | 2020-09-18T11:40:42 | 2020-09-18T11:40:42 | 2020-07-28T15:02:01 | 2020-07-28T15:01:57 | 675 | 0 | 0 | 0 | null | false | false | package ae.rta.dls.backend.service.mapper.prd;
import ae.rta.dls.backend.domain.prd.DrivingLicense;
import ae.rta.dls.backend.service.dto.prd.DrivingLicenseDTO;
import ae.rta.dls.backend.service.mapper.EntityMapper;
import org.mapstruct.*;
/**
* Mapper for the entity DrivingLicense and its DTO DrivingLicenseDTO.
*/
@Mapper(componentModel = "spring", uses = {})
public interface DrivingLicenseMapper extends EntityMapper<DrivingLicenseDTO, DrivingLicense> {
default DrivingLicense fromId(Long id) {
if (id == null) {
return null;
}
DrivingLicense drivingLicense = new DrivingLicense();
drivingLicense.setId(id);
return drivingLicense;
}
}
| UTF-8 | Java | 708 | java | DrivingLicenseMapper.java | Java | [] | null | [] | package ae.rta.dls.backend.service.mapper.prd;
import ae.rta.dls.backend.domain.prd.DrivingLicense;
import ae.rta.dls.backend.service.dto.prd.DrivingLicenseDTO;
import ae.rta.dls.backend.service.mapper.EntityMapper;
import org.mapstruct.*;
/**
* Mapper for the entity DrivingLicense and its DTO DrivingLicenseDTO.
*/
@Mapper(componentModel = "spring", uses = {})
public interface DrivingLicenseMapper extends EntityMapper<DrivingLicenseDTO, DrivingLicense> {
default DrivingLicense fromId(Long id) {
if (id == null) {
return null;
}
DrivingLicense drivingLicense = new DrivingLicense();
drivingLicense.setId(id);
return drivingLicense;
}
}
| 708 | 0.716102 | 0.716102 | 25 | 27.32 | 26.927637 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44 | false | false | 10 |
7795814564f9a0beff18605679a45e1768771d49 | 10,015,863,747,479 | 105c75011f664769b62c6fe184f4285393785f32 | /Training/src/patterns/_15_chain_of_responsibility_2/BankomatApp.java | 7861bce71776b1807e579c87418b9195b1cd5e91 | [] | no_license | volta-ua/Spring | https://github.com/volta-ua/Spring | 404de6c31cd793292803f1c4947f1e57cd3cca4c | d8805bd19bb94d0fecaf7a5b75353cf983641676 | refs/heads/master | 2021-06-23T03:23:55.690000 | 2019-10-20T23:22:04 | 2019-10-20T23:22:04 | 216,426,309 | 0 | 0 | null | false | 2020-10-13T16:51:52 | 2019-10-20T20:55:37 | 2019-10-20T23:22:13 | 2020-10-13T16:51:51 | 1,606 | 0 | 0 | 1 | Java | false | false | package patterns._15_chain_of_responsibility_2;
public class BankomatApp {
public static void main(String[] args) {
NoteModule noteModule500=new NoteModule500();
NoteModule noteModule200=new NoteModule200();
NoteModule noteModule100=new NoteModule100();
NoteModule noteModule50=new NoteModule50();
NoteModule noteModule20=new NoteModule20();
NoteModule noteModule10=new NoteModule10();
noteModule500.setNextMoneyModule(noteModule200);
noteModule200.setNextMoneyModule(noteModule100);
noteModule100.setNextMoneyModule(noteModule50);
noteModule50.setNextMoneyModule(noteModule20);
noteModule20.setNextMoneyModule(noteModule10);
noteModule500.takeMoney(new Money(410));
}
}
class Note{
public static final int H10=10;
public static final int H20=20;
public static final int H50=50;
public static final int H100=100;
public static final int H200=200;
public static final int H500=500;
}
class Money{
private int amt;
public int getAmt() {
return amt;
}
public void setAmt(int amt) {
if (amt>=Note.H10 && amt<=10_000 && amt%Note.H10==0)
this.amt = amt;
else
throw new RuntimeException("Сума грошей має бути в діапазоні 10-10 тис. грн. і кратна 10 грн.");
}
public Money(int amt) {
setAmt(amt);
}
}
abstract class NoteModule{
protected NoteModule next;
abstract void takeMoney(Money money);
void setNextMoneyModule(NoteModule module) {
next=module;
}
}
abstract class SuperNoteModule extends NoteModule{
int nominal;
public SuperNoteModule(int nominal) {this.nominal = nominal;}
@Override
void takeMoney(Money money) {
int countNote=money.getAmt()/nominal;
int remind=money.getAmt()%nominal;
if (countNote>0)
System.out.println("Видано "+countNote +" купюр номіналом "+ nominal);
if (remind>0 && next!=null)
next.takeMoney(new Money(remind));
}
}
/*
class NoteModule500 extends SuperNoteModule{public NoteModule500(){nominal=500;}}
class NoteModule200 extends SuperNoteModule{public NoteModule200(){nominal=200;}}
class NoteModule100 extends SuperNoteModule{public NoteModule100(){nominal=100;}}
class NoteModule50 extends SuperNoteModule{public NoteModule50(){nominal=50;}}
class NoteModule20 extends SuperNoteModule{public NoteModule20(){nominal=20;}}
class NoteModule10 extends SuperNoteModule{public NoteModule10(){nominal=10;}}
*/
class NoteModule500 extends SuperNoteModule{public NoteModule500(){super(Note.H500);}}
class NoteModule200 extends SuperNoteModule{public NoteModule200(){super(Note.H200);}}
class NoteModule100 extends SuperNoteModule{public NoteModule100(){super(Note.H100);}}
class NoteModule50 extends SuperNoteModule{public NoteModule50(){super(Note.H50);}}
class NoteModule20 extends SuperNoteModule{public NoteModule20(){super(Note.H20);}}
class NoteModule10 extends SuperNoteModule{public NoteModule10(){super(Note.H10);}} | WINDOWS-1251 | Java | 2,990 | java | BankomatApp.java | Java | [] | null | [] | package patterns._15_chain_of_responsibility_2;
public class BankomatApp {
public static void main(String[] args) {
NoteModule noteModule500=new NoteModule500();
NoteModule noteModule200=new NoteModule200();
NoteModule noteModule100=new NoteModule100();
NoteModule noteModule50=new NoteModule50();
NoteModule noteModule20=new NoteModule20();
NoteModule noteModule10=new NoteModule10();
noteModule500.setNextMoneyModule(noteModule200);
noteModule200.setNextMoneyModule(noteModule100);
noteModule100.setNextMoneyModule(noteModule50);
noteModule50.setNextMoneyModule(noteModule20);
noteModule20.setNextMoneyModule(noteModule10);
noteModule500.takeMoney(new Money(410));
}
}
class Note{
public static final int H10=10;
public static final int H20=20;
public static final int H50=50;
public static final int H100=100;
public static final int H200=200;
public static final int H500=500;
}
class Money{
private int amt;
public int getAmt() {
return amt;
}
public void setAmt(int amt) {
if (amt>=Note.H10 && amt<=10_000 && amt%Note.H10==0)
this.amt = amt;
else
throw new RuntimeException("Сума грошей має бути в діапазоні 10-10 тис. грн. і кратна 10 грн.");
}
public Money(int amt) {
setAmt(amt);
}
}
abstract class NoteModule{
protected NoteModule next;
abstract void takeMoney(Money money);
void setNextMoneyModule(NoteModule module) {
next=module;
}
}
abstract class SuperNoteModule extends NoteModule{
int nominal;
public SuperNoteModule(int nominal) {this.nominal = nominal;}
@Override
void takeMoney(Money money) {
int countNote=money.getAmt()/nominal;
int remind=money.getAmt()%nominal;
if (countNote>0)
System.out.println("Видано "+countNote +" купюр номіналом "+ nominal);
if (remind>0 && next!=null)
next.takeMoney(new Money(remind));
}
}
/*
class NoteModule500 extends SuperNoteModule{public NoteModule500(){nominal=500;}}
class NoteModule200 extends SuperNoteModule{public NoteModule200(){nominal=200;}}
class NoteModule100 extends SuperNoteModule{public NoteModule100(){nominal=100;}}
class NoteModule50 extends SuperNoteModule{public NoteModule50(){nominal=50;}}
class NoteModule20 extends SuperNoteModule{public NoteModule20(){nominal=20;}}
class NoteModule10 extends SuperNoteModule{public NoteModule10(){nominal=10;}}
*/
class NoteModule500 extends SuperNoteModule{public NoteModule500(){super(Note.H500);}}
class NoteModule200 extends SuperNoteModule{public NoteModule200(){super(Note.H200);}}
class NoteModule100 extends SuperNoteModule{public NoteModule100(){super(Note.H100);}}
class NoteModule50 extends SuperNoteModule{public NoteModule50(){super(Note.H50);}}
class NoteModule20 extends SuperNoteModule{public NoteModule20(){super(Note.H20);}}
class NoteModule10 extends SuperNoteModule{public NoteModule10(){super(Note.H10);}} | 2,990 | 0.75094 | 0.681927 | 87 | 31.666666 | 28.492252 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.505747 | false | false | 10 |
ae70ea826896faa0bacaa645c25895f336e71405 | 10,015,863,748,510 | d84bfaf422350cb50c2116e1eef99bae5e5e685a | /erphero/src/main/java/com/erphero/vo/Inbound.java | 0a505514a521a6672c2a904128b59eeb1768c409 | [] | no_license | KIR-0w0/ErpHero | https://github.com/KIR-0w0/ErpHero | e19b2ae68bd00a155f1b1958753b886715babdf8 | 9375e57620472ff2996821aba71e3ddcdce7884d | refs/heads/main | 2023-08-23T22:32:09.193000 | 2021-09-16T00:46:48 | 2021-09-16T00:46:48 | 390,616,522 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.erphero.vo;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class Inbound {
private String code;
@JsonFormat(pattern="yyyy-MM-dd")
private Date date;
private String managerCode;
private String managerName;
private String empCode;
private String venderCode;
private String venderName;
private String stage; //마감구분(검사, 처리)
private String status;
private String saveStatus;
private String locationNo;
private long quantity;
private List<InboundProduct> inboundProducts;
@JsonFormat(pattern="yyyy-MM-dd")
private Date finishDate;
@JsonFormat(pattern="yyyy-MM-dd")
private Date confirmedDate;
}
| UTF-8 | Java | 791 | java | Inbound.java | Java | [] | null | [] | package com.erphero.vo;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class Inbound {
private String code;
@JsonFormat(pattern="yyyy-MM-dd")
private Date date;
private String managerCode;
private String managerName;
private String empCode;
private String venderCode;
private String venderName;
private String stage; //마감구분(검사, 처리)
private String status;
private String saveStatus;
private String locationNo;
private long quantity;
private List<InboundProduct> inboundProducts;
@JsonFormat(pattern="yyyy-MM-dd")
private Date finishDate;
@JsonFormat(pattern="yyyy-MM-dd")
private Date confirmedDate;
}
| 791 | 0.787097 | 0.787097 | 34 | 21.794117 | 12.491831 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.205882 | false | false | 10 |
06b8221a74f1c3808fd8b060ea042fa4b938a4fb | 34,565,896,808,090 | 1633e3d4d0df2ff05f37e2129e56ebb9bb7c62c1 | /Ysop-JavaFx/src/application/AddCinemaView.java | 15b103702cae6beacf8458115dcf1e40f028edc4 | [] | no_license | rotemmi/Cinema_Manager_System | https://github.com/rotemmi/Cinema_Manager_System | ce9a6ae418fbf7b6249a47559caaa02245d8baa7 | bf5d9fe8b8d86d21e276d163e3232dbced5eeee6 | refs/heads/main | 2023-04-02T14:38:13.659000 | 2021-04-13T09:45:36 | 2021-04-13T09:45:36 | 357,493,919 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package application;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Optional;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceDialog;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class AddCinemaView extends AdminView
{
protected Stage stageAddCinema;
static AddCinemaView addCinemaView= new AddCinemaView();
public static AddCinemaView getAddCinemaView()
{
return addCinemaView;
}
protected void addCinemaWindow() throws IOException
{
Parent cinema = FXMLLoader.load(MainController.class.getResource("/application/AddRemoveCinema.fxml"));
stageAddCinema = new Stage();
stageAddCinema.initModality(Modality.APPLICATION_MODAL);
stageAddCinema.initOwner(stageAdmin);
Scene scene = new Scene(cinema);
stageAddCinema.setScene(scene);
stageAddCinema.showAndWait();
}
protected void showMessage(String msg)
{
Alert a = new Alert(AlertType.INFORMATION);
a.setTitle("Add Cinema Message");
a.setHeaderText(msg);
a.show();
}
protected String deleteCinemaPress(ArrayList<String>choices)
{
ChoiceDialog<String> dialog = new ChoiceDialog<>("Select Cinema Name", choices);
dialog.setTitle("Delete Cinema");
dialog.setHeaderText("Delete Cinema");
dialog.setContentText("Choose Cinema to Delete ");
Optional<String> result = dialog.showAndWait();
if (result.isPresent())
{
return result.get();
}
return "";
}
public Integer showAlertOverride()
{
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Warning");
alert.setContentText("The cinema is exist , do you want to Override?");
ButtonType okButton = new ButtonType("Yes", ButtonData.YES);
ButtonType noButton = new ButtonType("No", ButtonData.NO);
alert.getButtonTypes().setAll(okButton, noButton);
Optional<ButtonType> result = alert.showAndWait();
if(result.isPresent())
{
if(result.get().getButtonData() == ButtonData.YES)
{
return 1;
}
return 0;
}
return -1;
}
}
| UTF-8 | Java | 2,247 | java | AddCinemaView.java | Java | [] | null | [] | package application;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Optional;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceDialog;
import javafx.stage.Modality;
import javafx.stage.Stage;
public class AddCinemaView extends AdminView
{
protected Stage stageAddCinema;
static AddCinemaView addCinemaView= new AddCinemaView();
public static AddCinemaView getAddCinemaView()
{
return addCinemaView;
}
protected void addCinemaWindow() throws IOException
{
Parent cinema = FXMLLoader.load(MainController.class.getResource("/application/AddRemoveCinema.fxml"));
stageAddCinema = new Stage();
stageAddCinema.initModality(Modality.APPLICATION_MODAL);
stageAddCinema.initOwner(stageAdmin);
Scene scene = new Scene(cinema);
stageAddCinema.setScene(scene);
stageAddCinema.showAndWait();
}
protected void showMessage(String msg)
{
Alert a = new Alert(AlertType.INFORMATION);
a.setTitle("Add Cinema Message");
a.setHeaderText(msg);
a.show();
}
protected String deleteCinemaPress(ArrayList<String>choices)
{
ChoiceDialog<String> dialog = new ChoiceDialog<>("Select Cinema Name", choices);
dialog.setTitle("Delete Cinema");
dialog.setHeaderText("Delete Cinema");
dialog.setContentText("Choose Cinema to Delete ");
Optional<String> result = dialog.showAndWait();
if (result.isPresent())
{
return result.get();
}
return "";
}
public Integer showAlertOverride()
{
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Warning");
alert.setContentText("The cinema is exist , do you want to Override?");
ButtonType okButton = new ButtonType("Yes", ButtonData.YES);
ButtonType noButton = new ButtonType("No", ButtonData.NO);
alert.getButtonTypes().setAll(okButton, noButton);
Optional<ButtonType> result = alert.showAndWait();
if(result.isPresent())
{
if(result.get().getButtonData() == ButtonData.YES)
{
return 1;
}
return 0;
}
return -1;
}
}
| 2,247 | 0.743213 | 0.741878 | 85 | 25.435293 | 22.996391 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.776471 | false | false | 10 |
33f8e61ebaf48a52436a864f0d3806389771968f | 5,720,896,473,395 | 3f11d69cdc460bcef1b9b84dc5796836d306d03c | /app/src/main/java/com/ingic/lmslawyer/ui/binder/BookmarkBinder.java | e141930cb648b01fbf78496af68dff9d5ee22577 | [] | no_license | SaeedHyder/LMS_LAWYER_ANDROID | https://github.com/SaeedHyder/LMS_LAWYER_ANDROID | e2fc401afb68fc364e261607aff8e299946de17a | fb922d6e7b0ac94159e63d5d57e58da19bb53f3c | refs/heads/master | 2021-11-29T21:27:24.145000 | 2019-01-30T10:05:14 | 2019-01-30T10:05:14 | 168,320,582 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ingic.lmslawyer.ui.binder;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.ingic.lmslawyer.R;
import com.ingic.lmslawyer.activities.DockActivity;
import com.ingic.lmslawyer.entities.BookmarkEnt;
import com.ingic.lmslawyer.helpers.BasePreferenceHelper;
import com.ingic.lmslawyer.helpers.DateHelper;
import com.ingic.lmslawyer.helpers.TextViewHelper;
import com.ingic.lmslawyer.interfaces.BookmarkInterface;
import com.ingic.lmslawyer.interfaces.RecyclerClickListner;
import com.ingic.lmslawyer.ui.viewbinders.abstracts.CustomRecyclerViewBinder;
import com.ingic.lmslawyer.ui.views.AnyTextView;
import com.ingic.lmslawyer.util.RoundCornersImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BookmarkBinder extends CustomRecyclerViewBinder<BookmarkEnt> {
private DockActivity dockActivity;
private BasePreferenceHelper prefHelper;
private ImageLoader imageLoader;
private BookmarkInterface clickListner;
public BookmarkBinder(DockActivity dockActivity, BasePreferenceHelper prefHelper, BookmarkInterface clickListner) {
super(R.layout.row_item_bookmark);
this.dockActivity = dockActivity;
this.prefHelper = prefHelper;
this.imageLoader = ImageLoader.getInstance();
this.clickListner = clickListner;
}
@Override
public BaseViewHolder createViewHolder(View view) {
return new ViewHolder(view);
}
@Override
public void bindView(BookmarkEnt entity, int position, Object viewHolder, Context context) {
final ViewHolder holder = (ViewHolder) viewHolder;
imageLoader.displayImage(entity.getImageUrl(),holder.profileImage);
holder.txtName.setText(entity.getTitle()+"");
holder.tvDetail.setText(entity.getDescription()+"");
TextViewHelper.setText(holder.tvDateTime, DateHelper.getTime(entity.getCreatedAt())
+ " | " + DateHelper.getLocalDateTime2(entity.getCreatedAt()));
holder.btnShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickListner.share(entity,position);
}
});
holder.btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickListner.delete(entity,position);
}
});
}
static class ViewHolder extends BaseViewHolder {
@BindView(R.id.profileImage)
RoundCornersImageView profileImage;
@BindView(R.id.txtName)
AnyTextView txtName;
@BindView(R.id.tvDateTime)
AnyTextView tvDateTime;
@BindView(R.id.tvDetail)
AnyTextView tvDetail;
@BindView(R.id.textLayout)
LinearLayout textLayout;
@BindView(R.id.btnShare)
ImageView btnShare;
@BindView(R.id.btnDelete)
ImageView btnDelete;
@BindView(R.id.mainlayout)
LinearLayout mainlayout;
ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
}
| UTF-8 | Java | 3,268 | java | BookmarkBinder.java | Java | [] | null | [] | package com.ingic.lmslawyer.ui.binder;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.ingic.lmslawyer.R;
import com.ingic.lmslawyer.activities.DockActivity;
import com.ingic.lmslawyer.entities.BookmarkEnt;
import com.ingic.lmslawyer.helpers.BasePreferenceHelper;
import com.ingic.lmslawyer.helpers.DateHelper;
import com.ingic.lmslawyer.helpers.TextViewHelper;
import com.ingic.lmslawyer.interfaces.BookmarkInterface;
import com.ingic.lmslawyer.interfaces.RecyclerClickListner;
import com.ingic.lmslawyer.ui.viewbinders.abstracts.CustomRecyclerViewBinder;
import com.ingic.lmslawyer.ui.views.AnyTextView;
import com.ingic.lmslawyer.util.RoundCornersImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BookmarkBinder extends CustomRecyclerViewBinder<BookmarkEnt> {
private DockActivity dockActivity;
private BasePreferenceHelper prefHelper;
private ImageLoader imageLoader;
private BookmarkInterface clickListner;
public BookmarkBinder(DockActivity dockActivity, BasePreferenceHelper prefHelper, BookmarkInterface clickListner) {
super(R.layout.row_item_bookmark);
this.dockActivity = dockActivity;
this.prefHelper = prefHelper;
this.imageLoader = ImageLoader.getInstance();
this.clickListner = clickListner;
}
@Override
public BaseViewHolder createViewHolder(View view) {
return new ViewHolder(view);
}
@Override
public void bindView(BookmarkEnt entity, int position, Object viewHolder, Context context) {
final ViewHolder holder = (ViewHolder) viewHolder;
imageLoader.displayImage(entity.getImageUrl(),holder.profileImage);
holder.txtName.setText(entity.getTitle()+"");
holder.tvDetail.setText(entity.getDescription()+"");
TextViewHelper.setText(holder.tvDateTime, DateHelper.getTime(entity.getCreatedAt())
+ " | " + DateHelper.getLocalDateTime2(entity.getCreatedAt()));
holder.btnShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickListner.share(entity,position);
}
});
holder.btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
clickListner.delete(entity,position);
}
});
}
static class ViewHolder extends BaseViewHolder {
@BindView(R.id.profileImage)
RoundCornersImageView profileImage;
@BindView(R.id.txtName)
AnyTextView txtName;
@BindView(R.id.tvDateTime)
AnyTextView tvDateTime;
@BindView(R.id.tvDetail)
AnyTextView tvDetail;
@BindView(R.id.textLayout)
LinearLayout textLayout;
@BindView(R.id.btnShare)
ImageView btnShare;
@BindView(R.id.btnDelete)
ImageView btnDelete;
@BindView(R.id.mainlayout)
LinearLayout mainlayout;
ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
}
| 3,268 | 0.706548 | 0.70563 | 98 | 32.346939 | 25.265165 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.602041 | false | false | 10 |
3a8b1ee6d89c6d56fc995d75193f113c1d885e38 | 13,683,765,806,089 | 0c8602c22fbd7addca40c1c1cb54ebe66e4309d0 | /src/main/java/game/utility/Utilities.java | b16b42a1c0ab346959141e582909594fa0f98ab1 | [] | no_license | rrrRuslan/Fair-Server | https://github.com/rrrRuslan/Fair-Server | c5f7d8bb99e7e222a6dd7e7326f3ea75dd04c787 | 7a10805ee92107a082059864e8b9616ed965c319 | refs/heads/master | 2020-08-08T22:50:35.638000 | 2019-10-08T09:25:05 | 2019-10-08T09:25:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package game.utility;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Utilities {
public static Object[] getAllBeanConcClass(Class beanClass){
ApplicationContext context = new AnnotationConfigApplicationContext("game.context");
String[] beanNames = context.getBeanNamesForType(beanClass);
Object[] allBeans = new Object[beanNames.length];
for (int i = 0; i < beanNames.length; i++)
allBeans[i] = context.getBean(beanNames[i]);
return allBeans;
}
}
| UTF-8 | Java | 639 | java | Utilities.java | Java | [] | null | [] | package game.utility;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Utilities {
public static Object[] getAllBeanConcClass(Class beanClass){
ApplicationContext context = new AnnotationConfigApplicationContext("game.context");
String[] beanNames = context.getBeanNamesForType(beanClass);
Object[] allBeans = new Object[beanNames.length];
for (int i = 0; i < beanNames.length; i++)
allBeans[i] = context.getBean(beanNames[i]);
return allBeans;
}
}
| 639 | 0.697966 | 0.696401 | 18 | 34.5 | 32.156303 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 10 |
47291f750a438cae461ccfc195a2f3c95420df4b | 10,711,648,500,755 | 4deee735586e3814e0d020261cf6e0f8fef36702 | /src/main/java/com/electribe/editor/model/esx/edit/src/com/skratchdot/electribe/model/esx/provider/SampleItemProvider.java | 0c2ac2840c9c14196c7f0b75934e9ffbd04c65fe | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | ben-doyle/open-electribe-editor | https://github.com/ben-doyle/open-electribe-editor | b547e800fed539d34a1585710055e70a3fe9727e | d57ac32f381edbfda610c6562a6b0047ec48661e | refs/heads/master | 2020-04-09T17:40:44.547000 | 2018-12-19T03:11:13 | 2018-12-19T03:11:13 | 160,487,618 | 1 | 0 | null | true | 2018-12-05T08:45:32 | 2018-12-05T08:45:32 | 2018-05-20T13:18:26 | 2013-04-13T14:09:50 | 7,772 | 0 | 0 | 0 | null | false | null |
package com.electribe.editor.model.esx.edit.src.com.skratchdot.electribe.model.esx.provider;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import com.electribe.editor.model.esx.EsxPackage;
import com.electribe.editor.model.esx.Sample;
/**
* This is the item provider adapter for a {@link Sample} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class SampleItemProvider extends ItemProviderAdapter implements
IEditingDomainItemProvider, IStructuredItemContentProvider,
ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource,
ITableItemLabelProvider, ITableItemColorProvider, IItemColorProvider {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SampleItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
addStartPropertyDescriptor(object);
addEndPropertyDescriptor(object);
addLoopStartPropertyDescriptor(object);
addSampleRatePropertyDescriptor(object);
addSampleTunePropertyDescriptor(object);
addNumberOfSampleFramesPropertyDescriptor(object);
addPlayLevelPropertyDescriptor(object);
addStretchStepPropertyDescriptor(object);
addLoopTypePropertyDescriptor(object);
addSlicePropertyDescriptor(object);
addStereoOriginalPropertyDescriptor(object);
addStereoCurrentPropertyDescriptor(object);
addLabelPropertyDescriptor(object);
addMemUsedInBytesPropertyDescriptor(object);
addEmptyPropertyDescriptor(object);
addPartCountPropertyDescriptor(object);
addPatternCountPropertyDescriptor(object);
addSampleNumberOriginalPropertyDescriptor(object);
addSampleNumberCurrentPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_name_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_name_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__NAME, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Mem Used In Bytes feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addMemUsedInBytesPropertyDescriptor(Object object) {
itemPropertyDescriptors
.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_memUsedInBytes_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_memUsedInBytes_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__MEM_USED_IN_BYTES, false,
false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Empty feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEmptyPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_empty_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_empty_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__EMPTY, false, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Part Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPartCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_partCount_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_partCount_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PART_COUNT, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Pattern Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPatternCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_patternCount_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_patternCount_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PATTERN_COUNT, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Start feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStartPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_start_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_start_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__START, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the End feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEndPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_end_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_end_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__END, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Loop Start feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLoopStartPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_loopStart_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_loopStart_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LOOP_START, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Rate feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleRatePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleRate_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleRate_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_RATE, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Tune feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleTunePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleTune_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleTune_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_TUNE, false, false, false,
null, null, null));
}
/**
* This adds a property descriptor for the Number Of Sample Frames feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNumberOfSampleFramesPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_numberOfSampleFrames_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_numberOfSampleFrames_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__NUMBER_OF_SAMPLE_FRAMES, false,
false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
null, null));
}
/**
* This adds a property descriptor for the Play Level feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPlayLevelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_playLevel_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_playLevel_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PLAY_LEVEL, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stretch Step feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStretchStepPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stretchStep_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stretchStep_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STRETCH_STEP, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Loop Type feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLoopTypePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_loopType_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_loopType_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LOOP_TYPE, false, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Number Original feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleNumberOriginalPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleNumberOriginal_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleNumberOriginal_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_NUMBER_ORIGINAL, false,
false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null,
null));
}
/**
* This adds a property descriptor for the Sample Number Current feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleNumberCurrentPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleNumberCurrent_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleNumberCurrent_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_NUMBER_CURRENT, false,
false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(
Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(EsxPackage.Literals.SAMPLE__SAMPLE_TUNE);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This adds a property descriptor for the Slice feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSlicePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_slice_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_slice_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SLICE, false, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stereo Original feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStereoOriginalPropertyDescriptor(Object object) {
itemPropertyDescriptors
.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stereoOriginal_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stereoOriginal_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STEREO_ORIGINAL, false,
false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stereo Current feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStereoCurrentPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stereoCurrent_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stereoCurrent_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STEREO_CURRENT, false, false,
false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Label feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLabelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_label_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_label_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LABEL, false, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This returns Sample.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object,
getResourceLocator().getImage("full/obj16/Sample"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
String label = ((Sample) object).getName();
return label == null || label.length() == 0 ? getString("_UI_Sample_type")
: getString("_UI_Sample_type") + " " + label;
}
/**
* This returns the column text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public String getColumnText(Object object, int columnIndex) {
switch (columnIndex) {
// Esx#
case 0:
return ((Sample) object).getSampleNumberCurrent().toString();
// Orig#
case 1:
return ((Sample) object).getSampleNumberOriginal().toString();
// Name
case 2:
return ((Sample) object).getName();
// MemSize
case 3:
return Integer.toString(((Sample) object).getMemUsedInBytes());
// SampleRate
case 4:
return Integer.toString(((Sample) object).getSampleRate());
// SampleTune
case 5:
return Float.toString(((Sample) object).getSampleTune().getValue());
// StretchStep
case 6:
return ((Sample) object).getStretchStep().getLiteral();
// IsLoop?
case 7:
return ((Sample) object).getLoopType().getLiteral();
// IsSlice?
case 8:
return ((Sample) object).isSlice() ? getString("_UI_Display_Yes")
: getString("_UI_Display_No");
// PlayLevel
case 9:
return ((Sample) object).getPlayLevel().getLiteral();
// Start
case 10:
return Integer.toString(((Sample) object).getStart());
// LoopStart
case 11:
return Integer.toString(((Sample) object).getLoopStart());
// End
case 12:
return Integer.toString(((Sample) object).getEnd());
// NumSampleFrames
case 13:
return Integer
.toString(((Sample) object).getNumberOfSampleFrames());
// StereoOriginal
case 14:
return ((Sample) object).isStereoOriginal() ? getString("_UI_Display_Yes")
: getString("_UI_Display_No");
default:
return getText(object);
}
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Sample.class)) {
case EsxPackage.SAMPLE__NAME:
case EsxPackage.SAMPLE__OFFSET_CHANNEL1_START:
case EsxPackage.SAMPLE__OFFSET_CHANNEL1_END:
case EsxPackage.SAMPLE__OFFSET_CHANNEL2_START:
case EsxPackage.SAMPLE__OFFSET_CHANNEL2_END:
case EsxPackage.SAMPLE__START:
case EsxPackage.SAMPLE__END:
case EsxPackage.SAMPLE__LOOP_START:
case EsxPackage.SAMPLE__SAMPLE_RATE:
case EsxPackage.SAMPLE__NUMBER_OF_SAMPLE_FRAMES:
case EsxPackage.SAMPLE__PLAY_LEVEL:
case EsxPackage.SAMPLE__STRETCH_STEP:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO1:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO2:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO3:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO4:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO1:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO2:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO3:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO4:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL1:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL2:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL_BOTH:
case EsxPackage.SAMPLE__AUDIO_DATA_LOOP_START:
case EsxPackage.SAMPLE__SLICE_ARRAY:
case EsxPackage.SAMPLE__LOOP:
case EsxPackage.SAMPLE__LOOP_TYPE:
case EsxPackage.SAMPLE__SLICE:
case EsxPackage.SAMPLE__STEREO_ORIGINAL:
case EsxPackage.SAMPLE__STEREO_CURRENT:
case EsxPackage.SAMPLE__LABEL:
case EsxPackage.SAMPLE__MEM_USED_IN_BYTES:
case EsxPackage.SAMPLE__EMPTY:
case EsxPackage.SAMPLE__PART_COUNT:
case EsxPackage.SAMPLE__PATTERN_COUNT:
case EsxPackage.SAMPLE__SAMPLE_NUMBER_ORIGINAL:
case EsxPackage.SAMPLE__SAMPLE_NUMBER_CURRENT:
fireNotifyChanged(new ViewerNotification(notification,
notification.getNotifier(), false, true));
return;
case EsxPackage.SAMPLE__SAMPLE_TUNE:
fireNotifyChanged(new ViewerNotification(notification,
notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(
Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return EsxEditPlugin.INSTANCE;
}
@Override
protected Command createSetCommand(EditingDomain domain, EObject owner,
EStructuralFeature feature, Object value) {
// When setting name, only allow 8 characters
if (feature == EsxPackage.Literals.SAMPLE__NAME) {
value = StringUtils.left((String) value, 8);
}
// Start cannot be negative, greater than getEnd(),
// or greater than getNumberOfSampleFrames()
// If it's greater than getLoopStart(), then we need to adjust loopStart()
if (feature == EsxPackage.Literals.SAMPLE__START) {
int loopStart = ((Sample) owner).getLoopStart();
int end = ((Sample) owner).getEnd();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// Start cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// Start cannot be greater than getEnd()
if ((Integer) value > end) {
value = new Integer(end);
}
// Start cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
// If End is less than getLoopStart(), we need to adjust loopStart
if ((Integer) value > loopStart) {
CompoundCommand cmd = new CompoundCommand();
// Change getLoopStart()
cmd.append(new SetCommand(domain, owner,
EsxPackage.Literals.SAMPLE__LOOP_START, (Integer) value));
// Change getEnd()
cmd.append(new SetCommand(domain, owner, feature,
(Integer) value));
return cmd;
}
}
// End cannot be negative, less than getStart(),
// or greater than getNumberOfSampleFrames()
// If it's less than getLoopStart(), then we need to adjust loopStart()
if (feature == EsxPackage.Literals.SAMPLE__END) {
int loopStart = ((Sample) owner).getLoopStart();
int start = ((Sample) owner).getStart();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// End cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// End cannot be less than getStart()
if ((Integer) value < start) {
value = new Integer(start);
}
// End cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
// If End is less than getLoopStart(), we need to adjust loopStart
if ((Integer) value < loopStart) {
CompoundCommand cmd = new CompoundCommand();
// Change getLoopStart()
cmd.append(new SetCommand(domain, owner,
EsxPackage.Literals.SAMPLE__LOOP_START, (Integer) value));
// Change getEnd()
cmd.append(new SetCommand(domain, owner, feature,
(Integer) value));
return cmd;
}
}
// LoopStart cannot be negative, less than getStart(),
// greater than getEnd(), or greater than getNumberOfSampleFrames()
if (feature == EsxPackage.Literals.SAMPLE__LOOP_START) {
int start = ((Sample) owner).getStart();
int end = ((Sample) owner).getEnd();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// LoopStart cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// LoopStart cannot be less that getStart()
if ((Integer) value < start) {
value = new Integer(start);
}
// LoopStart cannot be greater than getEnd()
if ((Integer) value > end) {
value = new Integer(end);
}
// LoopStart cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
}
return super.createSetCommand(domain, owner, feature, value);
}
}
| UTF-8 | Java | 26,665 | java | SampleItemProvider.java | Java | [] | null | [] |
package com.electribe.editor.model.esx.edit.src.com.skratchdot.electribe.model.esx.provider;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import com.electribe.editor.model.esx.EsxPackage;
import com.electribe.editor.model.esx.Sample;
/**
* This is the item provider adapter for a {@link Sample} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class SampleItemProvider extends ItemProviderAdapter implements
IEditingDomainItemProvider, IStructuredItemContentProvider,
ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource,
ITableItemLabelProvider, ITableItemColorProvider, IItemColorProvider {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SampleItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
addStartPropertyDescriptor(object);
addEndPropertyDescriptor(object);
addLoopStartPropertyDescriptor(object);
addSampleRatePropertyDescriptor(object);
addSampleTunePropertyDescriptor(object);
addNumberOfSampleFramesPropertyDescriptor(object);
addPlayLevelPropertyDescriptor(object);
addStretchStepPropertyDescriptor(object);
addLoopTypePropertyDescriptor(object);
addSlicePropertyDescriptor(object);
addStereoOriginalPropertyDescriptor(object);
addStereoCurrentPropertyDescriptor(object);
addLabelPropertyDescriptor(object);
addMemUsedInBytesPropertyDescriptor(object);
addEmptyPropertyDescriptor(object);
addPartCountPropertyDescriptor(object);
addPatternCountPropertyDescriptor(object);
addSampleNumberOriginalPropertyDescriptor(object);
addSampleNumberCurrentPropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_name_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_name_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__NAME, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Mem Used In Bytes feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addMemUsedInBytesPropertyDescriptor(Object object) {
itemPropertyDescriptors
.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_memUsedInBytes_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_memUsedInBytes_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__MEM_USED_IN_BYTES, false,
false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Empty feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEmptyPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_empty_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_empty_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__EMPTY, false, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Part Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPartCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_partCount_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_partCount_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PART_COUNT, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Pattern Count feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPatternCountPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_patternCount_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_patternCount_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PATTERN_COUNT, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Start feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStartPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_start_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_start_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__START, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the End feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addEndPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_end_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_end_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__END, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Loop Start feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLoopStartPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_loopStart_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_loopStart_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LOOP_START, true, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Rate feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleRatePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleRate_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleRate_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_RATE, false, false, false,
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Tune feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleTunePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleTune_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleTune_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_TUNE, false, false, false,
null, null, null));
}
/**
* This adds a property descriptor for the Number Of Sample Frames feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addNumberOfSampleFramesPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_numberOfSampleFrames_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_numberOfSampleFrames_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__NUMBER_OF_SAMPLE_FRAMES, false,
false, false, ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE,
null, null));
}
/**
* This adds a property descriptor for the Play Level feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addPlayLevelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_playLevel_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_playLevel_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__PLAY_LEVEL, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stretch Step feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStretchStepPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stretchStep_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stretchStep_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STRETCH_STEP, true, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Loop Type feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLoopTypePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_loopType_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_loopType_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LOOP_TYPE, false, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Sample Number Original feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleNumberOriginalPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleNumberOriginal_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleNumberOriginal_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_NUMBER_ORIGINAL, false,
false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null,
null));
}
/**
* This adds a property descriptor for the Sample Number Current feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSampleNumberCurrentPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_sampleNumberCurrent_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_sampleNumberCurrent_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SAMPLE_NUMBER_CURRENT, false,
false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(
Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(EsxPackage.Literals.SAMPLE__SAMPLE_TUNE);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This adds a property descriptor for the Slice feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addSlicePropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_slice_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_slice_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__SLICE, false, false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stereo Original feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStereoOriginalPropertyDescriptor(Object object) {
itemPropertyDescriptors
.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stereoOriginal_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stereoOriginal_feature",
"_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STEREO_ORIGINAL, false,
false, false,
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Stereo Current feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addStereoCurrentPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_stereoCurrent_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_stereoCurrent_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__STEREO_CURRENT, false, false,
false, ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null));
}
/**
* This adds a property descriptor for the Label feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addLabelPropertyDescriptor(Object object) {
itemPropertyDescriptors.add(createItemPropertyDescriptor(
((ComposeableAdapterFactory) adapterFactory)
.getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Sample_label_feature"),
getString("_UI_PropertyDescriptor_description",
"_UI_Sample_label_feature", "_UI_Sample_type"),
EsxPackage.Literals.SAMPLE__LABEL, false, false, false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null));
}
/**
* This returns Sample.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object,
getResourceLocator().getImage("full/obj16/Sample"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
String label = ((Sample) object).getName();
return label == null || label.length() == 0 ? getString("_UI_Sample_type")
: getString("_UI_Sample_type") + " " + label;
}
/**
* This returns the column text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public String getColumnText(Object object, int columnIndex) {
switch (columnIndex) {
// Esx#
case 0:
return ((Sample) object).getSampleNumberCurrent().toString();
// Orig#
case 1:
return ((Sample) object).getSampleNumberOriginal().toString();
// Name
case 2:
return ((Sample) object).getName();
// MemSize
case 3:
return Integer.toString(((Sample) object).getMemUsedInBytes());
// SampleRate
case 4:
return Integer.toString(((Sample) object).getSampleRate());
// SampleTune
case 5:
return Float.toString(((Sample) object).getSampleTune().getValue());
// StretchStep
case 6:
return ((Sample) object).getStretchStep().getLiteral();
// IsLoop?
case 7:
return ((Sample) object).getLoopType().getLiteral();
// IsSlice?
case 8:
return ((Sample) object).isSlice() ? getString("_UI_Display_Yes")
: getString("_UI_Display_No");
// PlayLevel
case 9:
return ((Sample) object).getPlayLevel().getLiteral();
// Start
case 10:
return Integer.toString(((Sample) object).getStart());
// LoopStart
case 11:
return Integer.toString(((Sample) object).getLoopStart());
// End
case 12:
return Integer.toString(((Sample) object).getEnd());
// NumSampleFrames
case 13:
return Integer
.toString(((Sample) object).getNumberOfSampleFrames());
// StereoOriginal
case 14:
return ((Sample) object).isStereoOriginal() ? getString("_UI_Display_Yes")
: getString("_UI_Display_No");
default:
return getText(object);
}
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Sample.class)) {
case EsxPackage.SAMPLE__NAME:
case EsxPackage.SAMPLE__OFFSET_CHANNEL1_START:
case EsxPackage.SAMPLE__OFFSET_CHANNEL1_END:
case EsxPackage.SAMPLE__OFFSET_CHANNEL2_START:
case EsxPackage.SAMPLE__OFFSET_CHANNEL2_END:
case EsxPackage.SAMPLE__START:
case EsxPackage.SAMPLE__END:
case EsxPackage.SAMPLE__LOOP_START:
case EsxPackage.SAMPLE__SAMPLE_RATE:
case EsxPackage.SAMPLE__NUMBER_OF_SAMPLE_FRAMES:
case EsxPackage.SAMPLE__PLAY_LEVEL:
case EsxPackage.SAMPLE__STRETCH_STEP:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO1:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO2:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO3:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_MONO4:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO1:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO2:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO3:
case EsxPackage.SAMPLE__UNKNOWN_BYTE_STEREO4:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL1:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL2:
case EsxPackage.SAMPLE__AUDIO_DATA_CHANNEL_BOTH:
case EsxPackage.SAMPLE__AUDIO_DATA_LOOP_START:
case EsxPackage.SAMPLE__SLICE_ARRAY:
case EsxPackage.SAMPLE__LOOP:
case EsxPackage.SAMPLE__LOOP_TYPE:
case EsxPackage.SAMPLE__SLICE:
case EsxPackage.SAMPLE__STEREO_ORIGINAL:
case EsxPackage.SAMPLE__STEREO_CURRENT:
case EsxPackage.SAMPLE__LABEL:
case EsxPackage.SAMPLE__MEM_USED_IN_BYTES:
case EsxPackage.SAMPLE__EMPTY:
case EsxPackage.SAMPLE__PART_COUNT:
case EsxPackage.SAMPLE__PATTERN_COUNT:
case EsxPackage.SAMPLE__SAMPLE_NUMBER_ORIGINAL:
case EsxPackage.SAMPLE__SAMPLE_NUMBER_CURRENT:
fireNotifyChanged(new ViewerNotification(notification,
notification.getNotifier(), false, true));
return;
case EsxPackage.SAMPLE__SAMPLE_TUNE:
fireNotifyChanged(new ViewerNotification(notification,
notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(
Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return EsxEditPlugin.INSTANCE;
}
@Override
protected Command createSetCommand(EditingDomain domain, EObject owner,
EStructuralFeature feature, Object value) {
// When setting name, only allow 8 characters
if (feature == EsxPackage.Literals.SAMPLE__NAME) {
value = StringUtils.left((String) value, 8);
}
// Start cannot be negative, greater than getEnd(),
// or greater than getNumberOfSampleFrames()
// If it's greater than getLoopStart(), then we need to adjust loopStart()
if (feature == EsxPackage.Literals.SAMPLE__START) {
int loopStart = ((Sample) owner).getLoopStart();
int end = ((Sample) owner).getEnd();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// Start cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// Start cannot be greater than getEnd()
if ((Integer) value > end) {
value = new Integer(end);
}
// Start cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
// If End is less than getLoopStart(), we need to adjust loopStart
if ((Integer) value > loopStart) {
CompoundCommand cmd = new CompoundCommand();
// Change getLoopStart()
cmd.append(new SetCommand(domain, owner,
EsxPackage.Literals.SAMPLE__LOOP_START, (Integer) value));
// Change getEnd()
cmd.append(new SetCommand(domain, owner, feature,
(Integer) value));
return cmd;
}
}
// End cannot be negative, less than getStart(),
// or greater than getNumberOfSampleFrames()
// If it's less than getLoopStart(), then we need to adjust loopStart()
if (feature == EsxPackage.Literals.SAMPLE__END) {
int loopStart = ((Sample) owner).getLoopStart();
int start = ((Sample) owner).getStart();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// End cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// End cannot be less than getStart()
if ((Integer) value < start) {
value = new Integer(start);
}
// End cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
// If End is less than getLoopStart(), we need to adjust loopStart
if ((Integer) value < loopStart) {
CompoundCommand cmd = new CompoundCommand();
// Change getLoopStart()
cmd.append(new SetCommand(domain, owner,
EsxPackage.Literals.SAMPLE__LOOP_START, (Integer) value));
// Change getEnd()
cmd.append(new SetCommand(domain, owner, feature,
(Integer) value));
return cmd;
}
}
// LoopStart cannot be negative, less than getStart(),
// greater than getEnd(), or greater than getNumberOfSampleFrames()
if (feature == EsxPackage.Literals.SAMPLE__LOOP_START) {
int start = ((Sample) owner).getStart();
int end = ((Sample) owner).getEnd();
int maxEnd = ((Sample) owner).getNumberOfSampleFrames() - 1;
maxEnd = maxEnd < 0 ? 0 : maxEnd;
// LoopStart cannot be negative
if ((Integer) value < 0) {
value = new Integer(0);
}
// LoopStart cannot be less that getStart()
if ((Integer) value < start) {
value = new Integer(start);
}
// LoopStart cannot be greater than getEnd()
if ((Integer) value > end) {
value = new Integer(end);
}
// LoopStart cannot be greater than getNumberOfSampleFrames()
if ((Integer) value > maxEnd) {
value = new Integer(maxEnd);
}
}
return super.createSetCommand(domain, owner, feature, value);
}
}
| 26,665 | 0.711832 | 0.709807 | 764 | 33.900524 | 23.148916 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.887434 | false | false | 10 |
b45ff3cfe8b3c04738d026ef00acda988867f10a | 7,481,833,094,736 | f7c597f1f4503acb0719e9c618923f0f4eb7cf84 | /app/src/main/java/edu/wmdd/gover/PropertyAdapter.java | 9f36804800e23c59e7df016d3a6a00ec48f031e4 | [] | no_license | DenisCalixto/Gover | https://github.com/DenisCalixto/Gover | b14cc9357b09153b1da378801742a0289d5f4ea0 | 4670ddb4f2abdd52f556767bf28c43ca2bfdeb7e | refs/heads/master | 2020-08-15T23:43:15.782000 | 2019-12-09T09:08:05 | 2019-12-09T09:08:05 | 215,424,509 | 0 | 2 | null | false | 2019-12-09T09:08:07 | 2019-10-16T00:51:45 | 2019-11-22T23:22:37 | 2019-12-09T09:08:06 | 2,362 | 0 | 2 | 0 | Java | false | false | package edu.wmdd.gover;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import java.util.List;
public class PropertyAdapter extends RecyclerView.Adapter<PropertyAdapter.ViewHolder> {
private Context context;
private RecyclerViewClickListener mListener;
private List<Property> list;
public PropertyAdapter(Context context, List<Property> list, RecyclerViewClickListener listener) {
this.context = context;
this.list = list;
mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.property_item, parent, false);
return new ViewHolder(v, mListener);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Property property = list.get(position);
holder.textNotes.setText(property.getNotes());
holder.textName.setText(String.valueOf(property.getAddress()));
String url = String.valueOf(property.getImage_url());
if (url != "" && url != null && !url.equals("null")) {
Log.d("Volley",property.getNotes() + " has image: " + property.getImage_url());
ImageLoader imageLoader;
imageLoader = CustomVolleyRequest.getInstance(this.context)
.getImageLoader();
imageLoader.get(url, ImageLoader.getImageListener(holder.imageThumbnail,
R.drawable.loading_shape, android.R.drawable
.ic_dialog_alert));
holder.imageThumbnail.setImageUrl(url, imageLoader);
}
else {
Log.d("Volley",property.getNotes() + " has no image: " + property.getImage_url());
}
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView textNotes, textName;
public NetworkImageView imageThumbnail;
private RecyclerViewClickListener mListener;
public ViewHolder(View itemView, RecyclerViewClickListener listener) {
super(itemView);
textNotes = itemView.findViewById(R.id.property_notes);
textName = itemView.findViewById(R.id.property_name);
imageThumbnail = itemView.findViewById(R.id.property_thumbnail);
mListener = listener;
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
mListener.onClick(view, getAdapterPosition());
}
}
} | UTF-8 | Java | 2,915 | java | PropertyAdapter.java | Java | [] | null | [] | package edu.wmdd.gover;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import java.util.List;
public class PropertyAdapter extends RecyclerView.Adapter<PropertyAdapter.ViewHolder> {
private Context context;
private RecyclerViewClickListener mListener;
private List<Property> list;
public PropertyAdapter(Context context, List<Property> list, RecyclerViewClickListener listener) {
this.context = context;
this.list = list;
mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.property_item, parent, false);
return new ViewHolder(v, mListener);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Property property = list.get(position);
holder.textNotes.setText(property.getNotes());
holder.textName.setText(String.valueOf(property.getAddress()));
String url = String.valueOf(property.getImage_url());
if (url != "" && url != null && !url.equals("null")) {
Log.d("Volley",property.getNotes() + " has image: " + property.getImage_url());
ImageLoader imageLoader;
imageLoader = CustomVolleyRequest.getInstance(this.context)
.getImageLoader();
imageLoader.get(url, ImageLoader.getImageListener(holder.imageThumbnail,
R.drawable.loading_shape, android.R.drawable
.ic_dialog_alert));
holder.imageThumbnail.setImageUrl(url, imageLoader);
}
else {
Log.d("Volley",property.getNotes() + " has no image: " + property.getImage_url());
}
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView textNotes, textName;
public NetworkImageView imageThumbnail;
private RecyclerViewClickListener mListener;
public ViewHolder(View itemView, RecyclerViewClickListener listener) {
super(itemView);
textNotes = itemView.findViewById(R.id.property_notes);
textName = itemView.findViewById(R.id.property_name);
imageThumbnail = itemView.findViewById(R.id.property_thumbnail);
mListener = listener;
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
mListener.onClick(view, getAdapterPosition());
}
}
} | 2,915 | 0.667581 | 0.667581 | 88 | 32.136364 | 29.349455 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 10 |
3c1d6a89d488b729ac5c5f4aa81bb6366b4715da | 21,242,908,285,286 | 3cea89d3efeb79150473c3a2e9fce77ba9f73a10 | /src/main/java/SumOfUnique.java | a0473a67c8b09d3c0a66ab83c8ce86b88ece4918 | [] | no_license | a-molis/leetcode2021 | https://github.com/a-molis/leetcode2021 | e4dcee7d419d72a6dffc676ab21fe60763704c02 | 88b8e1a40233eabb5a59fb794ab89d3a732ab055 | refs/heads/master | 2023-04-10T10:28:23.473000 | 2021-04-24T03:34:01 | 2021-04-24T03:34:01 | 337,232,603 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
// From https://leetcode.com/problems/sum-of-unique-elements
public class SumOfUnique {
public static int sumOfUnique(int[] nums) {
HashMap<Integer, Integer> uniqueNums = new HashMap<>();
for (int i=0; i<nums.length; i++) {
int num = nums[i];
if (uniqueNums.containsKey(num)) {
uniqueNums.put(num, (uniqueNums.get(num) + 1));
} else {
uniqueNums.put(num, 1);
}
}
int output = 0;
for (Map.Entry<Integer, Integer> entry: uniqueNums.entrySet()) {
if (entry.getValue() == 1) {
output += entry.getKey();
}
}
return output;
}
public static void main(String[] args) {
int[] nums = {1,2,3,2};
System.out.println(sumOfUnique(nums));
}
}
| UTF-8 | Java | 917 | java | SumOfUnique.java | Java | [] | null | [] | import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
// From https://leetcode.com/problems/sum-of-unique-elements
public class SumOfUnique {
public static int sumOfUnique(int[] nums) {
HashMap<Integer, Integer> uniqueNums = new HashMap<>();
for (int i=0; i<nums.length; i++) {
int num = nums[i];
if (uniqueNums.containsKey(num)) {
uniqueNums.put(num, (uniqueNums.get(num) + 1));
} else {
uniqueNums.put(num, 1);
}
}
int output = 0;
for (Map.Entry<Integer, Integer> entry: uniqueNums.entrySet()) {
if (entry.getValue() == 1) {
output += entry.getKey();
}
}
return output;
}
public static void main(String[] args) {
int[] nums = {1,2,3,2};
System.out.println(sumOfUnique(nums));
}
}
| 917 | 0.53217 | 0.522355 | 35 | 25.200001 | 21.190025 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 10 |
4f2e9125b535f09b79dcb5c7d9d8bbe71cac0624 | 35,931,696,402,222 | 4aab9d938bb495f7de782705192cb1c4ac19cd59 | /src/main/java/com/adc/disasterforecast/tools/AutoStationHelper.java | a43f73c7da7756931a0097f05bc57ebd00b85e66 | [] | no_license | Victor-ZHC/weathervisualization | https://github.com/Victor-ZHC/weathervisualization | d4e98df51f268bfb211d9dcb99790843a1239a34 | 7311d3da0878b61f7cabef8280c0e8c29d6abc8c | refs/heads/master | 2018-11-05T12:39:35.307000 | 2018-10-16T10:17:45 | 2018-10-16T10:17:45 | 110,543,341 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.adc.disasterforecast.tools;
import org.json.simple.JSONObject;
/**
* @Description 自动站相关辅助类
* @Author lilin
* @Create 2017-12-08 23:00
**/
public class AutoStationHelper {
public static final String AREA_STATION_CODE_XUJIAHUI = "58367";
}
| UTF-8 | Java | 276 | java | AutoStationHelper.java | Java | [
{
"context": "ONObject;\n\n/**\n * @Description 自动站相关辅助类\n * @Author lilin\n * @Create 2017-12-08 23:00\n **/\npublic class Aut",
"end": 122,
"score": 0.9990742206573486,
"start": 117,
"tag": "USERNAME",
"value": "lilin"
}
] | null | [] | package com.adc.disasterforecast.tools;
import org.json.simple.JSONObject;
/**
* @Description 自动站相关辅助类
* @Author lilin
* @Create 2017-12-08 23:00
**/
public class AutoStationHelper {
public static final String AREA_STATION_CODE_XUJIAHUI = "58367";
}
| 276 | 0.730769 | 0.665385 | 12 | 20.666666 | 19.972202 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 10 |
f4fd4f4f985de282f57aaa4e439db6c2c0d2d5a6 | 37,847,251,812,654 | 5c6f79d47b51c645e0d9c98cf3ef9cd0c7e6c559 | /src/main/java/com/verybadcompany/app/cwe/CWEExample.java | 8b5c4c358d642feb9098c28a20004680b89874c0 | [] | no_license | Umach2021/java-jenkins-binary | https://github.com/Umach2021/java-jenkins-binary | fe909c186c79cc93cbea8b4bb016958f03eff9b5 | d00a311a6a45e26ba545b2e3e3029b966732c42d | refs/heads/master | 2023-09-01T00:13:01.382000 | 2021-10-06T04:25:03 | 2021-10-06T04:25:03 | 413,818,337 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.verybadcompany.app.cwe;
public interface CWEExample {
// marker interface
}
| UTF-8 | Java | 93 | java | CWEExample.java | Java | [] | null | [] | package com.verybadcompany.app.cwe;
public interface CWEExample {
// marker interface
}
| 93 | 0.752688 | 0.752688 | 5 | 17.6 | 14.472042 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 10 |
9be2ab80097858db3b465d28f63443605e668ce0 | 34,454,227,657,477 | b5be35faaacd176182c2d582a81ef28c9553f999 | /src/com/zero2ipo/protal/services/rm/IRmServices.java | 4e865cb5c3351fc7adc492f2f5a6c599709c748f | [] | no_license | zhengyunfei/fsportal_v6 | https://github.com/zhengyunfei/fsportal_v6 | c5eaaa09d4b7093400d79734c5491dcb07145fe4 | d728c8a8d03fdc0cb9b2812d4a37fd6548c2eb6e | HEAD | 2016-08-08T18:17:38.356000 | 2016-02-23T05:52:17 | 2016-02-23T05:52:17 | 52,334,043 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zero2ipo.protal.services.rm;
import com.zero2ipo.module.entity.tzyy.ReservationEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
*
* 预约投资服务接口
* @author liyang
*
*/
@Service
@Transactional
public interface IRmServices {
/**
* 根据用户ID和产品ID查询预约记录
* @param entity
* @return
*/
public ReservationEntity findByUserIdAndFundId(ReservationEntity entity);
/**
* 根据用户id查询所有已预约产品
* @param queryMap
* @return
*/
public List<ReservationEntity> findAllFundByUserId(Map<String, Object> queryMap);
/**
* 产品预约
* */
public boolean add(ReservationEntity bo);
}
| UTF-8 | Java | 786 | java | IRmServices.java | Java | [
{
"context": "ort java.util.Map;\n\n/**\n * \n * 预约投资服务接口\n * @author liyang\n *\n */\n\n@Service\n@Transactional\npublic interface ",
"end": 296,
"score": 0.9989203214645386,
"start": 290,
"tag": "USERNAME",
"value": "liyang"
}
] | null | [] | package com.zero2ipo.protal.services.rm;
import com.zero2ipo.module.entity.tzyy.ReservationEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
*
* 预约投资服务接口
* @author liyang
*
*/
@Service
@Transactional
public interface IRmServices {
/**
* 根据用户ID和产品ID查询预约记录
* @param entity
* @return
*/
public ReservationEntity findByUserIdAndFundId(ReservationEntity entity);
/**
* 根据用户id查询所有已预约产品
* @param queryMap
* @return
*/
public List<ReservationEntity> findAllFundByUserId(Map<String, Object> queryMap);
/**
* 产品预约
* */
public boolean add(ReservationEntity bo);
}
| 786 | 0.742254 | 0.739437 | 38 | 17.68421 | 21.485743 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.684211 | false | false | 10 |
b814eb11ba30c62156b8413ef88e18ae987e3746 | 4,157,528,364,359 | 941303fe43392a1892e4c5a05a1b33164a169b81 | /Spring/IOCProj20-DependencyCheck5uses/src/main/java/com/lp/beans/PersonImf.java | eeea72f9a310b22ef8981ee3327de6a487bf1c3f | [] | no_license | Lalit340/JAVA | https://github.com/Lalit340/JAVA | 8aa4f09a9b33955f6e8edf0c087a4c6f762d547b | cf036c8afc4226be841c87b09c0813e7d2c1a33e | refs/heads/master | 2020-05-17T23:09:08.120000 | 2019-05-02T10:57:56 | 2019-05-02T10:57:56 | 184,018,186 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lp.beans;
import java.util.Calendar;
public class PersonImf {
private long adharNo;
private String name;
private double age;
private Mobile mob;
private Calendar cal;
public void setAdharNo(long adharNo) {
this.adharNo = adharNo;
}
public void setName(String name) {
this.name = name;
}
public void setAge(double age) {
this.age = age;
}
public void setMob(Mobile mob) {
this.mob = mob;
}
public void setCal(Calendar cal) {
this.cal = cal;
}
@Override
public String toString() {
return "PersonImf [adharNo=" + adharNo + ", name=" + name + ", age=" + age + ", mob=" + mob + ", cal=" + cal
+ "]";
}
}
| UTF-8 | Java | 680 | java | PersonImf.java | Java | [] | null | [] | package com.lp.beans;
import java.util.Calendar;
public class PersonImf {
private long adharNo;
private String name;
private double age;
private Mobile mob;
private Calendar cal;
public void setAdharNo(long adharNo) {
this.adharNo = adharNo;
}
public void setName(String name) {
this.name = name;
}
public void setAge(double age) {
this.age = age;
}
public void setMob(Mobile mob) {
this.mob = mob;
}
public void setCal(Calendar cal) {
this.cal = cal;
}
@Override
public String toString() {
return "PersonImf [adharNo=" + adharNo + ", name=" + name + ", age=" + age + ", mob=" + mob + ", cal=" + cal
+ "]";
}
}
| 680 | 0.620588 | 0.620588 | 32 | 19.25 | 20.233017 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.59375 | false | false | 10 |
9c29fc8353a17a9db898206ef15d5882b4cb7581 | 4,131,758,546,211 | 357c51a57c4793742d6a778d48b51d7ddeb60f73 | /src/main/java/tinker_io/registry/ItemRegistry.java | 43a72358346edb5329f1e2e5ce2605edfcc1dc06 | [] | no_license | gkbm2013/GKB-s-Test-Mod | https://github.com/gkbm2013/GKB-s-Test-Mod | 8fbfe709fd9f5b8c584952883a910afe59481f8b | cb56c5d99cba4b31bfe865039b9ca6ab16d6decc | refs/heads/master | 2020-03-22T05:20:04.902000 | 2018-07-14T14:24:59 | 2018-07-14T14:24:59 | 139,557,645 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tinker_io.registry;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
import tinker_io.item.TestItem;
public class ItemRegistry {
public static TestItem testItem = new TestItem("test_item");
public static void register(IForgeRegistry<Item> registry) {
registry.registerAll(testItem);
}
public static void registerModels() {
testItem.registerItemModel();
}
// private static ModelResourceLocation getModelResourceLocation(String name) {
// return new ModelResourceLocation(TinkerIO.MOD_ID + ":" + name, "inventory");
// }
}
| UTF-8 | Java | 621 | java | ItemRegistry.java | Java | [] | null | [] | package tinker_io.registry;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;
import tinker_io.item.TestItem;
public class ItemRegistry {
public static TestItem testItem = new TestItem("test_item");
public static void register(IForgeRegistry<Item> registry) {
registry.registerAll(testItem);
}
public static void registerModels() {
testItem.registerItemModel();
}
// private static ModelResourceLocation getModelResourceLocation(String name) {
// return new ModelResourceLocation(TinkerIO.MOD_ID + ":" + name, "inventory");
// }
}
| 621 | 0.721417 | 0.721417 | 22 | 27.227272 | 27.599295 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.409091 | false | false | 10 |
4c1408718f2121ef561be0d64440740898572da6 | 13,262,859,028,627 | ad0495d6c98b80016712a1de91d368a305c92f48 | /src/main/java/hu/csakegysor/imcsb/controller/SearchController.java | 1f9ed8a424fc5d7dfcde199015c388a93fb62872 | [] | no_license | AradiPatrik/demoproj | https://github.com/AradiPatrik/demoproj | cd198ab9572e855988cfcf1d8b56b41e86e82fcb | ed376d111155d9e89111052bdb40b34a1b362158 | refs/heads/master | 2020-03-28T10:34:35.435000 | 2018-10-17T18:01:41 | 2018-10-17T18:01:41 | 148,121,938 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hu.csakegysor.imcsb.controller;
import hu.csakegysor.imcsb.utils.L;
import javafx.fxml.Initializable;
import java.net.URL;
import java.util.ResourceBundle;
public class SearchController implements Initializable {
private static final String SEARCH_CONTROLLER_INITIALIZED = "SearchController initialized";
private static final String SEARCH_CONTROLLER_CONSTRUCTED = "SearchController constructed";
public SearchController() {
L.info(SEARCH_CONTROLLER_CONSTRUCTED);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
L.info(SEARCH_CONTROLLER_INITIALIZED);
}
}
| UTF-8 | Java | 640 | java | SearchController.java | Java | [] | null | [] | package hu.csakegysor.imcsb.controller;
import hu.csakegysor.imcsb.utils.L;
import javafx.fxml.Initializable;
import java.net.URL;
import java.util.ResourceBundle;
public class SearchController implements Initializable {
private static final String SEARCH_CONTROLLER_INITIALIZED = "SearchController initialized";
private static final String SEARCH_CONTROLLER_CONSTRUCTED = "SearchController constructed";
public SearchController() {
L.info(SEARCH_CONTROLLER_CONSTRUCTED);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
L.info(SEARCH_CONTROLLER_INITIALIZED);
}
}
| 640 | 0.765625 | 0.765625 | 20 | 31 | 29.378563 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
bc6ee2dc62f29fcb38b70073f3ee7e6985d2e96e | 31,044,023,642,498 | 18261c7c87c86b969899b5d81985a018c3060806 | /src/main/java/com/design/factory/abstr/SqlServerUser.java | 9099aa4a0e056d91fd6212096eac3c66c7388a78 | [] | no_license | Zhangzhao199443/design-pattern-project | https://github.com/Zhangzhao199443/design-pattern-project | ddb80458f1642f59a9f2ce4afeb1339f8b0fc43d | 1a773df6e87b28a6f4a3989aa7ae3429d285a3ae | refs/heads/master | 2020-03-24T11:05:22.103000 | 2018-07-28T12:47:05 | 2018-07-28T12:47:05 | 142,675,342 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.design.factory.abstr;
public class SqlServerUser implements IUser{
public void insert() {
System.out.println("insert into sqlserverUser");
}
public void getUserById() {
System.out.println("get sqlserverUser by id");
}
}
| UTF-8 | Java | 266 | java | SqlServerUser.java | Java | [] | null | [] | package com.design.factory.abstr;
public class SqlServerUser implements IUser{
public void insert() {
System.out.println("insert into sqlserverUser");
}
public void getUserById() {
System.out.println("get sqlserverUser by id");
}
}
| 266 | 0.672932 | 0.672932 | 11 | 23.181818 | 21.005705 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 10 |
66615cc2461a099463e13b1a076b430ec881587f | 17,308,718,214,396 | 27afab29477d550550f5f1a542e1b39060ca499a | /src/java/ua/lyohha/tasks/types/cast2/TemplateGenerator.java | 7429220e67d82e60567336a1c02a2acc125f4d50 | [] | no_license | Lyohha/ATS-C-KhNTU-Edition | https://github.com/Lyohha/ATS-C-KhNTU-Edition | 87bc1300da0262f4a826695586e5320f5e137cf2 | 06e191545513ff6ec46d7c9cb6c376509a731d16 | refs/heads/master | 2021-07-03T11:44:09.276000 | 2021-02-03T21:20:06 | 2021-02-03T21:20:06 | 222,976,226 | 0 | 0 | null | false | 2019-12-15T11:29:24 | 2019-11-20T16:06:18 | 2019-12-15T09:13:57 | 2019-12-15T11:29:24 | 131 | 0 | 0 | 0 | Java | false | false | package ua.lyohha.tasks.types.cast2;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import ua.lyohha.tasks.CodeGenerator;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class TemplateGenerator {
private List<HBox> lines = new ArrayList<>();
private String[] answers = new String[4];
private Random random;
public TemplateGenerator() {
createTemplate();
}
public void setTemplate(Pane pane) {
for (int i = 0; i < lines.size(); i++) pane.getChildren().add(lines.get(i));
}
public String[] getAnswers() {
return answers;
}
private void createTemplate() {
random = new Random(System.currentTimeMillis());
createFirstsLine();
Variables variables = createVariables();
createFirstExpression(variables);
createSecondExpression(variables);
createThirdExpression(variables);
createFourthExpression(variables);
createLastLine();
}
private void createFirstExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2) + 2],
o2 = CodeGenerator.Operator.values()[random.nextInt(2) + 2];
lines.add(new HBox(
CodeGenerator.createPart("\tx=(y=d"),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart("i)"),
CodeGenerator.createPart(CodeGenerator.getOperator(o2)),
CodeGenerator.createPart(2),
CodeGenerator.createPart("; "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[0])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (variables.variables[0] == Variable.X)
answers[0] = toString(CodeGenerator.exeOperator((int) CodeGenerator.exeOperator(variables.d, 2, o1), 2, o2));
else
answers[0] = Integer.toString((int) CodeGenerator.exeOperator(variables.d, 2, o1));
}
private void createSecondExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2) + 2],
o2 = CodeGenerator.Operator.values()[random.nextInt(2) + 2];
lines.add(new HBox(
CodeGenerator.createPart("\ty=(x=d"),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart("i)"),
CodeGenerator.createPart(CodeGenerator.getOperator(o2)),
CodeGenerator.createPart(2),
CodeGenerator.createPart("; "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[1])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (variables.variables[1] == Variable.X)
answers[1] = toString(CodeGenerator.exeOperator(variables.d, 2, o1));
else
answers[1] = Integer.toString((int) CodeGenerator.exeOperator(CodeGenerator.exeOperator(variables.d, 2, o1), 2, o2));
}
private void createThirdExpression(Variables variables) {
int
i1 = random.nextInt(9 - variables.i) + variables.i + 1,
f1 = random.nextInt(9) + 1;
lines.add(new HBox(
CodeGenerator.createPart("\ty=d*(x="),
CodeGenerator.createPart(toDouble(i1, f1)),
CodeGenerator.createPart("/d); "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart("y"),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
answers[2] = Integer.toString(i1);
}
private void createFourthExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2)];
int i1, i2, f1, f2;
if (o1 == CodeGenerator.Operator.ADDITION) {
i1 = random.nextInt(variables.i);
f1 = random.nextInt(10);
i2 = variables.i - i1;
f2 = variables.f;
} else {
i1 = random.nextInt(9 - variables.i) + variables.i + 1;
f1 = random.nextInt(10);
i2 = i1 - variables.i + 1;
f2 = random.nextInt(10);
}
lines.add(new HBox(
CodeGenerator.createPart("\tx=d*(y=(("),
CodeGenerator.createPart("int", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(")"),
CodeGenerator.createPart(toDouble(i1, f1)),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart(toDouble(i2, f2)),
CodeGenerator.createPart(")/d); "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[3])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (o1 == CodeGenerator.Operator.ADDITION) {
if (variables.variables[3] == Variable.X)
answers[3] = toString(variables.d);
else
answers[3] = "1";
} else {
answers[3] = "0";
}
}
private Variables createVariables() {
Variable[] variables = new Variable[4];
for (int i = 0; i < variables.length; i++) {
variables[i] = Variable.values()[random.nextInt(Variable.values().length)];
}
Variables v = new Variables(variables, random.nextInt(5) + 1, random.nextInt(10));
lines.add(new HBox(
CodeGenerator.createPart("\tdouble ", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart("d="),
CodeGenerator.createPart(v.d),
CodeGenerator.createPart(", x;")
));
lines.add(new HBox(
CodeGenerator.createPart("\tint ", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart("i="),
CodeGenerator.createPart(2),
CodeGenerator.createPart(", y;")
));
lines.add(new HBox(
CodeGenerator.createPart(" ")
));
return v;
}
private void createFirstsLine() {
lines.add(new HBox(
CodeGenerator.createPart("#include", CodeGenerator.CodeType.DIRECTIVE),
CodeGenerator.createPart(" <stdio.h>", CodeGenerator.CodeType.LIBRARY)
));
lines.add(new HBox(
CodeGenerator.createPart("#define", CodeGenerator.CodeType.DIRECTIVE),
CodeGenerator.createPart(" PRINT(x)", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(" printf("),
CodeGenerator.createPart("\"%g\\n\"", CodeGenerator.CodeType.STRING),
CodeGenerator.createPart(", ("),
CodeGenerator.createPart("double", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(")"),
CodeGenerator.createPart("x)")
));
lines.add(new HBox(
CodeGenerator.createPart(" ")
));
lines.add(new HBox(
CodeGenerator.createPart("void", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(" main()")
));
lines.add(new HBox(
CodeGenerator.createPart("{")
));
}
private double toDouble(int n1, int n2) {
return ((double) n1 + (double) n2 / 10);
}
private void createLastLine() {
lines.add(new HBox(
CodeGenerator.createPart("}")
));
}
private String toString(double d) {
return removeZero(String.format("%.2f", d).replace(',', '.'));
}
private String removeZero(String string) {
if (string.charAt(string.length() - 1) == '.')
return string.substring(0, string.length() - 1);
if (string.charAt(string.length() - 1) != '0')
return string;
return removeZero(string.substring(0, string.length() - 1));
}
private String toString(Variable variable) {
switch (variable) {
case X:
return "x";
case Y:
return "y";
default:
return "";
}
}
private class Variables {
private Variable[] variables;
private int i;
private int f;
private double d;
private Variables(Variable[] variables, int i, int f) {
this.variables = variables;
this.i = i;
this.f = f;
this.d = (double) i + (double) f / 10;
}
private Variables(Variable[] variables, double d) {
this.d = d;
this.variables = variables;
this.i = (int) d;
this.f = (int) ((d - (double) this.i) * 10);
}
}
private enum Variable {
X,
Y,
}
}
| UTF-8 | Java | 9,487 | java | TemplateGenerator.java | Java | [] | null | [] | package ua.lyohha.tasks.types.cast2;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import ua.lyohha.tasks.CodeGenerator;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class TemplateGenerator {
private List<HBox> lines = new ArrayList<>();
private String[] answers = new String[4];
private Random random;
public TemplateGenerator() {
createTemplate();
}
public void setTemplate(Pane pane) {
for (int i = 0; i < lines.size(); i++) pane.getChildren().add(lines.get(i));
}
public String[] getAnswers() {
return answers;
}
private void createTemplate() {
random = new Random(System.currentTimeMillis());
createFirstsLine();
Variables variables = createVariables();
createFirstExpression(variables);
createSecondExpression(variables);
createThirdExpression(variables);
createFourthExpression(variables);
createLastLine();
}
private void createFirstExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2) + 2],
o2 = CodeGenerator.Operator.values()[random.nextInt(2) + 2];
lines.add(new HBox(
CodeGenerator.createPart("\tx=(y=d"),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart("i)"),
CodeGenerator.createPart(CodeGenerator.getOperator(o2)),
CodeGenerator.createPart(2),
CodeGenerator.createPart("; "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[0])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (variables.variables[0] == Variable.X)
answers[0] = toString(CodeGenerator.exeOperator((int) CodeGenerator.exeOperator(variables.d, 2, o1), 2, o2));
else
answers[0] = Integer.toString((int) CodeGenerator.exeOperator(variables.d, 2, o1));
}
private void createSecondExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2) + 2],
o2 = CodeGenerator.Operator.values()[random.nextInt(2) + 2];
lines.add(new HBox(
CodeGenerator.createPart("\ty=(x=d"),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart("i)"),
CodeGenerator.createPart(CodeGenerator.getOperator(o2)),
CodeGenerator.createPart(2),
CodeGenerator.createPart("; "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[1])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (variables.variables[1] == Variable.X)
answers[1] = toString(CodeGenerator.exeOperator(variables.d, 2, o1));
else
answers[1] = Integer.toString((int) CodeGenerator.exeOperator(CodeGenerator.exeOperator(variables.d, 2, o1), 2, o2));
}
private void createThirdExpression(Variables variables) {
int
i1 = random.nextInt(9 - variables.i) + variables.i + 1,
f1 = random.nextInt(9) + 1;
lines.add(new HBox(
CodeGenerator.createPart("\ty=d*(x="),
CodeGenerator.createPart(toDouble(i1, f1)),
CodeGenerator.createPart("/d); "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart("y"),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
answers[2] = Integer.toString(i1);
}
private void createFourthExpression(Variables variables) {
CodeGenerator.Operator
o1 = CodeGenerator.Operator.values()[random.nextInt(2)];
int i1, i2, f1, f2;
if (o1 == CodeGenerator.Operator.ADDITION) {
i1 = random.nextInt(variables.i);
f1 = random.nextInt(10);
i2 = variables.i - i1;
f2 = variables.f;
} else {
i1 = random.nextInt(9 - variables.i) + variables.i + 1;
f1 = random.nextInt(10);
i2 = i1 - variables.i + 1;
f2 = random.nextInt(10);
}
lines.add(new HBox(
CodeGenerator.createPart("\tx=d*(y=(("),
CodeGenerator.createPart("int", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(")"),
CodeGenerator.createPart(toDouble(i1, f1)),
CodeGenerator.createPart(CodeGenerator.getOperator(o1)),
CodeGenerator.createPart(toDouble(i2, f2)),
CodeGenerator.createPart(")/d); "),
CodeGenerator.createPart("PRINT(", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(toString(variables.variables[3])),
CodeGenerator.createPart(")", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(";")
));
if (o1 == CodeGenerator.Operator.ADDITION) {
if (variables.variables[3] == Variable.X)
answers[3] = toString(variables.d);
else
answers[3] = "1";
} else {
answers[3] = "0";
}
}
private Variables createVariables() {
Variable[] variables = new Variable[4];
for (int i = 0; i < variables.length; i++) {
variables[i] = Variable.values()[random.nextInt(Variable.values().length)];
}
Variables v = new Variables(variables, random.nextInt(5) + 1, random.nextInt(10));
lines.add(new HBox(
CodeGenerator.createPart("\tdouble ", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart("d="),
CodeGenerator.createPart(v.d),
CodeGenerator.createPart(", x;")
));
lines.add(new HBox(
CodeGenerator.createPart("\tint ", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart("i="),
CodeGenerator.createPart(2),
CodeGenerator.createPart(", y;")
));
lines.add(new HBox(
CodeGenerator.createPart(" ")
));
return v;
}
private void createFirstsLine() {
lines.add(new HBox(
CodeGenerator.createPart("#include", CodeGenerator.CodeType.DIRECTIVE),
CodeGenerator.createPart(" <stdio.h>", CodeGenerator.CodeType.LIBRARY)
));
lines.add(new HBox(
CodeGenerator.createPart("#define", CodeGenerator.CodeType.DIRECTIVE),
CodeGenerator.createPart(" PRINT(x)", CodeGenerator.CodeType.DEFINE1),
CodeGenerator.createPart(" printf("),
CodeGenerator.createPart("\"%g\\n\"", CodeGenerator.CodeType.STRING),
CodeGenerator.createPart(", ("),
CodeGenerator.createPart("double", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(")"),
CodeGenerator.createPart("x)")
));
lines.add(new HBox(
CodeGenerator.createPart(" ")
));
lines.add(new HBox(
CodeGenerator.createPart("void", CodeGenerator.CodeType.OPERATOR),
CodeGenerator.createPart(" main()")
));
lines.add(new HBox(
CodeGenerator.createPart("{")
));
}
private double toDouble(int n1, int n2) {
return ((double) n1 + (double) n2 / 10);
}
private void createLastLine() {
lines.add(new HBox(
CodeGenerator.createPart("}")
));
}
private String toString(double d) {
return removeZero(String.format("%.2f", d).replace(',', '.'));
}
private String removeZero(String string) {
if (string.charAt(string.length() - 1) == '.')
return string.substring(0, string.length() - 1);
if (string.charAt(string.length() - 1) != '0')
return string;
return removeZero(string.substring(0, string.length() - 1));
}
private String toString(Variable variable) {
switch (variable) {
case X:
return "x";
case Y:
return "y";
default:
return "";
}
}
private class Variables {
private Variable[] variables;
private int i;
private int f;
private double d;
private Variables(Variable[] variables, int i, int f) {
this.variables = variables;
this.i = i;
this.f = f;
this.d = (double) i + (double) f / 10;
}
private Variables(Variable[] variables, double d) {
this.d = d;
this.variables = variables;
this.i = (int) d;
this.f = (int) ((d - (double) this.i) * 10);
}
}
private enum Variable {
X,
Y,
}
}
| 9,487 | 0.5653 | 0.552229 | 265 | 34.799999 | 27.460875 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.743396 | false | false | 10 |
5bd43a6b2af7a0155728dfd87f62dac3c57eeb99 | 27,547,920,245,960 | 0945413ae92e478b30f323c99d52fc78bbcc58f6 | /Product.java | 053c8b10d591fe850acf9b10d3c86d99c2410d48 | [] | no_license | Obed-Nsiah/Ashesi_PointOfSales | https://github.com/Obed-Nsiah/Ashesi_PointOfSales | 15e7a769482b8a6584e63e44b52f28b8b28dcf60 | 8c8ca195176e930a9cbf6fb72fe62f5ea51d0796 | refs/heads/ObedBranch | 2021-01-19T17:55:50.267000 | 2014-11-30T16:28:48 | 2014-11-30T16:28:48 | 27,249,441 | 0 | 1 | null | false | 2014-11-30T16:28:48 | 2014-11-28T02:56:43 | 2014-11-30T16:28:48 | 2014-11-30T16:28:48 | 0 | 0 | 0 | 0 | Java | null | null |
/**
*
* @author Kojo Gyinaye
*/
public class Product {
String prodName;
double unitPrice;
double sellPrice;
int quant;
public Product(String name, double uPrice, double sPrice,int qty){
this.prodName = name;
this.sellPrice = sPrice;
this.unitPrice = uPrice;
this.quant = qty;
}
}
| UTF-8 | Java | 358 | java | Product.java | Java | [
{
"context": "\n/**\n *\n * @author Kojo Gyinaye\n */\npublic class Product {\n String prodName;\n ",
"end": 31,
"score": 0.9998927712440491,
"start": 19,
"tag": "NAME",
"value": "Kojo Gyinaye"
}
] | null | [] |
/**
*
* @author <NAME>
*/
public class Product {
String prodName;
double unitPrice;
double sellPrice;
int quant;
public Product(String name, double uPrice, double sPrice,int qty){
this.prodName = name;
this.sellPrice = sPrice;
this.unitPrice = uPrice;
this.quant = qty;
}
}
| 352 | 0.575419 | 0.575419 | 18 | 18.833334 | 16.385122 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.611111 | false | false | 10 |
56c2a87d8c9b0d2570e911d3e713cbd589d67b37 | 16,947,940,971,967 | 5eb42ceedc4ee04e56443d28851aa15498f2c403 | /src/java/com/wy/dao/impl/LotsAwardDaoImpl.java | 6fe4b5b02409d1c46d857ffbedc5c88072fc1d53 | [] | no_license | gogodog/frame-test-002 | https://github.com/gogodog/frame-test-002 | e03cbfb6047b14183e356b6a3da6eca86017eb89 | 52149a46a048bcddba762c4b85192ddc29821161 | refs/heads/master | 2016-08-23T04:08:48.758000 | 2016-05-10T02:27:45 | 2016-05-10T02:27:45 | 60,336,031 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wy.dao.impl;
import java.sql.SQLException;
import java.util.List;
import com.wy.dao.LotsAwardDao;
import com.wy.domain.condition.mysql.LotsAwardCondition;
import com.wy.domain.condition.mysql.LotsItemCondition;
import com.wy.domain.persistence.LotsAward;
import com.wy.domain.persistence.LotsItem;
public class LotsAwardDaoImpl extends BaseDaoImpl implements LotsAwardDao {
@Override
public int insert(LotsAward lotsAward) {
try {
getSqlMapClient().insert("LotsAward.insert", lotsAward);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public int update(LotsAward lotsAward) {
try {
getSqlMapClient().update("LotsAward.update", lotsAward);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public int delete(int id) {
try {
getSqlMapClient().delete("LotsAward.delete", id);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public List<LotsAward> search(LotsAward lotsAward) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getListCount(LotsAwardCondition cdt){
int totalnum=0;
try {
totalnum=(Integer)this.getSqlMapClient().queryForObject("LotsAward.getListCount", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return totalnum;
}
@Override
public List<LotsAward> getList(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getList", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public List<LotsAward> getListNoPager(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getListNoPager", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public LotsAward getLotsAward(LotsAwardCondition cdt){
try {
return (LotsAward) this.getSqlMapClient().queryForObject("LotsAward.getLotsAward",cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public List<LotsAward> getAwardList(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getAwardList", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public LotsAward getOneLotsAward(LotsAwardCondition cdt) throws Exception {
// TODO Auto-generated method stub
return (LotsAward) this.getSqlMapClient().queryForObject("LotsAward.getOneLotsAward",cdt);
}
}
| UTF-8 | Java | 2,622 | java | LotsAwardDaoImpl.java | Java | [] | null | [] | package com.wy.dao.impl;
import java.sql.SQLException;
import java.util.List;
import com.wy.dao.LotsAwardDao;
import com.wy.domain.condition.mysql.LotsAwardCondition;
import com.wy.domain.condition.mysql.LotsItemCondition;
import com.wy.domain.persistence.LotsAward;
import com.wy.domain.persistence.LotsItem;
public class LotsAwardDaoImpl extends BaseDaoImpl implements LotsAwardDao {
@Override
public int insert(LotsAward lotsAward) {
try {
getSqlMapClient().insert("LotsAward.insert", lotsAward);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public int update(LotsAward lotsAward) {
try {
getSqlMapClient().update("LotsAward.update", lotsAward);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public int delete(int id) {
try {
getSqlMapClient().delete("LotsAward.delete", id);
return 1 ;
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
@Override
public List<LotsAward> search(LotsAward lotsAward) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getListCount(LotsAwardCondition cdt){
int totalnum=0;
try {
totalnum=(Integer)this.getSqlMapClient().queryForObject("LotsAward.getListCount", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return totalnum;
}
@Override
public List<LotsAward> getList(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getList", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public List<LotsAward> getListNoPager(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getListNoPager", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public LotsAward getLotsAward(LotsAwardCondition cdt){
try {
return (LotsAward) this.getSqlMapClient().queryForObject("LotsAward.getLotsAward",cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public List<LotsAward> getAwardList(LotsAwardCondition cdt){
List<LotsAward> list=null;
try {
list=this.getSqlMapClient().queryForList("LotsAward.getAwardList", cdt);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
@Override
public LotsAward getOneLotsAward(LotsAwardCondition cdt) throws Exception {
// TODO Auto-generated method stub
return (LotsAward) this.getSqlMapClient().queryForObject("LotsAward.getOneLotsAward",cdt);
}
}
| 2,622 | 0.722731 | 0.720061 | 112 | 22.410715 | 23.375259 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.973214 | false | false | 10 |
07c90c467eb49aeb20f6bc490401d351320bae14 | 2,250,562,896,187 | 95e7c6d0a7202df5e6013bdac6d5702a18e1f870 | /app/src/main/java/com/birdguan/whichmovie/ui/login/LoginActivity.java | 1d7b7dcf2080601cd25e370ea3776077db167018 | [] | no_license | birdguan/WhichMovie | https://github.com/birdguan/WhichMovie | a0a30b0b38cb55ebb8092f13498068dadf1e4e8c | 1f680a0e5d00046c8fa317c261ef0ec0f4d59934 | refs/heads/master | 2022-11-15T07:23:27.815000 | 2020-06-23T08:10:11 | 2020-06-23T08:10:11 | 273,199,856 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.birdguan.whichmovie.ui.login;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.birdguan.whichmovie.MainActivity;
import com.birdguan.whichmovie.R;
import com.birdguan.whichmovie.base.BaseActivity;
import com.birdguan.whichmovie.model.User;
import com.birdguan.whichmovie.util.AESUtil;
import org.litepal.LitePal;
import java.util.List;
/**
* @Author: birdguan
* @Date: 2020/6/18 17:50
*/
public class LoginActivity extends BaseActivity {
private static final String TAG = "WhichMovie/LoginActivity";
private SharedPreferences pref; // 存储记住密码
private SharedPreferences.Editor editor;
private ImageView imageViewLogin;
private EditText editTextUsername;
private EditText editTextPassword;
private CheckBox checkBoxRemember;
private Button buttonSignUp;
private Button buttonLogin;
/**
* 焦点定位在editTextPassword时切换为捂眼图片,负责为睁眼图片
* 勾选记住密码复选框时用SharedPreferences保存用户名和密码
* 点击注册按钮buttonSignUp时存储到SQLite
* 点击登录按钮buttonLogin时到SQLite验证username对应的
* @param savedInstanceState -
*/
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
pref = PreferenceManager.getDefaultSharedPreferences(this);
imageViewLogin = (ImageView) findViewById(R.id.iv_login);
editTextUsername = (EditText) findViewById(R.id.et_username);
editTextPassword = (EditText) findViewById(R.id.et_password);
checkBoxRemember = (CheckBox) findViewById(R.id.cb_remember);
buttonSignUp = (Button) findViewById(R.id.btn_sign_up);
buttonLogin = (Button) findViewById(R.id.btn_login);
// 若之前用户选择了记住密码,则恢复用户名和密码以及CheckBox勾选状态
final boolean isRemember = pref.getBoolean("remember_password", false);
if (isRemember) {
String username = pref.getString("username", "");
String password = pref.getString("password", "");
// 对密码进行AES解密
try {
password = AESUtil.decrypt("41227677", password);
} catch (Exception e) {
Log.d(TAG, "AES密码解密失败");
e.printStackTrace();
}
editTextUsername.setText(username);
editTextPassword.setText(password);
checkBoxRemember.setChecked(true);
}
// 监听注册按钮buttonSignUp,按下时将用户名和密码存到SQLite
buttonSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 获取用户名和密码
String username = editTextUsername.getText().toString();
String password = editTextPassword.getText().toString();
// 对要储存到数据库的密码进行AES加密
try {
password = AESUtil.encrypt("41227677", password);
} catch (Exception e) {
Log.d(TAG, "对要储存到数据库的密码进行AES加密时失败");
}
// 将用户名和加密后的密码插入到数据库db_whichfilm
User user = new User();
user.setUsername(username);
user.setPassword(password);
user.save();
}
});
// 监听登录按钮buttonLogin,按下时从SQLite验证,验证成功进入MainActivity
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = editTextUsername.getText().toString();
String password = editTextPassword.getText().toString();
// 从数据库查询用户密码是否匹配
List<User> users = LitePal.where("username=?", username).find(User.class);
boolean isValid = false;
if (users != null) {
for (User user : users) {
String storedPassword = user.getPassword();
// 对数据库存储的密码进行AES解密
try {
storedPassword = AESUtil.decrypt("41227677", storedPassword);
} catch (Exception e) {
Log.d(TAG, "对数据库存储的密码进行AES解密失败");
}
if (password.equals(storedPassword)) {
isValid = true;
break;
}
}
}
if (isValid) {
// 若用户勾选checkBoxRemember,SharedPreferences记住密码
// 否则清除SharedPreferences存储的数据
editor = pref.edit();
if (checkBoxRemember.isChecked()) {
editor.putBoolean("remember_password", true);
editor.putString("username", username);
// 对用户密码进行AES加密
try {
password = AESUtil.encrypt("41227677", password);
} catch (Exception e) {
Log.d(TAG, "对SharedPreferences中存储的用户密码进行加密时失败");
password = "";
}
editor.putString("password", password);
} else {
editor.clear();
}
editor.apply();
// 跳转Activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("username", username);
startActivity(intent);
} else {
Toast.makeText(LoginActivity.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
}
}
});
// 监听密码输入框editTextPassword焦点,获得焦点将图片改为捂脸
editTextPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
imageViewLogin.setImageResource(R.drawable.login_password);
} else {
imageViewLogin.setImageResource(R.drawable.login_username);
}
}
});
}
}
| UTF-8 | Java | 7,175 | java | LoginActivity.java | Java | [
{
"context": ".LitePal;\n\nimport java.util.List;\n\n/**\n * @Author: birdguan\n * @Date: 2020/6/18 17:50\n */\npublic class LoginA",
"end": 729,
"score": 0.9996614456176758,
"start": 721,
"tag": "USERNAME",
"value": "birdguan"
},
{
"context": "AES解密\n try {\n ... | null | [] | package com.birdguan.whichmovie.ui.login;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.birdguan.whichmovie.MainActivity;
import com.birdguan.whichmovie.R;
import com.birdguan.whichmovie.base.BaseActivity;
import com.birdguan.whichmovie.model.User;
import com.birdguan.whichmovie.util.AESUtil;
import org.litepal.LitePal;
import java.util.List;
/**
* @Author: birdguan
* @Date: 2020/6/18 17:50
*/
public class LoginActivity extends BaseActivity {
private static final String TAG = "WhichMovie/LoginActivity";
private SharedPreferences pref; // 存储记住密码
private SharedPreferences.Editor editor;
private ImageView imageViewLogin;
private EditText editTextUsername;
private EditText editTextPassword;
private CheckBox checkBoxRemember;
private Button buttonSignUp;
private Button buttonLogin;
/**
* 焦点定位在editTextPassword时切换为捂眼图片,负责为睁眼图片
* 勾选记住密码复选框时用SharedPreferences保存用户名和密码
* 点击注册按钮buttonSignUp时存储到SQLite
* 点击登录按钮buttonLogin时到SQLite验证username对应的
* @param savedInstanceState -
*/
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
pref = PreferenceManager.getDefaultSharedPreferences(this);
imageViewLogin = (ImageView) findViewById(R.id.iv_login);
editTextUsername = (EditText) findViewById(R.id.et_username);
editTextPassword = (EditText) findViewById(R.id.et_password);
checkBoxRemember = (CheckBox) findViewById(R.id.cb_remember);
buttonSignUp = (Button) findViewById(R.id.btn_sign_up);
buttonLogin = (Button) findViewById(R.id.btn_login);
// 若之前用户选择了记住密码,则恢复用户名和密码以及CheckBox勾选状态
final boolean isRemember = pref.getBoolean("remember_password", false);
if (isRemember) {
String username = pref.getString("username", "");
String password = pref.getString("password", "");
// 对密码进行AES解密
try {
password = AESUtil.decrypt("<PASSWORD>", password);
} catch (Exception e) {
Log.d(TAG, "AES密码解密失败");
e.printStackTrace();
}
editTextUsername.setText(username);
editTextPassword.setText(password);
checkBoxRemember.setChecked(true);
}
// 监听注册按钮buttonSignUp,按下时将用户名和密码存到SQLite
buttonSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 获取用户名和密码
String username = editTextUsername.getText().toString();
String password = editTextPassword.getText().toString();
// 对要储存到数据库的密码进行AES加密
try {
password = AESUtil.encrypt("<PASSWORD>", password);
} catch (Exception e) {
Log.d(TAG, "对要储存到数据库的密码进行AES加密时失败");
}
// 将用户名和加密后的密码插入到数据库db_whichfilm
User user = new User();
user.setUsername(username);
user.setPassword(<PASSWORD>);
user.save();
}
});
// 监听登录按钮buttonLogin,按下时从SQLite验证,验证成功进入MainActivity
buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = editTextUsername.getText().toString();
String password = editTextPassword.getText().toString();
// 从数据库查询用户密码是否匹配
List<User> users = LitePal.where("username=?", username).find(User.class);
boolean isValid = false;
if (users != null) {
for (User user : users) {
String storedPassword = user.getPassword();
// 对数据库存储的密码进行AES解密
try {
storedPassword = AESUtil.decrypt("<PASSWORD>", storedPassword);
} catch (Exception e) {
Log.d(TAG, "对数据库存储的密码进行AES解密失败");
}
if (password.equals(storedPassword)) {
isValid = true;
break;
}
}
}
if (isValid) {
// 若用户勾选checkBoxRemember,SharedPreferences记住密码
// 否则清除SharedPreferences存储的数据
editor = pref.edit();
if (checkBoxRemember.isChecked()) {
editor.putBoolean("remember_password", true);
editor.putString("username", username);
// 对用户密码进行AES加密
try {
password = AESUtil.encrypt("<PASSWORD>", password);
} catch (Exception e) {
Log.d(TAG, "对SharedPreferences中存储的用户密码进行加密时失败");
password = "";
}
editor.putString("password", password);
} else {
editor.clear();
}
editor.apply();
// 跳转Activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("username", username);
startActivity(intent);
} else {
Toast.makeText(LoginActivity.this, "用户名或密码错误", Toast.LENGTH_SHORT).show();
}
}
});
// 监听密码输入框editTextPassword焦点,获得焦点将图片改为捂脸
editTextPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
imageViewLogin.setImageResource(R.drawable.login_password);
} else {
imageViewLogin.setImageResource(R.drawable.login_username);
}
}
});
}
}
| 7,185 | 0.562739 | 0.556151 | 172 | 36.947674 | 23.403753 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.593023 | false | false | 10 |
83c1775af8c5afe5905b3b32f7a645fdcbe80f7b | 25,984,552,145,234 | 6b4e298c8c5c74f82593044b50330e4a263a3303 | /src/database/controller/TeacherJpaController.java | dcc63f14165857b9aaf7c90fd54d515cf439b5cb | [] | no_license | larjel/SchoolManagement | https://github.com/larjel/SchoolManagement | 7c572e8e0c023fdd6eb3a0cc2fd77d3574bbc83d | 8748f6730e58a6ebaf7650ef2c069ad7e93b886c | refs/heads/master | 2020-04-10T17:17:27.643000 | 2019-03-28T16:35:08 | 2019-03-28T16:35:08 | 161,169,829 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package database.controller;
import database.MyEntityManager;
import database.domain.Course;
import database.domain.Teacher;
import java.util.List;
import javax.persistence.*;
/**
* @author Lars Jelleryd
*/
public class TeacherJpaController {
//------------------------------------------------------------------------
public static long getNumberOfTeachers() {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.getNumberOfTeachers", Long.class)
.getSingleResult();
} catch (NoResultException e) {
return 0;
}
}
//------------------------------------------------------------------------
public static double getAverageSalary() {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.getAverageSalary", Double.class)
.getSingleResult();
} catch (NoResultException e) {
return 0;
}
}
//------------------------------------------------------------------------
private static boolean teacherExists(Teacher teacher) {
try {
findTeacherByPersonalIdNumber(teacher.getPersonalIdNumber());
return true;
} catch (NoResultException e) {
return false;
}
}
//------------------------------------------------------------------------
public static Teacher findTeacherByPersonalIdNumber(String personalIdNumber) {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.findByPersonalIdNumber", Teacher.class)
.setParameter("personalIdNumber", personalIdNumber)
.getSingleResult();
} catch (NoResultException e) {
throw new NoResultException("No teacher with personal ID number " + personalIdNumber + " exists!");
}
}
//------------------------------------------------------------------------
public static Teacher findTeacherById(long id) {
Teacher teacher = MyEntityManager.get().find(Teacher.class, id);
if (teacher == null) {
throw new NoResultException("No teacher with ID " + id + " exists!");
}
return teacher;
}
//------------------------------------------------------------------------
public static void addTeacher(Teacher teacher) {
if (teacherExists(teacher)) {
throw new RuntimeException("Teacher already exists");
}
MyEntityManager.executeTransaction(em -> em.persist(teacher));
}
//------------------------------------------------------------------------
public static void deleteTeacher(long id) {
Teacher teacher = findTeacherById(id);
// Remove teacher from ALL courses first! Otherwise, there will be a
// SQLIntegrityConstraintViolationException due to foreign key constraint failure
CourseJpaController.deleteTeacherFromCourses(id);
// Delete teacher
MyEntityManager.executeTransaction(em -> em.remove(teacher));
}
//------------------------------------------------------------------------
public static void updateTeacherSalary(long id, int salary) {
Teacher teacher = findTeacherById(id);
if (teacher.getSalary() != salary) {
teacher.setSalary(salary);
MyEntityManager.executeTransaction(em -> em.merge(teacher));
}
}
//------------------------------------------------------------------------
public static List<Course> getTeacherCourses(long id) {
Teacher teacher = findTeacherById(id);
return teacher.getCourses();
}
//------------------------------------------------------------------------
public static List<Teacher> getAllTeachers() {
return MyEntityManager.get()
.createNamedQuery("Teacher.findAll", Teacher.class)
.getResultList();
}
}
| UTF-8 | Java | 3,991 | java | TeacherJpaController.java | Java | [
{
"context": ".List;\nimport javax.persistence.*;\n\n/**\n * @author Lars Jelleryd\n */\npublic class TeacherJpaController {\n\n //--",
"end": 206,
"score": 0.999873697757721,
"start": 193,
"tag": "NAME",
"value": "Lars Jelleryd"
}
] | null | [] | package database.controller;
import database.MyEntityManager;
import database.domain.Course;
import database.domain.Teacher;
import java.util.List;
import javax.persistence.*;
/**
* @author <NAME>
*/
public class TeacherJpaController {
//------------------------------------------------------------------------
public static long getNumberOfTeachers() {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.getNumberOfTeachers", Long.class)
.getSingleResult();
} catch (NoResultException e) {
return 0;
}
}
//------------------------------------------------------------------------
public static double getAverageSalary() {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.getAverageSalary", Double.class)
.getSingleResult();
} catch (NoResultException e) {
return 0;
}
}
//------------------------------------------------------------------------
private static boolean teacherExists(Teacher teacher) {
try {
findTeacherByPersonalIdNumber(teacher.getPersonalIdNumber());
return true;
} catch (NoResultException e) {
return false;
}
}
//------------------------------------------------------------------------
public static Teacher findTeacherByPersonalIdNumber(String personalIdNumber) {
try {
return MyEntityManager.get()
.createNamedQuery("Teacher.findByPersonalIdNumber", Teacher.class)
.setParameter("personalIdNumber", personalIdNumber)
.getSingleResult();
} catch (NoResultException e) {
throw new NoResultException("No teacher with personal ID number " + personalIdNumber + " exists!");
}
}
//------------------------------------------------------------------------
public static Teacher findTeacherById(long id) {
Teacher teacher = MyEntityManager.get().find(Teacher.class, id);
if (teacher == null) {
throw new NoResultException("No teacher with ID " + id + " exists!");
}
return teacher;
}
//------------------------------------------------------------------------
public static void addTeacher(Teacher teacher) {
if (teacherExists(teacher)) {
throw new RuntimeException("Teacher already exists");
}
MyEntityManager.executeTransaction(em -> em.persist(teacher));
}
//------------------------------------------------------------------------
public static void deleteTeacher(long id) {
Teacher teacher = findTeacherById(id);
// Remove teacher from ALL courses first! Otherwise, there will be a
// SQLIntegrityConstraintViolationException due to foreign key constraint failure
CourseJpaController.deleteTeacherFromCourses(id);
// Delete teacher
MyEntityManager.executeTransaction(em -> em.remove(teacher));
}
//------------------------------------------------------------------------
public static void updateTeacherSalary(long id, int salary) {
Teacher teacher = findTeacherById(id);
if (teacher.getSalary() != salary) {
teacher.setSalary(salary);
MyEntityManager.executeTransaction(em -> em.merge(teacher));
}
}
//------------------------------------------------------------------------
public static List<Course> getTeacherCourses(long id) {
Teacher teacher = findTeacherById(id);
return teacher.getCourses();
}
//------------------------------------------------------------------------
public static List<Teacher> getAllTeachers() {
return MyEntityManager.get()
.createNamedQuery("Teacher.findAll", Teacher.class)
.getResultList();
}
}
| 3,984 | 0.496617 | 0.496116 | 111 | 34.954956 | 29.242504 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 10 |
edc692a815e9fed537077f253239dcec44c00658 | 28,776,280,888,636 | 6fee8783282a25dbab02875236faef1b44061ad2 | /ShurikenHitStuff.java | 5e08cc5d1ddbf7e0f1ec38fb4d32b7525e59205a | [] | no_license | Kevlar0150/JavaGameProject | https://github.com/Kevlar0150/JavaGameProject | 5f9d11e21debd632fa5303cace4ff79f354a47a3 | 9b2ed4a2ff4ff9c531029750d28338b8b6a04261 | refs/heads/master | 2020-04-16T07:57:19.575000 | 2019-01-12T15:55:55 | 2019-01-12T15:55:55 | 165,405,384 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package game;
import city.cs.engine.*;
/**
* Collision listener that allows the Shuriken to collide with things.
*/
public class ShurikenHitStuff implements CollisionListener {
private Shuriken shuriken;
/** initialises Lemon collisions.
@param shuriken instance of Shuriken*/
public ShurikenHitStuff(Shuriken shuriken) {
this.shuriken = shuriken;
}
@Override
public void collide(CollisionEvent e) {
if(e.getOtherBody() instanceof Energy) {
e.getReportingBody().destroy();
}
if(e.getOtherBody() instanceof StaticBody) {
e.getReportingBody().destroy();
}
}
} | UTF-8 | Java | 721 | java | ShurikenHitStuff.java | Java | [] | null | [] | package game;
import city.cs.engine.*;
/**
* Collision listener that allows the Shuriken to collide with things.
*/
public class ShurikenHitStuff implements CollisionListener {
private Shuriken shuriken;
/** initialises Lemon collisions.
@param shuriken instance of Shuriken*/
public ShurikenHitStuff(Shuriken shuriken) {
this.shuriken = shuriken;
}
@Override
public void collide(CollisionEvent e) {
if(e.getOtherBody() instanceof Energy) {
e.getReportingBody().destroy();
}
if(e.getOtherBody() instanceof StaticBody) {
e.getReportingBody().destroy();
}
}
} | 721 | 0.599168 | 0.599168 | 28 | 23.821428 | 20.918299 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.214286 | false | false | 10 |
124ed43588a59f7286f597bb31cb8283775c015c | 38,070,590,121,071 | ba43ff30af334f187c35ead46d3a0b79e70feb92 | /src/main/java/en/app/springlabs/View/ListView.java | eee30a1d3914a21d5378e197c8f4061252853d14 | [] | no_license | denis82283/SpringLabs | https://github.com/denis82283/SpringLabs | 7b7848b98c30ed9af0a544f307d28076c73b0614 | c4a8d15ef726a5f164aa7d1d587f67c70eb1693c | refs/heads/main | 2023-07-17T23:18:43.375000 | 2021-08-25T18:49:41 | 2021-08-25T18:49:41 | 388,124,681 | 0 | 0 | null | false | 2021-08-19T19:43:42 | 2021-07-21T13:24:56 | 2021-08-16T17:24:06 | 2021-08-19T19:43:41 | 82 | 0 | 0 | 0 | Java | false | false | package en.app.springlabs.View;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import en.app.springlabs.Domain.Singers;
import en.app.springlabs.Service.SingersService;
@Route(value = "", layout = MainLayout.class)
@PageTitle("Singers | Vaadin")
public class ListView extends VerticalLayout{
private SingersService singersService;
private Grid<Singers> grid = new Grid<>(Singers.class);
private TextField filterText = new TextField();
private ContactForm form;
public ListView(SingersService singersService) {
this.singersService = singersService;
addClassName("list-view");
setSizeFull();
configureGrid();
form = new ContactForm(singersService.findAll());
form.addListener(ContactForm.SaveEvent.class, this::saveContact);
form.addListener(ContactForm.DeleteEvent.class, this::deleteContact);
form.addListener(ContactForm.CloseEvent.class, e -> closeEditor());
Div content = new Div(grid, form);
content.addClassName("content");
content.setSizeFull();
add(getToolbar(), content);
updateList();
closeEditor();
}
private void configureFilter() {
filterText.setPlaceholder("Filter by name...");
filterText.setClearButtonVisible(true);
filterText.setValueChangeMode(ValueChangeMode.LAZY);
filterText.addValueChangeListener(e -> updateList());
}
private void configureGrid() {
grid.addClassName("contact-grid");
grid.setSizeFull();
grid.setColumns(
"name",
"surname",
"musical_group",
"pseudonym"
);
grid.getColumns().forEach(col -> col.setAutoWidth(true));
grid.asSingleSelect().addValueChangeListener(event ->
editSingers(event.getValue()));
}
private void updateList() {
grid.setItems(singersService.findAll(filterText.getValue()));
}
public void editSingers(Singers singers) {
if (singers == null) {
closeEditor();
} else {
form.setSingers(singers);
form.setVisible(true);
addClassName("editing");
}
}
private void closeEditor() {
form.setSingers(null);
form.setVisible(false);
removeClassName("editing");
}
private void saveContact(ContactForm.SaveEvent event) {
singersService.save(event.getContact());
updateList();
closeEditor();
}
private void deleteContact(ContactForm.DeleteEvent event) {
singersService.delete(event.getContact());
updateList();
closeEditor();
}
void addSinger() {
grid.asSingleSelect().clear();
editSingers(new Singers());
}
private HorizontalLayout getToolbar() {
filterText.setPlaceholder("Filter by name...");
filterText.setClearButtonVisible(true);
filterText.setValueChangeMode(ValueChangeMode.LAZY);
filterText.addValueChangeListener(e -> updateList());
Button addContactButton = new Button("Add contact");
addContactButton.addClickListener(click -> addSinger());
HorizontalLayout toolbar = new HorizontalLayout(filterText, addContactButton);
toolbar.addClassName("toolbar");
return toolbar;
}
}
| UTF-8 | Java | 3,810 | java | ListView.java | Java | [] | null | [] | package en.app.springlabs.View;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import en.app.springlabs.Domain.Singers;
import en.app.springlabs.Service.SingersService;
@Route(value = "", layout = MainLayout.class)
@PageTitle("Singers | Vaadin")
public class ListView extends VerticalLayout{
private SingersService singersService;
private Grid<Singers> grid = new Grid<>(Singers.class);
private TextField filterText = new TextField();
private ContactForm form;
public ListView(SingersService singersService) {
this.singersService = singersService;
addClassName("list-view");
setSizeFull();
configureGrid();
form = new ContactForm(singersService.findAll());
form.addListener(ContactForm.SaveEvent.class, this::saveContact);
form.addListener(ContactForm.DeleteEvent.class, this::deleteContact);
form.addListener(ContactForm.CloseEvent.class, e -> closeEditor());
Div content = new Div(grid, form);
content.addClassName("content");
content.setSizeFull();
add(getToolbar(), content);
updateList();
closeEditor();
}
private void configureFilter() {
filterText.setPlaceholder("Filter by name...");
filterText.setClearButtonVisible(true);
filterText.setValueChangeMode(ValueChangeMode.LAZY);
filterText.addValueChangeListener(e -> updateList());
}
private void configureGrid() {
grid.addClassName("contact-grid");
grid.setSizeFull();
grid.setColumns(
"name",
"surname",
"musical_group",
"pseudonym"
);
grid.getColumns().forEach(col -> col.setAutoWidth(true));
grid.asSingleSelect().addValueChangeListener(event ->
editSingers(event.getValue()));
}
private void updateList() {
grid.setItems(singersService.findAll(filterText.getValue()));
}
public void editSingers(Singers singers) {
if (singers == null) {
closeEditor();
} else {
form.setSingers(singers);
form.setVisible(true);
addClassName("editing");
}
}
private void closeEditor() {
form.setSingers(null);
form.setVisible(false);
removeClassName("editing");
}
private void saveContact(ContactForm.SaveEvent event) {
singersService.save(event.getContact());
updateList();
closeEditor();
}
private void deleteContact(ContactForm.DeleteEvent event) {
singersService.delete(event.getContact());
updateList();
closeEditor();
}
void addSinger() {
grid.asSingleSelect().clear();
editSingers(new Singers());
}
private HorizontalLayout getToolbar() {
filterText.setPlaceholder("Filter by name...");
filterText.setClearButtonVisible(true);
filterText.setValueChangeMode(ValueChangeMode.LAZY);
filterText.addValueChangeListener(e -> updateList());
Button addContactButton = new Button("Add contact");
addContactButton.addClickListener(click -> addSinger());
HorizontalLayout toolbar = new HorizontalLayout(filterText, addContactButton);
toolbar.addClassName("toolbar");
return toolbar;
}
}
| 3,810 | 0.66273 | 0.66273 | 120 | 30.75 | 22.640764 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.633333 | false | false | 10 |
ae6996e92b6b72bac81da3746001b1cfadff9d57 | 8,083,128,516,027 | cbb75ebbee3fb80a5e5ad842b7a4bb4a5a1ec5f5 | /com/jingdong/crash/inner/ac.java | 1ce7e7e659646035539091cf863feb5de6490f61 | [] | no_license | killbus/jd_decompile | https://github.com/killbus/jd_decompile | 9cc676b4be9c0415b895e4c0cf1823e0a119dcef | 50c521ce6a2c71c37696e5c131ec2e03661417cc | refs/heads/master | 2022-01-13T03:27:02.492000 | 2018-05-14T11:21:30 | 2018-05-14T11:21:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jingdong.crash.inner;
import android.content.Context;
import android.content.Intent;
class ac implements b {
ac() {
}
public void a(Context context, v vVar) {
try {
if (ah.b) {
ah.a("DefaultOnCatchListener", "onCatch..........");
}
Intent intent = new Intent();
intent.putExtra("crash", vVar);
intent.setClass(context, CrashService.class);
context.startService(intent);
} catch (Throwable th) {
th.printStackTrace();
System.exit(0);
}
}
}
| UTF-8 | Java | 606 | java | ac.java | Java | [] | null | [] | package com.jingdong.crash.inner;
import android.content.Context;
import android.content.Intent;
class ac implements b {
ac() {
}
public void a(Context context, v vVar) {
try {
if (ah.b) {
ah.a("DefaultOnCatchListener", "onCatch..........");
}
Intent intent = new Intent();
intent.putExtra("crash", vVar);
intent.setClass(context, CrashService.class);
context.startService(intent);
} catch (Throwable th) {
th.printStackTrace();
System.exit(0);
}
}
}
| 606 | 0.531353 | 0.529703 | 24 | 24.25 | 18.626259 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 10 |
1cb9a7e66d21a33d402621a6aa16760cb1a0c7a1 | 23,407,571,828,444 | b5dd81b7eaff0ec12e702149730e37dcd866cde7 | /decorator pattern/src/Gti.java | 1b032678fa43cfee131f04afb593c93b4125c50c | [] | no_license | alwasa0b/designPatterns | https://github.com/alwasa0b/designPatterns | 84b7da80879db0ce90bcff90e2756986260f0459 | bd290654c2bd338c3e7a64aacc47f605a2de95ac | refs/heads/master | 2021-03-12T19:20:15.978000 | 2015-05-10T15:29:19 | 2015-05-10T15:29:19 | 33,360,264 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class Gti extends Trim {
IEngine engine;
Sensor s;
public Gti(IGolf baseGolf) {
super(baseGolf);
this.engine = new Engine(4, 2.0);
s = new Sensor(engine);
}
public double GetCost(){
return baseGolf.GetCost()+8000;
}
@Override
public IEngine GetEngine() {
// TODO Auto-generated method stub
return this.engine;
}
@Override
public String GetMPG() {
// TODO Auto-generated method stub
return "25 City, 34 HWY";
}
public String GetTrim() {
// TODO Auto-generated method stub
return "GTI";
}
public String GetWheels() {
// TODO Auto-generated method stub
return "18 inch alloy wheels";
}
}
| UTF-8 | Java | 645 | java | Gti.java | Java | [] | null | [] |
public class Gti extends Trim {
IEngine engine;
Sensor s;
public Gti(IGolf baseGolf) {
super(baseGolf);
this.engine = new Engine(4, 2.0);
s = new Sensor(engine);
}
public double GetCost(){
return baseGolf.GetCost()+8000;
}
@Override
public IEngine GetEngine() {
// TODO Auto-generated method stub
return this.engine;
}
@Override
public String GetMPG() {
// TODO Auto-generated method stub
return "25 City, 34 HWY";
}
public String GetTrim() {
// TODO Auto-generated method stub
return "GTI";
}
public String GetWheels() {
// TODO Auto-generated method stub
return "18 inch alloy wheels";
}
}
| 645 | 0.668217 | 0.648062 | 37 | 16.405405 | 13.603377 | 36 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.540541 | false | false | 10 |
8881f337b132e5d737ca15c99507a49d84e2a286 | 39,238,821,237,958 | 88bee0d8971b0051ef84add0dc38c8857865bae1 | /sternico-meals-bpm/src/main/java/de/gravitex/misc/datasource/MealRequesterDatasource.java | c18e916364c6abfa7c32a89df37942356c7ae4ac | [] | no_license | gheddie/speedys-resourceplanning-new | https://github.com/gheddie/speedys-resourceplanning-new | 894245bba36b35662b24fe3d790b97d2872afb79 | 64e7c22337b5c3b8c5f22c3e66efb0021d19a8cf | refs/heads/master | 2020-12-12T13:53:58.357000 | 2016-08-04T13:22:53 | 2016-08-04T13:22:53 | 47,066,595 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.gravitex.misc.datasource;
import de.gravitex.hibernateadapter.datasource.DefaultDatasource;
import de.gravitex.misc.entity.MealRequester;
public class MealRequesterDatasource extends DefaultDatasource<MealRequester>
{
protected Class<MealRequester> getGenericType()
{
return MealRequester.class;
}
} | UTF-8 | Java | 343 | java | MealRequesterDatasource.java | Java | [] | null | [] | package de.gravitex.misc.datasource;
import de.gravitex.hibernateadapter.datasource.DefaultDatasource;
import de.gravitex.misc.entity.MealRequester;
public class MealRequesterDatasource extends DefaultDatasource<MealRequester>
{
protected Class<MealRequester> getGenericType()
{
return MealRequester.class;
}
} | 343 | 0.772595 | 0.772595 | 12 | 26.75 | 27.028149 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 10 |
045bdd3e0bda19186d5305f9059e308b789745b2 | 34,093,450,451,026 | cef6b4b5d2eae54ef6383ee20fd3070597d37b54 | /budgeteer-core/src/test/java/de/adesso/budgeteer/core/user/service/GetUserByEmailServiceTest.java | bf5ed608125e64ee7f76770904c2208dadc44c05 | [
"MIT"
] | permissive | adessoAG/budgeteer | https://github.com/adessoAG/budgeteer | 8cafdaff7fb964ebb9677e077a35f3052fc10e1d | 74f51b00ce04a471d2a9dcb4197e4ec8d6bde6a8 | refs/heads/main | 2022-02-06T09:37:51.621000 | 2022-01-28T12:13:44 | 2022-01-28T12:13:44 | 24,379,703 | 17 | 13 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.adesso.budgeteer.core.user.service;
import de.adesso.budgeteer.core.user.domain.User;
import de.adesso.budgeteer.core.user.port.out.GetUserByEmailPort;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class GetUserByEmailServiceTest {
@InjectMocks private GetUserByEmailService getUserByEmailService;
@Mock private GetUserByEmailPort getUserByEmailPort;
@Test
void shouldReturnOptionalOfUserIfUserExists() {
var email = "test@mail";
var expectedUser = Optional.of(new User(1, "test"));
when(getUserByEmailPort.getUserByEmail(email)).thenReturn(expectedUser);
var returnedUser = getUserByEmailService.getUserByEmail(email);
assertThat(returnedUser).isEqualTo(expectedUser);
}
@Test
void shouldReturnEmptyOptionalIfUserDoesNotExists() {
var email = "test@mail";
var expectedUser = Optional.<User>empty();
when(getUserByEmailPort.getUserByEmail(email)).thenReturn(expectedUser);
var returnedUser = getUserByEmailService.getUserByEmail(email);
assertThat(returnedUser).isEqualTo(expectedUser);
}
}
| UTF-8 | Java | 1,434 | java | GetUserByEmailServiceTest.java | Java | [] | null | [] | package de.adesso.budgeteer.core.user.service;
import de.adesso.budgeteer.core.user.domain.User;
import de.adesso.budgeteer.core.user.port.out.GetUserByEmailPort;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class GetUserByEmailServiceTest {
@InjectMocks private GetUserByEmailService getUserByEmailService;
@Mock private GetUserByEmailPort getUserByEmailPort;
@Test
void shouldReturnOptionalOfUserIfUserExists() {
var email = "test@mail";
var expectedUser = Optional.of(new User(1, "test"));
when(getUserByEmailPort.getUserByEmail(email)).thenReturn(expectedUser);
var returnedUser = getUserByEmailService.getUserByEmail(email);
assertThat(returnedUser).isEqualTo(expectedUser);
}
@Test
void shouldReturnEmptyOptionalIfUserDoesNotExists() {
var email = "test@mail";
var expectedUser = Optional.<User>empty();
when(getUserByEmailPort.getUserByEmail(email)).thenReturn(expectedUser);
var returnedUser = getUserByEmailService.getUserByEmail(email);
assertThat(returnedUser).isEqualTo(expectedUser);
}
}
| 1,434 | 0.760809 | 0.760112 | 43 | 32.348839 | 26.713715 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.55814 | false | false | 10 |
df0b7bb10d96aa63820ae422cc078823cf7f3cec | 35,768,487,690,566 | 89b3e89d0186dcee896bbbc02f6e5b41205acce0 | /Beverage_Maker/Caramel.java | 09a481376e5399d075b59111069c463ecd268d02 | [] | no_license | Gamej18/Java-Code-Samples | https://github.com/Gamej18/Java-Code-Samples | 9c1afec817bf2e690a9c414961f5431b9a6f4de3 | 4f28f494bce32a627d21d148e1e18ef342cf9544 | refs/heads/main | 2023-03-01T06:22:52.968000 | 2022-03-04T23:05:44 | 2022-03-04T23:05:44 | 338,492,487 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Caramel extends Beverage {
public Caramel() {
description = "Caramel Coffee";
}
public double cost()
{
return 1.35;
}
}
| UTF-8 | Java | 170 | java | Caramel.java | Java | [] | null | [] | public class Caramel extends Beverage {
public Caramel() {
description = "Caramel Coffee";
}
public double cost()
{
return 1.35;
}
}
| 170 | 0.558824 | 0.541176 | 10 | 16 | 14.205632 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 10 |
f62c8c665af845e2417f335f98bbe3bb9e6de1f1 | 36,137,854,876,805 | 99501afc426faf1794d4b320948059965f6a6942 | /aula09-10-polymorphism/src/animals/Cat.java | 121bb62e2f138ba0302b54ec7e1279c42ada81bf | [] | no_license | poo-2021-2-da3/lecture-code | https://github.com/poo-2021-2-da3/lecture-code | 0d7ea12304aae5c2e8f3bbf48c39ef8ee6bcd28d | 47eb1330eb2d1aecea3b554f9558b535e1c1cd7e | refs/heads/main | 2023-06-30T04:05:20.941000 | 2021-07-28T14:07:35 | 2021-07-28T14:07:35 | 369,845,139 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package animals;
public class Cat extends Animal {
@Override
protected String makeNoise() {
return "miau";
}
@Override
protected String eatsWhat() {
return "meat";
}
}
| UTF-8 | Java | 210 | java | Cat.java | Java | [] | null | [] | package animals;
public class Cat extends Animal {
@Override
protected String makeNoise() {
return "miau";
}
@Override
protected String eatsWhat() {
return "meat";
}
}
| 210 | 0.590476 | 0.590476 | 13 | 15.153846 | 12.284112 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.230769 | false | false | 10 |
d053eb282877cb3e84e80e59e8aec93fa971f687 | 16,999,480,600,024 | 1950d5fb7e56bb750a738d9568a6fa0594d9c71c | /src/com/thread/sync/MyThread1.java | ee88523a4fb5db0aff4f575c60805de15a0efae0 | [] | no_license | PKOMBase/pko_thread | https://github.com/PKOMBase/pko_thread | 6ef98673b0da4c4b6aa1e5881aec401a4e85792a | cc7708bf98eaca02c260036f59ecfbb3e36dd9b6 | refs/heads/master | 2021-01-19T22:34:06.936000 | 2017-05-17T10:40:12 | 2017-05-17T10:40:12 | 88,824,078 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.thread.sync;
public class MyThread1 implements Runnable {
private String msg;
public MyThread1(String msg) {
super();
this.msg = msg;
}
public void doSomething(String msg) {
System.out.println("excuted by thread1:" + Thread.currentThread().getName());
System.out.println(msg);
}
public void run() {
doSomething(this.msg);
};
}
| UTF-8 | Java | 412 | java | MyThread1.java | Java | [] | null | [] | package com.thread.sync;
public class MyThread1 implements Runnable {
private String msg;
public MyThread1(String msg) {
super();
this.msg = msg;
}
public void doSomething(String msg) {
System.out.println("excuted by thread1:" + Thread.currentThread().getName());
System.out.println(msg);
}
public void run() {
doSomething(this.msg);
};
}
| 412 | 0.609223 | 0.601942 | 20 | 19.6 | 20.910284 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 10 |
2eaa8546e8094eef908905a43ff1aebeb045282a | 19,189,913,928,018 | 89b8ba48df0fd1807c4099ece560416215749a37 | /app/src/main/java/com/jannick/lipastreaming/adapters/StreamAdapter.java | 275466eee821245f57a166f445a2d9414f3c4a44 | [] | no_license | Jannickvb/LipaStreaming-android | https://github.com/Jannickvb/LipaStreaming-android | 8559e6663d26a8702dc135fa55a4424ec255f6c2 | d9dbade6cfa78c270e6dc04f3106e356c28b31a0 | refs/heads/master | 2021-01-10T16:33:55.271000 | 2016-03-30T22:47:31 | 2016-03-30T22:47:31 | 54,132,764 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jannick.lipastreaming.adapters;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.jannick.lipastreaming.R;
import com.jannick.lipastreaming.activities.edit.AlarmEditActivity;
import com.jannick.lipastreaming.activities.edit.StreamEditActivity;
import com.jannick.lipastreaming.model.jsonTokens.StreamToken;
import com.jannick.lipastreaming.utils.LinkUtils;
/**
* Created by Jannick on 17-3-2016.
*/
public class StreamAdapter extends ArrayAdapter<StreamToken.Stream>{
StreamToken.Stream[] streams;
public StreamAdapter(Context context, StreamToken.Stream[] streams){
super(context, R.layout.list_row_stream,streams);
this.streams = streams;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View v = inflater.inflate(R.layout.list_row_stream, parent, false);
final StreamToken.Stream item = getItem(position);
TextView name = (TextView)v.findViewById(R.id.stream_name);
TextView ip = (TextView)v.findViewById(R.id.stream_ip);
Button btTry = (Button)v.findViewById(R.id.list_row_try);
name.setText(item.getName());
ip.setText(item.getIp());
String link = "http://"+item.getIp() + "/" + item.getPath();
LinkUtils.addHyperlinkEvent(btTry,link);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), StreamEditActivity.class);
intent.putExtra("id", item.getId());
intent.putExtra("name", item.getName());
intent.putExtra("ip", item.getIp());
intent.putExtra("port", item.getPort());
intent.putExtra("path", item.getPath());
v.getContext().startActivity(intent);
}
});
return v;
}
}
| UTF-8 | Java | 2,237 | java | StreamAdapter.java | Java | [
{
"context": ".lipastreaming.utils.LinkUtils;\n\n/**\n * Created by Jannick on 17-3-2016.\n */\npublic class StreamAdapter exte",
"end": 665,
"score": 0.8990321755409241,
"start": 658,
"tag": "NAME",
"value": "Jannick"
}
] | null | [] | package com.jannick.lipastreaming.adapters;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.jannick.lipastreaming.R;
import com.jannick.lipastreaming.activities.edit.AlarmEditActivity;
import com.jannick.lipastreaming.activities.edit.StreamEditActivity;
import com.jannick.lipastreaming.model.jsonTokens.StreamToken;
import com.jannick.lipastreaming.utils.LinkUtils;
/**
* Created by Jannick on 17-3-2016.
*/
public class StreamAdapter extends ArrayAdapter<StreamToken.Stream>{
StreamToken.Stream[] streams;
public StreamAdapter(Context context, StreamToken.Stream[] streams){
super(context, R.layout.list_row_stream,streams);
this.streams = streams;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View v = inflater.inflate(R.layout.list_row_stream, parent, false);
final StreamToken.Stream item = getItem(position);
TextView name = (TextView)v.findViewById(R.id.stream_name);
TextView ip = (TextView)v.findViewById(R.id.stream_ip);
Button btTry = (Button)v.findViewById(R.id.list_row_try);
name.setText(item.getName());
ip.setText(item.getIp());
String link = "http://"+item.getIp() + "/" + item.getPath();
LinkUtils.addHyperlinkEvent(btTry,link);
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), StreamEditActivity.class);
intent.putExtra("id", item.getId());
intent.putExtra("name", item.getName());
intent.putExtra("ip", item.getIp());
intent.putExtra("port", item.getPort());
intent.putExtra("path", item.getPath());
v.getContext().startActivity(intent);
}
});
return v;
}
}
| 2,237 | 0.677246 | 0.674117 | 63 | 34.507938 | 25.52302 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.825397 | false | false | 10 |
1ecdda3c5c68dfe4ce6ec5d021755204237c972b | 4,234,837,792,699 | c954c5c9035e6d9e62d559f21debe232d6cd681d | /src/test/java/com/nowcoder/NowcoderApplicationTests.java | 4422fe93339b47e6f1c999d1f1e86598776b51a1 | [] | no_license | xiaohuixiaohuixiaohui/nowcoder | https://github.com/xiaohuixiaohuixiaohui/nowcoder | cec6d3846659215ca2836d1f072d9dbe5980fc99 | 6f9b1ed689c2f6cfe8954b9580f1df673ba140f0 | refs/heads/master | 2023-03-28T14:52:14.969000 | 2021-03-13T15:31:27 | 2021-03-13T15:31:27 | 347,407,371 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nowcoder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NowcoderApplicationTests {
}
| UTF-8 | Java | 174 | java | NowcoderApplicationTests.java | Java | [] | null | [] | package com.nowcoder;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NowcoderApplicationTests {
}
| 174 | 0.816092 | 0.816092 | 11 | 14.818182 | 19.144514 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 10 |
e9dc59ec876beca58574b6e9cd14a8a3ca0998fd | 32,495,722,608,485 | 4c5c9613e88a2cea6cec4f3587405ae1e02221af | /src/main/java/org/fixtrading/timpani/securitydef/messages/Message.java | b6cc53880b2e7f0039430b09a29572c364b4d044 | [
"Apache-2.0"
] | permissive | FIXTradingCommunity/timpani | https://github.com/FIXTradingCommunity/timpani | f384d166837ccfd1bd462c187b3995d9f2958b73 | b65ebf671b47a8d13ad968e3a0aa369117323854 | refs/heads/master | 2022-06-03T01:24:58 | 2022-05-23T13:20:04 | 2022-05-23T13:20:04 | 56,801,916 | 9 | 2 | Apache-2.0 | false | 2022-05-23T13:20:05 | 2016-04-21T19:57:17 | 2020-12-24T15:44:13 | 2022-05-23T13:20:04 | 40 | 9 | 2 | 2 | Java | false | false | package org.fixtrading.timpani.securitydef.messages;
/**
* Common interface for all messages
* @author Don Mendelson
*
*/
public interface Message {
String getMsgType();
}
| UTF-8 | Java | 180 | java | Message.java | Java | [
{
"context": "**\n * Common interface for all messages\n * @author Don Mendelson\n *\n */\npublic interface Message {\n\n String getMs",
"end": 119,
"score": 0.9997109174728394,
"start": 106,
"tag": "NAME",
"value": "Don Mendelson"
}
] | null | [] | package org.fixtrading.timpani.securitydef.messages;
/**
* Common interface for all messages
* @author <NAME>
*
*/
public interface Message {
String getMsgType();
}
| 173 | 0.727778 | 0.727778 | 11 | 15.363636 | 16.955946 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.181818 | false | false | 10 |
c82aa398c4b2186b708346b0a9ac4a0b2a3695b6 | 11,630,771,464,130 | cb0bbf825b8114c05210d20e77c6bb292f085d41 | /src/test/java/com/arobotv/problems/p0001_p0100/p0062_unique_paths/UniquePathsTest.java | 7e6f2dc710deb36db423028b9b218b61af762ffb | [
"Apache-2.0"
] | permissive | arobot/LeetCode | https://github.com/arobot/LeetCode | 9e8c754ad53a5fdfa02efa2d8dd7660d8704f2be | 8bfc5a1b0e6419fc2e5cc9317ae4f9de7ab93195 | refs/heads/remote | 2023-05-12T14:12:00.362000 | 2023-05-10T03:51:15 | 2023-05-10T03:51:15 | 74,114,048 | 0 | 0 | null | false | 2022-03-17T03:50:44 | 2016-11-18T09:16:44 | 2022-01-11T03:34:54 | 2022-03-17T03:50:43 | 2,565 | 0 | 0 | 0 | Java | false | false | package com.arobotv.problems.p0001_p0100.p0062_unique_paths;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UniquePathsTest {
static UniquePaths uniquePaths = new UniquePaths();
@Test
void testUniquePaths() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(1, 1));
}
@Test
void testUniquePaths2() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(1, 2));
}
@Test
void testUniquePaths3() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(2, 1));
}
@Test
void testUniquePaths4() {
Assertions.assertEquals(2, uniquePaths.uniquePaths(2, 2));
}
@Test
void testUniquePaths5() {
Assertions.assertEquals(3, uniquePaths.uniquePaths(2, 3));
}
@Test
void testUniquePaths6() {
Assertions.assertEquals(28, uniquePaths.uniquePaths(3, 7));
}
@Test
void testUniquePaths7() {
Assertions.assertEquals(6, uniquePaths.uniquePaths(3, 3));
}
}
| UTF-8 | Java | 1,020 | java | UniquePathsTest.java | Java | [] | null | [] | package com.arobotv.problems.p0001_p0100.p0062_unique_paths;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UniquePathsTest {
static UniquePaths uniquePaths = new UniquePaths();
@Test
void testUniquePaths() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(1, 1));
}
@Test
void testUniquePaths2() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(1, 2));
}
@Test
void testUniquePaths3() {
Assertions.assertEquals(1, uniquePaths.uniquePaths(2, 1));
}
@Test
void testUniquePaths4() {
Assertions.assertEquals(2, uniquePaths.uniquePaths(2, 2));
}
@Test
void testUniquePaths5() {
Assertions.assertEquals(3, uniquePaths.uniquePaths(2, 3));
}
@Test
void testUniquePaths6() {
Assertions.assertEquals(28, uniquePaths.uniquePaths(3, 7));
}
@Test
void testUniquePaths7() {
Assertions.assertEquals(6, uniquePaths.uniquePaths(3, 3));
}
}
| 1,020 | 0.664706 | 0.62549 | 37 | 26.567568 | 24.028744 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.675676 | false | false | 10 |
e986b6f034f38aff14e51d64d96ff7147cffd570 | 31,301,721,676,807 | c26b8ac74edee580186c263dc7f57faeba931276 | /data_structures/SeparateChainingHashMap.java | 0b8ff9d5cc1974c8cbb7067e804a426a769ad245 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | vmaudgalya/misc | https://github.com/vmaudgalya/misc | b8797c698061e84083b4e5a609b3337be90f96e4 | daad3a2a6c26d93e159dbf9cba4d2756619c65c0 | refs/heads/master | 2020-04-10T15:55:38.431000 | 2016-05-12T19:20:18 | 2016-05-12T19:20:18 | 40,466,490 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class SeparateChainingHashMap<Key, Value> {
private class Chain<Key, Value> {
private class Node {
Key key;
Value value;
Node next;
public Node(Key key, Value value, Node next) {
this.key = key;
this.value = value;
this.next = next;
}
}
private Node head;
public Value get(Key key) {
for (Node current = head; current != null; current = current.next) {
if (key.equals(current.key)) {
return current.value;
}
}
return null;
}
public boolean put(Key key, Value value) {
for (Node current = head; current != null; current = current.next) {
if (key.equals(current.key)) {
current.value = value;
return false;
}
}
head = new Node(key, value, head);
return true;
}
public Value remove(Key key) {
if (key.equals(head.key)) {
Value val = head.value;
head = head.next;
return val;
}
for (Node current = head; current.next != null; current = current.next) {
if (key.equals(current.next.key)) {
Value val = current.next.value;
current.next = current.next.next;
return val;
}
}
return null;
}
}
private Chain<Key, Value>[] table;
private int size; // number of items in map
private int capacity;
public SeparateChainingHashMap(int capacity) {
table = (Chain<Key, Value>[]) new Chain[capacity];
for (int i = 0; i < capacity; i++) {
table[i] = new Chain();
}
this.capacity = capacity;
}
public SeparateChainingHashMap() {
this(31);
}
public boolean isEmpty() {
return size == 0;
}
public int size() {
return size;
}
private int hash(Key key) {
nullCheck(key);
return (key.hashCode() & 0x7fffffff) % capacity; // avoid hashCode() negative ints
}
public Value get(Key key) {
nullCheck(key);
return table[hash(key)].get(key);
}
public void put(Key key, Value value) {
nullCheck(key);
if (table[hash(key)].put(key, value)) {
size++;
}
}
public boolean containsKey(Key key) {
nullCheck(key);
return get(key) != null;
}
public Value remove(Key key) {
nullCheck(key);
Value val = table[hash(key)].remove(key);
if (val != null) {
size--;
}
return val;
}
private void nullCheck(Key key) {
if (key == null) {
throw new NullPointerException("Null keys not permitted");
}
}
public static void main(String[] args) {
SeparateChainingHashMap<String, Integer> map = new SeparateChainingHashMap<String, Integer>();
map.put("Dogs", 2);
map.put("Cats", 40);
map.put("Ducks", 7);
System.out.println(map.containsKey("Ducks")); // true
System.out.println(map.size()); // 3
System.out.println(map.remove("Cats")); // 40
System.out.println(map.size()); // 2
}
} | UTF-8 | Java | 2,945 | java | SeparateChainingHashMap.java | Java | [] | null | [] | public class SeparateChainingHashMap<Key, Value> {
private class Chain<Key, Value> {
private class Node {
Key key;
Value value;
Node next;
public Node(Key key, Value value, Node next) {
this.key = key;
this.value = value;
this.next = next;
}
}
private Node head;
public Value get(Key key) {
for (Node current = head; current != null; current = current.next) {
if (key.equals(current.key)) {
return current.value;
}
}
return null;
}
public boolean put(Key key, Value value) {
for (Node current = head; current != null; current = current.next) {
if (key.equals(current.key)) {
current.value = value;
return false;
}
}
head = new Node(key, value, head);
return true;
}
public Value remove(Key key) {
if (key.equals(head.key)) {
Value val = head.value;
head = head.next;
return val;
}
for (Node current = head; current.next != null; current = current.next) {
if (key.equals(current.next.key)) {
Value val = current.next.value;
current.next = current.next.next;
return val;
}
}
return null;
}
}
private Chain<Key, Value>[] table;
private int size; // number of items in map
private int capacity;
public SeparateChainingHashMap(int capacity) {
table = (Chain<Key, Value>[]) new Chain[capacity];
for (int i = 0; i < capacity; i++) {
table[i] = new Chain();
}
this.capacity = capacity;
}
public SeparateChainingHashMap() {
this(31);
}
public boolean isEmpty() {
return size == 0;
}
public int size() {
return size;
}
private int hash(Key key) {
nullCheck(key);
return (key.hashCode() & 0x7fffffff) % capacity; // avoid hashCode() negative ints
}
public Value get(Key key) {
nullCheck(key);
return table[hash(key)].get(key);
}
public void put(Key key, Value value) {
nullCheck(key);
if (table[hash(key)].put(key, value)) {
size++;
}
}
public boolean containsKey(Key key) {
nullCheck(key);
return get(key) != null;
}
public Value remove(Key key) {
nullCheck(key);
Value val = table[hash(key)].remove(key);
if (val != null) {
size--;
}
return val;
}
private void nullCheck(Key key) {
if (key == null) {
throw new NullPointerException("Null keys not permitted");
}
}
public static void main(String[] args) {
SeparateChainingHashMap<String, Integer> map = new SeparateChainingHashMap<String, Integer>();
map.put("Dogs", 2);
map.put("Cats", 40);
map.put("Ducks", 7);
System.out.println(map.containsKey("Ducks")); // true
System.out.println(map.size()); // 3
System.out.println(map.remove("Cats")); // 40
System.out.println(map.size()); // 2
}
} | 2,945 | 0.573514 | 0.568761 | 127 | 22.19685 | 20.284216 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.582677 | false | false | 10 |
baef4fded819f0e08a39f677ebecc1bcb11f9358 | 34,359,738,376,168 | d54203fc2aa18f78120d2beda527475dedd1a0b6 | /NIO/NIO_IBM/UseFloatBuffer.java | 60c10250b900938ab0fc1b565b1aee519cae8035 | [] | no_license | sunguangchao/java-learning | https://github.com/sunguangchao/java-learning | 948a29d4817608003dca44fd1e9849930827e98a | 8ed98219d2731f291666b5dd293f7ee06930ba57 | refs/heads/master | 2021-05-01T23:32:15.750000 | 2020-02-23T14:48:23 | 2020-02-23T14:48:23 | 77,735,928 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package NIO_IBM;
import java.nio.FloatBuffer;
/**
* Created by 11981 on 2017/10/21.
*/
public class UseFloatBuffer {
public static void main(String[] args) throws Exception{
FloatBuffer buffer = FloatBuffer.allocate(1024);
for (int i=0; i < buffer.capacity(); ++i){
float f = (float) Math.sin(((float)i/10) * (2*Math.PI));
buffer.put(f);
}
buffer.flip();
while (buffer.hasRemaining()){
float f = buffer.get();
System.out.println(f);
}
}
}
| UTF-8 | Java | 547 | java | UseFloatBuffer.java | Java | [
{
"context": "\n\nimport java.nio.FloatBuffer;\n\n/**\n * Created by 11981 on 2017/10/21.\n */\npublic class UseFloatBuffer {\n",
"end": 71,
"score": 0.996688723564148,
"start": 66,
"tag": "USERNAME",
"value": "11981"
}
] | null | [] | package NIO_IBM;
import java.nio.FloatBuffer;
/**
* Created by 11981 on 2017/10/21.
*/
public class UseFloatBuffer {
public static void main(String[] args) throws Exception{
FloatBuffer buffer = FloatBuffer.allocate(1024);
for (int i=0; i < buffer.capacity(); ++i){
float f = (float) Math.sin(((float)i/10) * (2*Math.PI));
buffer.put(f);
}
buffer.flip();
while (buffer.hasRemaining()){
float f = buffer.get();
System.out.println(f);
}
}
}
| 547 | 0.553931 | 0.515539 | 21 | 25.047619 | 20.60161 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47619 | false | false | 10 |
743dc19e32e667a0e36d78e6b881b8bdcca25b9b | 31,198,642,457,026 | fc610522112f5c8c4dac2d83ce482b8cdc4909c7 | /src/main/java/dev/swt/gui/SelectionAdapterOpen.java | e827a4324fbd67a5031931978c63ff66e3fb72e4 | [] | no_license | xsjad0/simple-editor | https://github.com/xsjad0/simple-editor | 7c3211029190a10d19dee44515778406d4158154 | fb4b1c13ef0cdcfabeef23f09378f768fc68fa77 | refs/heads/dev | 2021-07-17T23:30:11.705000 | 2019-11-13T11:42:24 | 2019-11-13T11:42:24 | 221,023,691 | 0 | 0 | null | false | 2020-10-13T17:22:35 | 2019-11-11T16:33:24 | 2019-11-13T11:57:20 | 2020-10-13T17:22:33 | 1,720 | 0 | 0 | 3 | Java | false | false | package dev.swt.gui;
import java.io.File;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.*;
public class SelectionAdapterOpen extends SelectionAdapter {
private CTabFolder tabFolder;
public SelectionAdapterOpen(CTabFolder tabFolder) {
this.tabFolder = tabFolder;
}
public void widgetSelected(SelectionEvent e) {
Shell shell = (Shell) tabFolder.getShell();
FileDialog ask = new FileDialog(shell, SWT.OPEN);
String path = ask.open();
if (path != null) {
String[] pathArray = path.split(Pattern.quote(File.separator));
String filename = pathArray[pathArray.length - 1];
MyFile myFile = MyFileIO.read(path);
if (myFile != null) {
CTabItem newTab = new CTabItem(tabFolder, SWT.CLOSE);
MyText text = new MyText(tabFolder, SWT.MULTI | SWT.V_SCROLL);
newTab.setControl(text);
newTab.setText(filename);
text.setForeground(new Color(tabFolder.getDisplay(), Integer.valueOf(myFile.getMeta("ForegroundRed")),
Integer.valueOf(myFile.getMeta("ForegroundGreen")),
Integer.valueOf(myFile.getMeta("ForegroundBlue"))));
text.setText(myFile.getContent());
text.addModifyListener(new ModifyListenerText(tabFolder));
tabFolder.setSelection(newTab);
}
}
}
}
| UTF-8 | Java | 1,418 | java | SelectionAdapterOpen.java | Java | [] | null | [] | package dev.swt.gui;
import java.io.File;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.*;
public class SelectionAdapterOpen extends SelectionAdapter {
private CTabFolder tabFolder;
public SelectionAdapterOpen(CTabFolder tabFolder) {
this.tabFolder = tabFolder;
}
public void widgetSelected(SelectionEvent e) {
Shell shell = (Shell) tabFolder.getShell();
FileDialog ask = new FileDialog(shell, SWT.OPEN);
String path = ask.open();
if (path != null) {
String[] pathArray = path.split(Pattern.quote(File.separator));
String filename = pathArray[pathArray.length - 1];
MyFile myFile = MyFileIO.read(path);
if (myFile != null) {
CTabItem newTab = new CTabItem(tabFolder, SWT.CLOSE);
MyText text = new MyText(tabFolder, SWT.MULTI | SWT.V_SCROLL);
newTab.setControl(text);
newTab.setText(filename);
text.setForeground(new Color(tabFolder.getDisplay(), Integer.valueOf(myFile.getMeta("ForegroundRed")),
Integer.valueOf(myFile.getMeta("ForegroundGreen")),
Integer.valueOf(myFile.getMeta("ForegroundBlue"))));
text.setText(myFile.getContent());
text.addModifyListener(new ModifyListenerText(tabFolder));
tabFolder.setSelection(newTab);
}
}
}
}
| 1,418 | 0.735543 | 0.734838 | 45 | 30.51111 | 24.1731 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.4 | false | false | 10 |
7916a6dbe0853c9ae8e564408d17c7062298bc49 | 2,327,872,319,623 | b00a47e66c3e44fb1a5b80a61888eceb9d9ecb37 | /moyouXRms-servcie/src/main/java/com/moyou/moyouRms/service/task/impl/ScheduleJobServiceImp.java | 452a285f4c6a33b493c2bc7449c3f51fd21ca7ae | [] | no_license | moutainhigh/test | https://github.com/moutainhigh/test | a14994d91c7e56e06ec60d6fa0bad05c909dc2c5 | 2c2fbd1a993e428005e92f17b9ab7f20c430493d | refs/heads/master | 2021-09-11T15:23:10.889000 | 2018-04-09T06:10:17 | 2018-04-09T06:10:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.moyou.moyouRms.service.task.impl;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.quartz.CronTrigger;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.moyou.moyouRms.constants.RESPONSE;
import com.moyou.moyouRms.dao.task.base.ScheduleJobDao;
import com.moyou.moyouRms.manager.schedule.ScheduleManager;
import com.moyou.moyouRms.model.po.task.TaskSeting;
import com.moyou.moyouRms.model.po.task.base.ScheduleJob;
import com.moyou.moyouRms.response.Msg;
import com.moyou.moyouRms.service.BaseServiceImp;
import com.moyou.moyouRms.service.task.ScheduleJobService;
import com.moyou.moyouRms.service.task.TaskLogService;
import com.moyou.moyouRms.service.task.TaskSetingService;
import com.moyou.moyouRms.util.JsonUtil;
import com.moyou.moyouRms.util.schedule.CronExpressionUtil;
@Service("scheduleJobService")
public class ScheduleJobServiceImp extends BaseServiceImp<ScheduleJob> implements ScheduleJobService {
/** 调度工厂Bean */
@Autowired
private Scheduler scheduler;
@Autowired
private TaskSetingService taskSetingService;
@Resource
TaskLogService taskLogService;
/** 日志对象 */
private static final Logger LOG = LoggerFactory.getLogger(ScheduleJobServiceImp.class);
@Override
public void initScheduleJob() {
//查找启用的任务
ScheduleJob aj=new ScheduleJob();
aj.setStatus(1);
List<com.moyou.moyouRms.model.po.task.base.ScheduleJob> scheduleJobList = baseDao.find(aj);
if (scheduleJobList !=null && scheduleJobList.size() > 0) {
for (ScheduleJob scheduleJob : scheduleJobList) {
CronTrigger cronTrigger = ScheduleManager.getCronTrigger(scheduler, scheduleJob.getJobName(),scheduleJob.getJobGroup());
try {
TaskSeting ts = taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
if (ts != null && ts.getIntervalSecond() != null) {
int intervalSecond = ts.getIntervalSecond();
// /10 * * * * ?
String cronExpression=null;
if(ts.getModeType()==ScheduleJob.TALK_MODE_DAY||ts.getModeType()==ScheduleJob.TALK_MODE_NIGHT){
cronExpression = CronExpressionUtil.getCronExpressionBySecondForTalk(intervalSecond,ts.getModeType());
}else{
cronExpression = CronExpressionUtil.getCronExpressionBySecond(intervalSecond);
}
scheduleJob.setCronExpression(cronExpression);
}
scheduleJob.setExtend(ts);
LOG.info(scheduleJob.getJobClass()+"【初始化成功】");
if (cronTrigger == null) {
// 不存在,创建一个
ScheduleManager.createScheduleJob(scheduler, scheduleJob);
} else {
// 已存在,那么更新相应的定时设置
ScheduleManager.updateScheduleJob(scheduler, scheduleJob);
}
} catch (Exception e) {
logger.error("创建定时任务失败",e);
}
}
}
}
@Override
@Transactional
public int createScheduleJob(ScheduleJob o) {
int res=0;
try {
o.setCreateTime(new Date());
//当状态为启用时
if(o.getStatus()!=null && o.getStatus()==1){
ScheduleManager.createScheduleJob(scheduler,o);
}
//更新数据库
super.insert(o);
res=1;
} catch (Exception e) {
logger.error("创建任务失败",e);
}
return res;
}
@Override
@Transactional
public int updateScheduleJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
//先删除
ScheduleManager.deleteScheduleJob(scheduler,scheduleJob.getJobName(),scheduleJob.getJobGroup());
//当状态为启用时
if(o.getStatus()!=null && o.getStatus()==1){
ScheduleManager.createScheduleJob(scheduler, o);
}
//更新数据库
o.setUpdateTime(new Date());
dao.update(o);
res=1;
} catch (Exception e) {
logger.error("创建任务失败",e);
}
return res;
}
@Override
@Transactional
public int deleteScheduleJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
//先删除
ScheduleManager.deleteScheduleJob(scheduler, scheduleJob.getJobName(),scheduleJob.getJobGroup());
//更新数据库
dao.delete(o);
res=1;
}catch (Exception e) {
logger.error("删除任务失败", e);
}
return res;
}
@Override
@Transactional
public int runOnce(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==1){
//运行一次任务
ScheduleManager.runOnce(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
res=2;
}else{
//当任务没启动,必须先创建
ScheduleManager.createScheduleJob(scheduler, scheduleJob);
//时间短可能促发多次
//ScheduleUtils.pauseJob(scheduler,scheduleJob.getJobName(), scheduleJob.getJobGroup());
//然后立刻运行一次任务
ScheduleManager.runOnce(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
try {
//休眠3秒,等任务完成,完成不了就加长休眠时间吧...
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//再删除任务
ScheduleManager.deleteScheduleJob(scheduler,scheduleJob.getJobName(), scheduleJob.getJobGroup());
res=1;
}
} catch (Exception e) {
logger.error("运行一次定时任务失败", e);
}
return res;
}
@Override
@Transactional
public int pauseJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==1){
//判断jobKey为不为空,如为空,任务已停止
//先暂停任务
//ScheduleUtils.pauseJob(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
ScheduleManager.deleteScheduleJob(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
//更新数据库
scheduleJob.setStatus(0);
scheduleJob.setUpdateTime(new Date());
// logger.info(JsonUtil.toJson(scheduleJob));
dao.update(scheduleJob);
res=1;
}else{
//任务没启动,谈何暂停...
res=2;
}
} catch (Exception e) {
logger.error("暂停定时任务失败", e);
}
return res;
}
@Override
@Transactional
public int resumeJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==0){
TaskSeting ts = taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
if (ts != null && ts.getIntervalSecond() != null) {
int intervalSecond = ts.getIntervalSecond();
// /10 * * * * ?
String cronExpression=null;
if(ts.getModeType()==ScheduleJob.TALK_MODE_DAY||ts.getModeType()==ScheduleJob.TALK_MODE_NIGHT){
cronExpression = CronExpressionUtil.getCronExpressionBySecondForTalk(intervalSecond,ts.getModeType());
}else{
cronExpression = CronExpressionUtil.getCronExpressionBySecond(intervalSecond);
}
scheduleJob.setCronExpression(cronExpression);
}
scheduleJob.setExtend(ts);
LOG.info(scheduleJob.getJobClass()+"【初始化成功】");
logger.info("【重启定时任务】"+JsonUtil.toJson(scheduleJob));
Msg msg=ScheduleManager.createScheduleJob(scheduler, scheduleJob);
if(!msg.isSuccess()){
logger.error("恢复定时任务失败");
return RESPONSE.ERROR;
}
//更新数据库
scheduleJob.setStatus(1);
scheduleJob.setUpdateTime(new Date());
dao.update(scheduleJob);
res=1;
}else{
res=2;
}
} catch (Exception e) {
e.printStackTrace();
logger.error("恢复定时任务失败", e);
}
return res;
}
@Override
public int updateStartOrStop(ScheduleJob record) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean check(String str) {
// TODO Auto-generated method stub
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
ScheduleJob scheduleJob=dao.getScheduleJobByName(str);
// TaskSeting taskSeting= taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
// Integer intervalSecond = taskSeting.getIntervalSecond();
// Long time=Long.valueOf(System.currentTimeMillis()+"")-(intervalSecond*1000);//上一次运行的时间
// Map<String, Object> map= new HashMap<String,Object>();
// map.put("time",new Date(time));
// map.put("name", scheduleJob.getJobClass());
// List<TaskLog> list=taskLogService.queryNeerTaskLog(map);
try {
JobKey jobKey = new JobKey(scheduleJob.getJobName(),scheduleJob.getJobGroup());
// JobDetail jb = scheduler.getJobDetail(jobKey);
// System.out.println("==============:"+scheduler.checkExists(jobKey));
if(!scheduler.checkExists(jobKey)){
return false;
}else{
return true;
}
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
}
| UTF-8 | Java | 9,610 | java | ScheduleJobServiceImp.java | Java | [] | null | [] | package com.moyou.moyouRms.service.task.impl;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.quartz.CronTrigger;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.moyou.moyouRms.constants.RESPONSE;
import com.moyou.moyouRms.dao.task.base.ScheduleJobDao;
import com.moyou.moyouRms.manager.schedule.ScheduleManager;
import com.moyou.moyouRms.model.po.task.TaskSeting;
import com.moyou.moyouRms.model.po.task.base.ScheduleJob;
import com.moyou.moyouRms.response.Msg;
import com.moyou.moyouRms.service.BaseServiceImp;
import com.moyou.moyouRms.service.task.ScheduleJobService;
import com.moyou.moyouRms.service.task.TaskLogService;
import com.moyou.moyouRms.service.task.TaskSetingService;
import com.moyou.moyouRms.util.JsonUtil;
import com.moyou.moyouRms.util.schedule.CronExpressionUtil;
@Service("scheduleJobService")
public class ScheduleJobServiceImp extends BaseServiceImp<ScheduleJob> implements ScheduleJobService {
/** 调度工厂Bean */
@Autowired
private Scheduler scheduler;
@Autowired
private TaskSetingService taskSetingService;
@Resource
TaskLogService taskLogService;
/** 日志对象 */
private static final Logger LOG = LoggerFactory.getLogger(ScheduleJobServiceImp.class);
@Override
public void initScheduleJob() {
//查找启用的任务
ScheduleJob aj=new ScheduleJob();
aj.setStatus(1);
List<com.moyou.moyouRms.model.po.task.base.ScheduleJob> scheduleJobList = baseDao.find(aj);
if (scheduleJobList !=null && scheduleJobList.size() > 0) {
for (ScheduleJob scheduleJob : scheduleJobList) {
CronTrigger cronTrigger = ScheduleManager.getCronTrigger(scheduler, scheduleJob.getJobName(),scheduleJob.getJobGroup());
try {
TaskSeting ts = taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
if (ts != null && ts.getIntervalSecond() != null) {
int intervalSecond = ts.getIntervalSecond();
// /10 * * * * ?
String cronExpression=null;
if(ts.getModeType()==ScheduleJob.TALK_MODE_DAY||ts.getModeType()==ScheduleJob.TALK_MODE_NIGHT){
cronExpression = CronExpressionUtil.getCronExpressionBySecondForTalk(intervalSecond,ts.getModeType());
}else{
cronExpression = CronExpressionUtil.getCronExpressionBySecond(intervalSecond);
}
scheduleJob.setCronExpression(cronExpression);
}
scheduleJob.setExtend(ts);
LOG.info(scheduleJob.getJobClass()+"【初始化成功】");
if (cronTrigger == null) {
// 不存在,创建一个
ScheduleManager.createScheduleJob(scheduler, scheduleJob);
} else {
// 已存在,那么更新相应的定时设置
ScheduleManager.updateScheduleJob(scheduler, scheduleJob);
}
} catch (Exception e) {
logger.error("创建定时任务失败",e);
}
}
}
}
@Override
@Transactional
public int createScheduleJob(ScheduleJob o) {
int res=0;
try {
o.setCreateTime(new Date());
//当状态为启用时
if(o.getStatus()!=null && o.getStatus()==1){
ScheduleManager.createScheduleJob(scheduler,o);
}
//更新数据库
super.insert(o);
res=1;
} catch (Exception e) {
logger.error("创建任务失败",e);
}
return res;
}
@Override
@Transactional
public int updateScheduleJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
//先删除
ScheduleManager.deleteScheduleJob(scheduler,scheduleJob.getJobName(),scheduleJob.getJobGroup());
//当状态为启用时
if(o.getStatus()!=null && o.getStatus()==1){
ScheduleManager.createScheduleJob(scheduler, o);
}
//更新数据库
o.setUpdateTime(new Date());
dao.update(o);
res=1;
} catch (Exception e) {
logger.error("创建任务失败",e);
}
return res;
}
@Override
@Transactional
public int deleteScheduleJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
//先删除
ScheduleManager.deleteScheduleJob(scheduler, scheduleJob.getJobName(),scheduleJob.getJobGroup());
//更新数据库
dao.delete(o);
res=1;
}catch (Exception e) {
logger.error("删除任务失败", e);
}
return res;
}
@Override
@Transactional
public int runOnce(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==1){
//运行一次任务
ScheduleManager.runOnce(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
res=2;
}else{
//当任务没启动,必须先创建
ScheduleManager.createScheduleJob(scheduler, scheduleJob);
//时间短可能促发多次
//ScheduleUtils.pauseJob(scheduler,scheduleJob.getJobName(), scheduleJob.getJobGroup());
//然后立刻运行一次任务
ScheduleManager.runOnce(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
try {
//休眠3秒,等任务完成,完成不了就加长休眠时间吧...
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//再删除任务
ScheduleManager.deleteScheduleJob(scheduler,scheduleJob.getJobName(), scheduleJob.getJobGroup());
res=1;
}
} catch (Exception e) {
logger.error("运行一次定时任务失败", e);
}
return res;
}
@Override
@Transactional
public int pauseJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==1){
//判断jobKey为不为空,如为空,任务已停止
//先暂停任务
//ScheduleUtils.pauseJob(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
ScheduleManager.deleteScheduleJob(scheduler, scheduleJob.getJobName(), scheduleJob.getJobGroup());
//更新数据库
scheduleJob.setStatus(0);
scheduleJob.setUpdateTime(new Date());
// logger.info(JsonUtil.toJson(scheduleJob));
dao.update(scheduleJob);
res=1;
}else{
//任务没启动,谈何暂停...
res=2;
}
} catch (Exception e) {
logger.error("暂停定时任务失败", e);
}
return res;
}
@Override
@Transactional
public int resumeJob(ScheduleJob o) {
int res=0;
try {
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
//从数据库查找原信息
ScheduleJob scheduleJob=dao.getScheduleJobById(o.getScheduleJobId());
if(scheduleJob.getStatus()!=null && scheduleJob.getStatus()==0){
TaskSeting ts = taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
if (ts != null && ts.getIntervalSecond() != null) {
int intervalSecond = ts.getIntervalSecond();
// /10 * * * * ?
String cronExpression=null;
if(ts.getModeType()==ScheduleJob.TALK_MODE_DAY||ts.getModeType()==ScheduleJob.TALK_MODE_NIGHT){
cronExpression = CronExpressionUtil.getCronExpressionBySecondForTalk(intervalSecond,ts.getModeType());
}else{
cronExpression = CronExpressionUtil.getCronExpressionBySecond(intervalSecond);
}
scheduleJob.setCronExpression(cronExpression);
}
scheduleJob.setExtend(ts);
LOG.info(scheduleJob.getJobClass()+"【初始化成功】");
logger.info("【重启定时任务】"+JsonUtil.toJson(scheduleJob));
Msg msg=ScheduleManager.createScheduleJob(scheduler, scheduleJob);
if(!msg.isSuccess()){
logger.error("恢复定时任务失败");
return RESPONSE.ERROR;
}
//更新数据库
scheduleJob.setStatus(1);
scheduleJob.setUpdateTime(new Date());
dao.update(scheduleJob);
res=1;
}else{
res=2;
}
} catch (Exception e) {
e.printStackTrace();
logger.error("恢复定时任务失败", e);
}
return res;
}
@Override
public int updateStartOrStop(ScheduleJob record) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean check(String str) {
// TODO Auto-generated method stub
ScheduleJobDao dao=(ScheduleJobDao)baseDao;
ScheduleJob scheduleJob=dao.getScheduleJobByName(str);
// TaskSeting taskSeting= taskSetingService.selectByScheduleId(scheduleJob.getScheduleJobId());
// Integer intervalSecond = taskSeting.getIntervalSecond();
// Long time=Long.valueOf(System.currentTimeMillis()+"")-(intervalSecond*1000);//上一次运行的时间
// Map<String, Object> map= new HashMap<String,Object>();
// map.put("time",new Date(time));
// map.put("name", scheduleJob.getJobClass());
// List<TaskLog> list=taskLogService.queryNeerTaskLog(map);
try {
JobKey jobKey = new JobKey(scheduleJob.getJobName(),scheduleJob.getJobGroup());
// JobDetail jb = scheduler.getJobDetail(jobKey);
// System.out.println("==============:"+scheduler.checkExists(jobKey));
if(!scheduler.checkExists(jobKey)){
return false;
}else{
return true;
}
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
}
}
| 9,610 | 0.716496 | 0.712044 | 284 | 30.633802 | 27.491095 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.228873 | false | false | 10 |
718c38624573e19db8d8c717bfc9bf3f0b765c0c | 1,632,087,609,597 | aa1a8961ceb9c5a366b2efa776d029a4631a0b64 | /src/com/huidian/day4/demo06/Demo03Interface.java | 4106cb4434289826002585af9e5af352345c4968 | [] | no_license | lingweiov/java1 | https://github.com/lingweiov/java1 | 7e62305808be7a5ae0b6700217b30a4f9508feb8 | 5800955cd297215e5e17055c440b919df9be6a3f | refs/heads/master | 2020-09-13T18:38:59.453000 | 2019-12-09T13:15:36 | 2019-12-09T13:15:37 | 222,870,718 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.huidian.day4.demo06;/*
@outhor shkstart
@date 2019/11/23-16:17
*/
public class Demo03Interface {
public static void main(String[] args) {
// MyInterfaceStaticImpl impl=new MyInterfaceStaticImpl();
// impl.methodStatic();//错误写法,
// 不能通过接口实现类的对象来调用接口当中的静态方法
MyInterfaceStatic.methodStatic();
//正确调用接口当中的静态方法的用法
}
}
| UTF-8 | Java | 467 | java | Demo03Interface.java | Java | [
{
"context": "package com.huidian.day4.demo06;/*\n@outhor shkstart\n@date 2019/11/23-16:17\n*/\n\n\n\n\npublic class Demo03",
"end": 51,
"score": 0.9996201992034912,
"start": 43,
"tag": "USERNAME",
"value": "shkstart"
}
] | null | [] | package com.huidian.day4.demo06;/*
@outhor shkstart
@date 2019/11/23-16:17
*/
public class Demo03Interface {
public static void main(String[] args) {
// MyInterfaceStaticImpl impl=new MyInterfaceStaticImpl();
// impl.methodStatic();//错误写法,
// 不能通过接口实现类的对象来调用接口当中的静态方法
MyInterfaceStatic.methodStatic();
//正确调用接口当中的静态方法的用法
}
}
| 467 | 0.665783 | 0.62069 | 17 | 21.17647 | 19.479206 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.235294 | false | false | 10 |
a6ae49163a697e760ae23701bb73a2d4cf251c30 | 11,587,821,791,225 | b063b1d80c6b95b2962dff6301f59f37170faabc | /src/main/java/pages/HomePage.java | 1be8440688ae84a7c294fe84d48bad0e0f875779 | [] | no_license | dhrabia/SantanderTask1 | https://github.com/dhrabia/SantanderTask1 | 17835b585c453d64bdc7c80bea404693c0cf5789 | 36acdfe03d6a61cc85c5be7c54c9961957bde2b2 | refs/heads/master | 2023-02-11T08:11:21.418000 | 2021-01-07T18:17:34 | 2021-01-07T18:17:34 | 303,540,494 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pages;
import base.Page;
import data.Product;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class HomePage extends Page {
public HomePage(WebDriver driver) {
super(driver);
}
@FindBy(linkText = "Sign in")
private WebElement signInButton;
@FindBy(css = ".product-container")
private List<WebElement> listOfProducts;
@FindBy(css = ".product-container .product-name")
private List<WebElement> productNameList;
@FindBy(css = ".product-container > .right-block .price")
private List<WebElement> productPriceList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Quick view']")
private List<WebElement> quickViewProductList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Add to cart']")
private List<WebElement> addToCartButtonList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Add to cart']")
private List<WebElement> productMoreButtonList;
public AuthenticationPage clickOnSignInButton() {
signInButton.click();
return new AuthenticationPage(driver);
}
public QuickViewPage addItemToCart(int whichProduct) {
Product product = new Product();
product.setProductName(productNameList.get(whichProduct).getText());
product.setProductPrice(Double.parseDouble(productPriceList.get(whichProduct).getText().substring(1)));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", addToCartButtonList.get(whichProduct));
return new QuickViewPage(driver);
}
public ProductPage goToProduct(int whichProduct) {
Product product = new Product();
product.setProductName(productNameList.get(whichProduct).getText());
product.setProductPrice(Double.parseDouble(productPriceList.get(whichProduct).getText().substring(1)));
listOfProducts.get(whichProduct).click();
return new ProductPage(driver);
}
}
| UTF-8 | Java | 2,143 | java | HomePage.java | Java | [] | null | [] | package pages;
import base.Page;
import data.Product;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class HomePage extends Page {
public HomePage(WebDriver driver) {
super(driver);
}
@FindBy(linkText = "Sign in")
private WebElement signInButton;
@FindBy(css = ".product-container")
private List<WebElement> listOfProducts;
@FindBy(css = ".product-container .product-name")
private List<WebElement> productNameList;
@FindBy(css = ".product-container > .right-block .price")
private List<WebElement> productPriceList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Quick view']")
private List<WebElement> quickViewProductList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Add to cart']")
private List<WebElement> addToCartButtonList;
@FindBy(xpath = "//div[@class='product-container']//span[.='Add to cart']")
private List<WebElement> productMoreButtonList;
public AuthenticationPage clickOnSignInButton() {
signInButton.click();
return new AuthenticationPage(driver);
}
public QuickViewPage addItemToCart(int whichProduct) {
Product product = new Product();
product.setProductName(productNameList.get(whichProduct).getText());
product.setProductPrice(Double.parseDouble(productPriceList.get(whichProduct).getText().substring(1)));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", addToCartButtonList.get(whichProduct));
return new QuickViewPage(driver);
}
public ProductPage goToProduct(int whichProduct) {
Product product = new Product();
product.setProductName(productNameList.get(whichProduct).getText());
product.setProductPrice(Double.parseDouble(productPriceList.get(whichProduct).getText().substring(1)));
listOfProducts.get(whichProduct).click();
return new ProductPage(driver);
}
}
| 2,143 | 0.712552 | 0.711153 | 62 | 33.564518 | 29.681438 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
7e291365461fe321d4ab00e7f1485849907ba009 | 35,253,091,565,937 | 3c37569a14dbe71b1960ccc9aafbdf957cb906e0 | /Loterias/src/main/java/bae/baesso/dao/LoteriaDAO.java | 660bb27e2deccd1e738cd9e9eb72942cfafc7a4e | [] | no_license | victorbae/loterias | https://github.com/victorbae/loterias | dbdcba097f6b8bf56530d68058940ce7127f7eea | 41d77f7d5fa30ae3a6c67b04c0e8854729ea00fe | refs/heads/master | 2020-05-01T13:05:46.618000 | 2019-04-08T13:19:30 | 2019-04-08T13:19:30 | 177,481,455 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package bae.baesso.dao;
import com.mongodb.client.MongoCollection;
import bae.baesso.model.Loteria;
public interface LoteriaDAO extends CrudDAO<Loteria> {
MongoCollection<Loteria> getCollection();
}
| UTF-8 | Java | 214 | java | LoteriaDAO.java | Java | [] | null | [] | package bae.baesso.dao;
import com.mongodb.client.MongoCollection;
import bae.baesso.model.Loteria;
public interface LoteriaDAO extends CrudDAO<Loteria> {
MongoCollection<Loteria> getCollection();
}
| 214 | 0.766355 | 0.766355 | 10 | 19.4 | 20.577658 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
2fc2dcc8281fe776234613fdaf63b1e389e9ff63 | 19,894,288,551,547 | d80bca3870367c00206ff9fb874b3d81a962b0c1 | /Carrier/PushServer/pushserver/src/main/java/com/elastos/carrier/push/server/data/dao/mapper/TagMapper.java | 8070b1f39ceaf753d7f8d21507843d19cd865283 | [
"Apache-2.0"
] | permissive | elastos/Tapestry | https://github.com/elastos/Tapestry | 194e8239a159417ecb4dd97ced38595928ea550f | 994ad748a3d2301b22b529f0cab269b0a674733d | refs/heads/master | 2017-07-03T00:01:12.463000 | 2016-05-17T11:32:44 | 2016-05-17T11:32:44 | 48,774,597 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright (C) 2015 Elastos.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.elastos.carrier.push.server.data.dao.mapper;
import com.elastos.carrier.push.core.po.Tag;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* User:Lu.Tao
* Date:2015/9/18
*/
public interface TagMapper {
boolean deleteTagById(@Param("id") Integer id);
boolean addTag(Tag tag);
List<Tag> getTagsByAppId(@Param("appId") Integer appId);
Tag getTagByNameAndAppId(@Param("appId") Integer appId,@Param("tagName")String name);
} | UTF-8 | Java | 1,086 | java | TagMapper.java | Java | [
{
"context": ".Param;\r\n\r\nimport java.util.List;\r\n\r\n/**\r\n * User:Lu.Tao\r\n * Date:2015/9/18\r\n */\r\npublic interface TagMapp",
"end": 785,
"score": 0.965591549873352,
"start": 779,
"tag": "NAME",
"value": "Lu.Tao"
}
] | null | [] | /*
* Copyright (C) 2015 Elastos.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.elastos.carrier.push.server.data.dao.mapper;
import com.elastos.carrier.push.core.po.Tag;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* User:Lu.Tao
* Date:2015/9/18
*/
public interface TagMapper {
boolean deleteTagById(@Param("id") Integer id);
boolean addTag(Tag tag);
List<Tag> getTagsByAppId(@Param("appId") Integer appId);
Tag getTagByNameAndAppId(@Param("appId") Integer appId,@Param("tagName")String name);
} | 1,086 | 0.724678 | 0.710866 | 37 | 27.837837 | 28.061239 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.378378 | false | false | 10 |
7ecb3e4962df9c32ea894af63ab7863359a2082d | 19,894,288,553,015 | eeb141e6d2500e64c081f6c4efaa28f4141f7a97 | /andro1/app/src/main/java/com/example/taseen/andro1/MainActivity.java | 85b383f301c5272d9cbf0ac2c2793cd9c2b6c756 | [] | no_license | ahmedakter05/AndroidStudioProjects | https://github.com/ahmedakter05/AndroidStudioProjects | 396947cf73795211566b322df17d2ad871052042 | 18e9ce17a1c706567b12d267bbbaddaffb5183b8 | refs/heads/master | 2020-04-30T09:52:53.861000 | 2019-03-28T17:56:00 | 2019-03-28T17:56:00 | 176,760,753 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.taseen.andro1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.aa_button);
final TextView txtView = (TextView) findViewById(R.id.aa_textView);
String btnValue = button.getText().toString();
System.out.println(btnValue);
final String txtValue = txtView.getText().toString();
System.out.println(txtValue);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText simpleEditText = (EditText) findViewById(R.id.aa_editText);
final String strValue = simpleEditText.getText().toString();
System.out.println(strValue);
txtView.setText("Hello "+strValue+"\nThis is my First App");
}
});
final TextView txtViewsum = (TextView) findViewById(R.id.textView_sum);
//final String txtValuesum = txtViewsum.getText().toString();
Button button2 = (Button) findViewById(R.id.button_sum);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TextView txtEditn1 = (TextView) findViewById(R.id.editText_num1);
String txtValuen1 = txtEditn1.getText().toString();
int txtEditn11 = Integer.parseInt(txtValuen1);
System.out.println(txtEditn11);
TextView txtEditn2 = (TextView) findViewById(R.id.editText_num2);
String txtValuen2 = txtEditn2.getText().toString();
int txtEditn22 = Integer.parseInt(txtValuen2);
System.out.println(txtEditn22);
int sum = txtEditn11 + txtEditn22;
System.out.println("Sum: " + sum);
System.out.println(sum);
txtViewsum.setText("Hello, The Sum is: "+sum+"\nThank You");
}
});
}
}
| UTF-8 | Java | 2,308 | java | MainActivity.java | Java | [] | null | [] | package com.example.taseen.andro1;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.aa_button);
final TextView txtView = (TextView) findViewById(R.id.aa_textView);
String btnValue = button.getText().toString();
System.out.println(btnValue);
final String txtValue = txtView.getText().toString();
System.out.println(txtValue);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText simpleEditText = (EditText) findViewById(R.id.aa_editText);
final String strValue = simpleEditText.getText().toString();
System.out.println(strValue);
txtView.setText("Hello "+strValue+"\nThis is my First App");
}
});
final TextView txtViewsum = (TextView) findViewById(R.id.textView_sum);
//final String txtValuesum = txtViewsum.getText().toString();
Button button2 = (Button) findViewById(R.id.button_sum);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TextView txtEditn1 = (TextView) findViewById(R.id.editText_num1);
String txtValuen1 = txtEditn1.getText().toString();
int txtEditn11 = Integer.parseInt(txtValuen1);
System.out.println(txtEditn11);
TextView txtEditn2 = (TextView) findViewById(R.id.editText_num2);
String txtValuen2 = txtEditn2.getText().toString();
int txtEditn22 = Integer.parseInt(txtValuen2);
System.out.println(txtEditn22);
int sum = txtEditn11 + txtEditn22;
System.out.println("Sum: " + sum);
System.out.println(sum);
txtViewsum.setText("Hello, The Sum is: "+sum+"\nThank You");
}
});
}
}
| 2,308 | 0.62825 | 0.616984 | 62 | 36.225807 | 28.219427 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.596774 | false | false | 10 |
86b41534b6b7b21d346f5e0a452ad6db65341654 | 29,875,792,526,184 | 2df6fdeeae99d7e2299a605e0bb10866e3c40c8e | /src/main/java/com/example/java/javademo/dubbo/spi/ADubboService.java | 617a71ee02f68c6774948b278a2251ebf53ef517 | [] | no_license | songyalong/java-demo | https://github.com/songyalong/java-demo | 3146f0f2b5795b3b6843c57c6fa8be9ea19f6bc4 | 7260b3e582a33d33f89093a1a4f2a2b2dbf5b667 | refs/heads/master | 2022-07-04T23:52:00.213000 | 2019-07-12T06:08:36 | 2019-07-12T06:08:36 | 173,297,322 | 0 | 1 | null | false | 2020-07-01T18:45:33 | 2019-03-01T12:20:03 | 2019-07-12T06:09:03 | 2020-07-01T18:45:32 | 140 | 0 | 1 | 1 | Java | false | false | package com.example.java.javademo.dubbo.spi;
/**
* @Author: songyalong
* @Description:
* @Date: Created in ${time}${date}
* @Modified By:
*/
public class ADubboService implements DubboService {
@Override
public void sayHi() {
System.out.println("ADubboService");
}
}
| UTF-8 | Java | 293 | java | ADubboService.java | Java | [
{
"context": ".example.java.javademo.dubbo.spi;\n\n/**\n * @Author: songyalong\n * @Description:\n * @Date: Created in ${time}${da",
"end": 72,
"score": 0.9995994567871094,
"start": 62,
"tag": "USERNAME",
"value": "songyalong"
}
] | null | [] | package com.example.java.javademo.dubbo.spi;
/**
* @Author: songyalong
* @Description:
* @Date: Created in ${time}${date}
* @Modified By:
*/
public class ADubboService implements DubboService {
@Override
public void sayHi() {
System.out.println("ADubboService");
}
}
| 293 | 0.658703 | 0.658703 | 14 | 19.928572 | 17.060665 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | false | false | 10 |
55961cdd5a27784e4cf39150e384cacd6edc01fd | 6,330,781,842,233 | bcd4674ef3bef906220f4a246961e9749e6d0818 | /app/src/main/java/com/example/parksapp/adapter/OnParkClickListener.java | 70aba515bfe0d5d51048a6a18ab4caaddb16db52 | [] | no_license | ismatjafarli/ParkGuideApp | https://github.com/ismatjafarli/ParkGuideApp | fb41df9360def155bc5106ea5f793f2fa7013cb6 | dd6ff06ae87d4397a752d0392bf220cb992469e3 | refs/heads/main | 2023-04-18T05:51:00.484000 | 2021-04-27T06:07:42 | 2021-04-27T06:07:42 | 361,493,124 | 0 | 0 | null | false | 2021-04-27T06:07:43 | 2021-04-25T17:25:23 | 2021-04-26T20:34:53 | 2021-04-27T06:07:42 | 291 | 0 | 0 | 0 | Java | false | false | package com.example.parksapp.adapter;
import com.example.parksapp.model.Data;
public interface OnParkClickListener {
void onParkClicked (Data data);
}
| UTF-8 | Java | 157 | java | OnParkClickListener.java | Java | [] | null | [] | package com.example.parksapp.adapter;
import com.example.parksapp.model.Data;
public interface OnParkClickListener {
void onParkClicked (Data data);
}
| 157 | 0.789809 | 0.789809 | 7 | 21.428572 | 18.305792 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 10 |
0dd113b2d30bab122484601cc02a79b81adf9a7d | 12,214,887,055,873 | 276f13ea692eae515d44ee5c129d5787c2f9f67c | /Plugin/ScoreEditor/ScoreEditor/src/sample/model/business/ThreadedPlayer.java | 0b1e7c2bfae5c1ac6b14ac616d1aa7048996de09 | [] | no_license | Thomas0Po/FinalProject | https://github.com/Thomas0Po/FinalProject | 61f15835d6cb82a564dc506a6b8979cb48d0cbb7 | 8bb29fc54faf1a2fe22a5786a60505270be848a3 | refs/heads/master | 2021-01-10T00:54:45.926000 | 2015-03-03T12:33:48 | 2015-03-03T12:33:48 | 31,597,609 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package sample.model.business;
import org.jfugue.Pattern;
import org.jfugue.Player;
/**
* Created by favre on 16/10/2014.
*/
public class ThreadedPlayer extends Thread{
Player player = new Player();
Pattern pattern;
@Override
public void run() {
player.play(pattern);
}
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public Pattern getPattern() {
return pattern;
}
public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
}
| UTF-8 | Java | 600 | java | ThreadedPlayer.java | Java | [
{
"context": "ern;\nimport org.jfugue.Player;\n\n\n/**\n * Created by favre on 16/10/2014.\n */\npublic class ThreadedPlayer ex",
"end": 110,
"score": 0.999503493309021,
"start": 105,
"tag": "USERNAME",
"value": "favre"
}
] | null | [] | package sample.model.business;
import org.jfugue.Pattern;
import org.jfugue.Player;
/**
* Created by favre on 16/10/2014.
*/
public class ThreadedPlayer extends Thread{
Player player = new Player();
Pattern pattern;
@Override
public void run() {
player.play(pattern);
}
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public Pattern getPattern() {
return pattern;
}
public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
}
| 600 | 0.62 | 0.606667 | 35 | 16.142857 | 15.098047 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 10 |
ab3dbd8d5801ba91ae458454601e285417506ebf | 21,242,908,282,669 | 108873952d96fa2e39a0b0d2e3ab9e0e9b2ed84b | /ReflectyIO/src/main/java/com/heaven7/java/reflectyio/anno/ReflectyClass.java | ccea188cb3f30cc55dbef1c4e7d77c5fea23fa31 | [
"Apache-2.0"
] | permissive | LightSun/ReflectyIO | https://github.com/LightSun/ReflectyIO | 66ee7c81beeea8389b7c900975407a4d7bcbbbe8 | 3afdcde593efaf8c29a640c541860059635434e3 | refs/heads/master | 2021-06-13T01:11:40.715000 | 2021-04-29T01:41:43 | 2021-04-29T01:41:43 | 185,149,976 | 7 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2019
* heaven7(donshine723@gmail.com)
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heaven7.java.reflectyio.anno;
import com.heaven7.java.reflecty.iota.TypeAdapter;
import java.lang.annotation.*;
/**
* apply on the class
* @author heaven7
* @see com.heaven7.java.reflecty.ReflectyDelegate#performReflectClass(Class) .
*/
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReflectyClass {
/**
* indicate the type adapter used to read and write data.
* @return the child class of {@linkplain TypeAdapter}.
*/
Class<? extends TypeAdapter> value();
}
| UTF-8 | Java | 1,158 | java | ReflectyClass.java | Java | [
{
"context": "/*\n * Copyright 2019\n * heaven7(donshine723@gmail.com)\n\n * Licensed under the Apa",
"end": 31,
"score": 0.9996801018714905,
"start": 24,
"tag": "USERNAME",
"value": "heaven7"
},
{
"context": "/*\n * Copyright 2019\n * heaven7(donshine723@gmail.com)\n\n * Licensed un... | null | [] | /*
* Copyright 2019
* heaven7(<EMAIL>)
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heaven7.java.reflectyio.anno;
import com.heaven7.java.reflecty.iota.TypeAdapter;
import java.lang.annotation.*;
/**
* apply on the class
* @author heaven7
* @see com.heaven7.java.reflecty.ReflectyDelegate#performReflectClass(Class) .
*/
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReflectyClass {
/**
* indicate the type adapter used to read and write data.
* @return the child class of {@linkplain TypeAdapter}.
*/
Class<? extends TypeAdapter> value();
}
| 1,144 | 0.736615 | 0.722798 | 38 | 29.473684 | 26.311632 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.236842 | false | false | 10 |
64dbff32b12d4a4370f1835f3f122e454d4c9807 | 20,873,541,078,777 | f005b789216d8b3833fb2da3e306b4d7c8ca08f2 | /gopath-mgmt/src/main/java/com/todaysoft/ghealth/service/IAgencyService.java | 9a60dc37acb14682d36791dcb61c3230a9db64ca | [] | no_license | John930312/gopath | https://github.com/John930312/gopath | fa1570274b4d41efa2e0ccef0c620565ccbe6b37 | 0a73c7bdd011c5b7376d1db665dcb6166db62e1f | refs/heads/master | 2022-06-27T21:08:02.693000 | 2019-09-02T06:31:06 | 2019-09-02T06:31:06 | 205,792,654 | 0 | 0 | null | false | 2022-06-17T02:28:28 | 2019-09-02T06:40:19 | 2019-09-02T06:41:12 | 2022-06-17T02:28:25 | 11,307 | 0 | 0 | 4 | Java | false | false | package com.todaysoft.ghealth.service;
import com.todaysoft.ghealth.model.Agency;
import com.todaysoft.ghealth.model.searcher.AgencySearcher;
import com.todaysoft.ghealth.support.Pager;
/**
* @Author: zyf
* @Date: 2018/10/17 9:32
*/
public interface IAgencyService {
Pager<Agency> pager(AgencySearcher searcher, int pageNo, int pageSize);
Agency get(String id);
void create(Agency data);
void modify(Agency data);
void delete(Agency data);
boolean isCodeUnique(String code, String id);
}
| UTF-8 | Java | 524 | java | IAgencyService.java | Java | [
{
"context": ".todaysoft.ghealth.support.Pager;\n\n/**\n * @Author: zyf\n * @Date: 2018/10/17 9:32\n */\n\npublic interface I",
"end": 207,
"score": 0.9996957778930664,
"start": 204,
"tag": "USERNAME",
"value": "zyf"
}
] | null | [] | package com.todaysoft.ghealth.service;
import com.todaysoft.ghealth.model.Agency;
import com.todaysoft.ghealth.model.searcher.AgencySearcher;
import com.todaysoft.ghealth.support.Pager;
/**
* @Author: zyf
* @Date: 2018/10/17 9:32
*/
public interface IAgencyService {
Pager<Agency> pager(AgencySearcher searcher, int pageNo, int pageSize);
Agency get(String id);
void create(Agency data);
void modify(Agency data);
void delete(Agency data);
boolean isCodeUnique(String code, String id);
}
| 524 | 0.730916 | 0.709924 | 25 | 19.959999 | 21.689592 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52 | false | false | 10 |
2dd0d14b7db6b2ff925cec40f195535c7faa87b4 | 21,818,433,916,567 | 519325b3ddc711cc80e94f3ea8e41e6e4141bf6a | /app/src/main/java/app/whatsdone/android/services/ServiceListener.java | 1e436ad626948d1e36adf2a031c44de6f1cc6e17 | [] | no_license | sriThariduSangeeth/TestAndroid | https://github.com/sriThariduSangeeth/TestAndroid | bc7e258b354a2985cf378172c32bc1b14900f5ec | eb95e05bd121d7365d63bf5c48641b05c82ad805 | refs/heads/master | 2021-01-01T03:13:27.192000 | 2020-03-27T17:01:08 | 2020-03-27T17:01:08 | 239,154,540 | 0 | 0 | null | false | 2020-03-27T17:01:09 | 2020-02-08T15:28:35 | 2020-03-27T16:46:17 | 2020-03-27T17:01:09 | 4,851 | 0 | 0 | 1 | Java | false | false | package app.whatsdone.android.services;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import app.whatsdone.android.model.BaseEntity;
import app.whatsdone.android.model.Message;
import timber.log.Timber;
public interface ServiceListener {
default void onDataReceivedForMessage(ArrayList<Message> messages){
}
default void onDataReceived(List<BaseEntity> entities) {
}
default void onCompleted(boolean isSuccessful) {
}
default void onSuccess() {
}
default void onError(@Nullable String error){
Timber.e(error);
}
default void onDataReceived(BaseEntity entity){
}
}
| UTF-8 | Java | 693 | java | ServiceListener.java | Java | [] | null | [] | package app.whatsdone.android.services;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import app.whatsdone.android.model.BaseEntity;
import app.whatsdone.android.model.Message;
import timber.log.Timber;
public interface ServiceListener {
default void onDataReceivedForMessage(ArrayList<Message> messages){
}
default void onDataReceived(List<BaseEntity> entities) {
}
default void onCompleted(boolean isSuccessful) {
}
default void onSuccess() {
}
default void onError(@Nullable String error){
Timber.e(error);
}
default void onDataReceived(BaseEntity entity){
}
}
| 693 | 0.730159 | 0.730159 | 34 | 19.382353 | 21.250626 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.264706 | false | false | 10 |
bdb7d05d48afa9abaf29f4b30aba4b5cf2d544b6 | 26,860,725,536,908 | 678a3d58c110afd1e9ce195d2f20b2531d45a2e0 | /sources/com/airbnb/android/core/wishlists/WishListsChangedListener.java | 62d97177139e71e87aca3b2cf108c702015e1374 | [] | 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.core.wishlists;
import com.airbnb.android.core.models.WishList;
import java.util.List;
public interface WishListsChangedListener {
void onWishListsChanged(List<WishList> list, WishListChangeInfo wishListChangeInfo);
}
| UTF-8 | Java | 251 | java | WishListsChangedListener.java | Java | [] | null | [] | package com.airbnb.android.core.wishlists;
import com.airbnb.android.core.models.WishList;
import java.util.List;
public interface WishListsChangedListener {
void onWishListsChanged(List<WishList> list, WishListChangeInfo wishListChangeInfo);
}
| 251 | 0.824701 | 0.824701 | 8 | 30.375 | 28.874458 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 10 |
6c4c879e20d0265f519b208a323662eff70dbb0e | 28,647,431,888,890 | 0a2daa6ebc09343828c6118e306c38897e24ad8b | /src/main/java/telegram/BotConfig.java | b2964fcca0bcd5eb6598682abf6b052c8d66ba4c | [] | no_license | gordonkh/stupid-bot | https://github.com/gordonkh/stupid-bot | 14df9d65380c65434d8621d6683e5d84c743556a | 5541d67e156302c959b9610436030e2bab90ac37 | refs/heads/master | 2017-12-06T07:50:48.300000 | 2017-02-16T12:21:35 | 2017-02-16T12:21:35 | 79,995,428 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package telegram;
public class BotConfig {
public static final String TOKEN = "292177978:AAECvlCNtgvO8tX-NoYRqxgz087f22BjrYc";
public static final String NAME = "PS4 Monitor Bot";
public static final String BOT_ID = "@autohttp_bot";
public static Long ADMIN_ID = (long) 179546182;
}
| UTF-8 | Java | 293 | java | BotConfig.java | Java | [
{
"context": "BotConfig {\n\n\tpublic static final String TOKEN = \"292177978:AAECvlCNtgvO8tX-NoYRqxgz087f22BjrYc\";\n\n\tpublic sta",
"end": 92,
"score": 0.9969881176948547,
"start": 82,
"tag": "KEY",
"value": "292177978:"
},
{
"context": "{\n\n\tpublic static final String TOKEN = \... | null | [] | package telegram;
public class BotConfig {
public static final String TOKEN = "292177978:<KEY>";
public static final String NAME = "PS4 Monitor Bot";
public static final String BOT_ID = "@autohttp_bot";
public static Long ADMIN_ID = (long) 179546182;
}
| 263 | 0.754266 | 0.668942 | 13 | 21.538462 | 27.474787 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 10 |
e0ba4647151e0bd68a13d86ac8af5aebaf117fc4 | 3,616,362,494,060 | 4676df48aef08df1bf34acf1517e5022d66c256d | /src/test/java/it/unibz/inf/ontouml/vp/model/ontouml/deserialization/GeneralizationDeserializerTest.java | 23b0e40beb011f55badad1d8e3a4a7fd76236f30 | [
"Apache-2.0"
] | permissive | OntoUML/ontouml-vp-plugin | https://github.com/OntoUML/ontouml-vp-plugin | 16169c2fbe899003382aceb1793f37b2ca28763a | 9fc02b8162db9910f21b8713549cafce2627dad0 | refs/heads/master | 2023-05-15T02:40:09.443000 | 2021-12-14T06:59:59 | 2021-12-14T06:59:59 | 223,966,527 | 29 | 14 | Apache-2.0 | false | 2023-05-05T16:39:23 | 2019-11-25T14:21:32 | 2023-04-27T14:09:49 | 2023-02-06T09:17:23 | 28,032 | 24 | 11 | 56 | Java | false | false | package it.unibz.inf.ontouml.vp.model.ontouml.deserialization;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Classifier;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Generalization;
import java.io.IOException;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class GeneralizationDeserializerTest {
static String json =
"{\n"
+ " \"id\" : \"g1\",\n"
+ " \"type\" : \"Generalization\",\n"
+ " \"name\" : {\n"
+ " \"en\" : \"My Generalization\",\n"
+ " \"pt\" : \"Minha Generalization\"\n"
+ " },\n"
+ " \"description\" : {\n"
+ " \"pt\" : \"Minha descrição.\",\n"
+ " \"en\" : \"My description.\"\n"
+ " },\n"
+ " \"general\" : {\n"
+ " \"id\" : \"c1\",\n"
+ " \"type\" : \"Class\"\n"
+ " },\n"
+ " \"specific\" : {\n"
+ " \"id\" : \"c2\",\n"
+ " \"type\" : \"Class\"\n"
+ " }\n"
+ "}";
static ObjectMapper mapper;
static Generalization gen;
@BeforeAll
static void setUp() throws IOException {
mapper = new ObjectMapper();
gen = mapper.readValue(json, Generalization.class);
}
@Test
void shouldDeserializeId() {
assertThat(gen.getId()).isEqualTo("g1");
}
@Test
void shouldDeserializeName() {
assertThat(gen.getNameIn("en")).hasValue("My Generalization");
assertThat(gen.getNameIn("pt")).hasValue("Minha Generalization");
}
@Test
void shouldDeserializeDescription() {
assertThat(gen.getDescriptionIn("en")).hasValue("My description.");
assertThat(gen.getDescriptionIn("pt")).hasValue("Minha descrição.");
}
@Test
void shouldDeserializeGeneral() {
Optional<Classifier<?, ?>> general = gen.getGeneral();
assertThat(general).isPresent();
assertThat(general.get().getId()).isEqualTo("c1");
assertThat(general.get().getFirstName()).isEmpty();
}
@Test
void shouldDeserializeSpecific() {
Optional<Classifier<?, ?>> specific = gen.getSpecific();
assertThat(specific).isPresent();
assertThat(specific.get().getId()).isEqualTo("c2");
assertThat(specific.get().getFirstName()).isEmpty();
}
}
| UTF-8 | Java | 2,456 | java | GeneralizationDeserializerTest.java | Java | [] | null | [] | package it.unibz.inf.ontouml.vp.model.ontouml.deserialization;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Classifier;
import it.unibz.inf.ontouml.vp.model.ontouml.model.Generalization;
import java.io.IOException;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class GeneralizationDeserializerTest {
static String json =
"{\n"
+ " \"id\" : \"g1\",\n"
+ " \"type\" : \"Generalization\",\n"
+ " \"name\" : {\n"
+ " \"en\" : \"My Generalization\",\n"
+ " \"pt\" : \"Minha Generalization\"\n"
+ " },\n"
+ " \"description\" : {\n"
+ " \"pt\" : \"Minha descrição.\",\n"
+ " \"en\" : \"My description.\"\n"
+ " },\n"
+ " \"general\" : {\n"
+ " \"id\" : \"c1\",\n"
+ " \"type\" : \"Class\"\n"
+ " },\n"
+ " \"specific\" : {\n"
+ " \"id\" : \"c2\",\n"
+ " \"type\" : \"Class\"\n"
+ " }\n"
+ "}";
static ObjectMapper mapper;
static Generalization gen;
@BeforeAll
static void setUp() throws IOException {
mapper = new ObjectMapper();
gen = mapper.readValue(json, Generalization.class);
}
@Test
void shouldDeserializeId() {
assertThat(gen.getId()).isEqualTo("g1");
}
@Test
void shouldDeserializeName() {
assertThat(gen.getNameIn("en")).hasValue("My Generalization");
assertThat(gen.getNameIn("pt")).hasValue("Minha Generalization");
}
@Test
void shouldDeserializeDescription() {
assertThat(gen.getDescriptionIn("en")).hasValue("My description.");
assertThat(gen.getDescriptionIn("pt")).hasValue("Minha descrição.");
}
@Test
void shouldDeserializeGeneral() {
Optional<Classifier<?, ?>> general = gen.getGeneral();
assertThat(general).isPresent();
assertThat(general.get().getId()).isEqualTo("c1");
assertThat(general.get().getFirstName()).isEmpty();
}
@Test
void shouldDeserializeSpecific() {
Optional<Classifier<?, ?>> specific = gen.getSpecific();
assertThat(specific).isPresent();
assertThat(specific.get().getId()).isEqualTo("c2");
assertThat(specific.get().getFirstName()).isEmpty();
}
}
| 2,456 | 0.590538 | 0.587683 | 81 | 29.271605 | 22.274389 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.493827 | false | false | 10 |
e217aec9eb5bb66a2716b6311da5c6b3c7794157 | 22,505,628,676,106 | edd09fbdb80237cee3a46ffcdda8c01f7e40943b | /test2/src/main/java/com/app/server/businessservice/shopdb/shopdomain/ShopONEEE.java | b1f1b32236fb45bb61896981af23b32ca06325eb | [] | no_license | applifireAlgo/testmynfp | https://github.com/applifireAlgo/testmynfp | 27d911bb4c1f1502eb7a1008d15d69de2025f1c3 | f8bdd9235a35b5802ce742834113443f915beaab | refs/heads/master | 2016-09-14T03:33:44.710000 | 2016-05-11T13:58:49 | 2016-05-11T13:58:49 | 58,547,803 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.server.businessservice.shopdb.shopdomain;
import com.app.server.repository.shopdb.shopdomain.ShopABCRepository;
import com.app.shared.shopdb.shopdomain.ShopABC;
import com.athena.server.pluggable.utils.helper.RuntimeLogInfoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ShopONEEE {
@Autowired
private RuntimeLogInfoHelper runtimeLogInfoHelper;
@Autowired
private ShopABCRepository<ShopABC> shopABCRepository;
public void shopONEE() throws Exception {
com.app.shared.shopdb.shopdomain.ShopABC shopABC = new com.app.shared.shopdb.shopdomain.ShopABC();
shopABC.setPkone("oneee");
com.app.shared.shopdb.shopdomain.ShopABC shopABC1 = shopABCRepository.save(shopABC);
}
}
| UTF-8 | Java | 831 | java | ShopONEEE.java | Java | [] | null | [] | package com.app.server.businessservice.shopdb.shopdomain;
import com.app.server.repository.shopdb.shopdomain.ShopABCRepository;
import com.app.shared.shopdb.shopdomain.ShopABC;
import com.athena.server.pluggable.utils.helper.RuntimeLogInfoHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ShopONEEE {
@Autowired
private RuntimeLogInfoHelper runtimeLogInfoHelper;
@Autowired
private ShopABCRepository<ShopABC> shopABCRepository;
public void shopONEE() throws Exception {
com.app.shared.shopdb.shopdomain.ShopABC shopABC = new com.app.shared.shopdb.shopdomain.ShopABC();
shopABC.setPkone("oneee");
com.app.shared.shopdb.shopdomain.ShopABC shopABC1 = shopABCRepository.save(shopABC);
}
}
| 831 | 0.790614 | 0.78941 | 22 | 36.772728 | 31.344032 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
f7a3a95d2850fb6426b843e8136bc86933f33919 | 22,505,628,676,521 | 6570383ecd3924603cf2793ccb49f366660e7994 | /core/src/com/nezusera/game/RandomAI.java | 240a0e1e35fc6d8843e5b7650f34ec67e0951391 | [] | no_license | SudoSeaMouse/Aquarium | https://github.com/SudoSeaMouse/Aquarium | 472ed485d8372ae47b01ed2d0bc32053198ebe92 | 05620bc63abe0ec4a91aa0a1670e7e187c9ad1df | refs/heads/main | 2023-06-02T06:39:18.722000 | 2021-06-18T21:11:50 | 2021-06-18T21:11:50 | 377,211,722 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nezusera.game;
import java.util.Random;
public class RandomAI extends AI{
@Override
public void AIUpdate(float bugTimer, Random r) {
//Can we do something?
if (bugTimer <= 0) {
//Moves : Left, Right, Wait, Forward
int options = 4;
//Select Option
int option = r.nextInt(4);
switch (option) {
case 0:
parent.RotateLeft();
break;
case 1:
parent.RotateRight();
break;
case 2:
parent.Wait();
break;
case 3:
parent.Forward();
break;
}
}
}
}
| UTF-8 | Java | 784 | java | RandomAI.java | Java | [] | null | [] | package com.nezusera.game;
import java.util.Random;
public class RandomAI extends AI{
@Override
public void AIUpdate(float bugTimer, Random r) {
//Can we do something?
if (bugTimer <= 0) {
//Moves : Left, Right, Wait, Forward
int options = 4;
//Select Option
int option = r.nextInt(4);
switch (option) {
case 0:
parent.RotateLeft();
break;
case 1:
parent.RotateRight();
break;
case 2:
parent.Wait();
break;
case 3:
parent.Forward();
break;
}
}
}
}
| 784 | 0.404337 | 0.395408 | 32 | 23.5 | 13.953046 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
12e8617b98d546b2402fa51054e3ade3c748c175 | 9,869,834,867,486 | 17c30fed606a8b1c8f07f3befbef6ccc78288299 | /P9_8_0_0/src/main/java/android/rms/HwSysResImpl.java | 3f7312bb250435f8b99dfb0ec5c0794c9d3f40e5 | [] | no_license | EggUncle/HwFrameWorkSource | https://github.com/EggUncle/HwFrameWorkSource | 4e67f1b832a2f68f5eaae065c90215777b8633a7 | 162e751d0952ca13548f700aad987852b969a4ad | refs/heads/master | 2020-04-06T14:29:22.781000 | 2018-11-09T05:05:03 | 2018-11-09T05:05:03 | 157,543,151 | 1 | 0 | null | true | 2018-11-14T12:08:01 | 2018-11-14T12:08:01 | 2018-11-14T12:07:41 | 2018-11-09T05:05:10 | 26,058 | 0 | 0 | 0 | null | false | null | package android.rms;
import android.annotation.SuppressLint;
import android.database.IContentObserver;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.rms.IUpdateWhiteListCallback.Stub;
import android.rms.config.ResourceConfig;
import android.rms.iaware.AppTypeInfo;
import android.rms.resource.ActivityResource;
import android.rms.resource.AlarmResource;
import android.rms.resource.AppOpsResource;
import android.rms.resource.AppResource;
import android.rms.resource.AppServiceResource;
import android.rms.resource.BroadcastResource;
import android.rms.resource.ContentObserverResource;
import android.rms.resource.CursorResource;
import android.rms.resource.NotificationResource;
import android.rms.resource.OrderedBroadcastObserveResource;
import android.rms.resource.PidsResource;
import android.rms.resource.ReceiverResource;
import android.rms.utils.Utils;
import android.util.Log;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class HwSysResImpl implements HwSysResource {
private static final String TAG = "RMS.HwSysResImpl";
private static boolean enableIaware = SystemProperties.getBoolean("persist.sys.enable_iaware", false);
private static boolean enableRms = SystemProperties.getBoolean("ro.config.enable_rms", false);
protected ResourceConfig[] mResourceConfig;
protected HwSysResManager mResourceManger;
protected int mResourceType = -1;
private String mTag = TAG;
private IUpdateWhiteListCallback mUpdateWhiteListCallback = new Stub() {
public void update() throws RemoteException {
if (Utils.DEBUG) {
Log.d(HwSysResImpl.this.mTag, "IUpdateWhiteListCallback was called");
}
HwSysResImpl.this.initWhiteLists();
HwSysResImpl.this.onWhiteListUpdate();
}
};
private Map<Integer, ArrayList<String>> mWhiteListMap = new HashMap();
private int[] mWhiteListTypes;
public static HwSysResource getResource(int resourceType) {
if (enableRms) {
switch (resourceType) {
case 10:
return NotificationResource.getInstance();
case 12:
return ReceiverResource.getInstance();
case 13:
return AlarmResource.getInstance();
case 14:
return AppOpsResource.getInstance();
case 15:
return PidsResource.getInstance();
case 16:
return CursorResource.getInstance();
case 17:
return AppServiceResource.getInstance();
case 18:
return AppResource.getInstance();
case AppTypeInfo.APP_TYPE_GALLERY /*29*/:
return ContentObserverResource.getInstance();
case 30:
return ActivityResource.getInstance();
}
}
if (enableIaware) {
switch (resourceType) {
case 11:
return BroadcastResource.getInstance();
case 31:
return OrderedBroadcastObserveResource.getInstance();
}
}
return null;
}
public int acquire(int callingUid, String pkg, int processTpye) {
return 1;
}
public int acquire(int callingUid, String pkg, int processTpye, int count) {
return 1;
}
public int acquire(Uri uri, IContentObserver observer, Bundle args) {
return 1;
}
public int queryPkgPolicy(int type, int value, String key) {
return 0;
}
public void release(int callingUid, String pkg, int processTpye) {
}
public void clear(int callingUid, String pkg, int processTpye) {
}
public void dump(FileDescriptor fd, PrintWriter pw) {
}
public Bundle query() {
return null;
}
private static boolean isUidSystem(int uid, String pkg) {
int appid = UserHandle.getAppId(uid);
return (appid == 1000 || appid == 1001 || uid == 0) ? true : "android".equals(pkg);
}
private int isHuaweiApp(String pkg) {
return pkg.contains("huawei") ? 1 : 0;
}
public int getTypeId(int callingUid, String pkg, int processTpye) {
int typeID = processTpye;
if (-1 == processTpye) {
if (isUidSystem(callingUid, pkg)) {
typeID = 2;
} else if (pkg != null) {
typeID = isHuaweiApp(pkg);
} else {
typeID = 0;
}
}
if (Utils.DEBUG) {
Log.d(TAG, "getTypeId typeID/" + typeID);
}
return typeID;
}
public long getResourceId(int callingUid, String pkg, int processTpye) {
int typeID = getTypeId(callingUid, pkg, processTpye);
int uid = 3 == processTpye ? -1 : callingUid;
long id = (((long) typeID) << 32) + ((long) uid);
if (Utils.DEBUG) {
Log.d(TAG, "getResourceId typeID/" + typeID + " uid/" + uid + " id/" + id);
}
return id;
}
protected boolean registerResourceCallback(IUpdateWhiteListCallback updateCallback) {
return HwSysResManager.getInstance().registerResourceCallback(updateCallback);
}
protected ArrayList<String> getResWhiteList(int type) {
if (this.mWhiteListMap.get(Integer.valueOf(type)) == null) {
this.mWhiteListMap.put(Integer.valueOf(type), new ArrayList());
}
return (ArrayList) this.mWhiteListMap.get(Integer.valueOf(type));
}
private ArrayList<String> initResWhiteList(int type) {
String[] whiteList = null;
ArrayList<String> mList = new ArrayList();
String configWhiteList = HwSysResManager.getInstance().getWhiteList(this.mResourceType, type);
if (Utils.DEBUG) {
Log.d(this.mTag, "getResWhiteList put" + this.mResourceType + type + configWhiteList);
}
if (configWhiteList != null) {
whiteList = configWhiteList.split(";");
}
if (whiteList != null) {
int i = 0;
while (i < whiteList.length) {
if (!(mList.contains(whiteList[i]) || (whiteList[i].isEmpty() ^ 1) == 0)) {
mList.add(whiteList[i]);
if (Utils.DEBUG) {
Log.d(TAG, "getResWhiteList put the name into the list type:" + this.mResourceType + ", name:" + whiteList[i] + " , num:" + i);
}
}
i++;
}
}
return mList;
}
@SuppressLint({"PreferForInArrayList"})
private boolean isInWhiteList(String pkg, ArrayList<String> whiteList) {
if (pkg == null || whiteList == null) {
return false;
}
for (String proc : whiteList) {
if (pkg.equals(proc)) {
if (Utils.DEBUG) {
Log.i(this.mTag, "HwSysResImpl.isWhiteList pkg = " + pkg + " proc = " + proc);
}
return true;
}
}
return false;
}
protected boolean isInWhiteList(String pkg, int whiteListType) {
return isInWhiteList(pkg, (ArrayList) this.mWhiteListMap.get(Integer.valueOf(whiteListType)));
}
public HwSysResImpl(int resourceType, String tag, int[] whiteListTypes) {
this.mTag = tag;
this.mWhiteListTypes = copyWhiteListTypes(whiteListTypes);
this.mResourceType = resourceType;
this.mResourceManger = HwSysResManager.getInstance();
}
private int[] copyWhiteListTypes(int[] whiteListTypes) {
if (whiteListTypes == null) {
return null;
}
return Arrays.copyOf(whiteListTypes, whiteListTypes.length);
}
protected boolean getConfig() {
if (this.mResourceConfig != null) {
return true;
}
this.mResourceConfig = this.mResourceManger.getResourceConfig(this.mResourceType);
if (this.mResourceConfig == null && this.mResourceType == 11) {
getWhiteListConfig();
return true;
} else if (this.mResourceConfig == null) {
return false;
} else {
if (Utils.DEBUG) {
for (ResourceConfig resourceThreshold : this.mResourceConfig) {
if (Utils.DEBUG) {
Log.d(this.mTag, "getConfig threshold" + resourceThreshold.getResourceThreshold());
}
}
}
getWhiteListConfig();
return true;
}
}
private void getWhiteListConfig() {
if (this.mWhiteListTypes != null && this.mWhiteListTypes.length > 0) {
if (needUpdateWhiteList() && !registerResourceCallback(this.mUpdateWhiteListCallback) && Utils.DEBUG) {
Log.e(this.mTag, "Resource[type=" + this.mResourceManger + "] register callback failed");
}
initWhiteLists();
}
}
protected void onWhiteListUpdate() {
}
private void initWhiteLists() {
if (this.mWhiteListTypes != null && this.mWhiteListTypes.length > 0) {
for (int type : this.mWhiteListTypes) {
ArrayList<String> whitelist = initResWhiteList(type);
if (whitelist.size() > 0) {
if (Utils.DEBUG) {
Log.d(this.mTag, "initWhiteLists was called" + whitelist);
}
this.mWhiteListMap.put(Integer.valueOf(type), whitelist);
}
}
}
}
protected boolean needUpdateWhiteList() {
return true;
}
}
| UTF-8 | Java | 9,908 | java | HwSysResImpl.java | Java | [] | null | [] | package android.rms;
import android.annotation.SuppressLint;
import android.database.IContentObserver;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.rms.IUpdateWhiteListCallback.Stub;
import android.rms.config.ResourceConfig;
import android.rms.iaware.AppTypeInfo;
import android.rms.resource.ActivityResource;
import android.rms.resource.AlarmResource;
import android.rms.resource.AppOpsResource;
import android.rms.resource.AppResource;
import android.rms.resource.AppServiceResource;
import android.rms.resource.BroadcastResource;
import android.rms.resource.ContentObserverResource;
import android.rms.resource.CursorResource;
import android.rms.resource.NotificationResource;
import android.rms.resource.OrderedBroadcastObserveResource;
import android.rms.resource.PidsResource;
import android.rms.resource.ReceiverResource;
import android.rms.utils.Utils;
import android.util.Log;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class HwSysResImpl implements HwSysResource {
private static final String TAG = "RMS.HwSysResImpl";
private static boolean enableIaware = SystemProperties.getBoolean("persist.sys.enable_iaware", false);
private static boolean enableRms = SystemProperties.getBoolean("ro.config.enable_rms", false);
protected ResourceConfig[] mResourceConfig;
protected HwSysResManager mResourceManger;
protected int mResourceType = -1;
private String mTag = TAG;
private IUpdateWhiteListCallback mUpdateWhiteListCallback = new Stub() {
public void update() throws RemoteException {
if (Utils.DEBUG) {
Log.d(HwSysResImpl.this.mTag, "IUpdateWhiteListCallback was called");
}
HwSysResImpl.this.initWhiteLists();
HwSysResImpl.this.onWhiteListUpdate();
}
};
private Map<Integer, ArrayList<String>> mWhiteListMap = new HashMap();
private int[] mWhiteListTypes;
public static HwSysResource getResource(int resourceType) {
if (enableRms) {
switch (resourceType) {
case 10:
return NotificationResource.getInstance();
case 12:
return ReceiverResource.getInstance();
case 13:
return AlarmResource.getInstance();
case 14:
return AppOpsResource.getInstance();
case 15:
return PidsResource.getInstance();
case 16:
return CursorResource.getInstance();
case 17:
return AppServiceResource.getInstance();
case 18:
return AppResource.getInstance();
case AppTypeInfo.APP_TYPE_GALLERY /*29*/:
return ContentObserverResource.getInstance();
case 30:
return ActivityResource.getInstance();
}
}
if (enableIaware) {
switch (resourceType) {
case 11:
return BroadcastResource.getInstance();
case 31:
return OrderedBroadcastObserveResource.getInstance();
}
}
return null;
}
public int acquire(int callingUid, String pkg, int processTpye) {
return 1;
}
public int acquire(int callingUid, String pkg, int processTpye, int count) {
return 1;
}
public int acquire(Uri uri, IContentObserver observer, Bundle args) {
return 1;
}
public int queryPkgPolicy(int type, int value, String key) {
return 0;
}
public void release(int callingUid, String pkg, int processTpye) {
}
public void clear(int callingUid, String pkg, int processTpye) {
}
public void dump(FileDescriptor fd, PrintWriter pw) {
}
public Bundle query() {
return null;
}
private static boolean isUidSystem(int uid, String pkg) {
int appid = UserHandle.getAppId(uid);
return (appid == 1000 || appid == 1001 || uid == 0) ? true : "android".equals(pkg);
}
private int isHuaweiApp(String pkg) {
return pkg.contains("huawei") ? 1 : 0;
}
public int getTypeId(int callingUid, String pkg, int processTpye) {
int typeID = processTpye;
if (-1 == processTpye) {
if (isUidSystem(callingUid, pkg)) {
typeID = 2;
} else if (pkg != null) {
typeID = isHuaweiApp(pkg);
} else {
typeID = 0;
}
}
if (Utils.DEBUG) {
Log.d(TAG, "getTypeId typeID/" + typeID);
}
return typeID;
}
public long getResourceId(int callingUid, String pkg, int processTpye) {
int typeID = getTypeId(callingUid, pkg, processTpye);
int uid = 3 == processTpye ? -1 : callingUid;
long id = (((long) typeID) << 32) + ((long) uid);
if (Utils.DEBUG) {
Log.d(TAG, "getResourceId typeID/" + typeID + " uid/" + uid + " id/" + id);
}
return id;
}
protected boolean registerResourceCallback(IUpdateWhiteListCallback updateCallback) {
return HwSysResManager.getInstance().registerResourceCallback(updateCallback);
}
protected ArrayList<String> getResWhiteList(int type) {
if (this.mWhiteListMap.get(Integer.valueOf(type)) == null) {
this.mWhiteListMap.put(Integer.valueOf(type), new ArrayList());
}
return (ArrayList) this.mWhiteListMap.get(Integer.valueOf(type));
}
private ArrayList<String> initResWhiteList(int type) {
String[] whiteList = null;
ArrayList<String> mList = new ArrayList();
String configWhiteList = HwSysResManager.getInstance().getWhiteList(this.mResourceType, type);
if (Utils.DEBUG) {
Log.d(this.mTag, "getResWhiteList put" + this.mResourceType + type + configWhiteList);
}
if (configWhiteList != null) {
whiteList = configWhiteList.split(";");
}
if (whiteList != null) {
int i = 0;
while (i < whiteList.length) {
if (!(mList.contains(whiteList[i]) || (whiteList[i].isEmpty() ^ 1) == 0)) {
mList.add(whiteList[i]);
if (Utils.DEBUG) {
Log.d(TAG, "getResWhiteList put the name into the list type:" + this.mResourceType + ", name:" + whiteList[i] + " , num:" + i);
}
}
i++;
}
}
return mList;
}
@SuppressLint({"PreferForInArrayList"})
private boolean isInWhiteList(String pkg, ArrayList<String> whiteList) {
if (pkg == null || whiteList == null) {
return false;
}
for (String proc : whiteList) {
if (pkg.equals(proc)) {
if (Utils.DEBUG) {
Log.i(this.mTag, "HwSysResImpl.isWhiteList pkg = " + pkg + " proc = " + proc);
}
return true;
}
}
return false;
}
protected boolean isInWhiteList(String pkg, int whiteListType) {
return isInWhiteList(pkg, (ArrayList) this.mWhiteListMap.get(Integer.valueOf(whiteListType)));
}
public HwSysResImpl(int resourceType, String tag, int[] whiteListTypes) {
this.mTag = tag;
this.mWhiteListTypes = copyWhiteListTypes(whiteListTypes);
this.mResourceType = resourceType;
this.mResourceManger = HwSysResManager.getInstance();
}
private int[] copyWhiteListTypes(int[] whiteListTypes) {
if (whiteListTypes == null) {
return null;
}
return Arrays.copyOf(whiteListTypes, whiteListTypes.length);
}
protected boolean getConfig() {
if (this.mResourceConfig != null) {
return true;
}
this.mResourceConfig = this.mResourceManger.getResourceConfig(this.mResourceType);
if (this.mResourceConfig == null && this.mResourceType == 11) {
getWhiteListConfig();
return true;
} else if (this.mResourceConfig == null) {
return false;
} else {
if (Utils.DEBUG) {
for (ResourceConfig resourceThreshold : this.mResourceConfig) {
if (Utils.DEBUG) {
Log.d(this.mTag, "getConfig threshold" + resourceThreshold.getResourceThreshold());
}
}
}
getWhiteListConfig();
return true;
}
}
private void getWhiteListConfig() {
if (this.mWhiteListTypes != null && this.mWhiteListTypes.length > 0) {
if (needUpdateWhiteList() && !registerResourceCallback(this.mUpdateWhiteListCallback) && Utils.DEBUG) {
Log.e(this.mTag, "Resource[type=" + this.mResourceManger + "] register callback failed");
}
initWhiteLists();
}
}
protected void onWhiteListUpdate() {
}
private void initWhiteLists() {
if (this.mWhiteListTypes != null && this.mWhiteListTypes.length > 0) {
for (int type : this.mWhiteListTypes) {
ArrayList<String> whitelist = initResWhiteList(type);
if (whitelist.size() > 0) {
if (Utils.DEBUG) {
Log.d(this.mTag, "initWhiteLists was called" + whitelist);
}
this.mWhiteListMap.put(Integer.valueOf(type), whitelist);
}
}
}
}
protected boolean needUpdateWhiteList() {
return true;
}
}
| 9,908 | 0.594974 | 0.589423 | 277 | 34.768951 | 27.932306 | 152 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606498 | false | false | 10 |
14149e02493dc0e6c72e16882834c37960b1aab3 | 29,094,108,517,536 | b733c258761e7d91a7ef0e15ca0e01427618dc33 | /cards/src/main/java/org/rnd/jmagic/cards/TrigonofRage.java | a8c14213e5635e1dd33ab3cc7b9c409886fc918f | [] | no_license | jmagicdev/jmagic | https://github.com/jmagicdev/jmagic | d43aa3d2288f46a5fa950152486235614c6783e6 | 40e573f8e6d1cf42603fd05928f42e7080ce0f0d | refs/heads/master | 2021-01-20T06:57:51.007000 | 2014-10-22T03:03:34 | 2014-10-22T03:03:34 | 9,589,102 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.rnd.jmagic.cards;
import static org.rnd.jmagic.Convenience.*;
import org.rnd.jmagic.engine.*;
import org.rnd.jmagic.engine.generators.*;
@Name("Trigon of Rage")
@Types({Type.ARTIFACT})
@ManaCost("2")
@ColorIdentity({Color.RED})
public final class TrigonofRage extends Card
{
public static final class TrigonofRageAbility1 extends ActivatedAbility
{
public TrigonofRageAbility1(GameState state)
{
super(state, "(R)(R), (T): Put a charge counter on Trigon of Rage.");
this.setManaCost(new ManaPool("(R)(R)"));
this.costsTap = true;
this.addEffect(putCounters(1, Counter.CounterType.CHARGE, ABILITY_SOURCE_OF_THIS, "Put a charge counter on Trigon of Rage"));
}
}
public static final class TrigonofRageAbility2 extends ActivatedAbility
{
public TrigonofRageAbility2(GameState state)
{
super(state, "(2), (T), Remove a charge counter from Trigon of Rage: Target creature gets +3/+0 until end of turn.");
this.setManaCost(new ManaPool("(2)"));
this.costsTap = true;
this.addCost(removeCounters(1, Counter.CounterType.CHARGE, ABILITY_SOURCE_OF_THIS, "Remove a charge counter from Trigon of Rage"));
SetGenerator target = targetedBy(this.addTarget(CreaturePermanents.instance(), "target creature"));
this.addEffect(createFloatingEffect("Target creature gets +3/+0 until end of turn.", modifyPowerAndToughness(target, +3, +0)));
}
}
public TrigonofRage(GameState state)
{
super(state);
// Trigon of Rage enters the battlefield with three charge counters on
// it.
this.addAbility(new org.rnd.jmagic.abilities.EntersTheBattlefieldWithCounters(state, "Trigon of Rage", 3, Counter.CounterType.CHARGE));
// (R)(R), (T): Put a charge counter on Trigon of Rage.
this.addAbility(new TrigonofRageAbility1(state));
// (2), (T), Remove a charge counter from Trigon of Rage: Target
// creature gets +3/+0 until end of turn.
this.addAbility(new TrigonofRageAbility2(state));
}
}
| UTF-8 | Java | 1,946 | java | TrigonofRage.java | Java | [
{
"context": "mport org.rnd.jmagic.engine.generators.*;\n\n@Name(\"Trigon of Rage\")\n@Types({Type.ARTIFACT})\n@ManaCost(\"2\")\n@ColorId",
"end": 172,
"score": 0.9988940954208374,
"start": 158,
"tag": "NAME",
"value": "Trigon of Rage"
}
] | null | [] | package org.rnd.jmagic.cards;
import static org.rnd.jmagic.Convenience.*;
import org.rnd.jmagic.engine.*;
import org.rnd.jmagic.engine.generators.*;
@Name("<NAME>")
@Types({Type.ARTIFACT})
@ManaCost("2")
@ColorIdentity({Color.RED})
public final class TrigonofRage extends Card
{
public static final class TrigonofRageAbility1 extends ActivatedAbility
{
public TrigonofRageAbility1(GameState state)
{
super(state, "(R)(R), (T): Put a charge counter on Trigon of Rage.");
this.setManaCost(new ManaPool("(R)(R)"));
this.costsTap = true;
this.addEffect(putCounters(1, Counter.CounterType.CHARGE, ABILITY_SOURCE_OF_THIS, "Put a charge counter on Trigon of Rage"));
}
}
public static final class TrigonofRageAbility2 extends ActivatedAbility
{
public TrigonofRageAbility2(GameState state)
{
super(state, "(2), (T), Remove a charge counter from Trigon of Rage: Target creature gets +3/+0 until end of turn.");
this.setManaCost(new ManaPool("(2)"));
this.costsTap = true;
this.addCost(removeCounters(1, Counter.CounterType.CHARGE, ABILITY_SOURCE_OF_THIS, "Remove a charge counter from Trigon of Rage"));
SetGenerator target = targetedBy(this.addTarget(CreaturePermanents.instance(), "target creature"));
this.addEffect(createFloatingEffect("Target creature gets +3/+0 until end of turn.", modifyPowerAndToughness(target, +3, +0)));
}
}
public TrigonofRage(GameState state)
{
super(state);
// Trigon of Rage enters the battlefield with three charge counters on
// it.
this.addAbility(new org.rnd.jmagic.abilities.EntersTheBattlefieldWithCounters(state, "Trigon of Rage", 3, Counter.CounterType.CHARGE));
// (R)(R), (T): Put a charge counter on Trigon of Rage.
this.addAbility(new TrigonofRageAbility1(state));
// (2), (T), Remove a charge counter from Trigon of Rage: Target
// creature gets +3/+0 until end of turn.
this.addAbility(new TrigonofRageAbility2(state));
}
}
| 1,938 | 0.733813 | 0.723022 | 52 | 36.423077 | 39.534477 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.076923 | false | false | 10 |
9765bbe4c18d53a567f425d4bfcd185171f58946 | 16,295,105,949,962 | 265e8451f76fe44edc60773a888b0b8696c7dcc3 | /src/main/java/com/company/project/controller/TokenController.java | 8df53f6c059145e3b58dc11e5b8dd47d7290d932 | [] | no_license | SyuuTou/spring-boot-api-project-seed | https://github.com/SyuuTou/spring-boot-api-project-seed | 7b6641736c004dad067879e4139cf8dc370b1c90 | 7e21c32a45324fcc819440760499b698d1f86dc6 | refs/heads/master | 2020-03-31T15:39:18.900000 | 2018-11-07T08:52:45 | 2018-11-07T08:52:45 | 152,345,519 | 0 | 0 | null | true | 2018-10-10T01:38:59 | 2018-10-10T01:38:59 | 2018-10-10T01:38:58 | 2018-09-21T12:42:55 | 77 | 0 | 0 | 0 | null | false | null | package com.company.project.controller;
import com.company.project.security.authorization.annotation.Authorization;
import com.company.project.security.authorization.annotation.CurrentUser;
import com.company.project.security.authorization.manager.TokenService;
import com.company.project.core.Result;
import com.company.project.model.User;
import com.company.project.service.UserService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 获取和删除token的请求地址,在Restful设计中其实就对应着登录和退出登录的资源映射
*
* @author ScienJus
* @date 2015/7/30.
*/
@RestController
@RequestMapping("/tokens")
public class TokenController {
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
@Autowired
private RedisTemplate redisTemplate;
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "登录")
public ResponseEntity<Result> login(@RequestParam String username, @RequestParam String password) {
Assert.notNull(username, "username can not be empty");
Assert.notNull(password, "password can not be empty");
User user = new User(username);
// System.err.println(user);
// userService.save(user);
//生成授权信息,保存用户登录状态
String authorization = tokenService.createToken(1);
return new ResponseEntity<>(Result.success(authorization), HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.DELETE)
@Authorization
// @ApiResponses(value = {@ApiResponse(code = 405,message = "Invalid input",response = Integer.class)})
@ApiOperation(value = "退出登录")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "authorization", required = true, dataType = "string", paramType = "header"),
// @ApiImplicitParam(name = "sign", value = "sign", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<Result> logout(@ApiParam(hidden = true)
@CurrentUser User user) {
System.err.println(user);
// tokenService.deleteToken(user.getId());
return new ResponseEntity<>(Result.success(), HttpStatus.OK);
}
}
| UTF-8 | Java | 2,779 | java | TokenController.java | Java | [
{
"context": "n的请求地址,在Restful设计中其实就对应着登录和退出登录的资源映射\n *\n * @author ScienJus\n * @date 2015/7/30.\n */\n@RestController\n@RequestM",
"end": 1001,
"score": 0.9824619293212891,
"start": 993,
"tag": "USERNAME",
"value": "ScienJus"
}
] | null | [] | package com.company.project.controller;
import com.company.project.security.authorization.annotation.Authorization;
import com.company.project.security.authorization.annotation.CurrentUser;
import com.company.project.security.authorization.manager.TokenService;
import com.company.project.core.Result;
import com.company.project.model.User;
import com.company.project.service.UserService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 获取和删除token的请求地址,在Restful设计中其实就对应着登录和退出登录的资源映射
*
* @author ScienJus
* @date 2015/7/30.
*/
@RestController
@RequestMapping("/tokens")
public class TokenController {
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
@Autowired
private RedisTemplate redisTemplate;
@RequestMapping(method = RequestMethod.POST)
@ApiOperation(value = "登录")
public ResponseEntity<Result> login(@RequestParam String username, @RequestParam String password) {
Assert.notNull(username, "username can not be empty");
Assert.notNull(password, "password can not be empty");
User user = new User(username);
// System.err.println(user);
// userService.save(user);
//生成授权信息,保存用户登录状态
String authorization = tokenService.createToken(1);
return new ResponseEntity<>(Result.success(authorization), HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.DELETE)
@Authorization
// @ApiResponses(value = {@ApiResponse(code = 405,message = "Invalid input",response = Integer.class)})
@ApiOperation(value = "退出登录")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "authorization", required = true, dataType = "string", paramType = "header"),
// @ApiImplicitParam(name = "sign", value = "sign", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<Result> logout(@ApiParam(hidden = true)
@CurrentUser User user) {
System.err.println(user);
// tokenService.deleteToken(user.getId());
return new ResponseEntity<>(Result.success(), HttpStatus.OK);
}
}
| 2,779 | 0.729315 | 0.725197 | 68 | 38.279411 | 31.011311 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.691176 | false | false | 10 |
09526c50686704ba0f4837bb844204e4d8539178 | 20,658,792,717,488 | bedd87d6a5315284a891528e076310fd296bcb9d | /quartz定时任务/GroupTopicHotQuartz.java | d6e004019e59ce0be0f1b2efac7a80debd57ca54 | [] | no_license | winton979/codeSnippet | https://github.com/winton979/codeSnippet | 7c310fb5114327d0aff5a64634b7fc8a79d386e4 | 52ba261c2e247b75d765b4c7b80bd4dd9dcd21f7 | refs/heads/master | 2021-10-20T09:29:00.620000 | 2019-02-27T08:55:48 | 2019-02-27T08:55:48 | 107,529,857 | 3 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pricl.biz.group.quartz;
/**
* demo
*/
public class GroupTopicHotQuartz {
public void run() {
}
} | UTF-8 | Java | 125 | java | GroupTopicHotQuartz.java | Java | [] | null | [] | package com.pricl.biz.group.quartz;
/**
* demo
*/
public class GroupTopicHotQuartz {
public void run() {
}
} | 125 | 0.608 | 0.608 | 14 | 8 | 11.856282 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.714286 | false | false | 10 |
5a8c8bd8b01edea1398e2f5d289f4d9f9e2aad3a | 25,967,372,298,955 | 0c9be1922cd739597a3447ae47fb376f000f3e09 | /kwai-open_sdk/src/main/java/com/kuaishou/open/sdk/model/VideoInfo.java | a269cd1421db2be761efa45a8f77640156ca47d1 | [] | no_license | WugeKelvin/kwaiOpenSDK | https://github.com/WugeKelvin/kwaiOpenSDK | fe81817fa1b5d07c38874bae560298d2f65a9213 | abca0c24d0081bebe3f17fae79e3ab4cf3bc2333 | refs/heads/master | 2023-01-29T14:01:45.396000 | 2020-12-16T09:41:14 | 2020-12-16T09:41:14 | 320,157,688 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kuaishou.open.sdk.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author wuge <wuge@kuaishou.com>
* Created on 2020-12-11
*/
public class VideoInfo {
@JsonProperty("photo_id")
private String photoId;
private String caption;
private String cover;
@JsonProperty("play_url")
private String playUrl;
@JsonProperty("create_time")
private Long createTime;
@JsonProperty("like_count")
private Long likeCount;
@JsonProperty("comment_count")
private Long commentCount;
@JsonProperty("view_count")
private Long viewCount;
private Boolean pending;
public String getPhotoId() {
return photoId;
}
public void setPhotoId(String photoId) {
this.photoId = photoId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public String getPlayUrl() {
return playUrl;
}
public void setPlayUrl(String playUrl) {
this.playUrl = playUrl;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getLikeCount() {
return likeCount;
}
public void setLikeCount(Long likeCount) {
this.likeCount = likeCount;
}
public Boolean getPending() {
return pending;
}
public void setPending(Boolean pending) {
this.pending = pending;
}
public Long getCommentCount() {
return commentCount;
}
public void setCommentCount(Long commentCount) {
this.commentCount = commentCount;
}
public Long getViewCount() {
return viewCount;
}
public void setViewCount(Long viewCount) {
this.viewCount = viewCount;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("VideoInfo{");
sb.append("photoId='").append(photoId).append('\'');
sb.append(", caption='").append(caption).append('\'');
sb.append(", cover='").append(cover).append('\'');
sb.append(", playUrl='").append(playUrl).append('\'');
sb.append(", createTime=").append(createTime);
sb.append(", likeCount=").append(likeCount);
sb.append(", commentCount=").append(commentCount);
sb.append(", viewCount=").append(viewCount);
sb.append(", pending=").append(pending);
sb.append('}');
return sb.toString();
}
}
| UTF-8 | Java | 2,708 | java | VideoInfo.java | Java | [
{
"context": "l.jackson.annotation.JsonProperty;\n\n/**\n * @author wuge <wuge@kuaishou.com>\n * Created on 2020-12-11\n */\n",
"end": 112,
"score": 0.9996310472488403,
"start": 108,
"tag": "USERNAME",
"value": "wuge"
},
{
"context": "on.annotation.JsonProperty;\n\n/**\n * @author wu... | null | [] | package com.kuaishou.open.sdk.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author wuge <<EMAIL>>
* Created on 2020-12-11
*/
public class VideoInfo {
@JsonProperty("photo_id")
private String photoId;
private String caption;
private String cover;
@JsonProperty("play_url")
private String playUrl;
@JsonProperty("create_time")
private Long createTime;
@JsonProperty("like_count")
private Long likeCount;
@JsonProperty("comment_count")
private Long commentCount;
@JsonProperty("view_count")
private Long viewCount;
private Boolean pending;
public String getPhotoId() {
return photoId;
}
public void setPhotoId(String photoId) {
this.photoId = photoId;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public String getPlayUrl() {
return playUrl;
}
public void setPlayUrl(String playUrl) {
this.playUrl = playUrl;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getLikeCount() {
return likeCount;
}
public void setLikeCount(Long likeCount) {
this.likeCount = likeCount;
}
public Boolean getPending() {
return pending;
}
public void setPending(Boolean pending) {
this.pending = pending;
}
public Long getCommentCount() {
return commentCount;
}
public void setCommentCount(Long commentCount) {
this.commentCount = commentCount;
}
public Long getViewCount() {
return viewCount;
}
public void setViewCount(Long viewCount) {
this.viewCount = viewCount;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("VideoInfo{");
sb.append("photoId='").append(photoId).append('\'');
sb.append(", caption='").append(caption).append('\'');
sb.append(", cover='").append(cover).append('\'');
sb.append(", playUrl='").append(playUrl).append('\'');
sb.append(", createTime=").append(createTime);
sb.append(", likeCount=").append(likeCount);
sb.append(", commentCount=").append(commentCount);
sb.append(", viewCount=").append(viewCount);
sb.append(", pending=").append(pending);
sb.append('}');
return sb.toString();
}
}
| 2,698 | 0.612629 | 0.609675 | 122 | 21.196722 | 18.811245 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.401639 | false | false | 10 |
55dad2fc99d7e6f62f7b3002808d94cb7e80f5c5 | 30,588,757,142,150 | d49be7d2ad87784d11159713dc2e82c3a2afcdaa | /src/MenuBar.java | a5118305d61c94165ded27ef8e5903ba2a07cbed | [] | no_license | DW123411/PogodynkaAI | https://github.com/DW123411/PogodynkaAI | e93eb517a4ac99dba62483995a54d1817c9baa6b | f109f154256295edad78b8b305285e3a990e6f62 | refs/heads/master | 2020-04-26T06:29:10.499000 | 2020-01-17T22:40:09 | 2020-01-17T22:40:09 | 173,365,841 | 4 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null |
/**
*
* @author majzner marcin
*/
import javax.swing.*;
public class MenuBar extends JMenuBar {
JMenu plik = new JMenu("Plik");
//
private Okno parent;
JMenuItem wczytalldata = new JMenuItem("Wczytaj dane.");
JMenuItem wczytdladecyzji = new JMenuItem("Wczytaj dane bez decyzji.");
JSeparator endwczytaj = new JSeparator();
///
JMenuItem zapiszPlikJPG = new JMenuItem("Zapisz obraz.");
JMenuItem zapiszPlikTXT = new JMenuItem("Zapisz do pliku tekstowego.");
JSeparator endzapis = new JSeparator();
JMenuItem exit = new JMenuItem("Zakończ.");
///
JMenu edycja = new JMenu("Edycja");
//
JMenuItem rysujdrzewo = new JMenuItem("Rysuj drzewo.");
JMenuItem wyswietlDecyzje = new JMenuItem("Wyświetl decyzję.");
JMenuItem wyczysc = new JMenuItem("Wyczyść.");
JSeparator endrys = new JSeparator();
///
JMenuItem ustawrozmiarzbiorow = new JMenuItem("Ustaw rozmiary zbiorów.");
JMenuItem ustawmaxglebokosc = new JMenuItem("Ustaw maksymalną głębokość.");
//
JMenu widok = new JMenu("Widok");
JMenuItem pokatabele = new JMenuItem("Pokaż tabelę.");
JMenuItem pokaaccuracy = new JMenuItem("Dokładność.");
JMenuItem schowajMenu = new JMenuItem("Schowaj menu.");
JSeparator endtabela = new JSeparator();
///
JMenuItem scalowanie = new JMenuItem("Skalowanie.");
JSeparator endskalowanie = new JSeparator();
///
JMenuItem motywy = new JMenuItem("Wybór motywu.");
//
JMenu info = new JMenu("Info");
JMenuItem credits = new JMenuItem("O programie.");
JMenuItem manual = new JMenuItem("Instrukcja.");
public MenuBar(Okno parent){
super();
plik.add(wczytalldata);
plik.add(wczytdladecyzji);
plik.add(endwczytaj);
plik.add(zapiszPlikJPG);
plik.add(zapiszPlikTXT);
plik.add(endzapis);
plik.add(exit);
edycja.add( rysujdrzewo );
edycja.add (wyswietlDecyzje);
edycja.add( wyczysc );
edycja.add( endrys );
edycja.add( ustawrozmiarzbiorow );
edycja.add( ustawmaxglebokosc );
widok.add( pokatabele );
widok.add( pokaaccuracy );
widok.add(schowajMenu);
widok.add( endtabela );
widok.add( scalowanie );
widok.add( endskalowanie );
widok.add( motywy );
info.add( credits );
info.add( manual );
add(plik);
add(edycja);
add(widok);
add(info);
}
}
| UTF-8 | Java | 2,201 | java | MenuBar.java | Java | [
{
"context": "\n/**\n *\n * @author majzner marcin\n */\nimport javax.swing.*;\n\npublic class MenuBar e",
"end": 33,
"score": 0.999765932559967,
"start": 19,
"tag": "NAME",
"value": "majzner marcin"
}
] | null | [] |
/**
*
* @author <NAME>
*/
import javax.swing.*;
public class MenuBar extends JMenuBar {
JMenu plik = new JMenu("Plik");
//
private Okno parent;
JMenuItem wczytalldata = new JMenuItem("Wczytaj dane.");
JMenuItem wczytdladecyzji = new JMenuItem("Wczytaj dane bez decyzji.");
JSeparator endwczytaj = new JSeparator();
///
JMenuItem zapiszPlikJPG = new JMenuItem("Zapisz obraz.");
JMenuItem zapiszPlikTXT = new JMenuItem("Zapisz do pliku tekstowego.");
JSeparator endzapis = new JSeparator();
JMenuItem exit = new JMenuItem("Zakończ.");
///
JMenu edycja = new JMenu("Edycja");
//
JMenuItem rysujdrzewo = new JMenuItem("Rysuj drzewo.");
JMenuItem wyswietlDecyzje = new JMenuItem("Wyświetl decyzję.");
JMenuItem wyczysc = new JMenuItem("Wyczyść.");
JSeparator endrys = new JSeparator();
///
JMenuItem ustawrozmiarzbiorow = new JMenuItem("Ustaw rozmiary zbiorów.");
JMenuItem ustawmaxglebokosc = new JMenuItem("Ustaw maksymalną głębokość.");
//
JMenu widok = new JMenu("Widok");
JMenuItem pokatabele = new JMenuItem("Pokaż tabelę.");
JMenuItem pokaaccuracy = new JMenuItem("Dokładność.");
JMenuItem schowajMenu = new JMenuItem("Schowaj menu.");
JSeparator endtabela = new JSeparator();
///
JMenuItem scalowanie = new JMenuItem("Skalowanie.");
JSeparator endskalowanie = new JSeparator();
///
JMenuItem motywy = new JMenuItem("Wybór motywu.");
//
JMenu info = new JMenu("Info");
JMenuItem credits = new JMenuItem("O programie.");
JMenuItem manual = new JMenuItem("Instrukcja.");
public MenuBar(Okno parent){
super();
plik.add(wczytalldata);
plik.add(wczytdladecyzji);
plik.add(endwczytaj);
plik.add(zapiszPlikJPG);
plik.add(zapiszPlikTXT);
plik.add(endzapis);
plik.add(exit);
edycja.add( rysujdrzewo );
edycja.add (wyswietlDecyzje);
edycja.add( wyczysc );
edycja.add( endrys );
edycja.add( ustawrozmiarzbiorow );
edycja.add( ustawmaxglebokosc );
widok.add( pokatabele );
widok.add( pokaaccuracy );
widok.add(schowajMenu);
widok.add( endtabela );
widok.add( scalowanie );
widok.add( endskalowanie );
widok.add( motywy );
info.add( credits );
info.add( manual );
add(plik);
add(edycja);
add(widok);
add(info);
}
}
| 2,193 | 0.718864 | 0.718864 | 90 | 23.255556 | 21.050501 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.611111 | false | false | 10 |
9d8de74685a8189a0218eb5e3f4c065d4c23fe5f | 25,640,954,819,525 | 6337e65854a82d4e9f142615e5188f144dde08b3 | /src/main/java/mymod/blocks/MyBlock_3.java | 7b7f07ea0a866e1cb75a98b60272cc03e0b85bb8 | [] | no_license | FishSauceGaming/InfiniCraftgithub | https://github.com/FishSauceGaming/InfiniCraftgithub | 392a0c7bddf4fa3b283ea948a2836d629c821ef3 | b6262f294618cae80bf38104ce3c21e7d72f0a09 | refs/heads/master | 2021-01-23T15:09:09.061000 | 2014-09-30T00:09:13 | 2014-09-30T00:09:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mymod.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class MyBlock_3 extends Block {
private String texturePath = "mymod:";
private int thisBlockID;
public MyBlock_3 (int par1, Material blockMaterial, String textureName) {
super(Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setBlockName(textureName);
texturePath += textureName;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return thisBlockID;
}
public int quantityDropped(Random random)
{
return 1;
}
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(texturePath);
}
@SideOnly(Side.CLIENT)
/**
* Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
*/
public int getRenderBlockPass()
{
return 0;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
}
| UTF-8 | Java | 1,560 | java | MyBlock_3.java | Java | [] | null | [] | package mymod.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class MyBlock_3 extends Block {
private String texturePath = "mymod:";
private int thisBlockID;
public MyBlock_3 (int par1, Material blockMaterial, String textureName) {
super(Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setBlockName(textureName);
texturePath += textureName;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return thisBlockID;
}
public int quantityDropped(Random random)
{
return 1;
}
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(texturePath);
}
@SideOnly(Side.CLIENT)
/**
* Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
*/
public int getRenderBlockPass()
{
return 0;
}
/**
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
}
| 1,560 | 0.661538 | 0.654487 | 59 | 25.40678 | 27.075611 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.423729 | false | false | 10 |
fb06af3fc66398617734f37a58223042c3e170fc | 4,698,694,248,588 | fb214cb2b1b11bec3185ad07e0257a65fa35db7f | /programmers/old/level1/같은_숫자는_싫어.java | 2ff312a62fc4423276c815fc9b38f73d5bfc7889 | [] | no_license | LimHaksu/algorithm | https://github.com/LimHaksu/algorithm | 48738631ea9ea79edaf6d481ba2c6c4bd0d3d662 | 596307751301d2357f77319e047d1c9fc9adb635 | refs/heads/master | 2021-12-07T07:56:59.804000 | 2021-11-21T04:53:52 | 2021-11-21T04:53:52 | 180,160,651 | 2 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package programmers;
import java.util.*;
public class 같은_숫자는_싫어 {
static public class Solution {
public int[] solution(int[] arr) {
int currentNum = arr[0];
ArrayList<Integer> temp = new ArrayList<Integer>();
temp.add(arr[0]);
for (int i = 1; i < arr.length; ++i) {
if (currentNum != arr[i]) {
currentNum = arr[i];
temp.add(arr[i]);
}
}
int[] answer = new int[temp.size()];
for (int i = 0; i < answer.length; ++i) {
answer[i] = temp.get(i);
}
return answer;
}
}
public static void main(String[] args) {
int[] arr = { 1, 1, 3, 3, 0, 1, 1 };
Solution sol = new Solution();
System.out.println(Arrays.toString(sol.solution(arr)));
}
}
| UTF-8 | Java | 711 | java | 같은_숫자는_싫어.java | Java | [] | null | [] | package programmers;
import java.util.*;
public class 같은_숫자는_싫어 {
static public class Solution {
public int[] solution(int[] arr) {
int currentNum = arr[0];
ArrayList<Integer> temp = new ArrayList<Integer>();
temp.add(arr[0]);
for (int i = 1; i < arr.length; ++i) {
if (currentNum != arr[i]) {
currentNum = arr[i];
temp.add(arr[i]);
}
}
int[] answer = new int[temp.size()];
for (int i = 0; i < answer.length; ++i) {
answer[i] = temp.get(i);
}
return answer;
}
}
public static void main(String[] args) {
int[] arr = { 1, 1, 3, 3, 0, 1, 1 };
Solution sol = new Solution();
System.out.println(Arrays.toString(sol.solution(arr)));
}
}
| 711 | 0.582496 | 0.566714 | 30 | 22.233334 | 16.895134 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.866667 | false | false | 10 |
cd870fc4723cc4588a920bcbd8b545a8594f2874 | 34,462,817,601,493 | 52c7710bb013a52a26dc79f142070599ea7c6456 | /src/main/java/com/prueba/julio/util/Response.java | da402ee9cf9bfd98099725e957cc86ab0bc69db7 | [] | no_license | juliolicona007/ExamenSrPago | https://github.com/juliolicona007/ExamenSrPago | ab57271d4e4e0c1e54f72924306fb559db015c0e | f8dd422eec800b0dea0a114950c5177b73cf52ab | refs/heads/master | 2022-12-23T09:08:18.841000 | 2019-10-05T01:48:43 | 2019-10-05T01:48:43 | 212,929,072 | 0 | 0 | null | false | 2022-12-16T00:02:26 | 2019-10-05T01:44:19 | 2019-10-05T01:48:46 | 2022-12-16T00:02:25 | 41 | 0 | 0 | 6 | Java | false | false | package com.prueba.julio.util;
import java.io.Serializable;
import java.util.List;
public class Response implements Serializable{
private static final long serialVersionUID = 1L;
private Boolean success;
private List<String> error;
private String message;
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<String> getError() {
return error;
}
public void setError(List<String> error) {
this.error = error;
}
}
| UTF-8 | Java | 733 | java | Response.java | Java | [] | null | [] | package com.prueba.julio.util;
import java.io.Serializable;
import java.util.List;
public class Response implements Serializable{
private static final long serialVersionUID = 1L;
private Boolean success;
private List<String> error;
private String message;
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<String> getError() {
return error;
}
public void setError(List<String> error) {
this.error = error;
}
}
| 733 | 0.637108 | 0.635743 | 36 | 18.361111 | 16.369268 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.638889 | false | false | 10 |
fd01a846e7622642337790524e9d1dfa7419e2a0 | 35,914,516,530,724 | fcd46f84c746f5ed1dd38ce24f9cf5b27e150d78 | /finder-web/src/main/java/com/skin/finder/servlet/template/LangTemplate.java | 089d573ebf6cb18ec56adec6e90d8047eb1d8c0d | [
"Apache-2.0"
] | permissive | lambertwe/finder-parent | https://github.com/lambertwe/finder-parent | f03936ac7c1a9cec3901fbd2dd4e82e92296b099 | 378a643fda255a79582a4666637875c05bfb07fd | refs/heads/master | 2022-05-01T10:38:31.872000 | 2021-07-01T02:07:44 | 2021-07-01T02:07:44 | 177,890,255 | 0 | 0 | Apache-2.0 | false | 2022-03-31T18:47:21 | 2019-03-27T00:37:04 | 2021-07-01T02:07:53 | 2022-03-31T18:47:19 | 2,474 | 0 | 0 | 1 | Java | false | false | /*
* $RCSfile: LangTemplate.java,v $
* $Revision: 1.1 $
*
* JSP generated by JspCompiler-1.0.0
* http://www.finderweb.net
*/
package com.skin.finder.servlet.template;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.skin.finder.config.App;
/**
* <p>Title: LangTemplate</p>
* <p>Description: </p>
* @author JspKit
* @version 1.0
*/
public class LangTemplate extends com.skin.finder.web.servlet.JspServlet {
private static final long serialVersionUID = 1L;
private static final LangTemplate instance = new LangTemplate();
/**
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
public static void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
instance.service(request, response);
}
/**
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html; charset=utf-8");
OutputStream out = response.getOutputStream();
out.write(_jsp_76128, 0, _jsp_76128.length);
out.write(_jsp_76129, 0, _jsp_76129.length);
out.write(_jsp_76130, 0, _jsp_76130.length);
out.write(_jsp_76131, 0, _jsp_76131.length);
out.write(_jsp_76132, 0, _jsp_76132.length);
this.write(out, (App.hash()));
out.write(_jsp_76134, 0, _jsp_76134.length);
out.write(_jsp_76135, 0, _jsp_76135.length);
this.write(out, (App.hash()));
out.write(_jsp_76137, 0, _jsp_76137.length);
this.write(out, (App.hash()));
out.write(_jsp_76139, 0, _jsp_76139.length);
this.write(out, (App.hash()));
out.write(_jsp_76141, 0, _jsp_76141.length);
out.write(_jsp_76142, 0, _jsp_76142.length);
out.write(_jsp_76143, 0, _jsp_76143.length);
out.write(_jsp_76144, 0, _jsp_76144.length);
out.write(_jsp_76145, 0, _jsp_76145.length);
this.write(out, request.getAttribute("contextPath"));
out.write(_jsp_76147, 0, _jsp_76147.length);
this.write(out, request.getAttribute("workspace"));
out.write(_jsp_76149, 0, _jsp_76149.length);
out.write(_jsp_76150, 0, _jsp_76150.length);
out.write(_jsp_76151, 0, _jsp_76151.length);
out.write(_jsp_76152, 0, _jsp_76152.length);
out.write(_jsp_76153, 0, _jsp_76153.length);
out.write(_jsp_76154, 0, _jsp_76154.length);
out.write(_jsp_76155, 0, _jsp_76155.length);
out.write(_jsp_76156, 0, _jsp_76156.length);
out.write(_jsp_76157, 0, _jsp_76157.length);
out.flush();
}
protected static final byte[] _jsp_76128 = b("<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\r\n");
protected static final byte[] _jsp_76129 = b("<meta http-equiv=\"Pragma\" content=\"no-cache\"/>\r\n<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>\r\n");
protected static final byte[] _jsp_76130 = b("<meta http-equiv=\"Expires\" content=\"0\"/>\r\n<title>Setting - Powered by FinderWeb</title>\r\n");
protected static final byte[] _jsp_76131 = b("<link rel=\"shortcut icon\" href=\"?action=res&path=/finder/images/favicon.png\"/>\r\n");
protected static final byte[] _jsp_76132 = b("<link rel=\"stylesheet\" type=\"text/css\" href=\"?action=res&path=/finder/css/form.css&v=");
protected static final byte[] _jsp_76134 = b("\"/>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/jquery-1.12.4.min.js\"></script>\r\n");
protected static final byte[] _jsp_76135 = b("<script type=\"text/javascript\" src=\"?action=res&path=/finder/charset.js&v=");
protected static final byte[] _jsp_76137 = b("\"></script>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/colorpicker.js&v=");
protected static final byte[] _jsp_76139 = b("\"></script>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/config.js&v=");
protected static final byte[] _jsp_76141 = b("\"></script>\r\n<script type=\"text/javascript\">\r\n<!--\r\njQuery(function() {\r\n var theme = Finder.getCookie(\"finder_lang\");\r\n");
protected static final byte[] _jsp_76142 = b(" jQuery(\"select[name=lang]\").val(theme);\r\n});\r\n\r\njQuery(function() {\r\n jQuery(\"#ensure-btn\").click(function() {\r\n");
protected static final byte[] _jsp_76143 = b(" var lang = jQuery(\"select[name=lang]\").val();\r\n Finder.setCookie({\"name\": \"finder_lang\", \"value\": lang, \"expires\": 365 * 24 * 60 * 60});\r\n");
protected static final byte[] _jsp_76144 = b(" alert(\"Save successfully, please reload!\");\r\n });\r\n});\r\n//-->\r\n</script>\r\n");
protected static final byte[] _jsp_76145 = b("</head>\r\n<body contextPath=\"");
protected static final byte[] _jsp_76147 = b("\" workspace=\"");
protected static final byte[] _jsp_76149 = b("\">\r\n<div id=\"finder-panel\" class=\"form\">\r\n <div class=\"title\"><h4>Language</h4></div>\r\n");
protected static final byte[] _jsp_76150 = b(" <div class=\"form-row\">\r\n <div class=\"form-label\">Language:</div>\r\n <div class=\"form-c300\">\r\n");
protected static final byte[] _jsp_76151 = b(" <div class=\"form-field\">\r\n <select name=\"lang\">\r\n <option value=\"\">Auto</option>\r\n");
protected static final byte[] _jsp_76152 = b(" <option value=\"en\">English</option>\r\n <option value=\"zh_cn\">简体中文</option>\r\n");
protected static final byte[] _jsp_76153 = b(" <option value=\"zh_tw\">繁体中文</option>\r\n <option value=\"ja\">日本語</option>\r\n");
protected static final byte[] _jsp_76154 = b(" </select>\r\n </div>\r\n </div>\r\n <div class=\"form-m300\">\r\n");
protected static final byte[] _jsp_76155 = b(" <div class=\"form-comment\">Language.</div>\r\n </div>\r\n </div>\r\n");
protected static final byte[] _jsp_76156 = b(" <div class=\"button\">\r\n <button id=\"ensure-btn\" class=\"button ensure\">Ok</button>\r\n");
protected static final byte[] _jsp_76157 = b(" </div>\r\n</div>\r\n</body>\r\n</html>\r\n");
}
| UTF-8 | Java | 6,692 | java | LangTemplate.java | Java | [
{
"context": "angTemplate</p>\n * <p>Description: </p>\n * @author JspKit\n * @version 1.0\n */\npublic class LangTemplate ext",
"end": 477,
"score": 0.999544620513916,
"start": 471,
"tag": "USERNAME",
"value": "JspKit"
}
] | null | [] | /*
* $RCSfile: LangTemplate.java,v $
* $Revision: 1.1 $
*
* JSP generated by JspCompiler-1.0.0
* http://www.finderweb.net
*/
package com.skin.finder.servlet.template;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.skin.finder.config.App;
/**
* <p>Title: LangTemplate</p>
* <p>Description: </p>
* @author JspKit
* @version 1.0
*/
public class LangTemplate extends com.skin.finder.web.servlet.JspServlet {
private static final long serialVersionUID = 1L;
private static final LangTemplate instance = new LangTemplate();
/**
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
public static void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
instance.service(request, response);
}
/**
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html; charset=utf-8");
OutputStream out = response.getOutputStream();
out.write(_jsp_76128, 0, _jsp_76128.length);
out.write(_jsp_76129, 0, _jsp_76129.length);
out.write(_jsp_76130, 0, _jsp_76130.length);
out.write(_jsp_76131, 0, _jsp_76131.length);
out.write(_jsp_76132, 0, _jsp_76132.length);
this.write(out, (App.hash()));
out.write(_jsp_76134, 0, _jsp_76134.length);
out.write(_jsp_76135, 0, _jsp_76135.length);
this.write(out, (App.hash()));
out.write(_jsp_76137, 0, _jsp_76137.length);
this.write(out, (App.hash()));
out.write(_jsp_76139, 0, _jsp_76139.length);
this.write(out, (App.hash()));
out.write(_jsp_76141, 0, _jsp_76141.length);
out.write(_jsp_76142, 0, _jsp_76142.length);
out.write(_jsp_76143, 0, _jsp_76143.length);
out.write(_jsp_76144, 0, _jsp_76144.length);
out.write(_jsp_76145, 0, _jsp_76145.length);
this.write(out, request.getAttribute("contextPath"));
out.write(_jsp_76147, 0, _jsp_76147.length);
this.write(out, request.getAttribute("workspace"));
out.write(_jsp_76149, 0, _jsp_76149.length);
out.write(_jsp_76150, 0, _jsp_76150.length);
out.write(_jsp_76151, 0, _jsp_76151.length);
out.write(_jsp_76152, 0, _jsp_76152.length);
out.write(_jsp_76153, 0, _jsp_76153.length);
out.write(_jsp_76154, 0, _jsp_76154.length);
out.write(_jsp_76155, 0, _jsp_76155.length);
out.write(_jsp_76156, 0, _jsp_76156.length);
out.write(_jsp_76157, 0, _jsp_76157.length);
out.flush();
}
protected static final byte[] _jsp_76128 = b("<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\r\n");
protected static final byte[] _jsp_76129 = b("<meta http-equiv=\"Pragma\" content=\"no-cache\"/>\r\n<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>\r\n");
protected static final byte[] _jsp_76130 = b("<meta http-equiv=\"Expires\" content=\"0\"/>\r\n<title>Setting - Powered by FinderWeb</title>\r\n");
protected static final byte[] _jsp_76131 = b("<link rel=\"shortcut icon\" href=\"?action=res&path=/finder/images/favicon.png\"/>\r\n");
protected static final byte[] _jsp_76132 = b("<link rel=\"stylesheet\" type=\"text/css\" href=\"?action=res&path=/finder/css/form.css&v=");
protected static final byte[] _jsp_76134 = b("\"/>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/jquery-1.12.4.min.js\"></script>\r\n");
protected static final byte[] _jsp_76135 = b("<script type=\"text/javascript\" src=\"?action=res&path=/finder/charset.js&v=");
protected static final byte[] _jsp_76137 = b("\"></script>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/colorpicker.js&v=");
protected static final byte[] _jsp_76139 = b("\"></script>\r\n<script type=\"text/javascript\" src=\"?action=res&path=/finder/config.js&v=");
protected static final byte[] _jsp_76141 = b("\"></script>\r\n<script type=\"text/javascript\">\r\n<!--\r\njQuery(function() {\r\n var theme = Finder.getCookie(\"finder_lang\");\r\n");
protected static final byte[] _jsp_76142 = b(" jQuery(\"select[name=lang]\").val(theme);\r\n});\r\n\r\njQuery(function() {\r\n jQuery(\"#ensure-btn\").click(function() {\r\n");
protected static final byte[] _jsp_76143 = b(" var lang = jQuery(\"select[name=lang]\").val();\r\n Finder.setCookie({\"name\": \"finder_lang\", \"value\": lang, \"expires\": 365 * 24 * 60 * 60});\r\n");
protected static final byte[] _jsp_76144 = b(" alert(\"Save successfully, please reload!\");\r\n });\r\n});\r\n//-->\r\n</script>\r\n");
protected static final byte[] _jsp_76145 = b("</head>\r\n<body contextPath=\"");
protected static final byte[] _jsp_76147 = b("\" workspace=\"");
protected static final byte[] _jsp_76149 = b("\">\r\n<div id=\"finder-panel\" class=\"form\">\r\n <div class=\"title\"><h4>Language</h4></div>\r\n");
protected static final byte[] _jsp_76150 = b(" <div class=\"form-row\">\r\n <div class=\"form-label\">Language:</div>\r\n <div class=\"form-c300\">\r\n");
protected static final byte[] _jsp_76151 = b(" <div class=\"form-field\">\r\n <select name=\"lang\">\r\n <option value=\"\">Auto</option>\r\n");
protected static final byte[] _jsp_76152 = b(" <option value=\"en\">English</option>\r\n <option value=\"zh_cn\">简体中文</option>\r\n");
protected static final byte[] _jsp_76153 = b(" <option value=\"zh_tw\">繁体中文</option>\r\n <option value=\"ja\">日本語</option>\r\n");
protected static final byte[] _jsp_76154 = b(" </select>\r\n </div>\r\n </div>\r\n <div class=\"form-m300\">\r\n");
protected static final byte[] _jsp_76155 = b(" <div class=\"form-comment\">Language.</div>\r\n </div>\r\n </div>\r\n");
protected static final byte[] _jsp_76156 = b(" <div class=\"button\">\r\n <button id=\"ensure-btn\" class=\"button ensure\">Ok</button>\r\n");
protected static final byte[] _jsp_76157 = b(" </div>\r\n</div>\r\n</body>\r\n</html>\r\n");
}
| 6,692 | 0.608878 | 0.546491 | 111 | 59.072071 | 56.859192 | 220 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.261261 | false | false | 10 |
20ecf8fd059d2791f854bec956eba10c3856027b | 21,758,304,382,824 | ad74f0807a22e45f0f7d0ddd6ab61b894d1afd61 | /org.vsg.security/src/main/java/org/vsg/security/strategy/ResourcesStrategyHandlerManagerAware.java | 348f228dc35f579a13279963976d1dfb52e91356 | [] | no_license | dalinhuang/vsg-component-hatchery | https://github.com/dalinhuang/vsg-component-hatchery | c15bf620a9a3e5ad6059f1f6cbd968f6db525374 | 9c2774b0a254c37f6ad65ec995ecabbca065bfe5 | refs/heads/master | 2017-12-01T18:01:31.715000 | 2015-10-05T07:09:31 | 2015-10-05T07:09:31 | 60,820,730 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package org.vsg.security.strategy;
import org.vsg.security.ResourcesStrategyHandler;
/**
* @author Bill Vison
*
*/
public interface ResourcesStrategyHandlerManagerAware {
/**
* ioc handler
* @param handler
*/
void setHandler(ResourcesStrategyHandler handler);
}
| UTF-8 | Java | 291 | java | ResourcesStrategyHandlerManagerAware.java | Java | [
{
"context": "security.ResourcesStrategyHandler;\n\n/**\n * @author Bill Vison\n *\n */\npublic interface ResourcesStrategyHandlerM",
"end": 124,
"score": 0.9998677372932434,
"start": 114,
"tag": "NAME",
"value": "Bill Vison"
}
] | null | [] | /**
*
*/
package org.vsg.security.strategy;
import org.vsg.security.ResourcesStrategyHandler;
/**
* @author <NAME>
*
*/
public interface ResourcesStrategyHandlerManagerAware {
/**
* ioc handler
* @param handler
*/
void setHandler(ResourcesStrategyHandler handler);
}
| 287 | 0.707904 | 0.707904 | 20 | 13.55 | 18.186464 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.45 | false | false | 10 |
c3ed1cfe4123f8949b9e3860a4e43c204472d74a | 12,567,074,361,791 | fe1f2c68a0540195b227ebee1621819766ac073b | /OVO_jdgui/org/jetbrains/anko/appcompat/v7/_ButtonBarLayout.java | 52ef81cc6e179d6532ecf114a65bbbafdeb40842 | [] | no_license | Sulley01/KPI_4 | https://github.com/Sulley01/KPI_4 | 41d1fd816a3c0b2ab42cff54a4d83c1d536e19d3 | 04ed45324f255746869510f0b201120bbe4785e3 | refs/heads/master | 2020-03-09T05:03:37.279000 | 2018-04-18T16:52:10 | 2018-04-18T16:52:10 | 128,602,787 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.jetbrains.anko.appcompat.v7;
import android.content.Context;
import android.support.v7.widget.ButtonBarLayout;
import android.util.AttributeSet;
public class _ButtonBarLayout
extends ButtonBarLayout
{
public _ButtonBarLayout(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, null);
}
}
/* Location: C:\dex2jar-2.0\classes-dex2jar.jar!\org\jetbrains\anko\appcompat\v7\_ButtonBarLayout.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | UTF-8 | Java | 527 | java | _ButtonBarLayout.java | Java | [] | null | [] | package org.jetbrains.anko.appcompat.v7;
import android.content.Context;
import android.support.v7.widget.ButtonBarLayout;
import android.util.AttributeSet;
public class _ButtonBarLayout
extends ButtonBarLayout
{
public _ButtonBarLayout(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, null);
}
}
/* Location: C:\dex2jar-2.0\classes-dex2jar.jar!\org\jetbrains\anko\appcompat\v7\_ButtonBarLayout.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | 527 | 0.743833 | 0.717268 | 20 | 25.4 | 29.459124 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35 | false | false | 10 |
0f35d8c396ae1affc3265b821e09d24c0f5403aa | 8,830,452,785,593 | 0677a415f6ab6608f75dd3a259ee8b0a2d25c341 | /reactive-server/src/main/java/henry/jonathan/test/nio/reactive/server/ReactiveServerApplication.java | 3a6c06551eace4377d6810b29ac5bce1acfda838 | [] | no_license | henryyonathan90/nio-web-client-simulation | https://github.com/henryyonathan90/nio-web-client-simulation | 08663dd06aabfb7d5bef21eb73604e7efc9af328 | 7d2d123a18ad335969a30a7e7b5f113adec066dc | refs/heads/master | 2021-07-24T20:37:12.567000 | 2020-09-02T12:49:07 | 2020-09-02T12:49:07 | 214,975,177 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package henry.jonathan.test.nio.reactive.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class ReactiveServerApplication {
public static void main(String[] args) {
SpringApplication.run(ReactiveServerApplication.class, args);
}
}
| UTF-8 | Java | 433 | java | ReactiveServerApplication.java | Java | [] | null | [] | package henry.jonathan.test.nio.reactive.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class ReactiveServerApplication {
public static void main(String[] args) {
SpringApplication.run(ReactiveServerApplication.class, args);
}
}
| 433 | 0.838337 | 0.838337 | 13 | 32.307693 | 25.033468 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 10 |
257205e625fccd7c58bc7e9ed0b5f1a7f78e0085 | 13,314,398,683,482 | e7105213a99df687487e05ec665f53fd431c9973 | /app/src/main/java/com/duong/tokyolife/Model/QLDonHang/QLDonHangModel.java | 097b46b08f62884c96f31478a44fc41074ecd8d7 | [] | no_license | ngocduongnguyen/TokyoLife | https://github.com/ngocduongnguyen/TokyoLife | 487c5df056544f7ba2d2a32116f179c507fd2cfd | a0bf855ba3d49c9f817455399fb2be17f99b2b27 | refs/heads/master | 2020-04-29T07:51:57.401000 | 2019-05-13T00:09:32 | 2019-05-13T00:09:32 | 175,965,830 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.duong.tokyolife.Model.QLDonHang;
import android.util.Log;
import com.duong.tokyolife.Model.ObjectClass.ChiTietDonHang;
import com.duong.tokyolife.Model.ObjectClass.DonHang;
import com.duong.tokyolife.Model.ObjectClass.HoaDon;
import com.duong.tokyolife.Utils.DownloadJSON;
import com.duong.tokyolife.Utils.ServerName;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class QLDonHangModel {
public List<DonHang> layDanhSachDonHang(long idKhachHang){
List<DonHang> ds = new ArrayList<>();
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","layHoaDon");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(idKhachHang));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String dataJSON = downloadJSON.get();
JSONObject jsonObject = new JSONObject(dataJSON);
JSONArray jsonArray = jsonObject.getJSONArray("hoadon");
int count = jsonArray.length();
for (int i=0; i < count; i++){
DonHang donHang = new DonHang();
JSONObject hdJson = jsonArray.getJSONObject(i);
donHang.setMaHD(hdJson.getInt("mahd"));
donHang.setNgayMua(hdJson.getString("ngaymua"));
donHang.setTrangthai(hdJson.getString("trangthai"));
donHang.setTennguoinhan(hdJson.getString("tennguoinhan"));
donHang.setSodt(hdJson.getString("sodt"));
donHang.setDiachi(hdJson.getString("diachi"));
List<ChiTietDonHang> lstChiTiet = new ArrayList<>();
JSONArray chitietJSon = hdJson.getJSONArray("chitietdonhang");
int countCt = chitietJSon.length();
for (int j=0; j < countCt; j++){
ChiTietDonHang chiTietDonHang = new ChiTietDonHang();
chiTietDonHang.setTensp(chitietJSon.getJSONObject(j).getString("tensp"));
chiTietDonHang.setSoluong(chitietJSon.getJSONObject(j).getInt("soluong"));
chiTietDonHang.setGiamgia(chitietJSon.getJSONObject(j).getInt("giamgia"));
chiTietDonHang.setGia(chitietJSon.getJSONObject(j).getInt("gia"));
lstChiTiet.add(chiTietDonHang);
}
donHang.setChiTietDonHang(lstChiTiet);
ds.add(donHang);
}
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return ds;
}
public void huyDonHang(int madh){
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","huyDonHang");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(madh));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String data = downloadJSON.get();
Log.d("kiemtra",data);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void daNhanDonHang(int madh){
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","daNhanDonHang");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(madh));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String data = downloadJSON.get();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 4,468 | java | QLDonHangModel.java | Java | [] | null | [] | package com.duong.tokyolife.Model.QLDonHang;
import android.util.Log;
import com.duong.tokyolife.Model.ObjectClass.ChiTietDonHang;
import com.duong.tokyolife.Model.ObjectClass.DonHang;
import com.duong.tokyolife.Model.ObjectClass.HoaDon;
import com.duong.tokyolife.Utils.DownloadJSON;
import com.duong.tokyolife.Utils.ServerName;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class QLDonHangModel {
public List<DonHang> layDanhSachDonHang(long idKhachHang){
List<DonHang> ds = new ArrayList<>();
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","layHoaDon");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(idKhachHang));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String dataJSON = downloadJSON.get();
JSONObject jsonObject = new JSONObject(dataJSON);
JSONArray jsonArray = jsonObject.getJSONArray("hoadon");
int count = jsonArray.length();
for (int i=0; i < count; i++){
DonHang donHang = new DonHang();
JSONObject hdJson = jsonArray.getJSONObject(i);
donHang.setMaHD(hdJson.getInt("mahd"));
donHang.setNgayMua(hdJson.getString("ngaymua"));
donHang.setTrangthai(hdJson.getString("trangthai"));
donHang.setTennguoinhan(hdJson.getString("tennguoinhan"));
donHang.setSodt(hdJson.getString("sodt"));
donHang.setDiachi(hdJson.getString("diachi"));
List<ChiTietDonHang> lstChiTiet = new ArrayList<>();
JSONArray chitietJSon = hdJson.getJSONArray("chitietdonhang");
int countCt = chitietJSon.length();
for (int j=0; j < countCt; j++){
ChiTietDonHang chiTietDonHang = new ChiTietDonHang();
chiTietDonHang.setTensp(chitietJSon.getJSONObject(j).getString("tensp"));
chiTietDonHang.setSoluong(chitietJSon.getJSONObject(j).getInt("soluong"));
chiTietDonHang.setGiamgia(chitietJSon.getJSONObject(j).getInt("giamgia"));
chiTietDonHang.setGia(chitietJSon.getJSONObject(j).getInt("gia"));
lstChiTiet.add(chiTietDonHang);
}
donHang.setChiTietDonHang(lstChiTiet);
ds.add(donHang);
}
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
return ds;
}
public void huyDonHang(int madh){
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","huyDonHang");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(madh));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String data = downloadJSON.get();
Log.d("kiemtra",data);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void daNhanDonHang(int madh){
List<HashMap<String,String>> attrs = new ArrayList<>();
HashMap<String,String> goiham = new HashMap<>();
goiham.put("goiham","daNhanDonHang");
HashMap<String,String> id = new HashMap<>();
id.put("id", String.valueOf(madh));
Collections.addAll(attrs,goiham,id);
DownloadJSON downloadJSON = new DownloadJSON(ServerName.SERVER_NAME,attrs);
downloadJSON.execute();
try {
String data = downloadJSON.get();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
| 4,468 | 0.616383 | 0.615936 | 112 | 38.892857 | 24.117405 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.919643 | false | false | 10 |
e0db5222b09460407039ce23498a29d25a166472 | 13,314,398,686,896 | 8c37bbf70bf8b5988c1a83649fbd17b4453fb329 | /src/main/java/cn/chinaunicom/posstandardpos/service/PosSposVService.java | 756e93777c100748f3a68478a602001b8b02d7ca | [] | no_license | zuohw1/post | https://github.com/zuohw1/post | d7c3559758b065af57419af8db89ce74804d0c86 | 5617b8e850b86fedb5ca825f1eaa8ae53286f7f0 | refs/heads/master | 2020-04-03T18:24:05.338000 | 2018-12-11T15:13:30 | 2018-12-11T15:13:30 | 155,482,484 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.chinaunicom.posstandardpos.service;
import cn.chinaunicom.posstandardpos.entity.PosSposV;
import cn.chinaunicom.platform.service.IHrService;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* VIEW 服务类
* </p>
*
* @author zhangchi
* @since 2018-11-22
*/
public interface PosSposVService extends IHrService<PosSposV> {
public List<PosSposV> getPosSposVList();
public Integer savePosSposV(PosSposV entity);
public Integer updatePosSposV(PosSposV entity);
public Integer deletePosSposV(Long id);
Integer searchProvincePostListCount(HashMap<Object, Object> params);
}
| UTF-8 | Java | 612 | java | PosSposVService.java | Java | [
{
"context": "ist;\n\n/**\n * <p>\n * VIEW 服务类\n * </p>\n *\n * @author zhangchi\n * @since 2018-11-22\n */\npublic interface PosSpos",
"end": 257,
"score": 0.9989091753959656,
"start": 249,
"tag": "USERNAME",
"value": "zhangchi"
}
] | null | [] | package cn.chinaunicom.posstandardpos.service;
import cn.chinaunicom.posstandardpos.entity.PosSposV;
import cn.chinaunicom.platform.service.IHrService;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* VIEW 服务类
* </p>
*
* @author zhangchi
* @since 2018-11-22
*/
public interface PosSposVService extends IHrService<PosSposV> {
public List<PosSposV> getPosSposVList();
public Integer savePosSposV(PosSposV entity);
public Integer updatePosSposV(PosSposV entity);
public Integer deletePosSposV(Long id);
Integer searchProvincePostListCount(HashMap<Object, Object> params);
}
| 612 | 0.770627 | 0.757426 | 28 | 20.642857 | 22.381775 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.678571 | false | false | 10 |
07ef14b3317b4cab70b5a5d55ce75fb153eb5f63 | 32,049,046,000,305 | faccd9e4855cf1748ed08d8c36e7a0443b5aa3ff | /13주차/서울 지하철 2호선/김진수/BJ_16947.java | 4cb6dc74ca22117a707a4d218b46e90c164136a0 | [] | no_license | CodeJin19/SSAFYSeoul7AlgoStudy1 | https://github.com/CodeJin19/SSAFYSeoul7AlgoStudy1 | e1cdc58c9aac0aeb440dbd0c26ae9e9f2534a207 | bd520d3217ca1007cf80bf5e4d2c2709e09ed74c | refs/heads/main | 2023-06-21T01:10:21.073000 | 2021-08-01T18:56:04 | 2021-08-01T18:56:04 | 336,250,861 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ssafy.algoStudy_13;
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class BJ_16947 {
static ArrayList<Integer> link[];
static int degree1[];
static int degree2[];
static int ans[];
static boolean isCycle[];
static boolean isVisited[];
static void check(int idx) {
if (2 < degree2[idx]) {
degree2[idx] -= 1;
return;
}
isCycle[idx] = false;
isVisited[idx] = true;
int len = link[idx].size();
for (int i = 0; i < len; i++)
if (!isVisited[link[idx].get(i)])
check(link[idx].get(i));
}
static void setLen(int idx, int len) {
ans[idx] = len;
isVisited[idx] = true;
int size = link[idx].size();
for (int i = 0; i < size; i++)
if (!isVisited[link[idx].get(i)])
setLen(link[idx].get(i), len + 1);
}
static void startFrom(int idx) {
int len = link[idx].size();
for (int i = 0; i < len; i++)
if (!isCycle[link[idx].get(i)])
setLen(link[idx].get(i), 1);
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(reader.readLine());
link = new ArrayList[n + 1];
degree1 = new int[n + 1];
degree2 = new int[n + 1];
ans = new int[n + 1];
isCycle = new boolean[n + 1];
isVisited = new boolean[n + 1];
int from, to, idx;
boolean flag;
for (int i = 1; i <= n; i++) {
link[i] = new ArrayList<Integer>();
}
for (int i = 0; i < n; i++) {
st = new StringTokenizer(reader.readLine());
from = Integer.parseInt(st.nextToken());
to = Integer.parseInt(st.nextToken());
link[from].add(to);
link[to].add(from);
degree1[from] += 1;
degree1[to] += 1;
degree2[from] += 1;
degree2[to] += 1;
}
flag = true;
while (flag) {
flag = false;
for (int i = 1; i <= n; i++) {
if (degree2[i] == 1 && !isVisited[i]) {
flag = true;
isCycle[i] = false;
isVisited[i] = true;
check(link[i].get(0));
}
}
}
for (int i = 1; i <= n; i++)
if (!isVisited[i])
isCycle[i] = true;
isVisited = new boolean[n + 1];
for (int i = 1; i <= n; i++) {
if (isCycle[i]) {
isVisited[i] = true;
if (2 < degree1[i]) {
startFrom(i);
}
}
}
// for (int i = 1; i <= n; i++)
// if (degree2[i] == 1 && ans[i] == 0)
// ans[i] = getLen(link[i].get(0), i);
for (int i = 1; i <= n; i++) {
System.out.print(ans[i] + " ");
}
System.out.println();
}
}
| UTF-8 | Java | 2,516 | java | BJ_16947.java | Java | [] | null | [] | package com.ssafy.algoStudy_13;
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class BJ_16947 {
static ArrayList<Integer> link[];
static int degree1[];
static int degree2[];
static int ans[];
static boolean isCycle[];
static boolean isVisited[];
static void check(int idx) {
if (2 < degree2[idx]) {
degree2[idx] -= 1;
return;
}
isCycle[idx] = false;
isVisited[idx] = true;
int len = link[idx].size();
for (int i = 0; i < len; i++)
if (!isVisited[link[idx].get(i)])
check(link[idx].get(i));
}
static void setLen(int idx, int len) {
ans[idx] = len;
isVisited[idx] = true;
int size = link[idx].size();
for (int i = 0; i < size; i++)
if (!isVisited[link[idx].get(i)])
setLen(link[idx].get(i), len + 1);
}
static void startFrom(int idx) {
int len = link[idx].size();
for (int i = 0; i < len; i++)
if (!isCycle[link[idx].get(i)])
setLen(link[idx].get(i), 1);
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(reader.readLine());
link = new ArrayList[n + 1];
degree1 = new int[n + 1];
degree2 = new int[n + 1];
ans = new int[n + 1];
isCycle = new boolean[n + 1];
isVisited = new boolean[n + 1];
int from, to, idx;
boolean flag;
for (int i = 1; i <= n; i++) {
link[i] = new ArrayList<Integer>();
}
for (int i = 0; i < n; i++) {
st = new StringTokenizer(reader.readLine());
from = Integer.parseInt(st.nextToken());
to = Integer.parseInt(st.nextToken());
link[from].add(to);
link[to].add(from);
degree1[from] += 1;
degree1[to] += 1;
degree2[from] += 1;
degree2[to] += 1;
}
flag = true;
while (flag) {
flag = false;
for (int i = 1; i <= n; i++) {
if (degree2[i] == 1 && !isVisited[i]) {
flag = true;
isCycle[i] = false;
isVisited[i] = true;
check(link[i].get(0));
}
}
}
for (int i = 1; i <= n; i++)
if (!isVisited[i])
isCycle[i] = true;
isVisited = new boolean[n + 1];
for (int i = 1; i <= n; i++) {
if (isCycle[i]) {
isVisited[i] = true;
if (2 < degree1[i]) {
startFrom(i);
}
}
}
// for (int i = 1; i <= n; i++)
// if (degree2[i] == 1 && ans[i] == 0)
// ans[i] = getLen(link[i].get(0), i);
for (int i = 1; i <= n; i++) {
System.out.print(ans[i] + " ");
}
System.out.println();
}
}
| 2,516 | 0.562401 | 0.54213 | 122 | 19.622952 | 16.117056 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.516393 | false | false | 10 |
fca209b52a8c82d21bbbca4edca6673ee86e3131 | 32,049,046,004,775 | 803a91530ba9bd3a145f87ed5fb618203264f9ba | /Spring/spring-food-service/src/main/java/com/example/demo/entity/Recipe.java | f8e9d18017e520b4986ae3356b7fa9e131ce431c | [] | no_license | Ajeetgiri/ibm-fsd-000gel | https://github.com/Ajeetgiri/ibm-fsd-000gel | 271f9b5211c5978e6064067b8a9cd2b09eaeb8cb | d544d2c5dfd2dc353f6845b1a471c87746fc41b9 | refs/heads/master | 2023-01-12T13:39:49.141000 | 2019-09-18T12:08:12 | 2019-09-18T12:08:12 | 195,184,899 | 0 | 0 | null | false | 2023-01-07T08:53:01 | 2019-07-04T06:48:43 | 2019-09-18T12:11:32 | 2023-01-07T08:53:01 | 88,228 | 0 | 0 | 95 | JavaScript | false | false | package com.example.demo.entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
@Entity
public class Recipe {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String cook_time, difficulty, name;
private int Serving;
@OneToOne
private Note note;
@ManyToMany
@JoinTable(name = "recipe_ingredient", joinColumns = @JoinColumn(name = "recipe_id"), inverseJoinColumns = @JoinColumn(name = "indredient_id"))
private Set<Ingredient> ingredient = new HashSet<Ingredient>();
public Recipe(String cook_time, String difficulty, int serving, Set<Ingredient> ingredient) {
super();
this.cook_time = cook_time;
this.difficulty = difficulty;
Serving = serving;
this.ingredient = ingredient;
}
public Set<Ingredient> getIngredient() {
return ingredient;
}
public void setIngredient(Set<Ingredient> ingredient) {
this.ingredient = ingredient;
}
public Recipe(String name, String cook_time, String difficulty, int serving, Note note) {
super();
this.cook_time = cook_time;
this.difficulty = difficulty;
Serving = serving;
this.name = name;
this.note = note;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Recipe() {
super();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCook_time() {
return cook_time;
}
public void setCook_time(String cook_time) {
this.cook_time = cook_time;
}
public String getDifficulty() {
return difficulty;
}
public void setDifficulty(String difficulty) {
this.difficulty = difficulty;
}
public int getServing() {
return Serving;
}
public void setServing(int serving) {
Serving = serving;
}
}
| UTF-8 | Java | 2,039 | java | Recipe.java | Java | [] | null | [] | package com.example.demo.entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
@Entity
public class Recipe {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String cook_time, difficulty, name;
private int Serving;
@OneToOne
private Note note;
@ManyToMany
@JoinTable(name = "recipe_ingredient", joinColumns = @JoinColumn(name = "recipe_id"), inverseJoinColumns = @JoinColumn(name = "indredient_id"))
private Set<Ingredient> ingredient = new HashSet<Ingredient>();
public Recipe(String cook_time, String difficulty, int serving, Set<Ingredient> ingredient) {
super();
this.cook_time = cook_time;
this.difficulty = difficulty;
Serving = serving;
this.ingredient = ingredient;
}
public Set<Ingredient> getIngredient() {
return ingredient;
}
public void setIngredient(Set<Ingredient> ingredient) {
this.ingredient = ingredient;
}
public Recipe(String name, String cook_time, String difficulty, int serving, Note note) {
super();
this.cook_time = cook_time;
this.difficulty = difficulty;
Serving = serving;
this.name = name;
this.note = note;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Recipe() {
super();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCook_time() {
return cook_time;
}
public void setCook_time(String cook_time) {
this.cook_time = cook_time;
}
public String getDifficulty() {
return difficulty;
}
public void setDifficulty(String difficulty) {
this.difficulty = difficulty;
}
public int getServing() {
return Serving;
}
public void setServing(int serving) {
Serving = serving;
}
}
| 2,039 | 0.725356 | 0.725356 | 102 | 18.990196 | 22.541681 | 144 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.362745 | false | false | 10 |
c8fff5655b9d52b7e947be913ad0d6d239a76cef | 24,215,025,661,325 | de05085d86345bd3e1dc399cefbf714cfefca971 | /src/priv/wzb/design_pattern/createdpattern/builderpattern/example/Actor.java | d4cc5f67ef4f56ba3bdfdca61c4ce7daaa285eaf | [] | no_license | luoziling/Design_Pattern | https://github.com/luoziling/Design_Pattern | 97e432690cb54d32bb1645a96c2c4b2c81ae2dcf | a74d46be514aafd4a1ec9308e9aec3b108f441af | refs/heads/master | 2022-08-09T04:55:35.275000 | 2021-12-22T09:31:06 | 2021-12-22T09:31:06 | 207,322,291 | 3 | 0 | null | false | 2022-07-15T21:10:05 | 2019-09-09T13:58:21 | 2021-12-22T09:30:09 | 2022-07-15T21:10:05 | 102,362 | 0 | 0 | 8 | Java | false | false | package priv.wzb.design_pattern.createdpattern.builderpattern.example;
/**
* @author Satsuki
* @time 2019/6/25 16:00
* @description:
*/
public class Actor {
private String type; //角色类型
private String sex; //性别
private String face; //脸型
private String costume; //服装
private String hairstyle; //发型
public void setType(String type) {
this.type = type;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setFace(String face) {
this.face = face;
}
public void setCostume(String costume) {
this.costume = costume;
}
public void setHairstyle(String hairstyle) {
this.hairstyle = hairstyle;
}
public String getType() {
return (this.type);
}
public String getSex() {
return (this.sex);
}
public String getFace() {
return (this.face);
}
public String getCostume() {
return (this.costume);
}
public String getHairstyle() {
return (this.hairstyle);
}
}
| UTF-8 | Java | 1,090 | java | Actor.java | Java | [
{
"context": "tedpattern.builderpattern.example;\n\n/**\n * @author Satsuki\n * @time 2019/6/25 16:00\n * @description:\n */\npub",
"end": 94,
"score": 0.9986228346824646,
"start": 87,
"tag": "NAME",
"value": "Satsuki"
}
] | null | [] | package priv.wzb.design_pattern.createdpattern.builderpattern.example;
/**
* @author Satsuki
* @time 2019/6/25 16:00
* @description:
*/
public class Actor {
private String type; //角色类型
private String sex; //性别
private String face; //脸型
private String costume; //服装
private String hairstyle; //发型
public void setType(String type) {
this.type = type;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setFace(String face) {
this.face = face;
}
public void setCostume(String costume) {
this.costume = costume;
}
public void setHairstyle(String hairstyle) {
this.hairstyle = hairstyle;
}
public String getType() {
return (this.type);
}
public String getSex() {
return (this.sex);
}
public String getFace() {
return (this.face);
}
public String getCostume() {
return (this.costume);
}
public String getHairstyle() {
return (this.hairstyle);
}
}
| 1,090 | 0.584428 | 0.574109 | 45 | 22.688889 | 15.652933 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.355556 | false | false | 10 |
37281fe8cb2dfd288e65ecba711d7262539bef75 | 5,488,968,261,829 | 919d67d8deded96ace1b4771e660190118f29b97 | /java/revenj-core/src/main/java/org/revenj/database/postgres/converters/LongConverter.java | a3d5f6916a1e0b79a770218836ed2119101d4647 | [
"BSD-3-Clause"
] | permissive | ngs-doo/revenj | https://github.com/ngs-doo/revenj | c7aca9bc3c674b80c1e782972bfc4c2a18dee922 | dc79ce87b2a65b01689fafeab53509fea3706897 | refs/heads/master | 2023-07-05T18:35:33.293000 | 2023-05-25T13:21:11 | 2023-05-25T13:21:11 | 16,438,138 | 282 | 47 | BSD-3-Clause | false | 2023-05-25T13:21:12 | 2014-02-01T17:03:15 | 2023-03-09T13:38:52 | 2023-05-25T13:21:11 | 24,330 | 265 | 43 | 13 | C# | false | false | package org.revenj.database.postgres.converters;
import org.revenj.database.postgres.PostgresBuffer;
import org.revenj.database.postgres.PostgresReader;
import org.revenj.database.postgres.PostgresWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public abstract class LongConverter {
public static void serializeURI(PostgresBuffer sw, long value) throws IOException {
if (value == Long.MIN_VALUE) {
sw.addToBuffer("-9223372036854775808");
} else {
int offset = NumberConverter.serialize(value, sw.getTempBuffer());
sw.addToBuffer(sw.getTempBuffer(), offset, 21);
}
}
public static void serializeURI(PostgresBuffer sw, Long value) throws IOException {
if (value == null) return;
serializeURI(sw, value.longValue());
}
public static Long parseNullable(PostgresReader reader) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return null;
}
return parseLong(reader, cur, ')');
}
public static long parse(PostgresReader reader) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return 0L;
}
return parseLong(reader, cur, ')');
}
private static long parseLong(PostgresReader reader, int cur, char matchEnd) {
long res = 0;
if (cur == '-') {
cur = reader.read();
do {
res = (res << 3) + (res << 1) - (cur - 48);
cur = reader.read();
} while (cur != -1 && cur != ',' && cur != matchEnd);
} else {
do {
res = (res << 3) + (res << 1) + (cur - 48);
cur = reader.read();
} while (cur != -1 && cur != ',' && cur != matchEnd);
}
return res;
}
public static List<Long> parseCollection(PostgresReader reader, int context, boolean allowNulls) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return null;
}
boolean escaped = cur != '{';
if (escaped) {
reader.read(context);
}
cur = reader.peek();
if (cur == '}') {
if (escaped) {
reader.read(context + 2);
} else {
reader.read(2);
}
return new ArrayList<>(0);
}
Long defaultValue = allowNulls ? null : 0L;
List<Long> list = new ArrayList<>();
do {
cur = reader.read();
if (cur == 'N') {
list.add(defaultValue);
cur = reader.read(4);
} else {
list.add(parseLong(reader, cur, '}'));
cur = reader.last();
}
} while (cur == ',');
if (escaped) {
reader.read(context + 1);
} else {
reader.read();
}
return list;
}
private static final PostgresTuple MIN_TUPLE = new ValueTuple("-9223372036854775808", false, false);
public static PostgresTuple toTuple(Long value) {
return value == null ? null : toTuple(value.longValue());
}
public static PostgresTuple toTuple(long value) {
if (value == Long.MIN_VALUE) {
return MIN_TUPLE;
}
return new LongTuple(value);
}
private static class LongTuple extends PostgresTuple {
private final long value;
LongTuple(long value) {
this.value = value;
}
public boolean mustEscapeRecord() {
return false;
}
public boolean mustEscapeArray() {
return false;
}
public void insertRecord(PostgresWriter sw, String escaping, Mapping mappings) {
int offset = NumberConverter.serialize(value, sw.tmp);
sw.write(sw.tmp, offset, 21);
}
public String buildTuple(boolean quote) {
return Long.toString(value);
}
}
}
| UTF-8 | Java | 3,425 | java | LongConverter.java | Java | [] | null | [] | package org.revenj.database.postgres.converters;
import org.revenj.database.postgres.PostgresBuffer;
import org.revenj.database.postgres.PostgresReader;
import org.revenj.database.postgres.PostgresWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public abstract class LongConverter {
public static void serializeURI(PostgresBuffer sw, long value) throws IOException {
if (value == Long.MIN_VALUE) {
sw.addToBuffer("-9223372036854775808");
} else {
int offset = NumberConverter.serialize(value, sw.getTempBuffer());
sw.addToBuffer(sw.getTempBuffer(), offset, 21);
}
}
public static void serializeURI(PostgresBuffer sw, Long value) throws IOException {
if (value == null) return;
serializeURI(sw, value.longValue());
}
public static Long parseNullable(PostgresReader reader) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return null;
}
return parseLong(reader, cur, ')');
}
public static long parse(PostgresReader reader) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return 0L;
}
return parseLong(reader, cur, ')');
}
private static long parseLong(PostgresReader reader, int cur, char matchEnd) {
long res = 0;
if (cur == '-') {
cur = reader.read();
do {
res = (res << 3) + (res << 1) - (cur - 48);
cur = reader.read();
} while (cur != -1 && cur != ',' && cur != matchEnd);
} else {
do {
res = (res << 3) + (res << 1) + (cur - 48);
cur = reader.read();
} while (cur != -1 && cur != ',' && cur != matchEnd);
}
return res;
}
public static List<Long> parseCollection(PostgresReader reader, int context, boolean allowNulls) {
int cur = reader.read();
if (cur == ',' || cur == ')') {
return null;
}
boolean escaped = cur != '{';
if (escaped) {
reader.read(context);
}
cur = reader.peek();
if (cur == '}') {
if (escaped) {
reader.read(context + 2);
} else {
reader.read(2);
}
return new ArrayList<>(0);
}
Long defaultValue = allowNulls ? null : 0L;
List<Long> list = new ArrayList<>();
do {
cur = reader.read();
if (cur == 'N') {
list.add(defaultValue);
cur = reader.read(4);
} else {
list.add(parseLong(reader, cur, '}'));
cur = reader.last();
}
} while (cur == ',');
if (escaped) {
reader.read(context + 1);
} else {
reader.read();
}
return list;
}
private static final PostgresTuple MIN_TUPLE = new ValueTuple("-9223372036854775808", false, false);
public static PostgresTuple toTuple(Long value) {
return value == null ? null : toTuple(value.longValue());
}
public static PostgresTuple toTuple(long value) {
if (value == Long.MIN_VALUE) {
return MIN_TUPLE;
}
return new LongTuple(value);
}
private static class LongTuple extends PostgresTuple {
private final long value;
LongTuple(long value) {
this.value = value;
}
public boolean mustEscapeRecord() {
return false;
}
public boolean mustEscapeArray() {
return false;
}
public void insertRecord(PostgresWriter sw, String escaping, Mapping mappings) {
int offset = NumberConverter.serialize(value, sw.tmp);
sw.write(sw.tmp, offset, 21);
}
public String buildTuple(boolean quote) {
return Long.toString(value);
}
}
}
| 3,425 | 0.610511 | 0.592993 | 135 | 23.370371 | 22.541727 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.503704 | false | false | 10 |
f9bd98485df9b2d35e6d49d96154886b33bee607 | 21,930,103,014,900 | dd6799b6265f5a6677702f975277bd08609f98bd | /webclient/src/main/java/com/agorikov/rsdnhome/model/ComposedMessage.java | 0c284a1c5768f4068564472a3d96ab2c41ce7861 | [] | no_license | mnba/anusai-android | https://github.com/mnba/anusai-android | efd55c96cf69772e82d774d5dffd75559a342e69 | 9a8be70ad394dc78c4dcaefa853a875ca84b701d | refs/heads/master | 2021-05-28T18:55:13.813000 | 2012-07-11T09:25:57 | 2012-07-11T09:25:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.agorikov.rsdnhome.model;
import com.agorikov.rsdnhome.common.Builder;
public final class ComposedMessage implements ComposedMessageEntity {
private final long id;
private final Long parentId;
private final Long forumId;
private final String subj;
private final String body;
private ComposedMessage(final long id, final Long parentId, long forumId,
final String subj, final String body) {
this.id = id;
this.parentId = parentId;
this.forumId = forumId;
this.subj = subj;
this.body = body;
}
public long getId() {
return id;
}
public Long getParentId() {
return parentId;
}
public long getForumId() {
return forumId;
}
public String getSubj() {
return subj;
}
public String getBody() {
return body;
}
public static final class ComposedMessageBuilder implements Builder<ComposedMessage> {
private Long id;
private Long parentId;
private Long forumId;
private String subj;
private String body;
public ComposedMessageBuilder id(long id) {
this.id = id;
return this;
}
public ComposedMessageBuilder parentId(Long parentId) {
this.parentId = parentId;
return this;
}
public ComposedMessageBuilder forumId(long forumId) {
this.forumId = forumId;
return this;
}
public ComposedMessageBuilder subj(String subj) {
this.subj = subj;
return this;
}
public ComposedMessageBuilder body(String body) {
this.body = body;
return this;
}
void reset() {
this.id = null;
this.parentId = null;
this.forumId = null;
this.subj = null;
this.body = null;
}
@Override
public ComposedMessage build() {
try {
return new ComposedMessage(id, parentId, forumId, subj, body);
} finally {
reset();
}
}
public static ComposedMessageBuilder create() {
return new ComposedMessageBuilder();
}
}
}
| UTF-8 | Java | 1,857 | java | ComposedMessage.java | Java | [] | null | [] | package com.agorikov.rsdnhome.model;
import com.agorikov.rsdnhome.common.Builder;
public final class ComposedMessage implements ComposedMessageEntity {
private final long id;
private final Long parentId;
private final Long forumId;
private final String subj;
private final String body;
private ComposedMessage(final long id, final Long parentId, long forumId,
final String subj, final String body) {
this.id = id;
this.parentId = parentId;
this.forumId = forumId;
this.subj = subj;
this.body = body;
}
public long getId() {
return id;
}
public Long getParentId() {
return parentId;
}
public long getForumId() {
return forumId;
}
public String getSubj() {
return subj;
}
public String getBody() {
return body;
}
public static final class ComposedMessageBuilder implements Builder<ComposedMessage> {
private Long id;
private Long parentId;
private Long forumId;
private String subj;
private String body;
public ComposedMessageBuilder id(long id) {
this.id = id;
return this;
}
public ComposedMessageBuilder parentId(Long parentId) {
this.parentId = parentId;
return this;
}
public ComposedMessageBuilder forumId(long forumId) {
this.forumId = forumId;
return this;
}
public ComposedMessageBuilder subj(String subj) {
this.subj = subj;
return this;
}
public ComposedMessageBuilder body(String body) {
this.body = body;
return this;
}
void reset() {
this.id = null;
this.parentId = null;
this.forumId = null;
this.subj = null;
this.body = null;
}
@Override
public ComposedMessage build() {
try {
return new ComposedMessage(id, parentId, forumId, subj, body);
} finally {
reset();
}
}
public static ComposedMessageBuilder create() {
return new ComposedMessageBuilder();
}
}
}
| 1,857 | 0.693053 | 0.693053 | 95 | 18.547369 | 18.540861 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.273684 | false | false | 10 |
9f35e9c476ffd0d1b4784d46922fe0396a2b6570 | 506,806,145,068 | 41fe1002994257ed0888419af194e238ce678580 | /src/gui_tables/ChainTablePanel.java | 66366314bbd09167725c9e8047b797a81d9f3e4a | [] | no_license | savchukndr/AdminPanel | https://github.com/savchukndr/AdminPanel | c31824b50f510471079ad3825aa2bdc0bc8fb961 | 31d59434dd9caa42ba95349a676202a4c8f27642 | refs/heads/master | 2020-03-12T05:16:49.387000 | 2018-10-14T12:09:43 | 2018-10-14T12:09:43 | 130,460,664 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gui_tables;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import database.ChainDbTable;
import dialog_frames.*;
import gui.MainFrame;
import gui_panels.ChainPanel;
import main.Main;
public class ChainTablePanel extends JPanel {
private JTable table;
private ChainDbTable chainDbTable;
//CONSTRUCTOR
public ChainTablePanel() {
setLayout(new BorderLayout());
JPanel panelTop = new JPanel(); // EventQueue.invokeLater(() -> panelTop = new JPanel());
panelTop.setLayout(new GridBagLayout());
JPanel panelBottom = new JPanel();
panelBottom.setLayout(new GridBagLayout());
JButton buttonAddChain = new JButton("Add Chain");
buttonAddChain.addActionListener(this::addActionPerformed);
JButton buttonDeleteChain = new JButton("Delete Chain");
buttonDeleteChain.addActionListener(this::deleteActionPerformed);
table = new JTable();
JScrollPane scrollTable = new JScrollPane(table);
scrollTable.setViewportView(table);
panelTop.add(scrollTable);
panelBottom.add(buttonDeleteChain);
panelBottom.add(buttonAddChain);
//THE MODEL OF OUR TABLE
DefaultTableModel model = new DefaultTableModel() {
public Class<?> getColumnClass(int column) {
switch (column) {
case 0:
return Boolean.class;
case 1:
return String.class;
case 2:
return String.class;
default:
return String.class;
}
}
};
//ASSIGN THE MODEL TO TABLE
table.setModel(model);
model.addColumn("Select");
model.addColumn("ChainID");
model.addColumn("Chain");
chainDbTable = new ChainDbTable();
try {
ResultSet resultSet = chainDbTable.selectAll();
HashMap<String, String> chainMap = new HashMap<>();
while (resultSet.next()) {
chainMap.put(resultSet.getString("id"), resultSet.getString("name").trim());
}
//THE ROW
int count = 0;
for (String key : chainMap.keySet()) {
model.addRow(new Object[0]);
model.setValueAt(false, count, 0);
model.setValueAt(key, count, 1);
model.setValueAt(chainMap.get(key), count, 2);
count++;
}
} catch (NullPointerException | SQLException ignored) {
}
//ADD BUTTON TO FORM
buttonDeleteChain.setBounds(20, 30, 130, 30);
add(panelTop, BorderLayout.CENTER);
add(panelBottom, BorderLayout.SOUTH);
}
private void deleteActionPerformed(ActionEvent e) {
for (int i = 0; i < table.getRowCount(); i++) {
Boolean checked = Boolean.valueOf(table.getValueAt(i, 0).toString());
String chainId = table.getValueAt(i, 2).toString();
//DISPLAY
if (checked) {
chainDbTable.deleteRow(chainId);
JOptionPane.showMessageDialog(null, "Deleted: " + chainId);
}
}
MainFrame mainFrame = Main.getMainFrame();
ChainPanel chainPanel = mainFrame.getChainPanel();
chainPanel.remove(this);
chainPanel.revalidate();
chainPanel.repaint();
chainPanel.add(new ChainTablePanel());
}
private void addActionPerformed(ActionEvent e) {
AddChainFrame dialogFrame = new AddChainFrame(this);
dialogFrame.show();
}
} | UTF-8 | Java | 3,809 | java | ChainTablePanel.java | Java | [] | null | [] | package gui_tables;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import database.ChainDbTable;
import dialog_frames.*;
import gui.MainFrame;
import gui_panels.ChainPanel;
import main.Main;
public class ChainTablePanel extends JPanel {
private JTable table;
private ChainDbTable chainDbTable;
//CONSTRUCTOR
public ChainTablePanel() {
setLayout(new BorderLayout());
JPanel panelTop = new JPanel(); // EventQueue.invokeLater(() -> panelTop = new JPanel());
panelTop.setLayout(new GridBagLayout());
JPanel panelBottom = new JPanel();
panelBottom.setLayout(new GridBagLayout());
JButton buttonAddChain = new JButton("Add Chain");
buttonAddChain.addActionListener(this::addActionPerformed);
JButton buttonDeleteChain = new JButton("Delete Chain");
buttonDeleteChain.addActionListener(this::deleteActionPerformed);
table = new JTable();
JScrollPane scrollTable = new JScrollPane(table);
scrollTable.setViewportView(table);
panelTop.add(scrollTable);
panelBottom.add(buttonDeleteChain);
panelBottom.add(buttonAddChain);
//THE MODEL OF OUR TABLE
DefaultTableModel model = new DefaultTableModel() {
public Class<?> getColumnClass(int column) {
switch (column) {
case 0:
return Boolean.class;
case 1:
return String.class;
case 2:
return String.class;
default:
return String.class;
}
}
};
//ASSIGN THE MODEL TO TABLE
table.setModel(model);
model.addColumn("Select");
model.addColumn("ChainID");
model.addColumn("Chain");
chainDbTable = new ChainDbTable();
try {
ResultSet resultSet = chainDbTable.selectAll();
HashMap<String, String> chainMap = new HashMap<>();
while (resultSet.next()) {
chainMap.put(resultSet.getString("id"), resultSet.getString("name").trim());
}
//THE ROW
int count = 0;
for (String key : chainMap.keySet()) {
model.addRow(new Object[0]);
model.setValueAt(false, count, 0);
model.setValueAt(key, count, 1);
model.setValueAt(chainMap.get(key), count, 2);
count++;
}
} catch (NullPointerException | SQLException ignored) {
}
//ADD BUTTON TO FORM
buttonDeleteChain.setBounds(20, 30, 130, 30);
add(panelTop, BorderLayout.CENTER);
add(panelBottom, BorderLayout.SOUTH);
}
private void deleteActionPerformed(ActionEvent e) {
for (int i = 0; i < table.getRowCount(); i++) {
Boolean checked = Boolean.valueOf(table.getValueAt(i, 0).toString());
String chainId = table.getValueAt(i, 2).toString();
//DISPLAY
if (checked) {
chainDbTable.deleteRow(chainId);
JOptionPane.showMessageDialog(null, "Deleted: " + chainId);
}
}
MainFrame mainFrame = Main.getMainFrame();
ChainPanel chainPanel = mainFrame.getChainPanel();
chainPanel.remove(this);
chainPanel.revalidate();
chainPanel.repaint();
chainPanel.add(new ChainTablePanel());
}
private void addActionPerformed(ActionEvent e) {
AddChainFrame dialogFrame = new AddChainFrame(this);
dialogFrame.show();
}
} | 3,809 | 0.588606 | 0.583355 | 117 | 31.564102 | 22.406265 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.717949 | false | false | 10 |
8821a9398b56104133f95364fbc9f0335103eb4c | 13,374,528,179,242 | 618a92177a99d6a17f21512a693a50bf62500d4c | /src/main/java/com.saltedfish/algorithms/LeetCode2154.java | c158bab7fcd5442b7fd49a90aae17788da63a99d | [] | no_license | DangOYear/LeetCodeJava | https://github.com/DangOYear/LeetCodeJava | ac73f8dbb23054cdf308e1f18e2c595c84e33e2a | 643184bec8366959fcd03a853c46aaae3d778ac0 | refs/heads/master | 2023-02-09T06:21:05.703000 | 2023-01-22T10:15:33 | 2023-01-22T10:15:33 | 194,377,412 | 0 | 0 | null | false | 2023-07-16T09:18:13 | 2019-06-29T07:26:51 | 2022-01-05T16:46:00 | 2023-07-16T09:18:11 | 541 | 0 | 0 | 0 | Java | false | false | package com.saltedfish.algorithms;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author SaltedFish
* @date 2022/1/31
*/
public class LeetCode2154 {
class Solution {
public int findFinalValue(int[] nums, int original) {
Set<Integer> s = new HashSet<>();
for (int x : nums) {
s.add(x);
}
while (s.contains(original)) {
original = original << 1;
}
return original;
}
}
}
| UTF-8 | Java | 558 | java | LeetCode2154.java | Java | [
{
"context": "va.util.Map;\nimport java.util.Set;\n\n/**\n * @author SaltedFish\n * @date 2022/1/31\n */\npublic class LeetCode2154 ",
"end": 158,
"score": 0.9983243942260742,
"start": 148,
"tag": "USERNAME",
"value": "SaltedFish"
}
] | null | [] | package com.saltedfish.algorithms;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author SaltedFish
* @date 2022/1/31
*/
public class LeetCode2154 {
class Solution {
public int findFinalValue(int[] nums, int original) {
Set<Integer> s = new HashSet<>();
for (int x : nums) {
s.add(x);
}
while (s.contains(original)) {
original = original << 1;
}
return original;
}
}
}
| 558 | 0.537634 | 0.516129 | 25 | 21.32 | 15.369372 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.