id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
148,900
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/classloader/ClassLoaderWithRegistry.java
|
ClassLoaderWithRegistry.isIncluded
|
private boolean isIncluded(String _fqcn) {
if (includePackageNames.contains(_fqcn)) {
return true;
}
String packageName = _fqcn.substring(0, _fqcn.lastIndexOf('.') + 1);
for (String str : includePackageNames) {
if (packageName.startsWith(str)) {
return true;
}
}
return false;
}
|
java
|
private boolean isIncluded(String _fqcn) {
if (includePackageNames.contains(_fqcn)) {
return true;
}
String packageName = _fqcn.substring(0, _fqcn.lastIndexOf('.') + 1);
for (String str : includePackageNames) {
if (packageName.startsWith(str)) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"isIncluded",
"(",
"String",
"_fqcn",
")",
"{",
"if",
"(",
"includePackageNames",
".",
"contains",
"(",
"_fqcn",
")",
")",
"{",
"return",
"true",
";",
"}",
"String",
"packageName",
"=",
"_fqcn",
".",
"substring",
"(",
"0",
",",
"_fqcn",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"for",
"(",
"String",
"str",
":",
"includePackageNames",
")",
"{",
"if",
"(",
"packageName",
".",
"startsWith",
"(",
"str",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if a certain class is included.
@param _fqcn
@return
|
[
"Check",
"if",
"a",
"certain",
"class",
"is",
"included",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/classloader/ClassLoaderWithRegistry.java#L75-L88
|
148,901
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/SliceDefinition.java
|
SliceDefinition.add
|
public boolean add(TemporalExtendedPropositionDefinition tepd) {
if (tepd != null) {
boolean result = this.abstractedFrom.add(tepd);
if (result) {
recalculateChildren();
}
return result;
} else {
return false;
}
}
|
java
|
public boolean add(TemporalExtendedPropositionDefinition tepd) {
if (tepd != null) {
boolean result = this.abstractedFrom.add(tepd);
if (result) {
recalculateChildren();
}
return result;
} else {
return false;
}
}
|
[
"public",
"boolean",
"add",
"(",
"TemporalExtendedPropositionDefinition",
"tepd",
")",
"{",
"if",
"(",
"tepd",
"!=",
"null",
")",
"{",
"boolean",
"result",
"=",
"this",
".",
"abstractedFrom",
".",
"add",
"(",
"tepd",
")",
";",
"if",
"(",
"result",
")",
"{",
"recalculateChildren",
"(",
")",
";",
"}",
"return",
"result",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Adds a proposition id from which this slice definition is abstracted.
@param propId
a proposition id <code>String</code> for an abstract
parameter definition.
|
[
"Adds",
"a",
"proposition",
"id",
"from",
"which",
"this",
"slice",
"definition",
"is",
"abstracted",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/SliceDefinition.java#L141-L151
|
148,902
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/CompressionUtil.java
|
CompressionUtil.extractFileGzip
|
public static File extractFileGzip(String _compressedFile, String _outputFileName) {
return decompress(CompressionMethod.GZIP, _compressedFile, _outputFileName);
}
|
java
|
public static File extractFileGzip(String _compressedFile, String _outputFileName) {
return decompress(CompressionMethod.GZIP, _compressedFile, _outputFileName);
}
|
[
"public",
"static",
"File",
"extractFileGzip",
"(",
"String",
"_compressedFile",
",",
"String",
"_outputFileName",
")",
"{",
"return",
"decompress",
"(",
"CompressionMethod",
".",
"GZIP",
",",
"_compressedFile",
",",
"_outputFileName",
")",
";",
"}"
] |
Extracts a GZIP compressed file to the given outputfile.
@param _compressedFile
@param _outputFileName
@return file-object with outputfile or null on any error.
|
[
"Extracts",
"a",
"GZIP",
"compressed",
"file",
"to",
"the",
"given",
"outputfile",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompressionUtil.java#L42-L44
|
148,903
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/CompressionUtil.java
|
CompressionUtil.compressFileGzip
|
public static File compressFileGzip(String _sourceFile, String _outputFileName) {
return compress(CompressionMethod.GZIP, _sourceFile, _outputFileName);
}
|
java
|
public static File compressFileGzip(String _sourceFile, String _outputFileName) {
return compress(CompressionMethod.GZIP, _sourceFile, _outputFileName);
}
|
[
"public",
"static",
"File",
"compressFileGzip",
"(",
"String",
"_sourceFile",
",",
"String",
"_outputFileName",
")",
"{",
"return",
"compress",
"(",
"CompressionMethod",
".",
"GZIP",
",",
"_sourceFile",
",",
"_outputFileName",
")",
";",
"}"
] |
Compresses the given file with GZIP and writes the compressed file to outputFileName.
@param _sourceFile
@param _outputFileName
@return new File object with the compressed file or null on error
|
[
"Compresses",
"the",
"given",
"file",
"with",
"GZIP",
"and",
"writes",
"the",
"compressed",
"file",
"to",
"outputFileName",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/CompressionUtil.java#L52-L54
|
148,904
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UReport.java
|
UReport.title
|
public static void title(Writer writer, String title) throws IOException {
if (title == null || title.isEmpty()) {
return;
}
String out = String.format("%s\n%s\n\n", title,
Stream.generate(() -> "=").limit(title.length()).collect(Collectors.joining()));
writer.write(out);
}
|
java
|
public static void title(Writer writer, String title) throws IOException {
if (title == null || title.isEmpty()) {
return;
}
String out = String.format("%s\n%s\n\n", title,
Stream.generate(() -> "=").limit(title.length()).collect(Collectors.joining()));
writer.write(out);
}
|
[
"public",
"static",
"void",
"title",
"(",
"Writer",
"writer",
",",
"String",
"title",
")",
"throws",
"IOException",
"{",
"if",
"(",
"title",
"==",
"null",
"||",
"title",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"out",
"=",
"String",
".",
"format",
"(",
"\"%s\\n%s\\n\\n\"",
",",
"title",
",",
"Stream",
".",
"generate",
"(",
"(",
")",
"->",
"\"=\"",
")",
".",
"limit",
"(",
"title",
".",
"length",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
")",
")",
")",
";",
"writer",
".",
"write",
"(",
"out",
")",
";",
"}"
] |
Simple helper method that prints the specified title, underlined with '='
characters.
@param writer
the writer to write the title to.
@param title
the title to print (null or empty titles will be ignored).
@throws IOException
if the writer fails.
|
[
"Simple",
"helper",
"method",
"that",
"prints",
"the",
"specified",
"title",
"underlined",
"with",
"=",
"characters",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UReport.java#L107-L114
|
148,905
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Ray3D.java
|
Ray3D.VecToPoint
|
private Point3D VecToPoint(final Vec3DFloat vector) {
return new Point3D(vector.getX(), vector.getY(), vector.getZ());
}
|
java
|
private Point3D VecToPoint(final Vec3DFloat vector) {
return new Point3D(vector.getX(), vector.getY(), vector.getZ());
}
|
[
"private",
"Point3D",
"VecToPoint",
"(",
"final",
"Vec3DFloat",
"vector",
")",
"{",
"return",
"new",
"Point3D",
"(",
"vector",
".",
"getX",
"(",
")",
",",
"vector",
".",
"getY",
"(",
")",
",",
"vector",
".",
"getZ",
"(",
")",
")",
";",
"}"
] |
Transforms a Vec3DFloat object to a Point3D object.
@param vector The Vec3DFloat object.
@return The transformed Point3D.
|
[
"Transforms",
"a",
"Vec3DFloat",
"object",
"to",
"a",
"Point3D",
"object",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Ray3D.java#L57-L59
|
148,906
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Ray3D.java
|
Ray3D.update
|
public void update(final Ray3DFloat ray) {
final Point3D origin = VecToPoint(ray.getOrigin());
final Point3D direction = VecToPoint(ray.getDirection());
final Point3D end = origin.add(direction.normalize().multiply(rayLength));
super.setStartEndPoints(origin, end);
}
|
java
|
public void update(final Ray3DFloat ray) {
final Point3D origin = VecToPoint(ray.getOrigin());
final Point3D direction = VecToPoint(ray.getDirection());
final Point3D end = origin.add(direction.normalize().multiply(rayLength));
super.setStartEndPoints(origin, end);
}
|
[
"public",
"void",
"update",
"(",
"final",
"Ray3DFloat",
"ray",
")",
"{",
"final",
"Point3D",
"origin",
"=",
"VecToPoint",
"(",
"ray",
".",
"getOrigin",
"(",
")",
")",
";",
"final",
"Point3D",
"direction",
"=",
"VecToPoint",
"(",
"ray",
".",
"getDirection",
"(",
")",
")",
";",
"final",
"Point3D",
"end",
"=",
"origin",
".",
"add",
"(",
"direction",
".",
"normalize",
"(",
")",
".",
"multiply",
"(",
"rayLength",
")",
")",
";",
"super",
".",
"setStartEndPoints",
"(",
"origin",
",",
"end",
")",
";",
"}"
] |
Updates the ray orientation and position to the specified data.
@param ray Ray3DFloat object defining the placement data of the ray.
|
[
"Updates",
"the",
"ray",
"orientation",
"and",
"position",
"to",
"the",
"specified",
"data",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Ray3D.java#L87-L92
|
148,907
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ProtegeKnowledgeSourceBackend.java
|
ProtegeKnowledgeSourceBackend.readClass
|
private Cls readClass(String name, String superClass)
throws KnowledgeSourceReadException {
Cls cls = this.cm.getCls(name);
Cls superCls = this.cm.getCls(superClass);
if (cls != null && cls.hasSuperclass(superCls)) {
return cls;
} else {
return null;
}
}
|
java
|
private Cls readClass(String name, String superClass)
throws KnowledgeSourceReadException {
Cls cls = this.cm.getCls(name);
Cls superCls = this.cm.getCls(superClass);
if (cls != null && cls.hasSuperclass(superCls)) {
return cls;
} else {
return null;
}
}
|
[
"private",
"Cls",
"readClass",
"(",
"String",
"name",
",",
"String",
"superClass",
")",
"throws",
"KnowledgeSourceReadException",
"{",
"Cls",
"cls",
"=",
"this",
".",
"cm",
".",
"getCls",
"(",
"name",
")",
";",
"Cls",
"superCls",
"=",
"this",
".",
"cm",
".",
"getCls",
"(",
"superClass",
")",
";",
"if",
"(",
"cls",
"!=",
"null",
"&&",
"cls",
".",
"hasSuperclass",
"(",
"superCls",
")",
")",
"{",
"return",
"cls",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns the Cls from Protege if a matching Cls is found with the given
ancestor
@param name Name of the class to fetch
@param superClass name of the anscestor
@return A Cls containing the given class name
@throws KnowledgeSourceReadException
|
[
"Returns",
"the",
"Cls",
"from",
"Protege",
"if",
"a",
"matching",
"Cls",
"is",
"found",
"with",
"the",
"given",
"ancestor"
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ProtegeKnowledgeSourceBackend.java#L222-L231
|
148,908
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/TLSAValidator.java
|
TLSAValidator.validateTLSA
|
public boolean validateTLSA(URL url) throws ValidSelfSignedCertException {
TLSARecord tlsaRecord = getTLSARecord(url);
if(tlsaRecord == null) {
return false;
}
List<Certificate> certs = getUrlCerts(url);
if(certs == null || certs.size() == 0) {
return false;
}
// Get Cert Matching Selector and Matching Type Fields
Certificate matchingCert = getMatchingCert(tlsaRecord, certs);
if (matchingCert == null) {
return false;
}
// Check for single cert / self-signed and validate
switch(tlsaRecord.getCertificateUsage()) {
case TLSARecord.CertificateUsage.CA_CONSTRAINT:
if(isValidCertChain(matchingCert, certs) && matchingCert != certs.get(0)) {
return true;
}
break;
case TLSARecord.CertificateUsage.SERVICE_CERTIFICATE_CONSTRAINT:
if(isValidCertChain(matchingCert, certs) && matchingCert == certs.get(0)) {
return true;
}
break;
case TLSARecord.CertificateUsage.TRUST_ANCHOR_ASSERTION:
if(isValidCertChain(certs.get(0), certs) && matchingCert == certs.get(certs.size() - 1)) {
throw new ValidSelfSignedCertException(matchingCert);
}
break;
case TLSARecord.CertificateUsage.DOMAIN_ISSUED_CERTIFICATE:
// We've found a matching cert that does not require PKIX Chain Validation [RFC6698]
throw new ValidSelfSignedCertException(matchingCert);
}
return false;
}
|
java
|
public boolean validateTLSA(URL url) throws ValidSelfSignedCertException {
TLSARecord tlsaRecord = getTLSARecord(url);
if(tlsaRecord == null) {
return false;
}
List<Certificate> certs = getUrlCerts(url);
if(certs == null || certs.size() == 0) {
return false;
}
// Get Cert Matching Selector and Matching Type Fields
Certificate matchingCert = getMatchingCert(tlsaRecord, certs);
if (matchingCert == null) {
return false;
}
// Check for single cert / self-signed and validate
switch(tlsaRecord.getCertificateUsage()) {
case TLSARecord.CertificateUsage.CA_CONSTRAINT:
if(isValidCertChain(matchingCert, certs) && matchingCert != certs.get(0)) {
return true;
}
break;
case TLSARecord.CertificateUsage.SERVICE_CERTIFICATE_CONSTRAINT:
if(isValidCertChain(matchingCert, certs) && matchingCert == certs.get(0)) {
return true;
}
break;
case TLSARecord.CertificateUsage.TRUST_ANCHOR_ASSERTION:
if(isValidCertChain(certs.get(0), certs) && matchingCert == certs.get(certs.size() - 1)) {
throw new ValidSelfSignedCertException(matchingCert);
}
break;
case TLSARecord.CertificateUsage.DOMAIN_ISSUED_CERTIFICATE:
// We've found a matching cert that does not require PKIX Chain Validation [RFC6698]
throw new ValidSelfSignedCertException(matchingCert);
}
return false;
}
|
[
"public",
"boolean",
"validateTLSA",
"(",
"URL",
"url",
")",
"throws",
"ValidSelfSignedCertException",
"{",
"TLSARecord",
"tlsaRecord",
"=",
"getTLSARecord",
"(",
"url",
")",
";",
"if",
"(",
"tlsaRecord",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"List",
"<",
"Certificate",
">",
"certs",
"=",
"getUrlCerts",
"(",
"url",
")",
";",
"if",
"(",
"certs",
"==",
"null",
"||",
"certs",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// Get Cert Matching Selector and Matching Type Fields",
"Certificate",
"matchingCert",
"=",
"getMatchingCert",
"(",
"tlsaRecord",
",",
"certs",
")",
";",
"if",
"(",
"matchingCert",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// Check for single cert / self-signed and validate",
"switch",
"(",
"tlsaRecord",
".",
"getCertificateUsage",
"(",
")",
")",
"{",
"case",
"TLSARecord",
".",
"CertificateUsage",
".",
"CA_CONSTRAINT",
":",
"if",
"(",
"isValidCertChain",
"(",
"matchingCert",
",",
"certs",
")",
"&&",
"matchingCert",
"!=",
"certs",
".",
"get",
"(",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"case",
"TLSARecord",
".",
"CertificateUsage",
".",
"SERVICE_CERTIFICATE_CONSTRAINT",
":",
"if",
"(",
"isValidCertChain",
"(",
"matchingCert",
",",
"certs",
")",
"&&",
"matchingCert",
"==",
"certs",
".",
"get",
"(",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"break",
";",
"case",
"TLSARecord",
".",
"CertificateUsage",
".",
"TRUST_ANCHOR_ASSERTION",
":",
"if",
"(",
"isValidCertChain",
"(",
"certs",
".",
"get",
"(",
"0",
")",
",",
"certs",
")",
"&&",
"matchingCert",
"==",
"certs",
".",
"get",
"(",
"certs",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
"{",
"throw",
"new",
"ValidSelfSignedCertException",
"(",
"matchingCert",
")",
";",
"}",
"break",
";",
"case",
"TLSARecord",
".",
"CertificateUsage",
".",
"DOMAIN_ISSUED_CERTIFICATE",
":",
"// We've found a matching cert that does not require PKIX Chain Validation [RFC6698]",
"throw",
"new",
"ValidSelfSignedCertException",
"(",
"matchingCert",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Validates a URL's TLSA Record
If the TLSA Record for the URL does not exist, validation fails.
@param url URL Root to Generate TLSA record query
@return TLSA Validated or not (boolean)
@throws ValidSelfSignedCertException Return Matching Self Signed Cert for Inclusion into CertStore
|
[
"Validates",
"a",
"URL",
"s",
"TLSA",
"Record"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L69-L110
|
148,909
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/TLSAValidator.java
|
TLSAValidator.isValidCertChain
|
public boolean isValidCertChain(Certificate targetCert, List<Certificate> certs) {
try {
KeyStore cacerts = this.caCertService.getCaCertKeystore();
for (Certificate cert : certs) {
if (cert == targetCert) continue;
cacerts.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return this.chainValidator.validateKeyChain((X509Certificate) targetCert, cacerts);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
|
java
|
public boolean isValidCertChain(Certificate targetCert, List<Certificate> certs) {
try {
KeyStore cacerts = this.caCertService.getCaCertKeystore();
for (Certificate cert : certs) {
if (cert == targetCert) continue;
cacerts.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return this.chainValidator.validateKeyChain((X509Certificate) targetCert, cacerts);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
|
[
"public",
"boolean",
"isValidCertChain",
"(",
"Certificate",
"targetCert",
",",
"List",
"<",
"Certificate",
">",
"certs",
")",
"{",
"try",
"{",
"KeyStore",
"cacerts",
"=",
"this",
".",
"caCertService",
".",
"getCaCertKeystore",
"(",
")",
";",
"for",
"(",
"Certificate",
"cert",
":",
"certs",
")",
"{",
"if",
"(",
"cert",
"==",
"targetCert",
")",
"continue",
";",
"cacerts",
".",
"setCertificateEntry",
"(",
"(",
"(",
"X509Certificate",
")",
"cert",
")",
".",
"getSubjectDN",
"(",
")",
".",
"toString",
"(",
")",
",",
"cert",
")",
";",
"}",
"return",
"this",
".",
"chainValidator",
".",
"validateKeyChain",
"(",
"(",
"X509Certificate",
")",
"targetCert",
",",
"cacerts",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Validate whether the target cert is valid using the CA Certificate KeyStore and any included intermediate certificates
@param targetCert Target certificate to validate
@param certs Intermediate certificates to using during validation
@return isCertChainValid?
|
[
"Validate",
"whether",
"the",
"target",
"cert",
"is",
"valid",
"using",
"the",
"CA",
"Certificate",
"KeyStore",
"and",
"any",
"included",
"intermediate",
"certificates"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L118-L131
|
148,910
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/TLSAValidator.java
|
TLSAValidator.getMatchingCert
|
public Certificate getMatchingCert(TLSARecord tlsaRecord, List<Certificate> certs) {
for (Certificate cert : certs) {
byte[] digestMatch = new byte[0];
byte[] selectorData = new byte[0];
try {
// Get Selector Value
switch (tlsaRecord.getSelector()) {
case TLSARecord.Selector.FULL_CERTIFICATE:
selectorData = cert.getEncoded();
break;
case TLSARecord.Selector.SUBJECT_PUBLIC_KEY_INFO:
selectorData = cert.getPublicKey().getEncoded();
break;
}
// Validate Matching Type
switch (tlsaRecord.getMatchingType()) {
case TLSARecord.MatchingType.EXACT:
digestMatch = selectorData;
break;
case TLSARecord.MatchingType.SHA256:
digestMatch = MessageDigest.getInstance("SHA-256").digest(selectorData);
break;
case TLSARecord.MatchingType.SHA512:
digestMatch = MessageDigest.getInstance("SHA-512").digest(selectorData);
break;
}
} catch (Exception e) {
e.printStackTrace();
}
if (Arrays.equals(digestMatch, tlsaRecord.getCertificateAssociationData())) {
return cert;
}
}
return null;
}
|
java
|
public Certificate getMatchingCert(TLSARecord tlsaRecord, List<Certificate> certs) {
for (Certificate cert : certs) {
byte[] digestMatch = new byte[0];
byte[] selectorData = new byte[0];
try {
// Get Selector Value
switch (tlsaRecord.getSelector()) {
case TLSARecord.Selector.FULL_CERTIFICATE:
selectorData = cert.getEncoded();
break;
case TLSARecord.Selector.SUBJECT_PUBLIC_KEY_INFO:
selectorData = cert.getPublicKey().getEncoded();
break;
}
// Validate Matching Type
switch (tlsaRecord.getMatchingType()) {
case TLSARecord.MatchingType.EXACT:
digestMatch = selectorData;
break;
case TLSARecord.MatchingType.SHA256:
digestMatch = MessageDigest.getInstance("SHA-256").digest(selectorData);
break;
case TLSARecord.MatchingType.SHA512:
digestMatch = MessageDigest.getInstance("SHA-512").digest(selectorData);
break;
}
} catch (Exception e) {
e.printStackTrace();
}
if (Arrays.equals(digestMatch, tlsaRecord.getCertificateAssociationData())) {
return cert;
}
}
return null;
}
|
[
"public",
"Certificate",
"getMatchingCert",
"(",
"TLSARecord",
"tlsaRecord",
",",
"List",
"<",
"Certificate",
">",
"certs",
")",
"{",
"for",
"(",
"Certificate",
"cert",
":",
"certs",
")",
"{",
"byte",
"[",
"]",
"digestMatch",
"=",
"new",
"byte",
"[",
"0",
"]",
";",
"byte",
"[",
"]",
"selectorData",
"=",
"new",
"byte",
"[",
"0",
"]",
";",
"try",
"{",
"// Get Selector Value",
"switch",
"(",
"tlsaRecord",
".",
"getSelector",
"(",
")",
")",
"{",
"case",
"TLSARecord",
".",
"Selector",
".",
"FULL_CERTIFICATE",
":",
"selectorData",
"=",
"cert",
".",
"getEncoded",
"(",
")",
";",
"break",
";",
"case",
"TLSARecord",
".",
"Selector",
".",
"SUBJECT_PUBLIC_KEY_INFO",
":",
"selectorData",
"=",
"cert",
".",
"getPublicKey",
"(",
")",
".",
"getEncoded",
"(",
")",
";",
"break",
";",
"}",
"// Validate Matching Type",
"switch",
"(",
"tlsaRecord",
".",
"getMatchingType",
"(",
")",
")",
"{",
"case",
"TLSARecord",
".",
"MatchingType",
".",
"EXACT",
":",
"digestMatch",
"=",
"selectorData",
";",
"break",
";",
"case",
"TLSARecord",
".",
"MatchingType",
".",
"SHA256",
":",
"digestMatch",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-256\"",
")",
".",
"digest",
"(",
"selectorData",
")",
";",
"break",
";",
"case",
"TLSARecord",
".",
"MatchingType",
".",
"SHA512",
":",
"digestMatch",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-512\"",
")",
".",
"digest",
"(",
"selectorData",
")",
";",
"break",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"if",
"(",
"Arrays",
".",
"equals",
"(",
"digestMatch",
",",
"tlsaRecord",
".",
"getCertificateAssociationData",
"(",
")",
")",
")",
"{",
"return",
"cert",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the certificate matching the TLSA record from the given certs
@param tlsaRecord TLSARecord type describing the TLSA Record to be validated
@param certs All certs retrieved from the URL's SSL/TLS connection
@return Matching certificate or null
|
[
"Returns",
"the",
"certificate",
"matching",
"the",
"TLSA",
"record",
"from",
"the",
"given",
"certs"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L140-L181
|
148,911
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/TLSAValidator.java
|
TLSAValidator.getUrlCerts
|
public List<Certificate> getUrlCerts(URL url) {
SSLSocket socket = null;
TrustManager trm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[]{trm}, null);
SSLSocketFactory factory = sc.getSocketFactory();
socket = (SSLSocket) factory.createSocket(url.getHost(), (url.getPort() == -1) ? url.getDefaultPort() : url.getPort());
socket.startHandshake();
SSLSession session = socket.getSession();
Certificate[] certArray = session.getPeerCertificates();
return new ArrayList<Certificate>(Arrays.asList(certArray));
} catch (Exception e){
e.printStackTrace();
} finally {
if (socket != null && socket.isConnected()) {
try {
socket.close();
} catch (IOException ignored) {}
}
}
return new ArrayList<Certificate>();
}
|
java
|
public List<Certificate> getUrlCerts(URL url) {
SSLSocket socket = null;
TrustManager trm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[]{trm}, null);
SSLSocketFactory factory = sc.getSocketFactory();
socket = (SSLSocket) factory.createSocket(url.getHost(), (url.getPort() == -1) ? url.getDefaultPort() : url.getPort());
socket.startHandshake();
SSLSession session = socket.getSession();
Certificate[] certArray = session.getPeerCertificates();
return new ArrayList<Certificate>(Arrays.asList(certArray));
} catch (Exception e){
e.printStackTrace();
} finally {
if (socket != null && socket.isConnected()) {
try {
socket.close();
} catch (IOException ignored) {}
}
}
return new ArrayList<Certificate>();
}
|
[
"public",
"List",
"<",
"Certificate",
">",
"getUrlCerts",
"(",
"URL",
"url",
")",
"{",
"SSLSocket",
"socket",
"=",
"null",
";",
"TrustManager",
"trm",
"=",
"new",
"X509TrustManager",
"(",
")",
"{",
"public",
"X509Certificate",
"[",
"]",
"getAcceptedIssuers",
"(",
")",
"{",
"return",
"null",
";",
"}",
"public",
"void",
"checkClientTrusted",
"(",
"X509Certificate",
"[",
"]",
"certs",
",",
"String",
"authType",
")",
"{",
"}",
"public",
"void",
"checkServerTrusted",
"(",
"X509Certificate",
"[",
"]",
"certs",
",",
"String",
"authType",
")",
"{",
"}",
"}",
";",
"try",
"{",
"SSLContext",
"sc",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"SSL\"",
")",
";",
"sc",
".",
"init",
"(",
"null",
",",
"new",
"TrustManager",
"[",
"]",
"{",
"trm",
"}",
",",
"null",
")",
";",
"SSLSocketFactory",
"factory",
"=",
"sc",
".",
"getSocketFactory",
"(",
")",
";",
"socket",
"=",
"(",
"SSLSocket",
")",
"factory",
".",
"createSocket",
"(",
"url",
".",
"getHost",
"(",
")",
",",
"(",
"url",
".",
"getPort",
"(",
")",
"==",
"-",
"1",
")",
"?",
"url",
".",
"getDefaultPort",
"(",
")",
":",
"url",
".",
"getPort",
"(",
")",
")",
";",
"socket",
".",
"startHandshake",
"(",
")",
";",
"SSLSession",
"session",
"=",
"socket",
".",
"getSession",
"(",
")",
";",
"Certificate",
"[",
"]",
"certArray",
"=",
"session",
".",
"getPeerCertificates",
"(",
")",
";",
"return",
"new",
"ArrayList",
"<",
"Certificate",
">",
"(",
"Arrays",
".",
"asList",
"(",
"certArray",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"socket",
"!=",
"null",
"&&",
"socket",
".",
"isConnected",
"(",
")",
")",
"{",
"try",
"{",
"socket",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ignored",
")",
"{",
"}",
"}",
"}",
"return",
"new",
"ArrayList",
"<",
"Certificate",
">",
"(",
")",
";",
"}"
] |
Gets all certificates from an HTTPS endpoint URL
@param url URL to get certificates from
@return List of certificates retrieves from SSL/TLS endpoint
|
[
"Gets",
"all",
"certificates",
"from",
"an",
"HTTPS",
"endpoint",
"URL"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L189-L227
|
148,912
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/TLSAValidator.java
|
TLSAValidator.getTLSARecord
|
public TLSARecord getTLSARecord(URL url) {
String recordValue;
int port = url.getPort();
if (port == -1) {
port = url.getDefaultPort();
}
String tlsaRecordName = String.format("_%s._tcp.%s", port, DNSUtil.ensureDot(url.getHost()));
try {
recordValue = this.dnssecResolver.resolve(tlsaRecordName, Type.TLSA);
} catch (DNSSECException e) {
return null;
}
if (recordValue.equals("")) return null;
// Process TLSA Record
String[] tlsaValues = recordValue.split(" ");
if (tlsaValues.length != 4) return null;
try {
return new TLSARecord(
new Name(tlsaRecordName),
DClass.IN,
0,
Integer.parseInt(tlsaValues[0]),
Integer.parseInt(tlsaValues[1]),
Integer.parseInt(tlsaValues[2]),
BaseEncoding.base16().decode(tlsaValues[3])
);
} catch (TextParseException e) {
return null;
}
}
|
java
|
public TLSARecord getTLSARecord(URL url) {
String recordValue;
int port = url.getPort();
if (port == -1) {
port = url.getDefaultPort();
}
String tlsaRecordName = String.format("_%s._tcp.%s", port, DNSUtil.ensureDot(url.getHost()));
try {
recordValue = this.dnssecResolver.resolve(tlsaRecordName, Type.TLSA);
} catch (DNSSECException e) {
return null;
}
if (recordValue.equals("")) return null;
// Process TLSA Record
String[] tlsaValues = recordValue.split(" ");
if (tlsaValues.length != 4) return null;
try {
return new TLSARecord(
new Name(tlsaRecordName),
DClass.IN,
0,
Integer.parseInt(tlsaValues[0]),
Integer.parseInt(tlsaValues[1]),
Integer.parseInt(tlsaValues[2]),
BaseEncoding.base16().decode(tlsaValues[3])
);
} catch (TextParseException e) {
return null;
}
}
|
[
"public",
"TLSARecord",
"getTLSARecord",
"(",
"URL",
"url",
")",
"{",
"String",
"recordValue",
";",
"int",
"port",
"=",
"url",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"port",
"==",
"-",
"1",
")",
"{",
"port",
"=",
"url",
".",
"getDefaultPort",
"(",
")",
";",
"}",
"String",
"tlsaRecordName",
"=",
"String",
".",
"format",
"(",
"\"_%s._tcp.%s\"",
",",
"port",
",",
"DNSUtil",
".",
"ensureDot",
"(",
"url",
".",
"getHost",
"(",
")",
")",
")",
";",
"try",
"{",
"recordValue",
"=",
"this",
".",
"dnssecResolver",
".",
"resolve",
"(",
"tlsaRecordName",
",",
"Type",
".",
"TLSA",
")",
";",
"}",
"catch",
"(",
"DNSSECException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"recordValue",
".",
"equals",
"(",
"\"\"",
")",
")",
"return",
"null",
";",
"// Process TLSA Record",
"String",
"[",
"]",
"tlsaValues",
"=",
"recordValue",
".",
"split",
"(",
"\" \"",
")",
";",
"if",
"(",
"tlsaValues",
".",
"length",
"!=",
"4",
")",
"return",
"null",
";",
"try",
"{",
"return",
"new",
"TLSARecord",
"(",
"new",
"Name",
"(",
"tlsaRecordName",
")",
",",
"DClass",
".",
"IN",
",",
"0",
",",
"Integer",
".",
"parseInt",
"(",
"tlsaValues",
"[",
"0",
"]",
")",
",",
"Integer",
".",
"parseInt",
"(",
"tlsaValues",
"[",
"1",
"]",
")",
",",
"Integer",
".",
"parseInt",
"(",
"tlsaValues",
"[",
"2",
"]",
")",
",",
"BaseEncoding",
".",
"base16",
"(",
")",
".",
"decode",
"(",
"tlsaValues",
"[",
"3",
"]",
")",
")",
";",
"}",
"catch",
"(",
"TextParseException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Handle DNSSEC resolution for the URL's associated TLSA record
@param url URL to get TLSA record for
@return TLSARecord is it exists or null
|
[
"Handle",
"DNSSEC",
"resolution",
"for",
"the",
"URL",
"s",
"associated",
"TLSA",
"record"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/TLSAValidator.java#L235-L268
|
148,913
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/HorizontalTemporalInference.java
|
HorizontalTemporalInference.execute
|
<T extends TemporalProposition> boolean execute(
PropositionDefinition propDef, Segment<T> tp1, Segment<T> tp2) {
if (tp1 == null || tp2 == null) {
return false;
}
return executeInternal(propDef, tp1.getInterval(), tp2.getInterval());
}
|
java
|
<T extends TemporalProposition> boolean execute(
PropositionDefinition propDef, Segment<T> tp1, Segment<T> tp2) {
if (tp1 == null || tp2 == null) {
return false;
}
return executeInternal(propDef, tp1.getInterval(), tp2.getInterval());
}
|
[
"<",
"T",
"extends",
"TemporalProposition",
">",
"boolean",
"execute",
"(",
"PropositionDefinition",
"propDef",
",",
"Segment",
"<",
"T",
">",
"tp1",
",",
"Segment",
"<",
"T",
">",
"tp2",
")",
"{",
"if",
"(",
"tp1",
"==",
"null",
"||",
"tp2",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"executeInternal",
"(",
"propDef",
",",
"tp1",
".",
"getInterval",
"(",
")",
",",
"tp2",
".",
"getInterval",
"(",
")",
")",
";",
"}"
] |
Computes whether the union of two segments of temporal propositions
should be taken.
We assume that
<code>tp1</code> is before or at the same time as
<code>tp2</code>, and that
<code>tp1</code> and
<code>tp2</code> are instances of
<code>propDef</code>.
@param propDef a {@link PropositionDefinition}.
@param tp1 a {@link Segment<? extends TemporalProposition>}.
@param tp2 a {@link Segment<? extends TemporalProposition>}.
@return <code>true</code> if they should be combined, <code>false</code>
otherwise.
|
[
"Computes",
"whether",
"the",
"union",
"of",
"two",
"segments",
"of",
"temporal",
"propositions",
"should",
"be",
"taken",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/HorizontalTemporalInference.java#L62-L69
|
148,914
|
eurekaclinical/protempa
|
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/ColumnSpec.java
|
ColumnSpec.getTarget
|
String getTarget(Object source) {
if (this.mappings != null) {
return this.mappings.getTarget(source);
} else {
return null;
}
}
|
java
|
String getTarget(Object source) {
if (this.mappings != null) {
return this.mappings.getTarget(source);
} else {
return null;
}
}
|
[
"String",
"getTarget",
"(",
"Object",
"source",
")",
"{",
"if",
"(",
"this",
".",
"mappings",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"mappings",
".",
"getTarget",
"(",
"source",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns the proposition id corresponding to a specified value in this
column spec's column.
@param source
the value.
@return a proposition id {@link String} or <code>null</code> if a value
is specified that is not in this column spec's mappings from
proposition ids to values ({@link #getMappings() }
).
|
[
"Returns",
"the",
"proposition",
"id",
"corresponding",
"to",
"a",
"specified",
"value",
"in",
"this",
"column",
"spec",
"s",
"column",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/ColumnSpec.java#L338-L344
|
148,915
|
eurekaclinical/protempa
|
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/ColumnSpec.java
|
ColumnSpec.getLastSpec
|
public ColumnSpec getLastSpec() {
if (this.joinSpec == null) {
return this;
} else {
List<ColumnSpec> l = asList();
return l.get(l.size() - 1);
}
}
|
java
|
public ColumnSpec getLastSpec() {
if (this.joinSpec == null) {
return this;
} else {
List<ColumnSpec> l = asList();
return l.get(l.size() - 1);
}
}
|
[
"public",
"ColumnSpec",
"getLastSpec",
"(",
")",
"{",
"if",
"(",
"this",
".",
"joinSpec",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"else",
"{",
"List",
"<",
"ColumnSpec",
">",
"l",
"=",
"asList",
"(",
")",
";",
"return",
"l",
".",
"get",
"(",
"l",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"}"
] |
Gets the last column spec in the chain of column specs and joins.
@return a {@link ColumnSpec}
|
[
"Gets",
"the",
"last",
"column",
"spec",
"in",
"the",
"chain",
"of",
"column",
"specs",
"and",
"joins",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/ColumnSpec.java#L414-L421
|
148,916
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/value/AbsoluteTimeGranularity.java
|
AbsoluteTimeGranularity.toSQLString
|
public static String toSQLString(Long position) {
java.util.Date date = AbsoluteTimeGranularityUtil.asDate(position);
return new Timestamp(date.getTime()).toString();
}
|
java
|
public static String toSQLString(Long position) {
java.util.Date date = AbsoluteTimeGranularityUtil.asDate(position);
return new Timestamp(date.getTime()).toString();
}
|
[
"public",
"static",
"String",
"toSQLString",
"(",
"Long",
"position",
")",
"{",
"java",
".",
"util",
".",
"Date",
"date",
"=",
"AbsoluteTimeGranularityUtil",
".",
"asDate",
"(",
"position",
")",
";",
"return",
"new",
"Timestamp",
"(",
"date",
".",
"getTime",
"(",
")",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Convenience method to translate a timestamp into the format expected by
SQL.
@param position a date/time in milliseconds since the epoch.
@return a {@link String} in JDBC timestamp escape format.
|
[
"Convenience",
"method",
"to",
"translate",
"a",
"timestamp",
"into",
"the",
"format",
"expected",
"by",
"SQL",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/value/AbsoluteTimeGranularity.java#L585-L588
|
148,917
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.fadeForegroundIconColorFromOpaqueToTransparent
|
public void fadeForegroundIconColorFromOpaqueToTransparent(final int cycleCount) {
stopForegroundIconColorFadeAnimation();
foregroundColorFadeAnimation = Animations.createFadeTransition(foregroundIcon, JFXConstants.TRANSPARENCY_NONE, JFXConstants.TRANSPARENCY_FULLY, cycleCount, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
foregroundColorFadeAnimation.setOnFinished(event -> foregroundIcon.setOpacity(JFXConstants.TRANSPARENCY_FULLY));
foregroundColorFadeAnimation.play();
}
|
java
|
public void fadeForegroundIconColorFromOpaqueToTransparent(final int cycleCount) {
stopForegroundIconColorFadeAnimation();
foregroundColorFadeAnimation = Animations.createFadeTransition(foregroundIcon, JFXConstants.TRANSPARENCY_NONE, JFXConstants.TRANSPARENCY_FULLY, cycleCount, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
foregroundColorFadeAnimation.setOnFinished(event -> foregroundIcon.setOpacity(JFXConstants.TRANSPARENCY_FULLY));
foregroundColorFadeAnimation.play();
}
|
[
"public",
"void",
"fadeForegroundIconColorFromOpaqueToTransparent",
"(",
"final",
"int",
"cycleCount",
")",
"{",
"stopForegroundIconColorFadeAnimation",
"(",
")",
";",
"foregroundColorFadeAnimation",
"=",
"Animations",
".",
"createFadeTransition",
"(",
"foregroundIcon",
",",
"JFXConstants",
".",
"TRANSPARENCY_NONE",
",",
"JFXConstants",
".",
"TRANSPARENCY_FULLY",
",",
"cycleCount",
",",
"JFXConstants",
".",
"ANIMATION_DURATION_FADE_SLOW",
")",
";",
"foregroundColorFadeAnimation",
".",
"setOnFinished",
"(",
"event",
"->",
"foregroundIcon",
".",
"setOpacity",
"(",
"JFXConstants",
".",
"TRANSPARENCY_FULLY",
")",
")",
";",
"foregroundColorFadeAnimation",
".",
"play",
"(",
")",
";",
"}"
] |
Apply and play a FadeTransition on the icon in the foregroundIcon.
This Transition modifies the opacity of the foregroundIcon from opaque to fully transparent.
@param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless)
|
[
"Apply",
"and",
"play",
"a",
"FadeTransition",
"on",
"the",
"icon",
"in",
"the",
"foregroundIcon",
".",
"This",
"Transition",
"modifies",
"the",
"opacity",
"of",
"the",
"foregroundIcon",
"from",
"opaque",
"to",
"fully",
"transparent",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L189-L194
|
148,918
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.fadeBackgroundIconColorFromTransparentToOpaque
|
public void fadeBackgroundIconColorFromTransparentToOpaque(final int cycleCount) {
stopBackgroundIconColorFadeAnimation();
backgroundIconColorFadeAnimation = Animations.createFadeTransition(backgroundIcon, JFXConstants.TRANSPARENCY_FULLY, JFXConstants.TRANSPARENCY_NONE, 1, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
backgroundIconColorFadeAnimation.setOnFinished(event -> backgroundIcon.setOpacity(JFXConstants.TRANSPARENCY_NONE));
backgroundIconColorFadeAnimation.play();
}
|
java
|
public void fadeBackgroundIconColorFromTransparentToOpaque(final int cycleCount) {
stopBackgroundIconColorFadeAnimation();
backgroundIconColorFadeAnimation = Animations.createFadeTransition(backgroundIcon, JFXConstants.TRANSPARENCY_FULLY, JFXConstants.TRANSPARENCY_NONE, 1, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
backgroundIconColorFadeAnimation.setOnFinished(event -> backgroundIcon.setOpacity(JFXConstants.TRANSPARENCY_NONE));
backgroundIconColorFadeAnimation.play();
}
|
[
"public",
"void",
"fadeBackgroundIconColorFromTransparentToOpaque",
"(",
"final",
"int",
"cycleCount",
")",
"{",
"stopBackgroundIconColorFadeAnimation",
"(",
")",
";",
"backgroundIconColorFadeAnimation",
"=",
"Animations",
".",
"createFadeTransition",
"(",
"backgroundIcon",
",",
"JFXConstants",
".",
"TRANSPARENCY_FULLY",
",",
"JFXConstants",
".",
"TRANSPARENCY_NONE",
",",
"1",
",",
"JFXConstants",
".",
"ANIMATION_DURATION_FADE_SLOW",
")",
";",
"backgroundIconColorFadeAnimation",
".",
"setOnFinished",
"(",
"event",
"->",
"backgroundIcon",
".",
"setOpacity",
"(",
"JFXConstants",
".",
"TRANSPARENCY_NONE",
")",
")",
";",
"backgroundIconColorFadeAnimation",
".",
"play",
"(",
")",
";",
"}"
] |
Apply and play a FadeTransition on the icon in the foregroundIcon.
This Transition modifies the opacity of the foregroundIcon from fully transparent to opaque.
@param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless)
|
[
"Apply",
"and",
"play",
"a",
"FadeTransition",
"on",
"the",
"icon",
"in",
"the",
"foregroundIcon",
".",
"This",
"Transition",
"modifies",
"the",
"opacity",
"of",
"the",
"foregroundIcon",
"from",
"fully",
"transparent",
"to",
"opaque",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L202-L207
|
148,919
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.startBackgroundIconColorFadeAnimation
|
public void startBackgroundIconColorFadeAnimation(final int cycleCount) {
if (backgroundIcon == null) {
LOGGER.warn("Background animation skipped because background icon not set!");
return;
}
backgroundIconColorFadeAnimation = Animations.createFadeTransition(backgroundIcon, JFXConstants.TRANSPARENCY_FULLY, JFXConstants.TRANSPARENCY_NONE, cycleCount, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
backgroundIconColorFadeAnimation.setOnFinished(event -> backgroundIcon.setOpacity(JFXConstants.TRANSPARENCY_FULLY));
backgroundIconColorFadeAnimation.play();
}
|
java
|
public void startBackgroundIconColorFadeAnimation(final int cycleCount) {
if (backgroundIcon == null) {
LOGGER.warn("Background animation skipped because background icon not set!");
return;
}
backgroundIconColorFadeAnimation = Animations.createFadeTransition(backgroundIcon, JFXConstants.TRANSPARENCY_FULLY, JFXConstants.TRANSPARENCY_NONE, cycleCount, JFXConstants.ANIMATION_DURATION_FADE_SLOW);
backgroundIconColorFadeAnimation.setOnFinished(event -> backgroundIcon.setOpacity(JFXConstants.TRANSPARENCY_FULLY));
backgroundIconColorFadeAnimation.play();
}
|
[
"public",
"void",
"startBackgroundIconColorFadeAnimation",
"(",
"final",
"int",
"cycleCount",
")",
"{",
"if",
"(",
"backgroundIcon",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Background animation skipped because background icon not set!\"",
")",
";",
"return",
";",
"}",
"backgroundIconColorFadeAnimation",
"=",
"Animations",
".",
"createFadeTransition",
"(",
"backgroundIcon",
",",
"JFXConstants",
".",
"TRANSPARENCY_FULLY",
",",
"JFXConstants",
".",
"TRANSPARENCY_NONE",
",",
"cycleCount",
",",
"JFXConstants",
".",
"ANIMATION_DURATION_FADE_SLOW",
")",
";",
"backgroundIconColorFadeAnimation",
".",
"setOnFinished",
"(",
"event",
"->",
"backgroundIcon",
".",
"setOpacity",
"(",
"JFXConstants",
".",
"TRANSPARENCY_FULLY",
")",
")",
";",
"backgroundIconColorFadeAnimation",
".",
"play",
"(",
")",
";",
"}"
] |
Method starts the fade animation of the background icon color.
@param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless)
|
[
"Method",
"starts",
"the",
"fade",
"animation",
"of",
"the",
"background",
"icon",
"color",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L238-L246
|
148,920
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.startForegroundIconRotateAnimation
|
public void startForegroundIconRotateAnimation(final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) {
stopForegroundIconRotateAnimation();
foregroundRotateAnimation = Animations.createRotateTransition(foregroundIcon, fromAngle, toAngle, cycleCount, duration, interpolator, autoReverse);
foregroundRotateAnimation.setOnFinished(event -> foregroundIcon.setRotate(0));
foregroundRotateAnimation.play();
}
|
java
|
public void startForegroundIconRotateAnimation(final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) {
stopForegroundIconRotateAnimation();
foregroundRotateAnimation = Animations.createRotateTransition(foregroundIcon, fromAngle, toAngle, cycleCount, duration, interpolator, autoReverse);
foregroundRotateAnimation.setOnFinished(event -> foregroundIcon.setRotate(0));
foregroundRotateAnimation.play();
}
|
[
"public",
"void",
"startForegroundIconRotateAnimation",
"(",
"final",
"double",
"fromAngle",
",",
"final",
"double",
"toAngle",
",",
"final",
"int",
"cycleCount",
",",
"final",
"double",
"duration",
",",
"final",
"Interpolator",
"interpolator",
",",
"final",
"boolean",
"autoReverse",
")",
"{",
"stopForegroundIconRotateAnimation",
"(",
")",
";",
"foregroundRotateAnimation",
"=",
"Animations",
".",
"createRotateTransition",
"(",
"foregroundIcon",
",",
"fromAngle",
",",
"toAngle",
",",
"cycleCount",
",",
"duration",
",",
"interpolator",
",",
"autoReverse",
")",
";",
"foregroundRotateAnimation",
".",
"setOnFinished",
"(",
"event",
"->",
"foregroundIcon",
".",
"setRotate",
"(",
"0",
")",
")",
";",
"foregroundRotateAnimation",
".",
"play",
"(",
")",
";",
"}"
] |
Method starts the rotate animation of the foreground icon.
@param fromAngle the rotation angle where the transition should start.
@param toAngle the rotation angle where the transition should end.
@param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless).
@param duration the duration which one animation cycle should take.
@param interpolator defines the rotation value interpolation between {@code fromAngle} and {@code toAngle}.
@param autoReverse defines if the animation should be reversed at the end.
|
[
"Method",
"starts",
"the",
"rotate",
"animation",
"of",
"the",
"foreground",
"icon",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L359-L364
|
148,921
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.startBackgroundIconRotateAnimation
|
public void startBackgroundIconRotateAnimation(final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) {
stopBackgroundIconRotateAnimation();
backgroundRotateAnimation = Animations.createRotateTransition(backgroundIcon, fromAngle, toAngle, cycleCount, duration, interpolator, autoReverse);
backgroundRotateAnimation.setOnFinished(event -> backgroundIcon.setRotate(0));
backgroundRotateAnimation.play();
}
|
java
|
public void startBackgroundIconRotateAnimation(final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) {
stopBackgroundIconRotateAnimation();
backgroundRotateAnimation = Animations.createRotateTransition(backgroundIcon, fromAngle, toAngle, cycleCount, duration, interpolator, autoReverse);
backgroundRotateAnimation.setOnFinished(event -> backgroundIcon.setRotate(0));
backgroundRotateAnimation.play();
}
|
[
"public",
"void",
"startBackgroundIconRotateAnimation",
"(",
"final",
"double",
"fromAngle",
",",
"final",
"double",
"toAngle",
",",
"final",
"int",
"cycleCount",
",",
"final",
"double",
"duration",
",",
"final",
"Interpolator",
"interpolator",
",",
"final",
"boolean",
"autoReverse",
")",
"{",
"stopBackgroundIconRotateAnimation",
"(",
")",
";",
"backgroundRotateAnimation",
"=",
"Animations",
".",
"createRotateTransition",
"(",
"backgroundIcon",
",",
"fromAngle",
",",
"toAngle",
",",
"cycleCount",
",",
"duration",
",",
"interpolator",
",",
"autoReverse",
")",
";",
"backgroundRotateAnimation",
".",
"setOnFinished",
"(",
"event",
"->",
"backgroundIcon",
".",
"setRotate",
"(",
"0",
")",
")",
";",
"backgroundRotateAnimation",
".",
"play",
"(",
")",
";",
"}"
] |
Method starts the rotate animation of the background icon.
@param fromAngle the rotation angle where the transition should start.
@param toAngle the rotation angle where the transition should end.
@param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless).
@param duration the duration which one animation cycle should take.
@param interpolator defines the rotation value interpolation between {@code fromAngle} and {@code toAngle}.
@param autoReverse defines if the animation should be reversed at the end.
|
[
"Method",
"starts",
"the",
"rotate",
"animation",
"of",
"the",
"background",
"icon",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L376-L381
|
148,922
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.setForegroundIconColorDefault
|
public void setForegroundIconColorDefault() {
stopForegroundIconColorFadeAnimation();
foregroundIcon.getStyleClass().clear();
foregroundIcon.getStyleClass().add(JFXConstants.CSS_ICON);
foregroundFadeIcon.setFill(Color.TRANSPARENT);
}
|
java
|
public void setForegroundIconColorDefault() {
stopForegroundIconColorFadeAnimation();
foregroundIcon.getStyleClass().clear();
foregroundIcon.getStyleClass().add(JFXConstants.CSS_ICON);
foregroundFadeIcon.setFill(Color.TRANSPARENT);
}
|
[
"public",
"void",
"setForegroundIconColorDefault",
"(",
")",
"{",
"stopForegroundIconColorFadeAnimation",
"(",
")",
";",
"foregroundIcon",
".",
"getStyleClass",
"(",
")",
".",
"clear",
"(",
")",
";",
"foregroundIcon",
".",
"getStyleClass",
"(",
")",
".",
"add",
"(",
"JFXConstants",
".",
"CSS_ICON",
")",
";",
"foregroundFadeIcon",
".",
"setFill",
"(",
"Color",
".",
"TRANSPARENT",
")",
";",
"}"
] |
Reset the current foreground icon color to default.
|
[
"Reset",
"the",
"current",
"foreground",
"icon",
"color",
"to",
"default",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L488-L493
|
148,923
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java
|
SVGIcon.setBackgroundIconColorDefault
|
public void setBackgroundIconColorDefault() {
if (backgroundIcon == null) {
LOGGER.warn("Background modification skipped because background icon not set!");
return;
}
stopBackgroundIconColorFadeAnimation();
backgroundIcon.getStyleClass().clear();
backgroundIcon.getStyleClass().add(JFXConstants.CSS_ICON);
backgroundFadeIcon.setFill(Color.TRANSPARENT);
}
|
java
|
public void setBackgroundIconColorDefault() {
if (backgroundIcon == null) {
LOGGER.warn("Background modification skipped because background icon not set!");
return;
}
stopBackgroundIconColorFadeAnimation();
backgroundIcon.getStyleClass().clear();
backgroundIcon.getStyleClass().add(JFXConstants.CSS_ICON);
backgroundFadeIcon.setFill(Color.TRANSPARENT);
}
|
[
"public",
"void",
"setBackgroundIconColorDefault",
"(",
")",
"{",
"if",
"(",
"backgroundIcon",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Background modification skipped because background icon not set!\"",
")",
";",
"return",
";",
"}",
"stopBackgroundIconColorFadeAnimation",
"(",
")",
";",
"backgroundIcon",
".",
"getStyleClass",
"(",
")",
".",
"clear",
"(",
")",
";",
"backgroundIcon",
".",
"getStyleClass",
"(",
")",
".",
"add",
"(",
"JFXConstants",
".",
"CSS_ICON",
")",
";",
"backgroundFadeIcon",
".",
"setFill",
"(",
"Color",
".",
"TRANSPARENT",
")",
";",
"}"
] |
Reset the current background icon color to default.
|
[
"Reset",
"the",
"current",
"background",
"icon",
"color",
"to",
"default",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGIcon.java#L498-L507
|
148,924
|
byoutline/CachedField
|
cachedfield/src/main/java/com/byoutline/cachedfield/internal/ValueLoader.java
|
ValueLoader.loadValue
|
public synchronized void loadValue(final ARG_TYPE arg) {
if (fetchFuture != null) {
// Cancel thread if it was not yet starter.
fetchFuture.cancel(false);
// If thread was cancelled before it was started inform error listeners.
if (fetchThread != null) {
fetchThread.interruptAndInformListenersIfNeeded();
}
}
// We use thread instead of pure runnable so we can interrupt loading.
fetchThread = new LoadThread<RETURN_TYPE, ARG_TYPE>(valueGetter,
successListener,
errorListener,
value, arg, dropValueOnFailure);
fetchFuture = valueGetterExecutor.submit(fetchThread);
}
|
java
|
public synchronized void loadValue(final ARG_TYPE arg) {
if (fetchFuture != null) {
// Cancel thread if it was not yet starter.
fetchFuture.cancel(false);
// If thread was cancelled before it was started inform error listeners.
if (fetchThread != null) {
fetchThread.interruptAndInformListenersIfNeeded();
}
}
// We use thread instead of pure runnable so we can interrupt loading.
fetchThread = new LoadThread<RETURN_TYPE, ARG_TYPE>(valueGetter,
successListener,
errorListener,
value, arg, dropValueOnFailure);
fetchFuture = valueGetterExecutor.submit(fetchThread);
}
|
[
"public",
"synchronized",
"void",
"loadValue",
"(",
"final",
"ARG_TYPE",
"arg",
")",
"{",
"if",
"(",
"fetchFuture",
"!=",
"null",
")",
"{",
"// Cancel thread if it was not yet starter.",
"fetchFuture",
".",
"cancel",
"(",
"false",
")",
";",
"// If thread was cancelled before it was started inform error listeners.",
"if",
"(",
"fetchThread",
"!=",
"null",
")",
"{",
"fetchThread",
".",
"interruptAndInformListenersIfNeeded",
"(",
")",
";",
"}",
"}",
"// We use thread instead of pure runnable so we can interrupt loading.",
"fetchThread",
"=",
"new",
"LoadThread",
"<",
"RETURN_TYPE",
",",
"ARG_TYPE",
">",
"(",
"valueGetter",
",",
"successListener",
",",
"errorListener",
",",
"value",
",",
"arg",
",",
"dropValueOnFailure",
")",
";",
"fetchFuture",
"=",
"valueGetterExecutor",
".",
"submit",
"(",
"fetchThread",
")",
";",
"}"
] |
Loads value in separate thread.
|
[
"Loads",
"value",
"in",
"separate",
"thread",
"."
] |
73d83072cdca22d2b3f5b3d60a93b8a26d9513e6
|
https://github.com/byoutline/CachedField/blob/73d83072cdca22d2b3f5b3d60a93b8a26d9513e6/cachedfield/src/main/java/com/byoutline/cachedfield/internal/ValueLoader.java#L39-L54
|
148,925
|
openbase/jul
|
extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MetaConfigProcessor.java
|
MetaConfigProcessor.getValue
|
public static String getValue(final MetaConfig metaConfig, final String key) throws NotAvailableException {
for (EntryType.Entry entry : metaConfig.getEntryList()) {
if (entry.getKey().equals(key)) {
if (!entry.getValue().isEmpty()) {
return entry.getValue();
}
}
}
throw new NotAvailableException("value for Key[" + key + "]");
}
|
java
|
public static String getValue(final MetaConfig metaConfig, final String key) throws NotAvailableException {
for (EntryType.Entry entry : metaConfig.getEntryList()) {
if (entry.getKey().equals(key)) {
if (!entry.getValue().isEmpty()) {
return entry.getValue();
}
}
}
throw new NotAvailableException("value for Key[" + key + "]");
}
|
[
"public",
"static",
"String",
"getValue",
"(",
"final",
"MetaConfig",
"metaConfig",
",",
"final",
"String",
"key",
")",
"throws",
"NotAvailableException",
"{",
"for",
"(",
"EntryType",
".",
"Entry",
"entry",
":",
"metaConfig",
".",
"getEntryList",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"key",
")",
")",
"{",
"if",
"(",
"!",
"entry",
".",
"getValue",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"entry",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"throw",
"new",
"NotAvailableException",
"(",
"\"value for Key[\"",
"+",
"key",
"+",
"\"]\"",
")",
";",
"}"
] |
Resolves the key to the value entry of the given meta config.
@param metaConfig key value set
@param key the key to resolve
@return the related value of the given key.
@throws org.openbase.jul.exception.NotAvailableException si thrown if not value for the given key could be resolved.
|
[
"Resolves",
"the",
"key",
"to",
"the",
"value",
"entry",
"of",
"the",
"given",
"meta",
"config",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/type/processing/src/main/java/org/openbase/jul/extension/type/processing/MetaConfigProcessor.java#L46-L55
|
148,926
|
jbundle/jcalendarbutton
|
src/main/java/org/jbundle/util/jcalendarbutton/JTimePopup.java
|
JTimePopup.init
|
public void init(String strDateParam, Date timeTarget, String strLanguage)
{
if (strDateParam != null)
m_strDateParam = strDateParam; // Property name
timeNow = new Date();
if (timeTarget == null)
timeTarget = timeNow;
selectedTime = timeTarget;
if (strLanguage != null)
{
Locale locale = new Locale(strLanguage, "");
if (locale != null)
{
calendar = Calendar.getInstance(locale);
timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
}
}
targetTime = new Date(timeTarget.getTime());
this.layoutCalendar(targetTime);
this.addListSelectionListener(this);
}
|
java
|
public void init(String strDateParam, Date timeTarget, String strLanguage)
{
if (strDateParam != null)
m_strDateParam = strDateParam; // Property name
timeNow = new Date();
if (timeTarget == null)
timeTarget = timeNow;
selectedTime = timeTarget;
if (strLanguage != null)
{
Locale locale = new Locale(strLanguage, "");
if (locale != null)
{
calendar = Calendar.getInstance(locale);
timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
}
}
targetTime = new Date(timeTarget.getTime());
this.layoutCalendar(targetTime);
this.addListSelectionListener(this);
}
|
[
"public",
"void",
"init",
"(",
"String",
"strDateParam",
",",
"Date",
"timeTarget",
",",
"String",
"strLanguage",
")",
"{",
"if",
"(",
"strDateParam",
"!=",
"null",
")",
"m_strDateParam",
"=",
"strDateParam",
";",
"// Property name",
"timeNow",
"=",
"new",
"Date",
"(",
")",
";",
"if",
"(",
"timeTarget",
"==",
"null",
")",
"timeTarget",
"=",
"timeNow",
";",
"selectedTime",
"=",
"timeTarget",
";",
"if",
"(",
"strLanguage",
"!=",
"null",
")",
"{",
"Locale",
"locale",
"=",
"new",
"Locale",
"(",
"strLanguage",
",",
"\"\"",
")",
";",
"if",
"(",
"locale",
"!=",
"null",
")",
"{",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
"locale",
")",
";",
"timeFormat",
"=",
"DateFormat",
".",
"getTimeInstance",
"(",
"DateFormat",
".",
"SHORT",
",",
"locale",
")",
";",
"}",
"}",
"targetTime",
"=",
"new",
"Date",
"(",
"timeTarget",
".",
"getTime",
"(",
")",
")",
";",
"this",
".",
"layoutCalendar",
"(",
"targetTime",
")",
";",
"this",
".",
"addListSelectionListener",
"(",
"this",
")",
";",
"}"
] |
Creates new form TimePopup.
@param strDateParam The name of the date property (defaults to "date").
@param date The initial date for this button.
@param strLanguage The language to use.
|
[
"Creates",
"new",
"form",
"TimePopup",
"."
] |
2944e6a0b634b83768d5c0b7b4a2898176421403
|
https://github.com/jbundle/jcalendarbutton/blob/2944e6a0b634b83768d5c0b7b4a2898176421403/src/main/java/org/jbundle/util/jcalendarbutton/JTimePopup.java#L120-L143
|
148,927
|
jbundle/jcalendarbutton
|
src/main/java/org/jbundle/util/jcalendarbutton/JTimePopup.java
|
JTimePopup.valueChanged
|
public void valueChanged(ListSelectionEvent e)
{
int index = this.getSelectedIndex();
if (index != -1)
{
int hour = index / 2;
int minute = (int)(((float)index / 2 - hour) * 60);
calendar.setTime(targetTime);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
Date date = calendar.getTime();
JPopupMenu popupMenu = this.getJPopupMenu();
if (popupMenu != null)
{ // I'm not sure this is the correct code, but here it is!
Component invoker = popupMenu.getInvoker();
this.getParent().remove(this); // Just being careful
Container container = popupMenu.getParent();
popupMenu.setVisible(false);
container.remove(popupMenu);
if (invoker != null)
if (transferFocus)
invoker.transferFocus(); // Focus on next component after invoker
}
Date oldTime = selectedTime;
if (selectedTime == targetTime)
oldTime = null;
this.firePropertyChange(m_strDateParam, oldTime, date);
}
}
|
java
|
public void valueChanged(ListSelectionEvent e)
{
int index = this.getSelectedIndex();
if (index != -1)
{
int hour = index / 2;
int minute = (int)(((float)index / 2 - hour) * 60);
calendar.setTime(targetTime);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
Date date = calendar.getTime();
JPopupMenu popupMenu = this.getJPopupMenu();
if (popupMenu != null)
{ // I'm not sure this is the correct code, but here it is!
Component invoker = popupMenu.getInvoker();
this.getParent().remove(this); // Just being careful
Container container = popupMenu.getParent();
popupMenu.setVisible(false);
container.remove(popupMenu);
if (invoker != null)
if (transferFocus)
invoker.transferFocus(); // Focus on next component after invoker
}
Date oldTime = selectedTime;
if (selectedTime == targetTime)
oldTime = null;
this.firePropertyChange(m_strDateParam, oldTime, date);
}
}
|
[
"public",
"void",
"valueChanged",
"(",
"ListSelectionEvent",
"e",
")",
"{",
"int",
"index",
"=",
"this",
".",
"getSelectedIndex",
"(",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"int",
"hour",
"=",
"index",
"/",
"2",
";",
"int",
"minute",
"=",
"(",
"int",
")",
"(",
"(",
"(",
"float",
")",
"index",
"/",
"2",
"-",
"hour",
")",
"*",
"60",
")",
";",
"calendar",
".",
"setTime",
"(",
"targetTime",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hour",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"minute",
")",
";",
"Date",
"date",
"=",
"calendar",
".",
"getTime",
"(",
")",
";",
"JPopupMenu",
"popupMenu",
"=",
"this",
".",
"getJPopupMenu",
"(",
")",
";",
"if",
"(",
"popupMenu",
"!=",
"null",
")",
"{",
"// I'm not sure this is the correct code, but here it is!",
"Component",
"invoker",
"=",
"popupMenu",
".",
"getInvoker",
"(",
")",
";",
"this",
".",
"getParent",
"(",
")",
".",
"remove",
"(",
"this",
")",
";",
"// Just being careful",
"Container",
"container",
"=",
"popupMenu",
".",
"getParent",
"(",
")",
";",
"popupMenu",
".",
"setVisible",
"(",
"false",
")",
";",
"container",
".",
"remove",
"(",
"popupMenu",
")",
";",
"if",
"(",
"invoker",
"!=",
"null",
")",
"if",
"(",
"transferFocus",
")",
"invoker",
".",
"transferFocus",
"(",
")",
";",
"// Focus on next component after invoker",
"}",
"Date",
"oldTime",
"=",
"selectedTime",
";",
"if",
"(",
"selectedTime",
"==",
"targetTime",
")",
"oldTime",
"=",
"null",
";",
"this",
".",
"firePropertyChange",
"(",
"m_strDateParam",
",",
"oldTime",
",",
"date",
")",
";",
"}",
"}"
] |
Called whenever the value of the selection changes.
@param e the event that characterizes the change.
|
[
"Called",
"whenever",
"the",
"value",
"of",
"the",
"selection",
"changes",
"."
] |
2944e6a0b634b83768d5c0b7b4a2898176421403
|
https://github.com/jbundle/jcalendarbutton/blob/2944e6a0b634b83768d5c0b7b4a2898176421403/src/main/java/org/jbundle/util/jcalendarbutton/JTimePopup.java#L255-L283
|
148,928
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/AbstractProposition.java
|
AbstractProposition.initializeAbstractProposition
|
protected final void initializeAbstractProposition(String id,
UniqueId uniqueId) {
this.uniqueId = uniqueId;
if (id == null) {
this.id = "";
} else {
this.id = id.intern();
}
}
|
java
|
protected final void initializeAbstractProposition(String id,
UniqueId uniqueId) {
this.uniqueId = uniqueId;
if (id == null) {
this.id = "";
} else {
this.id = id.intern();
}
}
|
[
"protected",
"final",
"void",
"initializeAbstractProposition",
"(",
"String",
"id",
",",
"UniqueId",
"uniqueId",
")",
"{",
"this",
".",
"uniqueId",
"=",
"uniqueId",
";",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"this",
".",
"id",
"=",
"\"\"",
";",
"}",
"else",
"{",
"this",
".",
"id",
"=",
"id",
".",
"intern",
"(",
")",
";",
"}",
"}"
] |
Assigns fields specified in the constructor. This is pulled into a method
so that deserialization can initialize those fields correctly.
@param id the proposition id.
@param uniqueId the proposition's unique id.
|
[
"Assigns",
"fields",
"specified",
"in",
"the",
"constructor",
".",
"This",
"is",
"pulled",
"into",
"a",
"method",
"so",
"that",
"deserialization",
"can",
"initialize",
"those",
"fields",
"correctly",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/AbstractProposition.java#L96-L104
|
148,929
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/scale/MathEquation.java
|
MathEquation.getDescription
|
public String getDescription() {
Object[] params = new Object[parameters.length];
for (int i = 0; i < parameters.length; i++) {
params[i] = parameters[i];
}
return String.format(format, params);
}
|
java
|
public String getDescription() {
Object[] params = new Object[parameters.length];
for (int i = 0; i < parameters.length; i++) {
params[i] = parameters[i];
}
return String.format(format, params);
}
|
[
"public",
"String",
"getDescription",
"(",
")",
"{",
"Object",
"[",
"]",
"params",
"=",
"new",
"Object",
"[",
"parameters",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"params",
"[",
"i",
"]",
"=",
"parameters",
"[",
"i",
"]",
";",
"}",
"return",
"String",
".",
"format",
"(",
"format",
",",
"params",
")",
";",
"}"
] |
Get a text-based description of this equation
@return the string version of this equation
|
[
"Get",
"a",
"text",
"-",
"based",
"description",
"of",
"this",
"equation"
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/scale/MathEquation.java#L51-L57
|
148,930
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/scale/MathEquation.java
|
MathEquation.toJSONString
|
public String toJSONString() {
String parms = DoubleStream.of(parameters)
.mapToObj(d -> String.format("%f", d))
.collect(Collectors.joining(", ", "[", "]"));
String desc = String.format(format, DoubleStream.of(parameters).mapToObj(Double::valueOf).toArray());
return String.format(
"{name: \"%s\", valid: %s, format: \"%s\", description: \"%s\", parameters: %s, rsquare: %f}",
model.getName(), isValid() ? "true" : "false", format, desc, parms, rSquared);
}
|
java
|
public String toJSONString() {
String parms = DoubleStream.of(parameters)
.mapToObj(d -> String.format("%f", d))
.collect(Collectors.joining(", ", "[", "]"));
String desc = String.format(format, DoubleStream.of(parameters).mapToObj(Double::valueOf).toArray());
return String.format(
"{name: \"%s\", valid: %s, format: \"%s\", description: \"%s\", parameters: %s, rsquare: %f}",
model.getName(), isValid() ? "true" : "false", format, desc, parms, rSquared);
}
|
[
"public",
"String",
"toJSONString",
"(",
")",
"{",
"String",
"parms",
"=",
"DoubleStream",
".",
"of",
"(",
"parameters",
")",
".",
"mapToObj",
"(",
"d",
"->",
"String",
".",
"format",
"(",
"\"%f\"",
",",
"d",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
",",
"\"[\"",
",",
"\"]\"",
")",
")",
";",
"String",
"desc",
"=",
"String",
".",
"format",
"(",
"format",
",",
"DoubleStream",
".",
"of",
"(",
"parameters",
")",
".",
"mapToObj",
"(",
"Double",
"::",
"valueOf",
")",
".",
"toArray",
"(",
")",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"{name: \\\"%s\\\", valid: %s, format: \\\"%s\\\", description: \\\"%s\\\", parameters: %s, rsquare: %f}\"",
",",
"model",
".",
"getName",
"(",
")",
",",
"isValid",
"(",
")",
"?",
"\"true\"",
":",
"\"false\"",
",",
"format",
",",
"desc",
",",
"parms",
",",
"rSquared",
")",
";",
"}"
] |
Convert this equation in to a JSON string representing the vital
statistics of the equation.
@return a JSON interpretation of this equation.
|
[
"Convert",
"this",
"equation",
"in",
"to",
"a",
"JSON",
"string",
"representing",
"the",
"vital",
"statistics",
"of",
"the",
"equation",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/scale/MathEquation.java#L117-L126
|
148,931
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/scale/MathEquation.java
|
MathEquation.isValid
|
public boolean isValid() {
return Math.abs(parameters[0]) >= 0.001 && rSquared != Double.NEGATIVE_INFINITY && !Double.isNaN(rSquared);
}
|
java
|
public boolean isValid() {
return Math.abs(parameters[0]) >= 0.001 && rSquared != Double.NEGATIVE_INFINITY && !Double.isNaN(rSquared);
}
|
[
"public",
"boolean",
"isValid",
"(",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"parameters",
"[",
"0",
"]",
")",
">=",
"0.001",
"&&",
"rSquared",
"!=",
"Double",
".",
"NEGATIVE_INFINITY",
"&&",
"!",
"Double",
".",
"isNaN",
"(",
"rSquared",
")",
";",
"}"
] |
Indicate whether this equation is a suitable match against the actual
data.
@return true if this equation is useful when representing the actual
data's scalability
|
[
"Indicate",
"whether",
"this",
"equation",
"is",
"a",
"suitable",
"match",
"against",
"the",
"actual",
"data",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/scale/MathEquation.java#L135-L137
|
148,932
|
openbase/jul
|
extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/processing/ProtoBufJSonProcessor.java
|
ProtoBufJSonProcessor.serialize
|
public String serialize(final Object serviceState) throws InvalidStateException, CouldNotPerformException {
String jsonStringRep;
if (serviceState instanceof Message) {
try {
jsonStringRep = jsonFormat.printToString((Message) serviceState);
} catch (Exception ex) {
throw new CouldNotPerformException("Could not serialize service argument to string!", ex);
}
} else {
throw new InvalidStateException("Service attribute Class[" + serviceState.getClass().getSimpleName() + "] not a protobuf message!");
}
return jsonStringRep;
}
|
java
|
public String serialize(final Object serviceState) throws InvalidStateException, CouldNotPerformException {
String jsonStringRep;
if (serviceState instanceof Message) {
try {
jsonStringRep = jsonFormat.printToString((Message) serviceState);
} catch (Exception ex) {
throw new CouldNotPerformException("Could not serialize service argument to string!", ex);
}
} else {
throw new InvalidStateException("Service attribute Class[" + serviceState.getClass().getSimpleName() + "] not a protobuf message!");
}
return jsonStringRep;
}
|
[
"public",
"String",
"serialize",
"(",
"final",
"Object",
"serviceState",
")",
"throws",
"InvalidStateException",
",",
"CouldNotPerformException",
"{",
"String",
"jsonStringRep",
";",
"if",
"(",
"serviceState",
"instanceof",
"Message",
")",
"{",
"try",
"{",
"jsonStringRep",
"=",
"jsonFormat",
".",
"printToString",
"(",
"(",
"Message",
")",
"serviceState",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"CouldNotPerformException",
"(",
"\"Could not serialize service argument to string!\"",
",",
"ex",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Service attribute Class[\"",
"+",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\"] not a protobuf message!\"",
")",
";",
"}",
"return",
"jsonStringRep",
";",
"}"
] |
Serialize a serviceState which can be a proto message, enumeration or
a java primitive to string. If its a primitive toString is called while
messages or enumerations will be serialized into JSon
@param serviceState
@return
@throws org.openbase.jul.exception.InvalidStateException in case the given service argument does not contain any context.
@throws CouldNotPerformException in case the serialization failed.
<p>
TODO: release: change parameter type to message since java primitives cannot be de-/serialized anymore anyway
|
[
"Serialize",
"a",
"serviceState",
"which",
"can",
"be",
"a",
"proto",
"message",
"enumeration",
"or",
"a",
"java",
"primitive",
"to",
"string",
".",
"If",
"its",
"a",
"primitive",
"toString",
"is",
"called",
"while",
"messages",
"or",
"enumerations",
"will",
"be",
"serialized",
"into",
"JSon"
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/processing/ProtoBufJSonProcessor.java#L66-L79
|
148,933
|
openbase/jul
|
extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/processing/ProtoBufJSonProcessor.java
|
ProtoBufJSonProcessor.getServiceStateClassName
|
public String getServiceStateClassName(final Object serviceState) throws CouldNotPerformException {
// todo: move to dal or any bco component. Jul should be independent from bco architecture.
if (serviceState.getClass().getName().startsWith("org.openbase.type")) {
return serviceState.getClass().getName();
}
if (serviceState.getClass().isEnum()) {
logger.info(serviceState.getClass().getName());
return serviceState.getClass().getName();
}
logger.debug("Simple class name of attribute to upper case [" + serviceState.getClass().getSimpleName().toUpperCase() + "]");
JavaTypeToProto javaToProto;
try {
javaToProto = JavaTypeToProto.valueOf(serviceState.getClass().getSimpleName().toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CouldNotPerformException("ServiceState is not a supported java primitive nor a supported rst type", ex);
}
logger.debug("According proto type [" + javaToProto.getProtoType().name() + "]");
return javaToProto.getProtoType().name();
}
|
java
|
public String getServiceStateClassName(final Object serviceState) throws CouldNotPerformException {
// todo: move to dal or any bco component. Jul should be independent from bco architecture.
if (serviceState.getClass().getName().startsWith("org.openbase.type")) {
return serviceState.getClass().getName();
}
if (serviceState.getClass().isEnum()) {
logger.info(serviceState.getClass().getName());
return serviceState.getClass().getName();
}
logger.debug("Simple class name of attribute to upper case [" + serviceState.getClass().getSimpleName().toUpperCase() + "]");
JavaTypeToProto javaToProto;
try {
javaToProto = JavaTypeToProto.valueOf(serviceState.getClass().getSimpleName().toUpperCase());
} catch (IllegalArgumentException ex) {
throw new CouldNotPerformException("ServiceState is not a supported java primitive nor a supported rst type", ex);
}
logger.debug("According proto type [" + javaToProto.getProtoType().name() + "]");
return javaToProto.getProtoType().name();
}
|
[
"public",
"String",
"getServiceStateClassName",
"(",
"final",
"Object",
"serviceState",
")",
"throws",
"CouldNotPerformException",
"{",
"// todo: move to dal or any bco component. Jul should be independent from bco architecture.",
"if",
"(",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"\"org.openbase.type\"",
")",
")",
"{",
"return",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"serviceState",
".",
"getClass",
"(",
")",
".",
"isEnum",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"return",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"Simple class name of attribute to upper case [\"",
"+",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
".",
"toUpperCase",
"(",
")",
"+",
"\"]\"",
")",
";",
"JavaTypeToProto",
"javaToProto",
";",
"try",
"{",
"javaToProto",
"=",
"JavaTypeToProto",
".",
"valueOf",
"(",
"serviceState",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"throw",
"new",
"CouldNotPerformException",
"(",
"\"ServiceState is not a supported java primitive nor a supported rst type\"",
",",
"ex",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"\"According proto type [\"",
"+",
"javaToProto",
".",
"getProtoType",
"(",
")",
".",
"name",
"(",
")",
"+",
"\"]\"",
")",
";",
"return",
"javaToProto",
".",
"getProtoType",
"(",
")",
".",
"name",
"(",
")",
";",
"}"
] |
Get the string representation for a given serviceState which can be a
proto message, enumeration or a java primitive.
@param serviceState the serviceState
@return a string representation of the serviceState type
@throws CouldNotPerformException
|
[
"Get",
"the",
"string",
"representation",
"for",
"a",
"given",
"serviceState",
"which",
"can",
"be",
"a",
"proto",
"message",
"enumeration",
"or",
"a",
"java",
"primitive",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/extension/protobuf/src/main/java/org/openbase/jul/extension/protobuf/processing/ProtoBufJSonProcessor.java#L91-L111
|
148,934
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java
|
TypeQueryClassAdapter.hasEntityBeanInterface
|
private boolean hasEntityBeanInterface(String[] interfaces) {
for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i].equals(C_ENTITYBEAN)) {
return true;
}
}
return false;
}
|
java
|
private boolean hasEntityBeanInterface(String[] interfaces) {
for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i].equals(C_ENTITYBEAN)) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"hasEntityBeanInterface",
"(",
"String",
"[",
"]",
"interfaces",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"interfaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"interfaces",
"[",
"i",
"]",
".",
"equals",
"(",
"C_ENTITYBEAN",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return true if this case the EntityBean interface.
|
[
"Return",
"true",
"if",
"this",
"case",
"the",
"EntityBean",
"interface",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java#L46-L53
|
148,935
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java
|
TypeQueryClassAdapter.getDomainClass
|
protected String getDomainClass() {
int posStart = signature.indexOf('<');
int posEnd = signature.indexOf(';', posStart + 1);
return signature.substring(posStart + 2, posEnd);
}
|
java
|
protected String getDomainClass() {
int posStart = signature.indexOf('<');
int posEnd = signature.indexOf(';', posStart + 1);
return signature.substring(posStart + 2, posEnd);
}
|
[
"protected",
"String",
"getDomainClass",
"(",
")",
"{",
"int",
"posStart",
"=",
"signature",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"posEnd",
"=",
"signature",
".",
"indexOf",
"(",
"'",
"'",
",",
"posStart",
"+",
"1",
")",
";",
"return",
"signature",
".",
"substring",
"(",
"posStart",
"+",
"2",
",",
"posEnd",
")",
";",
"}"
] |
Extract and return the associated entity bean class from the signature.
|
[
"Extract",
"and",
"return",
"the",
"associated",
"entity",
"bean",
"class",
"from",
"the",
"signature",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java#L58-L62
|
148,936
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java
|
TypeQueryClassAdapter.visitAnnotation
|
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
classInfo.checkTypeQueryAnnotation(desc);
return super.visitAnnotation(desc, visible);
}
|
java
|
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
classInfo.checkTypeQueryAnnotation(desc);
return super.visitAnnotation(desc, visible);
}
|
[
"@",
"Override",
"public",
"AnnotationVisitor",
"visitAnnotation",
"(",
"String",
"desc",
",",
"boolean",
"visible",
")",
"{",
"classInfo",
".",
"checkTypeQueryAnnotation",
"(",
"desc",
")",
";",
"return",
"super",
".",
"visitAnnotation",
"(",
"desc",
",",
"visible",
")",
";",
"}"
] |
Look for TypeQueryBean annotation.
|
[
"Look",
"for",
"TypeQueryBean",
"annotation",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java#L67-L71
|
148,937
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java
|
TypeQueryClassAdapter.handleAssocBeanConstructor
|
private MethodVisitor handleAssocBeanConstructor(int access, String name, String desc, String signature, String[] exceptions) {
if (desc.equals(ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC)) {
classInfo.setHasBasicConstructor();
return new TypeQueryAssocBasicConstructor(classInfo, cv, desc, signature);
}
if (desc.equals(ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC)) {
classInfo.setHasMainConstructor();
return new TypeQueryAssocMainConstructor(classInfo, cv, desc, signature);
}
// leave as is
return super.visitMethod(access, name, desc, signature, exceptions);
}
|
java
|
private MethodVisitor handleAssocBeanConstructor(int access, String name, String desc, String signature, String[] exceptions) {
if (desc.equals(ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC)) {
classInfo.setHasBasicConstructor();
return new TypeQueryAssocBasicConstructor(classInfo, cv, desc, signature);
}
if (desc.equals(ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC)) {
classInfo.setHasMainConstructor();
return new TypeQueryAssocMainConstructor(classInfo, cv, desc, signature);
}
// leave as is
return super.visitMethod(access, name, desc, signature, exceptions);
}
|
[
"private",
"MethodVisitor",
"handleAssocBeanConstructor",
"(",
"int",
"access",
",",
"String",
"name",
",",
"String",
"desc",
",",
"String",
"signature",
",",
"String",
"[",
"]",
"exceptions",
")",
"{",
"if",
"(",
"desc",
".",
"equals",
"(",
"ASSOC_BEAN_BASIC_CONSTRUCTOR_DESC",
")",
")",
"{",
"classInfo",
".",
"setHasBasicConstructor",
"(",
")",
";",
"return",
"new",
"TypeQueryAssocBasicConstructor",
"(",
"classInfo",
",",
"cv",
",",
"desc",
",",
"signature",
")",
";",
"}",
"if",
"(",
"desc",
".",
"equals",
"(",
"ASSOC_BEAN_MAIN_CONSTRUCTOR_DESC",
")",
")",
"{",
"classInfo",
".",
"setHasMainConstructor",
"(",
")",
";",
"return",
"new",
"TypeQueryAssocMainConstructor",
"(",
"classInfo",
",",
"cv",
",",
"desc",
",",
"signature",
")",
";",
"}",
"// leave as is",
"return",
"super",
".",
"visitMethod",
"(",
"access",
",",
"name",
",",
"desc",
",",
"signature",
",",
"exceptions",
")",
";",
"}"
] |
Handle the constructors for assoc type query beans.
|
[
"Handle",
"the",
"constructors",
"for",
"assoc",
"type",
"query",
"beans",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java#L129-L141
|
148,938
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java
|
TypeQueryClassAdapter.addMarkerAnnotation
|
private void addMarkerAnnotation() {
if (isLog(4)) {
log("... adding marker annotation");
}
AnnotationVisitor av = cv.visitAnnotation(ANNOTATION_ALREADY_ENHANCED_MARKER, true);
if (av != null) {
av.visitEnd();
}
}
|
java
|
private void addMarkerAnnotation() {
if (isLog(4)) {
log("... adding marker annotation");
}
AnnotationVisitor av = cv.visitAnnotation(ANNOTATION_ALREADY_ENHANCED_MARKER, true);
if (av != null) {
av.visitEnd();
}
}
|
[
"private",
"void",
"addMarkerAnnotation",
"(",
")",
"{",
"if",
"(",
"isLog",
"(",
"4",
")",
")",
"{",
"log",
"(",
"\"... adding marker annotation\"",
")",
";",
"}",
"AnnotationVisitor",
"av",
"=",
"cv",
".",
"visitAnnotation",
"(",
"ANNOTATION_ALREADY_ENHANCED_MARKER",
",",
"true",
")",
";",
"if",
"(",
"av",
"!=",
"null",
")",
"{",
"av",
".",
"visitEnd",
"(",
")",
";",
"}",
"}"
] |
Add the marker annotation so that we don't enhance the type query bean twice.
|
[
"Add",
"the",
"marker",
"annotation",
"so",
"that",
"we",
"don",
"t",
"enhance",
"the",
"type",
"query",
"bean",
"twice",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryClassAdapter.java#L166-L175
|
148,939
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java
|
ShamirSecretSharing.split
|
public static List<SecretShare> split(BigInteger secret, BigInteger[] coefficients, int total, int threshold,
BigInteger prime) {
if (secret.compareTo(BigInteger.ZERO) <= 0) {
throw new IllegalArgumentException("secret must be positive integer");
}
if (prime.compareTo(secret) <= 0) {
throw new IllegalArgumentException("prime must be greater than secret");
}
if (coefficients.length < threshold) {
throw new IllegalArgumentException("not enough coefficients, need " + threshold + ", have " +
coefficients.length);
}
if (total < threshold) {
throw new IllegalArgumentException("total number of shares must be greater than or equal threshold");
}
List<SecretShare> shares = new ArrayList<>();
for (int i = 1; i <= total; i++) {
BigInteger x = BigInteger.valueOf(i);
BigInteger v = coefficients[0];
for (int c = 1; c < threshold; c++) {
v = v.add(x.modPow(BigInteger.valueOf(c), prime).multiply(coefficients[c]).mod(prime)).mod(prime);
}
shares.add(new SecretShare(i, v, prime));
}
return shares;
}
|
java
|
public static List<SecretShare> split(BigInteger secret, BigInteger[] coefficients, int total, int threshold,
BigInteger prime) {
if (secret.compareTo(BigInteger.ZERO) <= 0) {
throw new IllegalArgumentException("secret must be positive integer");
}
if (prime.compareTo(secret) <= 0) {
throw new IllegalArgumentException("prime must be greater than secret");
}
if (coefficients.length < threshold) {
throw new IllegalArgumentException("not enough coefficients, need " + threshold + ", have " +
coefficients.length);
}
if (total < threshold) {
throw new IllegalArgumentException("total number of shares must be greater than or equal threshold");
}
List<SecretShare> shares = new ArrayList<>();
for (int i = 1; i <= total; i++) {
BigInteger x = BigInteger.valueOf(i);
BigInteger v = coefficients[0];
for (int c = 1; c < threshold; c++) {
v = v.add(x.modPow(BigInteger.valueOf(c), prime).multiply(coefficients[c]).mod(prime)).mod(prime);
}
shares.add(new SecretShare(i, v, prime));
}
return shares;
}
|
[
"public",
"static",
"List",
"<",
"SecretShare",
">",
"split",
"(",
"BigInteger",
"secret",
",",
"BigInteger",
"[",
"]",
"coefficients",
",",
"int",
"total",
",",
"int",
"threshold",
",",
"BigInteger",
"prime",
")",
"{",
"if",
"(",
"secret",
".",
"compareTo",
"(",
"BigInteger",
".",
"ZERO",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"secret must be positive integer\"",
")",
";",
"}",
"if",
"(",
"prime",
".",
"compareTo",
"(",
"secret",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"prime must be greater than secret\"",
")",
";",
"}",
"if",
"(",
"coefficients",
".",
"length",
"<",
"threshold",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"not enough coefficients, need \"",
"+",
"threshold",
"+",
"\", have \"",
"+",
"coefficients",
".",
"length",
")",
";",
"}",
"if",
"(",
"total",
"<",
"threshold",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"total number of shares must be greater than or equal threshold\"",
")",
";",
"}",
"List",
"<",
"SecretShare",
">",
"shares",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"total",
";",
"i",
"++",
")",
"{",
"BigInteger",
"x",
"=",
"BigInteger",
".",
"valueOf",
"(",
"i",
")",
";",
"BigInteger",
"v",
"=",
"coefficients",
"[",
"0",
"]",
";",
"for",
"(",
"int",
"c",
"=",
"1",
";",
"c",
"<",
"threshold",
";",
"c",
"++",
")",
"{",
"v",
"=",
"v",
".",
"add",
"(",
"x",
".",
"modPow",
"(",
"BigInteger",
".",
"valueOf",
"(",
"c",
")",
",",
"prime",
")",
".",
"multiply",
"(",
"coefficients",
"[",
"c",
"]",
")",
".",
"mod",
"(",
"prime",
")",
")",
".",
"mod",
"(",
"prime",
")",
";",
"}",
"shares",
".",
"add",
"(",
"new",
"SecretShare",
"(",
"i",
",",
"v",
",",
"prime",
")",
")",
";",
"}",
"return",
"shares",
";",
"}"
] |
Split the secret into the specified total number of shares. Specified minimum threshold of shares will need to be
present in order to join them back into the secret.
@param secret number to split into shares
@param coefficients random coefficients of the underlying polynomial
@param total number of shares to generate
@param threshold minimum number of shares required to successfully join back the secret
@param prime to be used for finite field arithmetic
@return list of shares
|
[
"Split",
"the",
"secret",
"into",
"the",
"specified",
"total",
"number",
"of",
"shares",
".",
"Specified",
"minimum",
"threshold",
"of",
"shares",
"will",
"need",
"to",
"be",
"present",
"in",
"order",
"to",
"join",
"them",
"back",
"into",
"the",
"secret",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java#L80-L111
|
148,940
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java
|
ShamirSecretSharing.join
|
public static BigInteger join(List<SecretShare> shares) {
if (!checkSamePrimes(shares)) {
throw new IllegalArgumentException("shares not from the same series");
}
BigInteger res = BigInteger.ZERO;
for (int i = 0; i < shares.size(); i++) {
BigInteger n = BigInteger.ONE;
BigInteger d = BigInteger.ONE;
BigInteger prime = shares.get(i).getPrime();
for (int j = 0; j < shares.size(); j++) {
if (i != j) {
BigInteger sp = BigInteger.valueOf(shares.get(i).getN());
BigInteger np = BigInteger.valueOf(shares.get(j).getN());
n = n.multiply(np.negate()).mod(prime);
d = d.multiply(sp.subtract(np)).mod(prime);
}
}
BigInteger v = shares.get(i).getShare();
res = res.add(prime).add(v.multiply(n).multiply(d.modInverse(prime))).mod(prime);
}
return res;
}
|
java
|
public static BigInteger join(List<SecretShare> shares) {
if (!checkSamePrimes(shares)) {
throw new IllegalArgumentException("shares not from the same series");
}
BigInteger res = BigInteger.ZERO;
for (int i = 0; i < shares.size(); i++) {
BigInteger n = BigInteger.ONE;
BigInteger d = BigInteger.ONE;
BigInteger prime = shares.get(i).getPrime();
for (int j = 0; j < shares.size(); j++) {
if (i != j) {
BigInteger sp = BigInteger.valueOf(shares.get(i).getN());
BigInteger np = BigInteger.valueOf(shares.get(j).getN());
n = n.multiply(np.negate()).mod(prime);
d = d.multiply(sp.subtract(np)).mod(prime);
}
}
BigInteger v = shares.get(i).getShare();
res = res.add(prime).add(v.multiply(n).multiply(d.modInverse(prime))).mod(prime);
}
return res;
}
|
[
"public",
"static",
"BigInteger",
"join",
"(",
"List",
"<",
"SecretShare",
">",
"shares",
")",
"{",
"if",
"(",
"!",
"checkSamePrimes",
"(",
"shares",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"shares not from the same series\"",
")",
";",
"}",
"BigInteger",
"res",
"=",
"BigInteger",
".",
"ZERO",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"shares",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"BigInteger",
"n",
"=",
"BigInteger",
".",
"ONE",
";",
"BigInteger",
"d",
"=",
"BigInteger",
".",
"ONE",
";",
"BigInteger",
"prime",
"=",
"shares",
".",
"get",
"(",
"i",
")",
".",
"getPrime",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"shares",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"j",
")",
"{",
"BigInteger",
"sp",
"=",
"BigInteger",
".",
"valueOf",
"(",
"shares",
".",
"get",
"(",
"i",
")",
".",
"getN",
"(",
")",
")",
";",
"BigInteger",
"np",
"=",
"BigInteger",
".",
"valueOf",
"(",
"shares",
".",
"get",
"(",
"j",
")",
".",
"getN",
"(",
")",
")",
";",
"n",
"=",
"n",
".",
"multiply",
"(",
"np",
".",
"negate",
"(",
")",
")",
".",
"mod",
"(",
"prime",
")",
";",
"d",
"=",
"d",
".",
"multiply",
"(",
"sp",
".",
"subtract",
"(",
"np",
")",
")",
".",
"mod",
"(",
"prime",
")",
";",
"}",
"}",
"BigInteger",
"v",
"=",
"shares",
".",
"get",
"(",
"i",
")",
".",
"getShare",
"(",
")",
";",
"res",
"=",
"res",
".",
"add",
"(",
"prime",
")",
".",
"add",
"(",
"v",
".",
"multiply",
"(",
"n",
")",
".",
"multiply",
"(",
"d",
".",
"modInverse",
"(",
"prime",
")",
")",
")",
".",
"mod",
"(",
"prime",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Join shares back into the secret.
@param shares to join
@return secret number
|
[
"Join",
"shares",
"back",
"into",
"the",
"secret",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java#L129-L150
|
148,941
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java
|
ShamirSecretSharing.checkSamePrimes
|
private static boolean checkSamePrimes(List<SecretShare> shares) {
boolean ret = true;
BigInteger prime = null;
for (SecretShare share : shares) {
if (prime == null) {
prime = share.getPrime();
} else if (!prime.equals(share.getPrime())) {
ret = false;
break;
}
}
return ret;
}
|
java
|
private static boolean checkSamePrimes(List<SecretShare> shares) {
boolean ret = true;
BigInteger prime = null;
for (SecretShare share : shares) {
if (prime == null) {
prime = share.getPrime();
} else if (!prime.equals(share.getPrime())) {
ret = false;
break;
}
}
return ret;
}
|
[
"private",
"static",
"boolean",
"checkSamePrimes",
"(",
"List",
"<",
"SecretShare",
">",
"shares",
")",
"{",
"boolean",
"ret",
"=",
"true",
";",
"BigInteger",
"prime",
"=",
"null",
";",
"for",
"(",
"SecretShare",
"share",
":",
"shares",
")",
"{",
"if",
"(",
"prime",
"==",
"null",
")",
"{",
"prime",
"=",
"share",
".",
"getPrime",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"prime",
".",
"equals",
"(",
"share",
".",
"getPrime",
"(",
")",
")",
")",
"{",
"ret",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Verify if all shares have the same prime. If they do not, then they are not from the same series and cannot
possibly be joined.
@param shares to check
@return true if all shares have the same prime, false if not.
|
[
"Verify",
"if",
"all",
"shares",
"have",
"the",
"same",
"prime",
".",
"If",
"they",
"do",
"not",
"then",
"they",
"are",
"not",
"from",
"the",
"same",
"series",
"and",
"cannot",
"possibly",
"be",
"joined",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/ShamirSecretSharing.java#L159-L171
|
148,942
|
eurekaclinical/protempa
|
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/PropositionResultSetIterator.java
|
PropositionResultSetIterator.handleKeyId
|
final void handleKeyId(String kId) {
String oldKeyId = getKeyId();
if (oldKeyId != null && !oldKeyId.equals(kId)) {
createDataStreamingEvent(oldKeyId, this.props);
}
this.keyId = kId;
}
|
java
|
final void handleKeyId(String kId) {
String oldKeyId = getKeyId();
if (oldKeyId != null && !oldKeyId.equals(kId)) {
createDataStreamingEvent(oldKeyId, this.props);
}
this.keyId = kId;
}
|
[
"final",
"void",
"handleKeyId",
"(",
"String",
"kId",
")",
"{",
"String",
"oldKeyId",
"=",
"getKeyId",
"(",
")",
";",
"if",
"(",
"oldKeyId",
"!=",
"null",
"&&",
"!",
"oldKeyId",
".",
"equals",
"(",
"kId",
")",
")",
"{",
"createDataStreamingEvent",
"(",
"oldKeyId",
",",
"this",
".",
"props",
")",
";",
"}",
"this",
".",
"keyId",
"=",
"kId",
";",
"}"
] |
For recording the key id of the current record.
@param kId the key id {@link String}.
|
[
"For",
"recording",
"the",
"key",
"id",
"of",
"the",
"current",
"record",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/PropositionResultSetIterator.java#L128-L134
|
148,943
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/TopologicalSortComparator.java
|
TopologicalSortComparator.compare
|
@Override
public int compare(TemporalPropositionDefinition a1,
TemporalPropositionDefinition a2) {
if (a1 == a2) {
return 0;
} else {
Integer index1 = rule2Index.get(a1.getId());
Integer index2 = rule2Index.get(a2.getId());
return index1.compareTo(index2);
}
}
|
java
|
@Override
public int compare(TemporalPropositionDefinition a1,
TemporalPropositionDefinition a2) {
if (a1 == a2) {
return 0;
} else {
Integer index1 = rule2Index.get(a1.getId());
Integer index2 = rule2Index.get(a2.getId());
return index1.compareTo(index2);
}
}
|
[
"@",
"Override",
"public",
"int",
"compare",
"(",
"TemporalPropositionDefinition",
"a1",
",",
"TemporalPropositionDefinition",
"a2",
")",
"{",
"if",
"(",
"a1",
"==",
"a2",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"Integer",
"index1",
"=",
"rule2Index",
".",
"get",
"(",
"a1",
".",
"getId",
"(",
")",
")",
";",
"Integer",
"index2",
"=",
"rule2Index",
".",
"get",
"(",
"a2",
".",
"getId",
"(",
")",
")",
";",
"return",
"index1",
".",
"compareTo",
"(",
"index2",
")",
";",
"}",
"}"
] |
Compares two temporal proposition definitions topologically according to
the inverse of their abstractedFrom or inducedBy relationships.
@param a1 an {@link TemporalPropositionDefinition}.
@param a2 another {@link TemporalPropositionDefinition}.
@return a negative integer, zero, or a positive integer as the first
argument is less than, equal to, or greater than the second.
|
[
"Compares",
"two",
"temporal",
"proposition",
"definitions",
"topologically",
"according",
"to",
"the",
"inverse",
"of",
"their",
"abstractedFrom",
"or",
"inducedBy",
"relationships",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/TopologicalSortComparator.java#L145-L155
|
148,944
|
kevoree/kevoree-library
|
docker-node/src/main/java/org/kevoree/library/DockerNode.java
|
DockerNode.updateModelAccordingToDocker
|
private void updateModelAccordingToDocker() {
try {
final ModelHelper modelHelper = new ModelHelper(context.getNodeName(), docker, factory);
final ContainerRoot dockerModel = modelHelper.docker2model(modelService.getCurrentModel());
modelService.update(dockerModel, e -> {
if (e == null) {
Log.info("Model updated based on the local Docker engine configuration");
} else {
Log.warn("Failed to update model based on the local Docker engine configuration", e);
}
});
} catch (Exception e) {
Log.warn("Failed to update model based on the local Docker engine configuration", e);
}
}
|
java
|
private void updateModelAccordingToDocker() {
try {
final ModelHelper modelHelper = new ModelHelper(context.getNodeName(), docker, factory);
final ContainerRoot dockerModel = modelHelper.docker2model(modelService.getCurrentModel());
modelService.update(dockerModel, e -> {
if (e == null) {
Log.info("Model updated based on the local Docker engine configuration");
} else {
Log.warn("Failed to update model based on the local Docker engine configuration", e);
}
});
} catch (Exception e) {
Log.warn("Failed to update model based on the local Docker engine configuration", e);
}
}
|
[
"private",
"void",
"updateModelAccordingToDocker",
"(",
")",
"{",
"try",
"{",
"final",
"ModelHelper",
"modelHelper",
"=",
"new",
"ModelHelper",
"(",
"context",
".",
"getNodeName",
"(",
")",
",",
"docker",
",",
"factory",
")",
";",
"final",
"ContainerRoot",
"dockerModel",
"=",
"modelHelper",
".",
"docker2model",
"(",
"modelService",
".",
"getCurrentModel",
"(",
")",
")",
";",
"modelService",
".",
"update",
"(",
"dockerModel",
",",
"e",
"->",
"{",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"Log",
".",
"info",
"(",
"\"Model updated based on the local Docker engine configuration\"",
")",
";",
"}",
"else",
"{",
"Log",
".",
"warn",
"(",
"\"Failed to update model based on the local Docker engine configuration\"",
",",
"e",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"warn",
"(",
"\"Failed to update model based on the local Docker engine configuration\"",
",",
"e",
")",
";",
"}",
"}"
] |
Converts the currentModel state of the Docker engine to a Kevoree model.
This model is then merged with the currentModel in-use model and deployed.
Calling this method subsequently triggers a call to plan(currentModel, targetModel)
|
[
"Converts",
"the",
"currentModel",
"state",
"of",
"the",
"Docker",
"engine",
"to",
"a",
"Kevoree",
"model",
".",
"This",
"model",
"is",
"then",
"merged",
"with",
"the",
"currentModel",
"in",
"-",
"use",
"model",
"and",
"deployed",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/docker-node/src/main/java/org/kevoree/library/DockerNode.java#L100-L114
|
148,945
|
kevoree/kevoree-library
|
docker-node/src/main/java/org/kevoree/library/DockerNode.java
|
DockerNode.plan
|
@Override
public List<AdaptationCommand> plan(ContainerRoot currentModel, ContainerRoot targetModel)
throws KevoreeAdaptationException {
final List<AdaptationCommand> commands = super.plan(currentModel, targetModel);
final List<AdaptationCommand> dockerCommands = new ModelHelper(context.getNodeName(), docker, factory)
.model2docker(currentModel, targetModel);
Log.debug("=== Docker commands ===");
dockerCommands.forEach((cmd) -> Log.debug(" {} [{}]", cmd.getElement().path(), cmd.getType()));
Log.debug("========================");
commands.addAll(dockerCommands);
return commands;
}
|
java
|
@Override
public List<AdaptationCommand> plan(ContainerRoot currentModel, ContainerRoot targetModel)
throws KevoreeAdaptationException {
final List<AdaptationCommand> commands = super.plan(currentModel, targetModel);
final List<AdaptationCommand> dockerCommands = new ModelHelper(context.getNodeName(), docker, factory)
.model2docker(currentModel, targetModel);
Log.debug("=== Docker commands ===");
dockerCommands.forEach((cmd) -> Log.debug(" {} [{}]", cmd.getElement().path(), cmd.getType()));
Log.debug("========================");
commands.addAll(dockerCommands);
return commands;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"AdaptationCommand",
">",
"plan",
"(",
"ContainerRoot",
"currentModel",
",",
"ContainerRoot",
"targetModel",
")",
"throws",
"KevoreeAdaptationException",
"{",
"final",
"List",
"<",
"AdaptationCommand",
">",
"commands",
"=",
"super",
".",
"plan",
"(",
"currentModel",
",",
"targetModel",
")",
";",
"final",
"List",
"<",
"AdaptationCommand",
">",
"dockerCommands",
"=",
"new",
"ModelHelper",
"(",
"context",
".",
"getNodeName",
"(",
")",
",",
"docker",
",",
"factory",
")",
".",
"model2docker",
"(",
"currentModel",
",",
"targetModel",
")",
";",
"Log",
".",
"debug",
"(",
"\"=== Docker commands ===\"",
")",
";",
"dockerCommands",
".",
"forEach",
"(",
"(",
"cmd",
")",
"-",
">",
"Log",
".",
"debug",
"(",
"\" {} [{}]\"",
",",
"cmd",
".",
"getElement",
"(",
")",
".",
"path",
"(",
")",
",",
"cmd",
".",
"getType",
"(",
")",
")",
")",
";",
"Log",
".",
"debug",
"(",
"\"========================\"",
")",
";",
"commands",
".",
"addAll",
"(",
"dockerCommands",
")",
";",
"return",
"commands",
";",
"}"
] |
This is called when the node has to adapt from currentModel to targetModel.
The goal of this method is to return a list of executable adaptation commands according to
the delta between currentModel and targetModel.
@param currentModel the currently in-use model
@param targetModel the model that we want to converge to
@return a list of commands to execute in order to go from currentModel to targetModel
@throws KevoreeAdaptationException when something goes wrong while planning adaptations
|
[
"This",
"is",
"called",
"when",
"the",
"node",
"has",
"to",
"adapt",
"from",
"currentModel",
"to",
"targetModel",
".",
"The",
"goal",
"of",
"this",
"method",
"is",
"to",
"return",
"a",
"list",
"of",
"executable",
"adaptation",
"commands",
"according",
"to",
"the",
"delta",
"between",
"currentModel",
"and",
"targetModel",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/docker-node/src/main/java/org/kevoree/library/DockerNode.java#L126-L137
|
148,946
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/ArgParser.java
|
ArgParser.parse
|
public static HashMap<String,String> parse(String args){
HashMap<String,String> map = new HashMap<>();
if (args != null){
String[] split = args.split(";");
for (String nameValuePair : split) {
String[] nameValue = nameValuePair.split("=");
if (nameValue.length == 2){
map.put(nameValue[0].toLowerCase(), nameValue[1]);
}
}
}
return map;
}
|
java
|
public static HashMap<String,String> parse(String args){
HashMap<String,String> map = new HashMap<>();
if (args != null){
String[] split = args.split(";");
for (String nameValuePair : split) {
String[] nameValue = nameValuePair.split("=");
if (nameValue.length == 2){
map.put(nameValue[0].toLowerCase(), nameValue[1]);
}
}
}
return map;
}
|
[
"public",
"static",
"HashMap",
"<",
"String",
",",
"String",
">",
"parse",
"(",
"String",
"args",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"args",
"!=",
"null",
")",
"{",
"String",
"[",
"]",
"split",
"=",
"args",
".",
"split",
"(",
"\";\"",
")",
";",
"for",
"(",
"String",
"nameValuePair",
":",
"split",
")",
"{",
"String",
"[",
"]",
"nameValue",
"=",
"nameValuePair",
".",
"split",
"(",
"\"=\"",
")",
";",
"if",
"(",
"nameValue",
".",
"length",
"==",
"2",
")",
"{",
"map",
".",
"put",
"(",
"nameValue",
"[",
"0",
"]",
".",
"toLowerCase",
"(",
")",
",",
"nameValue",
"[",
"1",
"]",
")",
";",
"}",
"}",
"}",
"return",
"map",
";",
"}"
] |
Parse the args returning as name value pairs.
|
[
"Parse",
"the",
"args",
"returning",
"as",
"name",
"value",
"pairs",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/ArgParser.java#L13-L28
|
148,947
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/BooleanEditor.java
|
BooleanEditor.setAsText
|
@Override
public void setAsText(final String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
Object newValue = Boolean.valueOf(text);
setValue(newValue);
}
|
java
|
@Override
public void setAsText(final String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
Object newValue = Boolean.valueOf(text);
setValue(newValue);
}
|
[
"@",
"Override",
"public",
"void",
"setAsText",
"(",
"final",
"String",
"text",
")",
"{",
"if",
"(",
"BeanUtils",
".",
"isNull",
"(",
"text",
")",
")",
"{",
"setValue",
"(",
"null",
")",
";",
"return",
";",
"}",
"Object",
"newValue",
"=",
"Boolean",
".",
"valueOf",
"(",
"text",
")",
";",
"setValue",
"(",
"newValue",
")",
";",
"}"
] |
Map the argument text into Boolean.TRUE or Boolean.FALSE using Boolean.valueOf.
|
[
"Map",
"the",
"argument",
"text",
"into",
"Boolean",
".",
"TRUE",
"or",
"Boolean",
".",
"FALSE",
"using",
"Boolean",
".",
"valueOf",
"."
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/BooleanEditor.java#L40-L48
|
148,948
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/SubscribeDecoder.java
|
SubscribeDecoder.decodeSubscription
|
private void decodeSubscription(ByteBuf in, SubscribeMessage message) throws UnsupportedEncodingException {
String topic = Utils.decodeString(in);
byte qos = (byte)(in.readByte() & 0x03);
message.addSubscription(new SubscribeMessage.Couple(qos, topic));
}
|
java
|
private void decodeSubscription(ByteBuf in, SubscribeMessage message) throws UnsupportedEncodingException {
String topic = Utils.decodeString(in);
byte qos = (byte)(in.readByte() & 0x03);
message.addSubscription(new SubscribeMessage.Couple(qos, topic));
}
|
[
"private",
"void",
"decodeSubscription",
"(",
"ByteBuf",
"in",
",",
"SubscribeMessage",
"message",
")",
"throws",
"UnsupportedEncodingException",
"{",
"String",
"topic",
"=",
"Utils",
".",
"decodeString",
"(",
"in",
")",
";",
"byte",
"qos",
"=",
"(",
"byte",
")",
"(",
"in",
".",
"readByte",
"(",
")",
"&",
"0x03",
")",
";",
"message",
".",
"addSubscription",
"(",
"new",
"SubscribeMessage",
".",
"Couple",
"(",
"qos",
",",
"topic",
")",
")",
";",
"}"
] |
Populate the message with couple of Qos, topic
|
[
"Populate",
"the",
"message",
"with",
"couple",
"of",
"Qos",
"topic"
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/SubscribeDecoder.java#L62-L66
|
148,949
|
openbase/jul
|
pattern/default/src/main/java/org/openbase/jul/pattern/CompletableFutureLite.java
|
CompletableFutureLite.cancel
|
@Override
public boolean cancel(final boolean mayInterruptIfRunning) {
synchronized (lock) {
if (isDone()) {
return false;
}
throwable = new CancellationException();
lock.notifyAll();
return true;
}
}
|
java
|
@Override
public boolean cancel(final boolean mayInterruptIfRunning) {
synchronized (lock) {
if (isDone()) {
return false;
}
throwable = new CancellationException();
lock.notifyAll();
return true;
}
}
|
[
"@",
"Override",
"public",
"boolean",
"cancel",
"(",
"final",
"boolean",
"mayInterruptIfRunning",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"isDone",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"throwable",
"=",
"new",
"CancellationException",
"(",
")",
";",
"lock",
".",
"notifyAll",
"(",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Method cancels the future without delivering any specific reason.
@param mayInterruptIfRunning this flag is ignored since this implementation does not use its own computation thread.
@return if this invocation caused this CompletableFuture to be canceled, than {@code true} is returned. Otherwise {@code false} is returned.
|
[
"Method",
"cancels",
"the",
"future",
"without",
"delivering",
"any",
"specific",
"reason",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/pattern/default/src/main/java/org/openbase/jul/pattern/CompletableFutureLite.java#L99-L109
|
148,950
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryConstructorForAlias.java
|
TypeQueryConstructorForAlias.visitCode
|
@Override
public void visitCode() {
mv = cv.visitMethod(ACC_PRIVATE, "<init>", "(Z)V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(1, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, TQ_ROOT_BEAN, "<init>", "(Z)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(2, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, classInfo.getClassName(), "setRoot", "(Ljava/lang/Object;)V", false);
// init all the properties
List<FieldInfo> fields = classInfo.getFields();
if (fields != null) {
for (FieldInfo field : fields) {
field.writeFieldInit(mv);
}
}
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(3, l2);
mv.visitInsn(RETURN);
Label l12 = new Label();
mv.visitLabel(l12);
mv.visitLocalVariable("this", "L" + classInfo.getClassName() + ";", null, l0, l12, 0);
mv.visitLocalVariable("alias", "Z", null, l0, l12, 1);
mv.visitMaxs(5, 2);
mv.visitEnd();
}
|
java
|
@Override
public void visitCode() {
mv = cv.visitMethod(ACC_PRIVATE, "<init>", "(Z)V", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(1, l0);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ILOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, TQ_ROOT_BEAN, "<init>", "(Z)V", false);
Label l1 = new Label();
mv.visitLabel(l1);
mv.visitLineNumber(2, l1);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKEVIRTUAL, classInfo.getClassName(), "setRoot", "(Ljava/lang/Object;)V", false);
// init all the properties
List<FieldInfo> fields = classInfo.getFields();
if (fields != null) {
for (FieldInfo field : fields) {
field.writeFieldInit(mv);
}
}
Label l2 = new Label();
mv.visitLabel(l2);
mv.visitLineNumber(3, l2);
mv.visitInsn(RETURN);
Label l12 = new Label();
mv.visitLabel(l12);
mv.visitLocalVariable("this", "L" + classInfo.getClassName() + ";", null, l0, l12, 0);
mv.visitLocalVariable("alias", "Z", null, l0, l12, 1);
mv.visitMaxs(5, 2);
mv.visitEnd();
}
|
[
"@",
"Override",
"public",
"void",
"visitCode",
"(",
")",
"{",
"mv",
"=",
"cv",
".",
"visitMethod",
"(",
"ACC_PRIVATE",
",",
"\"<init>\"",
",",
"\"(Z)V\"",
",",
"null",
",",
"null",
")",
";",
"mv",
".",
"visitCode",
"(",
")",
";",
"Label",
"l0",
"=",
"new",
"Label",
"(",
")",
";",
"mv",
".",
"visitLabel",
"(",
"l0",
")",
";",
"mv",
".",
"visitLineNumber",
"(",
"1",
",",
"l0",
")",
";",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mv",
".",
"visitVarInsn",
"(",
"ILOAD",
",",
"1",
")",
";",
"mv",
".",
"visitMethodInsn",
"(",
"INVOKESPECIAL",
",",
"TQ_ROOT_BEAN",
",",
"\"<init>\"",
",",
"\"(Z)V\"",
",",
"false",
")",
";",
"Label",
"l1",
"=",
"new",
"Label",
"(",
")",
";",
"mv",
".",
"visitLabel",
"(",
"l1",
")",
";",
"mv",
".",
"visitLineNumber",
"(",
"2",
",",
"l1",
")",
";",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mv",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mv",
".",
"visitMethodInsn",
"(",
"INVOKEVIRTUAL",
",",
"classInfo",
".",
"getClassName",
"(",
")",
",",
"\"setRoot\"",
",",
"\"(Ljava/lang/Object;)V\"",
",",
"false",
")",
";",
"// init all the properties",
"List",
"<",
"FieldInfo",
">",
"fields",
"=",
"classInfo",
".",
"getFields",
"(",
")",
";",
"if",
"(",
"fields",
"!=",
"null",
")",
"{",
"for",
"(",
"FieldInfo",
"field",
":",
"fields",
")",
"{",
"field",
".",
"writeFieldInit",
"(",
"mv",
")",
";",
"}",
"}",
"Label",
"l2",
"=",
"new",
"Label",
"(",
")",
";",
"mv",
".",
"visitLabel",
"(",
"l2",
")",
";",
"mv",
".",
"visitLineNumber",
"(",
"3",
",",
"l2",
")",
";",
"mv",
".",
"visitInsn",
"(",
"RETURN",
")",
";",
"Label",
"l12",
"=",
"new",
"Label",
"(",
")",
";",
"mv",
".",
"visitLabel",
"(",
"l12",
")",
";",
"mv",
".",
"visitLocalVariable",
"(",
"\"this\"",
",",
"\"L\"",
"+",
"classInfo",
".",
"getClassName",
"(",
")",
"+",
"\";\"",
",",
"null",
",",
"l0",
",",
"l12",
",",
"0",
")",
";",
"mv",
".",
"visitLocalVariable",
"(",
"\"alias\"",
",",
"\"Z\"",
",",
"null",
",",
"l0",
",",
"l12",
",",
"1",
")",
";",
"mv",
".",
"visitMaxs",
"(",
"5",
",",
"2",
")",
";",
"mv",
".",
"visitEnd",
"(",
")",
";",
"}"
] |
Write the constructor initialising all the fields eagerly.
|
[
"Write",
"the",
"constructor",
"initialising",
"all",
"the",
"fields",
"eagerly",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryConstructorForAlias.java#L30-L67
|
148,951
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.getHostName
|
public static String getHostName() {
try {
return java.net.InetAddress.getLocalHost().getHostName();
} catch (java.net.UnknownHostException _ex) {
return null;
}
}
|
java
|
public static String getHostName() {
try {
return java.net.InetAddress.getLocalHost().getHostName();
} catch (java.net.UnknownHostException _ex) {
return null;
}
}
|
[
"public",
"static",
"String",
"getHostName",
"(",
")",
"{",
"try",
"{",
"return",
"java",
".",
"net",
".",
"InetAddress",
".",
"getLocalHost",
"(",
")",
".",
"getHostName",
"(",
")",
";",
"}",
"catch",
"(",
"java",
".",
"net",
".",
"UnknownHostException",
"_ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Gets the host name of the local machine.
@return host name
|
[
"Gets",
"the",
"host",
"name",
"of",
"the",
"local",
"machine",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L61-L67
|
148,952
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.getJavaVersion
|
public static String getJavaVersion() {
String[] sysPropParms = new String[] {"java.runtime.version", "java.version"};
for (int i = 0; i < sysPropParms.length; i++) {
String val = System.getProperty(sysPropParms[i]);
if (!StringUtil.isEmpty(val)) {
return val;
}
}
return null;
}
|
java
|
public static String getJavaVersion() {
String[] sysPropParms = new String[] {"java.runtime.version", "java.version"};
for (int i = 0; i < sysPropParms.length; i++) {
String val = System.getProperty(sysPropParms[i]);
if (!StringUtil.isEmpty(val)) {
return val;
}
}
return null;
}
|
[
"public",
"static",
"String",
"getJavaVersion",
"(",
")",
"{",
"String",
"[",
"]",
"sysPropParms",
"=",
"new",
"String",
"[",
"]",
"{",
"\"java.runtime.version\"",
",",
"\"java.version\"",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sysPropParms",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"val",
"=",
"System",
".",
"getProperty",
"(",
"sysPropParms",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"StringUtil",
".",
"isEmpty",
"(",
"val",
")",
")",
"{",
"return",
"val",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Determines the Java version of the executing JVM.
@return Java version
|
[
"Determines",
"the",
"Java",
"version",
"of",
"the",
"executing",
"JVM",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L97-L106
|
148,953
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.concatFilePath
|
public static String concatFilePath(boolean _includeTrailingDelimiter, String..._parts) {
if (_parts == null) {
return null;
}
StringBuilder allParts = new StringBuilder();
for (int i = 0; i < _parts.length; i++) {
if (_parts[i] == null) {
continue;
}
allParts.append(_parts[i]);
if (!_parts[i].endsWith(File.separator)) {
allParts.append(File.separator);
}
}
if (!_includeTrailingDelimiter && allParts.length() > 0) {
return allParts.substring(0, allParts.lastIndexOf(File.separator));
}
return allParts.toString();
}
|
java
|
public static String concatFilePath(boolean _includeTrailingDelimiter, String..._parts) {
if (_parts == null) {
return null;
}
StringBuilder allParts = new StringBuilder();
for (int i = 0; i < _parts.length; i++) {
if (_parts[i] == null) {
continue;
}
allParts.append(_parts[i]);
if (!_parts[i].endsWith(File.separator)) {
allParts.append(File.separator);
}
}
if (!_includeTrailingDelimiter && allParts.length() > 0) {
return allParts.substring(0, allParts.lastIndexOf(File.separator));
}
return allParts.toString();
}
|
[
"public",
"static",
"String",
"concatFilePath",
"(",
"boolean",
"_includeTrailingDelimiter",
",",
"String",
"...",
"_parts",
")",
"{",
"if",
"(",
"_parts",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"StringBuilder",
"allParts",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_parts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_parts",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"allParts",
".",
"append",
"(",
"_parts",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"_parts",
"[",
"i",
"]",
".",
"endsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"allParts",
".",
"append",
"(",
"File",
".",
"separator",
")",
";",
"}",
"}",
"if",
"(",
"!",
"_includeTrailingDelimiter",
"&&",
"allParts",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"return",
"allParts",
".",
"substring",
"(",
"0",
",",
"allParts",
".",
"lastIndexOf",
"(",
"File",
".",
"separator",
")",
")",
";",
"}",
"return",
"allParts",
".",
"toString",
"(",
")",
";",
"}"
] |
Concats a path from all given parts, using the path delimiter for the currently used platform.
@param _includeTrailingDelimiter include delimiter after last token
@param _parts parts to concat
@return concatinated string
|
[
"Concats",
"a",
"path",
"from",
"all",
"given",
"parts",
"using",
"the",
"path",
"delimiter",
"for",
"the",
"currently",
"used",
"platform",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L129-L151
|
148,954
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.appendTrailingDelimiter
|
public static String appendTrailingDelimiter(String _filePath) {
if (_filePath == null) {
return null;
}
if (!_filePath.endsWith(File.separator)) {
_filePath += File.separator;
}
return _filePath;
}
|
java
|
public static String appendTrailingDelimiter(String _filePath) {
if (_filePath == null) {
return null;
}
if (!_filePath.endsWith(File.separator)) {
_filePath += File.separator;
}
return _filePath;
}
|
[
"public",
"static",
"String",
"appendTrailingDelimiter",
"(",
"String",
"_filePath",
")",
"{",
"if",
"(",
"_filePath",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"_filePath",
".",
"endsWith",
"(",
"File",
".",
"separator",
")",
")",
"{",
"_filePath",
"+=",
"File",
".",
"separator",
";",
"}",
"return",
"_filePath",
";",
"}"
] |
Appends the OS specific path delimiter to the end of the String, if it is missing.
@param _filePath file path
@return String
|
[
"Appends",
"the",
"OS",
"specific",
"path",
"delimiter",
"to",
"the",
"end",
"of",
"the",
"String",
"if",
"it",
"is",
"missing",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L183-L191
|
148,955
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.createTempDirectory
|
public static File createTempDirectory(String _path, String _name, boolean _deleteOnExit) {
File outputDir = new File(concatFilePath(_path, _name));
if (!outputDir.exists()) {
try {
Files.createDirectory(Paths.get(outputDir.toString()));
} catch (IOException _ex) {
LOGGER.error("Error while creating temp directory: ", _ex);
}
} else {
return null;
}
if (_deleteOnExit) {
outputDir.deleteOnExit();
}
return outputDir;
}
|
java
|
public static File createTempDirectory(String _path, String _name, boolean _deleteOnExit) {
File outputDir = new File(concatFilePath(_path, _name));
if (!outputDir.exists()) {
try {
Files.createDirectory(Paths.get(outputDir.toString()));
} catch (IOException _ex) {
LOGGER.error("Error while creating temp directory: ", _ex);
}
} else {
return null;
}
if (_deleteOnExit) {
outputDir.deleteOnExit();
}
return outputDir;
}
|
[
"public",
"static",
"File",
"createTempDirectory",
"(",
"String",
"_path",
",",
"String",
"_name",
",",
"boolean",
"_deleteOnExit",
")",
"{",
"File",
"outputDir",
"=",
"new",
"File",
"(",
"concatFilePath",
"(",
"_path",
",",
"_name",
")",
")",
";",
"if",
"(",
"!",
"outputDir",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"Files",
".",
"createDirectory",
"(",
"Paths",
".",
"get",
"(",
"outputDir",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error while creating temp directory: \"",
",",
"_ex",
")",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"_deleteOnExit",
")",
"{",
"outputDir",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"return",
"outputDir",
";",
"}"
] |
Creates a new temporary directory in the given path.
@param _path path
@param _name directory name
@param _deleteOnExit delete directory on jvm shutdown
@return created Directory, null if directory/file was already existing
|
[
"Creates",
"a",
"new",
"temporary",
"directory",
"in",
"the",
"given",
"path",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L200-L216
|
148,956
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.createTempDirectory
|
public static File createTempDirectory(String _path, String _prefix, int _length, boolean _timestamp, boolean _deleteOnExit) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_HHmmss-SSS");
String randomStr = StringUtil.randomString(_length);
StringBuilder fileName = new StringBuilder();
if (_prefix != null) {
fileName.append(_prefix);
}
fileName.append(randomStr);
if (_timestamp) {
fileName.append("_").append(formatter.format(new Date()));
}
File result = createTempDirectory(_path, fileName.toString(), _deleteOnExit);
while (result == null) {
result = createTempDirectory(_path, _prefix, _length, _timestamp, _deleteOnExit);
}
return result;
}
|
java
|
public static File createTempDirectory(String _path, String _prefix, int _length, boolean _timestamp, boolean _deleteOnExit) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd_HHmmss-SSS");
String randomStr = StringUtil.randomString(_length);
StringBuilder fileName = new StringBuilder();
if (_prefix != null) {
fileName.append(_prefix);
}
fileName.append(randomStr);
if (_timestamp) {
fileName.append("_").append(formatter.format(new Date()));
}
File result = createTempDirectory(_path, fileName.toString(), _deleteOnExit);
while (result == null) {
result = createTempDirectory(_path, _prefix, _length, _timestamp, _deleteOnExit);
}
return result;
}
|
[
"public",
"static",
"File",
"createTempDirectory",
"(",
"String",
"_path",
",",
"String",
"_prefix",
",",
"int",
"_length",
",",
"boolean",
"_timestamp",
",",
"boolean",
"_deleteOnExit",
")",
"{",
"SimpleDateFormat",
"formatter",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyyMMdd_HHmmss-SSS\"",
")",
";",
"String",
"randomStr",
"=",
"StringUtil",
".",
"randomString",
"(",
"_length",
")",
";",
"StringBuilder",
"fileName",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"_prefix",
"!=",
"null",
")",
"{",
"fileName",
".",
"append",
"(",
"_prefix",
")",
";",
"}",
"fileName",
".",
"append",
"(",
"randomStr",
")",
";",
"if",
"(",
"_timestamp",
")",
"{",
"fileName",
".",
"append",
"(",
"\"_\"",
")",
".",
"append",
"(",
"formatter",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
")",
";",
"}",
"File",
"result",
"=",
"createTempDirectory",
"(",
"_path",
",",
"fileName",
".",
"toString",
"(",
")",
",",
"_deleteOnExit",
")",
";",
"while",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"createTempDirectory",
"(",
"_path",
",",
"_prefix",
",",
"_length",
",",
"_timestamp",
",",
"_deleteOnExit",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Creates a temporary directory in the given path.
You can specify certain files to get a random unique name.
@param _path where to place the temp folder
@param _prefix prefix of the folder
@param _length length of random chars
@param _timestamp add timestamp (yyyyMMdd_HHmmss-SSS) to directory name
@param _deleteOnExit mark directory for deletion on jvm termination
@return file
|
[
"Creates",
"a",
"temporary",
"directory",
"in",
"the",
"given",
"path",
".",
"You",
"can",
"specify",
"certain",
"files",
"to",
"get",
"a",
"random",
"unique",
"name",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L228-L247
|
148,957
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.isDebuggingEnabled
|
public static boolean isDebuggingEnabled() {
boolean debuggingEnabled = false;
if (ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0) {
debuggingEnabled = true;
} else if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Xdebug")) {
debuggingEnabled = true;
} else if (System.getProperty("debug", "").equals("true")) {
debuggingEnabled = true;
}
return debuggingEnabled;
}
|
java
|
public static boolean isDebuggingEnabled() {
boolean debuggingEnabled = false;
if (ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0) {
debuggingEnabled = true;
} else if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Xdebug")) {
debuggingEnabled = true;
} else if (System.getProperty("debug", "").equals("true")) {
debuggingEnabled = true;
}
return debuggingEnabled;
}
|
[
"public",
"static",
"boolean",
"isDebuggingEnabled",
"(",
")",
"{",
"boolean",
"debuggingEnabled",
"=",
"false",
";",
"if",
"(",
"ManagementFactory",
".",
"getRuntimeMXBean",
"(",
")",
".",
"getInputArguments",
"(",
")",
".",
"toString",
"(",
")",
".",
"indexOf",
"(",
"\"-agentlib:jdwp\"",
")",
">",
"0",
")",
"{",
"debuggingEnabled",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"ManagementFactory",
".",
"getRuntimeMXBean",
"(",
")",
".",
"getInputArguments",
"(",
")",
".",
"contains",
"(",
"\"-Xdebug\"",
")",
")",
"{",
"debuggingEnabled",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"System",
".",
"getProperty",
"(",
"\"debug\"",
",",
"\"\"",
")",
".",
"equals",
"(",
"\"true\"",
")",
")",
"{",
"debuggingEnabled",
"=",
"true",
";",
"}",
"return",
"debuggingEnabled",
";",
"}"
] |
Examines some system properties to determine whether the process is likely being debugged
in an IDE or remotely.
@return true if being debugged, false otherwise
|
[
"Examines",
"some",
"system",
"properties",
"to",
"determine",
"whether",
"the",
"process",
"is",
"likely",
"being",
"debugged",
"in",
"an",
"IDE",
"or",
"remotely",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L254-L264
|
148,958
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.formatBytesHumanReadable
|
public static String formatBytesHumanReadable(long _bytes, boolean _use1000BytesPerMb) {
int unit = _use1000BytesPerMb ? 1000 : 1024;
if (_bytes < unit) {
return _bytes + " B";
}
int exp = (int) (Math.log(_bytes) / Math.log(unit));
String pre = (_use1000BytesPerMb ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (_use1000BytesPerMb ? "" : "i");
return String.format("%.1f %sB", _bytes / Math.pow(unit, exp), pre);
}
|
java
|
public static String formatBytesHumanReadable(long _bytes, boolean _use1000BytesPerMb) {
int unit = _use1000BytesPerMb ? 1000 : 1024;
if (_bytes < unit) {
return _bytes + " B";
}
int exp = (int) (Math.log(_bytes) / Math.log(unit));
String pre = (_use1000BytesPerMb ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (_use1000BytesPerMb ? "" : "i");
return String.format("%.1f %sB", _bytes / Math.pow(unit, exp), pre);
}
|
[
"public",
"static",
"String",
"formatBytesHumanReadable",
"(",
"long",
"_bytes",
",",
"boolean",
"_use1000BytesPerMb",
")",
"{",
"int",
"unit",
"=",
"_use1000BytesPerMb",
"?",
"1000",
":",
"1024",
";",
"if",
"(",
"_bytes",
"<",
"unit",
")",
"{",
"return",
"_bytes",
"+",
"\" B\"",
";",
"}",
"int",
"exp",
"=",
"(",
"int",
")",
"(",
"Math",
".",
"log",
"(",
"_bytes",
")",
"/",
"Math",
".",
"log",
"(",
"unit",
")",
")",
";",
"String",
"pre",
"=",
"(",
"_use1000BytesPerMb",
"?",
"\"kMGTPE\"",
":",
"\"KMGTPE\"",
")",
".",
"charAt",
"(",
"exp",
"-",
"1",
")",
"+",
"(",
"_use1000BytesPerMb",
"?",
"\"\"",
":",
"\"i\"",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"%.1f %sB\"",
",",
"_bytes",
"/",
"Math",
".",
"pow",
"(",
"unit",
",",
"exp",
")",
",",
"pre",
")",
";",
"}"
] |
Formats a file size given in byte to something human readable.
@param _bytes size in bytes
@param _use1000BytesPerMb use 1000 bytes per MByte instead of 1024
@return String
|
[
"Formats",
"a",
"file",
"size",
"given",
"in",
"byte",
"to",
"something",
"human",
"readable",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L329-L337
|
148,959
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.getApplicationVersionFromJar
|
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
try {
Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attribs = manifest.getMainAttributes();
String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
if (ver == null) {
return _default;
}
String rev = attribs.getValue("Implementation-Revision");
if (rev != null) {
ver += "-r" + rev;
}
return ver;
}
} catch (IOException _ex) {
}
return _default;
}
|
java
|
public static String getApplicationVersionFromJar(Class<?> _class, String _default) {
try {
Enumeration<URL> resources = _class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attribs = manifest.getMainAttributes();
String ver = attribs.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
if (ver == null) {
return _default;
}
String rev = attribs.getValue("Implementation-Revision");
if (rev != null) {
ver += "-r" + rev;
}
return ver;
}
} catch (IOException _ex) {
}
return _default;
}
|
[
"public",
"static",
"String",
"getApplicationVersionFromJar",
"(",
"Class",
"<",
"?",
">",
"_class",
",",
"String",
"_default",
")",
"{",
"try",
"{",
"Enumeration",
"<",
"URL",
">",
"resources",
"=",
"_class",
".",
"getClassLoader",
"(",
")",
".",
"getResources",
"(",
"\"META-INF/MANIFEST.MF\"",
")",
";",
"while",
"(",
"resources",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Manifest",
"manifest",
"=",
"new",
"Manifest",
"(",
"resources",
".",
"nextElement",
"(",
")",
".",
"openStream",
"(",
")",
")",
";",
"Attributes",
"attribs",
"=",
"manifest",
".",
"getMainAttributes",
"(",
")",
";",
"String",
"ver",
"=",
"attribs",
".",
"getValue",
"(",
"Attributes",
".",
"Name",
".",
"IMPLEMENTATION_VERSION",
")",
";",
"if",
"(",
"ver",
"==",
"null",
")",
"{",
"return",
"_default",
";",
"}",
"String",
"rev",
"=",
"attribs",
".",
"getValue",
"(",
"\"Implementation-Revision\"",
")",
";",
"if",
"(",
"rev",
"!=",
"null",
")",
"{",
"ver",
"+=",
"\"-r\"",
"+",
"rev",
";",
"}",
"return",
"ver",
";",
"}",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"}",
"return",
"_default",
";",
"}"
] |
Read the JARs manifest and try to get the current program version from it.
@param _class class to use as entry point
@param _default default string to use if version could not be found
@return version or null
|
[
"Read",
"the",
"JARs",
"manifest",
"and",
"try",
"to",
"get",
"the",
"current",
"program",
"version",
"from",
"it",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L345-L368
|
148,960
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/SystemUtil.java
|
SystemUtil.normalizePath
|
public static String normalizePath(String _path, boolean _appendFinalSeparator) {
if (_path == null) {
return _path;
}
String path = _path
.replace("\\", FILE_SEPARATOR)
.replace("/", FILE_SEPARATOR);
if (_appendFinalSeparator && !path.endsWith(FILE_SEPARATOR)) {
path += FILE_SEPARATOR;
}
return path;
}
|
java
|
public static String normalizePath(String _path, boolean _appendFinalSeparator) {
if (_path == null) {
return _path;
}
String path = _path
.replace("\\", FILE_SEPARATOR)
.replace("/", FILE_SEPARATOR);
if (_appendFinalSeparator && !path.endsWith(FILE_SEPARATOR)) {
path += FILE_SEPARATOR;
}
return path;
}
|
[
"public",
"static",
"String",
"normalizePath",
"(",
"String",
"_path",
",",
"boolean",
"_appendFinalSeparator",
")",
"{",
"if",
"(",
"_path",
"==",
"null",
")",
"{",
"return",
"_path",
";",
"}",
"String",
"path",
"=",
"_path",
".",
"replace",
"(",
"\"\\\\\"",
",",
"FILE_SEPARATOR",
")",
".",
"replace",
"(",
"\"/\"",
",",
"FILE_SEPARATOR",
")",
";",
"if",
"(",
"_appendFinalSeparator",
"&&",
"!",
"path",
".",
"endsWith",
"(",
"FILE_SEPARATOR",
")",
")",
"{",
"path",
"+=",
"FILE_SEPARATOR",
";",
"}",
"return",
"path",
";",
"}"
] |
Normalize a file system path expression for the current OS.
Replaces path separators by this OS's path separator.
Appends a final path separator if parameter is set
and if not yet present.
@param _path path
@param _appendFinalSeparator controls appendix of separator at the end
@return normalized path
|
[
"Normalize",
"a",
"file",
"system",
"path",
"expression",
"for",
"the",
"current",
"OS",
".",
"Replaces",
"path",
"separators",
"by",
"this",
"OS",
"s",
"path",
"separator",
".",
"Appends",
"a",
"final",
"path",
"separator",
"if",
"parameter",
"is",
"set",
"and",
"if",
"not",
"yet",
"present",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/SystemUtil.java#L409-L421
|
148,961
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java
|
ConnectionManager.init
|
void init() throws KnowledgeSourceBackendInitializationException {
if (this.project == null) {
Util.logger().log(Level.FINE, "Opening Protege project {0}",
this.projectIdentifier);
this.project = initProject();
if (this.project == null) {
throw new KnowledgeSourceBackendInitializationException(
"Could not load project " + this.projectIdentifier);
} else {
this.protegeKnowledgeBase = this.project.getKnowledgeBase();
Util.logger().log(Level.FINE,
"Project {0} opened successfully",
this.projectIdentifier);
}
}
}
|
java
|
void init() throws KnowledgeSourceBackendInitializationException {
if (this.project == null) {
Util.logger().log(Level.FINE, "Opening Protege project {0}",
this.projectIdentifier);
this.project = initProject();
if (this.project == null) {
throw new KnowledgeSourceBackendInitializationException(
"Could not load project " + this.projectIdentifier);
} else {
this.protegeKnowledgeBase = this.project.getKnowledgeBase();
Util.logger().log(Level.FINE,
"Project {0} opened successfully",
this.projectIdentifier);
}
}
}
|
[
"void",
"init",
"(",
")",
"throws",
"KnowledgeSourceBackendInitializationException",
"{",
"if",
"(",
"this",
".",
"project",
"==",
"null",
")",
"{",
"Util",
".",
"logger",
"(",
")",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Opening Protege project {0}\"",
",",
"this",
".",
"projectIdentifier",
")",
";",
"this",
".",
"project",
"=",
"initProject",
"(",
")",
";",
"if",
"(",
"this",
".",
"project",
"==",
"null",
")",
"{",
"throw",
"new",
"KnowledgeSourceBackendInitializationException",
"(",
"\"Could not load project \"",
"+",
"this",
".",
"projectIdentifier",
")",
";",
"}",
"else",
"{",
"this",
".",
"protegeKnowledgeBase",
"=",
"this",
".",
"project",
".",
"getKnowledgeBase",
"(",
")",
";",
"Util",
".",
"logger",
"(",
")",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Project {0} opened successfully\"",
",",
"this",
".",
"projectIdentifier",
")",
";",
"}",
"}",
"}"
] |
Opens the project.
@throws KnowledgeSourceBackendInitializationException if an error
occurs.
|
[
"Opens",
"the",
"project",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java#L83-L98
|
148,962
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java
|
ConnectionManager.close
|
void close() {
if (this.project != null) {
Util.logger().log(Level.FINE, "Closing Protege project {0}",
this.projectIdentifier);
for (Iterator<ProjectListener> itr =
this.projectListeners.iterator(); itr.hasNext(); ) {
this.project.removeProjectListener(itr.next());
itr.remove();
}
try {
this.project.dispose();
Util.logger().fine("Done closing connection.");
} catch (IllegalStateException e) {
/*
* Protege registers a shutdown hook that is removed when
* dispose() is called on a project. However, we might call this
* method during an already started shutdown process. See
* documentation for java.lang.Runtime.removeShutdownHook. This
* exception should be harmless, unless there are other reasons
* dispose() could throw this exception?
*/
Util.logger().fine("Done closing connection.");
} finally {
this.project = null;
}
}
}
|
java
|
void close() {
if (this.project != null) {
Util.logger().log(Level.FINE, "Closing Protege project {0}",
this.projectIdentifier);
for (Iterator<ProjectListener> itr =
this.projectListeners.iterator(); itr.hasNext(); ) {
this.project.removeProjectListener(itr.next());
itr.remove();
}
try {
this.project.dispose();
Util.logger().fine("Done closing connection.");
} catch (IllegalStateException e) {
/*
* Protege registers a shutdown hook that is removed when
* dispose() is called on a project. However, we might call this
* method during an already started shutdown process. See
* documentation for java.lang.Runtime.removeShutdownHook. This
* exception should be harmless, unless there are other reasons
* dispose() could throw this exception?
*/
Util.logger().fine("Done closing connection.");
} finally {
this.project = null;
}
}
}
|
[
"void",
"close",
"(",
")",
"{",
"if",
"(",
"this",
".",
"project",
"!=",
"null",
")",
"{",
"Util",
".",
"logger",
"(",
")",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Closing Protege project {0}\"",
",",
"this",
".",
"projectIdentifier",
")",
";",
"for",
"(",
"Iterator",
"<",
"ProjectListener",
">",
"itr",
"=",
"this",
".",
"projectListeners",
".",
"iterator",
"(",
")",
";",
"itr",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"this",
".",
"project",
".",
"removeProjectListener",
"(",
"itr",
".",
"next",
"(",
")",
")",
";",
"itr",
".",
"remove",
"(",
")",
";",
"}",
"try",
"{",
"this",
".",
"project",
".",
"dispose",
"(",
")",
";",
"Util",
".",
"logger",
"(",
")",
".",
"fine",
"(",
"\"Done closing connection.\"",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"/*\n * Protege registers a shutdown hook that is removed when\n * dispose() is called on a project. However, we might call this\n * method during an already started shutdown process. See\n * documentation for java.lang.Runtime.removeShutdownHook. This\n * exception should be harmless, unless there are other reasons\n * dispose() could throw this exception?\n */",
"Util",
".",
"logger",
"(",
")",
".",
"fine",
"(",
"\"Done closing connection.\"",
")",
";",
"}",
"finally",
"{",
"this",
".",
"project",
"=",
"null",
";",
"}",
"}",
"}"
] |
Closes the project.
|
[
"Closes",
"the",
"project",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java#L111-L139
|
148,963
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java
|
ConnectionManager.getFromProtege
|
private <S, T> S getFromProtege(T obj, ProtegeCommand<S, T> getter)
throws KnowledgeSourceReadException {
if (protegeKnowledgeBase != null && getter != null) {
int tries = TRIES;
Exception lastException = null;
do {
try {
return getter.getHelper(obj);
} catch (Exception e) {
lastException = e;
Util.logger().log(
Level.WARNING,
"Exception attempting to "
+ getter.getWhat() + " " + obj, e);
tries--;
}
close();
try {
init();
} catch (KnowledgeSourceBackendInitializationException e) {
throw new KnowledgeSourceReadException(
"Exception attempting to "
+ getter.getWhat() + " " + obj, e);
}
} while (tries > 0);
throw new KnowledgeSourceReadException(
"Failed to " + getter.getWhat() + " "
+ obj + " after "
+ TRIES + " tries", lastException);
}
return null;
}
|
java
|
private <S, T> S getFromProtege(T obj, ProtegeCommand<S, T> getter)
throws KnowledgeSourceReadException {
if (protegeKnowledgeBase != null && getter != null) {
int tries = TRIES;
Exception lastException = null;
do {
try {
return getter.getHelper(obj);
} catch (Exception e) {
lastException = e;
Util.logger().log(
Level.WARNING,
"Exception attempting to "
+ getter.getWhat() + " " + obj, e);
tries--;
}
close();
try {
init();
} catch (KnowledgeSourceBackendInitializationException e) {
throw new KnowledgeSourceReadException(
"Exception attempting to "
+ getter.getWhat() + " " + obj, e);
}
} while (tries > 0);
throw new KnowledgeSourceReadException(
"Failed to " + getter.getWhat() + " "
+ obj + " after "
+ TRIES + " tries", lastException);
}
return null;
}
|
[
"private",
"<",
"S",
",",
"T",
">",
"S",
"getFromProtege",
"(",
"T",
"obj",
",",
"ProtegeCommand",
"<",
"S",
",",
"T",
">",
"getter",
")",
"throws",
"KnowledgeSourceReadException",
"{",
"if",
"(",
"protegeKnowledgeBase",
"!=",
"null",
"&&",
"getter",
"!=",
"null",
")",
"{",
"int",
"tries",
"=",
"TRIES",
";",
"Exception",
"lastException",
"=",
"null",
";",
"do",
"{",
"try",
"{",
"return",
"getter",
".",
"getHelper",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"Util",
".",
"logger",
"(",
")",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Exception attempting to \"",
"+",
"getter",
".",
"getWhat",
"(",
")",
"+",
"\" \"",
"+",
"obj",
",",
"e",
")",
";",
"tries",
"--",
";",
"}",
"close",
"(",
")",
";",
"try",
"{",
"init",
"(",
")",
";",
"}",
"catch",
"(",
"KnowledgeSourceBackendInitializationException",
"e",
")",
"{",
"throw",
"new",
"KnowledgeSourceReadException",
"(",
"\"Exception attempting to \"",
"+",
"getter",
".",
"getWhat",
"(",
")",
"+",
"\" \"",
"+",
"obj",
",",
"e",
")",
";",
"}",
"}",
"while",
"(",
"tries",
">",
"0",
")",
";",
"throw",
"new",
"KnowledgeSourceReadException",
"(",
"\"Failed to \"",
"+",
"getter",
".",
"getWhat",
"(",
")",
"+",
"\" \"",
"+",
"obj",
"+",
"\" after \"",
"+",
"TRIES",
"+",
"\" tries\"",
",",
"lastException",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Executes a command upon the Protege knowledge base, retrying if needed.
@param <S> The type of what is returned by the getter.
@param <T> The type of what is passed to protege as a parameter.
@param obj What is passed to Protege as a parameter.
@param getter the <code>ProtegeCommand</code>.
@return what is returned from the Protege command.
|
[
"Executes",
"a",
"command",
"upon",
"the",
"Protege",
"knowledge",
"base",
"retrying",
"if",
"needed",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java#L233-L264
|
148,964
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java
|
ConnectionManager.createInstance
|
Instance createInstance(String name, Cls cls)
throws KnowledgeSourceReadException {
return getFromProtege(new InstanceSpec(name, cls), INSTANCE_CREATOR);
}
|
java
|
Instance createInstance(String name, Cls cls)
throws KnowledgeSourceReadException {
return getFromProtege(new InstanceSpec(name, cls), INSTANCE_CREATOR);
}
|
[
"Instance",
"createInstance",
"(",
"String",
"name",
",",
"Cls",
"cls",
")",
"throws",
"KnowledgeSourceReadException",
"{",
"return",
"getFromProtege",
"(",
"new",
"InstanceSpec",
"(",
"name",
",",
"cls",
")",
",",
"INSTANCE_CREATOR",
")",
";",
"}"
] |
Creates a new instance in the knowledge base.
@param name the name <code>String</code> of the instance.
@param cls the <code>Cls</code> of the instance.
@return a new <code>Instance</code>, or <code>null</code> if an
invalid class specification was provided.
@see ConnectionManager#INSTANCE_CREATOR
|
[
"Creates",
"a",
"new",
"instance",
"in",
"the",
"knowledge",
"base",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/ConnectionManager.java#L475-L478
|
148,965
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/ConverterUtil.java
|
ConverterUtil.strToInt
|
public static Integer strToInt(String _str, Integer _default) {
if (_str == null) {
return _default;
}
if (TypeUtil.isInteger(_str, true)) {
return Integer.valueOf(_str);
} else {
return _default;
}
}
|
java
|
public static Integer strToInt(String _str, Integer _default) {
if (_str == null) {
return _default;
}
if (TypeUtil.isInteger(_str, true)) {
return Integer.valueOf(_str);
} else {
return _default;
}
}
|
[
"public",
"static",
"Integer",
"strToInt",
"(",
"String",
"_str",
",",
"Integer",
"_default",
")",
"{",
"if",
"(",
"_str",
"==",
"null",
")",
"{",
"return",
"_default",
";",
"}",
"if",
"(",
"TypeUtil",
".",
"isInteger",
"(",
"_str",
",",
"true",
")",
")",
"{",
"return",
"Integer",
".",
"valueOf",
"(",
"_str",
")",
";",
"}",
"else",
"{",
"return",
"_default",
";",
"}",
"}"
] |
Convert given String to Integer, returns _default if String is not an integer.
@param _str
@param _default
@return _str as Integer or _default value
|
[
"Convert",
"given",
"String",
"to",
"Integer",
"returns",
"_default",
"if",
"String",
"is",
"not",
"an",
"integer",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/ConverterUtil.java#L25-L34
|
148,966
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/ConverterUtil.java
|
ConverterUtil.toProperties
|
public static Properties toProperties(Map<?, ?> _map) {
Properties props = new Properties();
props.putAll(_map);
return props;
}
|
java
|
public static Properties toProperties(Map<?, ?> _map) {
Properties props = new Properties();
props.putAll(_map);
return props;
}
|
[
"public",
"static",
"Properties",
"toProperties",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"_map",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"props",
".",
"putAll",
"(",
"_map",
")",
";",
"return",
"props",
";",
"}"
] |
Convertes a map to a Properties object.
@param _map
@return Properties object
|
[
"Convertes",
"a",
"map",
"to",
"a",
"Properties",
"object",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/ConverterUtil.java#L60-L64
|
148,967
|
udoprog/tiny-serializer-java
|
tiny-serializer-core/src/main/java/eu/toolchain/serializer/TinySerializer.java
|
TinySerializer.nullable
|
@Override
public <T> Serializer<T> nullable(Serializer<T> serializer) {
return new NullSerializer<T>(serializer);
}
|
java
|
@Override
public <T> Serializer<T> nullable(Serializer<T> serializer) {
return new NullSerializer<T>(serializer);
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"Serializer",
"<",
"T",
">",
"nullable",
"(",
"Serializer",
"<",
"T",
">",
"serializer",
")",
"{",
"return",
"new",
"NullSerializer",
"<",
"T",
">",
"(",
"serializer",
")",
";",
"}"
] |
Build a serializer that is capable of serializing null values.
@return
|
[
"Build",
"a",
"serializer",
"that",
"is",
"capable",
"of",
"serializing",
"null",
"values",
"."
] |
e2a7d9e7eb9125a51a17ba3abad0b291a97f9c6f
|
https://github.com/udoprog/tiny-serializer-java/blob/e2a7d9e7eb9125a51a17ba3abad0b291a97f9c6f/tiny-serializer-core/src/main/java/eu/toolchain/serializer/TinySerializer.java#L189-L192
|
148,968
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readProperties
|
public static Properties readProperties(File _file) {
if (_file.exists()) {
try {
return readProperties(new FileInputStream(_file));
} catch (FileNotFoundException _ex) {
LOGGER.info("Could not load properties file: " + _file, _ex);
}
}
return null;
}
|
java
|
public static Properties readProperties(File _file) {
if (_file.exists()) {
try {
return readProperties(new FileInputStream(_file));
} catch (FileNotFoundException _ex) {
LOGGER.info("Could not load properties file: " + _file, _ex);
}
}
return null;
}
|
[
"public",
"static",
"Properties",
"readProperties",
"(",
"File",
"_file",
")",
"{",
"if",
"(",
"_file",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"return",
"readProperties",
"(",
"new",
"FileInputStream",
"(",
"_file",
")",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"_ex",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Could not load properties file: \"",
"+",
"_file",
",",
"_ex",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Trys to read a properties file.
Returns null if properties file could not be loaded
@param _file
@return Properties Object or null
|
[
"Trys",
"to",
"read",
"a",
"properties",
"file",
".",
"Returns",
"null",
"if",
"properties",
"file",
"could",
"not",
"be",
"loaded"
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L39-L48
|
148,969
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readProperties
|
public static Properties readProperties(InputStream _stream) {
Properties props = new Properties();
if (_stream == null) {
return null;
}
try {
props.load(_stream);
return props;
} catch (IOException | NumberFormatException _ex) {
LOGGER.warn("Could not properties: ", _ex);
}
return null;
}
|
java
|
public static Properties readProperties(InputStream _stream) {
Properties props = new Properties();
if (_stream == null) {
return null;
}
try {
props.load(_stream);
return props;
} catch (IOException | NumberFormatException _ex) {
LOGGER.warn("Could not properties: ", _ex);
}
return null;
}
|
[
"public",
"static",
"Properties",
"readProperties",
"(",
"InputStream",
"_stream",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"_stream",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"props",
".",
"load",
"(",
"_stream",
")",
";",
"return",
"props",
";",
"}",
"catch",
"(",
"IOException",
"|",
"NumberFormatException",
"_ex",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Could not properties: \"",
",",
"_ex",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Tries to read a properties file from an inputstream.
@param _stream
@return properties object/null
|
[
"Tries",
"to",
"read",
"a",
"properties",
"file",
"from",
"an",
"inputstream",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L55-L68
|
148,970
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.writeProperties
|
public static boolean writeProperties(File _file, Properties _props) {
LOGGER.debug("Trying to write Properties to file: " + _file);
try (FileOutputStream out = new FileOutputStream(_file)) {
_props.store(out, _file.getName());
LOGGER.debug("Successfully wrote properties to file: " + _file);
} catch (IOException _ex) {
LOGGER.warn("Could not save File: " + _file, _ex);
return false;
}
return true;
}
|
java
|
public static boolean writeProperties(File _file, Properties _props) {
LOGGER.debug("Trying to write Properties to file: " + _file);
try (FileOutputStream out = new FileOutputStream(_file)) {
_props.store(out, _file.getName());
LOGGER.debug("Successfully wrote properties to file: " + _file);
} catch (IOException _ex) {
LOGGER.warn("Could not save File: " + _file, _ex);
return false;
}
return true;
}
|
[
"public",
"static",
"boolean",
"writeProperties",
"(",
"File",
"_file",
",",
"Properties",
"_props",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Trying to write Properties to file: \"",
"+",
"_file",
")",
";",
"try",
"(",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"_file",
")",
")",
"{",
"_props",
".",
"store",
"(",
"out",
",",
"_file",
".",
"getName",
"(",
")",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Successfully wrote properties to file: \"",
"+",
"_file",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Could not save File: \"",
"+",
"_file",
",",
"_ex",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Writes a properties Object to file.
Returns true on success, false otherwise.
@param _file
@param _props
@return true on success, false otherwise
|
[
"Writes",
"a",
"properties",
"Object",
"to",
"file",
".",
"Returns",
"true",
"on",
"success",
"false",
"otherwise",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L98-L108
|
148,971
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readPropertiesBoolean
|
public static boolean readPropertiesBoolean(Properties _props, String _property) {
if (_props.containsKey(_property)) {
if (_props.getProperty(_property).matches("(?i)(1|yes|true|enabled|on|y)")) {
return true;
}
}
return false;
}
|
java
|
public static boolean readPropertiesBoolean(Properties _props, String _property) {
if (_props.containsKey(_property)) {
if (_props.getProperty(_property).matches("(?i)(1|yes|true|enabled|on|y)")) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"readPropertiesBoolean",
"(",
"Properties",
"_props",
",",
"String",
"_property",
")",
"{",
"if",
"(",
"_props",
".",
"containsKey",
"(",
"_property",
")",
")",
"{",
"if",
"(",
"_props",
".",
"getProperty",
"(",
"_property",
")",
".",
"matches",
"(",
"\"(?i)(1|yes|true|enabled|on|y)\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Reads a property as boolean from an properties object.
Returns true if read property matches 1, yes, true, enabled, on, y
@param _props
@param _property
@return
|
[
"Reads",
"a",
"property",
"as",
"boolean",
"from",
"an",
"properties",
"object",
".",
"Returns",
"true",
"if",
"read",
"property",
"matches",
"1",
"yes",
"true",
"enabled",
"on",
"y"
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L129-L136
|
148,972
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readFileToString
|
public static String readFileToString(String _file) {
List<String> localText = getTextfileFromUrl(_file);
if (localText == null) {
return null;
}
return StringUtil.join(guessLineTerminatorOfFile(_file), localText);
}
|
java
|
public static String readFileToString(String _file) {
List<String> localText = getTextfileFromUrl(_file);
if (localText == null) {
return null;
}
return StringUtil.join(guessLineTerminatorOfFile(_file), localText);
}
|
[
"public",
"static",
"String",
"readFileToString",
"(",
"String",
"_file",
")",
"{",
"List",
"<",
"String",
">",
"localText",
"=",
"getTextfileFromUrl",
"(",
"_file",
")",
";",
"if",
"(",
"localText",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"StringUtil",
".",
"join",
"(",
"guessLineTerminatorOfFile",
"(",
"_file",
")",
",",
"localText",
")",
";",
"}"
] |
Reads a file and returns it's content as string.
@param _file
@return
|
[
"Reads",
"a",
"file",
"and",
"returns",
"it",
"s",
"content",
"as",
"string",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L240-L247
|
148,973
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readFileFromClassPath
|
public static String readFileFromClassPath(String _fileName) {
StringBuilder sb = new StringBuilder();
for (String string : readFileFromClassPathAsList(_fileName)) {
sb.append(string).append("\n");
}
return sb.length() == 0 ? null : sb.toString();
}
|
java
|
public static String readFileFromClassPath(String _fileName) {
StringBuilder sb = new StringBuilder();
for (String string : readFileFromClassPathAsList(_fileName)) {
sb.append(string).append("\n");
}
return sb.length() == 0 ? null : sb.toString();
}
|
[
"public",
"static",
"String",
"readFileFromClassPath",
"(",
"String",
"_fileName",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"string",
":",
"readFileFromClassPathAsList",
"(",
"_fileName",
")",
")",
"{",
"sb",
".",
"append",
"(",
"string",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"return",
"sb",
".",
"length",
"(",
")",
"==",
"0",
"?",
"null",
":",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Reads a file from classpath to String.
@param _fileName
@return file contents as String or null
|
[
"Reads",
"a",
"file",
"from",
"classpath",
"to",
"String",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L351-L357
|
148,974
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readFileFromClassPathAsList
|
public static List<String> readFileFromClassPathAsList(String _fileName) {
List<String> result = readFileFromClassPathAsList(_fileName, Charset.defaultCharset(), false);
return result == null ? new ArrayList<String>() : result;
}
|
java
|
public static List<String> readFileFromClassPathAsList(String _fileName) {
List<String> result = readFileFromClassPathAsList(_fileName, Charset.defaultCharset(), false);
return result == null ? new ArrayList<String>() : result;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"readFileFromClassPathAsList",
"(",
"String",
"_fileName",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"readFileFromClassPathAsList",
"(",
"_fileName",
",",
"Charset",
".",
"defaultCharset",
"(",
")",
",",
"false",
")",
";",
"return",
"result",
"==",
"null",
"?",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
":",
"result",
";",
"}"
] |
Reads a file from classpath to a list of String using default charset and log any exception.
@param _fileName
@return file contents or empty list
|
[
"Reads",
"a",
"file",
"from",
"classpath",
"to",
"a",
"list",
"of",
"String",
"using",
"default",
"charset",
"and",
"log",
"any",
"exception",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L365-L368
|
148,975
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readFileFromClassPathAsList
|
public static List<String> readFileFromClassPathAsList(String _fileName, Charset _charset, boolean _silent) {
List<String> contents = new ArrayList<>();
if (StringUtil.isBlank(_fileName)) {
return contents;
}
InputStream inputStream = FileIoUtil.class.getClassLoader().getResourceAsStream(_fileName);
if (inputStream != null) {
try (BufferedReader dis = new BufferedReader(new InputStreamReader(inputStream, _charset))) {
String s;
while ((s = dis.readLine()) != null) {
contents.add(s);
}
return contents;
} catch (IOException _ex) {
if (!_silent) {
LOGGER.error("Error while reading resource to string: ", _ex);
}
return null;
}
} else {
if (_silent) {
return null;
}
}
return contents;
}
|
java
|
public static List<String> readFileFromClassPathAsList(String _fileName, Charset _charset, boolean _silent) {
List<String> contents = new ArrayList<>();
if (StringUtil.isBlank(_fileName)) {
return contents;
}
InputStream inputStream = FileIoUtil.class.getClassLoader().getResourceAsStream(_fileName);
if (inputStream != null) {
try (BufferedReader dis = new BufferedReader(new InputStreamReader(inputStream, _charset))) {
String s;
while ((s = dis.readLine()) != null) {
contents.add(s);
}
return contents;
} catch (IOException _ex) {
if (!_silent) {
LOGGER.error("Error while reading resource to string: ", _ex);
}
return null;
}
} else {
if (_silent) {
return null;
}
}
return contents;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"readFileFromClassPathAsList",
"(",
"String",
"_fileName",
",",
"Charset",
"_charset",
",",
"boolean",
"_silent",
")",
"{",
"List",
"<",
"String",
">",
"contents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"StringUtil",
".",
"isBlank",
"(",
"_fileName",
")",
")",
"{",
"return",
"contents",
";",
"}",
"InputStream",
"inputStream",
"=",
"FileIoUtil",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"_fileName",
")",
";",
"if",
"(",
"inputStream",
"!=",
"null",
")",
"{",
"try",
"(",
"BufferedReader",
"dis",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"inputStream",
",",
"_charset",
")",
")",
")",
"{",
"String",
"s",
";",
"while",
"(",
"(",
"s",
"=",
"dis",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"contents",
".",
"add",
"(",
"s",
")",
";",
"}",
"return",
"contents",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"if",
"(",
"!",
"_silent",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error while reading resource to string: \"",
",",
"_ex",
")",
";",
"}",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"_silent",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"contents",
";",
"}"
] |
Reads a file from classpath to a list of String with the given charset.
Will optionally suppress any exception logging.
@param _fileName file to read
@param _charset charset to use for reading
@param _silent true to suppress error logging, false otherwise
@return file contents or null on exception
|
[
"Reads",
"a",
"file",
"from",
"classpath",
"to",
"a",
"list",
"of",
"String",
"with",
"the",
"given",
"charset",
".",
"Will",
"optionally",
"suppress",
"any",
"exception",
"logging",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L379-L406
|
148,976
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.writeTextFile
|
public static boolean writeTextFile(String _fileName, String _fileContent, Charset _charset, boolean _append) {
if (StringUtil.isBlank(_fileName)) {
return false;
}
String allText = "";
if (_append) {
File file = new File(_fileName);
if (file.exists()) {
allText = readFileToString(file) + guessLineTerminatorOfFile(_fileName);
}
}
allText += _fileContent;
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(_fileName), _charset);
writer.write(allText);
} catch (IOException _ex) {
LOGGER.error("Could not write file to '" + _fileName + "'", _ex);
return false;
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException _ex) {
LOGGER.error("Error while closing file '" + _fileName + "'", _ex);
return false;
}
}
return true;
}
|
java
|
public static boolean writeTextFile(String _fileName, String _fileContent, Charset _charset, boolean _append) {
if (StringUtil.isBlank(_fileName)) {
return false;
}
String allText = "";
if (_append) {
File file = new File(_fileName);
if (file.exists()) {
allText = readFileToString(file) + guessLineTerminatorOfFile(_fileName);
}
}
allText += _fileContent;
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(_fileName), _charset);
writer.write(allText);
} catch (IOException _ex) {
LOGGER.error("Could not write file to '" + _fileName + "'", _ex);
return false;
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException _ex) {
LOGGER.error("Error while closing file '" + _fileName + "'", _ex);
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"writeTextFile",
"(",
"String",
"_fileName",
",",
"String",
"_fileContent",
",",
"Charset",
"_charset",
",",
"boolean",
"_append",
")",
"{",
"if",
"(",
"StringUtil",
".",
"isBlank",
"(",
"_fileName",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"allText",
"=",
"\"\"",
";",
"if",
"(",
"_append",
")",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"_fileName",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"allText",
"=",
"readFileToString",
"(",
"file",
")",
"+",
"guessLineTerminatorOfFile",
"(",
"_fileName",
")",
";",
"}",
"}",
"allText",
"+=",
"_fileContent",
";",
"OutputStreamWriter",
"writer",
"=",
"null",
";",
"try",
"{",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"_fileName",
")",
",",
"_charset",
")",
";",
"writer",
".",
"write",
"(",
"allText",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Could not write file to '\"",
"+",
"_fileName",
"+",
"\"'\"",
",",
"_ex",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Error while closing file '\"",
"+",
"_fileName",
"+",
"\"'\"",
",",
"_ex",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Write String to file with the given charset.
Optionally appends the data to the file.
@param _fileName the file to write
@param _fileContent the content to write
@param _charset the charset to use
@param _append append content to file, if false file will be overwritten if existing
@return true on successful write, false otherwise
|
[
"Write",
"String",
"to",
"file",
"with",
"the",
"given",
"charset",
".",
"Optionally",
"appends",
"the",
"data",
"to",
"the",
"file",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L419-L451
|
148,977
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/FileIoUtil.java
|
FileIoUtil.readFileFrom
|
public static List<String> readFileFrom(String _fileName, Charset _charset, SearchOrder... _searchOrder) {
InputStream stream = openInputStreamForFile(_fileName, _searchOrder);
if (stream != null) {
return readTextFileFromStream(stream, _charset, true);
}
return null;
}
|
java
|
public static List<String> readFileFrom(String _fileName, Charset _charset, SearchOrder... _searchOrder) {
InputStream stream = openInputStreamForFile(_fileName, _searchOrder);
if (stream != null) {
return readTextFileFromStream(stream, _charset, true);
}
return null;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"readFileFrom",
"(",
"String",
"_fileName",
",",
"Charset",
"_charset",
",",
"SearchOrder",
"...",
"_searchOrder",
")",
"{",
"InputStream",
"stream",
"=",
"openInputStreamForFile",
"(",
"_fileName",
",",
"_searchOrder",
")",
";",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"return",
"readTextFileFromStream",
"(",
"stream",
",",
"_charset",
",",
"true",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Read a file from different sources depending on _searchOrder.
Will return the first successfully read file which can be loaded either from custom path, classpath or system path.
@param _fileName file to read
@param _charset charset used for reading
@param _searchOrder search order
@return List of String with file content or null if file could not be found
|
[
"Read",
"a",
"file",
"from",
"different",
"sources",
"depending",
"on",
"_searchOrder",
".",
"Will",
"return",
"the",
"first",
"successfully",
"read",
"file",
"which",
"can",
"be",
"loaded",
"either",
"from",
"custom",
"path",
"classpath",
"or",
"system",
"path",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/FileIoUtil.java#L476-L482
|
148,978
|
eurekaclinical/protempa
|
protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/RemoteConnectionManager.java
|
RemoteConnectionManager.initProject
|
protected Project initProject() {
return RemoteProjectManager.getInstance().getProject(host, username,
password, getProjectIdentifier(), false);
}
|
java
|
protected Project initProject() {
return RemoteProjectManager.getInstance().getProject(host, username,
password, getProjectIdentifier(), false);
}
|
[
"protected",
"Project",
"initProject",
"(",
")",
"{",
"return",
"RemoteProjectManager",
".",
"getInstance",
"(",
")",
".",
"getProject",
"(",
"host",
",",
"username",
",",
"password",
",",
"getProjectIdentifier",
"(",
")",
",",
"false",
")",
";",
"}"
] |
Connects to the project specified in the constructor. Throws an
undocumented runtime exception
from within Protege if something bad happens.
@return a Protege {@link Project}.
|
[
"Connects",
"to",
"the",
"project",
"specified",
"in",
"the",
"constructor",
".",
"Throws",
"an",
"undocumented",
"runtime",
"exception",
"from",
"within",
"Protege",
"if",
"something",
"bad",
"happens",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-ksb-protege/src/main/java/org/protempa/backend/ksb/protege/RemoteConnectionManager.java#L68-L71
|
148,979
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UUtils.java
|
UUtils.getLogger
|
public static Logger getLogger(final Class<?> clazz) {
if (!clazz.getPackage().getName().startsWith(LOGGER.getName())) {
throw new IllegalArgumentException(String.format("Class %s is not a child of the package %s",
clazz.getName(), LOGGER.getName()));
}
LOGGER.fine(() -> String.format("Locating logger for class %s", clazz));
return Logger.getLogger(clazz.getName());
}
|
java
|
public static Logger getLogger(final Class<?> clazz) {
if (!clazz.getPackage().getName().startsWith(LOGGER.getName())) {
throw new IllegalArgumentException(String.format("Class %s is not a child of the package %s",
clazz.getName(), LOGGER.getName()));
}
LOGGER.fine(() -> String.format("Locating logger for class %s", clazz));
return Logger.getLogger(clazz.getName());
}
|
[
"public",
"static",
"Logger",
"getLogger",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"!",
"clazz",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"LOGGER",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Class %s is not a child of the package %s\"",
",",
"clazz",
".",
"getName",
"(",
")",
",",
"LOGGER",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"LOGGER",
".",
"fine",
"(",
"(",
")",
"->",
"String",
".",
"format",
"(",
"\"Locating logger for class %s\"",
",",
"clazz",
")",
")",
";",
"return",
"Logger",
".",
"getLogger",
"(",
"clazz",
".",
"getName",
"(",
")",
")",
";",
"}"
] |
Simple wrapper that forces initialization of the package-level LOGGER
instance.
@param clazz
The class to be logged.
@return A Logger using the name of the class as its hierarchy.
|
[
"Simple",
"wrapper",
"that",
"forces",
"initialization",
"of",
"the",
"package",
"-",
"level",
"LOGGER",
"instance",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UUtils.java#L40-L47
|
148,980
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UUtils.java
|
UUtils.setStandaloneLogging
|
public static void setStandaloneLogging(Level level) {
LOGGER.setUseParentHandlers(false);
for (Handler h : LOGGER.getHandlers()) {
LOGGER.removeHandler(h);
}
StdoutHandler handler = new StdoutHandler();
handler.setFormatter(new InlineFormatter());
LOGGER.addHandler(handler);
final UncaughtExceptionHandler ueh = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
LOGGER.log(Level.SEVERE, "Uncaught Exception in thread " + t.getName(), e);
if (ueh != null) {
ueh.uncaughtException(t, e);
}
});
setLogLevel(level);
}
|
java
|
public static void setStandaloneLogging(Level level) {
LOGGER.setUseParentHandlers(false);
for (Handler h : LOGGER.getHandlers()) {
LOGGER.removeHandler(h);
}
StdoutHandler handler = new StdoutHandler();
handler.setFormatter(new InlineFormatter());
LOGGER.addHandler(handler);
final UncaughtExceptionHandler ueh = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
LOGGER.log(Level.SEVERE, "Uncaught Exception in thread " + t.getName(), e);
if (ueh != null) {
ueh.uncaughtException(t, e);
}
});
setLogLevel(level);
}
|
[
"public",
"static",
"void",
"setStandaloneLogging",
"(",
"Level",
"level",
")",
"{",
"LOGGER",
".",
"setUseParentHandlers",
"(",
"false",
")",
";",
"for",
"(",
"Handler",
"h",
":",
"LOGGER",
".",
"getHandlers",
"(",
")",
")",
"{",
"LOGGER",
".",
"removeHandler",
"(",
"h",
")",
";",
"}",
"StdoutHandler",
"handler",
"=",
"new",
"StdoutHandler",
"(",
")",
";",
"handler",
".",
"setFormatter",
"(",
"new",
"InlineFormatter",
"(",
")",
")",
";",
"LOGGER",
".",
"addHandler",
"(",
"handler",
")",
";",
"final",
"UncaughtExceptionHandler",
"ueh",
"=",
"Thread",
".",
"getDefaultUncaughtExceptionHandler",
"(",
")",
";",
"Thread",
".",
"setDefaultUncaughtExceptionHandler",
"(",
"(",
"t",
",",
"e",
")",
"->",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Uncaught Exception in thread \"",
"+",
"t",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"if",
"(",
"ueh",
"!=",
"null",
")",
"{",
"ueh",
".",
"uncaughtException",
"(",
"t",
",",
"e",
")",
";",
"}",
"}",
")",
";",
"setLogLevel",
"(",
"level",
")",
";",
"}"
] |
Enable regular logging for all UBench code at the specified level.
@param level
the level to log for.
|
[
"Enable",
"regular",
"logging",
"for",
"all",
"UBench",
"code",
"at",
"the",
"specified",
"level",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UUtils.java#L55-L73
|
148,981
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UUtils.java
|
UUtils.setLogLevel
|
public static void setLogLevel(Level level) {
// all other ubench loggers inherit from here.
LOGGER.finer("Changing logging from " + LOGGER.getLevel());
LOGGER.setLevel(level);
if (!LOGGER.getUseParentHandlers()) {
LOGGER.setLevel(level);
Stream.of(LOGGER.getHandlers()).forEach(h -> h.setLevel(level));
}
LOGGER.finer("Changed logging to " + LOGGER.getLevel());
}
|
java
|
public static void setLogLevel(Level level) {
// all other ubench loggers inherit from here.
LOGGER.finer("Changing logging from " + LOGGER.getLevel());
LOGGER.setLevel(level);
if (!LOGGER.getUseParentHandlers()) {
LOGGER.setLevel(level);
Stream.of(LOGGER.getHandlers()).forEach(h -> h.setLevel(level));
}
LOGGER.finer("Changed logging to " + LOGGER.getLevel());
}
|
[
"public",
"static",
"void",
"setLogLevel",
"(",
"Level",
"level",
")",
"{",
"// all other ubench loggers inherit from here.",
"LOGGER",
".",
"finer",
"(",
"\"Changing logging from \"",
"+",
"LOGGER",
".",
"getLevel",
"(",
")",
")",
";",
"LOGGER",
".",
"setLevel",
"(",
"level",
")",
";",
"if",
"(",
"!",
"LOGGER",
".",
"getUseParentHandlers",
"(",
")",
")",
"{",
"LOGGER",
".",
"setLevel",
"(",
"level",
")",
";",
"Stream",
".",
"of",
"(",
"LOGGER",
".",
"getHandlers",
"(",
")",
")",
".",
"forEach",
"(",
"h",
"->",
"h",
".",
"setLevel",
"(",
"level",
")",
")",
";",
"}",
"LOGGER",
".",
"finer",
"(",
"\"Changed logging to \"",
"+",
"LOGGER",
".",
"getLevel",
"(",
")",
")",
";",
"}"
] |
Enable the specified debug level messages to be output. Note that both
this Logger and whatever Handler you use, have to be set to enable the
required log level for the handler to output the messages. If this UBench
code is logging 'stand alone' then this method will also change the
output level of the log handlers.
@param level The log level to activate for future log levels.
|
[
"Enable",
"the",
"specified",
"debug",
"level",
"messages",
"to",
"be",
"output",
".",
"Note",
"that",
"both",
"this",
"Logger",
"and",
"whatever",
"Handler",
"you",
"use",
"have",
"to",
"be",
"set",
"to",
"enable",
"the",
"required",
"log",
"level",
"for",
"the",
"handler",
"to",
"output",
"the",
"messages",
".",
"If",
"this",
"UBench",
"code",
"is",
"logging",
"stand",
"alone",
"then",
"this",
"method",
"will",
"also",
"change",
"the",
"output",
"level",
"of",
"the",
"log",
"handlers",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UUtils.java#L84-L93
|
148,982
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UUtils.java
|
UUtils.readResource
|
public static String readResource(String path) {
final long start = System.nanoTime();
try (InputStream is = UScale.class.getClassLoader().getResourceAsStream(path);) {
int len = 0;
byte[] buffer = new byte[2048];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((len = is.read(buffer)) >= 0) {
baos.write(buffer, 0, len);
}
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
LOGGER.log(Level.WARNING, e, () -> "IOException loading resource " + path);
throw new IllegalStateException("Unable to read class loaded stream " + path, e);
} catch (RuntimeException re) {
LOGGER.log(Level.WARNING, re, () -> "Unexpected exception loading resource " + path);
throw re;
} finally {
LOGGER.fine(() -> String.format("Loaded resource %s in %.3fms", path,
(System.nanoTime() - start) / 1000000.0));
}
}
|
java
|
public static String readResource(String path) {
final long start = System.nanoTime();
try (InputStream is = UScale.class.getClassLoader().getResourceAsStream(path);) {
int len = 0;
byte[] buffer = new byte[2048];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((len = is.read(buffer)) >= 0) {
baos.write(buffer, 0, len);
}
return new String(baos.toByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
LOGGER.log(Level.WARNING, e, () -> "IOException loading resource " + path);
throw new IllegalStateException("Unable to read class loaded stream " + path, e);
} catch (RuntimeException re) {
LOGGER.log(Level.WARNING, re, () -> "Unexpected exception loading resource " + path);
throw re;
} finally {
LOGGER.fine(() -> String.format("Loaded resource %s in %.3fms", path,
(System.nanoTime() - start) / 1000000.0));
}
}
|
[
"public",
"static",
"String",
"readResource",
"(",
"String",
"path",
")",
"{",
"final",
"long",
"start",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"try",
"(",
"InputStream",
"is",
"=",
"UScale",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"path",
")",
";",
")",
"{",
"int",
"len",
"=",
"0",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"2048",
"]",
";",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"while",
"(",
"(",
"len",
"=",
"is",
".",
"read",
"(",
"buffer",
")",
")",
">=",
"0",
")",
"{",
"baos",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"len",
")",
";",
"}",
"return",
"new",
"String",
"(",
"baos",
".",
"toByteArray",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"e",
",",
"(",
")",
"->",
"\"IOException loading resource \"",
"+",
"path",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unable to read class loaded stream \"",
"+",
"path",
",",
"e",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"re",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"re",
",",
"(",
")",
"->",
"\"Unexpected exception loading resource \"",
"+",
"path",
")",
";",
"throw",
"re",
";",
"}",
"finally",
"{",
"LOGGER",
".",
"fine",
"(",
"(",
")",
"->",
"String",
".",
"format",
"(",
"\"Loaded resource %s in %.3fms\"",
",",
"path",
",",
"(",
"System",
".",
"nanoTime",
"(",
")",
"-",
"start",
")",
"/",
"1000000.0",
")",
")",
";",
"}",
"}"
] |
Load a resource stored in the classpath, as a String.
@param path
the system resource to read
@return the resource as a String.
|
[
"Load",
"a",
"resource",
"stored",
"in",
"the",
"classpath",
"as",
"a",
"String",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UUtils.java#L138-L158
|
148,983
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/TypeQueryAddMethods.java
|
TypeQueryAddMethods.add
|
public static void add(ClassVisitor cw, ClassInfo classInfo, boolean typeQueryRootBean) {
List<FieldInfo> fields = classInfo.getFields();
if (fields != null) {
for (FieldInfo field : fields) {
field.writeMethod(cw, typeQueryRootBean);
}
}
}
|
java
|
public static void add(ClassVisitor cw, ClassInfo classInfo, boolean typeQueryRootBean) {
List<FieldInfo> fields = classInfo.getFields();
if (fields != null) {
for (FieldInfo field : fields) {
field.writeMethod(cw, typeQueryRootBean);
}
}
}
|
[
"public",
"static",
"void",
"add",
"(",
"ClassVisitor",
"cw",
",",
"ClassInfo",
"classInfo",
",",
"boolean",
"typeQueryRootBean",
")",
"{",
"List",
"<",
"FieldInfo",
">",
"fields",
"=",
"classInfo",
".",
"getFields",
"(",
")",
";",
"if",
"(",
"fields",
"!=",
"null",
")",
"{",
"for",
"(",
"FieldInfo",
"field",
":",
"fields",
")",
"{",
"field",
".",
"writeMethod",
"(",
"cw",
",",
"typeQueryRootBean",
")",
";",
"}",
"}",
"}"
] |
Add the generated 'property access' methods.
|
[
"Add",
"the",
"generated",
"property",
"access",
"methods",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/TypeQueryAddMethods.java#L16-L25
|
148,984
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/NetUtil.java
|
NetUtil.getHostName
|
public static String getHostName(String _ipAddress) {
try {
InetAddress addr = InetAddress.getByName(_ipAddress);
return addr.getHostName();
} catch (Exception _ex) {
return _ipAddress;
}
}
|
java
|
public static String getHostName(String _ipAddress) {
try {
InetAddress addr = InetAddress.getByName(_ipAddress);
return addr.getHostName();
} catch (Exception _ex) {
return _ipAddress;
}
}
|
[
"public",
"static",
"String",
"getHostName",
"(",
"String",
"_ipAddress",
")",
"{",
"try",
"{",
"InetAddress",
"addr",
"=",
"InetAddress",
".",
"getByName",
"(",
"_ipAddress",
")",
";",
"return",
"addr",
".",
"getHostName",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"_ex",
")",
"{",
"return",
"_ipAddress",
";",
"}",
"}"
] |
Get the host name of a local address, if available.
@param _ipAddress the IP address
@return the host name, or the original IP if name not available
|
[
"Get",
"the",
"host",
"name",
"of",
"a",
"local",
"address",
"if",
"available",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/NetUtil.java#L21-L28
|
148,985
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/NetUtil.java
|
NetUtil.isIPv4orIPv6Address
|
public static boolean isIPv4orIPv6Address(String _ipAddress) {
return IPV4_PATTERN.matcher(_ipAddress).matches() || IPV6_PATTERN.matcher(_ipAddress).matches();
}
|
java
|
public static boolean isIPv4orIPv6Address(String _ipAddress) {
return IPV4_PATTERN.matcher(_ipAddress).matches() || IPV6_PATTERN.matcher(_ipAddress).matches();
}
|
[
"public",
"static",
"boolean",
"isIPv4orIPv6Address",
"(",
"String",
"_ipAddress",
")",
"{",
"return",
"IPV4_PATTERN",
".",
"matcher",
"(",
"_ipAddress",
")",
".",
"matches",
"(",
")",
"||",
"IPV6_PATTERN",
".",
"matcher",
"(",
"_ipAddress",
")",
".",
"matches",
"(",
")",
";",
"}"
] |
Checks if given String is either a valid IPv4 or IPv6 address.
@param _ipAddress
@return true if valid address, false otherwise
|
[
"Checks",
"if",
"given",
"String",
"is",
"either",
"a",
"valid",
"IPv4",
"or",
"IPv6",
"address",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/NetUtil.java#L56-L58
|
148,986
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/value/OrdinalValue.java
|
OrdinalValue.compare
|
@Override
public ValueComparator compare(Value o) {
if (o == null) {
return ValueComparator.NOT_EQUAL_TO;
}
switch (o.getType()) {
case ORDINALVALUE:
OrdinalValue other = (OrdinalValue) o;
if (val == null || other.val == null) {
return ValueComparator.UNKNOWN;
}
int c = this.index - other.index;
if (c == 0) {
return ValueComparator.EQUAL_TO;
} else if (c > 0) {
return ValueComparator.GREATER_THAN;
} else {
return ValueComparator.LESS_THAN;
}
case VALUELIST:
ValueList<?> vl = (ValueList<?>) o;
return equals(vl) ? ValueComparator.EQUAL_TO
: ValueComparator.NOT_EQUAL_TO;
default:
return ValueComparator.NOT_EQUAL_TO;
}
}
|
java
|
@Override
public ValueComparator compare(Value o) {
if (o == null) {
return ValueComparator.NOT_EQUAL_TO;
}
switch (o.getType()) {
case ORDINALVALUE:
OrdinalValue other = (OrdinalValue) o;
if (val == null || other.val == null) {
return ValueComparator.UNKNOWN;
}
int c = this.index - other.index;
if (c == 0) {
return ValueComparator.EQUAL_TO;
} else if (c > 0) {
return ValueComparator.GREATER_THAN;
} else {
return ValueComparator.LESS_THAN;
}
case VALUELIST:
ValueList<?> vl = (ValueList<?>) o;
return equals(vl) ? ValueComparator.EQUAL_TO
: ValueComparator.NOT_EQUAL_TO;
default:
return ValueComparator.NOT_EQUAL_TO;
}
}
|
[
"@",
"Override",
"public",
"ValueComparator",
"compare",
"(",
"Value",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"}",
"switch",
"(",
"o",
".",
"getType",
"(",
")",
")",
"{",
"case",
"ORDINALVALUE",
":",
"OrdinalValue",
"other",
"=",
"(",
"OrdinalValue",
")",
"o",
";",
"if",
"(",
"val",
"==",
"null",
"||",
"other",
".",
"val",
"==",
"null",
")",
"{",
"return",
"ValueComparator",
".",
"UNKNOWN",
";",
"}",
"int",
"c",
"=",
"this",
".",
"index",
"-",
"other",
".",
"index",
";",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"return",
"ValueComparator",
".",
"EQUAL_TO",
";",
"}",
"else",
"if",
"(",
"c",
">",
"0",
")",
"{",
"return",
"ValueComparator",
".",
"GREATER_THAN",
";",
"}",
"else",
"{",
"return",
"ValueComparator",
".",
"LESS_THAN",
";",
"}",
"case",
"VALUELIST",
":",
"ValueList",
"<",
"?",
">",
"vl",
"=",
"(",
"ValueList",
"<",
"?",
">",
")",
"o",
";",
"return",
"equals",
"(",
"vl",
")",
"?",
"ValueComparator",
".",
"EQUAL_TO",
":",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"default",
":",
"return",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"}",
"}"
] |
Compares this value and another according to the defined order, or
checks this number value for membership in a value list.
@param o a {@link Value}.
@return If the provided value is an {@link OrdinalValue}, returns
{@link ValueComparator#GREATER_THAN},
{@link ValueComparator#LESS_THAN} or {@link ValueComparator#EQUAL_TO}
depending on whether this value is numerically greater than,
less than or equal to the value provided as argument. If the provided
value is a {@link ValueList}, returns
{@link ValueComparator#IN} if this object is a member of the list, or
{@link ValueComparator#NOT_IN} if not. Otherwise, returns
{@link ValueComparator#UNKNOWN}.
|
[
"Compares",
"this",
"value",
"and",
"another",
"according",
"to",
"the",
"defined",
"order",
"or",
"checks",
"this",
"number",
"value",
"for",
"membership",
"in",
"a",
"value",
"list",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/value/OrdinalValue.java#L114-L141
|
148,987
|
ops4j/org.ops4j.pax.wicket
|
service/src/main/java/org/ops4j/pax/wicket/internal/injection/BundleAnalysingComponentInstantiationListener.java
|
BundleAnalysingComponentInstantiationListener.getGenericTypeArgument
|
public static Class<?> getGenericTypeArgument(Field field) {
// TODO Might this better be located under SPI in an "InjectionUtil" class or something?
Type genericType = field.getGenericType();
if (genericType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
if (actualTypeArguments.length == 1) {
Type type = actualTypeArguments[0];
if (type instanceof Class<?>) {
Class<?> realClass = (Class<?>) type;
return realClass;
} else {
throw new IllegalArgumentException(
"only direct class types are allowed for generic parameter on field " + field.getName()
+ " of type "
+ genericType.getClass().getName() + "<T>, but " + type
+ " was given!");
}
} else {
throw new IllegalArgumentException("only one type parameter expected for field " + field.getName()
+ " but " + actualTypeArguments.length
+ " where found!");
}
} else {
throw new IllegalArgumentException(
"The field '" + field.getName()
+ "' is not a ParameterizedType but this is required for type inferrence!");
}
}
|
java
|
public static Class<?> getGenericTypeArgument(Field field) {
// TODO Might this better be located under SPI in an "InjectionUtil" class or something?
Type genericType = field.getGenericType();
if (genericType instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) genericType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
if (actualTypeArguments.length == 1) {
Type type = actualTypeArguments[0];
if (type instanceof Class<?>) {
Class<?> realClass = (Class<?>) type;
return realClass;
} else {
throw new IllegalArgumentException(
"only direct class types are allowed for generic parameter on field " + field.getName()
+ " of type "
+ genericType.getClass().getName() + "<T>, but " + type
+ " was given!");
}
} else {
throw new IllegalArgumentException("only one type parameter expected for field " + field.getName()
+ " but " + actualTypeArguments.length
+ " where found!");
}
} else {
throw new IllegalArgumentException(
"The field '" + field.getName()
+ "' is not a ParameterizedType but this is required for type inferrence!");
}
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"getGenericTypeArgument",
"(",
"Field",
"field",
")",
"{",
"// TODO Might this better be located under SPI in an \"InjectionUtil\" class or something?",
"Type",
"genericType",
"=",
"field",
".",
"getGenericType",
"(",
")",
";",
"if",
"(",
"genericType",
"instanceof",
"ParameterizedType",
")",
"{",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"genericType",
";",
"Type",
"[",
"]",
"actualTypeArguments",
"=",
"parameterizedType",
".",
"getActualTypeArguments",
"(",
")",
";",
"if",
"(",
"actualTypeArguments",
".",
"length",
"==",
"1",
")",
"{",
"Type",
"type",
"=",
"actualTypeArguments",
"[",
"0",
"]",
";",
"if",
"(",
"type",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"Class",
"<",
"?",
">",
"realClass",
"=",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"return",
"realClass",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"only direct class types are allowed for generic parameter on field \"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" of type \"",
"+",
"genericType",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"<T>, but \"",
"+",
"type",
"+",
"\" was given!\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"only one type parameter expected for field \"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\" but \"",
"+",
"actualTypeArguments",
".",
"length",
"+",
"\" where found!\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The field '\"",
"+",
"field",
".",
"getName",
"(",
")",
"+",
"\"' is not a ParameterizedType but this is required for type inferrence!\"",
")",
";",
"}",
"}"
] |
Takes a field and returns the type argument for this
@param field a {@link java.lang.reflect.Field} object.
@return the type of the generic parameter of that field
|
[
"Takes",
"a",
"field",
"and",
"returns",
"the",
"type",
"argument",
"for",
"this"
] |
ef7cb4bdf918e9e61ec69789b9c690567616faa9
|
https://github.com/ops4j/org.ops4j.pax.wicket/blob/ef7cb4bdf918e9e61ec69789b9c690567616faa9/service/src/main/java/org/ops4j/pax/wicket/internal/injection/BundleAnalysingComponentInstantiationListener.java#L188-L216
|
148,988
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Protempa.java
|
Protempa.validateDataSourceBackendData
|
public DataValidationEvent[] validateDataSourceBackendData()
throws DataSourceFailedDataValidationException,
DataSourceValidationIncompleteException {
KnowledgeSource knowledgeSource = getKnowledgeSource();
List<DataValidationEvent> validationEvents = new ArrayList<>();
try {
for (DataSourceBackend backend : getDataSource().getBackends()) {
CollectionUtils.addAll(validationEvents,
backend.validateData(knowledgeSource));
}
} catch (DataSourceBackendFailedDataValidationException ex) {
throw new DataSourceFailedDataValidationException(
"Data source failed validation", ex, validationEvents.toArray(new DataValidationEvent[validationEvents.size()]));
} catch (KnowledgeSourceReadException ex) {
throw new DataSourceValidationIncompleteException(
"An error occurred during validation", ex);
}
return validationEvents.toArray(new DataValidationEvent[validationEvents.size()]);
}
|
java
|
public DataValidationEvent[] validateDataSourceBackendData()
throws DataSourceFailedDataValidationException,
DataSourceValidationIncompleteException {
KnowledgeSource knowledgeSource = getKnowledgeSource();
List<DataValidationEvent> validationEvents = new ArrayList<>();
try {
for (DataSourceBackend backend : getDataSource().getBackends()) {
CollectionUtils.addAll(validationEvents,
backend.validateData(knowledgeSource));
}
} catch (DataSourceBackendFailedDataValidationException ex) {
throw new DataSourceFailedDataValidationException(
"Data source failed validation", ex, validationEvents.toArray(new DataValidationEvent[validationEvents.size()]));
} catch (KnowledgeSourceReadException ex) {
throw new DataSourceValidationIncompleteException(
"An error occurred during validation", ex);
}
return validationEvents.toArray(new DataValidationEvent[validationEvents.size()]);
}
|
[
"public",
"DataValidationEvent",
"[",
"]",
"validateDataSourceBackendData",
"(",
")",
"throws",
"DataSourceFailedDataValidationException",
",",
"DataSourceValidationIncompleteException",
"{",
"KnowledgeSource",
"knowledgeSource",
"=",
"getKnowledgeSource",
"(",
")",
";",
"List",
"<",
"DataValidationEvent",
">",
"validationEvents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"for",
"(",
"DataSourceBackend",
"backend",
":",
"getDataSource",
"(",
")",
".",
"getBackends",
"(",
")",
")",
"{",
"CollectionUtils",
".",
"addAll",
"(",
"validationEvents",
",",
"backend",
".",
"validateData",
"(",
"knowledgeSource",
")",
")",
";",
"}",
"}",
"catch",
"(",
"DataSourceBackendFailedDataValidationException",
"ex",
")",
"{",
"throw",
"new",
"DataSourceFailedDataValidationException",
"(",
"\"Data source failed validation\"",
",",
"ex",
",",
"validationEvents",
".",
"toArray",
"(",
"new",
"DataValidationEvent",
"[",
"validationEvents",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"catch",
"(",
"KnowledgeSourceReadException",
"ex",
")",
"{",
"throw",
"new",
"DataSourceValidationIncompleteException",
"(",
"\"An error occurred during validation\"",
",",
"ex",
")",
";",
"}",
"return",
"validationEvents",
".",
"toArray",
"(",
"new",
"DataValidationEvent",
"[",
"validationEvents",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Runs each data source backend's data validation routine.
@throws DataSourceFailedDataValidationException if validation failed.
@throws DataSourceValidationIncompleteException if an error occurred
during validation that prevented its completion.
|
[
"Runs",
"each",
"data",
"source",
"backend",
"s",
"data",
"validation",
"routine",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Protempa.java#L256-L274
|
148,989
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Protempa.java
|
Protempa.clear
|
public void clear() {
this.abstractionFinder.getAlgorithmSource().clear();
this.abstractionFinder.getDataSource().clear();
this.abstractionFinder.getKnowledgeSource().clear();
LOGGER.fine("Protempa cleared");
}
|
java
|
public void clear() {
this.abstractionFinder.getAlgorithmSource().clear();
this.abstractionFinder.getDataSource().clear();
this.abstractionFinder.getKnowledgeSource().clear();
LOGGER.fine("Protempa cleared");
}
|
[
"public",
"void",
"clear",
"(",
")",
"{",
"this",
".",
"abstractionFinder",
".",
"getAlgorithmSource",
"(",
")",
".",
"clear",
"(",
")",
";",
"this",
".",
"abstractionFinder",
".",
"getDataSource",
"(",
")",
".",
"clear",
"(",
")",
";",
"this",
".",
"abstractionFinder",
".",
"getKnowledgeSource",
"(",
")",
".",
"clear",
"(",
")",
";",
"LOGGER",
".",
"fine",
"(",
"\"Protempa cleared\"",
")",
";",
"}"
] |
Clears resources created by this object and the data source, knowledge
source and algorithm source.
|
[
"Clears",
"resources",
"created",
"by",
"this",
"object",
"and",
"the",
"data",
"source",
"knowledge",
"source",
"and",
"algorithm",
"source",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Protempa.java#L293-L298
|
148,990
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/PropositionDefinitionCache.java
|
PropositionDefinitionCache.merge
|
public void merge(PropositionDefinitionCache otherCache) {
if (otherCache != null) {
for (Map.Entry<String, PropositionDefinition> me : otherCache.cache.entrySet()) {
this.cache.putIfAbsent(me.getKey(), me.getValue());
}
}
}
|
java
|
public void merge(PropositionDefinitionCache otherCache) {
if (otherCache != null) {
for (Map.Entry<String, PropositionDefinition> me : otherCache.cache.entrySet()) {
this.cache.putIfAbsent(me.getKey(), me.getValue());
}
}
}
|
[
"public",
"void",
"merge",
"(",
"PropositionDefinitionCache",
"otherCache",
")",
"{",
"if",
"(",
"otherCache",
"!=",
"null",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"PropositionDefinition",
">",
"me",
":",
"otherCache",
".",
"cache",
".",
"entrySet",
"(",
")",
")",
"{",
"this",
".",
"cache",
".",
"putIfAbsent",
"(",
"me",
".",
"getKey",
"(",
")",
",",
"me",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Merges the given cache into this one. Any proposition definitions that
are not in this cache will be added.
@param otherCache another proposition definition cache.
|
[
"Merges",
"the",
"given",
"cache",
"into",
"this",
"one",
".",
"Any",
"proposition",
"definitions",
"that",
"are",
"not",
"in",
"this",
"cache",
"will",
"be",
"added",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/PropositionDefinitionCache.java#L54-L60
|
148,991
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java
|
TemporalProposition.setInterval
|
public void setInterval(Interval interval) {
if (interval == null) {
interval = INTERVAL_FACTORY.getInstance();
}
this.interval = interval;
}
|
java
|
public void setInterval(Interval interval) {
if (interval == null) {
interval = INTERVAL_FACTORY.getInstance();
}
this.interval = interval;
}
|
[
"public",
"void",
"setInterval",
"(",
"Interval",
"interval",
")",
"{",
"if",
"(",
"interval",
"==",
"null",
")",
"{",
"interval",
"=",
"INTERVAL_FACTORY",
".",
"getInstance",
"(",
")",
";",
"}",
"this",
".",
"interval",
"=",
"interval",
";",
"}"
] |
Sets the valid interval.
@param interval an <code>Interval</code>.
|
[
"Sets",
"the",
"valid",
"interval",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java#L93-L98
|
148,992
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java
|
TemporalProposition.getStartFormattedLong
|
public final String getStartFormattedLong() {
Granularity startGran = this.interval.getStartGranularity();
return formatStart(startGran != null ? startGran.getLongFormat() : null);
}
|
java
|
public final String getStartFormattedLong() {
Granularity startGran = this.interval.getStartGranularity();
return formatStart(startGran != null ? startGran.getLongFormat() : null);
}
|
[
"public",
"final",
"String",
"getStartFormattedLong",
"(",
")",
"{",
"Granularity",
"startGran",
"=",
"this",
".",
"interval",
".",
"getStartGranularity",
"(",
")",
";",
"return",
"formatStart",
"(",
"startGran",
"!=",
"null",
"?",
"startGran",
".",
"getLongFormat",
"(",
")",
":",
"null",
")",
";",
"}"
] |
Returns the earliest valid time of this proposition as a long string.
@return a <code>String</code>.
|
[
"Returns",
"the",
"earliest",
"valid",
"time",
"of",
"this",
"proposition",
"as",
"a",
"long",
"string",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java#L105-L108
|
148,993
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java
|
TemporalProposition.getFinishFormattedLong
|
public final String getFinishFormattedLong() {
Granularity finishGran = this.interval.getFinishGranularity();
return formatFinish(finishGran != null ? finishGran.getLongFormat()
: null);
}
|
java
|
public final String getFinishFormattedLong() {
Granularity finishGran = this.interval.getFinishGranularity();
return formatFinish(finishGran != null ? finishGran.getLongFormat()
: null);
}
|
[
"public",
"final",
"String",
"getFinishFormattedLong",
"(",
")",
"{",
"Granularity",
"finishGran",
"=",
"this",
".",
"interval",
".",
"getFinishGranularity",
"(",
")",
";",
"return",
"formatFinish",
"(",
"finishGran",
"!=",
"null",
"?",
"finishGran",
".",
"getLongFormat",
"(",
")",
":",
"null",
")",
";",
"}"
] |
Returns the latest valid time of this proposition as a long string.
@return a <code>String</code>.
|
[
"Returns",
"the",
"latest",
"valid",
"time",
"of",
"this",
"proposition",
"as",
"a",
"long",
"string",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java#L133-L137
|
148,994
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java
|
TemporalProposition.readTemporalProposition
|
protected void readTemporalProposition(ObjectInputStream s)
throws IOException, ClassNotFoundException {
int mode = s.readChar();
try {
switch (mode) {
case 0:
setInterval(INTERVAL_FACTORY.getInstance(s.readLong(),
(Granularity) s.readObject()));
break;
case 1:
setInterval(INTERVAL_FACTORY.getInstance(s.readLong(),
(Granularity) s.readObject(), s.readLong(),
(Granularity) s.readObject()));
break;
case 2:
setInterval(INTERVAL_FACTORY.getInstance(
(Long) s.readObject(), (Long) s.readObject(),
(Granularity) s.readObject(),
(Long) s.readObject(), (Long) s.readObject(),
(Granularity) s.readObject()));
break;
default:
throw new InvalidObjectException(
"Can't restore. Invalid mode: " + mode);
}
} catch (IllegalArgumentException iae) {
throw new InvalidObjectException("Can't restore: "
+ iae.getMessage());
}
}
|
java
|
protected void readTemporalProposition(ObjectInputStream s)
throws IOException, ClassNotFoundException {
int mode = s.readChar();
try {
switch (mode) {
case 0:
setInterval(INTERVAL_FACTORY.getInstance(s.readLong(),
(Granularity) s.readObject()));
break;
case 1:
setInterval(INTERVAL_FACTORY.getInstance(s.readLong(),
(Granularity) s.readObject(), s.readLong(),
(Granularity) s.readObject()));
break;
case 2:
setInterval(INTERVAL_FACTORY.getInstance(
(Long) s.readObject(), (Long) s.readObject(),
(Granularity) s.readObject(),
(Long) s.readObject(), (Long) s.readObject(),
(Granularity) s.readObject()));
break;
default:
throw new InvalidObjectException(
"Can't restore. Invalid mode: " + mode);
}
} catch (IllegalArgumentException iae) {
throw new InvalidObjectException("Can't restore: "
+ iae.getMessage());
}
}
|
[
"protected",
"void",
"readTemporalProposition",
"(",
"ObjectInputStream",
"s",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"int",
"mode",
"=",
"s",
".",
"readChar",
"(",
")",
";",
"try",
"{",
"switch",
"(",
"mode",
")",
"{",
"case",
"0",
":",
"setInterval",
"(",
"INTERVAL_FACTORY",
".",
"getInstance",
"(",
"s",
".",
"readLong",
"(",
")",
",",
"(",
"Granularity",
")",
"s",
".",
"readObject",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"1",
":",
"setInterval",
"(",
"INTERVAL_FACTORY",
".",
"getInstance",
"(",
"s",
".",
"readLong",
"(",
")",
",",
"(",
"Granularity",
")",
"s",
".",
"readObject",
"(",
")",
",",
"s",
".",
"readLong",
"(",
")",
",",
"(",
"Granularity",
")",
"s",
".",
"readObject",
"(",
")",
")",
")",
";",
"break",
";",
"case",
"2",
":",
"setInterval",
"(",
"INTERVAL_FACTORY",
".",
"getInstance",
"(",
"(",
"Long",
")",
"s",
".",
"readObject",
"(",
")",
",",
"(",
"Long",
")",
"s",
".",
"readObject",
"(",
")",
",",
"(",
"Granularity",
")",
"s",
".",
"readObject",
"(",
")",
",",
"(",
"Long",
")",
"s",
".",
"readObject",
"(",
")",
",",
"(",
"Long",
")",
"s",
".",
"readObject",
"(",
")",
",",
"(",
"Granularity",
")",
"s",
".",
"readObject",
"(",
")",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"InvalidObjectException",
"(",
"\"Can't restore. Invalid mode: \"",
"+",
"mode",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"InvalidObjectException",
"(",
"\"Can't restore: \"",
"+",
"iae",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Called while deserializing a temporal proposition.
@param s an {@link ObjectInputStream}.
@throws IOException input/output error during deserialization.
@throws ClassNotFoundException class of a serialized object cannot be
found.
|
[
"Called",
"while",
"deserializing",
"a",
"temporal",
"proposition",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/TemporalProposition.java#L323-L352
|
148,995
|
jarekratajski/badass
|
badass/src/main/java/pl/setblack/badass/Politician.java
|
Politician.beatAroundTheBush
|
public static <R> R beatAroundTheBush(Callable<R> callable) {
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
java
|
public static <R> R beatAroundTheBush(Callable<R> callable) {
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"<",
"R",
">",
"R",
"beatAroundTheBush",
"(",
"Callable",
"<",
"R",
">",
"callable",
")",
"{",
"try",
"{",
"return",
"callable",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
If exception happens during callable automatically wrap it in
RuntimeException.
|
[
"If",
"exception",
"happens",
"during",
"callable",
"automatically",
"wrap",
"it",
"in",
"RuntimeException",
"."
] |
ced39171044d60340e03a6c1ea7a0e2c483df558
|
https://github.com/jarekratajski/badass/blob/ced39171044d60340e03a6c1ea7a0e2c483df558/badass/src/main/java/pl/setblack/badass/Politician.java#L20-L26
|
148,996
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java
|
HawtDBStorageService.initInflightMessageStore
|
private void initInflightMessageStore() {
BTreeIndexFactory<String, StoredPublishEvent> indexFactory = new BTreeIndexFactory<String, StoredPublishEvent>();
indexFactory.setKeyCodec(StringCodec.INSTANCE);
m_inflightStore = (SortedIndex<String, StoredPublishEvent>) m_multiIndexFactory.openOrCreate("inflight", indexFactory);
}
|
java
|
private void initInflightMessageStore() {
BTreeIndexFactory<String, StoredPublishEvent> indexFactory = new BTreeIndexFactory<String, StoredPublishEvent>();
indexFactory.setKeyCodec(StringCodec.INSTANCE);
m_inflightStore = (SortedIndex<String, StoredPublishEvent>) m_multiIndexFactory.openOrCreate("inflight", indexFactory);
}
|
[
"private",
"void",
"initInflightMessageStore",
"(",
")",
"{",
"BTreeIndexFactory",
"<",
"String",
",",
"StoredPublishEvent",
">",
"indexFactory",
"=",
"new",
"BTreeIndexFactory",
"<",
"String",
",",
"StoredPublishEvent",
">",
"(",
")",
";",
"indexFactory",
".",
"setKeyCodec",
"(",
"StringCodec",
".",
"INSTANCE",
")",
";",
"m_inflightStore",
"=",
"(",
"SortedIndex",
"<",
"String",
",",
"StoredPublishEvent",
">",
")",
"m_multiIndexFactory",
".",
"openOrCreate",
"(",
"\"inflight\"",
",",
"indexFactory",
")",
";",
"}"
] |
Initialize the message store used to handle the temporary storage of QoS 1,2
messages in flight.
|
[
"Initialize",
"the",
"message",
"store",
"used",
"to",
"handle",
"the",
"temporary",
"storage",
"of",
"QoS",
"1",
"2",
"messages",
"in",
"flight",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/HawtDBStorageService.java#L137-L142
|
148,997
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java
|
JBossRuleCreator.visit
|
@Override
public void visit(LowLevelAbstractionDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
/*
* If there are no value definitions defined, we might still have an
* inverseIsA relationship with another low-level abstraction
* definition.
*/
if (!def.getValueDefinitions().isEmpty()) {
Rule rule = new Rule(def.getId());
Pattern sourceP = new Pattern(2, 1, PRIM_PARAM_OT, "");
Set<String> abstractedFrom = def.getAbstractedFrom();
String[] abstractedFromArr =
abstractedFrom.toArray(new String[abstractedFrom.size()]);
Set<String> subtrees = this.cache.collectPropIdDescendantsUsingInverseIsA(abstractedFromArr);
sourceP.addConstraint(new PredicateConstraint(
new PropositionPredicateExpression(subtrees)));
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP);
String contextId = def.getContextId();
if (contextId != null) {
Pattern sourceP2 = new Pattern(4, 1, CONTEXT_OT, "context");
sourceP2.addConstraint(new PredicateConstraint(
new PropositionPredicateExpression(contextId)));
Pattern resultP2 = new Pattern(3, 1, ARRAY_LIST_OT, "result2");
resultP2.setSource(new Collect(sourceP2, new Pattern(3, 1, ARRAY_LIST_OT, "result")));
resultP2.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP2);
}
Algorithm algo = this.algorithms.get(def);
rule.setConsequence(new LowLevelAbstractionConsequence(def,
algo, this.derivationsBuilder));
rule.setSalience(TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
java
|
@Override
public void visit(LowLevelAbstractionDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
/*
* If there are no value definitions defined, we might still have an
* inverseIsA relationship with another low-level abstraction
* definition.
*/
if (!def.getValueDefinitions().isEmpty()) {
Rule rule = new Rule(def.getId());
Pattern sourceP = new Pattern(2, 1, PRIM_PARAM_OT, "");
Set<String> abstractedFrom = def.getAbstractedFrom();
String[] abstractedFromArr =
abstractedFrom.toArray(new String[abstractedFrom.size()]);
Set<String> subtrees = this.cache.collectPropIdDescendantsUsingInverseIsA(abstractedFromArr);
sourceP.addConstraint(new PredicateConstraint(
new PropositionPredicateExpression(subtrees)));
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP);
String contextId = def.getContextId();
if (contextId != null) {
Pattern sourceP2 = new Pattern(4, 1, CONTEXT_OT, "context");
sourceP2.addConstraint(new PredicateConstraint(
new PropositionPredicateExpression(contextId)));
Pattern resultP2 = new Pattern(3, 1, ARRAY_LIST_OT, "result2");
resultP2.setSource(new Collect(sourceP2, new Pattern(3, 1, ARRAY_LIST_OT, "result")));
resultP2.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP2);
}
Algorithm algo = this.algorithms.get(def);
rule.setConsequence(new LowLevelAbstractionConsequence(def,
algo, this.derivationsBuilder));
rule.setSalience(TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"visit",
"(",
"LowLevelAbstractionDefinition",
"def",
")",
"throws",
"ProtempaException",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Creating rule for {0}\"",
",",
"def",
")",
";",
"try",
"{",
"/*\n * If there are no value definitions defined, we might still have an\n * inverseIsA relationship with another low-level abstraction\n * definition.\n */",
"if",
"(",
"!",
"def",
".",
"getValueDefinitions",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"def",
".",
"getId",
"(",
")",
")",
";",
"Pattern",
"sourceP",
"=",
"new",
"Pattern",
"(",
"2",
",",
"1",
",",
"PRIM_PARAM_OT",
",",
"\"\"",
")",
";",
"Set",
"<",
"String",
">",
"abstractedFrom",
"=",
"def",
".",
"getAbstractedFrom",
"(",
")",
";",
"String",
"[",
"]",
"abstractedFromArr",
"=",
"abstractedFrom",
".",
"toArray",
"(",
"new",
"String",
"[",
"abstractedFrom",
".",
"size",
"(",
")",
"]",
")",
";",
"Set",
"<",
"String",
">",
"subtrees",
"=",
"this",
".",
"cache",
".",
"collectPropIdDescendantsUsingInverseIsA",
"(",
"abstractedFromArr",
")",
";",
"sourceP",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"PropositionPredicateExpression",
"(",
"subtrees",
")",
")",
")",
";",
"Pattern",
"resultP",
"=",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
";",
"resultP",
".",
"setSource",
"(",
"new",
"Collect",
"(",
"sourceP",
",",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
")",
")",
";",
"resultP",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"CollectionSizeExpression",
"(",
"1",
")",
")",
")",
";",
"rule",
".",
"addPattern",
"(",
"resultP",
")",
";",
"String",
"contextId",
"=",
"def",
".",
"getContextId",
"(",
")",
";",
"if",
"(",
"contextId",
"!=",
"null",
")",
"{",
"Pattern",
"sourceP2",
"=",
"new",
"Pattern",
"(",
"4",
",",
"1",
",",
"CONTEXT_OT",
",",
"\"context\"",
")",
";",
"sourceP2",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"PropositionPredicateExpression",
"(",
"contextId",
")",
")",
")",
";",
"Pattern",
"resultP2",
"=",
"new",
"Pattern",
"(",
"3",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result2\"",
")",
";",
"resultP2",
".",
"setSource",
"(",
"new",
"Collect",
"(",
"sourceP2",
",",
"new",
"Pattern",
"(",
"3",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
")",
")",
";",
"resultP2",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"CollectionSizeExpression",
"(",
"1",
")",
")",
")",
";",
"rule",
".",
"addPattern",
"(",
"resultP2",
")",
";",
"}",
"Algorithm",
"algo",
"=",
"this",
".",
"algorithms",
".",
"get",
"(",
"def",
")",
";",
"rule",
".",
"setConsequence",
"(",
"new",
"LowLevelAbstractionConsequence",
"(",
"def",
",",
"algo",
",",
"this",
".",
"derivationsBuilder",
")",
")",
";",
"rule",
".",
"setSalience",
"(",
"TWO_SALIENCE",
")",
";",
"this",
".",
"ruleToAbstractionDefinition",
".",
"put",
"(",
"rule",
",",
"def",
")",
";",
"rules",
".",
"add",
"(",
"rule",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidRuleException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Translates a low-level abstraction definition into rules.
@param def a {@link LowLevelAbstractionDefinition}. Cannot be
<code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.
|
[
"Translates",
"a",
"low",
"-",
"level",
"abstraction",
"definition",
"into",
"rules",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L160-L209
|
148,998
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java
|
JBossRuleCreator.visit
|
@Override
public void visit(HighLevelAbstractionDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<ExtendedPropositionDefinition> epdsC = def
.getExtendedPropositionDefinitions();
/*
* If there are no extended proposition definitions defined, we
* might still have an inverseIsA relationship with another
* high-level abstraction definition.
*/
if (!epdsC.isEmpty()) {
Rule rule = new Rule(def.getId());
rule.setSalience(TWO_SALIENCE);
ExtendedPropositionDefinition[] epds = epdsC
.toArray(new ExtendedPropositionDefinition[epdsC.size()]);
for (int i = 0; i < epds.length; i++) {
Pattern p = new Pattern(i, PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
p.addConstraint(c);
rule.addPattern(p);
}
rule.addPattern(new EvalCondition(
new HighLevelAbstractionCondition(def, epds), null));
rule.setConsequence(new HighLevelAbstractionConsequence(def,
epds, this.derivationsBuilder));
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
java
|
@Override
public void visit(HighLevelAbstractionDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<ExtendedPropositionDefinition> epdsC = def
.getExtendedPropositionDefinitions();
/*
* If there are no extended proposition definitions defined, we
* might still have an inverseIsA relationship with another
* high-level abstraction definition.
*/
if (!epdsC.isEmpty()) {
Rule rule = new Rule(def.getId());
rule.setSalience(TWO_SALIENCE);
ExtendedPropositionDefinition[] epds = epdsC
.toArray(new ExtendedPropositionDefinition[epdsC.size()]);
for (int i = 0; i < epds.length; i++) {
Pattern p = new Pattern(i, PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
p.addConstraint(c);
rule.addPattern(p);
}
rule.addPattern(new EvalCondition(
new HighLevelAbstractionCondition(def, epds), null));
rule.setConsequence(new HighLevelAbstractionConsequence(def,
epds, this.derivationsBuilder));
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"visit",
"(",
"HighLevelAbstractionDefinition",
"def",
")",
"throws",
"ProtempaException",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Creating rule for {0}\"",
",",
"def",
")",
";",
"try",
"{",
"Set",
"<",
"ExtendedPropositionDefinition",
">",
"epdsC",
"=",
"def",
".",
"getExtendedPropositionDefinitions",
"(",
")",
";",
"/*\n * If there are no extended proposition definitions defined, we\n * might still have an inverseIsA relationship with another\n * high-level abstraction definition.\n */",
"if",
"(",
"!",
"epdsC",
".",
"isEmpty",
"(",
")",
")",
"{",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"def",
".",
"getId",
"(",
")",
")",
";",
"rule",
".",
"setSalience",
"(",
"TWO_SALIENCE",
")",
";",
"ExtendedPropositionDefinition",
"[",
"]",
"epds",
"=",
"epdsC",
".",
"toArray",
"(",
"new",
"ExtendedPropositionDefinition",
"[",
"epdsC",
".",
"size",
"(",
")",
"]",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"epds",
".",
"length",
";",
"i",
"++",
")",
"{",
"Pattern",
"p",
"=",
"new",
"Pattern",
"(",
"i",
",",
"PROP_OT",
")",
";",
"GetMatchesPredicateExpression",
"matchesPredicateExpression",
"=",
"new",
"GetMatchesPredicateExpression",
"(",
"epds",
"[",
"i",
"]",
",",
"this",
".",
"cache",
")",
";",
"Constraint",
"c",
"=",
"new",
"PredicateConstraint",
"(",
"matchesPredicateExpression",
")",
";",
"p",
".",
"addConstraint",
"(",
"c",
")",
";",
"rule",
".",
"addPattern",
"(",
"p",
")",
";",
"}",
"rule",
".",
"addPattern",
"(",
"new",
"EvalCondition",
"(",
"new",
"HighLevelAbstractionCondition",
"(",
"def",
",",
"epds",
")",
",",
"null",
")",
")",
";",
"rule",
".",
"setConsequence",
"(",
"new",
"HighLevelAbstractionConsequence",
"(",
"def",
",",
"epds",
",",
"this",
".",
"derivationsBuilder",
")",
")",
";",
"this",
".",
"ruleToAbstractionDefinition",
".",
"put",
"(",
"rule",
",",
"def",
")",
";",
"rules",
".",
"add",
"(",
"rule",
")",
";",
"ABSTRACTION_COMBINER",
".",
"toRules",
"(",
"def",
",",
"rules",
",",
"this",
".",
"derivationsBuilder",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidRuleException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Translates a high-level abstraction definition into rules.
@param def a {@link HighLevelAbstractionDefinition}. Cannot be
<code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.
|
[
"Translates",
"a",
"high",
"-",
"level",
"abstraction",
"definition",
"into",
"rules",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L253-L290
|
148,999
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java
|
JBossRuleCreator.visit
|
@Override
public void visit(SliceDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<TemporalExtendedPropositionDefinition> epdsC = def
.getTemporalExtendedPropositionDefinitions();
if (!epdsC.isEmpty()) {
TemporalExtendedPropositionDefinition[] epds = epdsC
.toArray(new TemporalExtendedPropositionDefinition[epdsC.size()]);
Rule rule = new Rule("SLICE_" + def.getId());
Pattern sourceP = new Pattern(2, 1, TEMP_PROP_OT, "");
for (int i = 0; i < epds.length; i++) {
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
sourceP.addConstraint(c);
}
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
int len;
int minInd = def.getMinIndex();
int maxInd = def.getMaxIndex();
if (maxInd < 0) {
len = Math.abs(minInd);
} else {
len = maxInd;
}
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(len)));
rule.addPattern(resultP);
rule.setConsequence(new SliceConsequence(def,
this.derivationsBuilder));
rule.setSalience(MINUS_TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
java
|
@Override
public void visit(SliceDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
Set<TemporalExtendedPropositionDefinition> epdsC = def
.getTemporalExtendedPropositionDefinitions();
if (!epdsC.isEmpty()) {
TemporalExtendedPropositionDefinition[] epds = epdsC
.toArray(new TemporalExtendedPropositionDefinition[epdsC.size()]);
Rule rule = new Rule("SLICE_" + def.getId());
Pattern sourceP = new Pattern(2, 1, TEMP_PROP_OT, "");
for (int i = 0; i < epds.length; i++) {
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression);
sourceP.addConstraint(c);
}
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
int len;
int minInd = def.getMinIndex();
int maxInd = def.getMaxIndex();
if (maxInd < 0) {
len = Math.abs(minInd);
} else {
len = maxInd;
}
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(len)));
rule.addPattern(resultP);
rule.setConsequence(new SliceConsequence(def,
this.derivationsBuilder));
rule.setSalience(MINUS_TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"visit",
"(",
"SliceDefinition",
"def",
")",
"throws",
"ProtempaException",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Creating rule for {0}\"",
",",
"def",
")",
";",
"try",
"{",
"Set",
"<",
"TemporalExtendedPropositionDefinition",
">",
"epdsC",
"=",
"def",
".",
"getTemporalExtendedPropositionDefinitions",
"(",
")",
";",
"if",
"(",
"!",
"epdsC",
".",
"isEmpty",
"(",
")",
")",
"{",
"TemporalExtendedPropositionDefinition",
"[",
"]",
"epds",
"=",
"epdsC",
".",
"toArray",
"(",
"new",
"TemporalExtendedPropositionDefinition",
"[",
"epdsC",
".",
"size",
"(",
")",
"]",
")",
";",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"\"SLICE_\"",
"+",
"def",
".",
"getId",
"(",
")",
")",
";",
"Pattern",
"sourceP",
"=",
"new",
"Pattern",
"(",
"2",
",",
"1",
",",
"TEMP_PROP_OT",
",",
"\"\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"epds",
".",
"length",
";",
"i",
"++",
")",
"{",
"GetMatchesPredicateExpression",
"matchesPredicateExpression",
"=",
"new",
"GetMatchesPredicateExpression",
"(",
"epds",
"[",
"i",
"]",
",",
"this",
".",
"cache",
")",
";",
"Constraint",
"c",
"=",
"new",
"PredicateConstraint",
"(",
"matchesPredicateExpression",
")",
";",
"sourceP",
".",
"addConstraint",
"(",
"c",
")",
";",
"}",
"Pattern",
"resultP",
"=",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
";",
"resultP",
".",
"setSource",
"(",
"new",
"Collect",
"(",
"sourceP",
",",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
")",
")",
";",
"int",
"len",
";",
"int",
"minInd",
"=",
"def",
".",
"getMinIndex",
"(",
")",
";",
"int",
"maxInd",
"=",
"def",
".",
"getMaxIndex",
"(",
")",
";",
"if",
"(",
"maxInd",
"<",
"0",
")",
"{",
"len",
"=",
"Math",
".",
"abs",
"(",
"minInd",
")",
";",
"}",
"else",
"{",
"len",
"=",
"maxInd",
";",
"}",
"resultP",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"CollectionSizeExpression",
"(",
"len",
")",
")",
")",
";",
"rule",
".",
"addPattern",
"(",
"resultP",
")",
";",
"rule",
".",
"setConsequence",
"(",
"new",
"SliceConsequence",
"(",
"def",
",",
"this",
".",
"derivationsBuilder",
")",
")",
";",
"rule",
".",
"setSalience",
"(",
"MINUS_TWO_SALIENCE",
")",
";",
"this",
".",
"ruleToAbstractionDefinition",
".",
"put",
"(",
"rule",
",",
"def",
")",
";",
"rules",
".",
"add",
"(",
"rule",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidRuleException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Translates a slice definition into rules.
@param def a {@link SliceDefinition}. Cannot be <code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.
|
[
"Translates",
"a",
"slice",
"definition",
"into",
"rules",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L299-L342
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.