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
3c2e6c43813163dbacf1f089a26f8999ca539e50
9,113,920,672,492
049fb175885f8e506052c8bf17b3e5b8992e0990
/java-bases/src/main/java/cn/withme/pattern/observe/Zoo.java
34331a28b867ae265c099bb672f7aa3eab71417c
[ "Apache-2.0" ]
permissive
q920447939/java-study
https://github.com/q920447939/java-study
f96a9bea148ba51e0fc24fcd002bbde74a1e7d2f
b0122c22de3d4b3b697694eb651e781533d09877
refs/heads/master
2023-06-07T18:19:26.220000
2023-05-29T08:38:01
2023-05-29T08:38:01
186,435,277
16
15
Apache-2.0
false
2022-06-23T05:24:26
2019-05-13T14:23:42
2022-06-23T05:21:30
2022-06-23T05:24:26
16,066
13
16
1
Java
false
false
package cn.withme.pattern.observe; /** * @author liming * @Description: * @date 2019年12月12日 */ public class Zoo implements Observe { @Override public String say() { return null; } }
UTF-8
Java
215
java
Zoo.java
Java
[ { "context": "package cn.withme.pattern.observe;\n\n/**\n * @author liming\n * @Description:\n * @date 2019年12月12日\n */\npublic ", "end": 57, "score": 0.9989025592803955, "start": 51, "tag": "USERNAME", "value": "liming" } ]
null
[]
package cn.withme.pattern.observe; /** * @author liming * @Description: * @date 2019年12月12日 */ public class Zoo implements Observe { @Override public String say() { return null; } }
215
0.626794
0.588517
14
13.928572
12.150628
38
false
false
0
0
0
0
0
0
0.142857
false
false
14
cf681fc3e19b4d6d5bc81c7fbc729b84a012d259
32,736,240,752,733
0a1f9155878a32d5b5efc142b7d38c77b7c79c5a
/app/src/main/java/com/dev/r19/localservicefinder/ClientFeedbackModel.java
943ac84326ebf14d602acc0cc06c0e4604ac011a
[]
no_license
bloodrob/LocalServiceFinder
https://github.com/bloodrob/LocalServiceFinder
591f60533a8bd357e6f5d37fcd1708a2f76f69d6
476b5bcf7a5bacc9e57b3f40e7aeae82474484ae
refs/heads/master
2020-04-07T16:36:35.118000
2019-04-01T17:26:42
2019-04-01T17:26:42
158,535,449
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.dev.r19.localservicefinder; import com.google.firebase.database.IgnoreExtraProperties; /** * Created by R19 on 12/5/2018. */ @IgnoreExtraProperties public class ClientFeedbackModel { private String Client_name; private String Client_email; private String Subject; private String Message; public ClientFeedbackModel() { } public ClientFeedbackModel(String Client_name,String Client_email,String Subject, String Message) { this.Client_name = Client_name; this.Client_email = Client_email; this.Subject = Subject; this.Message = Message; } public String getClient_name() { return Client_name; } public String getClient_email() { return Client_email; } public String getSubject() { return Subject; } public String getMessage() { return Message; } }
UTF-8
Java
896
java
ClientFeedbackModel.java
Java
[ { "context": "database.IgnoreExtraProperties;\n\n/**\n * Created by R19 on 12/5/2018.\n */\n@IgnoreExtraProperties\npublic c", "end": 122, "score": 0.9993345737457275, "start": 119, "tag": "USERNAME", "value": "R19" } ]
null
[]
package com.dev.r19.localservicefinder; import com.google.firebase.database.IgnoreExtraProperties; /** * Created by R19 on 12/5/2018. */ @IgnoreExtraProperties public class ClientFeedbackModel { private String Client_name; private String Client_email; private String Subject; private String Message; public ClientFeedbackModel() { } public ClientFeedbackModel(String Client_name,String Client_email,String Subject, String Message) { this.Client_name = Client_name; this.Client_email = Client_email; this.Subject = Subject; this.Message = Message; } public String getClient_name() { return Client_name; } public String getClient_email() { return Client_email; } public String getSubject() { return Subject; } public String getMessage() { return Message; } }
896
0.662946
0.65067
41
20.853659
20.625063
103
false
false
0
0
0
0
0
0
0.414634
false
false
14
d40ec1c732bf4e4fabd7071ce423d648a43bd54f
1,382,979,492,919
6fb5c58bb29aed2373a7bace650fc0fcb7f4196a
/src/main/java/com/projet01/InscriptionService.java
f3cec8e1a3a27a44018f7f127aafd560b72d9b13
[]
no_license
ekiriano/mgl7460-a19-projet1
https://github.com/ekiriano/mgl7460-a19-projet1
a960884934aa56680b3bab90781ba9d99fe0a9ef
c8a9156d72539facbf7cc5f68fdfb8b507a3660c
refs/heads/master
2020-07-29T04:24:26.862000
2019-10-17T17:20:52
2019-10-17T17:20:52
209,668,502
0
0
null
false
2020-10-13T16:36:18
2019-09-19T23:57:41
2019-10-17T17:21:07
2020-10-13T16:36:16
180
0
0
2
Java
false
false
package com.projet01; import java.util.ArrayList; import java.util.List; /** * Classe InscriptionService specifie les interactions entre Etudiant et Cours. */ public class InscriptionService { private List<Etudiant> etudiants; private List<Cours> cours; /** * Constructeur de la classe inscription Service . * */ public InscriptionService() { Etudiant etu1 = new Etudiant(0,"Pearl", "Dixon", "2949 Dola Mine Road , Apex, NC 27502", "919-362-4406"); Etudiant etu2 = new Etudiant(1,"Linda", "Vasquez", "2641 Bingamon Road,Garfield Heights, OH 44125", "440-465-9257"); Etudiant etu3 = new Etudiant(2,"Tommy", "Terry", "1156 Peck Street,Newport, NH 03773", "603-865-6649"); Etudiant etu4 = new Etudiant(3,"Rick", "Gilchrist", "2482 Poco Mas Drive,Dallas, TX 75247", "214-545-0088"); Etudiant etu5 = new Etudiant(4,"David", "Beaver", "1137 Victoria Court,Sanford, ME 04073 ", "207-490-0329"); ArrayList<Etudiant> listeDesEtudiants = new ArrayList<Etudiant>(); listeDesEtudiants.add(etu1); listeDesEtudiants.add(etu2); listeDesEtudiants.add(etu3); listeDesEtudiants.add(etu4); listeDesEtudiants.add(etu5); this.etudiants = listeDesEtudiants; Cours mgl7315 = new Cours( "Gestion de projet en génie logiciel", "MGL7315", "Non disponible", 3); Cours mgl7260 = new Cours( "Exigences et spécifications de systèmes logiciels", "MGL7260", "Non disponible", 3); Cours mgl7460 = new Cours( "Réalisation et maintenance de logiciels", "MGL7460", "Non disponible", 3); ArrayList<Cours> listeDesCours = new ArrayList<Cours>(); listeDesCours.add(mgl7315); listeDesCours.add(mgl7260); listeDesCours.add(mgl7460); this.cours = listeDesCours; } /** * Cette fonction liste la totalite des cours disponibles pour une inscription. * @return ArrayList Cours liste de tout les cours. */ public List<Cours> listerCours() { return this.cours; } /** Cette fonction liste tout les etudiants disponibles. * @return ArrayList Etudiant liste de tout les etudiants. */ public List<Etudiant> listerEtudiants() { return this.etudiants; } /** * Cette fonction nous permet de trouver un etudiant par son id. * @param idEtudiant idEtudiant. * @return Etudiant dont id est == param. */ public Etudiant trouverEtudiantParId(int idEtudiant) { for (Etudiant etudiant : listerEtudiants()) { if (etudiant.getId() == idEtudiant) { return etudiant; } } return new Etudiant(); } /** *Cette fonction permet de retrouver un cours en fonction de son code cours. * @param codeCours code du Cours. * @return Cours dont codeCours == codeCours */ public Cours trouverCoursParCode(String codeCours) { for (Cours cours : listerCours()) { if (cours.getCodeCours().equals(codeCours)) { return cours; } } Cours cours = new Cours(); return cours; } /** * Cette fonction permet d'inscrire un etudiant a un cours. * @param idEtudiant id etudiant * @param codeCours code du cours. * */ public void inscrireEtudiantAuCours(int idEtudiant, String codeCours) { Etudiant curEtu = trouverEtudiantParId(idEtudiant); List<Cours> curEtuCours = curEtu.getCoursInscrits(); Cours cours = trouverCoursParCode(codeCours); curEtuCours.add(cours); curEtu.setCoursInscrits(curEtuCours); } /** * Cette fonction permet de liuster les cours auquel est inscrtit un etudiant. * @param idEtudiant id Etudiant * @return ArrayList Cours liste des cours auquel est inscrit l'etudiant. */ public List<Cours> listerLesCoursEtudiantCourant(int idEtudiant) { Etudiant currentEtu = trouverEtudiantParId(idEtudiant); return currentEtu.getCoursInscrits(); } }
UTF-8
Java
4,003
java
InscriptionService.java
Java
[ { "context": "onService() {\n Etudiant etu1 = new Etudiant(0,\"Pearl\", \"Dixon\",\n \"2949 Dola Mine Road , Ape", "end": 407, "score": 0.9997801780700684, "start": 402, "tag": "NAME", "value": "Pearl" }, { "context": "() {\n Etudiant etu1 = new Etudiant(0,\"Pearl\", \"Dixon\",\n \"2949 Dola Mine Road , Apex, NC 275", "end": 416, "score": 0.9997425675392151, "start": 411, "tag": "NAME", "value": "Dixon" }, { "context": "9-362-4406\");\n Etudiant etu2 = new Etudiant(1,\"Linda\", \"Vasquez\",\n \"2641 Bingamon Road,Garf", "end": 529, "score": 0.99973464012146, "start": 524, "tag": "NAME", "value": "Linda" }, { "context": "6\");\n Etudiant etu2 = new Etudiant(1,\"Linda\", \"Vasquez\",\n \"2641 Bingamon Road,Garfield Height", "end": 540, "score": 0.9996799230575562, "start": 533, "tag": "NAME", "value": "Vasquez" }, { "context": "0-465-9257\");\n Etudiant etu3 = new Etudiant(2,\"Tommy\", \"Terry\",\n \"1156 Peck Street,Newport,", "end": 662, "score": 0.9996100664138794, "start": 657, "tag": "NAME", "value": "Tommy" }, { "context": "7\");\n Etudiant etu3 = new Etudiant(2,\"Tommy\", \"Terry\",\n \"1156 Peck Street,Newport, NH 03773", "end": 671, "score": 0.9996422529220581, "start": 666, "tag": "NAME", "value": "Terry" }, { "context": "3-865-6649\");\n Etudiant etu4 = new Etudiant(3,\"Rick\", \"Gilchrist\",\n \"2482 Poco Mas Drive,D", "end": 781, "score": 0.9996853470802307, "start": 777, "tag": "NAME", "value": "Rick" }, { "context": "49\");\n Etudiant etu4 = new Etudiant(3,\"Rick\", \"Gilchrist\",\n \"2482 Poco Mas Drive,Dallas, TX 752", "end": 794, "score": 0.9996514916419983, "start": 785, "tag": "NAME", "value": "Gilchrist" }, { "context": "4-545-0088\");\n Etudiant etu5 = new Etudiant(4,\"David\", \"Beaver\",\n \"1137 Victoria Court,Sanf", "end": 907, "score": 0.999882698059082, "start": 902, "tag": "NAME", "value": "David" }, { "context": "8\");\n Etudiant etu5 = new Etudiant(4,\"David\", \"Beaver\",\n \"1137 Victoria Court,Sanford, ME 04", "end": 917, "score": 0.9997792840003967, "start": 911, "tag": "NAME", "value": "Beaver" } ]
null
[]
package com.projet01; import java.util.ArrayList; import java.util.List; /** * Classe InscriptionService specifie les interactions entre Etudiant et Cours. */ public class InscriptionService { private List<Etudiant> etudiants; private List<Cours> cours; /** * Constructeur de la classe inscription Service . * */ public InscriptionService() { Etudiant etu1 = new Etudiant(0,"Pearl", "Dixon", "2949 Dola Mine Road , Apex, NC 27502", "919-362-4406"); Etudiant etu2 = new Etudiant(1,"Linda", "Vasquez", "2641 Bingamon Road,Garfield Heights, OH 44125", "440-465-9257"); Etudiant etu3 = new Etudiant(2,"Tommy", "Terry", "1156 Peck Street,Newport, NH 03773", "603-865-6649"); Etudiant etu4 = new Etudiant(3,"Rick", "Gilchrist", "2482 Poco Mas Drive,Dallas, TX 75247", "214-545-0088"); Etudiant etu5 = new Etudiant(4,"David", "Beaver", "1137 Victoria Court,Sanford, ME 04073 ", "207-490-0329"); ArrayList<Etudiant> listeDesEtudiants = new ArrayList<Etudiant>(); listeDesEtudiants.add(etu1); listeDesEtudiants.add(etu2); listeDesEtudiants.add(etu3); listeDesEtudiants.add(etu4); listeDesEtudiants.add(etu5); this.etudiants = listeDesEtudiants; Cours mgl7315 = new Cours( "Gestion de projet en génie logiciel", "MGL7315", "Non disponible", 3); Cours mgl7260 = new Cours( "Exigences et spécifications de systèmes logiciels", "MGL7260", "Non disponible", 3); Cours mgl7460 = new Cours( "Réalisation et maintenance de logiciels", "MGL7460", "Non disponible", 3); ArrayList<Cours> listeDesCours = new ArrayList<Cours>(); listeDesCours.add(mgl7315); listeDesCours.add(mgl7260); listeDesCours.add(mgl7460); this.cours = listeDesCours; } /** * Cette fonction liste la totalite des cours disponibles pour une inscription. * @return ArrayList Cours liste de tout les cours. */ public List<Cours> listerCours() { return this.cours; } /** Cette fonction liste tout les etudiants disponibles. * @return ArrayList Etudiant liste de tout les etudiants. */ public List<Etudiant> listerEtudiants() { return this.etudiants; } /** * Cette fonction nous permet de trouver un etudiant par son id. * @param idEtudiant idEtudiant. * @return Etudiant dont id est == param. */ public Etudiant trouverEtudiantParId(int idEtudiant) { for (Etudiant etudiant : listerEtudiants()) { if (etudiant.getId() == idEtudiant) { return etudiant; } } return new Etudiant(); } /** *Cette fonction permet de retrouver un cours en fonction de son code cours. * @param codeCours code du Cours. * @return Cours dont codeCours == codeCours */ public Cours trouverCoursParCode(String codeCours) { for (Cours cours : listerCours()) { if (cours.getCodeCours().equals(codeCours)) { return cours; } } Cours cours = new Cours(); return cours; } /** * Cette fonction permet d'inscrire un etudiant a un cours. * @param idEtudiant id etudiant * @param codeCours code du cours. * */ public void inscrireEtudiantAuCours(int idEtudiant, String codeCours) { Etudiant curEtu = trouverEtudiantParId(idEtudiant); List<Cours> curEtuCours = curEtu.getCoursInscrits(); Cours cours = trouverCoursParCode(codeCours); curEtuCours.add(cours); curEtu.setCoursInscrits(curEtuCours); } /** * Cette fonction permet de liuster les cours auquel est inscrtit un etudiant. * @param idEtudiant id Etudiant * @return ArrayList Cours liste des cours auquel est inscrit l'etudiant. */ public List<Cours> listerLesCoursEtudiantCourant(int idEtudiant) { Etudiant currentEtu = trouverEtudiantParId(idEtudiant); return currentEtu.getCoursInscrits(); } }
4,003
0.656164
0.618405
136
28.404411
24.345968
81
false
false
0
0
0
0
0
0
0.580882
false
false
14
7b657522d371e6d66730f64e4f07d67543876f6c
18,476,949,333,652
93d2e732d2d08715777a0fc3f4f2fa9cbd42db5d
/ftp/src/test/java/docs/javadsl/FtpRetrievingExample.java
11f09180113f0ba65cee30915aa5cbeb5d5ad522
[ "Apache-2.0" ]
permissive
AudaxHealthInc/alpakka
https://github.com/AudaxHealthInc/alpakka
8c4ab1bd78c4bf609f0b2c9ee1dee92546a43b3d
7197901d4808488a3faf2c02a437f771370100bf
refs/heads/master
2022-08-18T02:10:09.718000
2019-05-02T20:22:39
2019-05-02T20:22:39
184,331,123
1
2
NOASSERTION
true
2023-01-25T18:22:12
2019-04-30T21:02:39
2019-06-20T17:21:13
2022-08-11T04:37:56
12,565
1
2
0
Scala
false
false
/* * Copyright (C) 2016-2019 Lightbend Inc. <http://www.lightbend.com> */ package docs.javadsl; // #retrieving import akka.stream.IOResult; import akka.stream.alpakka.ftp.FtpSettings; import akka.stream.alpakka.ftp.javadsl.Ftp; import akka.stream.javadsl.Source; import akka.util.ByteString; import java.util.concurrent.CompletionStage; public class FtpRetrievingExample { public Source<ByteString, CompletionStage<IOResult>> retrieveFromPath( String path, FtpSettings settings) throws Exception { return Ftp.fromPath(path, settings); } } // #retrieving
UTF-8
Java
574
java
FtpRetrievingExample.java
Java
[]
null
[]
/* * Copyright (C) 2016-2019 Lightbend Inc. <http://www.lightbend.com> */ package docs.javadsl; // #retrieving import akka.stream.IOResult; import akka.stream.alpakka.ftp.FtpSettings; import akka.stream.alpakka.ftp.javadsl.Ftp; import akka.stream.javadsl.Source; import akka.util.ByteString; import java.util.concurrent.CompletionStage; public class FtpRetrievingExample { public Source<ByteString, CompletionStage<IOResult>> retrieveFromPath( String path, FtpSettings settings) throws Exception { return Ftp.fromPath(path, settings); } } // #retrieving
574
0.768293
0.754355
22
25.09091
22.841169
72
false
false
0
0
0
0
0
0
0.5
false
false
14
f13e4508669162c3ebda88efd8a84c5ac8b29a48
34,024,730,981,341
80d161f01189caba2c026581069f0772106f97ac
/dxbase/src/main/java/com/dxmovie/dxbase/utils/RxUtils.java
ff644092dbcb87465066951e3dedc1938de14608
[ "Apache-2.0" ]
permissive
zajhello/example
https://github.com/zajhello/example
8cd6077fb195a9db4c7ec51dcb80d041e2130959
7703ab9a84e2bc65b81011795115ac57efba624e
refs/heads/master
2021-07-17T16:26:29.257000
2021-07-17T09:18:44
2021-07-17T09:18:44
60,514,520
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.dxmovie.dxbase.utils; import androidx.lifecycle.LifecycleOwner; import com.dxmovie.dxbase.net.ApiErrorOperator; import com.dxmovie.dxbase.net.ApiErrorOperatorByFlowable; import com.dxmovie.dxbase.net.RetryWithDelay; import com.dxmovie.dxbase.net.RetryWithDelayByFlowable; import com.dxmovie.dxbase.response.BaseResponse; import com.trello.rxlifecycle2.LifecycleProvider; import com.trello.rxlifecycle2.LifecycleTransformer; import com.uber.autodispose.AutoDispose; import com.uber.autodispose.AutoDisposeConverter; import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider; import io.reactivex.FlowableTransformer; import io.reactivex.ObservableTransformer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.annotations.NonNull; import io.reactivex.schedulers.Schedulers; /** * 有关Rx的工具类 */ public class RxUtils { /** * /** * 生命周期绑定 */ public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull LifecycleProvider lifecycle) { return lifecycle.bindToLifecycle(); } /** * 线程调度器 */ public static <T> ObservableTransformer<T, T> schedulersTransformer() { return upstream -> upstream.subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelay(1,1)) .observeOn(AndroidSchedulers.mainThread()); } /** * 异常处理 + 线程调度器 (Infinite 的接口) */ public static <T extends BaseResponse> ObservableTransformer<T, T> exceptionIoTransformer() { return upstream -> upstream.lift(new ApiErrorOperator<>()) .subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelay(1,1)) .observeOn(AndroidSchedulers.mainThread()); } /** * 异常处理 + 线程调度器 (Infinite 的接口) */ public static <T extends BaseResponse> FlowableTransformer<T, T> exceptionIoTransformerByFlowable() { return upstream -> upstream.lift(new ApiErrorOperatorByFlowable<>()) .subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelayByFlowable(1,1)) .observeOn(AndroidSchedulers.mainThread()); } public static <T> AutoDisposeConverter<T> bindLifecycle(LifecycleOwner lifecycleOwner) { return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)); } }
UTF-8
Java
2,542
java
RxUtils.java
Java
[]
null
[]
package com.dxmovie.dxbase.utils; import androidx.lifecycle.LifecycleOwner; import com.dxmovie.dxbase.net.ApiErrorOperator; import com.dxmovie.dxbase.net.ApiErrorOperatorByFlowable; import com.dxmovie.dxbase.net.RetryWithDelay; import com.dxmovie.dxbase.net.RetryWithDelayByFlowable; import com.dxmovie.dxbase.response.BaseResponse; import com.trello.rxlifecycle2.LifecycleProvider; import com.trello.rxlifecycle2.LifecycleTransformer; import com.uber.autodispose.AutoDispose; import com.uber.autodispose.AutoDisposeConverter; import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider; import io.reactivex.FlowableTransformer; import io.reactivex.ObservableTransformer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.annotations.NonNull; import io.reactivex.schedulers.Schedulers; /** * 有关Rx的工具类 */ public class RxUtils { /** * /** * 生命周期绑定 */ public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull LifecycleProvider lifecycle) { return lifecycle.bindToLifecycle(); } /** * 线程调度器 */ public static <T> ObservableTransformer<T, T> schedulersTransformer() { return upstream -> upstream.subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelay(1,1)) .observeOn(AndroidSchedulers.mainThread()); } /** * 异常处理 + 线程调度器 (Infinite 的接口) */ public static <T extends BaseResponse> ObservableTransformer<T, T> exceptionIoTransformer() { return upstream -> upstream.lift(new ApiErrorOperator<>()) .subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelay(1,1)) .observeOn(AndroidSchedulers.mainThread()); } /** * 异常处理 + 线程调度器 (Infinite 的接口) */ public static <T extends BaseResponse> FlowableTransformer<T, T> exceptionIoTransformerByFlowable() { return upstream -> upstream.lift(new ApiErrorOperatorByFlowable<>()) .subscribeOn(Schedulers.io()) .retryWhen(new RetryWithDelayByFlowable(1,1)) .observeOn(AndroidSchedulers.mainThread()); } public static <T> AutoDisposeConverter<T> bindLifecycle(LifecycleOwner lifecycleOwner) { return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycleOwner)); } }
2,542
0.681707
0.678455
71
33.647888
29.604481
105
false
false
0
0
0
0
0
0
0.394366
false
false
14
c18687edd98d1e5f0d01d553fa9aa74ab4b0a82a
37,014,028,196,650
92225460ebca1bb6a594d77b6559b3629b7a94fa
/src/com/kingdee/eas/fdc/tenancy/RentRemissionEntryFactory.java
96029bfc54172d6e22bb3a40c8b2f7121b313add
[]
no_license
yangfan0725/sd
https://github.com/yangfan0725/sd
45182d34575381be3bbdd55f3f68854a6900a362
39ebad6e2eb76286d551a9e21967f3f5dc4880da
refs/heads/master
2023-04-29T01:56:43.770000
2023-04-24T05:41:13
2023-04-24T05:41:13
512,073,641
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.kingdee.eas.fdc.tenancy; import com.kingdee.bos.BOSException; import com.kingdee.bos.BOSObjectFactory; import com.kingdee.bos.util.BOSObjectType; import com.kingdee.bos.Context; public class RentRemissionEntryFactory { private RentRemissionEntryFactory() { } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getRemoteInstance() throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("09A090FB") ,com.kingdee.eas.fdc.tenancy.IRentRemissionEntry.class); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("09A090FB") ,com.kingdee.eas.fdc.tenancy.IRentRemissionEntry.class, objectCtx); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getLocalInstance(Context ctx) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("09A090FB")); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getLocalInstance(String sessionID) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("09A090FB")); } }
UTF-8
Java
1,504
java
RentRemissionEntryFactory.java
Java
[]
null
[]
package com.kingdee.eas.fdc.tenancy; import com.kingdee.bos.BOSException; import com.kingdee.bos.BOSObjectFactory; import com.kingdee.bos.util.BOSObjectType; import com.kingdee.bos.Context; public class RentRemissionEntryFactory { private RentRemissionEntryFactory() { } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getRemoteInstance() throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("09A090FB") ,com.kingdee.eas.fdc.tenancy.IRentRemissionEntry.class); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("09A090FB") ,com.kingdee.eas.fdc.tenancy.IRentRemissionEntry.class, objectCtx); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getLocalInstance(Context ctx) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("09A090FB")); } public static com.kingdee.eas.fdc.tenancy.IRentRemissionEntry getLocalInstance(String sessionID) throws BOSException { return (com.kingdee.eas.fdc.tenancy.IRentRemissionEntry)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("09A090FB")); } }
1,504
0.793883
0.780585
30
49.166668
62.02692
217
false
false
0
0
0
0
0
0
0.466667
false
false
14
f0feb78eb58d48302b682ee8178d8d00d91ab2b6
39,204,461,513,073
7ce60a55b2fda55bba469d85623847163f992914
/logger/src/main/java/com/antlet/logger/Main.java
a1ef6bba549f1345c0bf15a1825035780fabbbc3
[]
no_license
deanchen2013/logger
https://github.com/deanchen2013/logger
c520f2ea3501c3b0bd237d87acab27c9f6e0e261
39f1c6a5fd453fa6f6c023ed510bfa430827a722
refs/heads/master
2018-03-13T15:06:20.425000
2017-01-27T16:18:09
2017-01-27T16:18:09
68,180,548
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.antlet.logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; 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.ResponseBody; import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.io.*; import java.util.HashMap; import java.util.Map; @SpringBootApplication @Controller @ConfigurationProperties(prefix = "logger") @EnableSwagger2 public class Main { static final Log log = LogFactory.getLog(Main.class); String fileDB; public String getFileDB() { return fileDB; } public void setFileDB(String fileDB) { this.fileDB = fileDB; } public static void main(String[] args) throws Exception { log.debug("begin start logger!!!"); SpringApplication.run(Main.class, args); } // @RequestMapping("/") // String home() { // return "logger.html"; // } @RequestMapping(value = "/load", method = RequestMethod.GET) public @ResponseBody Map<String, String> load() { Map<String, String> result = new HashMap<String, String>(); if (fileDB == null || fileDB.equals("")) { result.put("msg", "file config not found:" + fileDB); return result; } BufferedReader reader = null; String content = ""; try { File file = new File(fileDB); if (!file.exists()) { file.createNewFile(); } reader = new BufferedReader(new FileReader(file)); String line = null; while((line = reader.readLine()) != null){ content += line + "\r\n"; } result.put("content",content); File backup = new File(fileDB + "." + System.currentTimeMillis()); backup.createNewFile(); FileCopyUtils.copy(file, backup); } catch (IOException e) { result.put("msg","read file error!"); log.error(e); return result; }finally{ try { reader.close(); } catch (IOException e) { } } return result; } @RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody Map<String, String> upload(@RequestParam("content") String content) { Map<String, String> result = new HashMap<String, String>(); if (fileDB == null || fileDB.equals("")) { result.put("msg", "file config not found:" + fileDB); return result; } FileWriter writer = null; try { File file = new File(fileDB); if (!file.exists()) { file.createNewFile(); } writer = new FileWriter(file); writer.write(content); result.put("msg","success"); } catch (IOException e) { result.put("msg","writer file error!"); log.error(e); return result; }finally{ try { writer.close(); } catch (IOException e) { } } return result; } }
UTF-8
Java
3,179
java
Main.java
Java
[]
null
[]
package com.antlet.logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; 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.ResponseBody; import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.io.*; import java.util.HashMap; import java.util.Map; @SpringBootApplication @Controller @ConfigurationProperties(prefix = "logger") @EnableSwagger2 public class Main { static final Log log = LogFactory.getLog(Main.class); String fileDB; public String getFileDB() { return fileDB; } public void setFileDB(String fileDB) { this.fileDB = fileDB; } public static void main(String[] args) throws Exception { log.debug("begin start logger!!!"); SpringApplication.run(Main.class, args); } // @RequestMapping("/") // String home() { // return "logger.html"; // } @RequestMapping(value = "/load", method = RequestMethod.GET) public @ResponseBody Map<String, String> load() { Map<String, String> result = new HashMap<String, String>(); if (fileDB == null || fileDB.equals("")) { result.put("msg", "file config not found:" + fileDB); return result; } BufferedReader reader = null; String content = ""; try { File file = new File(fileDB); if (!file.exists()) { file.createNewFile(); } reader = new BufferedReader(new FileReader(file)); String line = null; while((line = reader.readLine()) != null){ content += line + "\r\n"; } result.put("content",content); File backup = new File(fileDB + "." + System.currentTimeMillis()); backup.createNewFile(); FileCopyUtils.copy(file, backup); } catch (IOException e) { result.put("msg","read file error!"); log.error(e); return result; }finally{ try { reader.close(); } catch (IOException e) { } } return result; } @RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody Map<String, String> upload(@RequestParam("content") String content) { Map<String, String> result = new HashMap<String, String>(); if (fileDB == null || fileDB.equals("")) { result.put("msg", "file config not found:" + fileDB); return result; } FileWriter writer = null; try { File file = new File(fileDB); if (!file.exists()) { file.createNewFile(); } writer = new FileWriter(file); writer.write(content); result.put("msg","success"); } catch (IOException e) { result.put("msg","writer file error!"); log.error(e); return result; }finally{ try { writer.close(); } catch (IOException e) { } } return result; } }
3,179
0.673482
0.672539
111
26.639639
21.225004
91
false
false
0
0
0
0
0
0
2.36036
false
false
14
c2e578c46edfce8ddf542979d1b11e9db221f2bf
36,103,495,136,491
c871d3b5ad70e1f56eef9758ffccdb736e20dfd3
/app/src/main/java/com/hogo/rahul/retrofitusingjson/Retrofit2/WebService.java
76c0b4cca601b54ff6678063a7f8d42120ccbad3
[]
no_license
jainr5360/RetrofitUsingJSON-master
https://github.com/jainr5360/RetrofitUsingJSON-master
5a491147dc86d2ecc4f27c2c7c2770cff64fc2d4
da880106590978c93a61ea29ca7695fa428328ad
refs/heads/master
2021-07-25T16:00:36.268000
2017-11-07T18:35:38
2017-11-07T18:35:38
108,450,789
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.hogo.rahul.retrofitusingjson.Retrofit2; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Path; public interface WebService { @GET("api/app_controller/bh_menu_item/{itemId}") Call<MyResponse> getData(@Path("itemId") int itemId); }
UTF-8
Java
278
java
WebService.java
Java
[]
null
[]
package com.hogo.rahul.retrofitusingjson.Retrofit2; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Path; public interface WebService { @GET("api/app_controller/bh_menu_item/{itemId}") Call<MyResponse> getData(@Path("itemId") int itemId); }
278
0.751799
0.73741
13
20.384615
21.27309
57
false
false
0
0
0
0
0
0
0.384615
false
false
14
dfc440314a4d749618e1017a7e04128a94f10c41
12,661,563,620,589
ccb7425829295fb878c51de067bc605f31c6c8d7
/src/main/java/edu/pitt/dbmi/ccd/causal/rest/api/endpoint/DatasetFileEndpoint.java
c556bf4c59d76a3faf7042491ec6c5db93fabb0a
[]
no_license
bd2kccd/causal-rest-api
https://github.com/bd2kccd/causal-rest-api
44f530dac011c3cfa57f135a35339333da9c102e
c384222acc7b3548ff7f88fd29fd06a1a2ed2cff
refs/heads/development
2020-04-12T03:57:11.077000
2018-02-01T19:28:04
2018-02-01T19:28:04
60,381,741
2
1
null
false
2018-01-24T16:08:18
2016-06-03T22:38:59
2018-01-18T18:21:45
2018-01-24T16:08:18
509
0
1
0
Java
false
null
/* * Copyright (C) 2016 University of Pittsburgh. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package edu.pitt.dbmi.ccd.causal.rest.api.endpoint; import edu.pitt.dbmi.ccd.causal.rest.api.Role; import edu.pitt.dbmi.ccd.causal.rest.api.dto.DatasetFileDTO; import edu.pitt.dbmi.ccd.causal.rest.api.dto.DatasetFileSummarization; import edu.pitt.dbmi.ccd.causal.rest.api.service.DatasetFileEndpointService; import java.io.IOException; import java.util.List; import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.GenericEntity; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static javax.ws.rs.core.MediaType.APPLICATION_XML; import javax.ws.rs.core.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * * Jun 5, 2016 9:41:01 PM * * @author Kevin V. Bui (kvb2@pitt.edu) */ @Component @PermitAll @Path("/{uid}") public class DatasetFileEndpoint { private final DatasetFileEndpointService datasetFileEndpointService; @Autowired public DatasetFileEndpoint(DatasetFileEndpointService datasetFileEndpointService) { this.datasetFileEndpointService = datasetFileEndpointService; } /** * Delete a data file based on a given ID * * @param uid * @param id * @return 204 No content */ @DELETE @Path("/dataset/{id}") @RolesAllowed(Role.USER) public Response deleteById(@PathParam("uid") Long uid, @PathParam("id") Long id) { datasetFileEndpointService.deleteByIdAndUid(id, uid); return Response.noContent().build(); } /** * Get data file info for a given ID * * @param uid * @param id * @return 200 with data file info */ @GET @Path("/dataset/{id}") @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response findById(@PathParam("uid") Long uid, @PathParam("id") Long id) { DatasetFileDTO dataFileDTO = datasetFileEndpointService.findByIdAndUid(id, uid); return Response.ok(dataFileDTO).build(); } /** * List all the existing data files * * @param uid * @return 200 with file list */ @GET @Path("/dataset") @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response listDataFiles(@PathParam("uid") Long uid) { List<DatasetFileDTO> dataFileDTOs = datasetFileEndpointService.listAllDatasetFiles(uid); GenericEntity<List<DatasetFileDTO>> entity = new GenericEntity<List<DatasetFileDTO>>(dataFileDTOs) { }; return Response.ok(entity).build(); } /** * Data Summary * * @param uid * @param dataFileSummarization * @return * @throws IOException */ @POST @Path("/dataset/summarize") @Consumes(APPLICATION_JSON) @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response summarizeDataFile(@PathParam("uid") Long uid, @Valid DatasetFileSummarization dataFileSummarization) throws IOException { DatasetFileDTO dataFileDTO = datasetFileEndpointService.summarizeDatasetFile(uid, dataFileSummarization); return Response.ok(dataFileDTO).build(); } }
UTF-8
Java
4,237
java
DatasetFileEndpoint.java
Java
[ { "context": "t;\n\n/**\n *\n * Jun 5, 2016 9:41:01 PM\n *\n * @author Kevin V. Bui (kvb2@pitt.edu)\n */\n@Component\n@PermitAll\n@Path(\"", "end": 1834, "score": 0.9998722076416016, "start": 1822, "tag": "NAME", "value": "Kevin V. Bui" }, { "context": "un 5, 2016 9:41:01 PM\n *\n * @author Kevin V. Bui (kvb2@pitt.edu)\n */\n@Component\n@PermitAll\n@Path(\"/{uid}\")\npublic", "end": 1849, "score": 0.999930202960968, "start": 1836, "tag": "EMAIL", "value": "kvb2@pitt.edu" } ]
null
[]
/* * Copyright (C) 2016 University of Pittsburgh. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package edu.pitt.dbmi.ccd.causal.rest.api.endpoint; import edu.pitt.dbmi.ccd.causal.rest.api.Role; import edu.pitt.dbmi.ccd.causal.rest.api.dto.DatasetFileDTO; import edu.pitt.dbmi.ccd.causal.rest.api.dto.DatasetFileSummarization; import edu.pitt.dbmi.ccd.causal.rest.api.service.DatasetFileEndpointService; import java.io.IOException; import java.util.List; import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.GenericEntity; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static javax.ws.rs.core.MediaType.APPLICATION_XML; import javax.ws.rs.core.Response; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * * Jun 5, 2016 9:41:01 PM * * @author <NAME> (<EMAIL>) */ @Component @PermitAll @Path("/{uid}") public class DatasetFileEndpoint { private final DatasetFileEndpointService datasetFileEndpointService; @Autowired public DatasetFileEndpoint(DatasetFileEndpointService datasetFileEndpointService) { this.datasetFileEndpointService = datasetFileEndpointService; } /** * Delete a data file based on a given ID * * @param uid * @param id * @return 204 No content */ @DELETE @Path("/dataset/{id}") @RolesAllowed(Role.USER) public Response deleteById(@PathParam("uid") Long uid, @PathParam("id") Long id) { datasetFileEndpointService.deleteByIdAndUid(id, uid); return Response.noContent().build(); } /** * Get data file info for a given ID * * @param uid * @param id * @return 200 with data file info */ @GET @Path("/dataset/{id}") @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response findById(@PathParam("uid") Long uid, @PathParam("id") Long id) { DatasetFileDTO dataFileDTO = datasetFileEndpointService.findByIdAndUid(id, uid); return Response.ok(dataFileDTO).build(); } /** * List all the existing data files * * @param uid * @return 200 with file list */ @GET @Path("/dataset") @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response listDataFiles(@PathParam("uid") Long uid) { List<DatasetFileDTO> dataFileDTOs = datasetFileEndpointService.listAllDatasetFiles(uid); GenericEntity<List<DatasetFileDTO>> entity = new GenericEntity<List<DatasetFileDTO>>(dataFileDTOs) { }; return Response.ok(entity).build(); } /** * Data Summary * * @param uid * @param dataFileSummarization * @return * @throws IOException */ @POST @Path("/dataset/summarize") @Consumes(APPLICATION_JSON) @Produces({APPLICATION_JSON, APPLICATION_XML}) @RolesAllowed(Role.USER) public Response summarizeDataFile(@PathParam("uid") Long uid, @Valid DatasetFileSummarization dataFileSummarization) throws IOException { DatasetFileDTO dataFileDTO = datasetFileEndpointService.summarizeDatasetFile(uid, dataFileSummarization); return Response.ok(dataFileDTO).build(); } }
4,225
0.711588
0.702856
130
31.592308
28.390057
141
false
false
0
0
0
0
0
0
0.430769
false
false
14
4eb109f134917bf7f1f5cf8fb88c37d399fa15db
20,547,123,576,576
6033620f755c679bbd8086300765577a30b9f573
/04-马士兵JavaSE/basic-code/internet/src/demo04/TestUDPServer.java
61dd74ae470b5d460a2af30a4d332009b13bebb5
[ "MIT" ]
permissive
lm101845/LearnJava
https://github.com/lm101845/LearnJava
dbd1dc34fca5a163d7fdaa509940d34d07014a31
4947f507ad6011e6d64089b0e04d0aa92d4823d5
refs/heads/master
2023-05-25T10:37:34.038000
2022-12-21T08:53:28
2022-12-21T08:53:28
345,279,998
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package demo04; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.net.*; /** * @Author 李明 * @Date 2022/1/23 17:17 **/ public class TestUDPServer { public static void main(String[] args) throws Exception{ byte buf[] = new byte[1024]; DatagramPacket dp = new DatagramPacket(buf,buf.length); DatagramSocket ds = new DatagramSocket(5678); //这是UDP的5678端口 while (true){ ds.receive(dp); //只要有人发数据,我socket接收过来就给它仍包裹里 ByteArrayInputStream bais = new ByteArrayInputStream(buf); DataInputStream dis = new DataInputStream(bais); System.out.println(dis.readLong()); //System.out.println(new String(buf,0,dp.getLength())); } } }
UTF-8
Java
832
java
TestUDPServer.java
Java
[ { "context": "ataInputStream;\nimport java.net.*;\n/**\n * @Author 李明\n * @Date 2022/1/23 17:17\n **/\npublic class TestU", "end": 121, "score": 0.9990924596786499, "start": 119, "tag": "NAME", "value": "李明" } ]
null
[]
package demo04; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.net.*; /** * @Author 李明 * @Date 2022/1/23 17:17 **/ public class TestUDPServer { public static void main(String[] args) throws Exception{ byte buf[] = new byte[1024]; DatagramPacket dp = new DatagramPacket(buf,buf.length); DatagramSocket ds = new DatagramSocket(5678); //这是UDP的5678端口 while (true){ ds.receive(dp); //只要有人发数据,我socket接收过来就给它仍包裹里 ByteArrayInputStream bais = new ByteArrayInputStream(buf); DataInputStream dis = new DataInputStream(bais); System.out.println(dis.readLong()); //System.out.println(new String(buf,0,dp.getLength())); } } }
832
0.631105
0.597686
24
31.416666
21.363749
70
false
false
0
0
0
0
0
0
0.625
false
false
14
5c3cacaddc7b95cb3c564a7d9b89bd92d9707876
20,547,123,576,825
2f6adb486d34dfb719bede93d2f490d121cf431a
/KiviPaperiSakset/src/main/java/ohtu/kivipaperisakset/KPSTekoaly.java
1b6b54f26f5128bd3d113a07aa6c0f8817bfdb8d
[]
no_license
makevertti/ohtu-viikko7
https://github.com/makevertti/ohtu-viikko7
26b88c6385898dacb78444dca9883d65b02548a2
5897345793f7dbf83ef87a238ec4a8901c4dde39
refs/heads/master
2021-01-01T05:14:40.426000
2016-05-04T17:02:45
2016-05-04T17:02:45
57,986,960
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ohtu.kivipaperisakset; public class KPSTekoaly extends KPSPeli { private Tekoaly tekoaly; public KPSTekoaly() { this.tekoaly = new Tekoaly(); } @Override protected void tokanSiirto() { this.tokanSiirto = this.tekoaly.annaSiirto(); System.out.println("Tietokone valitsi: " + this.tokanSiirto); this.tekoaly.asetaSiirto(this.ekanSiirto); } }
UTF-8
Java
407
java
KPSTekoaly.java
Java
[]
null
[]
package ohtu.kivipaperisakset; public class KPSTekoaly extends KPSPeli { private Tekoaly tekoaly; public KPSTekoaly() { this.tekoaly = new Tekoaly(); } @Override protected void tokanSiirto() { this.tokanSiirto = this.tekoaly.annaSiirto(); System.out.println("Tietokone valitsi: " + this.tokanSiirto); this.tekoaly.asetaSiirto(this.ekanSiirto); } }
407
0.665848
0.665848
17
23
21.436638
69
false
false
0
0
0
0
0
0
0.352941
false
false
14
bd7b29db038a52dc86c39d5c926193315d5da58c
5,214,090,351,020
ddd8b520200e4cc69f0eeae6fe144cadf5363110
/test/java/uk/co/real_logic/sbe/json/JsonPrinterTest.java
6eed86837bbaa56910046cf6ece98c609ef626b4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
MarkBruns/simple-binary-encoding
https://github.com/MarkBruns/simple-binary-encoding
31890eec570fc273e7a590579781f0c0b88df1ad
5259fb0f6929e5921184a10eab70bc54e05fdaa0
refs/heads/master
2017-03-26T01:47:19.771000
2015-07-20T16:33:56
2015-07-20T16:33:56
39,412,574
1
0
null
true
2015-07-20T22:59:24
2015-07-20T22:59:24
2015-07-20T22:59:01
2015-07-20T16:34:11
19,013
0
0
0
null
null
null
/* * Copyright 2015 Real Logic Ltd. * * 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 uk.co.real_logic.sbe.json; import baseline.*; import org.junit.BeforeClass; import org.junit.Test; import uk.co.real_logic.agrona.concurrent.UnsafeBuffer; import uk.co.real_logic.sbe.ir.Ir; import uk.co.real_logic.sbe.ir.IrDecoder; import uk.co.real_logic.sbe.ir.IrEncoder; import uk.co.real_logic.sbe.xml.IrGenerator; import uk.co.real_logic.sbe.xml.MessageSchema; import uk.co.real_logic.sbe.xml.ParserOptions; import uk.co.real_logic.sbe.xml.XmlSchemaParser; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import static junit.framework.TestCase.assertEquals; public class JsonPrinterTest { private static final MessageHeaderEncoder MESSAGE_HEADER = new MessageHeaderEncoder(); private static final CarEncoder CAR = new CarEncoder(); private static final int MSG_BUFFER_CAPACITY = 4 * 1024; private static final int SCHEMA_BUFFER_CAPACITY = 16 * 1024; private static byte[] vehicleCode; private static byte[] manufacturerCode; private static byte[] make; private static byte[] model; @BeforeClass public static void setupExampleData() { try { vehicleCode = "abcdef".getBytes(CarEncoder.vehicleCodeCharacterEncoding()); manufacturerCode = "123".getBytes(EngineEncoder.manufacturerCodeCharacterEncoding()); make = "Honda".getBytes(CarEncoder.makeCharacterEncoding()); model = "Civic VTi".getBytes(CarEncoder.modelCharacterEncoding()); } catch (final UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } @Test public void exampleMessagePrintedAsJson() throws Exception { final ByteBuffer encodedSchemaBuffer = ByteBuffer.allocateDirect(SCHEMA_BUFFER_CAPACITY); encodeSchema(encodedSchemaBuffer); final ByteBuffer encodedMsgBuffer = ByteBuffer.allocateDirect(MSG_BUFFER_CAPACITY); encodeTestMessage(encodedMsgBuffer); encodedSchemaBuffer.flip(); final Ir ir = decodeIr(encodedSchemaBuffer); final JsonPrinter printer = new JsonPrinter(ir); final String result = printer.print(encodedMsgBuffer); assertEquals( "{\n" + " \"serialNumber\": 1234,\n" + " \"modelYear\": 2013,\n" + " \"someNumbers\": [0, 1, 2, 3, 4],\n" + " \"vehicleCode\": \"abcdef\",\n" + " \"capacity\": 2000,\n" + " \"numCylinders\": 4,\n" + " \"maxRpm\": 9000,\n" + " \"manufacturerCode\": \"123\",\n" + " \"fuel\": Petrol,\n" + " \"fuelFigures\": [\n" + " {\n" + " \"speed\": 30,\n" + " \"mpg\": 35.9\n" + " },\n" + " {\n" + " \"speed\": 55,\n" + " \"mpg\": 49.0\n" + " },\n" + " {\n" + " \"speed\": 75,\n" + " \"mpg\": 40.0\n" + " }],\n" + " \"performanceFigures\": [\n" + " {\n" + " \"octaneRating\": 95,\n" + " \"acceleration\": [\n" + " {\n" + " \"mph\": 30,\n" + " \"seconds\": 4.0\n" + " },\n" + " {\n" + " \"mph\": 60,\n" + " \"seconds\": 7.5\n" + " },\n" + " {\n" + " \"mph\": 100,\n" + " \"seconds\": 12.2\n" + " }]\n" + " },\n" + " {\n" + " \"octaneRating\": 99,\n" + " \"acceleration\": [\n" + " {\n" + " \"mph\": 30,\n" + " \"seconds\": 3.8\n" + " },\n" + " {\n" + " \"mph\": 60,\n" + " \"seconds\": 7.1\n" + " },\n" + " {\n" + " \"mph\": 100,\n" + " \"seconds\": 11.8\n" + " }]\n" + " }],\n" + " \"make\": \"Honda\",\n" + " \"model\": \"Civic VTi\",\n" + " \"activationCode\": \"\"\n" + "}" , result); } private static void encodeSchema(final ByteBuffer buffer) throws Exception { try (final InputStream in = new FileInputStream("examples/resources/example-schema.xml")) { final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT); final Ir ir = new IrGenerator().generate(schema); try (final IrEncoder irEncoder = new IrEncoder(buffer, ir)) { irEncoder.encode(); } } } private static void encodeTestMessage(final ByteBuffer buffer) { final UnsafeBuffer directBuffer = new UnsafeBuffer(buffer); int bufferOffset = 0; MESSAGE_HEADER.wrap(directBuffer, bufferOffset) .blockLength(CAR.sbeBlockLength()) .templateId(CAR.sbeTemplateId()) .schemaId(CAR.sbeSchemaId()) .version(CAR.sbeSchemaVersion()); bufferOffset += MESSAGE_HEADER.encodedLength(); final int srcOffset = 0; CAR.wrap(directBuffer, bufferOffset) .serialNumber(1234) .modelYear(2013) .available(BooleanType.TRUE) .code(Model.A) .putVehicleCode(vehicleCode, srcOffset); for (int i = 0, size = CarEncoder.someNumbersLength(); i < size; i++) { CAR.someNumbers(i, i); } CAR.extras() .clear() .cruiseControl(true) .sportsPack(true) .sunRoof(false); CAR.engine() .capacity(2000) .numCylinders((short)4) .putManufacturerCode(manufacturerCode, srcOffset); CAR.fuelFiguresCount(3) .next().speed(30).mpg(35.9f) .next().speed(55).mpg(49.0f) .next().speed(75).mpg(40.0f); final CarEncoder.PerformanceFiguresEncoder perfFigures = CAR.performanceFiguresCount(2); perfFigures.next() .octaneRating((short)95) .accelerationCount(3) .next().mph(30).seconds(4.0f) .next().mph(60).seconds(7.5f) .next().mph(100).seconds(12.2f); perfFigures.next() .octaneRating((short)99) .accelerationCount(3) .next().mph(30).seconds(3.8f) .next().mph(60).seconds(7.1f) .next().mph(100).seconds(11.8f); CAR.make(new String(make)); CAR.putModel(model, srcOffset, model.length); bufferOffset += CAR.encodedLength(); buffer.position(bufferOffset); } private static Ir decodeIr(final ByteBuffer buffer) throws IOException { try (final IrDecoder irDecoder = new IrDecoder(buffer)) { return irDecoder.decode(); } } }
UTF-8
Java
7,778
java
JsonPrinterTest.java
Java
[]
null
[]
/* * Copyright 2015 Real Logic Ltd. * * 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 uk.co.real_logic.sbe.json; import baseline.*; import org.junit.BeforeClass; import org.junit.Test; import uk.co.real_logic.agrona.concurrent.UnsafeBuffer; import uk.co.real_logic.sbe.ir.Ir; import uk.co.real_logic.sbe.ir.IrDecoder; import uk.co.real_logic.sbe.ir.IrEncoder; import uk.co.real_logic.sbe.xml.IrGenerator; import uk.co.real_logic.sbe.xml.MessageSchema; import uk.co.real_logic.sbe.xml.ParserOptions; import uk.co.real_logic.sbe.xml.XmlSchemaParser; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import static junit.framework.TestCase.assertEquals; public class JsonPrinterTest { private static final MessageHeaderEncoder MESSAGE_HEADER = new MessageHeaderEncoder(); private static final CarEncoder CAR = new CarEncoder(); private static final int MSG_BUFFER_CAPACITY = 4 * 1024; private static final int SCHEMA_BUFFER_CAPACITY = 16 * 1024; private static byte[] vehicleCode; private static byte[] manufacturerCode; private static byte[] make; private static byte[] model; @BeforeClass public static void setupExampleData() { try { vehicleCode = "abcdef".getBytes(CarEncoder.vehicleCodeCharacterEncoding()); manufacturerCode = "123".getBytes(EngineEncoder.manufacturerCodeCharacterEncoding()); make = "Honda".getBytes(CarEncoder.makeCharacterEncoding()); model = "Civic VTi".getBytes(CarEncoder.modelCharacterEncoding()); } catch (final UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } @Test public void exampleMessagePrintedAsJson() throws Exception { final ByteBuffer encodedSchemaBuffer = ByteBuffer.allocateDirect(SCHEMA_BUFFER_CAPACITY); encodeSchema(encodedSchemaBuffer); final ByteBuffer encodedMsgBuffer = ByteBuffer.allocateDirect(MSG_BUFFER_CAPACITY); encodeTestMessage(encodedMsgBuffer); encodedSchemaBuffer.flip(); final Ir ir = decodeIr(encodedSchemaBuffer); final JsonPrinter printer = new JsonPrinter(ir); final String result = printer.print(encodedMsgBuffer); assertEquals( "{\n" + " \"serialNumber\": 1234,\n" + " \"modelYear\": 2013,\n" + " \"someNumbers\": [0, 1, 2, 3, 4],\n" + " \"vehicleCode\": \"abcdef\",\n" + " \"capacity\": 2000,\n" + " \"numCylinders\": 4,\n" + " \"maxRpm\": 9000,\n" + " \"manufacturerCode\": \"123\",\n" + " \"fuel\": Petrol,\n" + " \"fuelFigures\": [\n" + " {\n" + " \"speed\": 30,\n" + " \"mpg\": 35.9\n" + " },\n" + " {\n" + " \"speed\": 55,\n" + " \"mpg\": 49.0\n" + " },\n" + " {\n" + " \"speed\": 75,\n" + " \"mpg\": 40.0\n" + " }],\n" + " \"performanceFigures\": [\n" + " {\n" + " \"octaneRating\": 95,\n" + " \"acceleration\": [\n" + " {\n" + " \"mph\": 30,\n" + " \"seconds\": 4.0\n" + " },\n" + " {\n" + " \"mph\": 60,\n" + " \"seconds\": 7.5\n" + " },\n" + " {\n" + " \"mph\": 100,\n" + " \"seconds\": 12.2\n" + " }]\n" + " },\n" + " {\n" + " \"octaneRating\": 99,\n" + " \"acceleration\": [\n" + " {\n" + " \"mph\": 30,\n" + " \"seconds\": 3.8\n" + " },\n" + " {\n" + " \"mph\": 60,\n" + " \"seconds\": 7.1\n" + " },\n" + " {\n" + " \"mph\": 100,\n" + " \"seconds\": 11.8\n" + " }]\n" + " }],\n" + " \"make\": \"Honda\",\n" + " \"model\": \"Civic VTi\",\n" + " \"activationCode\": \"\"\n" + "}" , result); } private static void encodeSchema(final ByteBuffer buffer) throws Exception { try (final InputStream in = new FileInputStream("examples/resources/example-schema.xml")) { final MessageSchema schema = XmlSchemaParser.parse(in, ParserOptions.DEFAULT); final Ir ir = new IrGenerator().generate(schema); try (final IrEncoder irEncoder = new IrEncoder(buffer, ir)) { irEncoder.encode(); } } } private static void encodeTestMessage(final ByteBuffer buffer) { final UnsafeBuffer directBuffer = new UnsafeBuffer(buffer); int bufferOffset = 0; MESSAGE_HEADER.wrap(directBuffer, bufferOffset) .blockLength(CAR.sbeBlockLength()) .templateId(CAR.sbeTemplateId()) .schemaId(CAR.sbeSchemaId()) .version(CAR.sbeSchemaVersion()); bufferOffset += MESSAGE_HEADER.encodedLength(); final int srcOffset = 0; CAR.wrap(directBuffer, bufferOffset) .serialNumber(1234) .modelYear(2013) .available(BooleanType.TRUE) .code(Model.A) .putVehicleCode(vehicleCode, srcOffset); for (int i = 0, size = CarEncoder.someNumbersLength(); i < size; i++) { CAR.someNumbers(i, i); } CAR.extras() .clear() .cruiseControl(true) .sportsPack(true) .sunRoof(false); CAR.engine() .capacity(2000) .numCylinders((short)4) .putManufacturerCode(manufacturerCode, srcOffset); CAR.fuelFiguresCount(3) .next().speed(30).mpg(35.9f) .next().speed(55).mpg(49.0f) .next().speed(75).mpg(40.0f); final CarEncoder.PerformanceFiguresEncoder perfFigures = CAR.performanceFiguresCount(2); perfFigures.next() .octaneRating((short)95) .accelerationCount(3) .next().mph(30).seconds(4.0f) .next().mph(60).seconds(7.5f) .next().mph(100).seconds(12.2f); perfFigures.next() .octaneRating((short)99) .accelerationCount(3) .next().mph(30).seconds(3.8f) .next().mph(60).seconds(7.1f) .next().mph(100).seconds(11.8f); CAR.make(new String(make)); CAR.putModel(model, srcOffset, model.length); bufferOffset += CAR.encodedLength(); buffer.position(bufferOffset); } private static Ir decodeIr(final ByteBuffer buffer) throws IOException { try (final IrDecoder irDecoder = new IrDecoder(buffer)) { return irDecoder.decode(); } } }
7,778
0.527771
0.507071
231
32.670994
22.888304
97
false
false
0
0
0
0
0
0
0.493506
false
false
14
57e256b88d1a93665edf7801d64021275ecdca38
21,904,333,263,628
8496f958d01ffa43b1d1eef3f2ae1564b5959ff2
/src/main/java/com/xxh/web/controller/WeChatController.java
dfcd515621a90ea5f484962f8392ce35437e71dc
[]
no_license
wulongtao/web-base-master
https://github.com/wulongtao/web-base-master
b30f37d6a44ff1f6ce8fb50f77b44ea13f570170
77a6521e4db1622d5836de2b974269a9049f9526
refs/heads/master
2020-12-30T17:10:20.365000
2018-04-21T06:44:43
2018-04-21T06:44:43
91,055,507
2
2
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.xxh.web.controller; import com.xxh.web.vo.wechat.WxMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.util.HashMap; import java.util.Map; /** * Created by 小小黑 on 2017/6/25. */ @Controller @RequestMapping("/wechat") public class WeChatController { private final Logger logger = LoggerFactory.getLogger(WeChatController.class); @ResponseBody @RequestMapping("") public String testJson(String signature, String timestamp, String nonce, String echostr, HttpServletRequest request/*, @RequestBody WxMessage wxMessage*/) throws IOException { logger.debug("signature=【"+signature+"】"); logger.debug("timestamp=【"+timestamp+"】"); logger.debug("nonce=【"+nonce+"】"); logger.debug("echostr=【"+echostr+"】"); // logger.debug("wxMessage=【"+wxMessage+"】"); InputStream bis = request.getInputStream(); byte[] bytes = new byte[50000]; bis.read(bytes); logger.debug("message=【"+new String(bytes)+"】"); return echostr; } @ResponseBody @RequestMapping("/index") public Map<String, Object> index(String id) { Map<String, Object> map = new HashMap<>(); Map<String, Object> data = new HashMap<>(); data.put("id", 2); map.put("result", 0); map.put("message", "成功 success"); map.put("data", data); return map; } }
UTF-8
Java
1,742
java
WeChatController.java
Java
[ { "context": ".HashMap;\nimport java.util.Map;\n\n/**\n * Created by 小小黑 on 2017/6/25.\n */\n@Controller\n@RequestMapping(\"/w", "end": 499, "score": 0.9995500445365906, "start": 496, "tag": "USERNAME", "value": "小小黑" } ]
null
[]
package com.xxh.web.controller; import com.xxh.web.vo.wechat.WxMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.util.HashMap; import java.util.Map; /** * Created by 小小黑 on 2017/6/25. */ @Controller @RequestMapping("/wechat") public class WeChatController { private final Logger logger = LoggerFactory.getLogger(WeChatController.class); @ResponseBody @RequestMapping("") public String testJson(String signature, String timestamp, String nonce, String echostr, HttpServletRequest request/*, @RequestBody WxMessage wxMessage*/) throws IOException { logger.debug("signature=【"+signature+"】"); logger.debug("timestamp=【"+timestamp+"】"); logger.debug("nonce=【"+nonce+"】"); logger.debug("echostr=【"+echostr+"】"); // logger.debug("wxMessage=【"+wxMessage+"】"); InputStream bis = request.getInputStream(); byte[] bytes = new byte[50000]; bis.read(bytes); logger.debug("message=【"+new String(bytes)+"】"); return echostr; } @ResponseBody @RequestMapping("/index") public Map<String, Object> index(String id) { Map<String, Object> map = new HashMap<>(); Map<String, Object> data = new HashMap<>(); data.put("id", 2); map.put("result", 0); map.put("message", "成功 success"); map.put("data", data); return map; } }
1,742
0.673888
0.66452
54
30.629629
29.018702
179
false
false
0
0
0
0
0
0
0.777778
false
false
14
24441a7d2999a977acc340f1d39a843281d619d4
5,574,867,569,271
c1d8d342aa8d29b20bfd7ba85955a5171c204d27
/myworkspace/MyJavaPrj/src/foundation/xml/hhfe/dto/MedicalItem.java
64939803d629b8747e6a299ca87acc585000049d
[]
no_license
baijiezi/eclipse-jee-juno-github
https://github.com/baijiezi/eclipse-jee-juno-github
720a693d0325da2c41dd88ffbd418ea94d0df66e
54126f64fd1b720587176edae5919468db5fb0be
refs/heads/master
2020-06-03T03:42:02.653000
2016-02-26T14:06:00
2016-02-26T14:06:00
19,774,098
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package foundation.xml.hhfe.dto; import java.util.HashMap; public class MedicalItem { private HashMap<String, Object> hm; public HashMap<String, Object> getHm() { return hm; } public void setHm(HashMap<String, Object> hm) { this.hm = hm; } }
UTF-8
Java
261
java
MedicalItem.java
Java
[]
null
[]
package foundation.xml.hhfe.dto; import java.util.HashMap; public class MedicalItem { private HashMap<String, Object> hm; public HashMap<String, Object> getHm() { return hm; } public void setHm(HashMap<String, Object> hm) { this.hm = hm; } }
261
0.689655
0.689655
20
12.05
15.236387
46
false
false
0
0
0
0
0
0
1.05
false
false
14
6e3d48e1fc6317a98c9d5f3b92d6807553776ed3
24,361,054,528,189
f297ddd1695f9303c32dd52f488b94852c814de3
/src/main/java/trig/Sec.java
627fd6fb85f991456cc1df68c20fb7f7a4f0c6c6
[]
no_license
xxPFFxx/TPO_Lab_2
https://github.com/xxPFFxx/TPO_Lab_2
2057fb52ce4fd426f064fce3b39742dabcc26697
003767daec4b747d6a1497c8284ece25c6824bf1
refs/heads/master
2023-03-27T23:17:47.577000
2021-04-08T16:08:02
2021-04-08T16:08:02
354,270,699
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package trig; public class Sec implements FunctionInterface { private double eps; private Cos cos; public Sec(double eps){ this.eps = eps; this.cos = new Cos(eps); } public Sec(double eps, Cos cos){ this.eps = eps; this.cos = cos; } public double calculate(double x){ if ((x-Math.PI/2) % Math.PI != 0){ return 1 / cos.calculate(x); } else { return Double.NaN; } } public double stubCalculate(double x){ if ((x-Math.PI/2) % Math.PI != 0){ return 1 / Math.cos(x); } else { return Double.NaN; } } public void setEps(double eps) { this.eps = eps; this.cos.setEps(eps); } }
UTF-8
Java
779
java
Sec.java
Java
[]
null
[]
package trig; public class Sec implements FunctionInterface { private double eps; private Cos cos; public Sec(double eps){ this.eps = eps; this.cos = new Cos(eps); } public Sec(double eps, Cos cos){ this.eps = eps; this.cos = cos; } public double calculate(double x){ if ((x-Math.PI/2) % Math.PI != 0){ return 1 / cos.calculate(x); } else { return Double.NaN; } } public double stubCalculate(double x){ if ((x-Math.PI/2) % Math.PI != 0){ return 1 / Math.cos(x); } else { return Double.NaN; } } public void setEps(double eps) { this.eps = eps; this.cos.setEps(eps); } }
779
0.496791
0.489089
35
21.257143
14.138787
47
false
false
0
0
0
0
0
0
0.4
false
false
14
48ec96f5206607d3811adaf77a983887cabfbfe9
7,507,602,859,790
111a0b930879a5c55f562b3638e27e4444feb960
/src/Tutorial_Book_Study/StringComparison.java
3745a7a5978752dc0f07f8b388ad4849af0c074e
[ "MIT" ]
permissive
rvenegas5/OOP-Java
https://github.com/rvenegas5/OOP-Java
52102d51b482c721e7158fe4ac5e34b4c99ef8a2
3ecc0e6eae585c0b53b8f5a53487e3cc705ad1a4
refs/heads/master
2022-11-30T18:42:36.171000
2020-08-13T04:38:21
2020-08-13T04:38:21
287,149,740
0
0
MIT
true
2020-08-13T01:13:41
2020-08-13T01:13:40
2020-07-19T20:44:39
2020-07-08T20:20:10
169
0
0
0
null
false
false
package Tutorial_Book_Study; import java.util.*; public class StringComparison { public static void main(String args []){ String pass1 = "A01997"; String pass2 = "A01997"; String pass3 = new String("a01997"); String pass4 = new String("A01997"); System.out.println(pass1==pass3); // "==", "reference of object" ke compare kore System.out.println(pass1.equals(pass3)); // equals "value/content" ke compare kore System.out.println(pass2.equalsIgnoreCase(pass3)); // equalsIgnoreCase case sensitive na System.out.println(pass3.equals(pass4)); } }
UTF-8
Java
663
java
StringComparison.java
Java
[ { "context": "id main(String args []){\r\n String pass1 = \"A01997\";\r\n String pass2 = \"A01997\";\r\n Stri", "end": 168, "score": 0.9987490773200989, "start": 162, "tag": "PASSWORD", "value": "A01997" }, { "context": "String pass1 = \"A01997\";\r\n String pass2 = \"A01997\";\r\n String pass3 = new String(\"a01997\");\r\n", "end": 202, "score": 0.9990395903587341, "start": 196, "tag": "PASSWORD", "value": "A01997" }, { "context": "2 = \"A01997\";\r\n String pass3 = new String(\"a01997\");\r\n String pass4 = new String(\"A01997\");\r", "end": 247, "score": 0.9970026016235352, "start": 241, "tag": "PASSWORD", "value": "a01997" }, { "context": "ng(\"a01997\");\r\n String pass4 = new String(\"A01997\");\r\n \r\n System.out.println(pass1==p", "end": 293, "score": 0.9992405772209167, "start": 287, "tag": "PASSWORD", "value": "A01997" } ]
null
[]
package Tutorial_Book_Study; import java.util.*; public class StringComparison { public static void main(String args []){ String pass1 = "<PASSWORD>"; String pass2 = "<PASSWORD>"; String pass3 = new String("<PASSWORD>"); String pass4 = new String("<PASSWORD>"); System.out.println(pass1==pass3); // "==", "reference of object" ke compare kore System.out.println(pass1.equals(pass3)); // equals "value/content" ke compare kore System.out.println(pass2.equalsIgnoreCase(pass3)); // equalsIgnoreCase case sensitive na System.out.println(pass3.equals(pass4)); } }
679
0.61086
0.562594
17
37
31.574375
98
false
false
0
0
0
0
0
0
0.647059
false
false
14
cdc42235b48e316a4431bb0bed2e174b4342f7a8
30,434,138,287,524
cfff003bc954ac51a53726635b6c15ca1b2900ba
/corejavatraining/src/com/vm/training/java/strings/StartWith.java
e8751f0295b62d70d5f936d717b038deeedb586c
[]
no_license
Asritha123/core-java
https://github.com/Asritha123/core-java
c0821fa455d20ae8b403b6ea90582173534d3538
b24458480e599c67bcd7b3113ccdc77c28632f33
refs/heads/master
2023-05-30T05:10:18.275000
2021-06-17T11:15:04
2021-06-17T11:15:04
372,224,056
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.vm.training.java.strings; public class StartWith { public static void main(String[] args){ String str = "When we take the time to examine the beauty of the world around us"; System.out.println("Is this string starts with "+"THIS"+" "+str.startsWith("When")); System.out.println("Is this string starts with "+"IS"+" " +str.startsWith("is")); System.out.println("Is this string starts with "+ " is after INDEX 5 "+str.startsWith("is", 5)); } }
UTF-8
Java
515
java
StartWith.java
Java
[]
null
[]
package com.vm.training.java.strings; public class StartWith { public static void main(String[] args){ String str = "When we take the time to examine the beauty of the world around us"; System.out.println("Is this string starts with "+"THIS"+" "+str.startsWith("When")); System.out.println("Is this string starts with "+"IS"+" " +str.startsWith("is")); System.out.println("Is this string starts with "+ " is after INDEX 5 "+str.startsWith("is", 5)); } }
515
0.629126
0.625243
13
37.76923
39.809456
104
false
false
0
0
0
0
0
0
0.461538
false
false
14
5b40476e1e33085988ce925974c93daf991712e8
31,318,901,589,425
79cfc372afda30721225a715c2954e4622861781
/algorithms/findsubset/src/main/removeduplicates/MainIntFileSb.java
07863c48b2dc9df4ba26611544da356ee77419d7
[]
no_license
A1esandr/jtasks
https://github.com/A1esandr/jtasks
1cb426506e80918334fcf5112e9226ce3eae2e7a
46bb433450324912aedb5fb22a661bef450ad7f2
refs/heads/master
2021-07-10T14:22:42.668000
2020-12-12T19:03:41
2020-12-12T19:03:41
226,080,048
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package main.removeduplicates; import java.io.*; public class MainIntFileSb { public static void main(String[] args) throws Exception { File file = new File("input.txt"); File outfile = new File("output.txt"); BufferedWriter writer = new BufferedWriter(new FileWriter(outfile)); BufferedReader r = new BufferedReader(new FileReader(file), 100); String size = r.readLine(); int sizeInt = Integer.parseInt(size); if (sizeInt == 0){ writer.write("\n"); writer.close(); return; } int last = 0; int lastValue = Integer.parseInt(r.readLine()); int next; StringBuilder sb = new StringBuilder(); sb.append(lastValue); sb.append("\n"); for(int i = 1; i < sizeInt; i++){ next = Integer.parseInt(r.readLine()); if (next > lastValue){ if(last == 100){ writer.write(sb.toString()); sb = new StringBuilder(); last = -1; } sb.append(next); sb.append("\n"); ++last; lastValue = next; } } writer.write(sb.toString()); writer.close(); } }
UTF-8
Java
1,306
java
MainIntFileSb.java
Java
[]
null
[]
package main.removeduplicates; import java.io.*; public class MainIntFileSb { public static void main(String[] args) throws Exception { File file = new File("input.txt"); File outfile = new File("output.txt"); BufferedWriter writer = new BufferedWriter(new FileWriter(outfile)); BufferedReader r = new BufferedReader(new FileReader(file), 100); String size = r.readLine(); int sizeInt = Integer.parseInt(size); if (sizeInt == 0){ writer.write("\n"); writer.close(); return; } int last = 0; int lastValue = Integer.parseInt(r.readLine()); int next; StringBuilder sb = new StringBuilder(); sb.append(lastValue); sb.append("\n"); for(int i = 1; i < sizeInt; i++){ next = Integer.parseInt(r.readLine()); if (next > lastValue){ if(last == 100){ writer.write(sb.toString()); sb = new StringBuilder(); last = -1; } sb.append(next); sb.append("\n"); ++last; lastValue = next; } } writer.write(sb.toString()); writer.close(); } }
1,306
0.493874
0.486217
44
28.681818
18.80978
76
false
false
0
0
0
0
0
0
0.681818
false
false
14
2e51c979dbe241a691baa27be1372bba454dc29a
12,369,505,812,965
7ef3b3b960031d1ea24ca7c5f4394aa6fac8fd7f
/Dumbo/src/test/OracleConnection2.java
b863202e96e6f8a237828c7cb8dbfce714558563
[]
no_license
abbi-gaurav/learning
https://github.com/abbi-gaurav/learning
cc7c028718c391f4a4346344898102fd3ec7f9f1
1fb3afe77691c0286e6a75cf0a7a9c150338a065
refs/heads/master
2016-09-15T17:10:18.316000
2016-03-20T18:37:27
2016-03-20T18:37:27
10,077,091
2
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class OracleConnection2 { private static final String QUERY = "select * from user_tables"; // private static final String USER = "DELTEAM3"; // private static final String PWD = "W00d5!oCk"; private static final String USER = "giridhar"; private static final String PWD = "password"; // private static final String URL = "jdbc:oracle:thin:@10.11.23.110:1521:blrdb01"; private static final String URL = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=10.11.23.14)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=orcl.blreng.scieng.local)))"; // (ADDRESS=(PROTOCOL=TCP)(HOST=blrgiswin03.blreng.scieng.local)(PORT=1521)) //private static final String URL = "jdbc:oracle:thin:@10.11.23.14:1521:orcl"; private static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName(DRIVER); System.out.println("Starting..."); Properties props = new Properties(); props.setProperty("user", USER); props.setProperty("password", PWD); props.setProperty("oracle.net.ssl_cipher_suites", "(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_anon_WITH_DES_CBC_SHA)"); props.setProperty("oracle.net.ssl_server_dn_match", "false"); Connection conn = DriverManager.getConnection(URL,props); Statement stmnt = conn.createStatement(); ResultSet rs = stmnt.executeQuery(QUERY); System.out.println("Rs["+rs+"]"); int columns = rs.getMetaData().getColumnCount(); while(rs.next()){ for(int i = 1; i <= columns; i++){ System.out.print(rs.getObject(i)+(i<= (columns-1) ? "--" : "")); } System.out.println(); } stmnt.close(); conn.close(); } }
UTF-8
Java
1,958
java
OracleConnection2.java
Java
[ { "context": "_tables\";\r\n//\tprivate static final String USER = \"DELTEAM3\";\r\n//\tprivate static final String PWD = \"W00d5!oC", "end": 345, "score": 0.9994165897369385, "start": 337, "tag": "USERNAME", "value": "DELTEAM3" }, { "context": "DELTEAM3\";\r\n//\tprivate static final String PWD = \"W00d5!oCk\";\r\n\tprivate static final String USER = \"giridhar\"", "end": 396, "score": 0.9993377923965454, "start": 387, "tag": "PASSWORD", "value": "W00d5!oCk" }, { "context": "W00d5!oCk\";\r\n\tprivate static final String USER = \"giridhar\";\r\n\tprivate static final String PWD = \"password\";", "end": 445, "score": 0.9996232986450195, "start": 437, "tag": "USERNAME", "value": "giridhar" }, { "context": " \"giridhar\";\r\n\tprivate static final String PWD = \"password\";\r\n\r\n//\tprivate static final String URL = \"jdbc:o", "end": 493, "score": 0.998445451259613, "start": 485, "tag": "PASSWORD", "value": "password" }, { "context": "vate static final String URL = \"jdbc:oracle:thin:@10.11.23.110:1521:blrdb01\";\r\n\tprivate static final String URL ", "end": 567, "score": 0.7809277176856995, "start": 555, "tag": "IP_ADDRESS", "value": "10.11.23.110" }, { "context": "vate static final String URL = \"jdbc:oracle:thin:@10.11.23.14:1521:orcl\";\r\n\tprivate static final String DRIVER ", "end": 918, "score": 0.870418906211853, "start": 907, "tag": "IP_ADDRESS", "value": "10.11.23.14" } ]
null
[]
package test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; public class OracleConnection2 { private static final String QUERY = "select * from user_tables"; // private static final String USER = "DELTEAM3"; // private static final String PWD = "<PASSWORD>"; private static final String USER = "giridhar"; private static final String PWD = "<PASSWORD>"; // private static final String URL = "jdbc:oracle:thin:@10.11.23.110:1521:blrdb01"; private static final String URL = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=10.11.23.14)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=orcl.blreng.scieng.local)))"; // (ADDRESS=(PROTOCOL=TCP)(HOST=blrgiswin03.blreng.scieng.local)(PORT=1521)) //private static final String URL = "jdbc:oracle:thin:@10.11.23.14:1521:orcl"; private static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName(DRIVER); System.out.println("Starting..."); Properties props = new Properties(); props.setProperty("user", USER); props.setProperty("password", PWD); props.setProperty("oracle.net.ssl_cipher_suites", "(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_anon_WITH_DES_CBC_SHA)"); props.setProperty("oracle.net.ssl_server_dn_match", "false"); Connection conn = DriverManager.getConnection(URL,props); Statement stmnt = conn.createStatement(); ResultSet rs = stmnt.executeQuery(QUERY); System.out.println("Rs["+rs+"]"); int columns = rs.getMetaData().getColumnCount(); while(rs.next()){ for(int i = 1; i <= columns; i++){ System.out.print(rs.getObject(i)+(i<= (columns-1) ? "--" : "")); } System.out.println(); } stmnt.close(); conn.close(); } }
1,961
0.692543
0.662921
49
37.918365
33.356354
178
false
false
0
0
0
0
0
0
2.183673
false
false
14
789f77bdcd0e77f14d2e1c6f00bb4db394505d3a
12,369,505,814,285
4171fe9ca4e6202de37602f73f8ea92437a54460
/src/easy/Problem504.java
40e34762af70a09267f145a1a1b220ea511d3699
[]
no_license
uzck/leetcode
https://github.com/uzck/leetcode
19992722e19279f89e635b4b82f52d21a2988c45
178f78479ad6321a22cca31d3d67996f794758a5
refs/heads/master
2020-04-10T12:47:15.177000
2019-10-13T10:56:11
2019-10-13T10:56:11
161,032,196
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package easy; /** * Base 7 * 10进制数用7进制表示 * 输入的范围在[-1e7,1e7] 不用考虑越界问题 */ public class Problem504 { /** * 1ms 94.12% * 短除法 * @param num * @return */ public String convertToBase7(int num) { StringBuffer buffer = new StringBuffer(); while (num > 0) { buffer.append(num % 7); num /= 7; } return num > 0 ? buffer.reverse().toString() : "-" + buffer.reverse().toString(); } public static void main(String[] args) { } }
UTF-8
Java
570
java
Problem504.java
Java
[]
null
[]
package easy; /** * Base 7 * 10进制数用7进制表示 * 输入的范围在[-1e7,1e7] 不用考虑越界问题 */ public class Problem504 { /** * 1ms 94.12% * 短除法 * @param num * @return */ public String convertToBase7(int num) { StringBuffer buffer = new StringBuffer(); while (num > 0) { buffer.append(num % 7); num /= 7; } return num > 0 ? buffer.reverse().toString() : "-" + buffer.reverse().toString(); } public static void main(String[] args) { } }
570
0.515385
0.475
27
18.25926
19.600817
89
false
false
0
0
0
0
0
0
0.222222
false
false
14
6a21b9c445b0163bb51a118f91e8ce1ff1635031
27,839,978,019,550
582098b9bc36f6d4a87a03f3cab1cc7e8d025ca2
/src/MODELE/Consommation.java
1ec3e817fa6542fc7bf5a7650873cf076719ae0b
[]
no_license
CLacaile/Facturation_Electricite
https://github.com/CLacaile/Facturation_Electricite
1af81d4fddf43c874503e7e9ef47f9c18f47a04e
cbd553a7a82df17bb872ac990b14e0675400aa4d
refs/heads/master
2020-04-15T12:24:05.874000
2019-01-14T20:24:34
2019-01-14T20:24:34
164,672,423
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package MODELE; import javax.persistence.*; import java.time.LocalDate; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @Entity public class Consommation { @Id @GeneratedValue private long id; private LocalDate date; private LocalTime heureDeb; private LocalTime heureArr; private int puissance; @ManyToOne(cascade = CascadeType.ALL) private Compteur compteur; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "Consommation_Tarif", joinColumns = {@JoinColumn(name = "Consommation_Id")}, inverseJoinColumns = {@JoinColumn(name = "Tarif_Id")}) private List<Tarif> tarifs = new ArrayList<>(); /** * @return the id */ public long getId() { return id; } /** * @return the date */ public LocalDate getDate() { return date; } /** * @param date the date to set */ public void setDate(LocalDate date) { this.date = date; } /** * @return the heureDeb */ public LocalTime getHeureDeb() { return heureDeb; } /** * @param heureDeb the heureDeb to set */ public void setHeureDeb(LocalTime heureDeb) { this.heureDeb = heureDeb; } /** * @return the heureArr */ public LocalTime getHeureArr() { return heureArr; } /** * @param heureArr the heureArr to set */ public void setHeureArr(LocalTime heureArr) { this.heureArr = heureArr; } /** * @return the puissance */ public int getPuissance() { return puissance; } /** * @param puissance the puissance to set */ public void setPuissance(int puissance) { this.puissance = puissance; } /** * @return the tarifs */ public List<Tarif> getTarifs() { return tarifs; } /** * @param tarifs the tarifs to set */ public void setTarifs(List<Tarif> tarifs) { this.tarifs = tarifs; } /** * @return the compteur */ public Compteur getCompteur() { return compteur; } /** * @param compteur */ public void setCompteur(Compteur compteur) { this.compteur = compteur; } /** * Retourne la consommation sous la forme d'une chaine de caracteres * @return Identifiant de la consommation : #id; Heure de debut : #heureDeb; Heure de fin : #heureArr; Puissance : #puissance kWh */ public String toString() { return "Identifiant de la consommation : " + id + "; Date : " + date.toString() + "; Heure de debut : " + heureDeb.toString() + "; Heure de fin : " + heureArr.toString() + "; Puissance : " + puissance + "kWh"; } }
UTF-8
Java
2,432
java
Consommation.java
Java
[]
null
[]
package MODELE; import javax.persistence.*; import java.time.LocalDate; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @Entity public class Consommation { @Id @GeneratedValue private long id; private LocalDate date; private LocalTime heureDeb; private LocalTime heureArr; private int puissance; @ManyToOne(cascade = CascadeType.ALL) private Compteur compteur; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "Consommation_Tarif", joinColumns = {@JoinColumn(name = "Consommation_Id")}, inverseJoinColumns = {@JoinColumn(name = "Tarif_Id")}) private List<Tarif> tarifs = new ArrayList<>(); /** * @return the id */ public long getId() { return id; } /** * @return the date */ public LocalDate getDate() { return date; } /** * @param date the date to set */ public void setDate(LocalDate date) { this.date = date; } /** * @return the heureDeb */ public LocalTime getHeureDeb() { return heureDeb; } /** * @param heureDeb the heureDeb to set */ public void setHeureDeb(LocalTime heureDeb) { this.heureDeb = heureDeb; } /** * @return the heureArr */ public LocalTime getHeureArr() { return heureArr; } /** * @param heureArr the heureArr to set */ public void setHeureArr(LocalTime heureArr) { this.heureArr = heureArr; } /** * @return the puissance */ public int getPuissance() { return puissance; } /** * @param puissance the puissance to set */ public void setPuissance(int puissance) { this.puissance = puissance; } /** * @return the tarifs */ public List<Tarif> getTarifs() { return tarifs; } /** * @param tarifs the tarifs to set */ public void setTarifs(List<Tarif> tarifs) { this.tarifs = tarifs; } /** * @return the compteur */ public Compteur getCompteur() { return compteur; } /** * @param compteur */ public void setCompteur(Compteur compteur) { this.compteur = compteur; } /** * Retourne la consommation sous la forme d'une chaine de caracteres * @return Identifiant de la consommation : #id; Heure de debut : #heureDeb; Heure de fin : #heureArr; Puissance : #puissance kWh */ public String toString() { return "Identifiant de la consommation : " + id + "; Date : " + date.toString() + "; Heure de debut : " + heureDeb.toString() + "; Heure de fin : " + heureArr.toString() + "; Puissance : " + puissance + "kWh"; } }
2,432
0.662418
0.662418
118
19.61017
19.269293
130
false
false
0
0
0
0
0
0
1.432203
false
false
14
b80946db41b213307bb0c3e61c2683dab1f295a3
20,950,850,492,672
d6df927388a6c5bca5c0129d783e5d48305da6c7
/src/test/java/com/learning/_392/SolutionTest.java
98aca7db0b80d903a3a69a83ce915e727cc5a0c3
[]
no_license
angrylittlebird/leetcode
https://github.com/angrylittlebird/leetcode
2891883a960d6a6de272c1812351f5e3b01b2cc6
99c4b5aa77ac04ecb9c238f6acdf352a1038f88f
refs/heads/master
2021-08-14T14:57:38.695000
2021-08-04T00:52:10
2021-08-04T00:52:10
203,542,374
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.learning._392; import org.junit.Test; import static org.junit.Assert.assertFalse; /** * @Author: ZHANG * @Date: 2021/2/13 * @Description: */ public class SolutionTest { @Test public void isSubsequence() { Solution solution = new Solution(); boolean subsequence = solution.isSubsequence("acb", "ahbgdc"); assertFalse(subsequence); } }
UTF-8
Java
389
java
SolutionTest.java
Java
[ { "context": "tic org.junit.Assert.assertFalse;\n\n/**\n * @Author: ZHANG\n * @Date: 2021/2/13\n * @Description:\n */\npublic c", "end": 118, "score": 0.9948871731758118, "start": 113, "tag": "NAME", "value": "ZHANG" } ]
null
[]
package com.learning._392; import org.junit.Test; import static org.junit.Assert.assertFalse; /** * @Author: ZHANG * @Date: 2021/2/13 * @Description: */ public class SolutionTest { @Test public void isSubsequence() { Solution solution = new Solution(); boolean subsequence = solution.isSubsequence("acb", "ahbgdc"); assertFalse(subsequence); } }
389
0.658098
0.632391
20
18.5
18.508106
70
false
false
0
0
0
0
0
0
0.35
false
false
14
3abef2f278daab651dda304472dfe19543921c91
25,142,738,589,086
9e854b2e15f1758ec32f9d750f38d0f8b2d30e43
/src/com/herenit/hhw/dao/smsmodule/HcSmsModuleMapper.java
08eacc75dc7af3835f9c5ba523e919f68eaf9381
[]
no_license
YangLin2510/health-cloud
https://github.com/YangLin2510/health-cloud
e6b08c5334648eed8acb28b8ce261097cb79cf4a
e6370c19432d2745be295d23aa78ce704c6a39be
refs/heads/master
2016-09-16T16:06:31.415000
2016-07-20T00:51:08
2016-07-20T00:51:08
63,738,150
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.herenit.hhw.dao.smsmodule; import java.util.List; import org.springframework.stereotype.Repository; /** * <p>ClassName: [Hcsmsmodule]</p> * * <p>Description: [请一句话描述该类的作用]</p> * * <p>Author: [tsinghua]</p> * * <p>UpdateUser: [tsinghua] </p> * * <p>UpdateRemark: [说明本次修改内容]</p> * * <p>@Version: [v1.0] </p> */ @Repository public interface HcSmsModuleMapper { public HcSmsModule getObject(HcSmsModule obj); public void insert(HcSmsModule obj); public void delete(HcSmsModule obj); public void update(HcSmsModule obj); public List<HcSmsModule> getList(HcSmsModule obj); }
UTF-8
Java
668
java
HcSmsModuleMapper.java
Java
[ { "context": "ption: [请一句话描述该类的作用]</p>\n *\n * <p>Author: [tsinghua]</p>\n *\n * <p>UpdateUser: [tsinghua] </p>\n *\n *", "end": 230, "score": 0.9959692358970642, "start": 222, "tag": "USERNAME", "value": "tsinghua" }, { "context": "hor: [tsinghua]</p>\n *\n * <p>UpdateUser: [tsinghua] </p>\n *\n * <p>UpdateRemark: [说明本次修改内容]</p>\n *\n *", "end": 268, "score": 0.9947290420532227, "start": 260, "tag": "USERNAME", "value": "tsinghua" } ]
null
[]
package com.herenit.hhw.dao.smsmodule; import java.util.List; import org.springframework.stereotype.Repository; /** * <p>ClassName: [Hcsmsmodule]</p> * * <p>Description: [请一句话描述该类的作用]</p> * * <p>Author: [tsinghua]</p> * * <p>UpdateUser: [tsinghua] </p> * * <p>UpdateRemark: [说明本次修改内容]</p> * * <p>@Version: [v1.0] </p> */ @Repository public interface HcSmsModuleMapper { public HcSmsModule getObject(HcSmsModule obj); public void insert(HcSmsModule obj); public void delete(HcSmsModule obj); public void update(HcSmsModule obj); public List<HcSmsModule> getList(HcSmsModule obj); }
668
0.673016
0.669841
33
18.121212
18.505949
51
false
false
0
0
0
0
0
0
0.545455
false
false
14
834ac402f2ed91093b6b21095f7b86ea26e43384
15,728,170,306,720
039bd544d1ed35410a74741822c9e5126e1c1020
/src/main/java/MusicShop/Accessories/DrumSticks.java
5ea1bc0536934e0251df57ef9041afe5f1c1a011
[]
no_license
helenosheaa/music_shop
https://github.com/helenosheaa/music_shop
9bc41a6fc0bb0355494e689f15c5d05cbe1a7f27
7f0e5d728aa1378e36abd63ce4a2fcff1d840f6c
refs/heads/master
2020-03-22T11:19:07.928000
2018-07-08T10:54:00
2018-07-08T10:54:00
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package MusicShop.Accessories; import MusicShop.Behaviours.ISell; public class DrumSticks extends Accessory implements ISell { private double costPrice; private double sellPrice; public DrumSticks(String name, String description, double costPrice, double sellPrice) { super(name, description); this.costPrice = costPrice; this.sellPrice = sellPrice; } public double getSellPrice() { return this.sellPrice; } public double getCostPrice() { return this.costPrice; } @Override public double calculateMarkUp() { double markUp = sellPrice - costPrice; return markUp; } }
UTF-8
Java
749
java
DrumSticks.java
Java
[]
null
[]
package MusicShop.Accessories; import MusicShop.Behaviours.ISell; public class DrumSticks extends Accessory implements ISell { private double costPrice; private double sellPrice; public DrumSticks(String name, String description, double costPrice, double sellPrice) { super(name, description); this.costPrice = costPrice; this.sellPrice = sellPrice; } public double getSellPrice() { return this.sellPrice; } public double getCostPrice() { return this.costPrice; } @Override public double calculateMarkUp() { double markUp = sellPrice - costPrice; return markUp; } }
749
0.604806
0.604806
29
24.827587
22.554255
96
false
false
0
0
0
0
0
0
0.517241
false
false
2
011747f52ccd7b7e31a385b874cb6e0557db2000
19,189,913,884,612
c2d9fdc6c57be076fef55979a377493486872162
/src/main/java/com/ibotta/main/repository/Dictionary.java
c3e9917d71078d42d4eb2abfaede64dc649b47d0
[]
no_license
AlexanderSav/Ibotta
https://github.com/AlexanderSav/Ibotta
1b657d43d9425b431d12c6da873cd816658dc0e2
608c521ef2b8a3510ea56cdb8057dcefb55dea5a
refs/heads/master
2020-06-25T06:47:59.332000
2019-07-30T23:39:27
2019-07-30T23:39:27
199,236,229
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.ibotta.main.repository; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.CopyOnWriteArraySet; import javax.annotation.PostConstruct; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; /** * @author Alexandr Savenkov * */ @Repository @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) public class Dictionary { private final String dicFileName = "dictionary.txt"; private Map<String, Set<String>> cache; public Map<String, Set<String>> getDataStorage(){ return cache; } private Map<String, Set<String>> initCache(){ /* * The HashMap implementation provides constant time performance for (get and put) basic operations * i.e the complexity of get() and put() is O(1) , assuming the hash function disperses the elements * properly among the buckets. */ //return new ConcurrentHashMap<String, Set<String>>(); /* * Treemap(ConcurrentSkipListMap) is sorted according to the natural ordering of its keys, or by a * Comparator provided at map creation time, depending on which constructor is used. This implementation * provides guaranteed log(n)time cost for the containsKey, get, put and remove operations. * For search operation,in java 7,it will take O(n) with a linked list. * While in java 8 , the same search operation in a tree will cost O(log(n)). */ return new ConcurrentSkipListMap<String, Set<String>>(); } private Set<String> initAnagramGroup(){ return new CopyOnWriteArraySet<String>(); } @PostConstruct public void init() { cache = initCache(); try (BufferedReader br = new BufferedReader(new InputStreamReader( this.getClass().getResourceAsStream("/" + dicFileName)))) { String word; while ((word = br.readLine()) != null) { String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set==null){ cache.put(key, initAnagramGroup()); } cache.get(key).add(word); } } catch (IOException e) { e.printStackTrace(); } } private String getDictionaryKey(String word){ if(word==null) return null; return word.chars().sorted(). collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append). toString(); } public Set<String> getAnagramSet(String word){ //retrieving anagrams, word can be out of set return cache.get(this.getDictionaryKey(word)); } public void addWords(String...words){ Arrays.stream(words).forEach( word->{ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set==null){ set = new CopyOnWriteArraySet<String>(); } set.add(word); cache.put(key, set); } ); } public boolean deleteWord(String word){ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set!=null&&set.contains(word)){ set.remove(word); return true; } return false; } public void deleteWords(){ cache = initCache(); } //Optional public boolean deleteAnagramsByWord(String word){ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); //Note that a word is not considered to be its own anagram. if(set!=null&&set.size()>1){ cache.remove(key); return true; } return false; } public boolean checkIfAllWordsAreInOneAnagramSet(String...words){ if(words.length<1) return false; if(Arrays.stream(words). map(this::getDictionaryKey). distinct(). count()>1) return false; String key = this.getDictionaryKey(words[0]); Set<String> set = cache.get(key); if(set!=null&&set.size()>1){ return Arrays.stream(words). filter(s->!set.contains(s)). count()==0; } return false; } }
UTF-8
Java
4,046
java
Dictionary.java
Java
[ { "context": "ngframework.stereotype.Repository;\n\n/**\n * @author Alexandr Savenkov\n *\n */\n@Repository\n@Scope(value = ConfigurableBea", "end": 549, "score": 0.9997838139533997, "start": 532, "tag": "NAME", "value": "Alexandr Savenkov" } ]
null
[]
package com.ibotta.main.repository; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.CopyOnWriteArraySet; import javax.annotation.PostConstruct; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Repository; /** * @author <NAME> * */ @Repository @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON) public class Dictionary { private final String dicFileName = "dictionary.txt"; private Map<String, Set<String>> cache; public Map<String, Set<String>> getDataStorage(){ return cache; } private Map<String, Set<String>> initCache(){ /* * The HashMap implementation provides constant time performance for (get and put) basic operations * i.e the complexity of get() and put() is O(1) , assuming the hash function disperses the elements * properly among the buckets. */ //return new ConcurrentHashMap<String, Set<String>>(); /* * Treemap(ConcurrentSkipListMap) is sorted according to the natural ordering of its keys, or by a * Comparator provided at map creation time, depending on which constructor is used. This implementation * provides guaranteed log(n)time cost for the containsKey, get, put and remove operations. * For search operation,in java 7,it will take O(n) with a linked list. * While in java 8 , the same search operation in a tree will cost O(log(n)). */ return new ConcurrentSkipListMap<String, Set<String>>(); } private Set<String> initAnagramGroup(){ return new CopyOnWriteArraySet<String>(); } @PostConstruct public void init() { cache = initCache(); try (BufferedReader br = new BufferedReader(new InputStreamReader( this.getClass().getResourceAsStream("/" + dicFileName)))) { String word; while ((word = br.readLine()) != null) { String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set==null){ cache.put(key, initAnagramGroup()); } cache.get(key).add(word); } } catch (IOException e) { e.printStackTrace(); } } private String getDictionaryKey(String word){ if(word==null) return null; return word.chars().sorted(). collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append). toString(); } public Set<String> getAnagramSet(String word){ //retrieving anagrams, word can be out of set return cache.get(this.getDictionaryKey(word)); } public void addWords(String...words){ Arrays.stream(words).forEach( word->{ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set==null){ set = new CopyOnWriteArraySet<String>(); } set.add(word); cache.put(key, set); } ); } public boolean deleteWord(String word){ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); if(set!=null&&set.contains(word)){ set.remove(word); return true; } return false; } public void deleteWords(){ cache = initCache(); } //Optional public boolean deleteAnagramsByWord(String word){ String key = this.getDictionaryKey(word); Set<String> set = cache.get(key); //Note that a word is not considered to be its own anagram. if(set!=null&&set.size()>1){ cache.remove(key); return true; } return false; } public boolean checkIfAllWordsAreInOneAnagramSet(String...words){ if(words.length<1) return false; if(Arrays.stream(words). map(this::getDictionaryKey). distinct(). count()>1) return false; String key = this.getDictionaryKey(words[0]); Set<String> set = cache.get(key); if(set!=null&&set.size()>1){ return Arrays.stream(words). filter(s->!set.contains(s)). count()==0; } return false; } }
4,035
0.6913
0.689076
150
25.973333
25.090488
107
false
false
0
0
0
0
0
0
1.96
false
false
2
57dafaf07c74fae3fb156c281cdf6a847ea30ceb
14,456,859,925,173
4e51de4348d2968305bb0ad24eed27008ac20f65
/study/java-design-patterns/src/main/java/com/paradm/designpatterns/iterator/BookShelf.java
3e5313b87071ba8818e45dc3fc46fd2f634e1a65
[]
no_license
jackyagui/jackyshen-java-study
https://github.com/jackyagui/jackyshen-java-study
74f4e7825e79104bd6e370840965e1562e05b89b
3ae0c312ed4a024b304eedd0846ef42817c88036
refs/heads/master
2021-09-26T20:29:37.879000
2018-11-02T08:12:41
2018-11-02T08:12:41
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.paradm.designpatterns.iterator; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class BookShelf implements Aggregate { private List<Book> bookList; private int last = 0; public BookShelf() { this.bookList = new ArrayList<Book>(); } public Book getBookAt(int index) { return bookList.get(index); } public void appendBook(Book book) { this.bookList.add(book); last++; } public int getLength() { return last; } @Override public Iterator<Book> iterator() { return new BookShelfIterator(this); } }
UTF-8
Java
635
java
BookShelf.java
Java
[]
null
[]
package com.paradm.designpatterns.iterator; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class BookShelf implements Aggregate { private List<Book> bookList; private int last = 0; public BookShelf() { this.bookList = new ArrayList<Book>(); } public Book getBookAt(int index) { return bookList.get(index); } public void appendBook(Book book) { this.bookList.add(book); last++; } public int getLength() { return last; } @Override public Iterator<Book> iterator() { return new BookShelfIterator(this); } }
635
0.650394
0.648819
34
16.67647
15.747494
45
false
false
0
0
0
0
0
0
0.352941
false
false
2
8703aeb51784fb84911d9e1be495fbacc8373215
11,209,864,686,228
492aeac9d4d45a365d54dbb7b69b4ae61e93e2c0
/src/test/java/com/mlbam/rms/infrastructure/resources/EndToEndTests/ArrisDSR6401EndToEndTest.java
43f802d64e1498aa55a03797e79b00a581d1eb33
[]
no_license
cstarling/streamshield-snmp
https://github.com/cstarling/streamshield-snmp
70c8751969d70dc0c0dac0a35f31a02419fdf536
2847d539094ecd5633584ede680836e6121144ef
refs/heads/master
2016-09-13T21:33:30.515000
2016-06-05T05:19:42
2016-06-05T05:19:42
60,444,205
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.mlbam.rms.infrastructure.resources.EndToEndTests; import com.mlbam.rms.infrastructure.resources.Constants.Constants; import com.mlbam.rms.infrastructure.resources.OutputASIStream; import com.mlbam.rms.infrastructure.resources.OutputStream; import com.mlbam.rms.infrastructure.resources.Stream; import com.mlbam.rms.infrastructure.resources.StreamShieldResource; import com.mlbam.rms.infrastructure.resources.TestObjects.*; import org.junit.BeforeClass; import org.junit.Test; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.mlbam.rms.infrastructure.resources.EndToEndTests.TestClass.endToEndTestHelper; import static org.junit.Assert.assertEquals; /** * Created by starling on 5/23/16. */ public class ArrisDSR6401EndToEndTest { private final static String TABLE_TO_WRITE_TO = "encoder_object_test"; private static final int STREAM_PASS_THROUGH_INDEX = 0; private static final int STREAM_ASI_INDEX = 1; private static final int STREAM_TRANSCODED_INDEX = 2; private static List<Stream> streamList = new ArrayList<Stream>(); public ArrayList<Map<String, String>> resultsFromDataBase; private static TestClass testClass; private static Stream passthrough_stream; private static Stream transcoded_stream; private static Stream asi_stream; @BeforeClass public static void beforeClass() throws SQLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, InterruptedException { EndToEndTestHelper endToEndTestHelper = new EndToEndTestHelper("ArrisDSR6401"); endToEndTestHelper.truncateTestTable(TABLE_TO_WRITE_TO); StreamShieldResource streamShieldResource = (StreamShieldResource) endToEndTestHelper.resources.get(0); streamList = endToEndTestHelper.generateStreamList(streamShieldResource, "ArrisDSR6401"); testClass = new TestClass("ArrisDSR6401", TABLE_TO_WRITE_TO); passthrough_stream = streamList.get(STREAM_PASS_THROUGH_INDEX); transcoded_stream = streamList.get(STREAM_TRANSCODED_INDEX); asi_stream = streamList.get(STREAM_ASI_INDEX); } @Test public void testStreamName() throws SQLException, InterruptedException { testClass.streamNameTest("M6-RFIRDRX19-PassThru", STREAM_PASS_THROUGH_INDEX); testClass.streamNameTest("M6-RFIRDRX19-ASI", STREAM_ASI_INDEX); testClass.streamNameTest("M6-RFIRDRX19-Xcoded", STREAM_TRANSCODED_INDEX); } @Test public void testType() throws SQLException, InterruptedException { testClass.typeTest(Constants.TYPE_OUTPUT, STREAM_PASS_THROUGH_INDEX); testClass.typeTest(Constants.TYPE_OUTPUT_ASI, STREAM_ASI_INDEX); } @Test public void testOffline() throws SQLException, InterruptedException { testClass.offlineTest(passthrough_stream, STREAM_PASS_THROUGH_INDEX); testClass.offlineTest(asi_stream, STREAM_ASI_INDEX); testClass.offlineTest(transcoded_stream, STREAM_TRANSCODED_INDEX); } @Test public void testStreamEndpointUnicast() throws SQLException, InterruptedException { EndpointTestObject endpointUnicastTestObject = new EndpointTestObject(Constants.UNICAST_ADDRESS, Constants.UNICAST_ADDRESS); testClass.endpointTest(passthrough_stream, endpointUnicastTestObject, STREAM_PASS_THROUGH_INDEX); testClass.endpointTest(transcoded_stream, endpointUnicastTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamEndpointMulticast() throws SQLException, InterruptedException { EndpointTestObject endpointMulticastTestObject = new EndpointTestObject(Constants.MULTICAST_ADDRESS, Constants.MULTICAST_ADDRESS); testClass.endpointTest(passthrough_stream, endpointMulticastTestObject, STREAM_PASS_THROUGH_INDEX); testClass.endpointTest(transcoded_stream, endpointMulticastTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamPort() throws SQLException, InterruptedException { PortTestObject portTestObject = new PortTestObject(Constants.PORT_5050, Constants.PORT_5050); testClass.portTest(passthrough_stream, portTestObject, STREAM_PASS_THROUGH_INDEX); testClass.portTest(transcoded_stream, portTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamFormat() throws SQLException, InterruptedException { //nothing has a format } @Test public void testStreamTransmit() throws SQLException, InterruptedException { //we dont use the test class here because stream one's transmit is also streams two transmit TransmitTestObject transmitTestObject = new TransmitTestObject(Constants.ENABLED, Constants.STRING_THREE, null); endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_TWO; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); transmitTestObject.expectedTransmitValue = Constants.DISABLED; assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_ONE; transmitTestObject.expectedTransmitValue = Constants.ENABLED; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); transmitTestObject.expectedTransmitValue = Constants.DISABLED; assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_ZERO; transmitTestObject.expectedTransmitValue = Constants.DISABLED; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); } @Test public void testStreamBars() throws SQLException, InterruptedException { BarsTestObject barsTestObject = new BarsTestObject(Constants.NOTAVAIL, Constants.NOTAVAIL); testClass.barsTest((OutputStream) passthrough_stream, barsTestObject, STREAM_PASS_THROUGH_INDEX); testClass.barsTest((OutputStream) transcoded_stream, barsTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamTone() throws SQLException, InterruptedException { ToneTestObject toneTestObject = new ToneTestObject(Constants.NOTAVAIL, Constants.NOTAVAIL); testClass.toneTest((OutputStream) passthrough_stream, toneTestObject, STREAM_PASS_THROUGH_INDEX); testClass.toneTest((OutputStream) transcoded_stream, toneTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testASITransmit() throws SQLException, InterruptedException { TransmitTestObject transmitTestObject = new TransmitTestObject(Constants.ENABLED, Constants.STRING_ZERO, null); testClass.testASITransmit((OutputASIStream) asi_stream, transmitTestObject, STREAM_ASI_INDEX); transmitTestObject.transmit = Constants.STRING_ZERO; transmitTestObject.expectedTransmitValue = Constants.ENABLED; testClass.testASITransmit((OutputASIStream) asi_stream, transmitTestObject, STREAM_ASI_INDEX); } }
UTF-8
Java
9,056
java
ArrisDSR6401EndToEndTest.java
Java
[ { "context": " org.junit.Assert.assertEquals;\n\n/**\n * Created by starling on 5/23/16.\n */\npublic class ArrisDSR6401EndToEnd", "end": 815, "score": 0.9995747804641724, "start": 807, "tag": "USERNAME", "value": "starling" } ]
null
[]
package com.mlbam.rms.infrastructure.resources.EndToEndTests; import com.mlbam.rms.infrastructure.resources.Constants.Constants; import com.mlbam.rms.infrastructure.resources.OutputASIStream; import com.mlbam.rms.infrastructure.resources.OutputStream; import com.mlbam.rms.infrastructure.resources.Stream; import com.mlbam.rms.infrastructure.resources.StreamShieldResource; import com.mlbam.rms.infrastructure.resources.TestObjects.*; import org.junit.BeforeClass; import org.junit.Test; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; import static com.mlbam.rms.infrastructure.resources.EndToEndTests.TestClass.endToEndTestHelper; import static org.junit.Assert.assertEquals; /** * Created by starling on 5/23/16. */ public class ArrisDSR6401EndToEndTest { private final static String TABLE_TO_WRITE_TO = "encoder_object_test"; private static final int STREAM_PASS_THROUGH_INDEX = 0; private static final int STREAM_ASI_INDEX = 1; private static final int STREAM_TRANSCODED_INDEX = 2; private static List<Stream> streamList = new ArrayList<Stream>(); public ArrayList<Map<String, String>> resultsFromDataBase; private static TestClass testClass; private static Stream passthrough_stream; private static Stream transcoded_stream; private static Stream asi_stream; @BeforeClass public static void beforeClass() throws SQLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, InterruptedException { EndToEndTestHelper endToEndTestHelper = new EndToEndTestHelper("ArrisDSR6401"); endToEndTestHelper.truncateTestTable(TABLE_TO_WRITE_TO); StreamShieldResource streamShieldResource = (StreamShieldResource) endToEndTestHelper.resources.get(0); streamList = endToEndTestHelper.generateStreamList(streamShieldResource, "ArrisDSR6401"); testClass = new TestClass("ArrisDSR6401", TABLE_TO_WRITE_TO); passthrough_stream = streamList.get(STREAM_PASS_THROUGH_INDEX); transcoded_stream = streamList.get(STREAM_TRANSCODED_INDEX); asi_stream = streamList.get(STREAM_ASI_INDEX); } @Test public void testStreamName() throws SQLException, InterruptedException { testClass.streamNameTest("M6-RFIRDRX19-PassThru", STREAM_PASS_THROUGH_INDEX); testClass.streamNameTest("M6-RFIRDRX19-ASI", STREAM_ASI_INDEX); testClass.streamNameTest("M6-RFIRDRX19-Xcoded", STREAM_TRANSCODED_INDEX); } @Test public void testType() throws SQLException, InterruptedException { testClass.typeTest(Constants.TYPE_OUTPUT, STREAM_PASS_THROUGH_INDEX); testClass.typeTest(Constants.TYPE_OUTPUT_ASI, STREAM_ASI_INDEX); } @Test public void testOffline() throws SQLException, InterruptedException { testClass.offlineTest(passthrough_stream, STREAM_PASS_THROUGH_INDEX); testClass.offlineTest(asi_stream, STREAM_ASI_INDEX); testClass.offlineTest(transcoded_stream, STREAM_TRANSCODED_INDEX); } @Test public void testStreamEndpointUnicast() throws SQLException, InterruptedException { EndpointTestObject endpointUnicastTestObject = new EndpointTestObject(Constants.UNICAST_ADDRESS, Constants.UNICAST_ADDRESS); testClass.endpointTest(passthrough_stream, endpointUnicastTestObject, STREAM_PASS_THROUGH_INDEX); testClass.endpointTest(transcoded_stream, endpointUnicastTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamEndpointMulticast() throws SQLException, InterruptedException { EndpointTestObject endpointMulticastTestObject = new EndpointTestObject(Constants.MULTICAST_ADDRESS, Constants.MULTICAST_ADDRESS); testClass.endpointTest(passthrough_stream, endpointMulticastTestObject, STREAM_PASS_THROUGH_INDEX); testClass.endpointTest(transcoded_stream, endpointMulticastTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamPort() throws SQLException, InterruptedException { PortTestObject portTestObject = new PortTestObject(Constants.PORT_5050, Constants.PORT_5050); testClass.portTest(passthrough_stream, portTestObject, STREAM_PASS_THROUGH_INDEX); testClass.portTest(transcoded_stream, portTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamFormat() throws SQLException, InterruptedException { //nothing has a format } @Test public void testStreamTransmit() throws SQLException, InterruptedException { //we dont use the test class here because stream one's transmit is also streams two transmit TransmitTestObject transmitTestObject = new TransmitTestObject(Constants.ENABLED, Constants.STRING_THREE, null); endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_TWO; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); transmitTestObject.expectedTransmitValue = Constants.DISABLED; assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_ONE; transmitTestObject.expectedTransmitValue = Constants.ENABLED; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); transmitTestObject.expectedTransmitValue = Constants.DISABLED; assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); endToEndTestHelper.resetSnmpResults(); transmitTestObject.transmit = Constants.STRING_ZERO; transmitTestObject.expectedTransmitValue = Constants.DISABLED; endToEndTestHelper.putOnSnmpResultMap(((OutputStream) passthrough_stream).getTransmitOID().toString(), transmitTestObject.transmit); endToEndTestHelper.runStreamShield(); resultsFromDataBase = endToEndTestHelper.getEndToEndStreamShieldResults(TABLE_TO_WRITE_TO); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_PASS_THROUGH_INDEX).get("TRANSMIT")); assertEquals(transmitTestObject.expectedTransmitValue, resultsFromDataBase.get(STREAM_TRANSCODED_INDEX).get("TRANSMIT")); } @Test public void testStreamBars() throws SQLException, InterruptedException { BarsTestObject barsTestObject = new BarsTestObject(Constants.NOTAVAIL, Constants.NOTAVAIL); testClass.barsTest((OutputStream) passthrough_stream, barsTestObject, STREAM_PASS_THROUGH_INDEX); testClass.barsTest((OutputStream) transcoded_stream, barsTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testStreamTone() throws SQLException, InterruptedException { ToneTestObject toneTestObject = new ToneTestObject(Constants.NOTAVAIL, Constants.NOTAVAIL); testClass.toneTest((OutputStream) passthrough_stream, toneTestObject, STREAM_PASS_THROUGH_INDEX); testClass.toneTest((OutputStream) transcoded_stream, toneTestObject, STREAM_TRANSCODED_INDEX); } @Test public void testASITransmit() throws SQLException, InterruptedException { TransmitTestObject transmitTestObject = new TransmitTestObject(Constants.ENABLED, Constants.STRING_ZERO, null); testClass.testASITransmit((OutputASIStream) asi_stream, transmitTestObject, STREAM_ASI_INDEX); transmitTestObject.transmit = Constants.STRING_ZERO; transmitTestObject.expectedTransmitValue = Constants.ENABLED; testClass.testASITransmit((OutputASIStream) asi_stream, transmitTestObject, STREAM_ASI_INDEX); } }
9,056
0.774293
0.769655
166
53.548191
45.277931
202
false
false
0
0
0
0
0
0
1
false
false
2
79fb4db85ce7c0b097652216a3e9c500b9f09768
38,869,454,031,748
50140936f9915df1e67fa80b666bf8914146803a
/simgridEclipsePlugin/src/simgrideclipseplugin/wizards/SimgridAbstractProjectWizardPage.java
f249e64955b15841611402e0f43ec19a6d3ab958
[]
no_license
mickours/simgrideclipse
https://github.com/mickours/simgrideclipse
bc20efe26982de4c683765ab0a844bff1f6aac26
8fbe80df807e14544466103b86c4daf561a2d430
refs/heads/master
2016-09-09T20:33:22.122000
2014-06-05T07:31:23
2014-06-05T07:31:23
20,515,799
2
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package simgrideclipseplugin.wizards; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; public abstract class SimgridAbstractProjectWizardPage extends WizardPage implements Listener { private LinkedList<Text> funcTextList; private Composite funcContainer; private Button plus; private Map<Button,Text> delButtonMap; /** * this map is used by the class that extends this to give * arguments to the <code>initializeNewProject</code> methods * in the parent wizard that must be a SimgridProjectWizard * @see SimgridAbstractProjectWizard SimgridProjectWizard */ protected Map<String, Object> argsMap; protected String errorMessage; public SimgridAbstractProjectWizardPage(String title) { super(title); setTitle(title); funcTextList = new LinkedList<Text>(); argsMap = new HashMap<String, Object>(); delButtonMap = new HashMap<Button, Text>(); } @Override public void createControl(Composite parent) { //initialize Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; setControl(container); addProjectSpecificComposite(container); //functions Label label = new Label(container, SWT.NULL); label.setText("&Add functions:"); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; label.setLayoutData(gd); funcContainer = new Composite(container, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; funcContainer.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; funcContainer.setLayoutData(gd); createFunctionText(); plus = new Button(container, SWT.PUSH ); plus.setImage(PlatformUI.getWorkbench().getSharedImages(). getImageDescriptor(ISharedImages.IMG_OBJ_ADD).createImage()); plus.addListener(SWT.Selection, this); setPageComplete(false); initializeComposite(); } /** * should be override to compute specific data before adding page * errorMessage should be set if an error occurred */ public abstract void init(SimgridAbstractProjectWizard wizard); /** * should be override to add project specific visual settings */ protected abstract void addProjectSpecificComposite(Composite container); /** * should be override to initialize project specific visual settings */ protected void initializeComposite() { funcTextList.get(0).setText("defaultFunction"); } private void createFunctionText(){ Text funcText = new Text(funcContainer, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL,GridData.FILL,true,true); // gd.widthHint = getControl().getParent().getSize().x - 40; funcText.setLayoutData(gd); funcText.addListener(SWT.KeyUp, this); funcTextList.add(funcText); Button moins = new Button(funcContainer, SWT.PUSH ); moins.setImage(PlatformUI.getWorkbench().getSharedImages(). getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE).createImage()); moins.addListener(SWT.Selection, this); delButtonMap.put(moins, funcText); } /** * set error message with the given message and update page complete status * if the message is empty or null reset error message and set page complete * @param message */ protected void updateStatus(String message) { message = (message == null || message.isEmpty()) ? null: message; setErrorMessage(message); setPageComplete(message == null); } public List<String> getFunctionNames() { List<String> l = new ArrayList<String>(funcTextList.size()); for (Text func : funcTextList){ l.add(func.getText()); } return l; } @Override public void handleEvent(Event event) { errorMessage = ""; if (event.widget == plus){ createFunctionText(); funcContainer.layout(); } else if (delButtonMap.containsKey(event.widget)){ int size = funcContainer.getChildren().length; if (size > 1){ Button b = (Button) event.widget; Text t = delButtonMap.get(b); funcTextList.remove(t); delButtonMap.remove(b); b.dispose(); t.dispose(); funcContainer.layout(); } } //handle errors else if (funcTextList.contains(event.widget)){ Text text = (Text) event.widget; if (text.getText().isEmpty() || !text.getText().matches("[A-Za-z0-9_]+")){ errorMessage += "the function name must use only letters and numbers"; } } ((Composite)getControl()).layout(); getShell().layout(); updateStatus(errorMessage); } public Map<String, Object> getArgsMap() { return argsMap; } }
UTF-8
Java
5,063
java
SimgridAbstractProjectWizardPage.java
Java
[]
null
[]
package simgrideclipseplugin.wizards; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; public abstract class SimgridAbstractProjectWizardPage extends WizardPage implements Listener { private LinkedList<Text> funcTextList; private Composite funcContainer; private Button plus; private Map<Button,Text> delButtonMap; /** * this map is used by the class that extends this to give * arguments to the <code>initializeNewProject</code> methods * in the parent wizard that must be a SimgridProjectWizard * @see SimgridAbstractProjectWizard SimgridProjectWizard */ protected Map<String, Object> argsMap; protected String errorMessage; public SimgridAbstractProjectWizardPage(String title) { super(title); setTitle(title); funcTextList = new LinkedList<Text>(); argsMap = new HashMap<String, Object>(); delButtonMap = new HashMap<Button, Text>(); } @Override public void createControl(Composite parent) { //initialize Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 3; setControl(container); addProjectSpecificComposite(container); //functions Label label = new Label(container, SWT.NULL); label.setText("&Add functions:"); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; label.setLayoutData(gd); funcContainer = new Composite(container, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; funcContainer.setLayout(layout); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; funcContainer.setLayoutData(gd); createFunctionText(); plus = new Button(container, SWT.PUSH ); plus.setImage(PlatformUI.getWorkbench().getSharedImages(). getImageDescriptor(ISharedImages.IMG_OBJ_ADD).createImage()); plus.addListener(SWT.Selection, this); setPageComplete(false); initializeComposite(); } /** * should be override to compute specific data before adding page * errorMessage should be set if an error occurred */ public abstract void init(SimgridAbstractProjectWizard wizard); /** * should be override to add project specific visual settings */ protected abstract void addProjectSpecificComposite(Composite container); /** * should be override to initialize project specific visual settings */ protected void initializeComposite() { funcTextList.get(0).setText("defaultFunction"); } private void createFunctionText(){ Text funcText = new Text(funcContainer, SWT.BORDER | SWT.SINGLE); GridData gd = new GridData(GridData.FILL,GridData.FILL,true,true); // gd.widthHint = getControl().getParent().getSize().x - 40; funcText.setLayoutData(gd); funcText.addListener(SWT.KeyUp, this); funcTextList.add(funcText); Button moins = new Button(funcContainer, SWT.PUSH ); moins.setImage(PlatformUI.getWorkbench().getSharedImages(). getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE).createImage()); moins.addListener(SWT.Selection, this); delButtonMap.put(moins, funcText); } /** * set error message with the given message and update page complete status * if the message is empty or null reset error message and set page complete * @param message */ protected void updateStatus(String message) { message = (message == null || message.isEmpty()) ? null: message; setErrorMessage(message); setPageComplete(message == null); } public List<String> getFunctionNames() { List<String> l = new ArrayList<String>(funcTextList.size()); for (Text func : funcTextList){ l.add(func.getText()); } return l; } @Override public void handleEvent(Event event) { errorMessage = ""; if (event.widget == plus){ createFunctionText(); funcContainer.layout(); } else if (delButtonMap.containsKey(event.widget)){ int size = funcContainer.getChildren().length; if (size > 1){ Button b = (Button) event.widget; Text t = delButtonMap.get(b); funcTextList.remove(t); delButtonMap.remove(b); b.dispose(); t.dispose(); funcContainer.layout(); } } //handle errors else if (funcTextList.contains(event.widget)){ Text text = (Text) event.widget; if (text.getText().isEmpty() || !text.getText().matches("[A-Za-z0-9_]+")){ errorMessage += "the function name must use only letters and numbers"; } } ((Composite)getControl()).layout(); getShell().layout(); updateStatus(errorMessage); } public Map<String, Object> getArgsMap() { return argsMap; } }
5,063
0.73336
0.731385
171
28.608187
22.363131
95
false
false
0
0
0
0
0
0
2.152047
false
false
2
36be04e1ef7e5f790448fb8baa699e32461a54c5
35,570,919,177,813
3a81339ee39494fbd0250df6abc6411f386907f9
/src/main/java/act/db/DbPlugin.java
9c1906382c49b005d7d9149d21112a3851beb649
[ "Apache-2.0" ]
permissive
zhaoyancong/actframework
https://github.com/zhaoyancong/actframework
cafba5687d78bbf78e4834b46168b1bd73e2a193
d910531793047a75e7067fcaacbf7caebe58132c
refs/heads/master
2021-01-13T05:01:11.170000
2017-02-07T07:40:46
2017-02-07T07:40:46
81,185,396
1
0
null
true
2017-02-07T08:34:16
2017-02-07T08:34:16
2017-02-04T05:47:54
2017-02-07T07:40:55
4,192
0
0
0
null
null
null
package act.db; import act.Act; import act.app.App; import act.plugin.Plugin; import act.util.DestroyableBase; import java.util.Map; /** * The base class for Database Plugin */ public abstract class DbPlugin extends DestroyableBase implements Plugin { @Override public void register() { Act.dbManager().register(this); Act.trigger(new DbPluginRegistered(this)); } @Override public int hashCode() { return getClass().hashCode(); } @Override public boolean equals(Object obj) { return obj == this || null != obj && getClass() == obj.getClass(); } public abstract DbService initDbService(String id, App app, Map<String, Object> conf); public void afterDbServiceLoaded() { } }
UTF-8
Java
763
java
DbPlugin.java
Java
[]
null
[]
package act.db; import act.Act; import act.app.App; import act.plugin.Plugin; import act.util.DestroyableBase; import java.util.Map; /** * The base class for Database Plugin */ public abstract class DbPlugin extends DestroyableBase implements Plugin { @Override public void register() { Act.dbManager().register(this); Act.trigger(new DbPluginRegistered(this)); } @Override public int hashCode() { return getClass().hashCode(); } @Override public boolean equals(Object obj) { return obj == this || null != obj && getClass() == obj.getClass(); } public abstract DbService initDbService(String id, App app, Map<String, Object> conf); public void afterDbServiceLoaded() { } }
763
0.661861
0.661861
35
20.799999
23.19458
90
false
false
0
0
0
0
0
0
0.457143
false
false
2
865d0a8b13d5ec2d627c8f6065cdf55f7b0e950f
36,163,624,668,664
375f88951fdfdf7180833a8fa8ff9a5794bd9309
/friendlyCompany/src/main/java/com/ours/friendlyCompany/service/FriendlycompanyService.java
4783b1133fccdc7c8c7ccabcf231786b0be8ab4f
[]
no_license
wubenfei/decoration-alliance
https://github.com/wubenfei/decoration-alliance
49935b891da89b9c63c8bfdc0be3140401b36e6d
102e8e4b52e23c641924e414f013a65ddb9181be
refs/heads/master
2022-12-11T00:28:07.012000
2020-01-15T07:11:37
2020-01-15T07:11:37
249,112,859
0
0
null
false
2022-12-06T00:35:03
2020-03-22T04:28:12
2021-04-30T15:32:35
2022-12-06T00:35:03
452
1
0
30
Java
false
false
package com.ours.friendlyCompany.service; import com.ours.friendlyCompany.entity.DecorationCompany; import com.ours.friendlyCompany.entity.Designer; import java.util.List; import java.util.Map; public interface FriendlycompanyService { List<Map<String, Object>> queryAllValue(); int insertAcompany(DecorationCompany decorationCompany); /** * Auth:MrW * @param tel * @param password * @return */ DecorationCompany selectByTelAndPassword(String tel, String password); Designer selectDesignerByTelAndPassword(String tel, String password); }
UTF-8
Java
589
java
FriendlycompanyService.java
Java
[ { "context": "nCompany decorationCompany);\n\n /**\n * Auth:MrW\n * @param tel\n * @param password\n * @", "end": 372, "score": 0.9993001818656921, "start": 369, "tag": "USERNAME", "value": "MrW" } ]
null
[]
package com.ours.friendlyCompany.service; import com.ours.friendlyCompany.entity.DecorationCompany; import com.ours.friendlyCompany.entity.Designer; import java.util.List; import java.util.Map; public interface FriendlycompanyService { List<Map<String, Object>> queryAllValue(); int insertAcompany(DecorationCompany decorationCompany); /** * Auth:MrW * @param tel * @param password * @return */ DecorationCompany selectByTelAndPassword(String tel, String password); Designer selectDesignerByTelAndPassword(String tel, String password); }
589
0.748727
0.748727
23
24.608696
24.428671
74
false
false
0
0
0
0
0
0
0.521739
false
false
2
08014389297e2141d3a7099a93963941c0ec9801
19,318,762,902,633
c759329fecfad6a8ebbe7877972e67e879cb0580
/src/com/xuyang/algorithm/leetcode/X_191_位1的个数.java
2bef48675d64ac8b1007c6de0ac3f74b3da62abc
[]
no_license
yangxua/work-algorithm-java
https://github.com/yangxua/work-algorithm-java
2ca48263d502223d894df8ccfb20d9ef1174bc95
8d8f8c8e8be655f6370fcce47d67d9080798fa46
refs/heads/master
2020-07-08T17:52:21.195000
2020-01-16T06:27:49
2020-01-16T06:27:49
203,737,008
17
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.xuyang.algorithm.leetcode; /** * @Auther: allanyang * @Date: 2019/9/4 21:22 * @Description: 类型题:位1的个数(191) 汉明距离(461) * * 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为汉明重量)。 * * 示例 1: * 输入:00000000000000000000000000001011 * 输出:3 * 解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。 * 示例 2: * 输入:00000000000000000000000010000000 * 输出:1 * 解释:输入的二进制串 00000000000000000000000010000000 中,共有一位为 '1'。 * 示例 3: * 输入:11111111111111111111111111111101 * 输出:31 * 解释:输入的二进制串 11111111111111111111111111111101 中,共有 31 位为 '1'。 * */ public class X_191_位1的个数 { public int hammingWeight(int n) { int count = 0; while (n != 0) { n &= (n-1); count++; } return count; //return Integer.bitCount(n); } }
UTF-8
Java
1,094
java
X_191_位1的个数.java
Java
[ { "context": "ge com.xuyang.algorithm.leetcode;\n\n/**\n * @Auther: allanyang\n * @Date: 2019/9/4 21:22\n * @Description: 类型题:位1", "end": 65, "score": 0.999215304851532, "start": 56, "tag": "USERNAME", "value": "allanyang" } ]
null
[]
package com.xuyang.algorithm.leetcode; /** * @Auther: allanyang * @Date: 2019/9/4 21:22 * @Description: 类型题:位1的个数(191) 汉明距离(461) * * 编写一个函数,输入是一个无符号整数,返回其二进制表达式中数字位数为 ‘1’ 的个数(也被称为汉明重量)。 * * 示例 1: * 输入:00000000000000000000000000001011 * 输出:3 * 解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。 * 示例 2: * 输入:00000000000000000000000010000000 * 输出:1 * 解释:输入的二进制串 00000000000000000000000010000000 中,共有一位为 '1'。 * 示例 3: * 输入:11111111111111111111111111111101 * 输出:31 * 解释:输入的二进制串 11111111111111111111111111111101 中,共有 31 位为 '1'。 * */ public class X_191_位1的个数 { public int hammingWeight(int n) { int count = 0; while (n != 0) { n &= (n-1); count++; } return count; //return Integer.bitCount(n); } }
1,094
0.6343
0.345523
37
20.459459
18.913166
62
false
false
0
0
0
0
0
0
0.162162
false
false
2
e48c84e2ed44ca2036af9c6c0c86fa03cf986a0e
5,334,349,442,572
9017a15de929c7648e43a3cbf93b0f1287bcfe46
/app/src/main/java/org/mult/daap/client/daap/request/Request.java
153a97ee387c06d9e58ffa14b297d9531928319b
[]
no_license
chrismiceli/daap-client
https://github.com/chrismiceli/daap-client
2dda916befc8e76b29fa46e33a546e4699e7b280
1bc9db23f5e7e5f2ccacc9a4b80111b4b4f94f02
refs/heads/master
2023-09-02T20:31:13.865000
2023-08-20T02:34:07
2023-08-20T02:34:07
32,236,951
9
8
null
false
2022-04-24T02:48:30
2015-03-14T23:29:45
2022-02-16T04:11:49
2022-04-24T02:48:29
2,874
8
5
35
Java
false
false
/* * Created on May 6, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments * Copyright 2003 Joseph Barnett * * This File is part of "one 2 oh my god" * * "one 2 oh my god" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or * your option) any later version. * * "one 2 oh my god" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with "one 2 oh my god"; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * update: Greg Jordan, 2004 */ package org.mult.daap.client.daap.request; import android.util.Log; import org.mult.daap.client.daap.DaapHost; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; /** * @author jbarnett To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public abstract class Request { protected final DaapHost host; protected int response_code; protected String response_message; public byte[] data; protected int offset; protected HttpURLConnection httpc; protected final int access_index; // start of song request. public Request(DaapHost h) { // needed for bug in android: // http://code.google.com/p/android/issues/detail?id=7786 System.setProperty("http.keepAlive", "false"); host = h; response_code = -1; offset = 0; access_index = 2; } protected String getRequestString() { return ""; } protected void query(String caller) throws BadResponseCodeException, PasswordFailedException, IOException { query(caller, false); } // Retry if we don't recognize the response code and turn of the Accept-Encoding. // This resolves issue 58. protected void query(String caller, boolean retry) throws BadResponseCodeException, PasswordFailedException, IOException { URL url = new URL("http://" + host.getAddress() + ":" + host.getPort() + "/" + getRequestString()); Log.d("Request", url.toString()); httpc = (HttpURLConnection) url.openConnection(); httpc.setConnectTimeout(45000); if (!retry) { httpc.setRequestProperty("Accept-Encoding", "identity"); } addRequestProperties(); httpc.connect(); response_code = httpc.getResponseCode(); if (response_code != HttpURLConnection.HTTP_OK && response_code != HttpURLConnection.HTTP_PARTIAL) { response_message = httpc.getResponseMessage(); if (response_code == HttpURLConnection.HTTP_UNAUTHORIZED) { throw new PasswordFailedException("" + response_code + ": " + response_message); } if (retry) { throw new BadResponseCodeException(response_code, response_message + " by " + host.getName()); } else { query(caller, true); } } } protected void readResponse() throws IOException { DataInputStream in = new DataInputStream(httpc.getInputStream()); int len = httpc.getContentLength(); if (httpc.getContentLength() == -1) { return; } data = new byte[len]; in.readFully(data); } protected void addRequestProperties() { httpc.setRequestProperty("User-Agent", "iTunes/4.6 (Windows; N)"); httpc.addRequestProperty("Accept-Language", "en-us, en;q=5.0"); httpc.addRequestProperty("Client-DAAP-Access-Index", String.valueOf(access_index)); httpc.addRequestProperty("Client-DAAP-Version", "3.0"); try { httpc.addRequestProperty("Client-DAAP-Validation", getHashCode(this)); } catch (NoSuchAlgorithmException e) { httpc.addRequestProperty("Client-DAAP-Validation", ""); } // httpc.addRequestProperty("Accept-Encoding", ""); if (host.isPasswordProtected()) { httpc.addRequestProperty("Authorization", "Basic " + host.getPassword()); } // httpc.addRequestProperty("Connection", "Close"); } String getHashCode(Request r) throws NoSuchAlgorithmException { return Hasher.GenerateHash("/" + r.getRequestString()); } public static String readString(byte[] data, int offset, int length) { return new String(data, offset, length, StandardCharsets.UTF_8); } protected static int readInt(byte[] data, int offset) { return (((data[offset] & 0xff) << 24) | ((data[1 + offset] & 0xff) << 16) | ((data[2 + offset] & 0xff) << 8) | (data[3 + offset] & 0xff)); } public DaapHost getHost() { return host; } /* convert from hex in binary to decimal */ public static int readInt(byte[] data, int offset, int size) { int i = 0; try { ByteArrayInputStream b = new ByteArrayInputStream(data, offset, size); DataInputStream d = new DataInputStream(b); int pow = size * 2 - 1; for (int j = 0; j < size; j++) { int num = (0xFF & d.readByte()); int up = ((int) Math.pow(16, pow)) * (num / 16); pow--; int down = ((int) Math.pow(16, pow)) * (num % 16); i += up + down; pow--; } } catch (IOException e) { e.printStackTrace(); } return i; } }
UTF-8
Java
6,236
java
Request.java
Java
[ { "context": "ode Generation>Code and Comments\n * Copyright 2003 Joseph Barnett\n *\n * This File is part of \"one 2 oh my god\"\n *\n ", "end": 181, "score": 0.9998855590820312, "start": 167, "tag": "NAME", "value": "Joseph Barnett" }, { "context": "te 330, Boston, MA 02111-1307 USA\n *\n *\n * update: Greg Jordan, 2004\n */\npackage org.mult.daap.client.daap.reque", "end": 975, "score": 0.9998703002929688, "start": 964, "tag": "NAME", "value": "Greg Jordan" }, { "context": "security.NoSuchAlgorithmException;\n\n/**\n * @author jbarnett To change the template for this generated type co", "end": 1366, "score": 0.9996579885482788, "start": 1358, "tag": "USERNAME", "value": "jbarnett" } ]
null
[]
/* * Created on May 6, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments * Copyright 2003 <NAME> * * This File is part of "one 2 oh my god" * * "one 2 oh my god" is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or * your option) any later version. * * "one 2 oh my god" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with "one 2 oh my god"; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * update: <NAME>, 2004 */ package org.mult.daap.client.daap.request; import android.util.Log; import org.mult.daap.client.daap.DaapHost; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; /** * @author jbarnett To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public abstract class Request { protected final DaapHost host; protected int response_code; protected String response_message; public byte[] data; protected int offset; protected HttpURLConnection httpc; protected final int access_index; // start of song request. public Request(DaapHost h) { // needed for bug in android: // http://code.google.com/p/android/issues/detail?id=7786 System.setProperty("http.keepAlive", "false"); host = h; response_code = -1; offset = 0; access_index = 2; } protected String getRequestString() { return ""; } protected void query(String caller) throws BadResponseCodeException, PasswordFailedException, IOException { query(caller, false); } // Retry if we don't recognize the response code and turn of the Accept-Encoding. // This resolves issue 58. protected void query(String caller, boolean retry) throws BadResponseCodeException, PasswordFailedException, IOException { URL url = new URL("http://" + host.getAddress() + ":" + host.getPort() + "/" + getRequestString()); Log.d("Request", url.toString()); httpc = (HttpURLConnection) url.openConnection(); httpc.setConnectTimeout(45000); if (!retry) { httpc.setRequestProperty("Accept-Encoding", "identity"); } addRequestProperties(); httpc.connect(); response_code = httpc.getResponseCode(); if (response_code != HttpURLConnection.HTTP_OK && response_code != HttpURLConnection.HTTP_PARTIAL) { response_message = httpc.getResponseMessage(); if (response_code == HttpURLConnection.HTTP_UNAUTHORIZED) { throw new PasswordFailedException("" + response_code + ": " + response_message); } if (retry) { throw new BadResponseCodeException(response_code, response_message + " by " + host.getName()); } else { query(caller, true); } } } protected void readResponse() throws IOException { DataInputStream in = new DataInputStream(httpc.getInputStream()); int len = httpc.getContentLength(); if (httpc.getContentLength() == -1) { return; } data = new byte[len]; in.readFully(data); } protected void addRequestProperties() { httpc.setRequestProperty("User-Agent", "iTunes/4.6 (Windows; N)"); httpc.addRequestProperty("Accept-Language", "en-us, en;q=5.0"); httpc.addRequestProperty("Client-DAAP-Access-Index", String.valueOf(access_index)); httpc.addRequestProperty("Client-DAAP-Version", "3.0"); try { httpc.addRequestProperty("Client-DAAP-Validation", getHashCode(this)); } catch (NoSuchAlgorithmException e) { httpc.addRequestProperty("Client-DAAP-Validation", ""); } // httpc.addRequestProperty("Accept-Encoding", ""); if (host.isPasswordProtected()) { httpc.addRequestProperty("Authorization", "Basic " + host.getPassword()); } // httpc.addRequestProperty("Connection", "Close"); } String getHashCode(Request r) throws NoSuchAlgorithmException { return Hasher.GenerateHash("/" + r.getRequestString()); } public static String readString(byte[] data, int offset, int length) { return new String(data, offset, length, StandardCharsets.UTF_8); } protected static int readInt(byte[] data, int offset) { return (((data[offset] & 0xff) << 24) | ((data[1 + offset] & 0xff) << 16) | ((data[2 + offset] & 0xff) << 8) | (data[3 + offset] & 0xff)); } public DaapHost getHost() { return host; } /* convert from hex in binary to decimal */ public static int readInt(byte[] data, int offset, int size) { int i = 0; try { ByteArrayInputStream b = new ByteArrayInputStream(data, offset, size); DataInputStream d = new DataInputStream(b); int pow = size * 2 - 1; for (int j = 0; j < size; j++) { int num = (0xFF & d.readByte()); int up = ((int) Math.pow(16, pow)) * (num / 16); pow--; int down = ((int) Math.pow(16, pow)) * (num % 16); i += up + down; pow--; } } catch (IOException e) { e.printStackTrace(); } return i; } }
6,223
0.608403
0.595734
174
34.844826
24.988136
85
false
false
0
0
0
0
0
0
0.689655
false
false
2
0a985b5baf2cbea87b1158b0380e5db455e0888b
23,991,687,381,758
6e477761837cce0f0c1adc2004ad48d2f89cea7c
/spring-bean/src/main/java/com/hnanet/_8_cache/basic/CacheTest.java
633a3760a448613411eaf16135fc555f3dc53047
[ "Apache-2.0" ]
permissive
wangshz/learn-java
https://github.com/wangshz/learn-java
5c525251f0ba35ea6fa29c7980585f45685870ac
bd288a25c2b8eef5a85773a0612753a2e16e72a5
refs/heads/master
2022-12-23T11:19:10.228000
2020-03-03T14:09:06
2020-03-03T14:09:06
233,182,956
4
1
Apache-2.0
false
2022-12-16T03:37:33
2020-01-11T05:45:07
2022-12-06T09:23:57
2022-12-16T03:37:31
6,188
1
1
8
Java
false
false
package com.hnanet._8_cache.basic; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class CacheTest { @Test public void testC(){ ApplicationContext con = new ClassPathXmlApplicationContext("spring/cache/bean-config.xml"); CacheSample cacheSample = (CacheSample) con.getBean("cacheSample"); List<User> users = cacheSample.getUser(Arrays.asList("ds","dsf")).values().stream().collect(Collectors.toList()); System.out.println(users); } }
UTF-8
Java
678
java
CacheTest.java
Java
[]
null
[]
package com.hnanet._8_cache.basic; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class CacheTest { @Test public void testC(){ ApplicationContext con = new ClassPathXmlApplicationContext("spring/cache/bean-config.xml"); CacheSample cacheSample = (CacheSample) con.getBean("cacheSample"); List<User> users = cacheSample.getUser(Arrays.asList("ds","dsf")).values().stream().collect(Collectors.toList()); System.out.println(users); } }
678
0.744838
0.743363
20
32.900002
34.168552
121
false
false
0
0
0
0
0
0
0.6
false
false
2
c0b6fe05237e3babea05fe96554b88ca482ab829
2,963,527,470,904
c2cb9dd51009c19cec0ad64d579da2be9f6ea204
/LeetCode/src/test1_1.java
a428da0191e5dc05470b756e672e1f84ff0a28d3
[]
no_license
LYgithub/JavaProject
https://github.com/LYgithub/JavaProject
a2cbf1637404bd054826abfb65415509b28f05e9
594b6a224591a74bbf18ffa0c0337dc69da226fe
refs/heads/master
2022-12-28T09:21:14.848000
2020-10-20T12:44:07
2020-10-20T12:44:07
288,051,639
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.Scanner; /** * @Project Name: LeetCode * @Package Name: PACKAGE_NAME * Created by MacBook Air on 2020/02/03. * Copyright © 2020 KawYang. All rights reserved. */ public class test1_1 { public static void main(String[] args) { int x ; Scanner read = new Scanner(System.in); x = read.nextInt(); System.out.println(change(x)); } public static String change(int a){ StringBuffer b = new StringBuffer(); int n; do{ n = a%16; if(n< 10 ){ b.insert(0,n); } else { b.insert(0,(char)(n-10+'A')); } a/=16; }while (a!=0); return b.toString(); } }
UTF-8
Java
751
java
test1_1.java
Java
[ { "context": " by MacBook Air on 2020/02/03.\n * Copyright © 2020 KawYang. All rights reserved.\n */\npublic class test1_1 {\n", "end": 157, "score": 0.9958989024162292, "start": 150, "tag": "NAME", "value": "KawYang" } ]
null
[]
import java.util.Scanner; /** * @Project Name: LeetCode * @Package Name: PACKAGE_NAME * Created by MacBook Air on 2020/02/03. * Copyright © 2020 KawYang. All rights reserved. */ public class test1_1 { public static void main(String[] args) { int x ; Scanner read = new Scanner(System.in); x = read.nextInt(); System.out.println(change(x)); } public static String change(int a){ StringBuffer b = new StringBuffer(); int n; do{ n = a%16; if(n< 10 ){ b.insert(0,n); } else { b.insert(0,(char)(n-10+'A')); } a/=16; }while (a!=0); return b.toString(); } }
751
0.490667
0.457333
31
23.193548
14.487858
49
false
false
0
0
0
0
0
0
0.483871
false
false
2
26caaf96331acb269bc24e8d61759b902c29ca5c
5,085,241,312,244
970b3738d4cdd7419254a89f3e589b895d20e8a7
/STU/Module1/Work3.java
57a5cfb162e8392598d40113e7d8ac93326194b5
[]
no_license
ViChen9/JavaTest
https://github.com/ViChen9/JavaTest
41e2286d998a3d401e2777388316b43404b4e2c8
4ca2fc8660eb4d70afdd3d0126ad4f214947f783
refs/heads/main
2023-01-22T21:27:06.021000
2020-12-08T12:04:54
2020-12-08T12:04:54
309,276,170
0
1
null
false
2020-11-02T06:56:40
2020-11-02T06:18:21
2020-11-02T06:51:07
2020-11-02T06:54:43
0
0
1
0
Java
false
false
import java.util.Arrays; /** * 3. 编程题 实现双色球抽奖游戏中奖号码的生成,中奖号码由 6 个红球号码和 1 个蓝球号码组成。 其中红球号码要求随机生成 6 个 1~33 之间不重复的随机号码。 其中蓝球号码要求随机生成 1 个 1~16 之间的随机号码。 */ public class Work3 { public static void main(String[] args) { //声明一维数组red的长度 int[] red = new int[7]; //跳出多层循环 label: //循环生成红、蓝球随机数 for (int a = 0; a < red.length; a++) { int tem = (int) (Math.random() * 33 + 1); //在数组最后直接生成篮球随机数,不做重复对比 if (red.length - 1 == a) { tem = (int) (Math.random() * 16 + 1); } //遍历数组检查重复随机数,跳过第一位与最后一位 for (int i = 0; a != 0 && a != 6 && i < a; i++) { //如果随机数与数组中的数重复,则抵消本次循环次数,跳回外层循环 if (tem == red[i]) { a--; continue label; } } //根据循环数组底数将筛选后的随机数写入 red[a] = tem; } System.out.print(Arrays.toString(red)); } }
UTF-8
Java
1,375
java
Work3.java
Java
[]
null
[]
import java.util.Arrays; /** * 3. 编程题 实现双色球抽奖游戏中奖号码的生成,中奖号码由 6 个红球号码和 1 个蓝球号码组成。 其中红球号码要求随机生成 6 个 1~33 之间不重复的随机号码。 其中蓝球号码要求随机生成 1 个 1~16 之间的随机号码。 */ public class Work3 { public static void main(String[] args) { //声明一维数组red的长度 int[] red = new int[7]; //跳出多层循环 label: //循环生成红、蓝球随机数 for (int a = 0; a < red.length; a++) { int tem = (int) (Math.random() * 33 + 1); //在数组最后直接生成篮球随机数,不做重复对比 if (red.length - 1 == a) { tem = (int) (Math.random() * 16 + 1); } //遍历数组检查重复随机数,跳过第一位与最后一位 for (int i = 0; a != 0 && a != 6 && i < a; i++) { //如果随机数与数组中的数重复,则抵消本次循环次数,跳回外层循环 if (tem == red[i]) { a--; continue label; } } //根据循环数组底数将筛选后的随机数写入 red[a] = tem; } System.out.print(Arrays.toString(red)); } }
1,375
0.451182
0.426516
32
29.4375
22.803423
117
false
false
0
0
0
0
0
0
0.375
false
false
2
442e847b89c0ff9aad194b876c5769d5483a4140
27,676,769,280,315
d88fe162917f960b73be9c0ee70b333e961dcc28
/FinalCattery/src/main/java/by/epam/cattery/dao/impl/CatDAOImpl.java
1ac058ab34d70890b471e3b5e27ecafc18cd2ebe
[]
no_license
WrittingCodeWithMyCat/Epam_Training
https://github.com/WrittingCodeWithMyCat/Epam_Training
235f70fb62a1047c2ce793f165a66c58f0f808f9
4c4aecc2c55adebf67bdce095fce9eab3497ca7a
refs/heads/master
2023-01-23T13:50:32.433000
2018-07-25T22:02:50
2018-07-25T22:02:50
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package by.epam.cattery.dao.impl; import by.epam.cattery.dao.CatDAO; import by.epam.cattery.dao.connection.ConnectionPool; import by.epam.cattery.dao.connection.ConnectionPoolException; import by.epam.cattery.dao.exception.DAOException; import by.epam.cattery.entity.*; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.sql.*; import java.util.ArrayList; import java.util.List; public class CatDAOImpl implements CatDAO { private static final Logger logger = LogManager.getLogger(CatDAOImpl.class); private final ConnectionPool connectionPool; private static final String FIND_ALL_CATS = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id FROM cat JOIN cat_colour " + "ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code)"; private static final String FIND_ALL_CATS_WITH_DISCOUNT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id, price - (price * (SELECT discount FROM user WHERE user_id = (?))) / 100" + " FROM cat JOIN cat_colour ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code)"; private static final String ADD_CAT = "INSERT INTO cat (name, lastname, gender, birth_date, description, body_colour_code, " + "cat_eyes_colour_code, parent_female, parent_male, price, user_suggested_id, offer_made_id) " + "VALUES(?,?,?,STR_TO_DATE(?, '%m/%d/%Y'),?,?,?,?,?,?,?,?)"; private static final String UPDATE_OFFER_STATUS_FOR_USER = "UPDATE user_offer SET user_offer_status_id=? " + "WHERE offer_id = ? AND user_offer_status_id=?;"; private static final String DELETE_CERTAIN_CAT = "DELETE FROM cat WHERE cat_id = ?;"; private static final String CONDITION_BY_STATUS = " WHERE sale_status_id = ?"; private static final String CONDITION_BY_CAT = " WHERE cat_id = ?"; public CatDAOImpl(ConnectionPool connectionPool) { this.connectionPool = connectionPool; } @Override public List<Cat> findAllCats() throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsByStatus(CatStatus status) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS + CONDITION_BY_STATUS); ps.setString(1, status.toString()); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsWithDiscount(int userId) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT); ps.setInt(1, userId); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats with discount; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsByStatusWithDiscount(int userId, CatStatus status) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT + CONDITION_BY_STATUS); ps.setInt(1, userId); ps.setString(2, status.toString()); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats by status; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public void addCat(Cat cat) throws DAOException { Connection con = null; PreparedStatement ps = null; PreparedStatement ps2; try { con = connectionPool.takeConnection(); con.setAutoCommit(false); ps = con.prepareStatement(ADD_CAT); ps.setString(1, cat.getName()); ps.setString(2, cat.getLastname()); ps.setString(3, cat.getGender().toString()); ps.setString(4, cat.getAge()); ps.setString(5, cat.getDescription()); ps.setString(6, cat.getBodyColour()); ps.setString(7, cat.getEyesColour()); ps.setString(8, cat.getFemaleParent()); ps.setString(9, cat.getMaleParent()); ps.setDouble(10, cat.getPrice()); ps.setInt(11, cat.getUserMadeOfferId()); ps.setInt(12, cat.getOfferMadeId()); ps.executeUpdate(); if (cat.getUserMadeOfferId() != 1) { ps2 = con.prepareStatement(UPDATE_OFFER_STATUS_FOR_USER); ps2.setString(1, OfferStatus.SENT.toString()); ps2.setInt(2, cat.getOfferMadeId()); ps2.setString(3, OfferStatus.APRVD.toString()); int i = ps2.executeUpdate(); if (i != 1) { logger.log(Level.WARN, "No more cats! An attempt to add already added cat during sending an offer by admin"); throw new DAOException("Attempt to add already processed offer "); } } con.commit(); } catch (ConnectionPoolException | SQLException e) { try { con.rollback(); throw new DAOException("Exception during adding cat", e); } catch (SQLException e1) { throw new DAOException("Exception while rollback after error during adding", e); } finally { connectionPool.closeConnection(con, ps); } } } @Override public Cat findSingleCat(int catId) throws DAOException { Cat cat = new Cat(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS + CONDITION_BY_CAT); ps.setInt(1, catId); rs = ps.executeQuery(); while (rs.next()) { cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); //???? cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); // int? cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); } return cat; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during finding single cats", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public Cat findSingleCatWithDiscount(int catId, int userId) throws DAOException { Cat cat = new Cat(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT + CONDITION_BY_CAT); ps.setInt(1, userId); ps.setInt(2, catId); rs = ps.executeQuery(); while (rs.next()) { cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); //???? cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); // int? cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); } return cat; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during finding single cats", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public void deleteCat(int catId) throws DAOException { Connection con = null; PreparedStatement ps = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(DELETE_CERTAIN_CAT); ps.setInt(1, catId); ps.executeUpdate(); } catch (ConnectionPoolException | SQLException e) { throw new DAOException("Exception while deleting cat from bd ", e); } finally { connectionPool.closeConnection(con, ps); } } @Override public void updateCat(Cat cat) throws DAOException { Connection con = null; PreparedStatement ps = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement("UPDATE cat SET name=?, lastname=?, gender=?, birth_date=STR_TO_DATE(?, '%m/%d/%Y')," + " description=?, body_colour_code=?, cat_eyes_colour_code=?, parent_female=?, " + "parent_male=?, price=? WHERE cat_id = ?;"); ps.setString(1, cat.getName()); ps.setString(2, cat.getLastname()); ps.setString(3, cat.getGender().toString()); ps.setString(4, cat.getAge()); ps.setString(5, cat.getDescription()); ps.setString(6, cat.getBodyColour()); ps.setString(7, cat.getEyesColour()); ps.setString(8, cat.getFemaleParent()); ps.setString(9, cat.getMaleParent()); ps.setDouble(10, cat.getPrice()); ps.setDouble(11, cat.getId()); ps.executeUpdate(); } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during updating cat info", e); } finally { connectionPool.closeConnection(con, ps); } } @Override public List<Cat> searchForCat(Cat cat) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); //FIND_ALL_CATS replace String SEARCH_FOR_CAT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id FROM cat JOIN cat_colour " + "ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code) WHERE "; StringBuffer condition = new StringBuffer(); if (cat.getGender() != null) { condition.append(" gender = '" + cat.getGender().toString() + "' AND "); } if (cat.getStatus() != null) { condition.append(" sale_status_id = '" + cat.getStatus().toString() + "' AND "); } if (!cat.getBodyColour().isEmpty()) { condition.append(" body_colour_code = '" + cat.getBodyColour() + "' AND "); } if (!cat.getEyesColour().isEmpty()) { condition.append(" cat_eyes_colour_code = '" + cat.getEyesColour() + "' AND "); } if (cat.getPrice() != 0.0) { condition.append(" price <= " + cat.getPrice() + " AND "); } condition.append(" 1 = 1;"); ps = con.prepareStatement(SEARCH_FOR_CAT + condition); rs = ps.executeQuery(); while (rs.next()) { Cat foundCat = new Cat(); foundCat.setId(rs.getInt(1)); foundCat.setName(rs.getString(2)); foundCat.setLastname(rs.getString(3)); foundCat.setGender(Gender.valueOf(rs.getString(4))); foundCat.setAge(rs.getString(5)); // отдельные константы числа foundCat.setDescription(rs.getString(6)); foundCat.setBodyColour(rs.getString(7)); foundCat.setEyesColour(rs.getString(8)); foundCat.setFemaleParent(rs.getString(9)); foundCat.setMaleParent(rs.getString(10)); foundCat.setPrice(rs.getDouble(11)); foundCat.setStatus(CatStatus.valueOf(rs.getString(12))); foundCat.setUserMadeOfferId(rs.getInt(13)); cats.add(foundCat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during searching for cat", e); } finally { connectionPool.closeConnection(con, ps, rs); } } // повторяется - в один метод // убрать user_suggested_id // цену сделать необязат @Override public List<Cat> searchForCatWithDiscount(Cat cat, int userId) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); //FIND_ALL_CATS replace String SEARCH_FOR_CAT_WITH_DISCOUNT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id, price - (price * (SELECT discount FROM user WHERE user_id = (?))) / 100" + " FROM cat JOIN cat_colour ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code) WHERE"; StringBuffer condition = new StringBuffer(); if (cat.getGender() != null) { condition.append(" gender = '" + cat.getGender().toString() + "' AND "); } if (cat.getStatus() != null) { condition.append(" sale_status_id = '" + cat.getStatus().toString() + "' AND "); } if (!cat.getBodyColour().isEmpty()) { condition.append(" body_colour_code = '" + cat.getBodyColour() + "' AND "); } if (!cat.getEyesColour().isEmpty()) { condition.append(" cat_eyes_colour_code = '" + cat.getEyesColour() + "' AND "); } if (cat.getPrice() != 0.0) { condition.append(" price - (price * (SELECT discount FROM user WHERE user_id = " + userId + ")) / 100 <= " + cat.getPrice() + " AND "); } condition.append(" 1 = 1;"); ps = con.prepareStatement(SEARCH_FOR_CAT_WITH_DISCOUNT + condition); ps.setInt(1, userId); rs = ps.executeQuery(); while (rs.next()) { Cat foundCat = new Cat(); foundCat.setId(rs.getInt(1)); foundCat.setName(rs.getString(2)); foundCat.setLastname(rs.getString(3)); foundCat.setGender(Gender.valueOf(rs.getString(4))); foundCat.setAge(rs.getString(5)); // отдельные константы числа foundCat.setDescription(rs.getString(6)); foundCat.setBodyColour(rs.getString(7)); foundCat.setEyesColour(rs.getString(8)); foundCat.setFemaleParent(rs.getString(9)); foundCat.setMaleParent(rs.getString(10)); foundCat.setPrice(rs.getDouble(11)); foundCat.setStatus(CatStatus.valueOf(rs.getString(12))); foundCat.setUserMadeOfferId(rs.getInt(13)); foundCat.setPriceWithDiscount(rs.getDouble(14)); cats.add(foundCat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during searching for cat with discount", e); } finally { connectionPool.closeConnection(con, ps, rs); } } }
UTF-8
Java
23,534
java
CatDAOImpl.java
Java
[ { "context": "tic final String ADD_CAT = \"INSERT INTO cat (name, lastname, gender, birth_date, description, body_colour_cod", "end": 1828, "score": 0.7199806571006775, "start": 1820, "tag": "NAME", "value": "lastname" }, { "context": " String SEARCH_FOR_CAT = \"SELECT cat_id, name, lastname, gender, \" +\n \"MONTH(CURDATE()", "end": 17092, "score": 0.9769230484962463, "start": 17084, "tag": "NAME", "value": "lastname" } ]
null
[]
package by.epam.cattery.dao.impl; import by.epam.cattery.dao.CatDAO; import by.epam.cattery.dao.connection.ConnectionPool; import by.epam.cattery.dao.connection.ConnectionPoolException; import by.epam.cattery.dao.exception.DAOException; import by.epam.cattery.entity.*; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.sql.*; import java.util.ArrayList; import java.util.List; public class CatDAOImpl implements CatDAO { private static final Logger logger = LogManager.getLogger(CatDAOImpl.class); private final ConnectionPool connectionPool; private static final String FIND_ALL_CATS = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id FROM cat JOIN cat_colour " + "ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code)"; private static final String FIND_ALL_CATS_WITH_DISCOUNT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id, price - (price * (SELECT discount FROM user WHERE user_id = (?))) / 100" + " FROM cat JOIN cat_colour ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code)"; private static final String ADD_CAT = "INSERT INTO cat (name, lastname, gender, birth_date, description, body_colour_code, " + "cat_eyes_colour_code, parent_female, parent_male, price, user_suggested_id, offer_made_id) " + "VALUES(?,?,?,STR_TO_DATE(?, '%m/%d/%Y'),?,?,?,?,?,?,?,?)"; private static final String UPDATE_OFFER_STATUS_FOR_USER = "UPDATE user_offer SET user_offer_status_id=? " + "WHERE offer_id = ? AND user_offer_status_id=?;"; private static final String DELETE_CERTAIN_CAT = "DELETE FROM cat WHERE cat_id = ?;"; private static final String CONDITION_BY_STATUS = " WHERE sale_status_id = ?"; private static final String CONDITION_BY_CAT = " WHERE cat_id = ?"; public CatDAOImpl(ConnectionPool connectionPool) { this.connectionPool = connectionPool; } @Override public List<Cat> findAllCats() throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsByStatus(CatStatus status) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS + CONDITION_BY_STATUS); ps.setString(1, status.toString()); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsWithDiscount(int userId) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT); ps.setInt(1, userId); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats with discount; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public List<Cat> findAllCatsByStatusWithDiscount(int userId, CatStatus status) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT + CONDITION_BY_STATUS); ps.setInt(1, userId); ps.setString(2, status.toString()); rs = ps.executeQuery(); while (rs.next()) { Cat cat = new Cat(); cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); cats.add(cat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during gathering cats by status; You must gather your cats before venturing forth", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public void addCat(Cat cat) throws DAOException { Connection con = null; PreparedStatement ps = null; PreparedStatement ps2; try { con = connectionPool.takeConnection(); con.setAutoCommit(false); ps = con.prepareStatement(ADD_CAT); ps.setString(1, cat.getName()); ps.setString(2, cat.getLastname()); ps.setString(3, cat.getGender().toString()); ps.setString(4, cat.getAge()); ps.setString(5, cat.getDescription()); ps.setString(6, cat.getBodyColour()); ps.setString(7, cat.getEyesColour()); ps.setString(8, cat.getFemaleParent()); ps.setString(9, cat.getMaleParent()); ps.setDouble(10, cat.getPrice()); ps.setInt(11, cat.getUserMadeOfferId()); ps.setInt(12, cat.getOfferMadeId()); ps.executeUpdate(); if (cat.getUserMadeOfferId() != 1) { ps2 = con.prepareStatement(UPDATE_OFFER_STATUS_FOR_USER); ps2.setString(1, OfferStatus.SENT.toString()); ps2.setInt(2, cat.getOfferMadeId()); ps2.setString(3, OfferStatus.APRVD.toString()); int i = ps2.executeUpdate(); if (i != 1) { logger.log(Level.WARN, "No more cats! An attempt to add already added cat during sending an offer by admin"); throw new DAOException("Attempt to add already processed offer "); } } con.commit(); } catch (ConnectionPoolException | SQLException e) { try { con.rollback(); throw new DAOException("Exception during adding cat", e); } catch (SQLException e1) { throw new DAOException("Exception while rollback after error during adding", e); } finally { connectionPool.closeConnection(con, ps); } } } @Override public Cat findSingleCat(int catId) throws DAOException { Cat cat = new Cat(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS + CONDITION_BY_CAT); ps.setInt(1, catId); rs = ps.executeQuery(); while (rs.next()) { cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); //???? cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); // int? cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); } return cat; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during finding single cats", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public Cat findSingleCatWithDiscount(int catId, int userId) throws DAOException { Cat cat = new Cat(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(FIND_ALL_CATS_WITH_DISCOUNT + CONDITION_BY_CAT); ps.setInt(1, userId); ps.setInt(2, catId); rs = ps.executeQuery(); while (rs.next()) { cat.setId(rs.getInt(1)); cat.setName(rs.getString(2)); cat.setLastname(rs.getString(3)); cat.setGender(Gender.valueOf(rs.getString(4))); //???? cat.setAge(rs.getString(5)); // отдельные константы числа cat.setDescription(rs.getString(6)); cat.setBodyColour(rs.getString(7)); cat.setEyesColour(rs.getString(8)); cat.setFemaleParent(rs.getString(9)); cat.setMaleParent(rs.getString(10)); cat.setPrice(rs.getDouble(11)); // int? cat.setStatus(CatStatus.valueOf(rs.getString(12))); cat.setUserMadeOfferId(rs.getInt(13)); cat.setPriceWithDiscount(rs.getDouble(14)); } return cat; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during finding single cats", e); } finally { connectionPool.closeConnection(con, ps, rs); } } @Override public void deleteCat(int catId) throws DAOException { Connection con = null; PreparedStatement ps = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement(DELETE_CERTAIN_CAT); ps.setInt(1, catId); ps.executeUpdate(); } catch (ConnectionPoolException | SQLException e) { throw new DAOException("Exception while deleting cat from bd ", e); } finally { connectionPool.closeConnection(con, ps); } } @Override public void updateCat(Cat cat) throws DAOException { Connection con = null; PreparedStatement ps = null; try { con = connectionPool.takeConnection(); ps = con.prepareStatement("UPDATE cat SET name=?, lastname=?, gender=?, birth_date=STR_TO_DATE(?, '%m/%d/%Y')," + " description=?, body_colour_code=?, cat_eyes_colour_code=?, parent_female=?, " + "parent_male=?, price=? WHERE cat_id = ?;"); ps.setString(1, cat.getName()); ps.setString(2, cat.getLastname()); ps.setString(3, cat.getGender().toString()); ps.setString(4, cat.getAge()); ps.setString(5, cat.getDescription()); ps.setString(6, cat.getBodyColour()); ps.setString(7, cat.getEyesColour()); ps.setString(8, cat.getFemaleParent()); ps.setString(9, cat.getMaleParent()); ps.setDouble(10, cat.getPrice()); ps.setDouble(11, cat.getId()); ps.executeUpdate(); } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during updating cat info", e); } finally { connectionPool.closeConnection(con, ps); } } @Override public List<Cat> searchForCat(Cat cat) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); //FIND_ALL_CATS replace String SEARCH_FOR_CAT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id FROM cat JOIN cat_colour " + "ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code) WHERE "; StringBuffer condition = new StringBuffer(); if (cat.getGender() != null) { condition.append(" gender = '" + cat.getGender().toString() + "' AND "); } if (cat.getStatus() != null) { condition.append(" sale_status_id = '" + cat.getStatus().toString() + "' AND "); } if (!cat.getBodyColour().isEmpty()) { condition.append(" body_colour_code = '" + cat.getBodyColour() + "' AND "); } if (!cat.getEyesColour().isEmpty()) { condition.append(" cat_eyes_colour_code = '" + cat.getEyesColour() + "' AND "); } if (cat.getPrice() != 0.0) { condition.append(" price <= " + cat.getPrice() + " AND "); } condition.append(" 1 = 1;"); ps = con.prepareStatement(SEARCH_FOR_CAT + condition); rs = ps.executeQuery(); while (rs.next()) { Cat foundCat = new Cat(); foundCat.setId(rs.getInt(1)); foundCat.setName(rs.getString(2)); foundCat.setLastname(rs.getString(3)); foundCat.setGender(Gender.valueOf(rs.getString(4))); foundCat.setAge(rs.getString(5)); // отдельные константы числа foundCat.setDescription(rs.getString(6)); foundCat.setBodyColour(rs.getString(7)); foundCat.setEyesColour(rs.getString(8)); foundCat.setFemaleParent(rs.getString(9)); foundCat.setMaleParent(rs.getString(10)); foundCat.setPrice(rs.getDouble(11)); foundCat.setStatus(CatStatus.valueOf(rs.getString(12))); foundCat.setUserMadeOfferId(rs.getInt(13)); cats.add(foundCat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during searching for cat", e); } finally { connectionPool.closeConnection(con, ps, rs); } } // повторяется - в один метод // убрать user_suggested_id // цену сделать необязат @Override public List<Cat> searchForCatWithDiscount(Cat cat, int userId) throws DAOException { List<Cat> cats = new ArrayList<>(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = connectionPool.takeConnection(); //FIND_ALL_CATS replace String SEARCH_FOR_CAT_WITH_DISCOUNT = "SELECT cat_id, name, lastname, gender, " + "MONTH(CURDATE()) - MONTH(birth_date), description," + "colour_name, eyes_colour_name, parent_female, parent_male, price, " + "sale_status_id, user_suggested_id, price - (price * (SELECT discount FROM user WHERE user_id = (?))) / 100" + " FROM cat JOIN cat_colour ON (cat.body_colour_code = cat_colour.EMS_code) " + "LEFT JOIN cat_eyes_colour ON (cat.cat_eyes_colour_code " + "= cat_eyes_colour.FIFe_eyes_colour_code) WHERE"; StringBuffer condition = new StringBuffer(); if (cat.getGender() != null) { condition.append(" gender = '" + cat.getGender().toString() + "' AND "); } if (cat.getStatus() != null) { condition.append(" sale_status_id = '" + cat.getStatus().toString() + "' AND "); } if (!cat.getBodyColour().isEmpty()) { condition.append(" body_colour_code = '" + cat.getBodyColour() + "' AND "); } if (!cat.getEyesColour().isEmpty()) { condition.append(" cat_eyes_colour_code = '" + cat.getEyesColour() + "' AND "); } if (cat.getPrice() != 0.0) { condition.append(" price - (price * (SELECT discount FROM user WHERE user_id = " + userId + ")) / 100 <= " + cat.getPrice() + " AND "); } condition.append(" 1 = 1;"); ps = con.prepareStatement(SEARCH_FOR_CAT_WITH_DISCOUNT + condition); ps.setInt(1, userId); rs = ps.executeQuery(); while (rs.next()) { Cat foundCat = new Cat(); foundCat.setId(rs.getInt(1)); foundCat.setName(rs.getString(2)); foundCat.setLastname(rs.getString(3)); foundCat.setGender(Gender.valueOf(rs.getString(4))); foundCat.setAge(rs.getString(5)); // отдельные константы числа foundCat.setDescription(rs.getString(6)); foundCat.setBodyColour(rs.getString(7)); foundCat.setEyesColour(rs.getString(8)); foundCat.setFemaleParent(rs.getString(9)); foundCat.setMaleParent(rs.getString(10)); foundCat.setPrice(rs.getDouble(11)); foundCat.setStatus(CatStatus.valueOf(rs.getString(12))); foundCat.setUserMadeOfferId(rs.getInt(13)); foundCat.setPriceWithDiscount(rs.getDouble(14)); cats.add(foundCat); } return cats; } catch (ConnectionPoolException e) { throw new DAOException("Exception while connecting via pool", e); } catch (SQLException e) { throw new DAOException("Exception during searching for cat with discount", e); } finally { connectionPool.closeConnection(con, ps, rs); } } }
23,534
0.557801
0.548661
603
37.648426
29.530642
137
false
false
0
0
0
0
0
0
0.804312
false
false
2
a52193e422d81107a80f72c3100713fa2ed93396
11,149,735,140,983
caf4c6f7f13bebd95465e8677eac1f5bce11c8a4
/src/main/java/com/supaham/sertest/MapConfig.java
09ae08d02c527f0491dfe942f87845835d292ce2
[]
no_license
SupaHam/PB-ModuleSerialization
https://github.com/SupaHam/PB-ModuleSerialization
f2a0540b6b5b140b74e23cf47bdb8fe147ae550d
1a86cf6f1a7480eb792207a48b83a9b6f16ee9b3
refs/heads/master
2016-09-05T13:57:09.875000
2015-07-14T10:27:43
2015-07-14T10:27:43
39,068,615
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.supaham.sertest; import com.google.common.base.Preconditions; import com.supaham.sertest.modules.framework.ModuleData; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pluginbase.config.annotation.SerializableAs; import pluginbase.config.annotation.SerializeWith; import pluginbase.config.serializers.Serializer; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @Getter @Setter @SerializableAs("MapConfig") public class MapConfig { @SerializeWith(ModuleSerializer.class) private Set<ModuleData> modules = new HashSet<>(); public static final class ModuleSerializer implements Serializer<Collection<ModuleData>> { @Nullable @Override public Object serialize(Collection<ModuleData> moduleDatas) throws IllegalArgumentException { return moduleDatas == null ? null : moduleDatas.stream().collect(Collectors.toList()); } @Nullable @Override public Set<ModuleData> deserialize(@Nullable Object o, @NotNull Class aClass) throws IllegalArgumentException { if (o == null) { return null; } Preconditions.checkArgument(o instanceof List, "Serialized object must be a list of modules"); //noinspection unchecked return new HashSet<>((List) o); } } }
UTF-8
Java
1,498
java
MapConfig.java
Java
[]
null
[]
package com.supaham.sertest; import com.google.common.base.Preconditions; import com.supaham.sertest.modules.framework.ModuleData; import lombok.Getter; import lombok.Setter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pluginbase.config.annotation.SerializableAs; import pluginbase.config.annotation.SerializeWith; import pluginbase.config.serializers.Serializer; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @Getter @Setter @SerializableAs("MapConfig") public class MapConfig { @SerializeWith(ModuleSerializer.class) private Set<ModuleData> modules = new HashSet<>(); public static final class ModuleSerializer implements Serializer<Collection<ModuleData>> { @Nullable @Override public Object serialize(Collection<ModuleData> moduleDatas) throws IllegalArgumentException { return moduleDatas == null ? null : moduleDatas.stream().collect(Collectors.toList()); } @Nullable @Override public Set<ModuleData> deserialize(@Nullable Object o, @NotNull Class aClass) throws IllegalArgumentException { if (o == null) { return null; } Preconditions.checkArgument(o instanceof List, "Serialized object must be a list of modules"); //noinspection unchecked return new HashSet<>((List) o); } } }
1,498
0.718291
0.718291
45
32.288887
30.049309
119
false
false
0
0
0
0
0
0
0.488889
false
false
2
901c34330cce24e8baf5a63df7a956a009a8be89
38,259,568,694,038
4cf6c2248c5142be5c1627f855dd8394fceae6e6
/springboot-jpa3-2/src/main/java/com/example/springbootjpa/repository/UserRepository.java
a3193f29788001689284424b0f3afd847dfcff3e
[]
no_license
Dormancy-Cat/spring-boot-study
https://github.com/Dormancy-Cat/spring-boot-study
fb4438b261f4122d4c129a721c88c8cae02421ff
946ee3fb9e48033cf0f33b340e9ee08b7fafee79
refs/heads/master
2023-08-24T03:24:50.799000
2021-10-21T07:07:32
2021-10-21T07:07:32
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.springbootjpa.repository; import com.example.springbootjpa.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; /** * 继承JpaRepository来完成对数据库的操作 * * @author chenye */ @Repository public interface UserRepository extends JpaRepository<User, Integer> { }
UTF-8
Java
381
java
UserRepository.java
Java
[ { "context": "y;\n\n/**\n * 继承JpaRepository来完成对数据库的操作\n *\n * @author chenye\n */\n@Repository\npublic interface UserRepository e", "end": 259, "score": 0.9996454119682312, "start": 253, "tag": "USERNAME", "value": "chenye" } ]
null
[]
package com.example.springbootjpa.repository; import com.example.springbootjpa.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; /** * 继承JpaRepository来完成对数据库的操作 * * @author chenye */ @Repository public interface UserRepository extends JpaRepository<User, Integer> { }
381
0.795518
0.795518
15
22.799999
20.906776
61
false
false
0
0
0
0
0
0
0.333333
false
false
2
46c8989012f4b62253ccd1598d76e691502fd769
6,837,587,941,258
7a0506321456521e7da1d6d79bf178bf4a8aafc0
/app/src/main/java/com/quadminds/leandronanni/quadmindsdemo/api/APIController.java
9471271b52c57f3a5ba515aef553a5d73c266aba
[]
no_license
lgnanni/QuadmindsDemo
https://github.com/lgnanni/QuadmindsDemo
afbe12741a1e22a2a141fcf0d42383b202c9d752
73e5724eafdeba22a4e653334d55ac5f16e71337
refs/heads/master
2020-03-31T23:35:20.187000
2018-10-11T22:09:58
2018-10-11T22:09:58
152,661,770
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.quadminds.leandronanni.quadmindsdemo.api; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.quadminds.leandronanni.quadmindsdemo.pojo.Note; import com.quadminds.leandronanni.quadmindsdemo.pojo.NotePost; import com.quadminds.leandronanni.quadmindsdemo.pojo.Notes; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class APIController { private static final String BASE_URL = "https://quadminds-notes-test.getsandbox.com/"; private static final String JSON_TYPE = "application/json; charset=utf-8"; private static APIController instance; private QuadMindsAPI quadmindsAPI; public static APIController getInstance() { if (instance == null) { instance = new APIController(); instance.start(); } return instance; } public void start() { final OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(15, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .build(); final Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); quadmindsAPI = retrofit.create(QuadMindsAPI.class); } public Call<Notes> getNotes() { return quadmindsAPI.getNotes(); } public Call<JsonObject> saveNewNote(final String title, final String content) { final NotePost post = new NotePost(title, content); final RequestBody body = RequestBody.create(okhttp3.MediaType.parse(JSON_TYPE), new Gson().toJson(post)); return quadmindsAPI.postNewNote(body); } public Call<JsonObject> saveExistingNote(final String id, final String title, final String content) { final NotePost post = new NotePost(title, content); final RequestBody body = RequestBody.create(okhttp3.MediaType.parse(JSON_TYPE), new Gson().toJson(post)); return quadmindsAPI.postExistingNote(id, body); } public Call<JsonObject> deleteNote(final String id) { return quadmindsAPI.deleteNote(id); } }
UTF-8
Java
2,412
java
APIController.java
Java
[]
null
[]
package com.quadminds.leandronanni.quadmindsdemo.api; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.quadminds.leandronanni.quadmindsdemo.pojo.Note; import com.quadminds.leandronanni.quadmindsdemo.pojo.NotePost; import com.quadminds.leandronanni.quadmindsdemo.pojo.Notes; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class APIController { private static final String BASE_URL = "https://quadminds-notes-test.getsandbox.com/"; private static final String JSON_TYPE = "application/json; charset=utf-8"; private static APIController instance; private QuadMindsAPI quadmindsAPI; public static APIController getInstance() { if (instance == null) { instance = new APIController(); instance.start(); } return instance; } public void start() { final OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(15, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .build(); final Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); quadmindsAPI = retrofit.create(QuadMindsAPI.class); } public Call<Notes> getNotes() { return quadmindsAPI.getNotes(); } public Call<JsonObject> saveNewNote(final String title, final String content) { final NotePost post = new NotePost(title, content); final RequestBody body = RequestBody.create(okhttp3.MediaType.parse(JSON_TYPE), new Gson().toJson(post)); return quadmindsAPI.postNewNote(body); } public Call<JsonObject> saveExistingNote(final String id, final String title, final String content) { final NotePost post = new NotePost(title, content); final RequestBody body = RequestBody.create(okhttp3.MediaType.parse(JSON_TYPE), new Gson().toJson(post)); return quadmindsAPI.postExistingNote(id, body); } public Call<JsonObject> deleteNote(final String id) { return quadmindsAPI.deleteNote(id); } }
2,412
0.669154
0.664179
84
27.726191
27.773468
90
false
false
0
0
0
0
0
0
0.488095
false
false
2
5cab5bf4190934ea6197a79d5b351f0c39cdf75c
12,970,801,240,213
93a348c525b7c979bc69749daad1281ac19ad439
/mcenter/java/so/wwb/gamebox/mcenter/report/form/VPlayerTransactionForm.java
9bf4310991ba65b11413394233327eb9baafeac8
[]
no_license
a12791602/gb-app_mcenter
https://github.com/a12791602/gb-app_mcenter
d45f41fc58663226d4769056daf4e46ac80fcb93
a95cb978b06cdce4420e275a63aea0161059cd00
refs/heads/master
2021-09-24T03:22:01.013000
2018-09-21T07:51:38
2018-09-21T07:51:38
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package so.wwb.gamebox.mcenter.report.form; import org.soul.web.support.IForm; /** * 玩家交易视图-jeff表单验证对象 * * @author jeff * @time 2015-11-12 14:57:43 */ //region your codes 1 public class VPlayerTransactionForm implements IForm { //endregion your codes 1 //region your codes 2 //endregion your codes 2 }
UTF-8
Java
344
java
VPlayerTransactionForm.java
Java
[ { "context": "rt.IForm;\n\n\n/**\n * 玩家交易视图-jeff表单验证对象\n *\n * @author jeff\n * @time 2015-11-12 14:57:43\n */\n//region your", "end": 122, "score": 0.6357266902923584, "start": 121, "tag": "NAME", "value": "j" }, { "context": ".IForm;\n\n\n/**\n * 玩家交易视图-jeff表单验证对象\n *\n * @author jeff\n * @time 2015-11-12 14:57:43\n */\n//region your co", "end": 125, "score": 0.6707666516304016, "start": 122, "tag": "USERNAME", "value": "eff" } ]
null
[]
package so.wwb.gamebox.mcenter.report.form; import org.soul.web.support.IForm; /** * 玩家交易视图-jeff表单验证对象 * * @author jeff * @time 2015-11-12 14:57:43 */ //region your codes 1 public class VPlayerTransactionForm implements IForm { //endregion your codes 1 //region your codes 2 //endregion your codes 2 }
344
0.70625
0.65
20
15.05
16.200232
54
false
false
0
0
0
0
0
0
0.1
false
false
2
0b4dd4b8468190e427e0253086bdb864fd0584c3
15,333,033,251,554
f1445a771cbcc3511dcaf03ac8aef23dbd42bde2
/MinoterieProjetEJB/ejbModule/com/minoterie/exception/NotAutorizedException.java
f0d63c891d74271f19bc72fe230ee3c573b9664b
[]
no_license
paraponera/MinoterieFinal
https://github.com/paraponera/MinoterieFinal
69ceaa7e4385c2f7dceb766d32c59dbe9d429817
0a55daa1f93ce5716ecb17dee1c838787e1d7b13
refs/heads/master
2021-01-17T13:09:41.050000
2016-08-14T20:05:25
2016-08-14T20:05:25
65,686,098
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.minoterie.exception; public class NotAutorizedException extends Exception{ /** * */ private static final long serialVersionUID = 1L; public NotAutorizedException() { super("non_autoriser"); } }
UTF-8
Java
220
java
NotAutorizedException.java
Java
[]
null
[]
package com.minoterie.exception; public class NotAutorizedException extends Exception{ /** * */ private static final long serialVersionUID = 1L; public NotAutorizedException() { super("non_autoriser"); } }
220
0.727273
0.722727
13
15.923077
19.02412
53
false
false
0
0
0
0
0
0
0.846154
false
false
2
bbc76a1bc2d869bc225318e0590fa5c181e6a04d
30,717,606,104,653
bac7ac85d7eae06bec19191e8d1b207b9be8b9cc
/src/main/java/com/tfswx/websocket/AbstractEndpoint.java
02441c6a4b06026ce0fab4234c1bd280aac48dcc
[]
no_license
Lighfer/websocket
https://github.com/Lighfer/websocket
20f67b47a30a880a6b5b079969b27df53f133b37
114b1d1649101750cc644f1a5dd582233511475f
refs/heads/master
2020-04-15T12:28:48.204000
2019-01-11T09:26:51
2019-01-11T09:26:51
164,676,112
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.tfswx.websocket; import com.tfswx.websocket.channel.Channel; import com.tfswx.websocket.message.Message; import com.tfswx.websocket.message.MessageType; import com.tfswx.websocket.namespace.NamespaceManager; import com.tfswx.websocket.processor.IWebSocketEventProcessor; import com.tfswx.websocket.processor.ProcessorContext; import com.tfswx.websocket.processor.close.RemoveFromSessionManagerProcessor; import com.tfswx.websocket.processor.error.CloseSessionProcessor; import com.tfswx.websocket.processor.error.PrintStackTraceProcessor; import com.tfswx.websocket.processor.message.AckProcessor; import com.tfswx.websocket.processor.message.ParseMessageProcessor; import com.tfswx.websocket.processor.message.TypedMessageProcessor; import com.tfswx.websocket.processor.open.AddToSessionManagerProcessor; import com.tfswx.websocket.processor.open.CheckDuplicateProcessor; import com.tfswx.websocket.session.SessionManager; import com.tfswx.websocket.session.WebSocketSession; import lombok.extern.slf4j.Slf4j; import javax.websocket.*; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * @author hjk */ @Slf4j public abstract class AbstractEndpoint { protected SessionManager sessionManager; protected Channel channel; protected String namespace; private static final List<IWebSocketEventProcessor> ON_OPEN_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_CLOSE_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_MESSAGE_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_ERROR_PROCESSOR_LIST; static { ON_OPEN_PROCESSOR_LIST = new ArrayList<>(2); ON_OPEN_PROCESSOR_LIST.add(new CheckDuplicateProcessor()); ON_OPEN_PROCESSOR_LIST.add(new AddToSessionManagerProcessor()); ON_CLOSE_PROCESSOR_LIST = new ArrayList<>(1); ON_CLOSE_PROCESSOR_LIST.add(new RemoveFromSessionManagerProcessor()); ON_MESSAGE_PROCESSOR_LIST = new ArrayList<>(3); ON_MESSAGE_PROCESSOR_LIST.add(new ParseMessageProcessor()); ON_MESSAGE_PROCESSOR_LIST.add(new AckProcessor()); ON_MESSAGE_PROCESSOR_LIST.add(new TypedMessageProcessor()); ON_ERROR_PROCESSOR_LIST = new ArrayList<>(2); ON_ERROR_PROCESSOR_LIST.add(new PrintStackTraceProcessor()); ON_ERROR_PROCESSOR_LIST.add(new CloseSessionProcessor()); } public AbstractEndpoint(String namespace) { this.namespace = namespace; this.sessionManager = NamespaceManager.createIfNotExists(namespace); this.channel = this.sessionManager.getChannel(); } @OnOpen public final void onWebSocketOpen(Session rawSession) throws IOException { // 默认40秒超时 30秒延迟+10秒超时 rawSession.setMaxIdleTimeout(30000); WebSocketSession session = new WebSocketSession( namespace, getSessionId(rawSession), rawSession ); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); runProcessor(context, getOnOpenProcessorList()); } @OnClose public final void onWebSocketClose(Session rawSession) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); runProcessor(context, getOnCloseProcessorList()); } @OnMessage public final void onWebSocketMessage(String message, Session rawSession) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, message, session ); try { runProcessor(context, getOnMessageProcessorList()); } catch (MessageableException e){ sendServerError(rawSession, e); } } @OnError public final void onWebSocketError(Session rawSession, Throwable throwable) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); context.setThrowable(throwable); try { runProcessor(context, getOnErrorProcessorList()); } catch (NullPointerException e){ e.printStackTrace(); } } private void runProcessor(ProcessorContext context, List<IWebSocketEventProcessor> l) throws IOException { for (IWebSocketEventProcessor processor : l) { if (!processor.process(context)) { break; } } } private void sendServerError(Session rawSession, MessageableException e) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); Message m = Message.builder() .type(MessageType.SERVER_ERROR.toString()) .payload(e.getMessage()) .errorCode(e.getCode()) .build(); e.apply(m); session.sendText(m); } protected List<IWebSocketEventProcessor> getOnOpenProcessorList() { return ON_OPEN_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnCloseProcessorList() { return ON_CLOSE_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnMessageProcessorList() { return ON_MESSAGE_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnErrorProcessorList() { return ON_ERROR_PROCESSOR_LIST; } protected WebSocketSession getWebSocketSession(Session rawSession) { return (WebSocketSession) rawSession.getUserProperties() .get(WebSocketSession.WEB_SOCKET_SESSION); } protected String getSessionId(Session session) { return session.getId(); } }
UTF-8
Java
6,188
java
AbstractEndpoint.java
Java
[ { "context": ".ArrayList;\nimport java.util.List;\n\n/**\n * @author hjk\n */\n@Slf4j\npublic abstract class AbstractEndpoint", "end": 1149, "score": 0.9995728731155396, "start": 1146, "tag": "USERNAME", "value": "hjk" } ]
null
[]
package com.tfswx.websocket; import com.tfswx.websocket.channel.Channel; import com.tfswx.websocket.message.Message; import com.tfswx.websocket.message.MessageType; import com.tfswx.websocket.namespace.NamespaceManager; import com.tfswx.websocket.processor.IWebSocketEventProcessor; import com.tfswx.websocket.processor.ProcessorContext; import com.tfswx.websocket.processor.close.RemoveFromSessionManagerProcessor; import com.tfswx.websocket.processor.error.CloseSessionProcessor; import com.tfswx.websocket.processor.error.PrintStackTraceProcessor; import com.tfswx.websocket.processor.message.AckProcessor; import com.tfswx.websocket.processor.message.ParseMessageProcessor; import com.tfswx.websocket.processor.message.TypedMessageProcessor; import com.tfswx.websocket.processor.open.AddToSessionManagerProcessor; import com.tfswx.websocket.processor.open.CheckDuplicateProcessor; import com.tfswx.websocket.session.SessionManager; import com.tfswx.websocket.session.WebSocketSession; import lombok.extern.slf4j.Slf4j; import javax.websocket.*; import java.io.IOException; import java.util.ArrayList; import java.util.List; /** * @author hjk */ @Slf4j public abstract class AbstractEndpoint { protected SessionManager sessionManager; protected Channel channel; protected String namespace; private static final List<IWebSocketEventProcessor> ON_OPEN_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_CLOSE_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_MESSAGE_PROCESSOR_LIST; private static final List<IWebSocketEventProcessor> ON_ERROR_PROCESSOR_LIST; static { ON_OPEN_PROCESSOR_LIST = new ArrayList<>(2); ON_OPEN_PROCESSOR_LIST.add(new CheckDuplicateProcessor()); ON_OPEN_PROCESSOR_LIST.add(new AddToSessionManagerProcessor()); ON_CLOSE_PROCESSOR_LIST = new ArrayList<>(1); ON_CLOSE_PROCESSOR_LIST.add(new RemoveFromSessionManagerProcessor()); ON_MESSAGE_PROCESSOR_LIST = new ArrayList<>(3); ON_MESSAGE_PROCESSOR_LIST.add(new ParseMessageProcessor()); ON_MESSAGE_PROCESSOR_LIST.add(new AckProcessor()); ON_MESSAGE_PROCESSOR_LIST.add(new TypedMessageProcessor()); ON_ERROR_PROCESSOR_LIST = new ArrayList<>(2); ON_ERROR_PROCESSOR_LIST.add(new PrintStackTraceProcessor()); ON_ERROR_PROCESSOR_LIST.add(new CloseSessionProcessor()); } public AbstractEndpoint(String namespace) { this.namespace = namespace; this.sessionManager = NamespaceManager.createIfNotExists(namespace); this.channel = this.sessionManager.getChannel(); } @OnOpen public final void onWebSocketOpen(Session rawSession) throws IOException { // 默认40秒超时 30秒延迟+10秒超时 rawSession.setMaxIdleTimeout(30000); WebSocketSession session = new WebSocketSession( namespace, getSessionId(rawSession), rawSession ); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); runProcessor(context, getOnOpenProcessorList()); } @OnClose public final void onWebSocketClose(Session rawSession) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); runProcessor(context, getOnCloseProcessorList()); } @OnMessage public final void onWebSocketMessage(String message, Session rawSession) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, message, session ); try { runProcessor(context, getOnMessageProcessorList()); } catch (MessageableException e){ sendServerError(rawSession, e); } } @OnError public final void onWebSocketError(Session rawSession, Throwable throwable) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); ProcessorContext context = new ProcessorContext( namespace, sessionManager, channel, session ); context.setThrowable(throwable); try { runProcessor(context, getOnErrorProcessorList()); } catch (NullPointerException e){ e.printStackTrace(); } } private void runProcessor(ProcessorContext context, List<IWebSocketEventProcessor> l) throws IOException { for (IWebSocketEventProcessor processor : l) { if (!processor.process(context)) { break; } } } private void sendServerError(Session rawSession, MessageableException e) throws IOException { WebSocketSession session = getWebSocketSession(rawSession); Message m = Message.builder() .type(MessageType.SERVER_ERROR.toString()) .payload(e.getMessage()) .errorCode(e.getCode()) .build(); e.apply(m); session.sendText(m); } protected List<IWebSocketEventProcessor> getOnOpenProcessorList() { return ON_OPEN_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnCloseProcessorList() { return ON_CLOSE_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnMessageProcessorList() { return ON_MESSAGE_PROCESSOR_LIST; } protected List<IWebSocketEventProcessor> getOnErrorProcessorList() { return ON_ERROR_PROCESSOR_LIST; } protected WebSocketSession getWebSocketSession(Session rawSession) { return (WebSocketSession) rawSession.getUserProperties() .get(WebSocketSession.WEB_SOCKET_SESSION); } protected String getSessionId(Session session) { return session.getId(); } }
6,188
0.690237
0.687318
173
34.641617
27.952869
100
false
false
0
0
0
0
0
0
0.549133
false
false
2
2d43b55314549ec9c500c778d4f900c3f27e8c79
20,615,843,031,423
667be4f0dd55ded0227dca51ebf5720175adf267
/monitoring-back/src/main/java/com/example/demo/repo/LogsRepository.java
626baa9d40ec7939aa3a345ea3ccefd02cc91530
[]
no_license
vladlavr/monitoring
https://github.com/vladlavr/monitoring
3d69fa33094c74cfaf08e0a62ccdd418f7424a62
05d2db87226079af4d57ef1e3cca010cb15fc9ee
refs/heads/master
2022-06-13T05:47:11.845000
2020-04-27T17:37:42
2020-04-27T17:37:42
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.demo.repo; import com.example.demo.data.CheckResultEntity; import com.example.demo.data.ConfigEntity; import com.example.demo.data.LogsEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import javax.transaction.Transactional; import java.sql.Time; import java.sql.Timestamp; import java.util.List; @Repository public interface LogsRepository extends JpaRepository<LogsEntity, Long>, JpaSpecificationExecutor<LogsEntity> { @Query( value = "SELECT * FROM logs WHERE check_id = :check_id order by id", nativeQuery = true) List<LogsEntity> findLogsById(@Param("check_id") Long check_id); @Query( value = "SELECT min(last_check) FROM logs WHERE check_id = :check_id", nativeQuery = true) Timestamp findLogsTimer(@Param("check_id") Long check_id); @Query( value = "SELECT * FROM logs WHERE check_id = :check_id and last_check > :time", nativeQuery = true) List<LogsEntity> findLogs(@Param("check_id") Long check_id, @Param("time") Timestamp time); List<LogsRepository> findAllByOrderByIdAsc(); }
UTF-8
Java
1,428
java
LogsRepository.java
Java
[]
null
[]
package com.example.demo.repo; import com.example.demo.data.CheckResultEntity; import com.example.demo.data.ConfigEntity; import com.example.demo.data.LogsEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; import javax.transaction.Transactional; import java.sql.Time; import java.sql.Timestamp; import java.util.List; @Repository public interface LogsRepository extends JpaRepository<LogsEntity, Long>, JpaSpecificationExecutor<LogsEntity> { @Query( value = "SELECT * FROM logs WHERE check_id = :check_id order by id", nativeQuery = true) List<LogsEntity> findLogsById(@Param("check_id") Long check_id); @Query( value = "SELECT min(last_check) FROM logs WHERE check_id = :check_id", nativeQuery = true) Timestamp findLogsTimer(@Param("check_id") Long check_id); @Query( value = "SELECT * FROM logs WHERE check_id = :check_id and last_check > :time", nativeQuery = true) List<LogsEntity> findLogs(@Param("check_id") Long check_id, @Param("time") Timestamp time); List<LogsRepository> findAllByOrderByIdAsc(); }
1,428
0.737395
0.737395
37
37.567566
30.647552
111
false
false
0
0
0
0
0
0
0.648649
false
false
2
6065b1c51bc5a4d2707845814d8404e6aebf5cb9
22,436,909,190,830
705b0ab0d7541122959c077de8ce8a8acbe26aa1
/Firecode/remove_dupl.java
0236fb5a8c34f8c5e8af6d9e17e4ba61b2aed253
[]
no_license
3esawe/Contest
https://github.com/3esawe/Contest
a53bea8322c78eb4d2a396197be4239a22f5fc26
e252d0d3d68f0fa9cc85e320f9a2bfa2452ffd08
refs/heads/master
2020-04-04T14:50:53.182000
2018-11-08T14:23:28
2018-11-08T14:23:28
156,015,500
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package Firecode; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class remove_dupl { public static void main(String[] args) { } public static ArrayList<String> removeDuplicates(List<String> input) { ArrayList<String> arrayList = new ArrayList<>(); for (int i = 0; i < input.size(); i ++){ if (input.contains(input.get(i)) && !arrayList.contains(input.get(i))){ arrayList.add(input.get(i)); } } Collections.sort(arrayList); return arrayList ; } }
UTF-8
Java
587
java
remove_dupl.java
Java
[]
null
[]
package Firecode; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class remove_dupl { public static void main(String[] args) { } public static ArrayList<String> removeDuplicates(List<String> input) { ArrayList<String> arrayList = new ArrayList<>(); for (int i = 0; i < input.size(); i ++){ if (input.contains(input.get(i)) && !arrayList.contains(input.get(i))){ arrayList.add(input.get(i)); } } Collections.sort(arrayList); return arrayList ; } }
587
0.60477
0.603066
22
25.681818
23.797224
83
false
false
0
0
0
0
0
0
0.454545
false
false
2
580dcfe7bbd8f3c656961b9f49c7e93278995fbd
31,748,398,300,237
d12522f38ef3d94e14ec34ceb5c204044d266e41
/src/main/java/com/sba/projecthandler/services/ProjectService.java
9fd1637318eab10386a9bc1b515163cfe7fc4f59
[]
no_license
fsdassignments/project-handler
https://github.com/fsdassignments/project-handler
7e2560e6cc93f3c8282f7a2378011441e97d7be2
d9a41bfec5cec750b93b9b3a05865565ab7da0c6
refs/heads/master
2020-11-28T17:16:22.953000
2019-12-31T08:38:58
2019-12-31T08:38:58
229,878,069
0
0
null
false
2019-12-31T08:39:00
2019-12-24T05:42:53
2019-12-30T13:18:21
2019-12-31T08:38:59
76
0
0
0
Java
false
false
package com.sba.projecthandler.services; import java.util.List; import com.sba.projecthandler.errors.ProjectNotFoundException; import com.sba.projecthandler.model.Project; public interface ProjectService { List<Project> list(); int save(Project project) throws Exception; Project update(int id, Project project) throws ProjectNotFoundException; Project get(int id) throws ProjectNotFoundException; }
UTF-8
Java
414
java
ProjectService.java
Java
[]
null
[]
package com.sba.projecthandler.services; import java.util.List; import com.sba.projecthandler.errors.ProjectNotFoundException; import com.sba.projecthandler.model.Project; public interface ProjectService { List<Project> list(); int save(Project project) throws Exception; Project update(int id, Project project) throws ProjectNotFoundException; Project get(int id) throws ProjectNotFoundException; }
414
0.806763
0.806763
17
23.352942
24.547531
73
false
false
0
0
0
0
0
0
0.941176
false
false
2
9cad5202c420f0dc7e012c95a69f74bcc77b156b
12,695,923,389,334
6ed1a3cfc0d8b2b38c19e347c5e57cbea8759dec
/src/main/java/pers/mingda/leetcode/LC0387FirstUniqueCharacterInAString.java
b13512dfd6fcda6ec1789aad4c33d6687e088d36
[]
no_license
Mingda-Rui/LeetCodePractise
https://github.com/Mingda-Rui/LeetCodePractise
6ff1ec3b82fcc82f935ef4995670a3725839a71c
cc43e606dba8f5d6753b47e4459674ee35f2e1fd
refs/heads/master
2023-01-27T20:16:07.065000
2023-01-16T03:18:48
2023-01-16T03:18:48
181,302,050
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package pers.mingda.leetcode; import java.util.LinkedHashMap; import java.util.Map; public class LC0387FirstUniqueCharacterInAString { public int firstUniqChar(String s) { int[] record = new int[128]; for (char c: s.toCharArray()) record[c]++; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (record[c] == 1) return i; } return -1; } public int firstUniqCharOnePass(String s) { Map<Character, Integer> map = new LinkedHashMap<>(); boolean[] seen = new boolean[128]; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (!seen[c]) { map.put(c, i); seen[c] = true; } else { map.remove(c); } } return map.isEmpty() ? -1 : map.entrySet().iterator().next().getValue(); } public int firstUniqCharTwoPointers(String s) { int slow = 0; int fast = 1; int[] record = new int[128]; record[s.charAt(slow)]++; while (slow < fast) { if (fast < s.length()) { if (s.charAt(slow) == s.charAt(fast)) slow++; record[s.charAt(fast)]++; fast++; } else if (record[s.charAt(slow)] > 1) { slow++; } else { return slow; } } return -1; } public int firstUniqCharStringIndexOf(String s) { int result = Integer.MAX_VALUE; for (char c = 'a'; c <= 'z'; c++) { int index = s.indexOf(c); if (index != -1 && index == s.lastIndexOf(c)) result = Math.min(result, index); } return result == Integer.MAX_VALUE ? -1 : result; } }
UTF-8
Java
1,860
java
LC0387FirstUniqueCharacterInAString.java
Java
[]
null
[]
package pers.mingda.leetcode; import java.util.LinkedHashMap; import java.util.Map; public class LC0387FirstUniqueCharacterInAString { public int firstUniqChar(String s) { int[] record = new int[128]; for (char c: s.toCharArray()) record[c]++; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (record[c] == 1) return i; } return -1; } public int firstUniqCharOnePass(String s) { Map<Character, Integer> map = new LinkedHashMap<>(); boolean[] seen = new boolean[128]; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (!seen[c]) { map.put(c, i); seen[c] = true; } else { map.remove(c); } } return map.isEmpty() ? -1 : map.entrySet().iterator().next().getValue(); } public int firstUniqCharTwoPointers(String s) { int slow = 0; int fast = 1; int[] record = new int[128]; record[s.charAt(slow)]++; while (slow < fast) { if (fast < s.length()) { if (s.charAt(slow) == s.charAt(fast)) slow++; record[s.charAt(fast)]++; fast++; } else if (record[s.charAt(slow)] > 1) { slow++; } else { return slow; } } return -1; } public int firstUniqCharStringIndexOf(String s) { int result = Integer.MAX_VALUE; for (char c = 'a'; c <= 'z'; c++) { int index = s.indexOf(c); if (index != -1 && index == s.lastIndexOf(c)) result = Math.min(result, index); } return result == Integer.MAX_VALUE ? -1 : result; } }
1,860
0.457527
0.444624
63
28.523809
17.912359
80
false
false
0
0
0
0
0
0
0.603175
false
false
2
9072923aaeb3cc3f5059e1b68a915fd3e5593bf6
29,274,497,144,261
0c5885fa689f5c309860a13fb929e14f26bfe7eb
/smProject-master/src/main/java/net/skhu/controller/MentorController.java
eb712b81d8110fab020904ddbe0890e0bc088428
[]
no_license
choiyk/smProject
https://github.com/choiyk/smProject
08b4c1f77c3bfbc948156a44a2b792daf1112a1d
812981f083f4d9357f1e6e2757d70a54e3d6072d
refs/heads/master
2022-08-13T22:56:03.105000
2022-07-24T08:01:11
2022-07-24T08:01:11
108,982,952
0
2
null
null
null
null
null
null
null
null
null
null
null
null
null
package net.skhu.controller; /* import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; @Controller public class MentorController { } *///멘토방에 필요하면 사용하고 아니면 지울것
UTF-8
Java
600
java
MentorController.java
Java
[]
null
[]
package net.skhu.controller; /* import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.multipart.MultipartFile; @Controller public class MentorController { } *///멘토방에 필요하면 사용하고 아니면 지울것
600
0.81383
0.81383
19
27.789474
24.614029
62
false
false
0
0
0
0
0
0
0.473684
false
false
2
ffbcb1ff8e591471039cfcce177f4e629ba89a64
24,197,845,792,558
20f5a93896b53ee464ed8473031f9bca179d69ac
/src/test/java/com/selenide/tests/OrderProductE2ETest.java
82e75dfa4856b092edcc2779e85345a40d309648
[]
no_license
anditpl/szkolenie_sii_selenide
https://github.com/anditpl/szkolenie_sii_selenide
138785378d62c5194d7399ed904dbace141e94d9
c88c69e42a8b30f97e40c8ccb1d510b4c6ccdee6
refs/heads/master
2023-03-24T05:32:51.812000
2021-03-14T17:44:05
2021-03-14T17:44:05
347,329,176
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.selenide.tests; import com.codeborne.selenide.Condition; import com.selenide.pages.CroppPage; import com.selenide.pages.HomePage; import org.junit.Test; import static com.codeborne.selenide.Selenide.*; import static org.junit.Assert.assertEquals; public class OrderProductE2ETest extends BaseTest { @Test public void smoke(){ croppPage.openSite(); homePage.selectMenuSubmenu("Kobieta", "Swetry"); subMenuPage.selectFirstProduct(); productPage.selectSize("XS"); productPage.assertSizeIsSelected("XS"); productPage.addProductToCard(); productPage.assertPrice("39,99"); productPage.goToBasket(); } @Test public void selectMenuSubMenuTest(){ croppPage.openSite(); homePage.selectMenuSubmenu("Kobieta", "Swetry"); subMenuPage.assertTitleIs("Modne swetry damskie z kolekcji Cropp – odkryj najnowsze trendy"); } @Test public void selectSizeTest(){ croppPage.openSite(); homePage.selectMenuSubmenu("Polecane", "Basic"); subMenuPage.selectFirstProduct(); productPage.selectSize("XS"); productPage.assertSizeIsSelected("XS"); } }
UTF-8
Java
1,204
java
OrderProductE2ETest.java
Java
[]
null
[]
package com.selenide.tests; import com.codeborne.selenide.Condition; import com.selenide.pages.CroppPage; import com.selenide.pages.HomePage; import org.junit.Test; import static com.codeborne.selenide.Selenide.*; import static org.junit.Assert.assertEquals; public class OrderProductE2ETest extends BaseTest { @Test public void smoke(){ croppPage.openSite(); homePage.selectMenuSubmenu("Kobieta", "Swetry"); subMenuPage.selectFirstProduct(); productPage.selectSize("XS"); productPage.assertSizeIsSelected("XS"); productPage.addProductToCard(); productPage.assertPrice("39,99"); productPage.goToBasket(); } @Test public void selectMenuSubMenuTest(){ croppPage.openSite(); homePage.selectMenuSubmenu("Kobieta", "Swetry"); subMenuPage.assertTitleIs("Modne swetry damskie z kolekcji Cropp – odkryj najnowsze trendy"); } @Test public void selectSizeTest(){ croppPage.openSite(); homePage.selectMenuSubmenu("Polecane", "Basic"); subMenuPage.selectFirstProduct(); productPage.selectSize("XS"); productPage.assertSizeIsSelected("XS"); } }
1,204
0.688852
0.684692
40
29.075001
21.788055
101
false
false
0
0
0
0
0
0
0.675
false
false
2
b4e1cfa12be61cb7ec05f96e8774c95439a2c068
8,813,272,947,507
38f2672ba3dbc9a931e70a88b156ffe2ba017841
/app/src/main/java/is/hello/sense/ui/fragments/updating/ConnectToWiFiFragment.java
0caa3718eb990ccdb6a680750174a478b5f2d0ec
[]
no_license
Jorge-eng/suripu-android
https://github.com/Jorge-eng/suripu-android
662e47e56f67869fa7214b67ca8253af90202783
753252c9e55b192985972d0c5e8e92b22edb5fca
refs/heads/master
2021-04-30T16:00:50.032000
2017-04-22T00:38:20
2017-04-22T00:38:20
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package is.hello.sense.ui.fragments.updating; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.v4.content.ContextCompat; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import javax.inject.Inject; import is.hello.commonsense.bluetooth.model.protobuf.SenseCommandProtos.wifi_endpoint; import is.hello.sense.R; import is.hello.sense.presenters.BasePresenter; import is.hello.sense.presenters.connectwifi.BaseConnectWifiPresenter; import is.hello.sense.ui.common.OnboardingToolbar; import is.hello.sense.ui.fragments.BasePresenterFragment; import is.hello.sense.ui.widget.LabelEditText; import is.hello.sense.ui.widget.util.Styles; import is.hello.sense.ui.widget.util.Views; import is.hello.sense.util.EditorActionHandler; import static is.hello.commonsense.bluetooth.model.protobuf.SenseCommandProtos.wifi_endpoint.sec_type; public class ConnectToWiFiFragment extends BasePresenterFragment implements AdapterView.OnItemSelectedListener, BaseConnectWifiPresenter.Output { public static final String ARG_SCAN_RESULT = ConnectToWiFiFragment.class.getName() + ".ARG_SCAN_RESULT"; private static final int ERROR_REQUEST_CODE = 0x30; private EditText networkName; private LabelEditText networkPassword; private Spinner networkSecurity; private Button continueButton; private View view; private OnboardingToolbar toolbar; @Inject BaseConnectWifiPresenter wifiPresenter; //region Lifecycle @Override protected BasePresenter getPresenter() { return wifiPresenter; } @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); wifiPresenter.setNetwork((wifi_endpoint) getArguments().getSerializable(ARG_SCAN_RESULT)); setRetainInstance(true); } @Nullable @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_connect_to_wifi, container, false); this.networkName = (EditText) view.findViewById(R.id.fragment_connect_to_wifi_network); this.networkPassword = (LabelEditText) view.findViewById(R.id.fragment_connect_to_wifi_password); networkPassword.setOnEditorActionListener(new EditorActionHandler(wifiPresenter::sendWifiCredentials)); this.continueButton = (Button) view.findViewById(R.id.fragment_connect_to_wifi_continue); Views.setSafeOnClickListener(continueButton, ignored -> wifiPresenter.sendWifiCredentials()); this.toolbar = OnboardingToolbar.of(this, view); return view; } @Override public void onDestroyView() { super.onDestroyView(); if (networkSecurity != null) { networkSecurity.setAdapter(null); networkSecurity.setOnItemSelectedListener(null); networkSecurity = null; } if (toolbar != null) { toolbar.onDestroyView(); toolbar = null; } networkName = null; if (networkPassword != null) { networkPassword.setOnEditorActionListener(null); } networkPassword = null; if (continueButton != null) { continueButton.setOnClickListener(null); } continueButton = null; view = null; } @Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ERROR_REQUEST_CODE && resultCode == Activity.RESULT_OK) { wifiPresenter.sendWifiCredentials(); } } @Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { inflater.inflate(R.menu.help, menu); final MenuItem infoItem = menu.findItem(R.id.action_help); if(infoItem != null){ Styles.tintMenuIcon(getActivity(), infoItem, R.color.action_bar_menu_icon); } } @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.action_help: { wifiPresenter.onHelpClick(null); return true; } default: { return super.onOptionsItemSelected(item); } } } //endregion @Override public void updateView(@Nullable final wifi_endpoint network) { if (view == null) { return; } final TextView title = (TextView) view.findViewById(R.id.fragment_connect_to_wifi_title); final TextView networkInfo = (TextView) view.findViewById(R.id.fragment_connect_to_wifi_info); final ViewGroup otherContainer = (ViewGroup) view.findViewById(R.id.fragment_connect_to_wifi_other_container); if (network != null) { networkName.setText(network.getSsid()); wifiPresenter.updatePasswordField(); final SpannableStringBuilder networkInfoBuilder = new SpannableStringBuilder(); networkInfoBuilder.append(getString(R.string.label_wifi_network_name)); final int start = networkInfoBuilder.length(); networkInfoBuilder.append(network.getSsid()); networkInfoBuilder.setSpan( new ForegroundColorSpan(ContextCompat.getColor(getActivity(), R.color.primary_text)), start, networkInfoBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE ); networkInfo.setText(networkInfoBuilder); networkInfo.setVisibility(View.VISIBLE); otherContainer.setVisibility(View.GONE); if (network.getSecurityType() == sec_type.SL_SCAN_SEC_TYPE_OPEN) { title.setText(R.string.title_sign_into_wifi_selection_open); } else { title.setText(R.string.title_sign_into_wifi_selection); } } else { networkSecurity = (Spinner) otherContainer.findViewById(R.id.fragment_connect_to_wifi_security); networkSecurity.setAdapter(new SecurityTypeAdapter(getActivity())); networkSecurity.setSelection(sec_type.SL_SCAN_SEC_TYPE_WPA_VALUE); networkSecurity.setOnItemSelectedListener(this); networkName.requestFocus(); networkInfo.setVisibility(View.GONE); otherContainer.setVisibility(View.VISIBLE); title.setText(R.string.title_sign_into_wifi_other); } } //region Password Field @Override public String getNetworkName() { if (networkName == null) { return null; } return networkName.getText().toString(); } @Override public String getNetworkPassword() { if (networkPassword == null) { return null; } return networkPassword.getInputText(); } @Override public void setNetworkPassword(final int visibility, final boolean requestFocus, final boolean clearInput) { if (networkPassword == null) { return; } networkPassword.setVisibility(visibility); if (clearInput) { networkPassword.setInputText(null); } if (requestFocus) { networkPassword.requestFocus(); } else { networkPassword.clearFocus(); } } @Override public wifi_endpoint.sec_type getNetworkSecurityType() { if (networkSecurity == null) { return null; } return (wifi_endpoint.sec_type) networkSecurity.getSelectedItem(); } @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { wifiPresenter.updatePasswordField(); } @Override public void onNothingSelected(final AdapterView<?> parent) { wifiPresenter.updatePasswordField(); } @Override public void useToolbar(final boolean use) { if (use) { this.toolbar.setWantsBackButton(true) .setOnHelpClickListener(wifiPresenter::onHelpClick); //todo add back support options after refactor this.toolbar.setVisible(true); setHasOptionsMenu(false); } else { setHasOptionsMenu(true); this.toolbar.hide(); } } //endregion private static class SecurityTypeAdapter extends ArrayAdapter<sec_type> { private SecurityTypeAdapter(final Context context) { super(context, R.layout.item_sec_type, sec_type.values()); } @Override public int getCount() { if (super.getCount() > 3) { return 4; } return super.getCount(); } private @StringRes int getTitle(final int position) { switch (getItem(position)) { case SL_SCAN_SEC_TYPE_OPEN: return R.string.sec_type_open; case SL_SCAN_SEC_TYPE_WEP: return R.string.sec_type_wep; case SL_SCAN_SEC_TYPE_WPA: return R.string.sec_type_wpa; default: return R.string.sec_type_wpa2; } } @Override public View getView(final int position, final View convertView, final ViewGroup parent) { final TextView text = (TextView) super.getView(position, convertView, parent); text.setText(getTitle(position)); return text; } @Override public View getDropDownView(final int position, final View convertView, final ViewGroup parent) { final TextView text = (TextView) super.getDropDownView(position, convertView, parent); text.setText(getTitle(position)); return text; } } }
UTF-8
Java
10,675
java
ConnectToWiFiFragment.java
Java
[]
null
[]
package is.hello.sense.ui.fragments.updating; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.support.v4.content.ContextCompat; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import javax.inject.Inject; import is.hello.commonsense.bluetooth.model.protobuf.SenseCommandProtos.wifi_endpoint; import is.hello.sense.R; import is.hello.sense.presenters.BasePresenter; import is.hello.sense.presenters.connectwifi.BaseConnectWifiPresenter; import is.hello.sense.ui.common.OnboardingToolbar; import is.hello.sense.ui.fragments.BasePresenterFragment; import is.hello.sense.ui.widget.LabelEditText; import is.hello.sense.ui.widget.util.Styles; import is.hello.sense.ui.widget.util.Views; import is.hello.sense.util.EditorActionHandler; import static is.hello.commonsense.bluetooth.model.protobuf.SenseCommandProtos.wifi_endpoint.sec_type; public class ConnectToWiFiFragment extends BasePresenterFragment implements AdapterView.OnItemSelectedListener, BaseConnectWifiPresenter.Output { public static final String ARG_SCAN_RESULT = ConnectToWiFiFragment.class.getName() + ".ARG_SCAN_RESULT"; private static final int ERROR_REQUEST_CODE = 0x30; private EditText networkName; private LabelEditText networkPassword; private Spinner networkSecurity; private Button continueButton; private View view; private OnboardingToolbar toolbar; @Inject BaseConnectWifiPresenter wifiPresenter; //region Lifecycle @Override protected BasePresenter getPresenter() { return wifiPresenter; } @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); wifiPresenter.setNetwork((wifi_endpoint) getArguments().getSerializable(ARG_SCAN_RESULT)); setRetainInstance(true); } @Nullable @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_connect_to_wifi, container, false); this.networkName = (EditText) view.findViewById(R.id.fragment_connect_to_wifi_network); this.networkPassword = (LabelEditText) view.findViewById(R.id.fragment_connect_to_wifi_password); networkPassword.setOnEditorActionListener(new EditorActionHandler(wifiPresenter::sendWifiCredentials)); this.continueButton = (Button) view.findViewById(R.id.fragment_connect_to_wifi_continue); Views.setSafeOnClickListener(continueButton, ignored -> wifiPresenter.sendWifiCredentials()); this.toolbar = OnboardingToolbar.of(this, view); return view; } @Override public void onDestroyView() { super.onDestroyView(); if (networkSecurity != null) { networkSecurity.setAdapter(null); networkSecurity.setOnItemSelectedListener(null); networkSecurity = null; } if (toolbar != null) { toolbar.onDestroyView(); toolbar = null; } networkName = null; if (networkPassword != null) { networkPassword.setOnEditorActionListener(null); } networkPassword = null; if (continueButton != null) { continueButton.setOnClickListener(null); } continueButton = null; view = null; } @Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ERROR_REQUEST_CODE && resultCode == Activity.RESULT_OK) { wifiPresenter.sendWifiCredentials(); } } @Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { inflater.inflate(R.menu.help, menu); final MenuItem infoItem = menu.findItem(R.id.action_help); if(infoItem != null){ Styles.tintMenuIcon(getActivity(), infoItem, R.color.action_bar_menu_icon); } } @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.action_help: { wifiPresenter.onHelpClick(null); return true; } default: { return super.onOptionsItemSelected(item); } } } //endregion @Override public void updateView(@Nullable final wifi_endpoint network) { if (view == null) { return; } final TextView title = (TextView) view.findViewById(R.id.fragment_connect_to_wifi_title); final TextView networkInfo = (TextView) view.findViewById(R.id.fragment_connect_to_wifi_info); final ViewGroup otherContainer = (ViewGroup) view.findViewById(R.id.fragment_connect_to_wifi_other_container); if (network != null) { networkName.setText(network.getSsid()); wifiPresenter.updatePasswordField(); final SpannableStringBuilder networkInfoBuilder = new SpannableStringBuilder(); networkInfoBuilder.append(getString(R.string.label_wifi_network_name)); final int start = networkInfoBuilder.length(); networkInfoBuilder.append(network.getSsid()); networkInfoBuilder.setSpan( new ForegroundColorSpan(ContextCompat.getColor(getActivity(), R.color.primary_text)), start, networkInfoBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE ); networkInfo.setText(networkInfoBuilder); networkInfo.setVisibility(View.VISIBLE); otherContainer.setVisibility(View.GONE); if (network.getSecurityType() == sec_type.SL_SCAN_SEC_TYPE_OPEN) { title.setText(R.string.title_sign_into_wifi_selection_open); } else { title.setText(R.string.title_sign_into_wifi_selection); } } else { networkSecurity = (Spinner) otherContainer.findViewById(R.id.fragment_connect_to_wifi_security); networkSecurity.setAdapter(new SecurityTypeAdapter(getActivity())); networkSecurity.setSelection(sec_type.SL_SCAN_SEC_TYPE_WPA_VALUE); networkSecurity.setOnItemSelectedListener(this); networkName.requestFocus(); networkInfo.setVisibility(View.GONE); otherContainer.setVisibility(View.VISIBLE); title.setText(R.string.title_sign_into_wifi_other); } } //region Password Field @Override public String getNetworkName() { if (networkName == null) { return null; } return networkName.getText().toString(); } @Override public String getNetworkPassword() { if (networkPassword == null) { return null; } return networkPassword.getInputText(); } @Override public void setNetworkPassword(final int visibility, final boolean requestFocus, final boolean clearInput) { if (networkPassword == null) { return; } networkPassword.setVisibility(visibility); if (clearInput) { networkPassword.setInputText(null); } if (requestFocus) { networkPassword.requestFocus(); } else { networkPassword.clearFocus(); } } @Override public wifi_endpoint.sec_type getNetworkSecurityType() { if (networkSecurity == null) { return null; } return (wifi_endpoint.sec_type) networkSecurity.getSelectedItem(); } @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { wifiPresenter.updatePasswordField(); } @Override public void onNothingSelected(final AdapterView<?> parent) { wifiPresenter.updatePasswordField(); } @Override public void useToolbar(final boolean use) { if (use) { this.toolbar.setWantsBackButton(true) .setOnHelpClickListener(wifiPresenter::onHelpClick); //todo add back support options after refactor this.toolbar.setVisible(true); setHasOptionsMenu(false); } else { setHasOptionsMenu(true); this.toolbar.hide(); } } //endregion private static class SecurityTypeAdapter extends ArrayAdapter<sec_type> { private SecurityTypeAdapter(final Context context) { super(context, R.layout.item_sec_type, sec_type.values()); } @Override public int getCount() { if (super.getCount() > 3) { return 4; } return super.getCount(); } private @StringRes int getTitle(final int position) { switch (getItem(position)) { case SL_SCAN_SEC_TYPE_OPEN: return R.string.sec_type_open; case SL_SCAN_SEC_TYPE_WEP: return R.string.sec_type_wep; case SL_SCAN_SEC_TYPE_WPA: return R.string.sec_type_wpa; default: return R.string.sec_type_wpa2; } } @Override public View getView(final int position, final View convertView, final ViewGroup parent) { final TextView text = (TextView) super.getView(position, convertView, parent); text.setText(getTitle(position)); return text; } @Override public View getDropDownView(final int position, final View convertView, final ViewGroup parent) { final TextView text = (TextView) super.getDropDownView(position, convertView, parent); text.setText(getTitle(position)); return text; } } }
10,675
0.645902
0.645246
313
33.105431
28.91198
121
false
false
0
0
0
0
0
0
0.527157
false
false
2
968552524fdc09c65787f1e7eda8fd059a229610
21,285,857,963,939
2048b6420d19b9fa11def6f2c2ff755386d04ecd
/view/src/main/java/com/mvrt/scoutview/ReportsFragment.java
f49af688e527d09fe53edce85726285b29d6d8d1
[]
no_license
akhil99/mvrt-scout-android
https://github.com/akhil99/mvrt-scout-android
0e70a8ff31daa530f8850838650b9e146e44e4fc
f96b6948a2947cba221e8afbde9a3fd0fb0c0236
refs/heads/master
2020-05-04T12:45:54.921000
2015-07-10T05:22:54
2015-07-10T05:22:54
33,960,879
4
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.mvrt.scoutview; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.mvrt.scoutview.adapters.TabPagerAdapter; import com.mvrt.scoutview.view.NavDrawerFragment; import com.mvrt.scoutview.view.SlidingTabLayout; public class ReportsFragment extends NavDrawerFragment { private SlidingTabLayout slidingTabs; TabPagerAdapter adapter; private ViewPager viewPager; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_reports, container, false); } @Override public void onViewCreated(View v, Bundle savedInstanceState){ viewPager = (ViewPager)v.findViewById(R.id.reportstab_viewpager); adapter = new TabPagerAdapter(getChildFragmentManager()); viewPager.setAdapter(adapter); slidingTabs = (SlidingTabLayout)v.findViewById(R.id.reportstab_slidingtabs); slidingTabs.setSelectedIndicatorColors(getResources().getColor(R.color.accent)); slidingTabs.setViewPager(viewPager); } @Override public String getTitle() { return "Scouting Reports"; } @Override public int getIcon() { return R.drawable.ic_reports_purple; } }
UTF-8
Java
1,426
java
ReportsFragment.java
Java
[]
null
[]
package com.mvrt.scoutview; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.mvrt.scoutview.adapters.TabPagerAdapter; import com.mvrt.scoutview.view.NavDrawerFragment; import com.mvrt.scoutview.view.SlidingTabLayout; public class ReportsFragment extends NavDrawerFragment { private SlidingTabLayout slidingTabs; TabPagerAdapter adapter; private ViewPager viewPager; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_reports, container, false); } @Override public void onViewCreated(View v, Bundle savedInstanceState){ viewPager = (ViewPager)v.findViewById(R.id.reportstab_viewpager); adapter = new TabPagerAdapter(getChildFragmentManager()); viewPager.setAdapter(adapter); slidingTabs = (SlidingTabLayout)v.findViewById(R.id.reportstab_slidingtabs); slidingTabs.setSelectedIndicatorColors(getResources().getColor(R.color.accent)); slidingTabs.setViewPager(viewPager); } @Override public String getTitle() { return "Scouting Reports"; } @Override public int getIcon() { return R.drawable.ic_reports_purple; } }
1,426
0.739832
0.73913
47
29.340425
27.446875
103
false
false
0
0
0
0
0
0
0.553191
false
false
2
d636068d4e5e2acf278312d1d3bea43fe780e078
26,044,681,729,609
c2842e2c5bcd776dd162b155497882d034495d85
/src/main/java/top/appx/zutil/easysql/DBUtil.java
313a5227ace3bfe3a39e7806d017d7cda5fe080b
[]
no_license
zhangwenyan/zutil.java
https://github.com/zhangwenyan/zutil.java
b6501e62e355a77003956eb98308c2a52a78c1f7
ab1a7e224829d896b0c674b00cfae3b58f2ad57d
refs/heads/master
2020-04-06T03:54:51.987000
2017-03-24T15:35:20
2017-03-24T15:35:20
83,102,389
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package top.appx.zutil.easysql; import java.lang.reflect.Method; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; /** * Created by qq799 on 2017/2/26. */ public class DBUtil { private DBUtil(){} public static List resultToList(ResultSet rs, Class<?> entityClass) { try { List list = new ArrayList(); while (rs.next()) { Object entity = entityClass.newInstance(); Method[] methods = entityClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("set")) { String paramName = method.getName().substring(3); Object value = rs.getObject(paramName); if (value != null) { Class typeClass = method.getParameterTypes()[0].getClass(); method.invoke(entity, value); } } } list.add(entity); } return list; } catch (Exception ex) { throw new EasySqlException(ex); } } public static DataTable resultToDataTable(ResultSet rs){ try { DataTable dt = new DataTable(); while (rs.next()) { int cc = rs.getMetaData().getColumnCount(); DataRow dr = new DataRow(dt); for (int i = 0; i < cc; i++) { String key = rs.getMetaData().getColumnName(i + 1); Object value = rs.getObject(i + 1); dr.put(key, value); } dt.add(dr); } return dt; }catch (Exception ex){ throw new EasySqlException(ex); } } public static String getCountSql(String sql){ return "select count(*) from ("+sql+") as easysql_count"; } /* public static String getSqlCount(String sql) { if (sql.IndexOf("order ") == -1) { return "select count(*) from ("+sql+ ") as easysql_tb"; } else { return "select count(*) from (" + sql.Substring(0,sql.IndexOf("order ")) + ") as easysql_tb"; } } */ }
UTF-8
Java
2,295
java
DBUtil.java
Java
[ { "context": "rayList;\nimport java.util.List;\n\n/**\n * Created by qq799 on 2017/2/26.\n */\npublic class DBUtil {\n priva", "end": 168, "score": 0.9995595812797546, "start": 163, "tag": "USERNAME", "value": "qq799" } ]
null
[]
package top.appx.zutil.easysql; import java.lang.reflect.Method; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; /** * Created by qq799 on 2017/2/26. */ public class DBUtil { private DBUtil(){} public static List resultToList(ResultSet rs, Class<?> entityClass) { try { List list = new ArrayList(); while (rs.next()) { Object entity = entityClass.newInstance(); Method[] methods = entityClass.getMethods(); for (Method method : methods) { if (method.getName().startsWith("set")) { String paramName = method.getName().substring(3); Object value = rs.getObject(paramName); if (value != null) { Class typeClass = method.getParameterTypes()[0].getClass(); method.invoke(entity, value); } } } list.add(entity); } return list; } catch (Exception ex) { throw new EasySqlException(ex); } } public static DataTable resultToDataTable(ResultSet rs){ try { DataTable dt = new DataTable(); while (rs.next()) { int cc = rs.getMetaData().getColumnCount(); DataRow dr = new DataRow(dt); for (int i = 0; i < cc; i++) { String key = rs.getMetaData().getColumnName(i + 1); Object value = rs.getObject(i + 1); dr.put(key, value); } dt.add(dr); } return dt; }catch (Exception ex){ throw new EasySqlException(ex); } } public static String getCountSql(String sql){ return "select count(*) from ("+sql+") as easysql_count"; } /* public static String getSqlCount(String sql) { if (sql.IndexOf("order ") == -1) { return "select count(*) from ("+sql+ ") as easysql_tb"; } else { return "select count(*) from (" + sql.Substring(0,sql.IndexOf("order ")) + ") as easysql_tb"; } } */ }
2,295
0.48061
0.473203
76
29.197369
24.387238
105
false
false
0
0
0
0
0
0
0.434211
false
false
2
f333f1cce18adf83eeab9b9b6daa9636b22e5158
17,025,250,371,085
9831f0a6a4da36247d12a05e13272b3bf677b10d
/src/com/photography/dao/exp/LogicExpressionExtr.java
9de39530bfdb7d298dbfc95b7f92ebdc19e97ba8
[]
no_license
nxxyb/shuadan
https://github.com/nxxyb/shuadan
e0002803321a27b2244996f4591bf7584113320a
ac782ea2587f080304fcccc90f1db5afcf5e4d59
refs/heads/master
2020-05-20T00:22:52.837000
2015-04-14T09:15:16
2015-04-14T09:15:16
33,303,665
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.photography.dao.exp; import java.util.ArrayList; import java.util.List; /** * LogicExpressionExtr * 逻辑表达式 * @author 门宏建 * @since 2011-8-11 * * @Copyright (C) 2012 天大求实电力新技术股份有限公司 版权所有 */ public class LogicExpressionExtr extends Expression { private static final long serialVersionUID = -5477270650928332876L; protected List<Expression> expressions; protected String logic; public String getLogic() { return logic; } public void setLogic(String logic) { this.logic = logic; } public List<Expression> getExpressions() { return expressions; } public void setExpressions(List<Expression> expressions) { this.expressions = expressions; } public LogicExpressionExtr(List<Expression> expressions, String logic) { super(); this.expressions = expressions; this.logic = logic; } @Override public Expression clone() { List<Expression> newExprs = new ArrayList<Expression>(); if(expressions!=null) { for(Expression expression : expressions) { newExprs.add(expression.clone()); } } return new LogicExpressionExtr(newExprs,logic); } }
UTF-8
Java
1,161
java
LogicExpressionExtr.java
Java
[ { "context": ";\n\n/**\n * LogicExpressionExtr\n * 逻辑表达式\n * @author 门宏建 \n * @since 2011-8-11 \n * \n * @Copyright (C) 2012 ", "end": 136, "score": 0.9994792342185974, "start": 133, "tag": "NAME", "value": "门宏建" } ]
null
[]
package com.photography.dao.exp; import java.util.ArrayList; import java.util.List; /** * LogicExpressionExtr * 逻辑表达式 * @author 门宏建 * @since 2011-8-11 * * @Copyright (C) 2012 天大求实电力新技术股份有限公司 版权所有 */ public class LogicExpressionExtr extends Expression { private static final long serialVersionUID = -5477270650928332876L; protected List<Expression> expressions; protected String logic; public String getLogic() { return logic; } public void setLogic(String logic) { this.logic = logic; } public List<Expression> getExpressions() { return expressions; } public void setExpressions(List<Expression> expressions) { this.expressions = expressions; } public LogicExpressionExtr(List<Expression> expressions, String logic) { super(); this.expressions = expressions; this.logic = logic; } @Override public Expression clone() { List<Expression> newExprs = new ArrayList<Expression>(); if(expressions!=null) { for(Expression expression : expressions) { newExprs.add(expression.clone()); } } return new LogicExpressionExtr(newExprs,logic); } }
1,161
0.724481
0.69738
57
18.421053
20.0245
73
false
false
0
0
0
0
0
0
1.192982
false
false
2
b71beee7835251c7a6562dcfea7d4a82fe3fba28
30,588,757,091,877
8793867db7904f36d2a4dc6afdcb505020add61a
/src/test/java/uk/co/swilson/advent/Day21Test.java
58b5b0adf78d517e225ba834bdfe66846d52dc27
[]
no_license
swilson96/advent-of-code-2020
https://github.com/swilson96/advent-of-code-2020
d4872c118a8943af8627a7c237196038689ade89
38d026e292aacff3f7cdf0aa2d8482f87cf1aa6b
refs/heads/main
2023-02-08T12:26:28.795000
2020-12-31T14:46:51
2020-12-31T14:46:51
318,088,312
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package uk.co.swilson.advent; import org.junit.jupiter.api.Test; import uk.co.swilson.advent.day21.Day21; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; public class Day21Test { private static final String EXAMPLE_INPUT = "mxmxvkd kfcds sqjhc nhms (contains dairy, fish)\n" + "trh fvjkl sbzzf mxmxvkd (contains dairy)\n" + "sqjhc fvjkl (contains soy)\n" + "sqjhc mxmxvkd sbzzf (contains fish)"; @Test public void example() { var solver = new Day21(); var result = solver.solvePartOne(EXAMPLE_INPUT); assertThat(result).isEqualTo(5); } @Test public void partTwoExample() { var solver = new Day21(); var result = solver.solvePartTwoToString(EXAMPLE_INPUT); assertThat(result).isEqualTo("mxmxvkd,sqjhc,fvjkl"); } }
UTF-8
Java
884
java
Day21Test.java
Java
[]
null
[]
package uk.co.swilson.advent; import org.junit.jupiter.api.Test; import uk.co.swilson.advent.day21.Day21; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; public class Day21Test { private static final String EXAMPLE_INPUT = "mxmxvkd kfcds sqjhc nhms (contains dairy, fish)\n" + "trh fvjkl sbzzf mxmxvkd (contains dairy)\n" + "sqjhc fvjkl (contains soy)\n" + "sqjhc mxmxvkd sbzzf (contains fish)"; @Test public void example() { var solver = new Day21(); var result = solver.solvePartOne(EXAMPLE_INPUT); assertThat(result).isEqualTo(5); } @Test public void partTwoExample() { var solver = new Day21(); var result = solver.solvePartTwoToString(EXAMPLE_INPUT); assertThat(result).isEqualTo("mxmxvkd,sqjhc,fvjkl"); } }
884
0.642534
0.63009
27
30.74074
26.417717
101
false
false
0
0
0
0
0
0
0.518519
false
false
2
c671ce709d2994af4fa4f62986fabe17b0e3c7c5
24,232,205,530,130
7c5a05deb4ab085ec8d3f640048eb221e1bcfe33
/app/src/main/java/com/ftiron/next/presentation/model/SearchedSeriesModel.java
eacb7aef7f25843621632bc01904e9558198049b
[]
no_license
xTiron/Next
https://github.com/xTiron/Next
3a57aa443cc7a236bbdf009bc1975dfa6c052961
5a22d44b7cef0a307892a061dbbf8593e5f9195a
refs/heads/master
2018-12-31T18:08:44.945000
2015-05-10T21:18:04
2015-05-10T21:18:04
32,932,933
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.ftiron.next.presentation.model; /** * Created by ftiron on 15-Apr-15. */ public class SearchedSeriesModel { private int seriesId; private String seriesName; private String bannerUrl; private String firstAired; public SearchedSeriesModel(int seriesId){ this.seriesId = seriesId; } public int getSeriesId() { return seriesId; } public String getSeriesName() { return seriesName; } public void setSeriesName(String seriesName) { this.seriesName = seriesName; } public String getBannerUrl() { return bannerUrl; } public void setBannerUrl(String bannerUrl) { this.bannerUrl = bannerUrl; } public String getFirstAired() { return firstAired; } public void setFirstAired(String firstAired) { this.firstAired = firstAired; } }
UTF-8
Java
887
java
SearchedSeriesModel.java
Java
[ { "context": "ftiron.next.presentation.model;\n\n/**\n * Created by ftiron on 15-Apr-15.\n */\npublic class SearchedSeriesMode", "end": 69, "score": 0.9996075630187988, "start": 63, "tag": "USERNAME", "value": "ftiron" } ]
null
[]
package com.ftiron.next.presentation.model; /** * Created by ftiron on 15-Apr-15. */ public class SearchedSeriesModel { private int seriesId; private String seriesName; private String bannerUrl; private String firstAired; public SearchedSeriesModel(int seriesId){ this.seriesId = seriesId; } public int getSeriesId() { return seriesId; } public String getSeriesName() { return seriesName; } public void setSeriesName(String seriesName) { this.seriesName = seriesName; } public String getBannerUrl() { return bannerUrl; } public void setBannerUrl(String bannerUrl) { this.bannerUrl = bannerUrl; } public String getFirstAired() { return firstAired; } public void setFirstAired(String firstAired) { this.firstAired = firstAired; } }
887
0.645998
0.641488
45
18.711111
17.21191
50
false
false
0
0
0
0
0
0
0.288889
false
false
2
66fed774cb0b00a730a18b053289ebdbe59a4dbb
30,648,886,655,319
03730a3efb85f010794e8791deb5aa51d6720d48
/streaming/java/streaming-state/src/main/java/io/ray/streaming/state/store/memory/MemoryNonKeyedMapStore.java
b6a95d80974f799c1886940fad1b68ea7e6e7827
[ "Apache-2.0", "BSD-3-Clause", "MIT" ]
permissive
ray-project/mobius
https://github.com/ray-project/mobius
9d842028cb0c2c9ff592e3b036287be618cd69d2
15522e57679acb5e28392890a86ce56409659a5e
refs/heads/master
2023-08-29T08:46:55.960000
2022-10-31T04:09:27
2022-10-31T04:09:27
137,820,418
85
12
Apache-2.0
false
2022-10-31T04:09:28
2018-06-19T00:23:12
2022-10-08T10:52:44
2022-10-31T04:09:27
1,616
62
8
7
Java
false
false
package io.ray.streaming.state.store.memory; import io.ray.streaming.common.metric.MetricGroup; import io.ray.streaming.state.api.state.MapState; import io.ray.streaming.state.store.backend.memory.MemoryStateBackend; import io.ray.streaming.state.typeinfo.serializer.TypeSerializer; /** * Implementation of {@link MapState} type(nonkeyed) state in Memory backend. * * @param <K> Key data type * @param <V> Value data type */ public class MemoryNonKeyedMapStore<K, V> extends MemoryMapStore<K, V> { private final int stateKey; public MemoryNonKeyedMapStore( MemoryStateBackend backend, String jobName, String stateName, TypeSerializer typeSerializer, MetricGroup metricGroup, int stateKey) { super(backend, jobName, stateName, typeSerializer, metricGroup); this.stateKey = stateKey; } }
UTF-8
Java
846
java
MemoryNonKeyedMapStore.java
Java
[]
null
[]
package io.ray.streaming.state.store.memory; import io.ray.streaming.common.metric.MetricGroup; import io.ray.streaming.state.api.state.MapState; import io.ray.streaming.state.store.backend.memory.MemoryStateBackend; import io.ray.streaming.state.typeinfo.serializer.TypeSerializer; /** * Implementation of {@link MapState} type(nonkeyed) state in Memory backend. * * @param <K> Key data type * @param <V> Value data type */ public class MemoryNonKeyedMapStore<K, V> extends MemoryMapStore<K, V> { private final int stateKey; public MemoryNonKeyedMapStore( MemoryStateBackend backend, String jobName, String stateName, TypeSerializer typeSerializer, MetricGroup metricGroup, int stateKey) { super(backend, jobName, stateName, typeSerializer, metricGroup); this.stateKey = stateKey; } }
846
0.745863
0.745863
29
28.172413
24.695482
77
false
false
0
0
0
0
0
0
0.655172
false
false
2
200f666a8583448d7edf067919503100e6bdf83b
21,698,174,819,999
21f4600f9570696144a84ff75fb2374d67820616
/hw5/Node.java
4aeed5321eb87a786003e6479c453f4f202106ca
[]
no_license
jonluntzel/331-Software-Design
https://github.com/jonluntzel/331-Software-Design
e1a6fc19cb874b89b89936678e649613c24b495d
40fd3a643696f549bdedc872a5ca788610deaf0c
refs/heads/master
2020-04-02T05:34:32.927000
2018-11-12T04:23:04
2018-11-12T04:23:04
154,089,251
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package hw5; /** * @author luntzel * * A class for nodes, which are vertices in a graph. * * Specification fields: * @specfield value: String //the value of the node * * Abstract Invariant: * Non-null fields only in the node * */ public class Node<E extends Comparable<E>> implements Comparable<Node<E>> { private final E value; /** * Abstraction Function: AF(this) = a node with node.value = value * * Rep invariant: value != null */ /** * * @param value the value of the node * @modifies this * @effects Sets the node's value */ public Node(E value) { this.value = value; checkRep(); } /** * * @return the node's value */ public E getValue() { checkRep(); return value; } /** * @returns hashCode for a node as determined by value */ public int hashCode() { return value.hashCode(); } /** * @param Object * (overrides) to compare * @returns false if this node and o are unequal, and true otherwise */ public boolean equals(Object o) { if (o instanceof Node<?>) { return ((Node<?>) o).getValue().equals(this.getValue()); } return false; } @Override public int compareTo(Node<E> o) { return this.getValue().compareTo(o.getValue()); } /** * @effects determines if the node rep invariant is upheld */ private void checkRep() { assert value != null : "value must be non-null."; } }
UTF-8
Java
1,398
java
Node.java
Java
[ { "context": "package hw5;\n\n\n/**\n * @author luntzel\n *\n * A class for nodes, which are vertices in a ", "end": 37, "score": 0.9977827072143555, "start": 30, "tag": "USERNAME", "value": "luntzel" } ]
null
[]
package hw5; /** * @author luntzel * * A class for nodes, which are vertices in a graph. * * Specification fields: * @specfield value: String //the value of the node * * Abstract Invariant: * Non-null fields only in the node * */ public class Node<E extends Comparable<E>> implements Comparable<Node<E>> { private final E value; /** * Abstraction Function: AF(this) = a node with node.value = value * * Rep invariant: value != null */ /** * * @param value the value of the node * @modifies this * @effects Sets the node's value */ public Node(E value) { this.value = value; checkRep(); } /** * * @return the node's value */ public E getValue() { checkRep(); return value; } /** * @returns hashCode for a node as determined by value */ public int hashCode() { return value.hashCode(); } /** * @param Object * (overrides) to compare * @returns false if this node and o are unequal, and true otherwise */ public boolean equals(Object o) { if (o instanceof Node<?>) { return ((Node<?>) o).getValue().equals(this.getValue()); } return false; } @Override public int compareTo(Node<E> o) { return this.getValue().compareTo(o.getValue()); } /** * @effects determines if the node rep invariant is upheld */ private void checkRep() { assert value != null : "value must be non-null."; } }
1,398
0.626609
0.625894
75
17.639999
19.748175
75
false
false
0
0
0
0
0
0
1.013333
false
false
2
d91b492435e043f553627b9ed04a552d242f4ff5
21,698,174,823,463
63a9286881ea30d8d91ba3c90cfbaef0abc6ef3d
/src/test/java/fooddiary/logic/commands/AddCommandIntegrationTest.java
1f5538260270182bb48df13426cb819ae6a6e8b6
[ "MIT" ]
permissive
AY2021S2-CS2103-T14-2/tp
https://github.com/AY2021S2-CS2103-T14-2/tp
216206609981858ea2a867fcb93a1fc063594866
1c50b50b67fb9ff34d74e50c7730f8e5bfc83afc
refs/heads/master
2023-04-04T00:34:49.928000
2021-04-12T12:12:11
2021-04-12T12:12:11
336,695,890
0
5
NOASSERTION
true
2021-04-12T12:12:11
2021-02-07T03:55:53
2021-04-12T11:58:05
2021-04-12T12:12:11
47,474
0
5
0
Java
false
false
package fooddiary.logic.commands; import static fooddiary.logic.commands.CommandTestUtil.assertCommandSuccess; import static fooddiary.testutil.TypicalEntries.getTypicalFoodDiaryWithMultipleEntries; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import fooddiary.model.Model; import fooddiary.model.ModelManager; import fooddiary.model.UserPrefs; import fooddiary.model.entry.Entry; import fooddiary.testutil.EntryBuilder; /** * Contains integration tests (interaction with the Model) for {@code AddCommand}. */ public class AddCommandIntegrationTest { private Model model; @BeforeEach public void setUp() { model = new ModelManager(getTypicalFoodDiaryWithMultipleEntries(), new UserPrefs()); } @Test public void execute_newEntry_success() { Entry validEntry = new EntryBuilder().build(); Model expectedModel = new ModelManager(model.getFoodDiary(), new UserPrefs()); expectedModel.addEntry(validEntry); assertCommandSuccess(new AddCommand(validEntry), model, String.format(AddCommand.MESSAGE_SUCCESS, validEntry), expectedModel); } @Test public void execute_duplicateEntry_throwsCommandException() { Entry entryInList = model.getFoodDiary().getEntryList().get(0); CommandTestUtil.assertCommandFailure(new AddCommand(entryInList), model, AddCommand.MESSAGE_DUPLICATE_ENTRY); } }
UTF-8
Java
1,433
java
AddCommandIntegrationTest.java
Java
[]
null
[]
package fooddiary.logic.commands; import static fooddiary.logic.commands.CommandTestUtil.assertCommandSuccess; import static fooddiary.testutil.TypicalEntries.getTypicalFoodDiaryWithMultipleEntries; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import fooddiary.model.Model; import fooddiary.model.ModelManager; import fooddiary.model.UserPrefs; import fooddiary.model.entry.Entry; import fooddiary.testutil.EntryBuilder; /** * Contains integration tests (interaction with the Model) for {@code AddCommand}. */ public class AddCommandIntegrationTest { private Model model; @BeforeEach public void setUp() { model = new ModelManager(getTypicalFoodDiaryWithMultipleEntries(), new UserPrefs()); } @Test public void execute_newEntry_success() { Entry validEntry = new EntryBuilder().build(); Model expectedModel = new ModelManager(model.getFoodDiary(), new UserPrefs()); expectedModel.addEntry(validEntry); assertCommandSuccess(new AddCommand(validEntry), model, String.format(AddCommand.MESSAGE_SUCCESS, validEntry), expectedModel); } @Test public void execute_duplicateEntry_throwsCommandException() { Entry entryInList = model.getFoodDiary().getEntryList().get(0); CommandTestUtil.assertCommandFailure(new AddCommand(entryInList), model, AddCommand.MESSAGE_DUPLICATE_ENTRY); } }
1,433
0.750872
0.750174
44
31.568182
32.403984
117
false
false
0
0
0
0
0
0
0.590909
false
false
2
d5a4024701a878209e3f0f9bf4d0cc7ef04f1907
14,113,262,594,459
4f7522878886d0492506eaf8a6f77f691591059b
/src/main/java/com/api/springboot/repository/CompraRepository.java
6a5dd030b851e66028226c12dfd7c35d4ca25bec
[]
no_license
LucasAlves011/springbootXD
https://github.com/LucasAlves011/springbootXD
35187b77dd06ec6dc2600b2ba0b4658b227238f3
32b1b9198add647f33dfc681737bc89515c64560
refs/heads/master
2022-12-30T00:06:09.763000
2020-10-16T16:53:35
2020-10-16T16:53:35
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.api.springboot.repository; import com.api.springboot.model.Compra; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface CompraRepository extends JpaRepository<Compra, Long> { Compra findById(long id); void deleteById(long id); }
UTF-8
Java
341
java
CompraRepository.java
Java
[]
null
[]
package com.api.springboot.repository; import com.api.springboot.model.Compra; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface CompraRepository extends JpaRepository<Compra, Long> { Compra findById(long id); void deleteById(long id); }
341
0.806452
0.806452
13
25.23077
24.268225
71
false
false
0
0
0
0
0
0
0.538462
false
false
2
23aea54b51bb92983c5de9fc9ca9d331a6214415
30,434,138,326,921
0365a01e4f365b6d1dc93ea9ef289d354408360c
/wushiwan-server/src/main/java/com/leemon/wushiwan/entity/CoreImg.java
274c7ad02b67eded46bc78b4ac3fd2d39a6af302
[ "BSD-2-Clause" ]
permissive
wangsong1299/bungke
https://github.com/wangsong1299/bungke
4b94411876fb8516e35edcb9248ee45c93e8da13
5f7021e78e465e644b003ef4fb5ca984fbb6fbcd
refs/heads/master
2023-01-31T02:38:28.259000
2020-10-21T02:53:39
2020-10-21T02:53:39
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.leemon.wushiwan.entity; import com.leemon.wushiwan.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * * </p> * * @author leemon * @since 2019-04-02 */ @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CoreImg extends BaseEntity { private static final long serialVersionUID = 1L; /** * 具体的ID,比如发布任务是core_mission_detail,提交任务是core_mission_accept的id,意见反馈是sys_advice的id */ @TableField("data_id") private Integer dataId; /** * 任务发布者的ID,或者任务接取者的ID */ @TableField("user_id") private Integer userId; /** * 图片的本地路径 */ @TableField("path") private String path; /** * 此字段主要是为了区分同一个id却有多个需要区分的图片,比如创建任务,需要上传审核图片和操作图片 */ @TableField("type") private Integer type; }
UTF-8
Java
1,091
java
CoreImg.java
Java
[ { "context": "ssors;\r\n\r\n/**\r\n * <p>\r\n *\r\n * </p>\r\n *\r\n * @author leemon\r\n * @since 2019-04-02\r\n */\r\n@Data\r\n@EqualsAndHash", "end": 285, "score": 0.9995343685150146, "start": 279, "tag": "USERNAME", "value": "leemon" } ]
null
[]
package com.leemon.wushiwan.entity; import com.leemon.wushiwan.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * * </p> * * @author leemon * @since 2019-04-02 */ @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class CoreImg extends BaseEntity { private static final long serialVersionUID = 1L; /** * 具体的ID,比如发布任务是core_mission_detail,提交任务是core_mission_accept的id,意见反馈是sys_advice的id */ @TableField("data_id") private Integer dataId; /** * 任务发布者的ID,或者任务接取者的ID */ @TableField("user_id") private Integer userId; /** * 图片的本地路径 */ @TableField("path") private String path; /** * 此字段主要是为了区分同一个id却有多个需要区分的图片,比如创建任务,需要上传审核图片和操作图片 */ @TableField("type") private Integer type; }
1,091
0.684556
0.674699
49
16.632652
18.265272
83
false
false
0
0
0
0
0
0
0.714286
false
false
2
e71b0d7ca36a1bb5bbed068cedb2f800a6ebdf1a
16,320,875,764,557
f4852cd346e1a9161b3ee85a1e17291970c3c86a
/src/test/java/com/aaron/spring/test1.java
85695635d849ef19706f498b7d9c8a648ffc16fd
[]
no_license
All-conquring/Spring
https://github.com/All-conquring/Spring
80d76f360608b5475121e137f69e87ab44074758
6b384fefacb339b9fddb07aa0178bd395cbe310a
refs/heads/master
2020-03-26T07:55:50.416000
2018-08-14T06:49:33
2018-08-14T06:49:33
144,678,078
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.aaron.spring; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.aaron.entity.Computer; import com.aaron.entity.Printer; import com.aaron.entity.User; import junit.framework.TestCase; public class test1 extends TestCase{ public void testIoc(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); User user = (User)context.getBean("timo"); user.sayHello(); } public void testPrinter(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Printer printer = (Printer)context.getBean("hp"); printer.print(); } public void testComputer(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Computer com = (Computer)context.getBean("computer"); com.assmbly(); } }
UTF-8
Java
947
java
test1.java
Java
[ { "context": "text.xml\");\r\n\t\tUser user = (User)context.getBean(\"timo\");\r\n\t\tuser.sayHello();\r\n\t}\r\n\t\r\n\tpublic void testP", "end": 504, "score": 0.9983147382736206, "start": 500, "tag": "USERNAME", "value": "timo" } ]
null
[]
package com.aaron.spring; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.aaron.entity.Computer; import com.aaron.entity.Printer; import com.aaron.entity.User; import junit.framework.TestCase; public class test1 extends TestCase{ public void testIoc(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); User user = (User)context.getBean("timo"); user.sayHello(); } public void testPrinter(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Printer printer = (Printer)context.getBean("hp"); printer.print(); } public void testComputer(){ ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); Computer com = (Computer)context.getBean("computer"); com.assmbly(); } }
947
0.755016
0.75396
33
26.69697
28.437582
92
false
false
0
0
0
0
0
0
1.30303
false
false
2
180d6f6dab7707bdc31b2686731a1a7e65379355
26,774,826,130,531
ceb1bc7cf71a5981f8a9c0c07539a99a1df39678
/aula19-20-exercicio/app/src/main/java/pt/isel/poo/firstapp/view/CircleView.java
a855c8ff8eb2d3ef2bb8c01eb4237dce3e015768
[]
no_license
jsimaoisel/isel-leic-poo-1516ver
https://github.com/jsimaoisel/isel-leic-poo-1516ver
71ec1712d919eea17d2dd15f181b3f741fbc6641
7ef949e1ca8340e7bde6531c746a3b37ab8563db
refs/heads/master
2021-01-21T04:47:20.821000
2016-06-08T08:56:43
2016-06-08T08:56:43
53,486,406
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package pt.isel.poo.firstapp.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.MotionEvent; import android.view.View; public class CircleView extends View { private int radius; private Paint paint; public CircleView(Context context, int radius) { super(context); paint = new Paint(); this.radius = radius; } public void setRadius(int r) { radius = r; invalidate(); } public boolean onTouchEvent(MotionEvent ev) { int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: System.out.print("Down @"); break; case MotionEvent.ACTION_UP: System.out.print("Up @ "); break; case MotionEvent.ACTION_MOVE: System.out.print("Move @ "); break; } System.out.println(" x=" + ev.getX() + " y=" + ev.getY()); return true; } public void onDraw(Canvas c) { int cx = c.getWidth() / 2; int cy = c.getHeight() / 2; paint.setColor(Color.DKGRAY); paint.setStyle(Paint.Style.FILL); c.drawCircle(cx, cy, radius, paint); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); paint.setStrokeWidth(20); c.drawRect(1,1,getWidth()-1,getHeight()-1,paint); } }
UTF-8
Java
1,524
java
CircleView.java
Java
[]
null
[]
package pt.isel.poo.firstapp.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.MotionEvent; import android.view.View; public class CircleView extends View { private int radius; private Paint paint; public CircleView(Context context, int radius) { super(context); paint = new Paint(); this.radius = radius; } public void setRadius(int r) { radius = r; invalidate(); } public boolean onTouchEvent(MotionEvent ev) { int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: System.out.print("Down @"); break; case MotionEvent.ACTION_UP: System.out.print("Up @ "); break; case MotionEvent.ACTION_MOVE: System.out.print("Move @ "); break; } System.out.println(" x=" + ev.getX() + " y=" + ev.getY()); return true; } public void onDraw(Canvas c) { int cx = c.getWidth() / 2; int cy = c.getHeight() / 2; paint.setColor(Color.DKGRAY); paint.setStyle(Paint.Style.FILL); c.drawCircle(cx, cy, radius, paint); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.RED); paint.setStrokeWidth(20); c.drawRect(1,1,getWidth()-1,getHeight()-1,paint); } }
1,524
0.561024
0.555774
56
26.214285
15.344513
57
false
false
0
0
0
0
0
0
0.714286
false
false
2
2dd8f5247e68e2346d7299b97894b71815f7f59e
15,221,364,107,954
46ff11e1140614a87a6a3ae14a590a1929d8acf4
/src/main/java/com/cts/CreditScoreModule/Entity/ResponseMessage.java
3d2d775b29b27ead326a6d821d7b74391d8306aa
[]
no_license
guruteja99/retail-creditscore
https://github.com/guruteja99/retail-creditscore
cd25d5fa61d8d04cd4eacf80c585b0c00f4a18b1
3c39b96c46af16aad36dc34953057a39c52da57a
refs/heads/master
2023-04-03T22:08:31.303000
2021-03-30T15:52:30
2021-03-30T15:52:30
328,614,362
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.cts.CreditScoreModule.Entity; import java.util.List; import lombok.Data; @Data public class ResponseMessage { private int status; private String[] months; private Integer[] scores; }
UTF-8
Java
202
java
ResponseMessage.java
Java
[]
null
[]
package com.cts.CreditScoreModule.Entity; import java.util.List; import lombok.Data; @Data public class ResponseMessage { private int status; private String[] months; private Integer[] scores; }
202
0.767327
0.767327
13
14.538462
13.602123
41
false
false
0
0
0
0
0
0
0.692308
false
false
2
99157faaeddde590d366c86a9a786aa20d067a71
23,613,730,223,954
d416a359e040c41aa2b830d6560fcc737334de5d
/app/src/main/java/com/example/hppc/dealofday/Activity/CategoryActivity.java
b3cd066f520450259351f367c66a21b1746b8a87
[]
no_license
amitkpandey/DealOfDay
https://github.com/amitkpandey/DealOfDay
4c403b24fd6134f3d751d1f9440a033d3ec65c46
ef35de7bf337d3cf4da7e0ad98a25815de27188d
refs/heads/master
2020-03-16T21:10:32.801000
2017-05-25T05:47:34
2017-05-25T05:47:34
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.hppc.dealofday.Activity; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.View; import android.widget.ExpandableListView; import android.widget.ImageView; import android.widget.Toast; import com.example.hppc.dealofday.Adapters.ExpandableListAdapter; import com.example.hppc.dealofday.R; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class CategoryActivity extends AppCompatActivity { List<String> groupList; List<String> childList; Map<String, List<String>> laptopCollection; ExpandableListView expListView; ImageView backButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_category); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_activities_category); if (toolbar != null) setSupportActionBar(toolbar); getSupportActionBar().setTitle(null); createGroupList(); createCollection(); expListView = (ExpandableListView) findViewById(R.id.category_list); backButton = (ImageView) findViewById(R.id.back_button); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); final ExpandableListAdapter expListAdapter = new ExpandableListAdapter( this, groupList, laptopCollection); expListView.setAdapter(expListAdapter); expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { final String selected = (String) expListAdapter.getChild( groupPosition, childPosition); if(groupPosition == 0 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonMobile"); startActivity(intent); } else if(groupPosition == 0 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartMobile"); startActivity(intent); } else if(groupPosition == 0 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealMobile"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonLaptops"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartLaptops"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealLaptops"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonWatches"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartWatches"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealWatches"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonBooks"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartBooks"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealBooks"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonWM"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartWM"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealWM"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonFashion"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartFashion"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealFashion"); startActivity(intent); } return true; } }); } private void createGroupList() { groupList = new ArrayList<String>(); groupList.add("Mobile Phones"); groupList.add("Laptops"); groupList.add("Watches"); groupList.add("Books"); groupList.add("Washing Mechine"); groupList.add("Fashion"); } private void createCollection() { // preparing laptops collection(child) String[] mobileModels = {"Amazon", "flipkart", "Snapdeal"}; String[] LaptopModels = {"Amazon", "flipkart", "Snapdeal"}; String[] WatchesModels = {"Amazon", "flipkart", "Snapdeal"}; String[] BooksModels = {"Amazon", "flipkart", "Snapdeal"}; String[] WashingMechinesModel = {"Amazon", "flipkart", "Snapdeal"}; String[] FashionModels = {"Amazon", "flipkart", "Snapdeal"}; laptopCollection = new LinkedHashMap<String, List<String>>(); for (String laptop : groupList) { if (laptop.equals("Mobile Phones")) { loadChild(mobileModels); } else if (laptop.equals("Laptops")) loadChild(LaptopModels); else if (laptop.equals("Watches")) loadChild(WatchesModels); else if (laptop.equals("Books")) loadChild(BooksModels); else if (laptop.equals("Washing Mechine")) loadChild(WashingMechinesModel); else loadChild(FashionModels); laptopCollection.put(laptop, childList); } } private void loadChild(String[] laptopModels) { childList = new ArrayList<String>(); for (String model : laptopModels) childList.add(model); } private void setGroupIndicatorToRight() { /* Get the screen width */ DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; expListView.setIndicatorBounds(width - getDipsFromPixel(35), width - getDipsFromPixel(5)); } // Convert pixel to dip public int getDipsFromPixel(float pixels) { // Get the screen's density scale final float scale = getResources().getDisplayMetrics().density; // Convert the dps to pixels, based on density scale return (int) (pixels * scale + 0.5f); } }
UTF-8
Java
9,784
java
CategoryActivity.java
Java
[ { "context": ";\n intent.putExtra(\"keyName\", \"amazonMobile\");\n startActivity(intent);\n ", "end": 2332, "score": 0.997150719165802, "start": 2320, "tag": "KEY", "value": "amazonMobile" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartMobile\");\n startActivity(intent);\n ", "end": 2620, "score": 0.9203980565071106, "start": 2606, "tag": "KEY", "value": "flipkartMobile" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealMobile\");\n startActivity(intent);\n ", "end": 2908, "score": 0.9052354693412781, "start": 2894, "tag": "KEY", "value": "snapdealMobile" }, { "context": ";\n intent.putExtra(\"keyName\", \"amazonLaptops\");\n startActivity(intent);\n ", "end": 3195, "score": 0.9946274757385254, "start": 3182, "tag": "KEY", "value": "amazonLaptops" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartLaptops\");\n startActivity(intent);\n ", "end": 3484, "score": 0.9937125444412231, "start": 3469, "tag": "KEY", "value": "flipkartLaptops" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealLaptops\");\n startActivity(intent);\n ", "end": 3773, "score": 0.9923398494720459, "start": 3758, "tag": "KEY", "value": "snapdealLaptops" }, { "context": ";\n intent.putExtra(\"keyName\", \"amazonWatches\");\n startActivity(intent);\n ", "end": 4060, "score": 0.9900849461555481, "start": 4047, "tag": "KEY", "value": "amazonWatches" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartWatches\");\n startActivity(intent);\n ", "end": 4349, "score": 0.9932470321655273, "start": 4334, "tag": "KEY", "value": "flipkartWatches" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealWatches\");\n startActivity(intent);\n ", "end": 4638, "score": 0.9960271716117859, "start": 4623, "tag": "KEY", "value": "snapdealWatches" }, { "context": ";\n intent.putExtra(\"keyName\", \"amazonBooks\");\n startActivity(intent);\n ", "end": 4923, "score": 0.9907351732254028, "start": 4912, "tag": "KEY", "value": "amazonBooks" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartBooks\");\n startActivity(intent);\n ", "end": 5210, "score": 0.9965211153030396, "start": 5197, "tag": "KEY", "value": "flipkartBooks" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealBooks\");\n startActivity(intent);\n ", "end": 5497, "score": 0.9846882224082947, "start": 5484, "tag": "KEY", "value": "snapdealBooks" }, { "context": ";\n intent.putExtra(\"keyName\", \"amazonWM\");\n startActivity(intent);\n ", "end": 5779, "score": 0.9876385927200317, "start": 5771, "tag": "KEY", "value": "amazonWM" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartWM\");\n startActivity(intent);\n ", "end": 6063, "score": 0.9954560399055481, "start": 6053, "tag": "KEY", "value": "flipkartWM" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealWM\");\n startActivity(intent);\n ", "end": 6347, "score": 0.9905128479003906, "start": 6337, "tag": "KEY", "value": "snapdealWM" }, { "context": ";\n intent.putExtra(\"keyName\", \"amazonFashion\");\n startActivity(intent);\n ", "end": 6634, "score": 0.9806051254272461, "start": 6621, "tag": "KEY", "value": "amazonFashion" }, { "context": ";\n intent.putExtra(\"keyName\", \"flipkartFashion\");\n startActivity(intent);\n ", "end": 6923, "score": 0.9923337697982788, "start": 6908, "tag": "KEY", "value": "flipkartFashion" }, { "context": ";\n intent.putExtra(\"keyName\", \"snapdealFashion\");\n startActivity(intent);\n ", "end": 7212, "score": 0.9949127435684204, "start": 7197, "tag": "KEY", "value": "snapdealFashion" } ]
null
[]
package com.example.hppc.dealofday.Activity; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.util.DisplayMetrics; import android.view.View; import android.widget.ExpandableListView; import android.widget.ImageView; import android.widget.Toast; import com.example.hppc.dealofday.Adapters.ExpandableListAdapter; import com.example.hppc.dealofday.R; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class CategoryActivity extends AppCompatActivity { List<String> groupList; List<String> childList; Map<String, List<String>> laptopCollection; ExpandableListView expListView; ImageView backButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_category); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_activities_category); if (toolbar != null) setSupportActionBar(toolbar); getSupportActionBar().setTitle(null); createGroupList(); createCollection(); expListView = (ExpandableListView) findViewById(R.id.category_list); backButton = (ImageView) findViewById(R.id.back_button); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); final ExpandableListAdapter expListAdapter = new ExpandableListAdapter( this, groupList, laptopCollection); expListView.setAdapter(expListAdapter); expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { final String selected = (String) expListAdapter.getChild( groupPosition, childPosition); if(groupPosition == 0 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonMobile"); startActivity(intent); } else if(groupPosition == 0 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartMobile"); startActivity(intent); } else if(groupPosition == 0 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealMobile"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonLaptops"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartLaptops"); startActivity(intent); } else if(groupPosition == 1 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealLaptops"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonWatches"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartWatches"); startActivity(intent); } else if(groupPosition == 2 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealWatches"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonBooks"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartBooks"); startActivity(intent); } else if(groupPosition == 3 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealBooks"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonWM"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartWM"); startActivity(intent); } else if(groupPosition == 4 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealWM"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 0){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "amazonFashion"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 1){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "flipkartFashion"); startActivity(intent); } else if(groupPosition == 5 && childPosition == 2){ Intent intent = new Intent(CategoryActivity.this, WebViewActivity.class); intent.putExtra("keyName", "snapdealFashion"); startActivity(intent); } return true; } }); } private void createGroupList() { groupList = new ArrayList<String>(); groupList.add("Mobile Phones"); groupList.add("Laptops"); groupList.add("Watches"); groupList.add("Books"); groupList.add("Washing Mechine"); groupList.add("Fashion"); } private void createCollection() { // preparing laptops collection(child) String[] mobileModels = {"Amazon", "flipkart", "Snapdeal"}; String[] LaptopModels = {"Amazon", "flipkart", "Snapdeal"}; String[] WatchesModels = {"Amazon", "flipkart", "Snapdeal"}; String[] BooksModels = {"Amazon", "flipkart", "Snapdeal"}; String[] WashingMechinesModel = {"Amazon", "flipkart", "Snapdeal"}; String[] FashionModels = {"Amazon", "flipkart", "Snapdeal"}; laptopCollection = new LinkedHashMap<String, List<String>>(); for (String laptop : groupList) { if (laptop.equals("Mobile Phones")) { loadChild(mobileModels); } else if (laptop.equals("Laptops")) loadChild(LaptopModels); else if (laptop.equals("Watches")) loadChild(WatchesModels); else if (laptop.equals("Books")) loadChild(BooksModels); else if (laptop.equals("Washing Mechine")) loadChild(WashingMechinesModel); else loadChild(FashionModels); laptopCollection.put(laptop, childList); } } private void loadChild(String[] laptopModels) { childList = new ArrayList<String>(); for (String model : laptopModels) childList.add(model); } private void setGroupIndicatorToRight() { /* Get the screen width */ DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; expListView.setIndicatorBounds(width - getDipsFromPixel(35), width - getDipsFromPixel(5)); } // Convert pixel to dip public int getDipsFromPixel(float pixels) { // Get the screen's density scale final float scale = getResources().getDisplayMetrics().density; // Convert the dps to pixels, based on density scale return (int) (pixels * scale + 0.5f); } }
9,784
0.566231
0.561836
226
42.296459
26.489365
93
false
false
0
0
0
0
0
0
0.79646
false
false
2
f515da684fde0be82f532228f0e50d1cbdd7b97f
13,950,053,801,040
e806e6ab8edf0e8df9091252eee6864d5a1d1b4a
/src/com/class12/StartsWith.java
b5bd53d3416687a827d5cc3253b4ac554882b324
[]
no_license
farrukh21/Java-Classes
https://github.com/farrukh21/Java-Classes
1ea382ea7173b63169d5e5fb206c59f59b4b3069
c45495d105fbe7bee0e10dd0612523725affaae1
refs/heads/master
2022-03-24T06:47:40.694000
2019-12-24T21:24:38
2019-12-24T21:24:38
219,891,311
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.class12; public class StartsWith { public static void main(String[] args) { /* * This method tests if a string starts with the * specified prefix beginning */ String str2="It is very hot in th class"; System.out.println(""); /* * this method checks whether a string is empty or not. * This method returns true if the given string * is empty, else it returns false. */ String str=""; System.out.println("Is this string empty= "+ str.isEmpty()); String st1="hello"; System.out.println("Is this string empty= "+st1.isEmpty()); if(!str.isEmpty()) { System.out.println("This is not empty"); }else { System.out.println("This is empty"); } String sentece="each day is a promise to brighten up th day,\nBut first you must.."; System.out.println(sentece); } }
UTF-8
Java
813
java
StartsWith.java
Java
[]
null
[]
package com.class12; public class StartsWith { public static void main(String[] args) { /* * This method tests if a string starts with the * specified prefix beginning */ String str2="It is very hot in th class"; System.out.println(""); /* * this method checks whether a string is empty or not. * This method returns true if the given string * is empty, else it returns false. */ String str=""; System.out.println("Is this string empty= "+ str.isEmpty()); String st1="hello"; System.out.println("Is this string empty= "+st1.isEmpty()); if(!str.isEmpty()) { System.out.println("This is not empty"); }else { System.out.println("This is empty"); } String sentece="each day is a promise to brighten up th day,\nBut first you must.."; System.out.println(sentece); } }
813
0.672817
0.666667
33
23.636364
22.597691
85
false
false
0
0
0
0
0
0
1.484848
false
false
2
6f3feba3562b88432c8acc50d7328773a3d17c2a
24,300,924,960,785
b3c6bd6d049afe175e793499735036daa440422f
/http/src/main/java/com/perosa/BotTrafficApp.java
764ffd399afb6bf20e88e36c682a9159f1edafbe
[ "Apache-2.0" ]
permissive
perosa/BotTraffic
https://github.com/perosa/BotTraffic
19a68e3e4b585ea3ba01f9e5de1e3cb39423205f
8fcb832e7f96887c9f4ac7fa4066f175cade7db4
refs/heads/main
2022-01-30T21:39:40.910000
2022-01-27T09:26:25
2022-01-27T09:26:25
202,415,382
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.perosa; import com.perosa.bot.traffic.core.service.registry.watch.ServiceRegistryWatcher; import com.perosa.bot.traffic.http.metrics.prometheus.MetricsHandler; import com.perosa.bot.traffic.http.server.dispatch.Dispatcher; import com.perosa.bot.traffic.http.server.ReverseProxy; import io.prometheus.client.hotspot.DefaultExports; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * */ public class BotTrafficApp { private static final Logger LOGGER = LoggerFactory.getLogger(BotTrafficApp.class); public static void main(String[] args) { DefaultExports.initialize(); new ReverseProxy(new Dispatcher()).setUp(); new MetricsHandler().setUp(); ServiceRegistryWatcher.init(); Runtime.getRuntime().addShutdownHook(new TerminationManager()); LOGGER.info("BotTraffic is up!"); LOGGER.trace("->" + System.getenv()); } } class TerminationManager extends Thread { private static final Logger LOGGER = LoggerFactory.getLogger(TerminationManager.class); public void run() { LOGGER.info("Come back soon!"); } }
UTF-8
Java
1,127
java
BotTrafficApp.java
Java
[]
null
[]
package com.perosa; import com.perosa.bot.traffic.core.service.registry.watch.ServiceRegistryWatcher; import com.perosa.bot.traffic.http.metrics.prometheus.MetricsHandler; import com.perosa.bot.traffic.http.server.dispatch.Dispatcher; import com.perosa.bot.traffic.http.server.ReverseProxy; import io.prometheus.client.hotspot.DefaultExports; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * */ public class BotTrafficApp { private static final Logger LOGGER = LoggerFactory.getLogger(BotTrafficApp.class); public static void main(String[] args) { DefaultExports.initialize(); new ReverseProxy(new Dispatcher()).setUp(); new MetricsHandler().setUp(); ServiceRegistryWatcher.init(); Runtime.getRuntime().addShutdownHook(new TerminationManager()); LOGGER.info("BotTraffic is up!"); LOGGER.trace("->" + System.getenv()); } } class TerminationManager extends Thread { private static final Logger LOGGER = LoggerFactory.getLogger(TerminationManager.class); public void run() { LOGGER.info("Come back soon!"); } }
1,127
0.722272
0.720497
43
25.186047
27.73316
91
false
false
0
0
0
0
0
0
0.418605
false
false
2
8847f481ddc2cb27e6de16e991635f1ab83bddef
29,832,842,866,845
deeb45167a21f040f908cdfed6e13001148a84e9
/MPD/app/src/main/java/com/fred/n0568843/mpd/Deadline.java
eda6ea722f1da847951c7768d5674f4bc44c27a0
[]
no_license
FredP1/MPD
https://github.com/FredP1/MPD
00a900b5d84536ac933372780acb074be2ced5e9
645f71cab7372e5074abc462a31c9250a1efacb6
refs/heads/master
2021-03-30T15:36:10.890000
2018-03-22T18:09:55
2018-03-22T18:09:55
123,914,493
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.fred.n0568843.mpd; /** * Created by N0568843 on 19/03/2018. */ public class Deadline { String deadlineName; String module; String deadlineDate; String deadlineTime; public Deadline(){ } public Deadline(String DeadlineName, String Module, String DeadlineDate, String DeadlineTime) { deadlineName = DeadlineName; module = Module; deadlineDate = DeadlineDate; deadlineTime = DeadlineTime; } }
UTF-8
Java
477
java
Deadline.java
Java
[ { "context": "package com.fred.n0568843.mpd;\n\n/**\n * Created by N0568843 on 19/03/2018.\n */\n\npublic class Deadline {\n S", "end": 58, "score": 0.9989781379699707, "start": 50, "tag": "USERNAME", "value": "N0568843" } ]
null
[]
package com.fred.n0568843.mpd; /** * Created by N0568843 on 19/03/2018. */ public class Deadline { String deadlineName; String module; String deadlineDate; String deadlineTime; public Deadline(){ } public Deadline(String DeadlineName, String Module, String DeadlineDate, String DeadlineTime) { deadlineName = DeadlineName; module = Module; deadlineDate = DeadlineDate; deadlineTime = DeadlineTime; } }
477
0.660377
0.614256
24
18.875
21.164658
97
false
false
0
0
0
0
0
0
0.5
false
false
2
889cc7ded56fa895094e53bcfa43bb3899e520c7
26,121,991,106,403
cd296ecf457b1af52dc615e83cfdb5c5918666fb
/Vital Statistics sifter/Statistics Sifter/src/sift/read/JSONReader.java
deabf547f03bce91234814bec09ac2b782201665
[]
no_license
jonnyowenpowell-zz/probable-octo-palm-tree
https://github.com/jonnyowenpowell-zz/probable-octo-palm-tree
35858ebd756b68c726f443d2c2b8e5c9fc10b1c4
5ec84ba1200c7f57e2b51bda37b06b8503aa7822
refs/heads/master
2021-09-09T03:57:58.794000
2018-03-13T17:01:06
2018-03-13T17:01:06
108,151,423
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package sift.read; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public abstract class JSONReader { /** * The original data source to be read */ protected JSONObject jsonObj = null; /** * ctor * @param fileName * @throws FileNotFoundException * @throws IOException * @throws ParseException */ public JSONReader(String fileName) throws FileNotFoundException, IOException, ParseException { JSONParser parser = new JSONParser(); Object obj = parser.parse(new FileReader(fileName)); this.jsonObj = (JSONObject) obj; } }
UTF-8
Java
721
java
JSONReader.java
Java
[]
null
[]
package sift.read; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public abstract class JSONReader { /** * The original data source to be read */ protected JSONObject jsonObj = null; /** * ctor * @param fileName * @throws FileNotFoundException * @throws IOException * @throws ParseException */ public JSONReader(String fileName) throws FileNotFoundException, IOException, ParseException { JSONParser parser = new JSONParser(); Object obj = parser.parse(new FileReader(fileName)); this.jsonObj = (JSONObject) obj; } }
721
0.750347
0.750347
30
23.033333
21.379871
95
false
false
0
0
0
0
0
0
1.133333
false
false
2
16963d61f5c49b2f0132e96555190ef415d00cf5
4,715,874,153,800
73ef4954908bcc6165864e94adeeac6b01a075b3
/src/Stage4/Enemy.java
a0281346564fdea699831b2f49359b642a3d9f4a
[]
no_license
danielhr444/TempleGalaga
https://github.com/danielhr444/TempleGalaga
5290b53db109cca73efa6dc41db6007aff818151
0221a3adfbe8920fdf3c6dec6e11b1bf52fcecaf
refs/heads/master
2021-05-22T02:51:55.728000
2020-04-04T07:44:16
2020-04-04T07:44:16
252,938,759
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package Stage4; import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Graphics2D; public class Enemy { private int startX; private int startY; private int x; private int y; static int sideLength; private double a; private double divider; private double startTime; private Rectangle hitbox; private boolean isAlive; private boolean top; private boolean right; private boolean bottom; private boolean left; public Enemy(int x, int y, boolean top, boolean right, boolean left, boolean bottom) { startX = x; startY = y; sideLength = 30; a = Math.random()*5 + 1; divider = Math.random()*3 + 1.2; this.top = top; this.right = right; this.left = left; this.bottom = bottom; hitbox = new Rectangle(startX, startY, sideLength, sideLength); startTime = System.currentTimeMillis(); isAlive = true; hitbox.setBounds(new Rectangle(x, y, sideLength, sideLength)); } public void drawEnemies(Graphics g) { g.setColor(Color.green); g.fillRect(x, y, sideLength, sideLength); hitbox.setBounds(x, y, sideLength, sideLength); // Graphics2D g2d = (Graphics2D) g; // g2d.setColor(Color.MAGENTA); // g2d.draw(hitbox); } public void update() { // divider = 1; double currentTime = System.currentTimeMillis() - startTime; double t = Math.toRadians(currentTime)/ divider; double r = 20; double theta = -5.7; if (isAlive) { //2D-Helical path if (top) { x = startX + (int)(r * Math.sin(t)); y = startY - (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta)); } if (bottom) { x = startX + (int)(r * Math.sin(t)); y = startY +((int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); } if (right) { x = (startX + (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); y = (startY - (int)(r * Math.sin(t))); } if (left) { x = (startX - (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); y = (startY + (int)(r * Math.sin(t))); } if (t >= 700) { startTime = System.currentTimeMillis(); } } else { x = 1000000; y = 1000000; } } public Rectangle getHitbox() { return hitbox; } public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public int getStartX() { return startX; } public int getStartY() { return startY; } public void setY(int y) { this.y = y; } public void setLifeStatus(boolean isAlive) { this.isAlive = isAlive; } }
UTF-8
Java
2,999
java
Enemy.java
Java
[]
null
[]
package Stage4; import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Graphics2D; public class Enemy { private int startX; private int startY; private int x; private int y; static int sideLength; private double a; private double divider; private double startTime; private Rectangle hitbox; private boolean isAlive; private boolean top; private boolean right; private boolean bottom; private boolean left; public Enemy(int x, int y, boolean top, boolean right, boolean left, boolean bottom) { startX = x; startY = y; sideLength = 30; a = Math.random()*5 + 1; divider = Math.random()*3 + 1.2; this.top = top; this.right = right; this.left = left; this.bottom = bottom; hitbox = new Rectangle(startX, startY, sideLength, sideLength); startTime = System.currentTimeMillis(); isAlive = true; hitbox.setBounds(new Rectangle(x, y, sideLength, sideLength)); } public void drawEnemies(Graphics g) { g.setColor(Color.green); g.fillRect(x, y, sideLength, sideLength); hitbox.setBounds(x, y, sideLength, sideLength); // Graphics2D g2d = (Graphics2D) g; // g2d.setColor(Color.MAGENTA); // g2d.draw(hitbox); } public void update() { // divider = 1; double currentTime = System.currentTimeMillis() - startTime; double t = Math.toRadians(currentTime)/ divider; double r = 20; double theta = -5.7; if (isAlive) { //2D-Helical path if (top) { x = startX + (int)(r * Math.sin(t)); y = startY - (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta)); } if (bottom) { x = startX + (int)(r * Math.sin(t)); y = startY +((int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); } if (right) { x = (startX + (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); y = (startY - (int)(r * Math.sin(t))); } if (left) { x = (startX - (int)(r * Math.cos(t) * Math.cos(theta) - a * t * Math.sin(theta))); y = (startY + (int)(r * Math.sin(t))); } if (t >= 700) { startTime = System.currentTimeMillis(); } } else { x = 1000000; y = 1000000; } } public Rectangle getHitbox() { return hitbox; } public int getX() { return x; } public int getY() { return y; } public void setX(int x) { this.x = x; } public int getStartX() { return startX; } public int getStartY() { return startY; } public void setY(int y) { this.y = y; } public void setLifeStatus(boolean isAlive) { this.isAlive = isAlive; } }
2,999
0.52951
0.517172
102
28.411764
20.870916
95
false
false
0
0
0
0
0
0
0.970588
false
false
2
65b6ecb915286a6aa80b1f566bd5537d9f697c10
6,322,191,875,374
d76aefd5759c1fe248d6999613866670701b0806
/src/main/java/com/ig/controllers/UsuarioLoginController.java
be3a893e6d3297708b914cdf31c52d31da1afc49
[]
no_license
zulu15/IGWeb
https://github.com/zulu15/IGWeb
4969300c40031856b30595b2905ec82e0c4d9e1f
3b52c7c5a34142157c0b864a6404970bb8c4e1e8
refs/heads/master
2021-01-10T01:50:33.626000
2015-11-30T15:15:54
2015-11-30T15:15:54
46,457,927
2
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.ig.controllers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.ig.modelo.Socio; import com.ig.services.SocioService; @Controller @RequestMapping("/usuario") public class UsuarioLoginController { @Autowired private SocioService socioService; @RequestMapping(method = RequestMethod.GET) public String iniciar(ModelMap modelo) { modelo.put("loginForm", new Socio()); return "/usuario/login"; } @RequestMapping(method = RequestMethod.POST) public String validarLoginUsuario(ModelMap modelo, @ModelAttribute("loginForm") Socio socio) { if (isDatosCompletos(socio) && socioService.isSocioRegistrado(socio)) { socio = socioService.obtenerSocio(socio); System.out.println(socio); modelo.put("socioForm", socio); return "index"; } modelo.addAttribute("loginFallido", "Usuario o contraseña incorrectos!!"); return "/usuario/login"; } private boolean isDatosCompletos(Socio socio) { return (socio.getEmail() != null && !socio.getEmail().isEmpty() && socio.getPassword() != null && !socio.getPassword().isEmpty()); } }
UTF-8
Java
1,413
java
UsuarioLoginController.java
Java
[]
null
[]
package com.ig.controllers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.ig.modelo.Socio; import com.ig.services.SocioService; @Controller @RequestMapping("/usuario") public class UsuarioLoginController { @Autowired private SocioService socioService; @RequestMapping(method = RequestMethod.GET) public String iniciar(ModelMap modelo) { modelo.put("loginForm", new Socio()); return "/usuario/login"; } @RequestMapping(method = RequestMethod.POST) public String validarLoginUsuario(ModelMap modelo, @ModelAttribute("loginForm") Socio socio) { if (isDatosCompletos(socio) && socioService.isSocioRegistrado(socio)) { socio = socioService.obtenerSocio(socio); System.out.println(socio); modelo.put("socioForm", socio); return "index"; } modelo.addAttribute("loginFallido", "Usuario o contraseña incorrectos!!"); return "/usuario/login"; } private boolean isDatosCompletos(Socio socio) { return (socio.getEmail() != null && !socio.getEmail().isEmpty() && socio.getPassword() != null && !socio.getPassword().isEmpty()); } }
1,413
0.746459
0.746459
43
30.83721
29.434935
132
false
false
0
0
0
0
0
0
1.372093
false
false
2
bc99b60b6444751bc02488272609daf981d095d4
146,028,910,660
70bafb86375ef42abf1636d75689ff17ba74dd28
/movieDataBaseFirstMethod/src/main/java/util/DatabaseUtilsHomeWorkMovies.java
3c286a4ab2ff2750b54c3767203251928f7914ed
[]
no_license
Brandioo/MovieDataBase
https://github.com/Brandioo/MovieDataBase
de3a07dd145cf995819cd1739c5823d31ee51530
676e7e2ae83adbbc9cf802b92840f3666f2b27ba
refs/heads/main
2023-02-10T02:06:56.610000
2020-12-29T21:01:32
2020-12-29T21:01:32
325,107,705
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package util; public class DatabaseUtilsHomeWorkMovies { public static String DATABASE_HOST="jdbc:mysql://localhost:3306/homeworks"; public static String DATABASE_USER="root"; public static String DATABASE_PASSWORD="bapinjo123"; }
UTF-8
Java
245
java
DatabaseUtilsHomeWorkMovies.java
Java
[ { "context": "oot\";\n public static String DATABASE_PASSWORD=\"bapinjo123\";\n}\n\n", "end": 239, "score": 0.8690276741981506, "start": 229, "tag": "PASSWORD", "value": "bapinjo123" } ]
null
[]
package util; public class DatabaseUtilsHomeWorkMovies { public static String DATABASE_HOST="jdbc:mysql://localhost:3306/homeworks"; public static String DATABASE_USER="root"; public static String DATABASE_PASSWORD="<PASSWORD>"; }
245
0.767347
0.738775
7
33.857143
27.78195
79
false
false
0
0
0
0
0
0
0.571429
false
false
2
12a5f6126ac1aa7b565d01914f204efb335face5
146,028,907,497
94ee7b3781b6a5c13874c138fc5666bb9c9c4165
/autotest-core/src/test/java/com/xjy/autotest/enums/OrientationType.java
69e45551fd8b8b609271f8b5517ccfd08627dd45
[]
no_license
bellmit/test-5
https://github.com/bellmit/test-5
d50c847566067cf2456dd3f4687307e4eabe205f
bb0445617f873cb9fa57b208244df13e16717980
refs/heads/master
2023-07-18T15:18:14.807000
2020-05-19T07:47:55
2020-05-19T07:47:55
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.xjy.autotest.enums; /** * @Author: Jax * @Date: 2018-01-2018/1/22-14:50 * @Desc: **/ public enum OrientationType { FORWARD_EAST("FORWARD_EAST","朝东"), FORWARD_WEST("FORWARD_WEST","朝西"), FORWARD_NORTH("FORWARD_NORTH","朝北"), FORWARD_SOUTH("FORWARD_SOUTH","朝南"), SOUTH_NORTH_TRANSPARENT("SOUTH_NORTH_TRANSPARENT","南北通透"), EAST_WEST("EAST_WEST","东西") ; private String code; private String message; private OrientationType(String code, String message) { this.code = code; this.message = message; } public String code() { return code; } public String message() { return message; } public static OrientationType getByCode(String code) { for (OrientationType result : values()) { if (result.code().equals(code)) { return result; } } return null; } /** * 获取全部枚举值 * * @return List<String> */ public static java.util.List<String> getAllEnumCode() { java.util.List<String> list = new java.util.ArrayList<String>(values().length); for (OrientationType _enum : values()) { list.add(_enum.code()); } return list; } /** * 获取全部枚举 * * @return List<ListType> */ public static java.util.List<OrientationType> getAllEnum() { java.util.List<OrientationType> list = new java.util.ArrayList<OrientationType>(values().length); for (OrientationType _enum : values()) { list.add(_enum); } return list; } /** * 获取全部枚举描述 * * @return List<ListType> */ public static java.util.List<String> getAllEnumMessage() { java.util.List<String> list = new java.util.ArrayList<String>(values().length); for (OrientationType _enum : values()) { list.add(_enum.message); } return list; } }
UTF-8
Java
2,041
java
OrientationType.java
Java
[ { "context": "package com.xjy.autotest.enums;\n\n/**\n * @Author: Jax\n * @Date: 2018-01-2018/1/22-14:50\n * @Desc:\n **/\n", "end": 52, "score": 0.9859942197799683, "start": 49, "tag": "USERNAME", "value": "Jax" } ]
null
[]
package com.xjy.autotest.enums; /** * @Author: Jax * @Date: 2018-01-2018/1/22-14:50 * @Desc: **/ public enum OrientationType { FORWARD_EAST("FORWARD_EAST","朝东"), FORWARD_WEST("FORWARD_WEST","朝西"), FORWARD_NORTH("FORWARD_NORTH","朝北"), FORWARD_SOUTH("FORWARD_SOUTH","朝南"), SOUTH_NORTH_TRANSPARENT("SOUTH_NORTH_TRANSPARENT","南北通透"), EAST_WEST("EAST_WEST","东西") ; private String code; private String message; private OrientationType(String code, String message) { this.code = code; this.message = message; } public String code() { return code; } public String message() { return message; } public static OrientationType getByCode(String code) { for (OrientationType result : values()) { if (result.code().equals(code)) { return result; } } return null; } /** * 获取全部枚举值 * * @return List<String> */ public static java.util.List<String> getAllEnumCode() { java.util.List<String> list = new java.util.ArrayList<String>(values().length); for (OrientationType _enum : values()) { list.add(_enum.code()); } return list; } /** * 获取全部枚举 * * @return List<ListType> */ public static java.util.List<OrientationType> getAllEnum() { java.util.List<OrientationType> list = new java.util.ArrayList<OrientationType>(values().length); for (OrientationType _enum : values()) { list.add(_enum); } return list; } /** * 获取全部枚举描述 * * @return List<ListType> */ public static java.util.List<String> getAllEnumMessage() { java.util.List<String> list = new java.util.ArrayList<String>(values().length); for (OrientationType _enum : values()) { list.add(_enum.message); } return list; } }
2,041
0.562151
0.553526
89
21.146067
22.537634
105
false
false
0
0
0
0
0
0
0.348315
false
false
2
4a4c6e3501888045c46b62d344d72becbd0f4198
10,161,892,670,530
81b2c5de0f0f1046633fa6bd08276aa3c664fbc6
/src/ch05/format/FormattingDates3.java
e15b6d4ce48d13c3f328f8ac8b94192fadc34934
[]
no_license
JoseYonis/jp8
https://github.com/JoseYonis/jp8
52b01d92b2aae569d82d85d3793f749dcf1cd2a9
d21630e310f7701603a0ad7fbb8843a158614e37
refs/heads/master
2019-05-17T12:28:39.301000
2019-03-26T16:23:18
2019-03-26T16:23:18
82,991,695
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ch05.format; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; public class FormattingDates3 { public static void main(String[] args) { LocalDate date = LocalDate.of(2020, Month.JANUARY, 20); LocalTime time = LocalTime.of(11, 12, 34); LocalDateTime dateTime = LocalDateTime.of(date, time); DateTimeFormatter shortF = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT); DateTimeFormatter mediumF = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); System.out.println(shortF.format(dateTime)); // 1/20/20 11:12 AM System.out.println(mediumF.format(dateTime)); // Jan 20, 2020 11:12:34 DateTimeFormatter f = DateTimeFormatter.ofPattern("MMMM dd, yyyy, hh:mm"); System.out.println(dateTime.format(f)); // January 20, 2020, 11:12 DateTimeFormatter f2 = DateTimeFormatter.ofPattern("hh:mm"); System.out.println(f2.format(dateTime)); // 11:12 //System.out.println(f2.format(date)); // java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: ClockHourOfAmPm System.out.println(f2.format(time)); // 11:12 DateTimeFormatter f3 = DateTimeFormatter.ofPattern("MM dd yyyy"); LocalDate date3 = LocalDate.parse("01 02 2015", f3); LocalTime time3 = LocalTime.parse("11:22"); System.out.println(date3); // 2015–01–02 System.out.println(time3); // 11:22 DateTimeFormatter f4 = DateTimeFormatter.ofPattern("MMw dd yyyy"); LocalDate date2 = LocalDate.parse("01 02 2015", f4); // java.time.format.DateTimeParseException: Text '01 02 2015' could not be parsed at index 2 } }
WINDOWS-1252
Java
1,733
java
FormattingDates3.java
Java
[]
null
[]
package ch05.format; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; public class FormattingDates3 { public static void main(String[] args) { LocalDate date = LocalDate.of(2020, Month.JANUARY, 20); LocalTime time = LocalTime.of(11, 12, 34); LocalDateTime dateTime = LocalDateTime.of(date, time); DateTimeFormatter shortF = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT); DateTimeFormatter mediumF = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); System.out.println(shortF.format(dateTime)); // 1/20/20 11:12 AM System.out.println(mediumF.format(dateTime)); // Jan 20, 2020 11:12:34 DateTimeFormatter f = DateTimeFormatter.ofPattern("MMMM dd, yyyy, hh:mm"); System.out.println(dateTime.format(f)); // January 20, 2020, 11:12 DateTimeFormatter f2 = DateTimeFormatter.ofPattern("hh:mm"); System.out.println(f2.format(dateTime)); // 11:12 //System.out.println(f2.format(date)); // java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: ClockHourOfAmPm System.out.println(f2.format(time)); // 11:12 DateTimeFormatter f3 = DateTimeFormatter.ofPattern("MM dd yyyy"); LocalDate date3 = LocalDate.parse("01 02 2015", f3); LocalTime time3 = LocalTime.parse("11:22"); System.out.println(date3); // 2015–01–02 System.out.println(time3); // 11:22 DateTimeFormatter f4 = DateTimeFormatter.ofPattern("MMw dd yyyy"); LocalDate date2 = LocalDate.parse("01 02 2015", f4); // java.time.format.DateTimeParseException: Text '01 02 2015' could not be parsed at index 2 } }
1,733
0.735685
0.673222
40
41.224998
35.033905
147
false
false
0
0
0
0
0
0
2.125
false
false
2
1a12c8b7b5f14f781d8d45d86bfddad04d2e36c7
10,264,971,857,203
7d26dfa1c1cd679fd9656e68f18ebc6449486f6e
/src/main/java/scalc/internal/functions/AbsFunction.java
a170a0cb0eaae43ee4cd2a7cbcc1e4a58c1eeb30
[ "MIT" ]
permissive
MatWein/SCalc
https://github.com/MatWein/SCalc
619f7b5d20dd750839513efae0b847b17961a143
c78caf52edd19d54b10ce9a5e725c91977979258
refs/heads/master
2022-05-31T15:47:14.792000
2022-04-05T22:00:52
2022-04-05T22:00:52
164,258,245
5
0
MIT
false
2020-11-12T20:24:51
2019-01-05T23:05:38
2020-11-12T20:21:59
2020-11-12T20:24:03
71
1
0
0
Java
false
false
package scalc.internal.functions; import scalc.SCalcOptions; import scalc.exceptions.CalculationException; import scalc.interfaces.FunctionImpl; import java.math.BigDecimal; import java.util.List; public class AbsFunction implements FunctionImpl { public static final AbsFunction INSTANCE = new AbsFunction(); @Override public BigDecimal call(SCalcOptions<?> options, List<BigDecimal> functionParams) { if (functionParams.size() != 1) { throw new CalculationException("The abs function has to get exactly one parameter."); } BigDecimal firstParam = functionParams.get(0); if (firstParam.compareTo(new BigDecimal(0).setScale(options.getCalculationScale(), options.getCalculationRoundingMode())) < 0) { return firstParam.multiply(new BigDecimal(-1).setScale(options.getCalculationScale(), options.getCalculationRoundingMode())); } else { return firstParam; } } }
UTF-8
Java
966
java
AbsFunction.java
Java
[]
null
[]
package scalc.internal.functions; import scalc.SCalcOptions; import scalc.exceptions.CalculationException; import scalc.interfaces.FunctionImpl; import java.math.BigDecimal; import java.util.List; public class AbsFunction implements FunctionImpl { public static final AbsFunction INSTANCE = new AbsFunction(); @Override public BigDecimal call(SCalcOptions<?> options, List<BigDecimal> functionParams) { if (functionParams.size() != 1) { throw new CalculationException("The abs function has to get exactly one parameter."); } BigDecimal firstParam = functionParams.get(0); if (firstParam.compareTo(new BigDecimal(0).setScale(options.getCalculationScale(), options.getCalculationRoundingMode())) < 0) { return firstParam.multiply(new BigDecimal(-1).setScale(options.getCalculationScale(), options.getCalculationRoundingMode())); } else { return firstParam; } } }
966
0.717391
0.712215
26
36.153847
38.901939
137
false
false
0
0
0
0
0
0
0.538462
false
false
2
a8e791666c5f33c02a5b4c0e44ae48c873ad98ca
16,406,775,088,350
b60230401507d6dd86e4b419a53d16555fa76b00
/src/main/java/com/example/springServer/dto/UserInfoDto.java
66b7f490286b106df93e912b45ab2746606c5277
[]
no_license
amerariia/DiplomServer
https://github.com/amerariia/DiplomServer
2104bf24db3f100bcc9ec9cf8bfb4048d039390e
4d19c044cbd9b7512b7742c12bbc689af25d5ec6
refs/heads/master
2023-05-12T22:42:05.121000
2021-06-05T13:35:47
2021-06-05T13:35:47
342,677,226
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.springServer.dto; import lombok.Getter; import lombok.Setter; @Getter @Setter public class UserInfoDto { private Integer id; private String name; private String email; }
UTF-8
Java
204
java
UserInfoDto.java
Java
[]
null
[]
package com.example.springServer.dto; import lombok.Getter; import lombok.Setter; @Getter @Setter public class UserInfoDto { private Integer id; private String name; private String email; }
204
0.75
0.75
12
16
11.846237
37
false
false
0
0
0
0
0
0
0.5
false
false
2
d5bbc0e15e8a02c8d0f969b0095f0f04a3e26886
4,518,305,599,275
ba55ffba75a0f83740d56d2e98993769ebbc19ef
/app/src/main/java/com/pentakill/cake/ui/activity/SettingActivity.java
e3d6f73f3c2d952017573e4e73487a42ea4f5367
[]
no_license
zoulux/Cake
https://github.com/zoulux/Cake
b15f6d1625530fe6cc0354d90149a959afa70394
e1c8da5591e742e1f9bfccf9e2c5026be37d3202
refs/heads/master
2021-01-18T15:07:28.587000
2016-02-23T15:45:41
2016-02-23T15:45:41
50,674,050
1
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.pentakill.cake.ui.activity; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import com.nostra13.universalimageloader.core.ImageLoader; import com.pentakill.cake.R; import com.pentakill.cake.common.listener.PopupListener; import com.pentakill.cake.db.CakeDao; import com.pentakill.cake.db.CategoryDao; import com.pentakill.cake.db.ShopCartDao; import com.pentakill.cake.db.ShopDao; import com.pentakill.cake.model.CategoryBean; import com.pentakill.cake.ui.adapter.CategorySettingAdapter; import com.pentakill.cake.ui.widget.ExpandableListView; import com.pentakill.cake.ui.widget.SelectPicPW; import java.util.List; public class SettingActivity extends BaseActivity implements View.OnClickListener, PopupListener { private static final String TAG = "SettingActivity"; private CategoryDao categoryDao; private ShopDao shopDao; private CakeDao cakeDao; private ShopCartDao shopCartDao; private ExpandableListView listView; private CategorySettingAdapter adapter; private List<CategoryBean> data; private EditText etShopName; private EditText etShopPhone; private TextView tvSetShopIcon, tvSetShopName, tvSetShopMobile; private ImageView ivShopIcon; private SelectPicPW selectShopIconPW; private int REQUEST_CODE_CAPTURE_CAMEIA = 0x1; private int REQUEST_CODE_PICK_IMAGE = 0x2; private ImageView ivTheme1, ivTheme2, ivTheme3, ivTheme4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); initDaos(); initViews(); initListener(); initDatas(); } private void initListener() { tvSetShopIcon.setOnClickListener(this); ivTheme1.setOnClickListener(this); ivTheme2.setOnClickListener(this); ivTheme3.setOnClickListener(this); ivTheme4.setOnClickListener(this); tvSetShopName.setOnClickListener(this); tvSetShopMobile.setOnClickListener(this); } private void initDaos() { categoryDao = new CategoryDao(this); shopDao = new ShopDao(this); shopDao.add(); } private void initDatas() { data = categoryDao.selectAll(); adapter.setData(data); } private void initViews() { listView = (ExpandableListView) findViewById(R.id.lv_category_setting); etShopName = (EditText) findViewById(R.id.et_category_name); tvSetShopIcon = (TextView) findViewById(R.id.tv_update_shop_mobile); etShopPhone = (EditText) findViewById(R.id.et_category_phone); ivShopIcon = (ImageView) findViewById(R.id.iv_shop_icon); ivTheme1 = (ImageView) findViewById(R.id.iv_theme1); ivTheme2 = (ImageView) findViewById(R.id.iv_theme2); ivTheme3 = (ImageView) findViewById(R.id.iv_theme3); ivTheme4 = (ImageView) findViewById(R.id.iv_theme4); tvSetShopName = (TextView) findViewById(R.id.tv_update_shop_name); tvSetShopMobile = (TextView) findViewById(R.id.tv_update_shop_mobile); adapter = new CategorySettingAdapter(this, R.layout.item_category_setting); listView.setAdapter(adapter); etShopName.setHint(shopDao.getShopName()); etShopPhone.setHint(shopDao.getShopPhone()); selectShopIconPW = new SelectPicPW(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_update_shop_icon: setShopIcon(v); break; case R.id.iv_theme1: changeTheme(1); break; case R.id.iv_theme2: changeTheme(2); break; case R.id.iv_theme3: changeTheme(3); break; case R.id.iv_theme4: changeTheme(4); break; case R.id.tv_update_shop_name: updateName(); break; case R.id.tv_update_shop_mobile: updateMobile(); break; } } private void updateMobile() { String name = etShopName.getText().toString(); if (!TextUtils.isEmpty(name)){ shopDao.setShopName(name); } } private void updateName() { String phone = etShopPhone.getText().toString(); if (!TextUtils.isEmpty(phone)){ shopDao.setShopPhone(phone); } } private void changeTheme(int themeType) { showToast(themeType + ""); } private void setShopIcon(View v) { selectShopIconPW.showAtLocation(v, Gravity.BOTTOM, 0, 0); selectShopIconPW.setListener(this); } @Override public void onSelectFromAlbum() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE); Log.d(TAG, "onSelectFromAlbum: "); } @Override public void onSelectFromCamera() { Log.d(TAG, "onSelectFromCamera: "); String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, REQUEST_CODE_CAPTURE_CAMEIA); } else { showToast("请确认已经插入SD卡"); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { showToast("请再试一遍"); return; } if (requestCode == REQUEST_CODE_PICK_IMAGE) { Uri uri = data.getData(); ImageLoader.getInstance().displayImage(uri.toString(), ivShopIcon); } else if (requestCode == REQUEST_CODE_CAPTURE_CAMEIA) { Uri uri = data.getData(); Bitmap bitmap = null; if (uri == null) { Bundle bundle = data.getExtras(); bitmap = (Bitmap) bundle.get("data"); ivShopIcon.setImageBitmap(bitmap); } else { ImageLoader.getInstance().displayImage(uri.toString(), ivShopIcon); } } } }
UTF-8
Java
6,627
java
SettingActivity.java
Java
[]
null
[]
package com.pentakill.cake.ui.activity; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import com.nostra13.universalimageloader.core.ImageLoader; import com.pentakill.cake.R; import com.pentakill.cake.common.listener.PopupListener; import com.pentakill.cake.db.CakeDao; import com.pentakill.cake.db.CategoryDao; import com.pentakill.cake.db.ShopCartDao; import com.pentakill.cake.db.ShopDao; import com.pentakill.cake.model.CategoryBean; import com.pentakill.cake.ui.adapter.CategorySettingAdapter; import com.pentakill.cake.ui.widget.ExpandableListView; import com.pentakill.cake.ui.widget.SelectPicPW; import java.util.List; public class SettingActivity extends BaseActivity implements View.OnClickListener, PopupListener { private static final String TAG = "SettingActivity"; private CategoryDao categoryDao; private ShopDao shopDao; private CakeDao cakeDao; private ShopCartDao shopCartDao; private ExpandableListView listView; private CategorySettingAdapter adapter; private List<CategoryBean> data; private EditText etShopName; private EditText etShopPhone; private TextView tvSetShopIcon, tvSetShopName, tvSetShopMobile; private ImageView ivShopIcon; private SelectPicPW selectShopIconPW; private int REQUEST_CODE_CAPTURE_CAMEIA = 0x1; private int REQUEST_CODE_PICK_IMAGE = 0x2; private ImageView ivTheme1, ivTheme2, ivTheme3, ivTheme4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); initDaos(); initViews(); initListener(); initDatas(); } private void initListener() { tvSetShopIcon.setOnClickListener(this); ivTheme1.setOnClickListener(this); ivTheme2.setOnClickListener(this); ivTheme3.setOnClickListener(this); ivTheme4.setOnClickListener(this); tvSetShopName.setOnClickListener(this); tvSetShopMobile.setOnClickListener(this); } private void initDaos() { categoryDao = new CategoryDao(this); shopDao = new ShopDao(this); shopDao.add(); } private void initDatas() { data = categoryDao.selectAll(); adapter.setData(data); } private void initViews() { listView = (ExpandableListView) findViewById(R.id.lv_category_setting); etShopName = (EditText) findViewById(R.id.et_category_name); tvSetShopIcon = (TextView) findViewById(R.id.tv_update_shop_mobile); etShopPhone = (EditText) findViewById(R.id.et_category_phone); ivShopIcon = (ImageView) findViewById(R.id.iv_shop_icon); ivTheme1 = (ImageView) findViewById(R.id.iv_theme1); ivTheme2 = (ImageView) findViewById(R.id.iv_theme2); ivTheme3 = (ImageView) findViewById(R.id.iv_theme3); ivTheme4 = (ImageView) findViewById(R.id.iv_theme4); tvSetShopName = (TextView) findViewById(R.id.tv_update_shop_name); tvSetShopMobile = (TextView) findViewById(R.id.tv_update_shop_mobile); adapter = new CategorySettingAdapter(this, R.layout.item_category_setting); listView.setAdapter(adapter); etShopName.setHint(shopDao.getShopName()); etShopPhone.setHint(shopDao.getShopPhone()); selectShopIconPW = new SelectPicPW(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.tv_update_shop_icon: setShopIcon(v); break; case R.id.iv_theme1: changeTheme(1); break; case R.id.iv_theme2: changeTheme(2); break; case R.id.iv_theme3: changeTheme(3); break; case R.id.iv_theme4: changeTheme(4); break; case R.id.tv_update_shop_name: updateName(); break; case R.id.tv_update_shop_mobile: updateMobile(); break; } } private void updateMobile() { String name = etShopName.getText().toString(); if (!TextUtils.isEmpty(name)){ shopDao.setShopName(name); } } private void updateName() { String phone = etShopPhone.getText().toString(); if (!TextUtils.isEmpty(phone)){ shopDao.setShopPhone(phone); } } private void changeTheme(int themeType) { showToast(themeType + ""); } private void setShopIcon(View v) { selectShopIconPW.showAtLocation(v, Gravity.BOTTOM, 0, 0); selectShopIconPW.setListener(this); } @Override public void onSelectFromAlbum() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE); Log.d(TAG, "onSelectFromAlbum: "); } @Override public void onSelectFromCamera() { Log.d(TAG, "onSelectFromCamera: "); String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, REQUEST_CODE_CAPTURE_CAMEIA); } else { showToast("请确认已经插入SD卡"); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { showToast("请再试一遍"); return; } if (requestCode == REQUEST_CODE_PICK_IMAGE) { Uri uri = data.getData(); ImageLoader.getInstance().displayImage(uri.toString(), ivShopIcon); } else if (requestCode == REQUEST_CODE_CAPTURE_CAMEIA) { Uri uri = data.getData(); Bitmap bitmap = null; if (uri == null) { Bundle bundle = data.getExtras(); bitmap = (Bitmap) bundle.get("data"); ivShopIcon.setImageBitmap(bitmap); } else { ImageLoader.getInstance().displayImage(uri.toString(), ivShopIcon); } } } }
6,627
0.640509
0.635661
212
30.122641
22.720909
98
false
false
0
0
0
0
0
0
0.632075
false
false
2
2073fceff93862333e229c28bf899a08aecf28ad
549,755,816,310
d3bbae7bc4e8954b4db2a048f8fc4591583da1aa
/src/main/java/com/example/RechargeSoftware/Master/Entity/Role.java
0121146171a2b7bffe937e9db12d0fc1db413890
[]
no_license
akash211191/rechargeBackend
https://github.com/akash211191/rechargeBackend
e4e7123f10fcbf0a60a1f90a0bee3140b30f4d36
97b56f5c3aa2f67f3e7495b4c6149ef6e3a1245e
refs/heads/master
2023-08-20T10:39:42.696000
2021-10-26T07:12:02
2021-10-26T07:12:02
420,583,777
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.example.RechargeSoftware.Master.Entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.NamedNativeQueries; import org.hibernate.annotations.NamedNativeQuery; @NamedNativeQueries({ @NamedNativeQuery(name = "Role.getAllRoleListExceptAdmin", query = "select * from Tbl_Role where role_name != 'Admin'") }) @Entity @Table(name= "Tbl_Role") public class Role { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "role_id") int roleId; @Column(name = "role_name") int roleName; public int getRoleId() { return roleId; } public void setRoleId(int roleId) { this.roleId = roleId; } public int getRoleName() { return roleName; } public void setRoleName(int roleName) { this.roleName = roleName; } }
UTF-8
Java
978
java
Role.java
Java
[]
null
[]
package com.example.RechargeSoftware.Master.Entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.NamedNativeQueries; import org.hibernate.annotations.NamedNativeQuery; @NamedNativeQueries({ @NamedNativeQuery(name = "Role.getAllRoleListExceptAdmin", query = "select * from Tbl_Role where role_name != 'Admin'") }) @Entity @Table(name= "Tbl_Role") public class Role { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "role_id") int roleId; @Column(name = "role_name") int roleName; public int getRoleId() { return roleId; } public void setRoleId(int roleId) { this.roleId = roleId; } public int getRoleName() { return roleName; } public void setRoleName(int roleName) { this.roleName = roleName; } }
978
0.736196
0.736196
46
20.26087
22.467789
120
false
false
0
0
0
0
0
0
1.413043
false
false
2
4c8dbf16ec8aac447fc521c986044fe2240b6235
31,258,771,984,585
91db9fb27edda8096979eee4e3dae566ad33543e
/src/main/java/com/github/java/book/JavaMultiThreadInAction/ch1/SleepTimer.java
15a3ce9ce20395a27b40a415b2b6891845045916
[]
no_license
wenxuejiang610/Java365
https://github.com/wenxuejiang610/Java365
0dcfab7b58c05946b5045e2b39caa247fc576f2c
be8efd1c1af7210eb015c03f4db3c5f51b2542a0
refs/heads/master
2023-01-31T04:57:00.702000
2020-11-22T06:50:45
2020-11-22T06:50:45
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.github.java.book.JavaMultiThreadInAction.ch1; /** * @author pengfei.zhao * @date 2020/10/18 20:37 */ public class SleepTimer { public static int count; public static void main(String[] args) throws InterruptedException { count = args.length >= 1 ? Integer.parseInt(args[0]) : 60; int maintain; while (true) { maintain = countDown(); if (0 == maintain) { break; } System.out.printf("Countdown: %s", maintain); Thread.sleep(1000); System.out.println("Done."); } } private static int countDown() { return count--; } }
UTF-8
Java
684
java
SleepTimer.java
Java
[ { "context": ".book.JavaMultiThreadInAction.ch1;\n\n/**\n * @author pengfei.zhao\n * @date 2020/10/18 20:37\n */\npublic class SleepT", "end": 86, "score": 0.9967823624610901, "start": 74, "tag": "NAME", "value": "pengfei.zhao" } ]
null
[]
package com.github.java.book.JavaMultiThreadInAction.ch1; /** * @author pengfei.zhao * @date 2020/10/18 20:37 */ public class SleepTimer { public static int count; public static void main(String[] args) throws InterruptedException { count = args.length >= 1 ? Integer.parseInt(args[0]) : 60; int maintain; while (true) { maintain = countDown(); if (0 == maintain) { break; } System.out.printf("Countdown: %s", maintain); Thread.sleep(1000); System.out.println("Done."); } } private static int countDown() { return count--; } }
684
0.548246
0.516082
30
21.799999
20.580574
72
false
false
0
0
0
0
0
0
0.366667
false
false
2
574bb280ab20f709c2023e40dff24f6a2ce52c4a
23,158,463,676,475
764789cbaddc2c31fbaef35df50407e2d1481b02
/src/main/java/org/techvalleyhigh/frc5881/powerup/robot/utils/trajectories/TrajectoryExport.java
09431cac620fc65c9282ddb65e8303cafe0a346a
[]
no_license
FRC5881/2018Robot
https://github.com/FRC5881/2018Robot
281feeb460dd030b78a3d0f2b29f14e8f2c526bf
290328c8c163ae152bdc15cbcce8572b6759e99b
refs/heads/master
2021-09-26T23:38:22.583000
2018-11-04T15:50:46
2018-11-04T15:50:46
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package org.techvalleyhigh.frc5881.powerup.robot.utils.trajectories; import jaci.pathfinder.Pathfinder; import jaci.pathfinder.Trajectory; import jaci.pathfinder.Waypoint; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Map; /** * Generates and exports all current Autonomous Routine Trajectories to an * external file. */ public class TrajectoryExport { public static void main(String[] args) { System.out.println("Exporting Trajectory Paths to: " + getExportDir()); Map<Integer, Autonomous> autos = TrajectoryUtil.getAutos(); for(Integer key : autos.keySet()) { Autonomous auto = autos.get(key); System.out.println("Generating Trajectory for Auto " + key); Trajectory trajectory = Pathfinder.generate(auto.getPath(), auto.getConfig()); exportTrajectory(trajectory, auto.getPath(), auto.getConfig(), key); System.out.println(""); } } private static String getExportDir() { return System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator; } private static void exportTrajectory(Trajectory trajectory, Waypoint[] path, Trajectory.Config config, int autoNumber) { try { File export = new File(getExportDir() + "auto_" + autoNumber + ".csv"); PrintWriter printWriter = new PrintWriter(export); // Start with config values: printWriter.println("" + config.dt + "," + config.max_velocity + "," + config.max_acceleration + "," + config.max_jerk); // Dump waypoints for(Waypoint waypoint : path) { printWriter.println("" + waypoint.x + "," + waypoint.y + "," + waypoint.angle); } // Add a separator to denote start of trajectory data printWriter.println("---"); for(Trajectory.Segment segment : trajectory.segments) { printWriter.println("" + segment.dt + "," + segment.x + "," + segment.y + "," + segment.position + "," + segment.velocity + "," + segment.acceleration + "," + segment.jerk + "," + segment.heading); } printWriter.close(); System.out.println("Auto " + autoNumber + " exported successfully."); } catch (FileNotFoundException e) { System.err.println("Cannot output auto " + autoNumber); e.printStackTrace(); } } }
UTF-8
Java
2,655
java
TrajectoryExport.java
Java
[]
null
[]
package org.techvalleyhigh.frc5881.powerup.robot.utils.trajectories; import jaci.pathfinder.Pathfinder; import jaci.pathfinder.Trajectory; import jaci.pathfinder.Waypoint; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Map; /** * Generates and exports all current Autonomous Routine Trajectories to an * external file. */ public class TrajectoryExport { public static void main(String[] args) { System.out.println("Exporting Trajectory Paths to: " + getExportDir()); Map<Integer, Autonomous> autos = TrajectoryUtil.getAutos(); for(Integer key : autos.keySet()) { Autonomous auto = autos.get(key); System.out.println("Generating Trajectory for Auto " + key); Trajectory trajectory = Pathfinder.generate(auto.getPath(), auto.getConfig()); exportTrajectory(trajectory, auto.getPath(), auto.getConfig(), key); System.out.println(""); } } private static String getExportDir() { return System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator; } private static void exportTrajectory(Trajectory trajectory, Waypoint[] path, Trajectory.Config config, int autoNumber) { try { File export = new File(getExportDir() + "auto_" + autoNumber + ".csv"); PrintWriter printWriter = new PrintWriter(export); // Start with config values: printWriter.println("" + config.dt + "," + config.max_velocity + "," + config.max_acceleration + "," + config.max_jerk); // Dump waypoints for(Waypoint waypoint : path) { printWriter.println("" + waypoint.x + "," + waypoint.y + "," + waypoint.angle); } // Add a separator to denote start of trajectory data printWriter.println("---"); for(Trajectory.Segment segment : trajectory.segments) { printWriter.println("" + segment.dt + "," + segment.x + "," + segment.y + "," + segment.position + "," + segment.velocity + "," + segment.acceleration + "," + segment.jerk + "," + segment.heading); } printWriter.close(); System.out.println("Auto " + autoNumber + " exported successfully."); } catch (FileNotFoundException e) { System.err.println("Cannot output auto " + autoNumber); e.printStackTrace(); } } }
2,655
0.591714
0.590207
72
35.875
33.309967
112
false
false
0
0
0
0
0
0
0.638889
false
false
2
db396cc21089fbe0f55a1abd068e0cf85088283f
30,700,426,241,429
7a9c0556c19d1f0b3c713756228344d2e39f4923
/week7/day03/beansday/src/main/java/com/greenfox/beansday/HelloBeans/HelloWorldApplication.java
5e5377a8e67781f306d5344d69022100c76d368b
[]
no_license
green-fox-academy/gaborki
https://github.com/green-fox-academy/gaborki
c838b366634a47d1b72cd717ded6123ba5c13408
66233121ede4f3e6285e52875ce4201c26cc7109
refs/heads/master
2021-06-19T04:14:19.401000
2017-07-03T09:29:24
2017-07-03T09:29:24
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.greenfox.beansday.HelloBeans; import com.greenfox.beansday.HelloBeans.Color.ColorConfig; import com.greenfox.beansday.HelloBeans.Color.Red; import com.greenfox.beansday.HelloBeans.HelloBeans.HelloWorld; import com.greenfox.beansday.HelloBeans.HelloBeans.HelloWorldConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @SpringBootApplication public class HelloWorldApplication { public static void main(String[] args) { SpringApplication.run(HelloWorldApplication.class, args); ApplicationContext factory = new AnnotationConfigApplicationContext(HelloWorldConfig.class); HelloWorld printhello = factory.getBean(HelloWorld.class); printhello.setMessage("helloooooo!"); printhello.getMessage(); ApplicationContext colorFactory = new AnnotationConfigApplicationContext(ColorConfig.class); Red red = colorFactory.getBean(Red.class); red.printColor(); } }
UTF-8
Java
1,097
java
HelloWorldApplication.java
Java
[]
null
[]
package com.greenfox.beansday.HelloBeans; import com.greenfox.beansday.HelloBeans.Color.ColorConfig; import com.greenfox.beansday.HelloBeans.Color.Red; import com.greenfox.beansday.HelloBeans.HelloBeans.HelloWorld; import com.greenfox.beansday.HelloBeans.HelloBeans.HelloWorldConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @SpringBootApplication public class HelloWorldApplication { public static void main(String[] args) { SpringApplication.run(HelloWorldApplication.class, args); ApplicationContext factory = new AnnotationConfigApplicationContext(HelloWorldConfig.class); HelloWorld printhello = factory.getBean(HelloWorld.class); printhello.setMessage("helloooooo!"); printhello.getMessage(); ApplicationContext colorFactory = new AnnotationConfigApplicationContext(ColorConfig.class); Red red = colorFactory.getBean(Red.class); red.printColor(); } }
1,097
0.839562
0.839562
28
38.17857
29.588913
94
false
false
0
0
0
0
0
0
1.285714
false
false
2
d72638992fa0bd634761185d387822fb8376b51b
30,872,224,989,045
e315c2bb2ea17cd8388a39aa0587e47cb417af0a
/src/tn/com/smartsoft/framework/apiThecallr/mig/ConnectionConf.java
6151aa6c758cce61e13b6b1ea1e386a91c76dcb4
[]
no_license
wissem007/badges
https://github.com/wissem007/badges
000536a40e34e20592fe6e4cb2684d93604c44c9
2064bd07b52141cf3cff0892e628cc62b4f94fdc
refs/heads/master
2020-12-26T14:06:11.693000
2020-01-31T23:40:07
2020-01-31T23:40:07
237,530,008
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package tn.com.smartsoft.framework.apiThecallr.mig; import java.sql.Connection; import java.sql.Driver; import java.util.Properties; import oracle.jdbc.driver.OracleConnection; public class ConnectionConf { private String connectionURL; private String userName; private String password; private String driver; public ConnectionConf(String connectionURL, String driver, String userName, String password) { super(); this.connectionURL = connectionURL; this.userName = userName; this.password = password; this.driver = driver; } public ConnectionConf() { } public void setConnectionURL(String connectionURL) { this.connectionURL = connectionURL; } public String getConnectionURL() { return connectionURL; } public void setUserName(String userName) { this.userName = userName; } public String getUserName() { return userName; } public void setPassword(String password) { this.password = password; } public String getPassword() { return password; } public void setDriver(String driver) { this.driver = driver; } public String getDriver() { return driver; } public Connection creeConnection() throws Exception { Driver driver = (Driver) Class.forName(getDriver()).newInstance(); Properties info = new Properties(); info.put("user", getUserName()); info.put("password", getPassword()); Connection connection = driver.connect(getConnectionURL(), info); if (connection instanceof OracleConnection) { ((oracle.jdbc.OracleConnection) connection).setRemarksReporting(true); } return connection; } }
UTF-8
Java
1,585
java
ConnectionConf.java
Java
[ { "context": "f {\n\tprivate String connectionURL;\n\tprivate String userName;\n\tprivate String password;\n\tprivate String driver", "end": 265, "score": 0.8004831671714783, "start": 257, "tag": "USERNAME", "value": "userName" }, { "context": "onConf(String connectionURL, String driver, String userName, String password) {\n\t\tsuper();\n\t\tthis.connectionU", "end": 394, "score": 0.6692769527435303, "start": 386, "tag": "USERNAME", "value": "userName" }, { "context": "s.connectionURL = connectionURL;\n\t\tthis.userName = userName;\n\t\tthis.password = password;\n\t\tthis.driver = driv", "end": 490, "score": 0.9974476099014282, "start": 482, "tag": "USERNAME", "value": "userName" }, { "context": "URL;\n\t\tthis.userName = userName;\n\t\tthis.password = password;\n\t\tthis.driver = driver;\n\t}\n\t\n\tpublic ConnectionC", "end": 518, "score": 0.9950383901596069, "start": 510, "tag": "PASSWORD", "value": "password" }, { "context": "onnectionURL;\n\t}\n\t\n\tpublic void setUserName(String userName) {\n\t\tthis.userName = userName;\n\t}\n\t\n\tpublic Strin", "end": 783, "score": 0.8701848387718201, "start": 775, "tag": "USERNAME", "value": "userName" }, { "context": "d setUserName(String userName) {\n\t\tthis.userName = userName;\n\t}\n\t\n\tpublic String getUserName() {\n\t\treturn use", "end": 813, "score": 0.9976629018783569, "start": 805, "tag": "USERNAME", "value": "userName" }, { "context": "Name;\n\t}\n\t\n\tpublic String getUserName() {\n\t\treturn userName;\n\t}\n\t\n\tpublic void setPassword(String password) {", "end": 868, "score": 0.9960655570030212, "start": 860, "tag": "USERNAME", "value": "userName" }, { "context": "word;\n\t}\n\t\n\tpublic String getPassword() {\n\t\treturn password;\n\t}\n\t\n\tpublic void setDriver(String driver) {\n\t\tt", "end": 1000, "score": 0.6046845316886902, "start": 992, "tag": "PASSWORD", "value": "password" } ]
null
[]
package tn.com.smartsoft.framework.apiThecallr.mig; import java.sql.Connection; import java.sql.Driver; import java.util.Properties; import oracle.jdbc.driver.OracleConnection; public class ConnectionConf { private String connectionURL; private String userName; private String password; private String driver; public ConnectionConf(String connectionURL, String driver, String userName, String password) { super(); this.connectionURL = connectionURL; this.userName = userName; this.password = <PASSWORD>; this.driver = driver; } public ConnectionConf() { } public void setConnectionURL(String connectionURL) { this.connectionURL = connectionURL; } public String getConnectionURL() { return connectionURL; } public void setUserName(String userName) { this.userName = userName; } public String getUserName() { return userName; } public void setPassword(String password) { this.password = password; } public String getPassword() { return <PASSWORD>; } public void setDriver(String driver) { this.driver = driver; } public String getDriver() { return driver; } public Connection creeConnection() throws Exception { Driver driver = (Driver) Class.forName(getDriver()).newInstance(); Properties info = new Properties(); info.put("user", getUserName()); info.put("password", getPassword()); Connection connection = driver.connect(getConnectionURL(), info); if (connection instanceof OracleConnection) { ((oracle.jdbc.OracleConnection) connection).setRemarksReporting(true); } return connection; } }
1,589
0.739432
0.739432
70
21.657143
21.03323
95
false
false
0
0
0
0
0
0
1.7
false
false
2
b1d0944c99347259431e006b7a738a13c914c97f
17,428,977,351,421
66f46fe68eab229960eaf778db9eac2772c9e935
/message/src/main/java/com/github/dactiv/xiaoshamu/message/service/support/site/SiteMessageChannelSender.java
d9f4d7c4b992cbc74aef5cc85b8bffd7a5d7c665
[ "Apache-2.0" ]
permissive
dactiv/xiaoshamu
https://github.com/dactiv/xiaoshamu
e4f07d6be1af3ab29a79f797e1035618f8d12471
eb2bf488529b2cfb61a22a1bbd2b2a42206dd931
refs/heads/master
2020-12-31T08:17:25.052000
2020-07-31T09:19:24
2020-07-31T09:19:24
226,810,748
1
0
Apache-2.0
false
2020-07-02T01:41:03
2019-12-09T07:28:13
2020-07-01T13:28:37
2020-07-02T01:41:01
2,813
1
0
1
Java
false
false
package com.github.dactiv.xiaoshamu.message.service.support.site; import com.github.dactiv.xiaoshamu.commons.spring.web.RestResult; import com.github.dactiv.xiaoshamu.message.dao.entity.SiteMessage; import java.util.Map; /** * 消息推送渠道发送者 * * @author maurice */ public interface SiteMessageChannelSender { /** * 获取消息推送渠道类型 * * @return 站内信渠道类型 */ String getType(); /** * 发送消息 * * @param entity 站内信消息实体 * * @return rest 结果集 */ RestResult<Map<String, Object>> sendSiteMessage(SiteMessage entity) throws Exception; }
UTF-8
Java
666
java
SiteMessageChannelSender.java
Java
[ { "context": "ort java.util.Map;\n\n/**\n * 消息推送渠道发送者\n *\n * @author maurice\n */\npublic interface SiteMessageChannelSender {\n\n", "end": 262, "score": 0.9996544718742371, "start": 255, "tag": "USERNAME", "value": "maurice" } ]
null
[]
package com.github.dactiv.xiaoshamu.message.service.support.site; import com.github.dactiv.xiaoshamu.commons.spring.web.RestResult; import com.github.dactiv.xiaoshamu.message.dao.entity.SiteMessage; import java.util.Map; /** * 消息推送渠道发送者 * * @author maurice */ public interface SiteMessageChannelSender { /** * 获取消息推送渠道类型 * * @return 站内信渠道类型 */ String getType(); /** * 发送消息 * * @param entity 站内信消息实体 * * @return rest 结果集 */ RestResult<Map<String, Object>> sendSiteMessage(SiteMessage entity) throws Exception; }
666
0.665529
0.665529
30
18.533333
23.205938
89
false
false
0
0
0
0
0
0
0.233333
false
false
2
1b3c08b1ac72d2a91cb5c8f8647bff49620a9c13
22,007,412,486,395
78fcff9d0c9356a74fd479c19cd865f61d7f564e
/claimMateCamera/src/main/java/com/commonsware/cwac/camera/demo/fragments/DemoCameraFragment.java
e2f140520d29f8ca33c31837d0b24a0e6dc48959
[]
no_license
claimmate-apps/Camera-Android
https://github.com/claimmate-apps/Camera-Android
d05c9332eabdf79a1aa582f4817dc785ff4dcb94
ced9e4dab9e303c976625730f59cc4a07aada50a
refs/heads/master
2021-08-14T21:34:49.491000
2021-08-13T12:15:30
2021-08-13T12:15:30
241,575,128
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
/*** 7 Copyright (c) 2013 CommonsWare, LLC 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.commonsware.cwac.camera.demo.fragments; import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.hardware.Camera; import android.hardware.Camera.Face; import android.hardware.Camera.Parameters; import android.os.Build; import android.os.Bundle; import android.os.SystemClock; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.Toast; import com.commonsware.cwac.camera.CameraFragment; import com.commonsware.cwac.camera.CameraHost; import com.commonsware.cwac.camera.CameraUtils; import com.commonsware.cwac.camera.PictureTransaction; import com.commonsware.cwac.camera.SimpleCameraHost; import com.commonsware.cwac.camera.demo.activities.DisplayActivity; import com.example.claimmate.R; @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class DemoCameraFragment extends CameraFragment implements OnSeekBarChangeListener { private static final String KEY_USE_FFC = "com.commonsware.cwac.camera.demo.USE_FFC"; private MenuItem singleShotItem = null; private MenuItem autoFocusItem = null; private MenuItem takePictureItem = null; private MenuItem flashItem = null; // private MenuItem recordItem=null; private MenuItem stopRecordItem = null; private MenuItem mirrorFFC = null; private boolean singleShotProcessing = false; private SeekBar zoom = null; private long lastFaceToast = 0L; String flashMode = null; boolean flash = true; ImageView flashImageView; public String data = ""; static DemoCameraFragment newInstance(boolean useFFC) { DemoCameraFragment f = new DemoCameraFragment(); Bundle args = new Bundle(); args.putBoolean(KEY_USE_FFC, useFFC); f.setArguments(args); return (f); } @Override public void onCreate(Bundle state) { super.onCreate(state); setHasOptionsMenu(true); SimpleCameraHost.Builder builder = new SimpleCameraHost.Builder(new DemoCameraHost(getActivity())); setCameraHost(builder.useFullBleedPreview(true).build()); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View cameraView = super.onCreateView(inflater, container, savedInstanceState); View results = inflater.inflate(R.layout.fragment, container, false); ((ViewGroup) results.findViewById(R.id.camera)).addView(cameraView); zoom = (SeekBar) results.findViewById(R.id.zoom); flashImageView = (ImageView) results.findViewById(R.id.flashImageView); zoom.setKeepScreenOn(true); flashImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (flash) { flash = false; flashImageView.setImageResource(R.drawable.camera_flash_off); } else { flash = true; flashImageView.setImageResource(R.drawable.camera_flash_on); } } }); // setRecordingItemVisibility(); return (results); } @Override public void onPause() { super.onPause(); getActivity().invalidateOptionsMenu(); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.camera, menu); takePictureItem = menu.findItem(R.id.camera); singleShotItem = menu.findItem(R.id.single_shot); singleShotItem.setChecked(getContract().isSingleShotMode()); autoFocusItem = menu.findItem(R.id.autofocus); flashItem = menu.findItem(R.id.flash); // recordItem=menu.findItem(R.id.record); stopRecordItem = menu.findItem(R.id.stop); // mirrorFFC=menu.findItem(R.id.mirror_ffc); if (isRecording()) { // recordItem.setVisible(false); stopRecordItem.setVisible(true); takePictureItem.setVisible(false); } // setRecordingItemVisibility(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.camera: // takeSimplePicture(); return (true); // case R.id.record: // try { // record(); // getActivity().invalidateOptionsMenu(); // } // catch (Exception e) { // Log.e(getClass().getSimpleName(), // "Exception trying to record", e); // Toast.makeText(getActivity(), e.getMessage(), // Toast.LENGTH_LONG).show(); // } // // return(true); case R.id.stop: try { stopRecording(); getActivity().invalidateOptionsMenu(); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Exception trying to stop recording", e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); } return (true); case R.id.autofocus: takePictureItem.setEnabled(false); autoFocus(); return (true); case R.id.single_shot: item.setChecked(!item.isChecked()); getContract().setSingleShotMode(item.isChecked()); return (true); case R.id.show_zoom: item.setChecked(!item.isChecked()); zoom.setVisibility(item.isChecked() ? View.VISIBLE : View.GONE); return (true); // case R.id.flash: // case R.id.mirror_ffc: // item.setChecked(!item.isChecked()); // // return(true); } return (super.onOptionsItemSelected(item)); } boolean isSingleShotProcessing() { return (singleShotProcessing); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { zoom.setEnabled(false); zoomTo(progress).onComplete(new Runnable() { @Override public void run() { zoom.setEnabled(true); } }).go(); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // ignore } @Override public void onStopTrackingTouch(SeekBar seekBar) { // ignore } // void setRecordingItemVisibility() { // if (zoom != null && recordItem != null) { // if (getDisplayOrientation() != 0 // && getDisplayOrientation() != 180) { // recordItem.setVisible(false); // } // } // } Contract getContract() { return ((Contract) getActivity()); } @TargetApi(23) public void takeSimplePicture(String data) { this.data = data; if (singleShotItem != null && singleShotItem.isChecked()) { singleShotProcessing = true; takePictureItem.setEnabled(false); } PictureTransaction xact = new PictureTransaction(getCameraHost()); if ((this.singleShotItem != null) ) { this.singleShotProcessing = true; this.takePictureItem.setEnabled(false); } if (flash) { xact.flashMode(flashMode); } takePicture(xact); } interface Contract { boolean isSingleShotMode(); void setSingleShotMode(boolean mode); } @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @SuppressWarnings("deprecation") public class DemoCameraHost extends SimpleCameraHost implements Camera.FaceDetectionListener { boolean supportsFaces = false; public DemoCameraHost(Context _ctxt) { super(_ctxt); } @Override public boolean useFrontFacingCamera() { if (getArguments() == null) { return (false); } return (getArguments().getBoolean(KEY_USE_FFC)); } @Override public boolean useSingleShotMode() { if (singleShotItem == null) { return (false); } return (singleShotItem.isChecked()); } @Override public void saveImage(PictureTransaction xact, byte[] image) { singleShotProcessing = true; if (getActivity() != null) { DisplayActivity.imageToShow = image; Intent paramPictureTransaction = new Intent(getActivity(), DisplayActivity.class); paramPictureTransaction.putExtra("data", data); startActivity(paramPictureTransaction); } } @Override public void autoFocusAvailable() { if (autoFocusItem != null) { autoFocusItem.setEnabled(true); if (supportsFaces) startFaceDetection(); } } @Override public void autoFocusUnavailable() { if (autoFocusItem != null) { stopFaceDetection(); if (supportsFaces) autoFocusItem.setEnabled(false); } } @Override public void onCameraFail(CameraHost.FailureReason reason) { super.onCameraFail(reason); Toast.makeText(getActivity(), "Sorry, but you cannot use the camera now!", Toast.LENGTH_LONG).show(); } @Override public Parameters adjustPreviewParameters(Parameters parameters) { flashMode = CameraUtils.findBestFlashModeMatch(parameters, Camera.Parameters.FLASH_MODE_RED_EYE, Camera.Parameters.FLASH_MODE_AUTO, Camera.Parameters.FLASH_MODE_ON); if (doesZoomReallyWork() && parameters.getMaxZoom() > 0) { zoom.setMax(parameters.getMaxZoom()); zoom.setOnSeekBarChangeListener(DemoCameraFragment.this); } else { zoom.setEnabled(false); } if (parameters.getMaxNumDetectedFaces() > 0) { supportsFaces = true; } else { Toast.makeText(getActivity(), "Face detection not available for this camera", Toast.LENGTH_LONG).show(); } return (super.adjustPreviewParameters(parameters)); } @Override public void onFaceDetection(Face[] faces, Camera camera) { if (faces.length > 0) { long now = SystemClock.elapsedRealtime(); if (now > lastFaceToast + 10000) { Toast.makeText(getActivity(), "I see your face!", Toast.LENGTH_LONG).show(); lastFaceToast = now; } } } @Override @TargetApi(16) public void onAutoFocus(boolean success, Camera camera) { super.onAutoFocus(success, camera); takePictureItem.setEnabled(true); } @Override public boolean mirrorFFC() { return (mirrorFFC.isChecked()); } } }
UTF-8
Java
12,523
java
DemoCameraFragment.java
Java
[]
null
[]
/*** 7 Copyright (c) 2013 CommonsWare, LLC 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.commonsware.cwac.camera.demo.fragments; import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.hardware.Camera; import android.hardware.Camera.Face; import android.hardware.Camera.Parameters; import android.os.Build; import android.os.Bundle; import android.os.SystemClock; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.Toast; import com.commonsware.cwac.camera.CameraFragment; import com.commonsware.cwac.camera.CameraHost; import com.commonsware.cwac.camera.CameraUtils; import com.commonsware.cwac.camera.PictureTransaction; import com.commonsware.cwac.camera.SimpleCameraHost; import com.commonsware.cwac.camera.demo.activities.DisplayActivity; import com.example.claimmate.R; @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class DemoCameraFragment extends CameraFragment implements OnSeekBarChangeListener { private static final String KEY_USE_FFC = "com.commonsware.cwac.camera.demo.USE_FFC"; private MenuItem singleShotItem = null; private MenuItem autoFocusItem = null; private MenuItem takePictureItem = null; private MenuItem flashItem = null; // private MenuItem recordItem=null; private MenuItem stopRecordItem = null; private MenuItem mirrorFFC = null; private boolean singleShotProcessing = false; private SeekBar zoom = null; private long lastFaceToast = 0L; String flashMode = null; boolean flash = true; ImageView flashImageView; public String data = ""; static DemoCameraFragment newInstance(boolean useFFC) { DemoCameraFragment f = new DemoCameraFragment(); Bundle args = new Bundle(); args.putBoolean(KEY_USE_FFC, useFFC); f.setArguments(args); return (f); } @Override public void onCreate(Bundle state) { super.onCreate(state); setHasOptionsMenu(true); SimpleCameraHost.Builder builder = new SimpleCameraHost.Builder(new DemoCameraHost(getActivity())); setCameraHost(builder.useFullBleedPreview(true).build()); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View cameraView = super.onCreateView(inflater, container, savedInstanceState); View results = inflater.inflate(R.layout.fragment, container, false); ((ViewGroup) results.findViewById(R.id.camera)).addView(cameraView); zoom = (SeekBar) results.findViewById(R.id.zoom); flashImageView = (ImageView) results.findViewById(R.id.flashImageView); zoom.setKeepScreenOn(true); flashImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (flash) { flash = false; flashImageView.setImageResource(R.drawable.camera_flash_off); } else { flash = true; flashImageView.setImageResource(R.drawable.camera_flash_on); } } }); // setRecordingItemVisibility(); return (results); } @Override public void onPause() { super.onPause(); getActivity().invalidateOptionsMenu(); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.camera, menu); takePictureItem = menu.findItem(R.id.camera); singleShotItem = menu.findItem(R.id.single_shot); singleShotItem.setChecked(getContract().isSingleShotMode()); autoFocusItem = menu.findItem(R.id.autofocus); flashItem = menu.findItem(R.id.flash); // recordItem=menu.findItem(R.id.record); stopRecordItem = menu.findItem(R.id.stop); // mirrorFFC=menu.findItem(R.id.mirror_ffc); if (isRecording()) { // recordItem.setVisible(false); stopRecordItem.setVisible(true); takePictureItem.setVisible(false); } // setRecordingItemVisibility(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.camera: // takeSimplePicture(); return (true); // case R.id.record: // try { // record(); // getActivity().invalidateOptionsMenu(); // } // catch (Exception e) { // Log.e(getClass().getSimpleName(), // "Exception trying to record", e); // Toast.makeText(getActivity(), e.getMessage(), // Toast.LENGTH_LONG).show(); // } // // return(true); case R.id.stop: try { stopRecording(); getActivity().invalidateOptionsMenu(); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Exception trying to stop recording", e); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show(); } return (true); case R.id.autofocus: takePictureItem.setEnabled(false); autoFocus(); return (true); case R.id.single_shot: item.setChecked(!item.isChecked()); getContract().setSingleShotMode(item.isChecked()); return (true); case R.id.show_zoom: item.setChecked(!item.isChecked()); zoom.setVisibility(item.isChecked() ? View.VISIBLE : View.GONE); return (true); // case R.id.flash: // case R.id.mirror_ffc: // item.setChecked(!item.isChecked()); // // return(true); } return (super.onOptionsItemSelected(item)); } boolean isSingleShotProcessing() { return (singleShotProcessing); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { zoom.setEnabled(false); zoomTo(progress).onComplete(new Runnable() { @Override public void run() { zoom.setEnabled(true); } }).go(); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // ignore } @Override public void onStopTrackingTouch(SeekBar seekBar) { // ignore } // void setRecordingItemVisibility() { // if (zoom != null && recordItem != null) { // if (getDisplayOrientation() != 0 // && getDisplayOrientation() != 180) { // recordItem.setVisible(false); // } // } // } Contract getContract() { return ((Contract) getActivity()); } @TargetApi(23) public void takeSimplePicture(String data) { this.data = data; if (singleShotItem != null && singleShotItem.isChecked()) { singleShotProcessing = true; takePictureItem.setEnabled(false); } PictureTransaction xact = new PictureTransaction(getCameraHost()); if ((this.singleShotItem != null) ) { this.singleShotProcessing = true; this.takePictureItem.setEnabled(false); } if (flash) { xact.flashMode(flashMode); } takePicture(xact); } interface Contract { boolean isSingleShotMode(); void setSingleShotMode(boolean mode); } @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @SuppressWarnings("deprecation") public class DemoCameraHost extends SimpleCameraHost implements Camera.FaceDetectionListener { boolean supportsFaces = false; public DemoCameraHost(Context _ctxt) { super(_ctxt); } @Override public boolean useFrontFacingCamera() { if (getArguments() == null) { return (false); } return (getArguments().getBoolean(KEY_USE_FFC)); } @Override public boolean useSingleShotMode() { if (singleShotItem == null) { return (false); } return (singleShotItem.isChecked()); } @Override public void saveImage(PictureTransaction xact, byte[] image) { singleShotProcessing = true; if (getActivity() != null) { DisplayActivity.imageToShow = image; Intent paramPictureTransaction = new Intent(getActivity(), DisplayActivity.class); paramPictureTransaction.putExtra("data", data); startActivity(paramPictureTransaction); } } @Override public void autoFocusAvailable() { if (autoFocusItem != null) { autoFocusItem.setEnabled(true); if (supportsFaces) startFaceDetection(); } } @Override public void autoFocusUnavailable() { if (autoFocusItem != null) { stopFaceDetection(); if (supportsFaces) autoFocusItem.setEnabled(false); } } @Override public void onCameraFail(CameraHost.FailureReason reason) { super.onCameraFail(reason); Toast.makeText(getActivity(), "Sorry, but you cannot use the camera now!", Toast.LENGTH_LONG).show(); } @Override public Parameters adjustPreviewParameters(Parameters parameters) { flashMode = CameraUtils.findBestFlashModeMatch(parameters, Camera.Parameters.FLASH_MODE_RED_EYE, Camera.Parameters.FLASH_MODE_AUTO, Camera.Parameters.FLASH_MODE_ON); if (doesZoomReallyWork() && parameters.getMaxZoom() > 0) { zoom.setMax(parameters.getMaxZoom()); zoom.setOnSeekBarChangeListener(DemoCameraFragment.this); } else { zoom.setEnabled(false); } if (parameters.getMaxNumDetectedFaces() > 0) { supportsFaces = true; } else { Toast.makeText(getActivity(), "Face detection not available for this camera", Toast.LENGTH_LONG).show(); } return (super.adjustPreviewParameters(parameters)); } @Override public void onFaceDetection(Face[] faces, Camera camera) { if (faces.length > 0) { long now = SystemClock.elapsedRealtime(); if (now > lastFaceToast + 10000) { Toast.makeText(getActivity(), "I see your face!", Toast.LENGTH_LONG).show(); lastFaceToast = now; } } } @Override @TargetApi(16) public void onAutoFocus(boolean success, Camera camera) { super.onAutoFocus(success, camera); takePictureItem.setEnabled(true); } @Override public boolean mirrorFFC() { return (mirrorFFC.isChecked()); } } }
12,523
0.585403
0.583327
417
29.033573
22.971964
98
false
false
0
0
0
0
0
0
0.460432
false
false
2
77d7cf633ec5be7685cb6ee9f1bcd22b8003e025
12,945,031,493,336
b5af8657c597acd0b5a0b35fbc3d3975941bb7cd
/persistance/src/main/java/cz/muni/fi/pv254/dao/GenreDaoImpl.java
83b2decbea6c56344609f08b6d392d78549da080
[]
no_license
VargaiD/HelloWorld
https://github.com/VargaiD/HelloWorld
897e9b2451269df45cd52e65690a1ee80b4bba1c
7dae5190eb228e8d3f58f4bbd6e4a89eea947e8c
refs/heads/master
2021-05-16T08:43:51.201000
2019-01-06T08:10:02
2019-01-06T08:10:02
104,176,550
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package cz.muni.fi.pv254.dao; import cz.muni.fi.pv254.entity.Game; import cz.muni.fi.pv254.entity.Genre; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import javax.persistence.EntityManager; import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; import java.util.HashSet; import java.util.List; import java.util.Set; @Transactional @Repository public class GenreDaoImpl implements GenreDao { @PersistenceContext private EntityManager em; @Override public void remove(Genre genre) { em.remove(em.contains(genre) ? genre : em.merge(genre)); } @Override public Genre add(Genre genre) { return em.merge(genre); } @Override public void update(Genre genre) { em.merge(genre); } @Override public List<Genre> findAll() { return em.createQuery("SELECT g FROM Genre g", Genre.class) .getResultList(); } @Override public Genre findById(Long id) { Genre genre = em.find(Genre.class, id); return genre; } @Override public Genre findByName(String name) { if (name == null || name.isEmpty()) throw new IllegalArgumentException("Cannot search for null name"); try { Genre genre = em.createQuery("SELECT g FROM Genre g where g.name =:name", Genre.class).setParameter("name", name).getSingleResult(); return genre; } catch (NoResultException ex) { return null; } } }
UTF-8
Java
1,607
java
GenreDaoImpl.java
Java
[]
null
[]
package cz.muni.fi.pv254.dao; import cz.muni.fi.pv254.entity.Game; import cz.muni.fi.pv254.entity.Genre; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import javax.persistence.EntityManager; import javax.persistence.NoResultException; import javax.persistence.PersistenceContext; import java.util.HashSet; import java.util.List; import java.util.Set; @Transactional @Repository public class GenreDaoImpl implements GenreDao { @PersistenceContext private EntityManager em; @Override public void remove(Genre genre) { em.remove(em.contains(genre) ? genre : em.merge(genre)); } @Override public Genre add(Genre genre) { return em.merge(genre); } @Override public void update(Genre genre) { em.merge(genre); } @Override public List<Genre> findAll() { return em.createQuery("SELECT g FROM Genre g", Genre.class) .getResultList(); } @Override public Genre findById(Long id) { Genre genre = em.find(Genre.class, id); return genre; } @Override public Genre findByName(String name) { if (name == null || name.isEmpty()) throw new IllegalArgumentException("Cannot search for null name"); try { Genre genre = em.createQuery("SELECT g FROM Genre g where g.name =:name", Genre.class).setParameter("name", name).getSingleResult(); return genre; } catch (NoResultException ex) { return null; } } }
1,607
0.654014
0.648413
62
24.919355
21.906178
85
false
false
0
0
0
0
0
0
0.451613
false
false
2
9d9de2fc54d1b59ca82d4e0375d454e768ab386b
6,631,429,546,301
f895cb28b865c822e6fb10e2827fb1a50d6a74cd
/app/src/main/java/com/world_tech_point/lambebrowser/serviceFragment/MembershipSave.java
ad66dde3592786b5dba1c79f04e84bdb4a475548
[]
no_license
somon122/LambeBrowserApp
https://github.com/somon122/LambeBrowserApp
30a2611dfef557dd6bb529be660da9726f27b918
c01bcb0b9e8b67285dfa94bcaec7f47b7e5e622b
refs/heads/master
2023-01-06T07:32:17.538000
2020-11-09T02:38:56
2020-11-09T02:38:56
286,386,597
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.world_tech_point.lambebrowser.serviceFragment; import android.content.Context; import android.content.SharedPreferences; public class MembershipSave { private Context context; private SharedPreferences sharedPreferences; private SharedPreferences.Editor editor; public MembershipSave(Context context) { this.context = context; sharedPreferences = context.getSharedPreferences("userInfo", Context.MODE_PRIVATE); editor = sharedPreferences.edit(); } public void saveUserInfo (int id,String userName, String email, String user_type, String add_fee_status, String number, String referCode,String bankName, String bankAccountNo, String facebookID, String instragramID){ editor.putInt("id",id); editor.putString("number",number); editor.putString("email",email); editor.putString("userName",userName); editor.putString("user_type",user_type); editor.putString("add_fee_status",add_fee_status); editor.putString("referCode",referCode); editor.putString("bankName",bankName); editor.putString("bankAccountNo",bankAccountNo); editor.putString("facebookID",facebookID); editor.putString("instragramID",instragramID); editor.commit(); } public void setTowBalance (String earnPoint, String referPoint){ editor.putString("earnPoint",earnPoint); editor.putString("referPoint",referPoint); editor.commit(); } public String getEarnPoint (){ String earnPoint = sharedPreferences.getString("earnPoint","0"); return earnPoint; } public String getReferPoint (){ String referPoint = sharedPreferences.getString("referPoint","0"); return referPoint; } public void setEmailNumber (String email, String number){ editor.putString("email",email); editor.putString("number",number); editor.commit(); } public int getId (){ int id = sharedPreferences.getInt("id",0); return id; } public String getEmail (){ String email = sharedPreferences.getString("email",""); return email; } public String getNumber (){ String number = sharedPreferences.getString("number",""); return number; } public String getUserName (){ String userName = sharedPreferences.getString("userName",""); return userName; } public String getUser_type (){ String user_type = sharedPreferences.getString("user_type",""); return user_type; } public String getAdd_fee_status (){ String add_fee_status = sharedPreferences.getString("add_fee_status",""); return add_fee_status; } public String getReferCode (){ String referCode = sharedPreferences.getString("referCode",""); return referCode; } public String getBankName (){ String bankName = sharedPreferences.getString("bankName",""); return bankName; } public String getBankAccountNo (){ String bankAccountNo = sharedPreferences.getString("bankAccountNo",""); return bankAccountNo; } public String getFacebookID (){ String facebookID = sharedPreferences.getString("facebookID",""); return facebookID; } public String getInstragramID (){ String instragramID = sharedPreferences.getString("instragramID",""); return instragramID; } public void delete(){ editor.clear(); editor.commit(); } }
UTF-8
Java
3,603
java
MembershipSave.java
Java
[ { "context": " }\n\n\n public void saveUserInfo (int id,String userName, String email, String user_type, String add_fee_s", "end": 563, "score": 0.9928871393203735, "start": 555, "tag": "USERNAME", "value": "userName" }, { "context": "mail\",email);\n editor.putString(\"userName\",userName);\n editor.putString(\"user_type\",user_type)", "end": 920, "score": 0.9989914894104004, "start": 912, "tag": "USERNAME", "value": "userName" }, { "context": " return number;\n }\n public String getUserName (){\n\n String userName = sharedPreferences.", "end": 2379, "score": 0.8291592001914978, "start": 2371, "tag": "USERNAME", "value": "UserName" }, { "context": " String userName = sharedPreferences.getString(\"userName\",\"\");\n return userName;\n }\n public S", "end": 2448, "score": 0.9555115699768066, "start": 2440, "tag": "USERNAME", "value": "userName" }, { "context": "eferences.getString(\"userName\",\"\");\n return userName;\n }\n public String getUser_type (){\n\n ", "end": 2478, "score": 0.5527326464653015, "start": 2470, "tag": "USERNAME", "value": "userName" } ]
null
[]
package com.world_tech_point.lambebrowser.serviceFragment; import android.content.Context; import android.content.SharedPreferences; public class MembershipSave { private Context context; private SharedPreferences sharedPreferences; private SharedPreferences.Editor editor; public MembershipSave(Context context) { this.context = context; sharedPreferences = context.getSharedPreferences("userInfo", Context.MODE_PRIVATE); editor = sharedPreferences.edit(); } public void saveUserInfo (int id,String userName, String email, String user_type, String add_fee_status, String number, String referCode,String bankName, String bankAccountNo, String facebookID, String instragramID){ editor.putInt("id",id); editor.putString("number",number); editor.putString("email",email); editor.putString("userName",userName); editor.putString("user_type",user_type); editor.putString("add_fee_status",add_fee_status); editor.putString("referCode",referCode); editor.putString("bankName",bankName); editor.putString("bankAccountNo",bankAccountNo); editor.putString("facebookID",facebookID); editor.putString("instragramID",instragramID); editor.commit(); } public void setTowBalance (String earnPoint, String referPoint){ editor.putString("earnPoint",earnPoint); editor.putString("referPoint",referPoint); editor.commit(); } public String getEarnPoint (){ String earnPoint = sharedPreferences.getString("earnPoint","0"); return earnPoint; } public String getReferPoint (){ String referPoint = sharedPreferences.getString("referPoint","0"); return referPoint; } public void setEmailNumber (String email, String number){ editor.putString("email",email); editor.putString("number",number); editor.commit(); } public int getId (){ int id = sharedPreferences.getInt("id",0); return id; } public String getEmail (){ String email = sharedPreferences.getString("email",""); return email; } public String getNumber (){ String number = sharedPreferences.getString("number",""); return number; } public String getUserName (){ String userName = sharedPreferences.getString("userName",""); return userName; } public String getUser_type (){ String user_type = sharedPreferences.getString("user_type",""); return user_type; } public String getAdd_fee_status (){ String add_fee_status = sharedPreferences.getString("add_fee_status",""); return add_fee_status; } public String getReferCode (){ String referCode = sharedPreferences.getString("referCode",""); return referCode; } public String getBankName (){ String bankName = sharedPreferences.getString("bankName",""); return bankName; } public String getBankAccountNo (){ String bankAccountNo = sharedPreferences.getString("bankAccountNo",""); return bankAccountNo; } public String getFacebookID (){ String facebookID = sharedPreferences.getString("facebookID",""); return facebookID; } public String getInstragramID (){ String instragramID = sharedPreferences.getString("instragramID",""); return instragramID; } public void delete(){ editor.clear(); editor.commit(); } }
3,603
0.649459
0.648626
132
26.295454
27.162735
123
false
false
0
0
0
0
0
0
0.727273
false
false
2
bc1870c69a24d02a6873abd4d311f0a02bf665c2
21,509,196,255,807
007f9ee0592c07ad481feb1bca69424b833e90a1
/Javaoops/src/coreJava/SuperParentDemo.java
0765dc98e6025e205b598d18d107d02ad4bad061
[]
no_license
KeshavJha0610/Core-Java
https://github.com/KeshavJha0610/Core-Java
4c6489e2478a456fa38ecb12ba510e1844447664
cbe4f98e81c5511b04d6c5eec31b3010632ff52d
refs/heads/main
2023-03-07T12:31:18.903000
2022-07-25T15:44:45
2022-07-25T15:44:45
339,660,844
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package coreJava; public class SuperParentDemo { String name = "Keshav"; public SuperParentDemo() { System.out.println("parent class constructor"); } public void getData() { System.out.println("I am parent class"); } public static void main(String[] args) { } }
UTF-8
Java
332
java
SuperParentDemo.java
Java
[ { "context": "ublic class SuperParentDemo {\r\n String name = \"Keshav\";\r\n\r\n public SuperParentDemo() {\r\n Syst", "end": 78, "score": 0.9997848868370056, "start": 72, "tag": "NAME", "value": "Keshav" } ]
null
[]
package coreJava; public class SuperParentDemo { String name = "Keshav"; public SuperParentDemo() { System.out.println("parent class constructor"); } public void getData() { System.out.println("I am parent class"); } public static void main(String[] args) { } }
332
0.581325
0.581325
19
15.473684
18.265205
55
false
false
0
0
0
0
0
0
0.210526
false
false
2
98a59469a90301ed176b83b4109302ffb0df2291
33,449,205,318,375
780cb3633c24f42beca3d38fb72d1447a20cf381
/VoteApplication/src/main/java/com/VoteApplication/controller/FeatureController.java
08e07d1471d12edc658148e0a17ae13f5a8c28d5
[]
no_license
VlatkoIliev/VoteApplication
https://github.com/VlatkoIliev/VoteApplication
1dba35d0463e91bec2b2bf5c1ca80da56d5eeec1
8d40db7c02df0bd1c187c2a7b7417dc6ba24ffad
refs/heads/main
2023-07-10T09:04:56.243000
2021-08-18T17:15:17
2021-08-18T17:15:17
379,720,325
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.VoteApplication.controller; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import com.VoteApplication.domain.Comment; import com.VoteApplication.domain.Feature; import com.VoteApplication.domain.User; import com.VoteApplication.service.FeatureService; @Controller @RequestMapping("/products/{productId}/features") public class FeatureController { private Logger log = LoggerFactory.getLogger(FeatureController.class); @Autowired private FeatureService featureService; @PostMapping("") public String createFeature(@AuthenticationPrincipal User user, @PathVariable Long productId) { Feature feature = featureService.createFeature(productId, user); return "redirect:/products/"+productId+"/features/"+feature.getId(); } @GetMapping("{featureId}") public String getFeature(@AuthenticationPrincipal User user,ModelMap model, @PathVariable Long productId, @PathVariable Long featureId) { Optional<Feature> featureOpt = featureService.findById(featureId); if(featureOpt.isPresent()) { Feature feature = featureOpt.get(); model.put("feature", feature); SortedSet<Comment> commentsWithoutDuplicates = getCommentsWithoutDuplicates(0, new HashSet<Long>(), feature.getComments()); model.put("thread", commentsWithoutDuplicates); model.put("comment", new Comment()); } // handle a situation where we can't find a feature by featureId model.put("user", user); return "feature"; } private SortedSet<Comment> getCommentsWithoutDuplicates(int page, Set<Long> visitedComments, SortedSet<Comment> comments) { page++; Iterator<Comment> itr = comments.iterator(); while(itr.hasNext()) { Comment comment = itr.next(); boolean addedVisitedComments = visitedComments.add(comment.getId()); if(!addedVisitedComments) { itr.remove(); if(page != 1) return comments; } if(addedVisitedComments && !comment.getComments().isEmpty()) getCommentsWithoutDuplicates(page, visitedComments, comment.getComments()); } return comments; } /* * private Set<Comment> getCommentsWithoutDuplicates(Feature feature) { * * * return feature.getComments(); } */ @PostMapping("{featureId}") public String updateFeature(@AuthenticationPrincipal User user,Feature feature, @PathVariable Long productId, @PathVariable Long featureId) { feature.setUser(user); feature = featureService.save(feature); // redirect:/p/"+feature.getProduct().getName(); String encodedProductName; try { encodedProductName = URLEncoder.encode(feature.getProduct().getName(), "UTF-8"); } catch (UnsupportedEncodingException e) { log.warn("Unable to encode the URL string: " + feature.getProduct().getName() + ", redirecting instead to dashboard!"); return "redirect:/dashboard"; } return "redirect:/p/"+encodedProductName; } }
UTF-8
Java
3,679
java
FeatureController.java
Java
[]
null
[]
package com.VoteApplication.controller; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import com.VoteApplication.domain.Comment; import com.VoteApplication.domain.Feature; import com.VoteApplication.domain.User; import com.VoteApplication.service.FeatureService; @Controller @RequestMapping("/products/{productId}/features") public class FeatureController { private Logger log = LoggerFactory.getLogger(FeatureController.class); @Autowired private FeatureService featureService; @PostMapping("") public String createFeature(@AuthenticationPrincipal User user, @PathVariable Long productId) { Feature feature = featureService.createFeature(productId, user); return "redirect:/products/"+productId+"/features/"+feature.getId(); } @GetMapping("{featureId}") public String getFeature(@AuthenticationPrincipal User user,ModelMap model, @PathVariable Long productId, @PathVariable Long featureId) { Optional<Feature> featureOpt = featureService.findById(featureId); if(featureOpt.isPresent()) { Feature feature = featureOpt.get(); model.put("feature", feature); SortedSet<Comment> commentsWithoutDuplicates = getCommentsWithoutDuplicates(0, new HashSet<Long>(), feature.getComments()); model.put("thread", commentsWithoutDuplicates); model.put("comment", new Comment()); } // handle a situation where we can't find a feature by featureId model.put("user", user); return "feature"; } private SortedSet<Comment> getCommentsWithoutDuplicates(int page, Set<Long> visitedComments, SortedSet<Comment> comments) { page++; Iterator<Comment> itr = comments.iterator(); while(itr.hasNext()) { Comment comment = itr.next(); boolean addedVisitedComments = visitedComments.add(comment.getId()); if(!addedVisitedComments) { itr.remove(); if(page != 1) return comments; } if(addedVisitedComments && !comment.getComments().isEmpty()) getCommentsWithoutDuplicates(page, visitedComments, comment.getComments()); } return comments; } /* * private Set<Comment> getCommentsWithoutDuplicates(Feature feature) { * * * return feature.getComments(); } */ @PostMapping("{featureId}") public String updateFeature(@AuthenticationPrincipal User user,Feature feature, @PathVariable Long productId, @PathVariable Long featureId) { feature.setUser(user); feature = featureService.save(feature); // redirect:/p/"+feature.getProduct().getName(); String encodedProductName; try { encodedProductName = URLEncoder.encode(feature.getProduct().getName(), "UTF-8"); } catch (UnsupportedEncodingException e) { log.warn("Unable to encode the URL string: " + feature.getProduct().getName() + ", redirecting instead to dashboard!"); return "redirect:/dashboard"; } return "redirect:/p/"+encodedProductName; } }
3,679
0.740147
0.738788
110
31.445454
32.359791
142
false
false
0
0
0
0
0
0
1.936364
false
false
2
a29e2acd423290fca0b512b126be0a5308d0a75d
4,415,226,429,493
83f4d29a65c1efc7129984f6c8be7fd3577fc97e
/src/PalindromePartitioning.java
6734c37b2ca6a31e636b353e94db9cd0966919d3
[]
no_license
jeonghunyoon/data-structure
https://github.com/jeonghunyoon/data-structure
6f7e7e0d433b2baf08047b8d8dd9fabb645d5412
fe68481362d7fbf0518ad60bc689bf891b40b951
refs/heads/master
2019-03-11T04:42:17.299000
2017-11-24T11:47:41
2017-11-24T11:47:41
101,829,382
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
import java.util.ArrayList; import java.util.List; /** * Created by Jeonghun on 2017. 10. 16.. */ public class PalindromePartitioning { public static void main(String[] args) { PalindromePartitioning solution = new PalindromePartitioning(); Print.printStrListOfList(solution.partition("aab")); } public List<List<String>> partition(String s) { List<List<String>> result = new ArrayList<>(); if (s == null || s.length() == 0) { return result; } List<String> palindrome = new ArrayList<>(); addPalindrom(0, s, result, palindrome); return result; } private void addPalindrom(int start, String s, List<List<String>> result, List<String> palindrome) { if (start == s.length()) { List<String> temp = new ArrayList<>(palindrome); result.add(temp); return; } for (int i = start + 1 ; i <= s.length() ; i++) { String str = s.substring(start, i); if (isPalindrome(str)) { palindrome.add(str); addPalindrom(i, s, result, palindrome); palindrome.remove(palindrome.size() - 1); } } } private boolean isPalindrome(String str) { int start = 0; int end = str.length() - 1; boolean result = true; while(start < end) { if (str.charAt(start) != str.charAt(end)) { result = false; break; } start++; end--; } return result; } }
UTF-8
Java
1,315
java
PalindromePartitioning.java
Java
[ { "context": "rayList;\nimport java.util.List;\n\n/**\n * Created by Jeonghun on 2017. 10. 16..\n */\npublic class PalindromePart", "end": 78, "score": 0.986839234828949, "start": 70, "tag": "USERNAME", "value": "Jeonghun" } ]
null
[]
import java.util.ArrayList; import java.util.List; /** * Created by Jeonghun on 2017. 10. 16.. */ public class PalindromePartitioning { public static void main(String[] args) { PalindromePartitioning solution = new PalindromePartitioning(); Print.printStrListOfList(solution.partition("aab")); } public List<List<String>> partition(String s) { List<List<String>> result = new ArrayList<>(); if (s == null || s.length() == 0) { return result; } List<String> palindrome = new ArrayList<>(); addPalindrom(0, s, result, palindrome); return result; } private void addPalindrom(int start, String s, List<List<String>> result, List<String> palindrome) { if (start == s.length()) { List<String> temp = new ArrayList<>(palindrome); result.add(temp); return; } for (int i = start + 1 ; i <= s.length() ; i++) { String str = s.substring(start, i); if (isPalindrome(str)) { palindrome.add(str); addPalindrom(i, s, result, palindrome); palindrome.remove(palindrome.size() - 1); } } } private boolean isPalindrome(String str) { int start = 0; int end = str.length() - 1; boolean result = true; while(start < end) { if (str.charAt(start) != str.charAt(end)) { result = false; break; } start++; end--; } return result; } }
1,315
0.638783
0.628137
59
21.305084
21.390839
101
false
false
0
0
0
0
0
0
2.288136
false
false
2
ff3ffee9de9216e73aca64c0b7c84914c27188e9
4,415,226,431,206
6aa62ec68d340bfd7abe8bd255a71ad26992cb4b
/app/src/main/java/droiddevs/com/tripplanner/tripmap/TripMapFragment.java
8d1ec6995fb9db67ac5d595a62d549e89917e45c
[]
no_license
DroidDevs/trip-planner
https://github.com/DroidDevs/trip-planner
bfceb7a77c0472de5f92850b692443a22163ea26
952f9b8ee9d4e09a87e728c47e22c482a4cc8153
refs/heads/master
2021-01-23T08:20:57.780000
2017-04-26T23:41:49
2017-04-26T23:41:49
86,501,921
0
0
null
false
2017-04-27T00:06:44
2017-03-28T20:01:03
2017-04-26T18:54:41
2017-04-27T00:06:09
47,042
0
0
10
Java
null
null
package droiddevs.com.tripplanner.tripmap; import android.os.Bundle; import android.support.annotation.Nullable; import droiddevs.com.tripplanner.adapters.map.BaseMapAdapter; import droiddevs.com.tripplanner.adapters.tripmap.TripMapAdapter; import droiddevs.com.tripplanner.application.TripPlannerApplication; import droiddevs.com.tripplanner.map.BaseMapFragment; import droiddevs.com.tripplanner.map.MapContract; import droiddevs.com.tripplanner.model.map.TripDestinationMapItem; /** * Created by elmira on 4/11/17. */ public class TripMapFragment extends BaseMapFragment<TripDestinationMapItem> { public static final String ARGUMENT_TRIP_ID = "tripId"; private MapContract.Presenter mPresenter; private String mTripId; public static TripMapFragment newInstance(String tripId) { Bundle bundle = new Bundle(); bundle.putString(ARGUMENT_TRIP_ID, tripId); TripMapFragment fragment = new TripMapFragment(); fragment.setArguments(bundle); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTripId = getArguments().getString(ARGUMENT_TRIP_ID); mPresenter = new TripMapPresenter(this, TripPlannerApplication.getRepository(), mTripId); } @Override public BaseMapAdapter getMapAdapter() { return new TripMapAdapter(); } @Override public void onResume() { super.onResume(); mPresenter.reloadData(); } @Override public void setPresenter(MapContract.Presenter presenter) { this.mPresenter = presenter; } @Override public void onMapItemClick(TripDestinationMapItem data) { } }
UTF-8
Java
1,731
java
TripMapFragment.java
Java
[ { "context": "del.map.TripDestinationMapItem;\n\n/**\n * Created by elmira on 4/11/17.\n */\n\npublic class TripMapFragment ext", "end": 508, "score": 0.9990465044975281, "start": 502, "tag": "USERNAME", "value": "elmira" } ]
null
[]
package droiddevs.com.tripplanner.tripmap; import android.os.Bundle; import android.support.annotation.Nullable; import droiddevs.com.tripplanner.adapters.map.BaseMapAdapter; import droiddevs.com.tripplanner.adapters.tripmap.TripMapAdapter; import droiddevs.com.tripplanner.application.TripPlannerApplication; import droiddevs.com.tripplanner.map.BaseMapFragment; import droiddevs.com.tripplanner.map.MapContract; import droiddevs.com.tripplanner.model.map.TripDestinationMapItem; /** * Created by elmira on 4/11/17. */ public class TripMapFragment extends BaseMapFragment<TripDestinationMapItem> { public static final String ARGUMENT_TRIP_ID = "tripId"; private MapContract.Presenter mPresenter; private String mTripId; public static TripMapFragment newInstance(String tripId) { Bundle bundle = new Bundle(); bundle.putString(ARGUMENT_TRIP_ID, tripId); TripMapFragment fragment = new TripMapFragment(); fragment.setArguments(bundle); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTripId = getArguments().getString(ARGUMENT_TRIP_ID); mPresenter = new TripMapPresenter(this, TripPlannerApplication.getRepository(), mTripId); } @Override public BaseMapAdapter getMapAdapter() { return new TripMapAdapter(); } @Override public void onResume() { super.onResume(); mPresenter.reloadData(); } @Override public void setPresenter(MapContract.Presenter presenter) { this.mPresenter = presenter; } @Override public void onMapItemClick(TripDestinationMapItem data) { } }
1,731
0.731947
0.729058
59
28.338984
26.019295
97
false
false
0
0
0
0
0
0
0.457627
false
false
2
8d50727e4090a6605cada6f29dcbe3760558eedb
12,747,462,962,064
aab6f363923ed3ce9e82be9a3f13ad84a3ad61f1
/modules/sis-domain/src/main/java/cz/snet/domain/model/invoice/amount/Amount.java
34ad279be1536a01c1640b1d14c123fad5cd261e
[]
no_license
rsikora/sis
https://github.com/rsikora/sis
b373f5d07cfe9fdb258510afeecc93894baa4d7d
a7353c206fcacca5f269a6cb73b602f810497102
refs/heads/master
2021-01-11T08:09:22.895000
2010-03-25T22:11:02
2010-03-25T22:11:02
558,594
0
1
null
null
null
null
null
null
null
null
null
null
null
null
null
package cz.snet.domain.model.invoice.amount; import cz.snet.domain.model.invoice.amount.rounding.RoundingStrategy; import cz.snet.domain.shared.ValueObject; import java.math.BigDecimal; import java.math.RoundingMode; public class Amount implements ValueObject<Amount> { protected final BigDecimal value; protected Amount(BigDecimal value) { if (isRoundingNeededFor(value)) throw new IllegalArgumentException("Rounding is needed for " + value); this.value = value.setScale(2, RoundingMode.UNNECESSARY); } public static Amount from(BigDecimal value) { return new Amount(value); } public static Amount from(String value) { return new Amount(new BigDecimal(value)); } public static Amount from(BigDecimal value, RoundingStrategy rounding) { return new Amount(rounding.round(value)); } @SuppressWarnings({"ResultOfMethodCallIgnored"}) public static boolean isRoundingNeededFor(BigDecimal value) { try { value.setScale(2, RoundingMode.UNNECESSARY); } catch (ArithmeticException e) { return true; } return false; } public BigDecimal value() { return value; } public Amount add(Amount amount) { return new Amount(value.add(amount.value())); } public Amount subtract(Amount amount) { return new Amount(value.subtract(amount.value())); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Amount)) return false; Amount amount = (Amount) o; return value.equals(amount.value); } @Override public int hashCode() { return value.hashCode(); } @Override public String toString() { return value.toString(); } }
UTF-8
Java
1,905
java
Amount.java
Java
[]
null
[]
package cz.snet.domain.model.invoice.amount; import cz.snet.domain.model.invoice.amount.rounding.RoundingStrategy; import cz.snet.domain.shared.ValueObject; import java.math.BigDecimal; import java.math.RoundingMode; public class Amount implements ValueObject<Amount> { protected final BigDecimal value; protected Amount(BigDecimal value) { if (isRoundingNeededFor(value)) throw new IllegalArgumentException("Rounding is needed for " + value); this.value = value.setScale(2, RoundingMode.UNNECESSARY); } public static Amount from(BigDecimal value) { return new Amount(value); } public static Amount from(String value) { return new Amount(new BigDecimal(value)); } public static Amount from(BigDecimal value, RoundingStrategy rounding) { return new Amount(rounding.round(value)); } @SuppressWarnings({"ResultOfMethodCallIgnored"}) public static boolean isRoundingNeededFor(BigDecimal value) { try { value.setScale(2, RoundingMode.UNNECESSARY); } catch (ArithmeticException e) { return true; } return false; } public BigDecimal value() { return value; } public Amount add(Amount amount) { return new Amount(value.add(amount.value())); } public Amount subtract(Amount amount) { return new Amount(value.subtract(amount.value())); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Amount)) return false; Amount amount = (Amount) o; return value.equals(amount.value); } @Override public int hashCode() { return value.hashCode(); } @Override public String toString() { return value.toString(); } }
1,905
0.626247
0.625197
69
25.608696
22.641644
82
false
false
0
0
0
0
0
0
0.376812
false
false
2
b186e08cd4db3a5024e2a52907f565f03536a6c6
35,210,141,898,484
a225db77848d0f16e67e8b5926f4ea752fa96f64
/serenity-screenplay-webdriver/src/main/java/net/serenitybdd/screenplay/ui/RadioButton.java
4d62fe370a4d7bbcf3d5742dd39aa6813bfcfd2c
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
AnshumanGo/serenity-core
https://github.com/AnshumanGo/serenity-core
cb3c1ee091aa627b0bed59a9d4d6d5196ad3037a
39330a5e92ec54ccb5d0c43c4f6aa4b97c75486b
refs/heads/master
2021-11-29T19:54:27.254000
2021-11-17T15:46:06
2021-11-17T15:46:06
219,955,490
1
1
NOASSERTION
true
2020-10-01T11:18:58
2019-11-06T09:09:01
2019-11-06T10:19:22
2020-10-01T11:18:58
197,885
1
0
0
HTML
false
false
package net.serenitybdd.screenplay.ui; import net.serenitybdd.core.pages.WebElementFacade; import net.serenitybdd.screenplay.abilities.BrowseTheWeb; import net.serenitybdd.screenplay.targets.Target; import org.openqa.selenium.By; import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.function.Function; import static net.serenitybdd.screenplay.ui.LocatorStrategies.fieldWithLabel; /** * An HTML Radio button */ public class RadioButton { private static final String BY_ID_OR_NAME = "css:input[id='{0}' i],input[name='{0}' i],input[data-test='{0}' i],input.{0}"; private static final String BY_VALUE = "css:input[type='radio'][value='{0}' i]"; /** * Locate a radio button with a given name or id. */ public static Target called(String name) { return Target.the("the '" + name + "' radio button").locatedBy(BY_ID_OR_NAME).of(name); } /** * Locate a radio button with a given value. */ public static Target withValue(String value) { return Target.the("the '" + value + "' radio button").locatedBy(BY_VALUE).of(value); } /** * Locate a radio button with a given label */ public static Target withLabel(String labelText) { return Target.the("the '" + labelText + " radio button").locatedBy(fieldWithLabel(labelText)); } }
UTF-8
Java
1,368
java
RadioButton.java
Java
[]
null
[]
package net.serenitybdd.screenplay.ui; import net.serenitybdd.core.pages.WebElementFacade; import net.serenitybdd.screenplay.abilities.BrowseTheWeb; import net.serenitybdd.screenplay.targets.Target; import org.openqa.selenium.By; import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.function.Function; import static net.serenitybdd.screenplay.ui.LocatorStrategies.fieldWithLabel; /** * An HTML Radio button */ public class RadioButton { private static final String BY_ID_OR_NAME = "css:input[id='{0}' i],input[name='{0}' i],input[data-test='{0}' i],input.{0}"; private static final String BY_VALUE = "css:input[type='radio'][value='{0}' i]"; /** * Locate a radio button with a given name or id. */ public static Target called(String name) { return Target.the("the '" + name + "' radio button").locatedBy(BY_ID_OR_NAME).of(name); } /** * Locate a radio button with a given value. */ public static Target withValue(String value) { return Target.the("the '" + value + "' radio button").locatedBy(BY_VALUE).of(value); } /** * Locate a radio button with a given label */ public static Target withLabel(String labelText) { return Target.the("the '" + labelText + " radio button").locatedBy(fieldWithLabel(labelText)); } }
1,368
0.682749
0.679094
44
30.113636
32.812981
127
false
false
0
0
0
0
0
0
0.409091
false
false
2
f21876d0f0f47b406c8cde21f1896e9ebe01bea0
36,962,488,556,231
7591b19a91f662db7131c6da7d9e477ad8141828
/app/src/main/java/com/mr/truck/activities/ImportPayCodeActivity.java
b23ebf6fb5f08d5cef6168e1e37bccc7c3befb56
[]
no_license
dameDolla/MyDirver-master
https://github.com/dameDolla/MyDirver-master
90ff819c84256cb7080110772171ecbc33a6da71
e135ae0cae4a3e1b99a0f88b977ba62568b66bf4
refs/heads/master
2021-01-06T20:44:11.526000
2017-12-06T08:56:12
2017-12-06T08:56:12
99,550,651
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.mr.truck.activities; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.mr.truck.R; import com.mr.truck.utils.ToolsUtils; import com.mr.truck.view.PasswordInputView; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by yanqi on 2017/9/18. */ public class ImportPayCodeActivity extends BaseActivity implements View.OnClickListener{ @BindView(R.id.import_paycode_submit) public Button submit; @BindView(R.id.passwordInputView) public PasswordInputView password; @BindView(R.id.top_title) public TextView title; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reset_import_password); ButterKnife.bind(this); initView(); } private void initView() { title.setText("设置支付密码"); submit.setText("下一步"); submit.setOnClickListener(this); } private void submits() { String psw = password.getText().toString(); if (!TextUtils.isEmpty(psw)){ Intent intent = new Intent(ImportPayCodeActivity.this,RetypePayCodeActivity.class); intent.putExtra("password",psw); startActivity(intent); }else { ToolsUtils.getInstance().toastShowStr(ImportPayCodeActivity.this,"请输入密码"); } } @Override public void onClick(View view) { submits(); } }
UTF-8
Java
1,670
java
ImportPayCodeActivity.java
Java
[ { "context": "import butterknife.ButterKnife;\n\n/**\n * Created by yanqi on 2017/9/18.\n */\n\npublic class ImportPayCodeActi", "end": 446, "score": 0.9996390342712402, "start": 441, "tag": "USERNAME", "value": "yanqi" } ]
null
[]
package com.mr.truck.activities; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.mr.truck.R; import com.mr.truck.utils.ToolsUtils; import com.mr.truck.view.PasswordInputView; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by yanqi on 2017/9/18. */ public class ImportPayCodeActivity extends BaseActivity implements View.OnClickListener{ @BindView(R.id.import_paycode_submit) public Button submit; @BindView(R.id.passwordInputView) public PasswordInputView password; @BindView(R.id.top_title) public TextView title; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reset_import_password); ButterKnife.bind(this); initView(); } private void initView() { title.setText("设置支付密码"); submit.setText("下一步"); submit.setOnClickListener(this); } private void submits() { String psw = password.getText().toString(); if (!TextUtils.isEmpty(psw)){ Intent intent = new Intent(ImportPayCodeActivity.this,RetypePayCodeActivity.class); intent.putExtra("password",psw); startActivity(intent); }else { ToolsUtils.getInstance().toastShowStr(ImportPayCodeActivity.this,"请输入密码"); } } @Override public void onClick(View view) { submits(); } }
1,670
0.688794
0.684531
64
24.65625
22.002285
95
false
false
0
0
0
0
0
0
0.5
false
false
2
04a8c7c0d92fa08dd9acea627ecd70e7aa659ee3
26,946,624,871,425
5ba92ee6f899b3f7786dac9a56c9f894be122de0
/Model/src/main/java/timer/integracao/model/viasoft/Itemestab.java
63ded54026ad089ce7da9c1652d91bbf169cfaf8
[]
no_license
StwartMassmann/TimerInt
https://github.com/StwartMassmann/TimerInt
b00671c775a09f1704cfcbe377719f43300370a3
278063f5526b47ccb08d906ba4497f4c6559451d
refs/heads/master
2019-01-21T18:06:07.879000
2018-04-27T01:03:05
2018-04-27T01:03:05
85,225,093
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package timer.integracao.model.viasoft; import java.io.Serializable; import java.util.Collection; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.NamedStoredProcedureQuery; import javax.persistence.OneToMany; import javax.persistence.ParameterMode; import javax.persistence.StoredProcedureParameter; import javax.persistence.Table; import javax.persistence.*; import javax.persistence.NamedStoredProcedureQueries; @Entity @Table(name = "ITEMESTAB") @IdClass(ItemestabPK.class) @NamedQueries({ @NamedQuery(name = "Itemestab.findAll", query = "SELECT i FROM Itemestab i"), @NamedQuery(name = "Itemestab.findByEstabitem", query = "SELECT i FROM Itemestab i where i.estabitem = :estabitem"), @NamedQuery(name = "Itemestab.findByEmpresa", query = "SELECT i FROM Itemestab i WHERE i.empresa = :empresa"), @NamedQuery(name = "Itemestab.findByItem", query = "SELECT i FROM Itemestab i WHERE i.item = :item") }) @NamedStoredProcedureQueries( { @NamedStoredProcedureQuery(name = "SALDOVTEX", procedureName = "SALDOVTEX", resultSetMappings = { "SaldoResultSetMapping" }, parameters = { @StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "ESTAB"), //@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "LOCAL"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "EMPRESA"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "ITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "ESTABITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "VTEXSKUID"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "LOCALVTEX"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Double.class, name = "QUANTIDADE") } ), @NamedStoredProcedureQuery(name = "SALDOVTEXPORITEM", procedureName = "SALDOVTEXPORITEM", resultSetMappings = { "SaldoResultSetMapping" }, parameters = { @StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "ESTAB"), @StoredProcedureParameter(mode = ParameterMode.IN, type = String.class, name = "PRODUTO"), //@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "LOCAL"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "EMPRESA"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "ITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "ESTABITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "VTEXSKUID"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "LOCALVTEX"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Double.class, name = "QUANTIDADE") } ) } ) @SqlResultSetMapping(name = "SaldoResultSetMapping", classes = @ConstructorResult( targetClass = ProcedureSaldoVtex.class, columns ={ @ColumnResult(name = "empresa", type =Integer.class), @ColumnResult(name = "item", type =String.class), @ColumnResult(name = "estabitem", type =Integer.class), @ColumnResult(name = "vtexskuid", type =Integer.class), @ColumnResult(name = "localvtex", type =String.class), @ColumnResult(name = "quantidade", type =Double.class) } ) ) public class Itemestab implements Entidade, Serializable { private static final long serialVersionUID = 1L; public Itemestab() { super(); } /* * @EmbeddedId private ItemestabPK itemestabpk; */ public Itemestab(Item item1, Pempresa pempresa) { super(); this.item1 = item1; this.pempresa = pempresa; } public Itemestab(Integer empresa, String item, Integer estabitem, Integer vtexskuid, double quantidade) { super(); this.estabitem = estabitem; this.item = item; this.empresa = empresa; this.vtexskuid = vtexskuid; this.quantidade = quantidade; } public Itemestab(int estabitem, String item, int empresa) { super(); this.estabitem = estabitem; this.item = item; this.empresa = empresa; } @Basic(optional = false) @Column(name = "ESTABITEM") private int estabitem; @Basic(optional = false) @Column(name = "ITEM") private String item; @Basic(optional = false) @Column(name = "EMPRESA") private int empresa; @OneToMany(mappedBy = "itemestab") private Collection<Pestoque> pestoque; @Id @JoinColumns({ @JoinColumn(name = "ESTABITEM", referencedColumnName = "EMPRESA", insertable = false, updatable = false), @JoinColumn(name = "ITEM", referencedColumnName = "ITEM", insertable = false, updatable = false) }) @ManyToOne(optional = false) private Item item1; @Id @JoinColumn(name = "EMPRESA", referencedColumnName = "EMPRESA", insertable = false, updatable = false) @ManyToOne(optional = false) private Pempresa pempresa; @Column(name = "VTEXID") private Integer vtexid; @Column(name = "VTEXSKUID") private Integer vtexskuid; @Column(name = "VTEXPRODUCTFAULT") private String vtexproductfault; @Column(name = "VTEXSKUFAULT") private String vtexskufault; @Column(name = "VTEXINVENTORYSYNC") private String vtexinventorysync; @Column(name = "VTEXPRICINGSYNC") private String vtexpricingsync; @Column(name = "USAECOMMERCE") private String usaecommerce; @Column(name = "VTEXIDSYNC") private String vtexidsync; @Column(name = "VTEXSKUIDSYNC") private String vtexskuidsync; @OneToMany(mappedBy = "itemestab") private List<Categoriaitem> categoriaitem; @Column(name = "QUANTIDADE") private double quantidade; @Column(name = "PRPROMOCAO") private double prpromocao; public double getPrpromocao() { return prpromocao; } public void setPrpromocao(double prpromocao) { this.prpromocao = prpromocao; } public int getEstabitem() { return estabitem; } public void setEstabitem(int estabitem) { this.estabitem = estabitem; } public String getItem() { return item; } public void setItem(String item) { this.item = item; } public int getEmpresa() { return empresa; } public void setEmpresa(int empresa) { this.empresa = empresa; } public Pempresa getPempresa() { return pempresa; } public void setPempresa(Pempresa pempresa) { this.pempresa = pempresa; } public Collection<Pestoque> getPestoque() { return pestoque; } public void setPestoque(Collection<Pestoque> pestoque) { this.pestoque = pestoque; } public List<Categoriaitem> getCategoriaitem() { return categoriaitem; } public void setCategoriaitem(List<Categoriaitem> categoriaitem) { this.categoriaitem = categoriaitem; } public Item getItem1() { return item1; } public void setItem1(Item item1) { this.item1 = item1; } public Integer getVtexid() { return vtexid; } public void setVtexid(Integer vtexid) { this.vtexid = vtexid; } public Integer getVtexskuid() { return vtexskuid; } public void setVtexskuid(Integer vtexskuid) { this.vtexskuid = vtexskuid; } public String getVtexproductfault() { return vtexproductfault; } public void setVtexproductfault(String vtexproductfault) { this.vtexproductfault = vtexproductfault; } public String getVtexskufault() { return vtexskufault; } public void setVtexskufault(String vtexskufault) { this.vtexskufault = vtexskufault; } public String getVtexinventorysync() { return vtexinventorysync; } public void setVtexinventorysync(String vtexinventorysync) { this.vtexinventorysync = vtexinventorysync; } public String getVtexpricingsync() { return vtexpricingsync; } public void setVtexpricingsync(String vtexpricingsync) { this.vtexpricingsync = vtexpricingsync; } public String getUsaecommerce() { return usaecommerce; } public void setUsaecommerce(String usaecommerce) { this.usaecommerce = usaecommerce; } public String getVtexidsync() { return vtexidsync; } public void setVtexidsync(String vtexidsync) { this.vtexidsync = vtexidsync; } public String getVtexskuidsync() { return vtexskuidsync; } public void setVtexskuidsync(String vtexskuidsync) { this.vtexskuidsync = vtexskuidsync; } public double getQuantidade() { return quantidade; } public void setQuantidade(double quantidade) { this.quantidade = quantidade; } }
UTF-8
Java
8,929
java
Itemestab.java
Java
[]
null
[]
package timer.integracao.model.viasoft; import java.io.Serializable; import java.util.Collection; import java.util.List; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.NamedStoredProcedureQuery; import javax.persistence.OneToMany; import javax.persistence.ParameterMode; import javax.persistence.StoredProcedureParameter; import javax.persistence.Table; import javax.persistence.*; import javax.persistence.NamedStoredProcedureQueries; @Entity @Table(name = "ITEMESTAB") @IdClass(ItemestabPK.class) @NamedQueries({ @NamedQuery(name = "Itemestab.findAll", query = "SELECT i FROM Itemestab i"), @NamedQuery(name = "Itemestab.findByEstabitem", query = "SELECT i FROM Itemestab i where i.estabitem = :estabitem"), @NamedQuery(name = "Itemestab.findByEmpresa", query = "SELECT i FROM Itemestab i WHERE i.empresa = :empresa"), @NamedQuery(name = "Itemestab.findByItem", query = "SELECT i FROM Itemestab i WHERE i.item = :item") }) @NamedStoredProcedureQueries( { @NamedStoredProcedureQuery(name = "SALDOVTEX", procedureName = "SALDOVTEX", resultSetMappings = { "SaldoResultSetMapping" }, parameters = { @StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "ESTAB"), //@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "LOCAL"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "EMPRESA"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "ITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "ESTABITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "VTEXSKUID"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "LOCALVTEX"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Double.class, name = "QUANTIDADE") } ), @NamedStoredProcedureQuery(name = "SALDOVTEXPORITEM", procedureName = "SALDOVTEXPORITEM", resultSetMappings = { "SaldoResultSetMapping" }, parameters = { @StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "ESTAB"), @StoredProcedureParameter(mode = ParameterMode.IN, type = String.class, name = "PRODUTO"), //@StoredProcedureParameter(mode = ParameterMode.IN, type = Integer.class, name = "LOCAL"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "EMPRESA"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "ITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "ESTABITEM"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Integer.class, name = "VTEXSKUID"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = String.class, name = "LOCALVTEX"), @StoredProcedureParameter(mode = ParameterMode.OUT, type = Double.class, name = "QUANTIDADE") } ) } ) @SqlResultSetMapping(name = "SaldoResultSetMapping", classes = @ConstructorResult( targetClass = ProcedureSaldoVtex.class, columns ={ @ColumnResult(name = "empresa", type =Integer.class), @ColumnResult(name = "item", type =String.class), @ColumnResult(name = "estabitem", type =Integer.class), @ColumnResult(name = "vtexskuid", type =Integer.class), @ColumnResult(name = "localvtex", type =String.class), @ColumnResult(name = "quantidade", type =Double.class) } ) ) public class Itemestab implements Entidade, Serializable { private static final long serialVersionUID = 1L; public Itemestab() { super(); } /* * @EmbeddedId private ItemestabPK itemestabpk; */ public Itemestab(Item item1, Pempresa pempresa) { super(); this.item1 = item1; this.pempresa = pempresa; } public Itemestab(Integer empresa, String item, Integer estabitem, Integer vtexskuid, double quantidade) { super(); this.estabitem = estabitem; this.item = item; this.empresa = empresa; this.vtexskuid = vtexskuid; this.quantidade = quantidade; } public Itemestab(int estabitem, String item, int empresa) { super(); this.estabitem = estabitem; this.item = item; this.empresa = empresa; } @Basic(optional = false) @Column(name = "ESTABITEM") private int estabitem; @Basic(optional = false) @Column(name = "ITEM") private String item; @Basic(optional = false) @Column(name = "EMPRESA") private int empresa; @OneToMany(mappedBy = "itemestab") private Collection<Pestoque> pestoque; @Id @JoinColumns({ @JoinColumn(name = "ESTABITEM", referencedColumnName = "EMPRESA", insertable = false, updatable = false), @JoinColumn(name = "ITEM", referencedColumnName = "ITEM", insertable = false, updatable = false) }) @ManyToOne(optional = false) private Item item1; @Id @JoinColumn(name = "EMPRESA", referencedColumnName = "EMPRESA", insertable = false, updatable = false) @ManyToOne(optional = false) private Pempresa pempresa; @Column(name = "VTEXID") private Integer vtexid; @Column(name = "VTEXSKUID") private Integer vtexskuid; @Column(name = "VTEXPRODUCTFAULT") private String vtexproductfault; @Column(name = "VTEXSKUFAULT") private String vtexskufault; @Column(name = "VTEXINVENTORYSYNC") private String vtexinventorysync; @Column(name = "VTEXPRICINGSYNC") private String vtexpricingsync; @Column(name = "USAECOMMERCE") private String usaecommerce; @Column(name = "VTEXIDSYNC") private String vtexidsync; @Column(name = "VTEXSKUIDSYNC") private String vtexskuidsync; @OneToMany(mappedBy = "itemestab") private List<Categoriaitem> categoriaitem; @Column(name = "QUANTIDADE") private double quantidade; @Column(name = "PRPROMOCAO") private double prpromocao; public double getPrpromocao() { return prpromocao; } public void setPrpromocao(double prpromocao) { this.prpromocao = prpromocao; } public int getEstabitem() { return estabitem; } public void setEstabitem(int estabitem) { this.estabitem = estabitem; } public String getItem() { return item; } public void setItem(String item) { this.item = item; } public int getEmpresa() { return empresa; } public void setEmpresa(int empresa) { this.empresa = empresa; } public Pempresa getPempresa() { return pempresa; } public void setPempresa(Pempresa pempresa) { this.pempresa = pempresa; } public Collection<Pestoque> getPestoque() { return pestoque; } public void setPestoque(Collection<Pestoque> pestoque) { this.pestoque = pestoque; } public List<Categoriaitem> getCategoriaitem() { return categoriaitem; } public void setCategoriaitem(List<Categoriaitem> categoriaitem) { this.categoriaitem = categoriaitem; } public Item getItem1() { return item1; } public void setItem1(Item item1) { this.item1 = item1; } public Integer getVtexid() { return vtexid; } public void setVtexid(Integer vtexid) { this.vtexid = vtexid; } public Integer getVtexskuid() { return vtexskuid; } public void setVtexskuid(Integer vtexskuid) { this.vtexskuid = vtexskuid; } public String getVtexproductfault() { return vtexproductfault; } public void setVtexproductfault(String vtexproductfault) { this.vtexproductfault = vtexproductfault; } public String getVtexskufault() { return vtexskufault; } public void setVtexskufault(String vtexskufault) { this.vtexskufault = vtexskufault; } public String getVtexinventorysync() { return vtexinventorysync; } public void setVtexinventorysync(String vtexinventorysync) { this.vtexinventorysync = vtexinventorysync; } public String getVtexpricingsync() { return vtexpricingsync; } public void setVtexpricingsync(String vtexpricingsync) { this.vtexpricingsync = vtexpricingsync; } public String getUsaecommerce() { return usaecommerce; } public void setUsaecommerce(String usaecommerce) { this.usaecommerce = usaecommerce; } public String getVtexidsync() { return vtexidsync; } public void setVtexidsync(String vtexidsync) { this.vtexidsync = vtexidsync; } public String getVtexskuidsync() { return vtexskuidsync; } public void setVtexskuidsync(String vtexskuidsync) { this.vtexskuidsync = vtexskuidsync; } public double getQuantidade() { return quantidade; } public void setQuantidade(double quantidade) { this.quantidade = quantidade; } }
8,929
0.715646
0.714414
317
26.167192
27.967091
118
false
false
0
0
0
0
0
0
1.555205
false
false
2
0a144b6675973c04a904300d198f7117e7eaf102
27,453,431,014,644
c6a6abcab0b70c68af2e6de7023653d957e509d4
/BittorrentClient/src/StudentWork/Message.java
3257a7d7345d2b514edec4295ec1dcfc83635f85
[]
no_license
MMXZ/RUBTClient
https://github.com/MMXZ/RUBTClient
03e223a1b1fe483efe44accd778800e7ad67e4f3
8a087dd96feac247f5e707dcb1a4d9dfd8d02ba2
refs/heads/master
2020-04-24T14:45:00.193000
2014-12-08T18:27:45
2014-12-08T18:27:45
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package StudentWork; import java.io.DataInputStream; import java.io.IOException; import java.net.Socket; import java.nio.ByteBuffer; /** * Message class; handles creation and parsing messages. * @author Imran * @author Joe Kennedy */ public class Message{ final static byte KEEP_ALIVE = -1; final static byte CHOKE = 0; final static byte UNCHOKE = 1; final static byte INTERESTED =2; final static byte NOT_INTERESTED = 3; final static byte HAVE = 4; final static byte BITFIELD = 5; final static byte REQUEST = 6; final static byte PIECE = 7; final static byte CANCEL = 8; final static int BLOCKLENGTH = 16384; //NOT THE PIECE SIZE SPECIFIED BY THE TORRENT. We will be downloading pieces in blocks of this length. int length; byte id; byte[] bfield; int have; //If piece or request int pieceIndex; int pieceOffset; byte[] block; //piece only int bLen; //request only //Default constructor. Makes empty message for received messages. /** * Creates empty Message object. Used for receiving messages. */ Message (){} //Initialized constructor. Makes a message to send. /** * @param msg_len length of message * @param msg_id int specifying message type. */ Message (int msg_len, byte msg_id){ length = msg_len; id = msg_id; } //For choke/unchoke /** * @return byte[] of message that chokes/unchokes peer */ byte[] sendChokeStatus(){ ByteBuffer ret = ByteBuffer.allocate(5); ret.putInt(length); ret.put(id); return ret.array(); } /** * @return byte[] of interest message */ byte[] sendInter(){ ByteBuffer ret = ByteBuffer.allocate(5); ret.putInt(length); ret.put(id); return ret.array(); } /** * @param bLen length of block wanted by peer * @return byte[] of request message */ byte[] sendReq(int bLen){ ByteBuffer ret = ByteBuffer.allocate(17); ret.putInt(length); ret.put(id); ret.putInt(pieceIndex); ret.putInt(pieceOffset); ret.putInt(bLen); return ret.array(); } /** * @param piece byte[] of data to send * @return byte[] of piece message to send */ byte[] sendPiece(byte[] piece){ ByteBuffer ret = ByteBuffer.allocate(13+piece.length); ret.putInt(length); ret.put(id); ret.putInt(pieceIndex); ret.putInt(pieceOffset); ret.put(piece); return ret.array(); } /** * @param din input stream to read message from * @return Message recieved * @throws IOException If message is bad or not received well, throw IOException */ Message receive(DataInputStream din, String peerID, Socket socket) throws IOException{ length = din.readInt(); if(length < 0 || length > 131081){ throw new IOException("Recieved bad massage length."); } if (length == 0){ //Keep alive code } id = din.readByte(); if(id >= 0 && id < 9){ // System.out.println("Recieved message of type " + id); }else{ //Bad throw new IOException("Recieved bad message ID."); } //Received have message if(id == HAVE){ have = din.readInt(); bfield = null; return this; } //Received bitfield if (id == BITFIELD){ bfield = new byte [length-1]; din.readFully(bfield); have = -1; return this; } if(id == REQUEST){ pieceIndex = din.readInt(); pieceOffset = din.readInt(); bLen = din.readInt(); return this; } //Received piece if (id == PIECE){ pieceIndex = din.readInt(); pieceOffset = din.readInt(); block = new byte[length-9]; din.readFully(block); return this; } return null; } }
UTF-8
Java
3,515
java
Message.java
Java
[ { "context": " handles creation and parsing messages.\n * @author Imran\n * @author Joe Kennedy\n */\npublic class Message{\n", "end": 212, "score": 0.9974328279495239, "start": 207, "tag": "NAME", "value": "Imran" }, { "context": " and parsing messages.\n * @author Imran\n * @author Joe Kennedy\n */\npublic class Message{\n\tfinal static byte KEEP", "end": 235, "score": 0.9998788833618164, "start": 224, "tag": "NAME", "value": "Joe Kennedy" } ]
null
[]
package StudentWork; import java.io.DataInputStream; import java.io.IOException; import java.net.Socket; import java.nio.ByteBuffer; /** * Message class; handles creation and parsing messages. * @author Imran * @author <NAME> */ public class Message{ final static byte KEEP_ALIVE = -1; final static byte CHOKE = 0; final static byte UNCHOKE = 1; final static byte INTERESTED =2; final static byte NOT_INTERESTED = 3; final static byte HAVE = 4; final static byte BITFIELD = 5; final static byte REQUEST = 6; final static byte PIECE = 7; final static byte CANCEL = 8; final static int BLOCKLENGTH = 16384; //NOT THE PIECE SIZE SPECIFIED BY THE TORRENT. We will be downloading pieces in blocks of this length. int length; byte id; byte[] bfield; int have; //If piece or request int pieceIndex; int pieceOffset; byte[] block; //piece only int bLen; //request only //Default constructor. Makes empty message for received messages. /** * Creates empty Message object. Used for receiving messages. */ Message (){} //Initialized constructor. Makes a message to send. /** * @param msg_len length of message * @param msg_id int specifying message type. */ Message (int msg_len, byte msg_id){ length = msg_len; id = msg_id; } //For choke/unchoke /** * @return byte[] of message that chokes/unchokes peer */ byte[] sendChokeStatus(){ ByteBuffer ret = ByteBuffer.allocate(5); ret.putInt(length); ret.put(id); return ret.array(); } /** * @return byte[] of interest message */ byte[] sendInter(){ ByteBuffer ret = ByteBuffer.allocate(5); ret.putInt(length); ret.put(id); return ret.array(); } /** * @param bLen length of block wanted by peer * @return byte[] of request message */ byte[] sendReq(int bLen){ ByteBuffer ret = ByteBuffer.allocate(17); ret.putInt(length); ret.put(id); ret.putInt(pieceIndex); ret.putInt(pieceOffset); ret.putInt(bLen); return ret.array(); } /** * @param piece byte[] of data to send * @return byte[] of piece message to send */ byte[] sendPiece(byte[] piece){ ByteBuffer ret = ByteBuffer.allocate(13+piece.length); ret.putInt(length); ret.put(id); ret.putInt(pieceIndex); ret.putInt(pieceOffset); ret.put(piece); return ret.array(); } /** * @param din input stream to read message from * @return Message recieved * @throws IOException If message is bad or not received well, throw IOException */ Message receive(DataInputStream din, String peerID, Socket socket) throws IOException{ length = din.readInt(); if(length < 0 || length > 131081){ throw new IOException("Recieved bad massage length."); } if (length == 0){ //Keep alive code } id = din.readByte(); if(id >= 0 && id < 9){ // System.out.println("Recieved message of type " + id); }else{ //Bad throw new IOException("Recieved bad message ID."); } //Received have message if(id == HAVE){ have = din.readInt(); bfield = null; return this; } //Received bitfield if (id == BITFIELD){ bfield = new byte [length-1]; din.readFully(bfield); have = -1; return this; } if(id == REQUEST){ pieceIndex = din.readInt(); pieceOffset = din.readInt(); bLen = din.readInt(); return this; } //Received piece if (id == PIECE){ pieceIndex = din.readInt(); pieceOffset = din.readInt(); block = new byte[length-9]; din.readFully(block); return this; } return null; } }
3,510
0.657753
0.64808
162
20.697531
19.526205
142
false
false
0
0
0
0
0
0
2.006173
false
false
2
b76f137cf871ec879f4f594c8604271cf00c5ffc
38,620,345,932,198
e957b37eca9ad55cf294886b385664f4de1e578b
/CatTocDiSalon_Mobile/RedisApp/app/src/main/java/com/phongnt/redisapp/requests/ApiUtils.java
9d947ca26a3e958e9f16a17f92f194cdeae6d1a0
[]
no_license
phongnt1997/BigProject_android_resfulAPI_c-
https://github.com/phongnt1997/BigProject_android_resfulAPI_c-
c03681f5872112be2d30763f990d84ac4229631d
f31ae67eb31550724525622fcd7724fe239c3d91
refs/heads/master
2020-04-09T01:49:03.428000
2018-12-01T07:35:06
2018-12-01T07:35:06
159,918,144
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.phongnt.redisapp.requests; public class ApiUtils { }
UTF-8
Java
66
java
ApiUtils.java
Java
[]
null
[]
package com.phongnt.redisapp.requests; public class ApiUtils { }
66
0.787879
0.787879
4
15.5
15.913831
38
false
false
0
0
0
0
0
0
0.25
false
false
2
fa83a897dde821ca0a66d2fae6cc01636e349df5
35,631,048,703,669
c554c41da5acbe29a76d9682da88e2b6095d3eb6
/src/ClassesExercise/model/Automovil.java
be1a9371d2ff7aaae8621fcade85f0cf3655b5f2
[]
no_license
LucasAgustinDiaz/javaExercises
https://github.com/LucasAgustinDiaz/javaExercises
9617f385f797f2dee247b136d73b138e4e5f7dd7
b377b852f25b014044bc200f319e4d862070fccd
refs/heads/main
2023-06-09T14:31:31.695000
2021-07-03T00:41:37
2021-07-03T00:41:37
382,487,080
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ClassesExercise.model; import Interface.IVehiculo; public class Automovil implements IVehiculo { private Double velocidad; private Double aceleracion; private Double anguloDeGiro; private String patente; private Integer peso; private Integer ruedas; public Automovil(Double velocidad, Double aceleracion, Double anguloDeGiro, String patente) { this.velocidad = velocidad; this.aceleracion = aceleracion; this.anguloDeGiro = anguloDeGiro; this.patente = patente; this.peso = 1000; this.ruedas = 4; } @Override public String toString() { return "Automovil{" + "velocidad=" + velocidad + ", aceleracion=" + aceleracion + ", anguloDeGiro=" + anguloDeGiro + ", patente='" + patente + '\'' + '}'; } @Override public void acelerar() { System.out.println("Auto acelerando a fondo"); } public Integer getPeso() { return peso; } public void setPeso(Integer peso) { this.peso = peso; } public Integer getRuedas() { return ruedas; } public void setRuedas(Integer ruedas) { this.ruedas = ruedas; } public String getPatente() { return patente; } public void setPatente(String patente) { this.patente = patente; } public Double getVelocidad() { return velocidad; } public void setVelocidad(Double velocidad) { this.velocidad = velocidad; } public Double getAceleracion() { return aceleracion; } public void setAceleracion(Double aceleracion) { this.aceleracion = aceleracion; } public Double getAnguloDeGiro() { return anguloDeGiro; } public void setAnguloDeGiro(Double anguloDeGiro) { this.anguloDeGiro = anguloDeGiro; } }
UTF-8
Java
1,927
java
Automovil.java
Java
[]
null
[]
package ClassesExercise.model; import Interface.IVehiculo; public class Automovil implements IVehiculo { private Double velocidad; private Double aceleracion; private Double anguloDeGiro; private String patente; private Integer peso; private Integer ruedas; public Automovil(Double velocidad, Double aceleracion, Double anguloDeGiro, String patente) { this.velocidad = velocidad; this.aceleracion = aceleracion; this.anguloDeGiro = anguloDeGiro; this.patente = patente; this.peso = 1000; this.ruedas = 4; } @Override public String toString() { return "Automovil{" + "velocidad=" + velocidad + ", aceleracion=" + aceleracion + ", anguloDeGiro=" + anguloDeGiro + ", patente='" + patente + '\'' + '}'; } @Override public void acelerar() { System.out.println("Auto acelerando a fondo"); } public Integer getPeso() { return peso; } public void setPeso(Integer peso) { this.peso = peso; } public Integer getRuedas() { return ruedas; } public void setRuedas(Integer ruedas) { this.ruedas = ruedas; } public String getPatente() { return patente; } public void setPatente(String patente) { this.patente = patente; } public Double getVelocidad() { return velocidad; } public void setVelocidad(Double velocidad) { this.velocidad = velocidad; } public Double getAceleracion() { return aceleracion; } public void setAceleracion(Double aceleracion) { this.aceleracion = aceleracion; } public Double getAnguloDeGiro() { return anguloDeGiro; } public void setAnguloDeGiro(Double anguloDeGiro) { this.anguloDeGiro = anguloDeGiro; } }
1,927
0.601453
0.598858
85
21.670588
18.934803
97
false
false
0
0
0
0
0
0
0.4
false
false
2
1903abad4f6c997bdca7f4f89df4c2a36e0da238
34,815,004,921,913
db9aa1c976bfc61ba1109788e27d83ae2e67747b
/OLD/Applet/src/view/Instructions.java
8f2d06115ad2e94c8aff7a04ec3eb7065442f296
[]
no_license
bgrosskleg/HomeAutomation
https://github.com/bgrosskleg/HomeAutomation
6cd59d627474baea42acba84d91644623601bc5f
50785b6ed4d8d2468c00cbe456832dec0dbc6f55
refs/heads/master
2021-01-13T01:49:38.708000
2014-04-07T21:01:40
2014-04-07T21:01:40
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package view; import java.awt.Dimension; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; public class Instructions extends JPanel { private static final long serialVersionUID = 1L; public Instructions() { super(); setPreferredSize(new Dimension(800,150)); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); JLabel instructions = new JLabel("<html><nobr>" + "Instructions <br>" + "Walls:&#09Click to define ends of walls. <br>" + "Regions:&#09Click to define vertices of a region. Return to initial vertex to complete region. <br>" + "Lights:&#09Click to place a light. <br>" + "Sensors:&#09Click to place a sensor. <br>" + "Erase:&#09Click to erase highlighted objects.</nobr></html>"); add(instructions); } }
UTF-8
Java
840
java
Instructions.java
Java
[]
null
[]
package view; import java.awt.Dimension; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; public class Instructions extends JPanel { private static final long serialVersionUID = 1L; public Instructions() { super(); setPreferredSize(new Dimension(800,150)); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); JLabel instructions = new JLabel("<html><nobr>" + "Instructions <br>" + "Walls:&#09Click to define ends of walls. <br>" + "Regions:&#09Click to define vertices of a region. Return to initial vertex to complete region. <br>" + "Lights:&#09Click to place a light. <br>" + "Sensors:&#09Click to place a sensor. <br>" + "Erase:&#09Click to erase highlighted objects.</nobr></html>"); add(instructions); } }
840
0.660714
0.640476
33
23.454546
25.54389
108
false
false
0
0
0
0
0
0
1.848485
false
false
2
44f99f995ad14a3f118ed912c3b6a0813bfb6b5c
28,424,093,584,470
83c3a27f73bc3ddcd4b01f923a741d1a6516464f
/src/sudoku/GenerarGrilla.java
5916bbee4086a604bbecf3616ab90837cc6dff6f
[]
no_license
sabrina-dohmen/sudoku
https://github.com/sabrina-dohmen/sudoku
0999ee83043b40decf48bdd8a57d6ddfb9cfca72
8a64dc4f3e45c7e7e98d60d32960f633ef04b49c
refs/heads/master
2023-09-04T23:34:30.253000
2021-11-16T12:46:26
2021-11-16T12:46:26
null
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package sudoku; import java.util.Random; import javax.swing.JOptionPane; // Clase de prueba para la creación de la grilla: // Crea la grilla de números para el juego Sudoku dependiendo al nivel de dificultad ingresado por el usuario public class GenerarGrilla { //public static void main(String[] args){ public void generarGrilla(){ int[][] grilla = new int[9][9]; int[] arreglo = new int[9]; int nivel=0; llenarArregloNumerosRandom(arreglo); llenarGrillaConArregloRandom(grilla, arreglo); cambiarOrdenColumnas(grilla); cambiarOrdenFilas(grilla); borrarNumerosAleatorios(grilla,nivel,arreglo); mostrarGrilla(grilla, nivel); } public int[] llenarArregloNumerosRandom(int[] arreglo){ Random random = new Random(); int posicion = 0; while(posicion < arreglo.length) { int numeroRandom = random.nextInt(9); if(numeroRandom==0){ numeroRandom=9; } boolean repetido = false; while(!repetido) { for(int i=0; i<posicion; i++) { if(numeroRandom == arreglo[i]) { repetido = true; break; } } if(!repetido) { arreglo[posicion] = numeroRandom; posicion++; } } } return arreglo; } public int[][] llenarGrillaConArregloRandom(int[][]grilla, int[]arregloUno){ int[] arregloDos = new int[9]; int[] arregloTres = new int[9]; for(int i=0;i<8;i++){ arregloDos[i]=arregloUno[i+1]; } arregloDos[8]=arregloUno[0]; for(int i=0;i<7;i++){ arregloTres[i]=arregloUno[i+2]; } arregloTres[7]=arregloUno[0]; arregloTres[8]=arregloUno[1]; cambiarColumnasCadaTres(grilla, arregloUno, 0); cambiarColumnasCadaTres(grilla, arregloDos, 3); cambiarColumnasCadaTres(grilla, arregloTres, 6); return grilla; } public int[][] cambiarColumnasCadaTres(int[][]grilla, int[]arreglo, int fila){ //agrega arregloUno a la primera fila de la grilla System.arraycopy(arreglo, 0, grilla[fila], 0, 9); for(int i=0; i<3; i++){ //agrega intercalado arregloUno a 2da fila grilla[fila+1][i]=arreglo[i+3]; grilla[fila+1][i+3]=arreglo[i+6]; grilla[fila+1][i+6]=arreglo[i]; //agrega intercalado arregloUno a 3ra fila grilla[fila+2][i]=arreglo[i+6]; grilla[fila+2][i+3]=arreglo[i]; grilla[fila+2][i+6]=arreglo[i+3]; } return grilla; } public int[][] cambiarOrdenFilas(int[][]grilla){ int[]arreglo=new int[9]; //System.arraycopy(grilla[0], 0, arreglo, 0, 9); //copiar primer fila de la grilla en el arreglo //System.arraycopy(grilla[2], 0, grilla[0], 0, 9); //copiar fila 2 a fila 0 de la grilla //System.arraycopy(arreglo, 0, grilla[2], 0, 9); //copiar arreglo en fila 2 de la grilla System.arraycopy(grilla[0], 0, arreglo, 0, 9); System.arraycopy(grilla[1], 0, grilla[0], 0, 9); System.arraycopy(arreglo, 0, grilla[1], 0, 9); //System.arraycopy(grilla[3], 0, arreglo, 0, 9); //System.arraycopy(grilla[5], 0, grilla[3], 0, 9); //System.arraycopy(arreglo, 0, grilla[5], 0, 9); System.arraycopy(grilla[5], 0, arreglo, 0, 9); System.arraycopy(grilla[4], 0, grilla[5], 0, 9); System.arraycopy(arreglo, 0, grilla[4], 0, 9); System.arraycopy(grilla[6], 0, arreglo, 0, 9); System.arraycopy(grilla[8], 0, grilla[6], 0, 9); System.arraycopy(arreglo, 0, grilla[8], 0, 9); return grilla; } public int[][] cambiarOrdenColumnas(int[][]grilla){ int[]arreglo=new int[9]; for(int i=0; i<9; i++){ arreglo[i]=grilla[i][0]; } //copiar primer columna de la grilla en el arreglo for(int i=0; i<9; i++){ grilla[i][0]=grilla[i][2]; } //copiar columna 2 a columna 0 de la grilla for(int i=0; i<9; i++){ grilla[i][2]=arreglo[i]; } //copiar arreglo en columna 2 de la grilla for(int i=0; i<9; i++){ arreglo[i]=grilla[i][0]; } for(int i=0; i<9; i++){ grilla[i][0]=grilla[i][1]; } for(int i=0; i<9; i++){ grilla[i][1]=arreglo[i]; } for(int i=0; i<9; i++){ arreglo[i]=grilla[i][3]; } for(int i=0; i<9; i++){ grilla[i][3]=grilla[i][5]; } for(int i=0; i<9; i++){ grilla[i][5]=arreglo[i]; } //for(int i=0; i<9; i++){ arreglo[i]=grilla[i][6]; } //for(int i=0; i<9; i++){ grilla[i][6]=grilla[i][8]; } //for(int i=0; i<9; i++){ grilla[i][8]=arreglo[i]; } return grilla; } public int[][] borrarNumerosAleatorios(int[][] grilla, int nivel, int[]arreglo){ int response = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el número de la dificultad de nivel" +"\n1. Fácil"+"\n2. Intermedio"+"\n3. Difícil")); switch (response){ case 1: nivel = 40; break; case 2: nivel = 50; break; case 3: nivel = 60; break; default: nivel = 30; } Random random = new Random(); for(int i=0; i<nivel; i++){ int n = random.nextInt(9); int m = random.nextInt(9); if(grilla[n][m] != 0){ grilla[n][m]=0; } else { i--; } } return grilla; } public void mostrarGrilla(int[][]grilla, int nivel){ for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { System.out.print(grilla[i][j] + " "); } System.out.println(); } System.out.println("--------------------------"); } }
UTF-8
Java
6,190
java
GenerarGrilla.java
Java
[]
null
[]
package sudoku; import java.util.Random; import javax.swing.JOptionPane; // Clase de prueba para la creación de la grilla: // Crea la grilla de números para el juego Sudoku dependiendo al nivel de dificultad ingresado por el usuario public class GenerarGrilla { //public static void main(String[] args){ public void generarGrilla(){ int[][] grilla = new int[9][9]; int[] arreglo = new int[9]; int nivel=0; llenarArregloNumerosRandom(arreglo); llenarGrillaConArregloRandom(grilla, arreglo); cambiarOrdenColumnas(grilla); cambiarOrdenFilas(grilla); borrarNumerosAleatorios(grilla,nivel,arreglo); mostrarGrilla(grilla, nivel); } public int[] llenarArregloNumerosRandom(int[] arreglo){ Random random = new Random(); int posicion = 0; while(posicion < arreglo.length) { int numeroRandom = random.nextInt(9); if(numeroRandom==0){ numeroRandom=9; } boolean repetido = false; while(!repetido) { for(int i=0; i<posicion; i++) { if(numeroRandom == arreglo[i]) { repetido = true; break; } } if(!repetido) { arreglo[posicion] = numeroRandom; posicion++; } } } return arreglo; } public int[][] llenarGrillaConArregloRandom(int[][]grilla, int[]arregloUno){ int[] arregloDos = new int[9]; int[] arregloTres = new int[9]; for(int i=0;i<8;i++){ arregloDos[i]=arregloUno[i+1]; } arregloDos[8]=arregloUno[0]; for(int i=0;i<7;i++){ arregloTres[i]=arregloUno[i+2]; } arregloTres[7]=arregloUno[0]; arregloTres[8]=arregloUno[1]; cambiarColumnasCadaTres(grilla, arregloUno, 0); cambiarColumnasCadaTres(grilla, arregloDos, 3); cambiarColumnasCadaTres(grilla, arregloTres, 6); return grilla; } public int[][] cambiarColumnasCadaTres(int[][]grilla, int[]arreglo, int fila){ //agrega arregloUno a la primera fila de la grilla System.arraycopy(arreglo, 0, grilla[fila], 0, 9); for(int i=0; i<3; i++){ //agrega intercalado arregloUno a 2da fila grilla[fila+1][i]=arreglo[i+3]; grilla[fila+1][i+3]=arreglo[i+6]; grilla[fila+1][i+6]=arreglo[i]; //agrega intercalado arregloUno a 3ra fila grilla[fila+2][i]=arreglo[i+6]; grilla[fila+2][i+3]=arreglo[i]; grilla[fila+2][i+6]=arreglo[i+3]; } return grilla; } public int[][] cambiarOrdenFilas(int[][]grilla){ int[]arreglo=new int[9]; //System.arraycopy(grilla[0], 0, arreglo, 0, 9); //copiar primer fila de la grilla en el arreglo //System.arraycopy(grilla[2], 0, grilla[0], 0, 9); //copiar fila 2 a fila 0 de la grilla //System.arraycopy(arreglo, 0, grilla[2], 0, 9); //copiar arreglo en fila 2 de la grilla System.arraycopy(grilla[0], 0, arreglo, 0, 9); System.arraycopy(grilla[1], 0, grilla[0], 0, 9); System.arraycopy(arreglo, 0, grilla[1], 0, 9); //System.arraycopy(grilla[3], 0, arreglo, 0, 9); //System.arraycopy(grilla[5], 0, grilla[3], 0, 9); //System.arraycopy(arreglo, 0, grilla[5], 0, 9); System.arraycopy(grilla[5], 0, arreglo, 0, 9); System.arraycopy(grilla[4], 0, grilla[5], 0, 9); System.arraycopy(arreglo, 0, grilla[4], 0, 9); System.arraycopy(grilla[6], 0, arreglo, 0, 9); System.arraycopy(grilla[8], 0, grilla[6], 0, 9); System.arraycopy(arreglo, 0, grilla[8], 0, 9); return grilla; } public int[][] cambiarOrdenColumnas(int[][]grilla){ int[]arreglo=new int[9]; for(int i=0; i<9; i++){ arreglo[i]=grilla[i][0]; } //copiar primer columna de la grilla en el arreglo for(int i=0; i<9; i++){ grilla[i][0]=grilla[i][2]; } //copiar columna 2 a columna 0 de la grilla for(int i=0; i<9; i++){ grilla[i][2]=arreglo[i]; } //copiar arreglo en columna 2 de la grilla for(int i=0; i<9; i++){ arreglo[i]=grilla[i][0]; } for(int i=0; i<9; i++){ grilla[i][0]=grilla[i][1]; } for(int i=0; i<9; i++){ grilla[i][1]=arreglo[i]; } for(int i=0; i<9; i++){ arreglo[i]=grilla[i][3]; } for(int i=0; i<9; i++){ grilla[i][3]=grilla[i][5]; } for(int i=0; i<9; i++){ grilla[i][5]=arreglo[i]; } //for(int i=0; i<9; i++){ arreglo[i]=grilla[i][6]; } //for(int i=0; i<9; i++){ grilla[i][6]=grilla[i][8]; } //for(int i=0; i<9; i++){ grilla[i][8]=arreglo[i]; } return grilla; } public int[][] borrarNumerosAleatorios(int[][] grilla, int nivel, int[]arreglo){ int response = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el número de la dificultad de nivel" +"\n1. Fácil"+"\n2. Intermedio"+"\n3. Difícil")); switch (response){ case 1: nivel = 40; break; case 2: nivel = 50; break; case 3: nivel = 60; break; default: nivel = 30; } Random random = new Random(); for(int i=0; i<nivel; i++){ int n = random.nextInt(9); int m = random.nextInt(9); if(grilla[n][m] != 0){ grilla[n][m]=0; } else { i--; } } return grilla; } public void mostrarGrilla(int[][]grilla, int nivel){ for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { System.out.print(grilla[i][j] + " "); } System.out.println(); } System.out.println("--------------------------"); } }
6,190
0.507842
0.478254
170
35.376472
25.154337
113
false
false
0
0
0
0
0
0
1.217647
false
false
2
d865f51ac0e02da64b9f44b18d579da508943805
18,210,661,353,311
f89e00c94a57f9474d9750f8f17e64117db75ec7
/app/src/main/java/com/kaissersoft/app/auctionsystem/ui/watchers/MoneyTextWatcher.java
1621bd9d50cba5c0c50e1c3ac77130e3b9a8605f
[]
no_license
eefret/AuctionSystem
https://github.com/eefret/AuctionSystem
b6d5a87b311b76591cdeb492d24e187db2d4efab
16cbef562919af198a436d5845183e36bb3fedb3
refs/heads/master
2016-09-05T23:54:18.383000
2015-08-08T12:58:04
2015-08-08T12:58:04
40,402,775
1
2
null
null
null
null
null
null
null
null
null
null
null
null
null
package com.kaissersoft.app.auctionsystem.ui.watchers; import android.text.Editable; import android.text.Selection; import android.text.TextWatcher; import android.widget.EditText; import java.lang.ref.WeakReference; import java.math.BigDecimal; import java.text.NumberFormat; /** * Created by eefret on 08/04/15. */ import java.util.Locale; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; public class MoneyTextWatcher implements TextWatcher { private EditText et; public MoneyTextWatcher(EditText et) { this.et = et; } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable s) { if (!s.toString().matches("^\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?$")) { String userInput = "" + s.toString().replaceAll("[^\\d]", ""); StringBuilder cashAmountBuilder = new StringBuilder(userInput); while (cashAmountBuilder.length() > 3 && cashAmountBuilder.charAt(0) == '0') { cashAmountBuilder.deleteCharAt(0); } while (cashAmountBuilder.length() < 3) { cashAmountBuilder.insert(0, '0'); } cashAmountBuilder.insert(cashAmountBuilder.length() - 2, '.'); et.removeTextChangedListener(this); et.setText(cashAmountBuilder.toString()); et.setTextKeepState("$" + cashAmountBuilder.toString()); Selection.setSelection(et.getText(), cashAmountBuilder.toString().length() + 1); et.addTextChangedListener(this); } } }
UTF-8
Java
1,788
java
MoneyTextWatcher.java
Java
[ { "context": "\nimport java.text.NumberFormat;\n\n/**\n * Created by eefret on 08/04/15.\n */\nimport java.util.Locale;\n\nimport", "end": 304, "score": 0.9872575402259827, "start": 298, "tag": "USERNAME", "value": "eefret" } ]
null
[]
package com.kaissersoft.app.auctionsystem.ui.watchers; import android.text.Editable; import android.text.Selection; import android.text.TextWatcher; import android.widget.EditText; import java.lang.ref.WeakReference; import java.math.BigDecimal; import java.text.NumberFormat; /** * Created by eefret on 08/04/15. */ import java.util.Locale; import android.text.Editable; import android.text.TextWatcher; import android.widget.EditText; public class MoneyTextWatcher implements TextWatcher { private EditText et; public MoneyTextWatcher(EditText et) { this.et = et; } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable s) { if (!s.toString().matches("^\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?$")) { String userInput = "" + s.toString().replaceAll("[^\\d]", ""); StringBuilder cashAmountBuilder = new StringBuilder(userInput); while (cashAmountBuilder.length() > 3 && cashAmountBuilder.charAt(0) == '0') { cashAmountBuilder.deleteCharAt(0); } while (cashAmountBuilder.length() < 3) { cashAmountBuilder.insert(0, '0'); } cashAmountBuilder.insert(cashAmountBuilder.length() - 2, '.'); et.removeTextChangedListener(this); et.setText(cashAmountBuilder.toString()); et.setTextKeepState("$" + cashAmountBuilder.toString()); Selection.setSelection(et.getText(), cashAmountBuilder.toString().length() + 1); et.addTextChangedListener(this); } } }
1,788
0.64038
0.627517
63
27.396826
27.922535
92
false
false
0
0
0
0
0
0
0.587302
false
false
2
ceda2c6e489fad87b3f78eb2cc1797c2b821014d
25,915,832,674,027
3dbcf51d85ee4346d0d6f09bc62dea406c072e23
/OntoNotesParallel/src/ims/coref/data/NE.java
27167a107765ecc3830780957a906b6e288c160b
[]
no_license
onenlper/bilingual-pronoun
https://github.com/onenlper/bilingual-pronoun
32386fe9c30d130b8501bb60f1dd3b749563b57c
91f74d84297502c092165c6089064aa3b3b1b877
refs/heads/master
2021-01-10T19:57:55.110000
2014-03-12T00:37:05
2014-03-12T00:37:05
34,142,811
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package ims.coref.data; import java.util.ArrayList; import java.util.List; public class NE { int b; int e; Sentence s; String label; public NE(int beg,int end,Sentence s,String label){ b=beg; e=end; this.s=s; this.label=label; } public String getLabel(){ return label; } public Span getSpan(){ return s.getSpan(b, e); } public static List<NE> getNEs(String[] neCol, Sentence s) { List<NE> n=new ArrayList<NE>(); String curLbl=null; int begIndex=-1; for(int i=1;i<neCol.length;++i){ if(neCol[i].equals("*") || neCol[i].equals("-")) continue; else if(neCol[i].startsWith("(")){ if(curLbl!=null) throw new RuntimeException("Nested NEs. Shouldn't happen"); String label=neCol[i].substring(1, neCol[i].length()-1); if(neCol[i].endsWith(")")){ n.add(new NE(i,i,s,label)); } else { begIndex=i; curLbl=label; } } else if(neCol[i].equals("*)")){ n.add(new NE(begIndex,i,s,curLbl)); begIndex=-1; curLbl=null; } else { throw new RuntimeException("Failed to parse NE: "+neCol[i]); } } return n; } public String toString(){ StringBuilder sb=new StringBuilder(label).append(": '"); for(int i=b;i<=e;++i) sb.append(s.forms[i]).append(' '); return sb.append("'").toString(); } }
UTF-8
Java
1,297
java
NE.java
Java
[]
null
[]
package ims.coref.data; import java.util.ArrayList; import java.util.List; public class NE { int b; int e; Sentence s; String label; public NE(int beg,int end,Sentence s,String label){ b=beg; e=end; this.s=s; this.label=label; } public String getLabel(){ return label; } public Span getSpan(){ return s.getSpan(b, e); } public static List<NE> getNEs(String[] neCol, Sentence s) { List<NE> n=new ArrayList<NE>(); String curLbl=null; int begIndex=-1; for(int i=1;i<neCol.length;++i){ if(neCol[i].equals("*") || neCol[i].equals("-")) continue; else if(neCol[i].startsWith("(")){ if(curLbl!=null) throw new RuntimeException("Nested NEs. Shouldn't happen"); String label=neCol[i].substring(1, neCol[i].length()-1); if(neCol[i].endsWith(")")){ n.add(new NE(i,i,s,label)); } else { begIndex=i; curLbl=label; } } else if(neCol[i].equals("*)")){ n.add(new NE(begIndex,i,s,curLbl)); begIndex=-1; curLbl=null; } else { throw new RuntimeException("Failed to parse NE: "+neCol[i]); } } return n; } public String toString(){ StringBuilder sb=new StringBuilder(label).append(": '"); for(int i=b;i<=e;++i) sb.append(s.forms[i]).append(' '); return sb.append("'").toString(); } }
1,297
0.611411
0.607556
62
19.919355
17.823778
64
false
false
0
0
0
0
0
0
2.806452
false
false
2
da9d2ff1b000f3b79c0fa279be7f2668dac72063
30,099,130,880,800
0b01a5963db6ad16594b246d129866a46e0afe2c
/src/xin/suttonprog/dp/_70ClimbingStairs.java
d9ff746dba8dbef4fbff6cc2d87806843a364511
[]
no_license
SuttonFd/Leetcode
https://github.com/SuttonFd/Leetcode
47582618b54fd7a916bc1e433d88fd869a76c5ac
fe2538fadefd7c66c8ffdc6742475b143a3bfd38
refs/heads/master
2020-04-27T16:35:51.969000
2019-05-25T07:59:36
2019-05-25T07:59:36
174,487,187
0
0
null
null
null
null
null
null
null
null
null
null
null
null
null
package xin.suttonprog.dp; /** * @author codingZhengsz * @since 2019-03-23 22:10 **/ public class _70ClimbingStairs { /** * 使用递归的方式,每次有两个选择,两个选择之后是新的两次选择 * 超出时间限制,无法使用 */ public int climbStairs_Recursive(int n) { if(n == 1) { return 1; } if(n == 2) { return 2; } return climbStairs_Recursive(n-1) + climbStairs_Recursive(n-2); } /** * 使用动态规划的方法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.4 MB, less than 14.76% */ public int climbStairs_dp1(int n){ int[] ans = new int[n+1]; ans[0] = 1; ans[1] = 1; for(int i=2;i<=n;i++){ ans[i] = ans[i-1] + ans[i-2]; } return ans[n]; } /** * 动态规划方法的节省空间算法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.3 MB, less than 44.56% */ public int climbStairs_dp2(int n){ int[] ans = new int[3]; ans[0] = 1; ans[1] = 1; for(int i=2;i<=n;i++){ ans[i%3] = ans[(i-1)%3] + ans[(i-2)%3]; } return ans[n%3]; } /** * 动态规划方法的节省空间算法的新解法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.4 MB, less than 32.13% */ public int climbStairs_dp3(int n) { if(n < 4) return n; int a,b = 3,c = 5; for(int i= 5;i <= n; i++) { a = c; c = b + c; b = a; } return c; } public static void main(String[] args) { System.out.println(new _70ClimbingStairs().climbStairs_dp3(3)); } }
UTF-8
Java
1,774
java
_70ClimbingStairs.java
Java
[ { "context": "package xin.suttonprog.dp;\n\n/**\n * @author codingZhengsz\n * @since 2019-03-23 22:10\n **/\npublic class _70C", "end": 56, "score": 0.9982264041900635, "start": 43, "tag": "USERNAME", "value": "codingZhengsz" } ]
null
[]
package xin.suttonprog.dp; /** * @author codingZhengsz * @since 2019-03-23 22:10 **/ public class _70ClimbingStairs { /** * 使用递归的方式,每次有两个选择,两个选择之后是新的两次选择 * 超出时间限制,无法使用 */ public int climbStairs_Recursive(int n) { if(n == 1) { return 1; } if(n == 2) { return 2; } return climbStairs_Recursive(n-1) + climbStairs_Recursive(n-2); } /** * 使用动态规划的方法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.4 MB, less than 14.76% */ public int climbStairs_dp1(int n){ int[] ans = new int[n+1]; ans[0] = 1; ans[1] = 1; for(int i=2;i<=n;i++){ ans[i] = ans[i-1] + ans[i-2]; } return ans[n]; } /** * 动态规划方法的节省空间算法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.3 MB, less than 44.56% */ public int climbStairs_dp2(int n){ int[] ans = new int[3]; ans[0] = 1; ans[1] = 1; for(int i=2;i<=n;i++){ ans[i%3] = ans[(i-1)%3] + ans[(i-2)%3]; } return ans[n%3]; } /** * 动态规划方法的节省空间算法的新解法 * Runtime: 2 ms, faster than 87.84% * Memory Usage: 36.4 MB, less than 32.13% */ public int climbStairs_dp3(int n) { if(n < 4) return n; int a,b = 3,c = 5; for(int i= 5;i <= n; i++) { a = c; c = b + c; b = a; } return c; } public static void main(String[] args) { System.out.println(new _70ClimbingStairs().climbStairs_dp3(3)); } }
1,774
0.462871
0.409035
73
21.136986
16.596184
71
false
false
0
0
0
0
0
0
0.479452
false
false
2