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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
144,800
|
duracloud/snapshot
|
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java
|
RestoreJobExecutionListener.getExpirationDate
|
protected Date getExpirationDate(Date endDate, int daysToExpire) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.add(Calendar.DATE, daysToExpire);
return calendar.getTime();
}
|
java
|
protected Date getExpirationDate(Date endDate, int daysToExpire) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.add(Calendar.DATE, daysToExpire);
return calendar.getTime();
}
|
[
"protected",
"Date",
"getExpirationDate",
"(",
"Date",
"endDate",
",",
"int",
"daysToExpire",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"setTime",
"(",
"endDate",
")",
";",
"calendar",
".",
"add",
"(",
"Calendar",
".",
"DATE",
",",
"daysToExpire",
")",
";",
"return",
"calendar",
".",
"getTime",
"(",
")",
";",
"}"
] |
Calculates the restore expiration date based on the restoration
end date and the number of days before retirement
@param endDate date on which the restoration completed
@param daysToExpire number of days the restored content should stay in place
before it is retired
@return expiration date of restored content
|
[
"Calculates",
"the",
"restore",
"expiration",
"date",
"based",
"on",
"the",
"restoration",
"end",
"date",
"and",
"the",
"number",
"of",
"days",
"before",
"retirement"
] |
7cb387b22fd4a9425087f654276138727c2c0b73
|
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java#L264-L269
|
144,801
|
duracloud/snapshot
|
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java
|
RestoreJobExecutionListener.getSnapshotTaskClient
|
private SnapshotTaskClient getSnapshotTaskClient(DuracloudEndPointConfig source) {
return this.snapshotTaskClientHelper.create(source,
bridgeConfig.getDuracloudUsername(),
bridgeConfig.getDuracloudPassword());
}
|
java
|
private SnapshotTaskClient getSnapshotTaskClient(DuracloudEndPointConfig source) {
return this.snapshotTaskClientHelper.create(source,
bridgeConfig.getDuracloudUsername(),
bridgeConfig.getDuracloudPassword());
}
|
[
"private",
"SnapshotTaskClient",
"getSnapshotTaskClient",
"(",
"DuracloudEndPointConfig",
"source",
")",
"{",
"return",
"this",
".",
"snapshotTaskClientHelper",
".",
"create",
"(",
"source",
",",
"bridgeConfig",
".",
"getDuracloudUsername",
"(",
")",
",",
"bridgeConfig",
".",
"getDuracloudPassword",
"(",
")",
")",
";",
"}"
] |
Build the snapshot task client - for communicating with the DuraCloud snapshot
provider to perform tasks.
@param source DuraCloud connection source
@return task client
|
[
"Build",
"the",
"snapshot",
"task",
"client",
"-",
"for",
"communicating",
"with",
"the",
"DuraCloud",
"snapshot",
"provider",
"to",
"perform",
"tasks",
"."
] |
7cb387b22fd4a9425087f654276138727c2c0b73
|
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/RestoreJobExecutionListener.java#L288-L292
|
144,802
|
vatbub/common
|
internet/src/main/java/com/github/vatbub/common/internet/Internet.java
|
Internet.webread
|
@SuppressWarnings("UnusedReturnValue")
public static String webread(URL url) throws IOException {
StringBuilder result = new StringBuilder();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result.toString();
}
|
java
|
@SuppressWarnings("UnusedReturnValue")
public static String webread(URL url) throws IOException {
StringBuilder result = new StringBuilder();
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result.toString();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"UnusedReturnValue\"",
")",
"public",
"static",
"String",
"webread",
"(",
"URL",
"url",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"HttpURLConnection",
"conn",
"=",
"(",
"HttpURLConnection",
")",
"url",
".",
"openConnection",
"(",
")",
";",
"conn",
".",
"setRequestMethod",
"(",
"\"GET\"",
")",
";",
"BufferedReader",
"rd",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"conn",
".",
"getInputStream",
"(",
")",
")",
")",
";",
"String",
"line",
";",
"while",
"(",
"(",
"line",
"=",
"rd",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"result",
".",
"append",
"(",
"line",
")",
";",
"}",
"rd",
".",
"close",
"(",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Sends a GET request to url and retrieves the server response
@param url The url to call.
@return The server response
@throws IOException No Internet connection
|
[
"Sends",
"a",
"GET",
"request",
"to",
"url",
"and",
"retrieves",
"the",
"server",
"response"
] |
8b9fd2ece0a23d520ce53b66c84cbd094e378443
|
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/internet/src/main/java/com/github/vatbub/common/internet/Internet.java#L179-L191
|
144,803
|
vatbub/common
|
internet/src/main/java/com/github/vatbub/common/internet/Internet.java
|
Internet.openInDefaultBrowser
|
public static void openInDefaultBrowser(URL url) throws IOException {
Runtime rt = Runtime.getRuntime();
if (SystemUtils.IS_OS_WINDOWS) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (SystemUtils.IS_OS_MAC) {
rt.exec("open" + url);
} else {
String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
"netscape", "opera", "links", "lynx"};
StringBuilder cmd = new StringBuilder();
for (int i = 0; i < browsers.length; i++)
cmd.append(i == 0 ? "" : " || ").append(browsers[i]).append(" \"").append(url).append("\" ");
rt.exec(new String[]{"sh", "-c", cmd.toString()});
}
}
|
java
|
public static void openInDefaultBrowser(URL url) throws IOException {
Runtime rt = Runtime.getRuntime();
if (SystemUtils.IS_OS_WINDOWS) {
rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (SystemUtils.IS_OS_MAC) {
rt.exec("open" + url);
} else {
String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
"netscape", "opera", "links", "lynx"};
StringBuilder cmd = new StringBuilder();
for (int i = 0; i < browsers.length; i++)
cmd.append(i == 0 ? "" : " || ").append(browsers[i]).append(" \"").append(url).append("\" ");
rt.exec(new String[]{"sh", "-c", cmd.toString()});
}
}
|
[
"public",
"static",
"void",
"openInDefaultBrowser",
"(",
"URL",
"url",
")",
"throws",
"IOException",
"{",
"Runtime",
"rt",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
";",
"if",
"(",
"SystemUtils",
".",
"IS_OS_WINDOWS",
")",
"{",
"rt",
".",
"exec",
"(",
"\"rundll32 url.dll,FileProtocolHandler \"",
"+",
"url",
")",
";",
"}",
"else",
"if",
"(",
"SystemUtils",
".",
"IS_OS_MAC",
")",
"{",
"rt",
".",
"exec",
"(",
"\"open\"",
"+",
"url",
")",
";",
"}",
"else",
"{",
"String",
"[",
"]",
"browsers",
"=",
"{",
"\"epiphany\"",
",",
"\"firefox\"",
",",
"\"mozilla\"",
",",
"\"konqueror\"",
",",
"\"netscape\"",
",",
"\"opera\"",
",",
"\"links\"",
",",
"\"lynx\"",
"}",
";",
"StringBuilder",
"cmd",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"browsers",
".",
"length",
";",
"i",
"++",
")",
"cmd",
".",
"append",
"(",
"i",
"==",
"0",
"?",
"\"\"",
":",
"\" || \"",
")",
".",
"append",
"(",
"browsers",
"[",
"i",
"]",
")",
".",
"append",
"(",
"\" \\\"\"",
")",
".",
"append",
"(",
"url",
")",
".",
"append",
"(",
"\"\\\" \"",
")",
";",
"rt",
".",
"exec",
"(",
"new",
"String",
"[",
"]",
"{",
"\"sh\"",
",",
"\"-c\"",
",",
"cmd",
".",
"toString",
"(",
")",
"}",
")",
";",
"}",
"}"
] |
OPens the specified url in the default browser.
@param url The url to open
@throws IOException If the URL cannot be opened
|
[
"OPens",
"the",
"specified",
"url",
"in",
"the",
"default",
"browser",
"."
] |
8b9fd2ece0a23d520ce53b66c84cbd094e378443
|
https://github.com/vatbub/common/blob/8b9fd2ece0a23d520ce53b66c84cbd094e378443/internet/src/main/java/com/github/vatbub/common/internet/Internet.java#L440-L457
|
144,804
|
lastaflute/lasta-thymeleaf
|
src/main/java/org/lastaflute/thymeleaf/expression/HandyDateExpressionObject.java
|
HandyDateExpressionObject.format
|
public String format(Object expression, Object objPattern) {
if (objPattern instanceof String) {
final String pattern = filterPattern((String) objPattern);
if (expression == null) {
return null;
}
if (expression instanceof LocalDate) {
return create((LocalDate) expression).toDisp(pattern);
}
if (expression instanceof LocalDateTime) {
return create((LocalDateTime) expression).toDisp(pattern);
}
if (expression instanceof java.util.Date) {
return create((java.util.Date) expression).toDisp(pattern);
}
if (expression instanceof String) {
return create((String) expression).toDisp(pattern);
}
String msg =
"First argument as two arguments should be LocalDate or LocalDateTime or Date or String(expression): " + expression;
throw new TemplateProcessingException(msg);
}
String msg = "Second argument as two arguments should be String(pattern): objPattern=" + objPattern;
throw new TemplateProcessingException(msg);
}
|
java
|
public String format(Object expression, Object objPattern) {
if (objPattern instanceof String) {
final String pattern = filterPattern((String) objPattern);
if (expression == null) {
return null;
}
if (expression instanceof LocalDate) {
return create((LocalDate) expression).toDisp(pattern);
}
if (expression instanceof LocalDateTime) {
return create((LocalDateTime) expression).toDisp(pattern);
}
if (expression instanceof java.util.Date) {
return create((java.util.Date) expression).toDisp(pattern);
}
if (expression instanceof String) {
return create((String) expression).toDisp(pattern);
}
String msg =
"First argument as two arguments should be LocalDate or LocalDateTime or Date or String(expression): " + expression;
throw new TemplateProcessingException(msg);
}
String msg = "Second argument as two arguments should be String(pattern): objPattern=" + objPattern;
throw new TemplateProcessingException(msg);
}
|
[
"public",
"String",
"format",
"(",
"Object",
"expression",
",",
"Object",
"objPattern",
")",
"{",
"if",
"(",
"objPattern",
"instanceof",
"String",
")",
"{",
"final",
"String",
"pattern",
"=",
"filterPattern",
"(",
"(",
"String",
")",
"objPattern",
")",
";",
"if",
"(",
"expression",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"expression",
"instanceof",
"LocalDate",
")",
"{",
"return",
"create",
"(",
"(",
"LocalDate",
")",
"expression",
")",
".",
"toDisp",
"(",
"pattern",
")",
";",
"}",
"if",
"(",
"expression",
"instanceof",
"LocalDateTime",
")",
"{",
"return",
"create",
"(",
"(",
"LocalDateTime",
")",
"expression",
")",
".",
"toDisp",
"(",
"pattern",
")",
";",
"}",
"if",
"(",
"expression",
"instanceof",
"java",
".",
"util",
".",
"Date",
")",
"{",
"return",
"create",
"(",
"(",
"java",
".",
"util",
".",
"Date",
")",
"expression",
")",
".",
"toDisp",
"(",
"pattern",
")",
";",
"}",
"if",
"(",
"expression",
"instanceof",
"String",
")",
"{",
"return",
"create",
"(",
"(",
"String",
")",
"expression",
")",
".",
"toDisp",
"(",
"pattern",
")",
";",
"}",
"String",
"msg",
"=",
"\"First argument as two arguments should be LocalDate or LocalDateTime or Date or String(expression): \"",
"+",
"expression",
";",
"throw",
"new",
"TemplateProcessingException",
"(",
"msg",
")",
";",
"}",
"String",
"msg",
"=",
"\"Second argument as two arguments should be String(pattern): objPattern=\"",
"+",
"objPattern",
";",
"throw",
"new",
"TemplateProcessingException",
"(",
"msg",
")",
";",
"}"
] |
Get formatted date string.
@param expression Date expression. (NullAllowed: if null, returns null)
@param objPattern date format pattern. (NotNull)
@return formatted date string. (NullAllowed: if expression is null.)
|
[
"Get",
"formatted",
"date",
"string",
"."
] |
d340a6e7eeddfcc9177052958c383fecd4a7fefa
|
https://github.com/lastaflute/lasta-thymeleaf/blob/d340a6e7eeddfcc9177052958c383fecd4a7fefa/src/main/java/org/lastaflute/thymeleaf/expression/HandyDateExpressionObject.java#L230-L254
|
144,805
|
cloudiator/sword
|
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/strategy/JCloudsCreateVirtualMachineStrategy.java
|
JCloudsCreateVirtualMachineStrategy.enrich
|
private NodeMetadata enrich(NodeMetadata nodeMetadata, Template template) {
final NodeMetadataBuilder nodeMetadataBuilder = NodeMetadataBuilder
.fromNodeMetadata(nodeMetadata);
if (nodeMetadata.getHardware() == null) {
nodeMetadataBuilder.hardware(template.getHardware());
}
if (nodeMetadata.getImageId() == null) {
nodeMetadataBuilder.imageId(template.getImage().getId());
}
if (nodeMetadata.getLocation() == null) {
nodeMetadataBuilder.location(template.getLocation());
}
return nodeMetadataBuilder.build();
}
|
java
|
private NodeMetadata enrich(NodeMetadata nodeMetadata, Template template) {
final NodeMetadataBuilder nodeMetadataBuilder = NodeMetadataBuilder
.fromNodeMetadata(nodeMetadata);
if (nodeMetadata.getHardware() == null) {
nodeMetadataBuilder.hardware(template.getHardware());
}
if (nodeMetadata.getImageId() == null) {
nodeMetadataBuilder.imageId(template.getImage().getId());
}
if (nodeMetadata.getLocation() == null) {
nodeMetadataBuilder.location(template.getLocation());
}
return nodeMetadataBuilder.build();
}
|
[
"private",
"NodeMetadata",
"enrich",
"(",
"NodeMetadata",
"nodeMetadata",
",",
"Template",
"template",
")",
"{",
"final",
"NodeMetadataBuilder",
"nodeMetadataBuilder",
"=",
"NodeMetadataBuilder",
".",
"fromNodeMetadata",
"(",
"nodeMetadata",
")",
";",
"if",
"(",
"nodeMetadata",
".",
"getHardware",
"(",
")",
"==",
"null",
")",
"{",
"nodeMetadataBuilder",
".",
"hardware",
"(",
"template",
".",
"getHardware",
"(",
")",
")",
";",
"}",
"if",
"(",
"nodeMetadata",
".",
"getImageId",
"(",
")",
"==",
"null",
")",
"{",
"nodeMetadataBuilder",
".",
"imageId",
"(",
"template",
".",
"getImage",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"nodeMetadata",
".",
"getLocation",
"(",
")",
"==",
"null",
")",
"{",
"nodeMetadataBuilder",
".",
"location",
"(",
"template",
".",
"getLocation",
"(",
")",
")",
";",
"}",
"return",
"nodeMetadataBuilder",
".",
"build",
"(",
")",
";",
"}"
] |
Enriches the spawned vm with information of the template if the spawned vm does not contain
information about hardware, image or location
@param nodeMetadata the node to enrich
@param template the template used to spawn the node
@return the enriched node
|
[
"Enriches",
"the",
"spawned",
"vm",
"with",
"information",
"of",
"the",
"template",
"if",
"the",
"spawned",
"vm",
"does",
"not",
"contain",
"information",
"about",
"hardware",
"image",
"or",
"location"
] |
b7808ea2776c6d70d439342c403369dfc5bb26bc
|
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/strategy/JCloudsCreateVirtualMachineStrategy.java#L117-L134
|
144,806
|
cloudiator/sword
|
drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/strategy/JCloudsCreateVirtualMachineStrategy.java
|
JCloudsCreateVirtualMachineStrategy.modifyTemplateOptions
|
protected org.jclouds.compute.options.TemplateOptions modifyTemplateOptions(
VirtualMachineTemplate originalVirtualMachineTemplate,
org.jclouds.compute.options.TemplateOptions originalTemplateOptions) {
return originalTemplateOptions;
}
|
java
|
protected org.jclouds.compute.options.TemplateOptions modifyTemplateOptions(
VirtualMachineTemplate originalVirtualMachineTemplate,
org.jclouds.compute.options.TemplateOptions originalTemplateOptions) {
return originalTemplateOptions;
}
|
[
"protected",
"org",
".",
"jclouds",
".",
"compute",
".",
"options",
".",
"TemplateOptions",
"modifyTemplateOptions",
"(",
"VirtualMachineTemplate",
"originalVirtualMachineTemplate",
",",
"org",
".",
"jclouds",
".",
"compute",
".",
"options",
".",
"TemplateOptions",
"originalTemplateOptions",
")",
"{",
"return",
"originalTemplateOptions",
";",
"}"
] |
Extension point for the template options. Allows the subclass to replace the jclouds template
options object with a new one before it is passed to the template builder.
@param originalVirtualMachineTemplate the original virtual machine template
@param originalTemplateOptions the original template options
@return the replaced template options.
|
[
"Extension",
"point",
"for",
"the",
"template",
"options",
".",
"Allows",
"the",
"subclass",
"to",
"replace",
"the",
"jclouds",
"template",
"options",
"object",
"with",
"a",
"new",
"one",
"before",
"it",
"is",
"passed",
"to",
"the",
"template",
"builder",
"."
] |
b7808ea2776c6d70d439342c403369dfc5bb26bc
|
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/jclouds/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/jclouds/strategy/JCloudsCreateVirtualMachineStrategy.java#L156-L160
|
144,807
|
duracloud/snapshot
|
snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/SpaceManifestSnapshotManifestVerifier.java
|
SpaceManifestSnapshotManifestVerifier.verify
|
public boolean verify() {
this.errors = new LinkedList<>();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(generator.generate(spaceId, ManifestFormat.TSV)))) {
WriteOnlyStringSet snapshotManifest = ManifestFileHelper.loadManifestSetFromFile(this.md5Manifest);
log.info("loaded manifest set into memory.");
ManifestFormatter formatter = new TsvManifestFormatter();
// skip header
if (formatter.getHeader() != null) {
reader.readLine();
}
String line = null;
int stitchedManifestCount = 0;
while ((line = reader.readLine()) != null) {
ManifestItem item = formatter.parseLine(line);
String contentId = item.getContentId();
if (!contentId.equals(Constants.SNAPSHOT_PROPS_FILENAME)) {
if (!snapshotManifest.contains(ManifestFileHelper.formatManifestSetString(contentId,
item.getContentChecksum()))) {
String message = "Snapshot manifest does not contain content id/checksum combination ("
+ contentId + ", " + item.getContentChecksum();
errors.add(message);
}
stitchedManifestCount++;
}
}
int snapshotCount = snapshotManifest.size();
if (stitchedManifestCount != snapshotCount) {
String message = "Snapshot Manifest size (" + snapshotCount +
") does not equal DuraCloud Manifest (" + stitchedManifestCount + ")";
errors.add(message);
log.error(message);
}
} catch (Exception e) {
String message = "Failed to verify space manifest against snapshot manifest:" + e.getMessage();
errors.add(message);
log.error(message, e);
}
log.info("verification complete. error count = {}", errors.size());
return getResult(errors);
}
|
java
|
public boolean verify() {
this.errors = new LinkedList<>();
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(generator.generate(spaceId, ManifestFormat.TSV)))) {
WriteOnlyStringSet snapshotManifest = ManifestFileHelper.loadManifestSetFromFile(this.md5Manifest);
log.info("loaded manifest set into memory.");
ManifestFormatter formatter = new TsvManifestFormatter();
// skip header
if (formatter.getHeader() != null) {
reader.readLine();
}
String line = null;
int stitchedManifestCount = 0;
while ((line = reader.readLine()) != null) {
ManifestItem item = formatter.parseLine(line);
String contentId = item.getContentId();
if (!contentId.equals(Constants.SNAPSHOT_PROPS_FILENAME)) {
if (!snapshotManifest.contains(ManifestFileHelper.formatManifestSetString(contentId,
item.getContentChecksum()))) {
String message = "Snapshot manifest does not contain content id/checksum combination ("
+ contentId + ", " + item.getContentChecksum();
errors.add(message);
}
stitchedManifestCount++;
}
}
int snapshotCount = snapshotManifest.size();
if (stitchedManifestCount != snapshotCount) {
String message = "Snapshot Manifest size (" + snapshotCount +
") does not equal DuraCloud Manifest (" + stitchedManifestCount + ")";
errors.add(message);
log.error(message);
}
} catch (Exception e) {
String message = "Failed to verify space manifest against snapshot manifest:" + e.getMessage();
errors.add(message);
log.error(message, e);
}
log.info("verification complete. error count = {}", errors.size());
return getResult(errors);
}
|
[
"public",
"boolean",
"verify",
"(",
")",
"{",
"this",
".",
"errors",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"try",
"(",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"generator",
".",
"generate",
"(",
"spaceId",
",",
"ManifestFormat",
".",
"TSV",
")",
")",
")",
")",
"{",
"WriteOnlyStringSet",
"snapshotManifest",
"=",
"ManifestFileHelper",
".",
"loadManifestSetFromFile",
"(",
"this",
".",
"md5Manifest",
")",
";",
"log",
".",
"info",
"(",
"\"loaded manifest set into memory.\"",
")",
";",
"ManifestFormatter",
"formatter",
"=",
"new",
"TsvManifestFormatter",
"(",
")",
";",
"// skip header",
"if",
"(",
"formatter",
".",
"getHeader",
"(",
")",
"!=",
"null",
")",
"{",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"String",
"line",
"=",
"null",
";",
"int",
"stitchedManifestCount",
"=",
"0",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"ManifestItem",
"item",
"=",
"formatter",
".",
"parseLine",
"(",
"line",
")",
";",
"String",
"contentId",
"=",
"item",
".",
"getContentId",
"(",
")",
";",
"if",
"(",
"!",
"contentId",
".",
"equals",
"(",
"Constants",
".",
"SNAPSHOT_PROPS_FILENAME",
")",
")",
"{",
"if",
"(",
"!",
"snapshotManifest",
".",
"contains",
"(",
"ManifestFileHelper",
".",
"formatManifestSetString",
"(",
"contentId",
",",
"item",
".",
"getContentChecksum",
"(",
")",
")",
")",
")",
"{",
"String",
"message",
"=",
"\"Snapshot manifest does not contain content id/checksum combination (\"",
"+",
"contentId",
"+",
"\", \"",
"+",
"item",
".",
"getContentChecksum",
"(",
")",
";",
"errors",
".",
"add",
"(",
"message",
")",
";",
"}",
"stitchedManifestCount",
"++",
";",
"}",
"}",
"int",
"snapshotCount",
"=",
"snapshotManifest",
".",
"size",
"(",
")",
";",
"if",
"(",
"stitchedManifestCount",
"!=",
"snapshotCount",
")",
"{",
"String",
"message",
"=",
"\"Snapshot Manifest size (\"",
"+",
"snapshotCount",
"+",
"\") does not equal DuraCloud Manifest (\"",
"+",
"stitchedManifestCount",
"+",
"\")\"",
";",
"errors",
".",
"add",
"(",
"message",
")",
";",
"log",
".",
"error",
"(",
"message",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"message",
"=",
"\"Failed to verify space manifest against snapshot manifest:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"errors",
".",
"add",
"(",
"message",
")",
";",
"log",
".",
"error",
"(",
"message",
",",
"e",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"verification complete. error count = {}\"",
",",
"errors",
".",
"size",
"(",
")",
")",
";",
"return",
"getResult",
"(",
"errors",
")",
";",
"}"
] |
Performs the verification.
@return true if verification was a success. Otherwise false. Errors can
be obtained by calling getErrors() after execution completes.
|
[
"Performs",
"the",
"verification",
"."
] |
7cb387b22fd4a9425087f654276138727c2c0b73
|
https://github.com/duracloud/snapshot/blob/7cb387b22fd4a9425087f654276138727c2c0b73/snapshot-service-impl/src/main/java/org/duracloud/snapshot/service/impl/SpaceManifestSnapshotManifestVerifier.java#L60-L106
|
144,808
|
cloudiator/sword
|
drivers/openstack4j/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/openstack4j/internal/OsClientV3Factory.java
|
OsClientV3Factory.handleIdentifiers
|
@Nullable
private static Identifiers handleIdentifiers(String domainIdOrName, String projectIdOrName,
String endpoint, String userId, String password) {
//we try all four cases and return the one that works
Set<Identifiers> possibleIdentifiers = new HashSet<Identifiers>() {{
add(new Identifiers(Identifier.byName(domainIdOrName), Identifier.byName(projectIdOrName)));
add(new Identifiers(Identifier.byId(domainIdOrName), Identifier.byId(projectIdOrName)));
add(new Identifiers(Identifier.byId(domainIdOrName), Identifier.byName(projectIdOrName)));
add(new Identifiers(Identifier.byName(domainIdOrName), Identifier.byId(projectIdOrName)));
}};
for (Identifiers candidate : possibleIdentifiers) {
try {
authenticate(endpoint, userId, password, candidate.getDomain(), candidate.getProject());
} catch (AuthenticationException | ClientResponseException e) {
continue;
}
return candidate;
}
return null;
}
|
java
|
@Nullable
private static Identifiers handleIdentifiers(String domainIdOrName, String projectIdOrName,
String endpoint, String userId, String password) {
//we try all four cases and return the one that works
Set<Identifiers> possibleIdentifiers = new HashSet<Identifiers>() {{
add(new Identifiers(Identifier.byName(domainIdOrName), Identifier.byName(projectIdOrName)));
add(new Identifiers(Identifier.byId(domainIdOrName), Identifier.byId(projectIdOrName)));
add(new Identifiers(Identifier.byId(domainIdOrName), Identifier.byName(projectIdOrName)));
add(new Identifiers(Identifier.byName(domainIdOrName), Identifier.byId(projectIdOrName)));
}};
for (Identifiers candidate : possibleIdentifiers) {
try {
authenticate(endpoint, userId, password, candidate.getDomain(), candidate.getProject());
} catch (AuthenticationException | ClientResponseException e) {
continue;
}
return candidate;
}
return null;
}
|
[
"@",
"Nullable",
"private",
"static",
"Identifiers",
"handleIdentifiers",
"(",
"String",
"domainIdOrName",
",",
"String",
"projectIdOrName",
",",
"String",
"endpoint",
",",
"String",
"userId",
",",
"String",
"password",
")",
"{",
"//we try all four cases and return the one that works",
"Set",
"<",
"Identifiers",
">",
"possibleIdentifiers",
"=",
"new",
"HashSet",
"<",
"Identifiers",
">",
"(",
")",
"{",
"{",
"add",
"(",
"new",
"Identifiers",
"(",
"Identifier",
".",
"byName",
"(",
"domainIdOrName",
")",
",",
"Identifier",
".",
"byName",
"(",
"projectIdOrName",
")",
")",
")",
";",
"add",
"(",
"new",
"Identifiers",
"(",
"Identifier",
".",
"byId",
"(",
"domainIdOrName",
")",
",",
"Identifier",
".",
"byId",
"(",
"projectIdOrName",
")",
")",
")",
";",
"add",
"(",
"new",
"Identifiers",
"(",
"Identifier",
".",
"byId",
"(",
"domainIdOrName",
")",
",",
"Identifier",
".",
"byName",
"(",
"projectIdOrName",
")",
")",
")",
";",
"add",
"(",
"new",
"Identifiers",
"(",
"Identifier",
".",
"byName",
"(",
"domainIdOrName",
")",
",",
"Identifier",
".",
"byId",
"(",
"projectIdOrName",
")",
")",
")",
";",
"}",
"}",
";",
"for",
"(",
"Identifiers",
"candidate",
":",
"possibleIdentifiers",
")",
"{",
"try",
"{",
"authenticate",
"(",
"endpoint",
",",
"userId",
",",
"password",
",",
"candidate",
".",
"getDomain",
"(",
")",
",",
"candidate",
".",
"getProject",
"(",
")",
")",
";",
"}",
"catch",
"(",
"AuthenticationException",
"|",
"ClientResponseException",
"e",
")",
"{",
"continue",
";",
"}",
"return",
"candidate",
";",
"}",
"return",
"null",
";",
"}"
] |
This method tries to determine if the authentication should happen by using the user provided
information as domain ID or domain name resp. project ID or project name.
It does so by brute forcing the four different possible combinations.
Returns early on success.
@param domainIdOrName the domain id or name
@param projectIdOrName the project id or name
@param endpoint the endpoint
@param userId the user
@param password the password of the user
@return The valid identifiers if a valid combination exists or null if all combinations failed.
|
[
"This",
"method",
"tries",
"to",
"determine",
"if",
"the",
"authentication",
"should",
"happen",
"by",
"using",
"the",
"user",
"provided",
"information",
"as",
"domain",
"ID",
"or",
"domain",
"name",
"resp",
".",
"project",
"ID",
"or",
"project",
"name",
"."
] |
b7808ea2776c6d70d439342c403369dfc5bb26bc
|
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/drivers/openstack4j/src/main/java/de/uniulm/omi/cloudiator/sword/drivers/openstack4j/internal/OsClientV3Factory.java#L67-L88
|
144,809
|
cloudiator/sword
|
core/src/main/java/de/uniulm/omi/cloudiator/sword/config/AbstractComputeModule.java
|
AbstractComputeModule.configure
|
@Override
protected void configure() {
bind(DiscoveryService.class).to(BaseDiscoveryService.class);
bind(OperatingSystemDetectionStrategy.class)
.to(NameSubstringBasedOperatingSystemDetectionStrategy.class);
}
|
java
|
@Override
protected void configure() {
bind(DiscoveryService.class).to(BaseDiscoveryService.class);
bind(OperatingSystemDetectionStrategy.class)
.to(NameSubstringBasedOperatingSystemDetectionStrategy.class);
}
|
[
"@",
"Override",
"protected",
"void",
"configure",
"(",
")",
"{",
"bind",
"(",
"DiscoveryService",
".",
"class",
")",
".",
"to",
"(",
"BaseDiscoveryService",
".",
"class",
")",
";",
"bind",
"(",
"OperatingSystemDetectionStrategy",
".",
"class",
")",
".",
"to",
"(",
"NameSubstringBasedOperatingSystemDetectionStrategy",
".",
"class",
")",
";",
"}"
] |
Can be extended to load own implementation of classes.
|
[
"Can",
"be",
"extended",
"to",
"load",
"own",
"implementation",
"of",
"classes",
"."
] |
b7808ea2776c6d70d439342c403369dfc5bb26bc
|
https://github.com/cloudiator/sword/blob/b7808ea2776c6d70d439342c403369dfc5bb26bc/core/src/main/java/de/uniulm/omi/cloudiator/sword/config/AbstractComputeModule.java#L57-L64
|
144,810
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/Update.java
|
Update.update
|
public static Update update(String key, Object value) {
return new Update().set(key, value);
}
|
java
|
public static Update update(String key, Object value) {
return new Update().set(key, value);
}
|
[
"public",
"static",
"Update",
"update",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"return",
"new",
"Update",
"(",
")",
".",
"set",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Static factory method to create an Update using the provided key
@param key the field name for the update operation
@param value the value to set for the field
@return Updated object
|
[
"Static",
"factory",
"method",
"to",
"create",
"an",
"Update",
"using",
"the",
"provided",
"key"
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/Update.java#L45-L47
|
144,811
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/crypto/CryptoUtil.java
|
CryptoUtil.encryptFields
|
public static void encryptFields(Object object, CollectionMetaData cmd, ICipher cipher)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (String secretAnnotatedFieldName: cmd.getSecretAnnotatedFieldNames()) {
Method getterMethod = cmd.getGetterMethodForFieldName(secretAnnotatedFieldName);
Method setterMethod = cmd.getSetterMethodForFieldName(secretAnnotatedFieldName);
String value;
String encryptedValue = null;
try {
value = (String)getterMethod.invoke(object);
if (null != value) {
encryptedValue = cipher.encrypt(value);
setterMethod.invoke(object, encryptedValue);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
logger.error("Error when invoking method for a @Secret annotated field", e);
throw e;
}
}
}
|
java
|
public static void encryptFields(Object object, CollectionMetaData cmd, ICipher cipher)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (String secretAnnotatedFieldName: cmd.getSecretAnnotatedFieldNames()) {
Method getterMethod = cmd.getGetterMethodForFieldName(secretAnnotatedFieldName);
Method setterMethod = cmd.getSetterMethodForFieldName(secretAnnotatedFieldName);
String value;
String encryptedValue = null;
try {
value = (String)getterMethod.invoke(object);
if (null != value) {
encryptedValue = cipher.encrypt(value);
setterMethod.invoke(object, encryptedValue);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
logger.error("Error when invoking method for a @Secret annotated field", e);
throw e;
}
}
}
|
[
"public",
"static",
"void",
"encryptFields",
"(",
"Object",
"object",
",",
"CollectionMetaData",
"cmd",
",",
"ICipher",
"cipher",
")",
"throws",
"IllegalAccessException",
",",
"IllegalArgumentException",
",",
"InvocationTargetException",
"{",
"for",
"(",
"String",
"secretAnnotatedFieldName",
":",
"cmd",
".",
"getSecretAnnotatedFieldNames",
"(",
")",
")",
"{",
"Method",
"getterMethod",
"=",
"cmd",
".",
"getGetterMethodForFieldName",
"(",
"secretAnnotatedFieldName",
")",
";",
"Method",
"setterMethod",
"=",
"cmd",
".",
"getSetterMethodForFieldName",
"(",
"secretAnnotatedFieldName",
")",
";",
"String",
"value",
";",
"String",
"encryptedValue",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"(",
"String",
")",
"getterMethod",
".",
"invoke",
"(",
"object",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"encryptedValue",
"=",
"cipher",
".",
"encrypt",
"(",
"value",
")",
";",
"setterMethod",
".",
"invoke",
"(",
"object",
",",
"encryptedValue",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error when invoking method for a @Secret annotated field\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}",
"}"
] |
A utility method to encrypt the value of field marked by the @Secret annotation using its
setter/mutator method.
@param object the actual Object representing the POJO we want the Id of.
@param cmd the CollectionMetaData object from which we can obtain the list
containing names of fields which have the @Secret annotation
@param cipher the actual cipher implementation to use
@throws IllegalAccessException Error when invoking method for a @Secret annotated field due to permissions
@throws IllegalArgumentException Error when invoking method for a @Secret annotated field due to wrong arguments
@throws InvocationTargetException Error when invoking method for a @Secret annotated field, the method threw a exception
|
[
"A",
"utility",
"method",
"to",
"encrypt",
"the",
"value",
"of",
"field",
"marked",
"by",
"the"
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/crypto/CryptoUtil.java#L58-L77
|
144,812
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/crypto/CryptoUtil.java
|
CryptoUtil.decryptFields
|
public static void decryptFields(Object object, CollectionMetaData cmd, ICipher cipher)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (String secretAnnotatedFieldName: cmd.getSecretAnnotatedFieldNames()) {
Method getterMethod = cmd.getGetterMethodForFieldName(secretAnnotatedFieldName);
Method setterMethod = cmd.getSetterMethodForFieldName(secretAnnotatedFieldName);
String value;
String decryptedValue = null;
try {
value = (String)getterMethod.invoke(object);
if (null != value) {
decryptedValue = cipher.decrypt(value);
setterMethod.invoke(object, decryptedValue);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
logger.error("Error when invoking method for a @Secret annotated field", e);
throw e;
}
}
}
|
java
|
public static void decryptFields(Object object, CollectionMetaData cmd, ICipher cipher)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (String secretAnnotatedFieldName: cmd.getSecretAnnotatedFieldNames()) {
Method getterMethod = cmd.getGetterMethodForFieldName(secretAnnotatedFieldName);
Method setterMethod = cmd.getSetterMethodForFieldName(secretAnnotatedFieldName);
String value;
String decryptedValue = null;
try {
value = (String)getterMethod.invoke(object);
if (null != value) {
decryptedValue = cipher.decrypt(value);
setterMethod.invoke(object, decryptedValue);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
logger.error("Error when invoking method for a @Secret annotated field", e);
throw e;
}
}
}
|
[
"public",
"static",
"void",
"decryptFields",
"(",
"Object",
"object",
",",
"CollectionMetaData",
"cmd",
",",
"ICipher",
"cipher",
")",
"throws",
"IllegalAccessException",
",",
"IllegalArgumentException",
",",
"InvocationTargetException",
"{",
"for",
"(",
"String",
"secretAnnotatedFieldName",
":",
"cmd",
".",
"getSecretAnnotatedFieldNames",
"(",
")",
")",
"{",
"Method",
"getterMethod",
"=",
"cmd",
".",
"getGetterMethodForFieldName",
"(",
"secretAnnotatedFieldName",
")",
";",
"Method",
"setterMethod",
"=",
"cmd",
".",
"getSetterMethodForFieldName",
"(",
"secretAnnotatedFieldName",
")",
";",
"String",
"value",
";",
"String",
"decryptedValue",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"(",
"String",
")",
"getterMethod",
".",
"invoke",
"(",
"object",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"decryptedValue",
"=",
"cipher",
".",
"decrypt",
"(",
"value",
")",
";",
"setterMethod",
".",
"invoke",
"(",
"object",
",",
"decryptedValue",
")",
";",
"}",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error when invoking method for a @Secret annotated field\"",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}",
"}"
] |
A utility method to decrypt the value of field marked by the @Secret annotation using its
setter/mutator method.
@param object the actual Object representing the POJO we want the Id of.
@param cmd the CollectionMetaData object from which we can obtain the list
containing names of fields which have the @Secret annotation
@param cipher the actual cipher implementation to use
@throws IllegalAccessException Error when invoking method for a @Secret annotated field due to permissions
@throws IllegalArgumentException Error when invoking method for a @Secret annotated field due to wrong arguments
@throws InvocationTargetException Error when invoking method for a @Secret annotated field, the method threw a exception
|
[
"A",
"utility",
"method",
"to",
"decrypt",
"the",
"value",
"of",
"field",
"marked",
"by",
"the"
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/crypto/CryptoUtil.java#L90-L110
|
144,813
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/crypto/CryptoUtil.java
|
CryptoUtil.generate128BitKey
|
public static String generate128BitKey(String password, String salt)
throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeySpecException {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 128);
SecretKey key = factory.generateSecret(spec);
byte[] keybyte = key.getEncoded();
return Base64.getEncoder().encodeToString(keybyte);
}
|
java
|
public static String generate128BitKey(String password, String salt)
throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeySpecException {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 128);
SecretKey key = factory.generateSecret(spec);
byte[] keybyte = key.getEncoded();
return Base64.getEncoder().encodeToString(keybyte);
}
|
[
"public",
"static",
"String",
"generate128BitKey",
"(",
"String",
"password",
",",
"String",
"salt",
")",
"throws",
"NoSuchAlgorithmException",
",",
"UnsupportedEncodingException",
",",
"InvalidKeySpecException",
"{",
"SecretKeyFactory",
"factory",
"=",
"SecretKeyFactory",
".",
"getInstance",
"(",
"\"PBKDF2WithHmacSHA256\"",
")",
";",
"KeySpec",
"spec",
"=",
"new",
"PBEKeySpec",
"(",
"password",
".",
"toCharArray",
"(",
")",
",",
"salt",
".",
"getBytes",
"(",
")",
",",
"65536",
",",
"128",
")",
";",
"SecretKey",
"key",
"=",
"factory",
".",
"generateSecret",
"(",
"spec",
")",
";",
"byte",
"[",
"]",
"keybyte",
"=",
"key",
".",
"getEncoded",
"(",
")",
";",
"return",
"Base64",
".",
"getEncoder",
"(",
")",
".",
"encodeToString",
"(",
"keybyte",
")",
";",
"}"
] |
Utility method to help generate a strong 128 bit Key to be used for the DefaultAESCBCCipher.
Note: This function is only provided as a utility to generate strong password it should
be used statically to generate a key and then the key should be captured and used in your program.
This function defaults to using 65536 iterations and 128 bits for key size. If you wish to use 256 bits key size
then ensure that you have Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy installed
and change the last argument to {@link javax.crypto.spec.PBEKeySpec} below to 256
@param password A password which acts as a seed for generation of the key
@param salt A salt used in combination with the password for the generation of the key
@return A Base64 Encoded string representing the 128 bit key
@throws NoSuchAlgorithmException if the KeyFactory algorithm is not found in available crypto providers
@throws UnsupportedEncodingException if the char encoding of the salt is not known.
@throws InvalidKeySpecException invalid generated key
|
[
"Utility",
"method",
"to",
"help",
"generate",
"a",
"strong",
"128",
"bit",
"Key",
"to",
"be",
"used",
"for",
"the",
"DefaultAESCBCCipher",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/crypto/CryptoUtil.java#L131-L140
|
144,814
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java
|
CollectionSchemaUpdate.update
|
public static CollectionSchemaUpdate update(String key, IOperation operation) {
return new CollectionSchemaUpdate().set(key, operation);
}
|
java
|
public static CollectionSchemaUpdate update(String key, IOperation operation) {
return new CollectionSchemaUpdate().set(key, operation);
}
|
[
"public",
"static",
"CollectionSchemaUpdate",
"update",
"(",
"String",
"key",
",",
"IOperation",
"operation",
")",
"{",
"return",
"new",
"CollectionSchemaUpdate",
"(",
")",
".",
"set",
"(",
"key",
",",
"operation",
")",
";",
"}"
] |
Static factory method to create an CollectionUpdate for the specified key
@param key: JSON attribute to update
@param operation: operation to carry out on the attribute
@return the updated CollectionSchemaUpdate
|
[
"Static",
"factory",
"method",
"to",
"create",
"an",
"CollectionUpdate",
"for",
"the",
"specified",
"key"
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java#L48-L50
|
144,815
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java
|
CollectionSchemaUpdate.set
|
public CollectionSchemaUpdate set(String key, IOperation operation) {
collectionUpdateData.put(key, operation);
return this;
}
|
java
|
public CollectionSchemaUpdate set(String key, IOperation operation) {
collectionUpdateData.put(key, operation);
return this;
}
|
[
"public",
"CollectionSchemaUpdate",
"set",
"(",
"String",
"key",
",",
"IOperation",
"operation",
")",
"{",
"collectionUpdateData",
".",
"put",
"(",
"key",
",",
"operation",
")",
";",
"return",
"this",
";",
"}"
] |
A method to set a new Operation for a key. It may be of type ADD, RENAME or DELETE.
Only one operation per key can be specified. Attempt to add a second operation for a any key will override the first one.
Attempt to add a ADD operation for a key which already exists will have no effect.
Attempt to add a DELETE operation for akey which does not exist will have no effect.
@param key (a.k.a JSON Field name) for which operation is being added
@param operation operation to perform
@return the updated CollectionSchemaUpdate
|
[
"A",
"method",
"to",
"set",
"a",
"new",
"Operation",
"for",
"a",
"key",
".",
"It",
"may",
"be",
"of",
"type",
"ADD",
"RENAME",
"or",
"DELETE",
".",
"Only",
"one",
"operation",
"per",
"key",
"can",
"be",
"specified",
".",
"Attempt",
"to",
"add",
"a",
"second",
"operation",
"for",
"a",
"any",
"key",
"will",
"override",
"the",
"first",
"one",
".",
"Attempt",
"to",
"add",
"a",
"ADD",
"operation",
"for",
"a",
"key",
"which",
"already",
"exists",
"will",
"have",
"no",
"effect",
".",
"Attempt",
"to",
"add",
"a",
"DELETE",
"operation",
"for",
"akey",
"which",
"does",
"not",
"exist",
"will",
"have",
"no",
"effect",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java#L62-L65
|
144,816
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java
|
CollectionSchemaUpdate.getAddOperations
|
public Map<String, AddOperation> getAddOperations() {
Map<String, AddOperation> addOperations = new TreeMap<String, AddOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.ADD)) {
AddOperation aop = (AddOperation)op;
if (null != aop.getDefaultValue()) {
addOperations.put(key, aop);
}
}
}
return addOperations;
}
|
java
|
public Map<String, AddOperation> getAddOperations() {
Map<String, AddOperation> addOperations = new TreeMap<String, AddOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.ADD)) {
AddOperation aop = (AddOperation)op;
if (null != aop.getDefaultValue()) {
addOperations.put(key, aop);
}
}
}
return addOperations;
}
|
[
"public",
"Map",
"<",
"String",
",",
"AddOperation",
">",
"getAddOperations",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"AddOperation",
">",
"addOperations",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"AddOperation",
">",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"IOperation",
">",
"entry",
":",
"collectionUpdateData",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"IOperation",
"op",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"op",
".",
"getOperationType",
"(",
")",
".",
"equals",
"(",
"Type",
".",
"ADD",
")",
")",
"{",
"AddOperation",
"aop",
"=",
"(",
"AddOperation",
")",
"op",
";",
"if",
"(",
"null",
"!=",
"aop",
".",
"getDefaultValue",
"(",
")",
")",
"{",
"addOperations",
".",
"put",
"(",
"key",
",",
"aop",
")",
";",
"}",
"}",
"}",
"return",
"addOperations",
";",
"}"
] |
Returns a Map of ADD operations which have a non-null default value specified.
@return Map of ADD operations which have a non-null default value specified
|
[
"Returns",
"a",
"Map",
"of",
"ADD",
"operations",
"which",
"have",
"a",
"non",
"-",
"null",
"default",
"value",
"specified",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java#L76-L89
|
144,817
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java
|
CollectionSchemaUpdate.getRenameOperations
|
public Map<String, RenameOperation> getRenameOperations() {
Map<String, RenameOperation> renOperations = new TreeMap<String, RenameOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.RENAME)) {
renOperations.put(key, (RenameOperation)op);
}
}
return renOperations;
}
|
java
|
public Map<String, RenameOperation> getRenameOperations() {
Map<String, RenameOperation> renOperations = new TreeMap<String, RenameOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.RENAME)) {
renOperations.put(key, (RenameOperation)op);
}
}
return renOperations;
}
|
[
"public",
"Map",
"<",
"String",
",",
"RenameOperation",
">",
"getRenameOperations",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"RenameOperation",
">",
"renOperations",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"RenameOperation",
">",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"IOperation",
">",
"entry",
":",
"collectionUpdateData",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"IOperation",
"op",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"op",
".",
"getOperationType",
"(",
")",
".",
"equals",
"(",
"Type",
".",
"RENAME",
")",
")",
"{",
"renOperations",
".",
"put",
"(",
"key",
",",
"(",
"RenameOperation",
")",
"op",
")",
";",
"}",
"}",
"return",
"renOperations",
";",
"}"
] |
Returns a Map of RENAME operations.
@return Map of RENAME operations which have a non-null default value specified
|
[
"Returns",
"a",
"Map",
"of",
"RENAME",
"operations",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java#L96-L106
|
144,818
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java
|
CollectionSchemaUpdate.getDeleteOperations
|
public Map<String, DeleteOperation> getDeleteOperations() {
Map<String, DeleteOperation> delOperations = new TreeMap<String, DeleteOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.DELETE)) {
delOperations.put(key, (DeleteOperation)op);
}
}
return delOperations;
}
|
java
|
public Map<String, DeleteOperation> getDeleteOperations() {
Map<String, DeleteOperation> delOperations = new TreeMap<String, DeleteOperation>();
for (Entry<String, IOperation> entry : collectionUpdateData.entrySet()) {
String key = entry.getKey();
IOperation op = entry.getValue();
if (op.getOperationType().equals(Type.DELETE)) {
delOperations.put(key, (DeleteOperation)op);
}
}
return delOperations;
}
|
[
"public",
"Map",
"<",
"String",
",",
"DeleteOperation",
">",
"getDeleteOperations",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"DeleteOperation",
">",
"delOperations",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"DeleteOperation",
">",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"IOperation",
">",
"entry",
":",
"collectionUpdateData",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"IOperation",
"op",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"op",
".",
"getOperationType",
"(",
")",
".",
"equals",
"(",
"Type",
".",
"DELETE",
")",
")",
"{",
"delOperations",
".",
"put",
"(",
"key",
",",
"(",
"DeleteOperation",
")",
"op",
")",
";",
"}",
"}",
"return",
"delOperations",
";",
"}"
] |
Returns a Map of DELETE operations.
@return Map of DELETE operations which have a non-null default value specified
|
[
"Returns",
"a",
"Map",
"of",
"DELETE",
"operations",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/query/ddl/CollectionSchemaUpdate.java#L113-L123
|
144,819
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/Util.java
|
Util.getIdForEntity
|
protected static Object getIdForEntity(Object document, Method getterMethodForId) {
Object id = null;
if (null != getterMethodForId) {
try {
id = getterMethodForId.invoke(document);
} catch (IllegalAccessException e) {
logger.error("Failed to invoke getter method for a idAnnotated field due to permissions", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field due to permissions", e);
} catch (IllegalArgumentException e) {
logger.error("Failed to invoke getter method for a idAnnotated field due to wrong arguments", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field due to wrong arguments", e);
} catch (InvocationTargetException e) {
logger.error("Failed to invoke getter method for a idAnnotated field, the method threw a exception", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field, the method threw a exception", e);
}
}
return id;
}
|
java
|
protected static Object getIdForEntity(Object document, Method getterMethodForId) {
Object id = null;
if (null != getterMethodForId) {
try {
id = getterMethodForId.invoke(document);
} catch (IllegalAccessException e) {
logger.error("Failed to invoke getter method for a idAnnotated field due to permissions", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field due to permissions", e);
} catch (IllegalArgumentException e) {
logger.error("Failed to invoke getter method for a idAnnotated field due to wrong arguments", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field due to wrong arguments", e);
} catch (InvocationTargetException e) {
logger.error("Failed to invoke getter method for a idAnnotated field, the method threw a exception", e);
throw new InvalidJsonDbApiUsageException("Failed to invoke getter method for a idAnnotated field, the method threw a exception", e);
}
}
return id;
}
|
[
"protected",
"static",
"Object",
"getIdForEntity",
"(",
"Object",
"document",
",",
"Method",
"getterMethodForId",
")",
"{",
"Object",
"id",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"getterMethodForId",
")",
"{",
"try",
"{",
"id",
"=",
"getterMethodForId",
".",
"invoke",
"(",
"document",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to invoke getter method for a idAnnotated field due to permissions\"",
",",
"e",
")",
";",
"throw",
"new",
"InvalidJsonDbApiUsageException",
"(",
"\"Failed to invoke getter method for a idAnnotated field due to permissions\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to invoke getter method for a idAnnotated field due to wrong arguments\"",
",",
"e",
")",
";",
"throw",
"new",
"InvalidJsonDbApiUsageException",
"(",
"\"Failed to invoke getter method for a idAnnotated field due to wrong arguments\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to invoke getter method for a idAnnotated field, the method threw a exception\"",
",",
"e",
")",
";",
"throw",
"new",
"InvalidJsonDbApiUsageException",
"(",
"\"Failed to invoke getter method for a idAnnotated field, the method threw a exception\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"id",
";",
"}"
] |
A utility method to extract the value of field marked by the @Id annotation using its
getter/accessor method.
@param document the actual Object representing the POJO we want the Id of.
@param getterMethodForId the Method that is the accessor for the attributed with @Id annotation
@return the actual Id or if none exists then a new random UUID
|
[
"A",
"utility",
"method",
"to",
"extract",
"the",
"value",
"of",
"field",
"marked",
"by",
"the"
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/Util.java#L107-L124
|
144,820
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/Util.java
|
Util.deepCopy
|
protected static Object deepCopy(Object fromBean) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLEncoder out = new XMLEncoder(bos);
out.writeObject(fromBean);
out.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
XMLDecoder in = new XMLDecoder(bis, null, null, JsonDBTemplate.class.getClassLoader());
Object toBean = in.readObject();
in.close();
return toBean;
}
|
java
|
protected static Object deepCopy(Object fromBean) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
XMLEncoder out = new XMLEncoder(bos);
out.writeObject(fromBean);
out.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
XMLDecoder in = new XMLDecoder(bis, null, null, JsonDBTemplate.class.getClassLoader());
Object toBean = in.readObject();
in.close();
return toBean;
}
|
[
"protected",
"static",
"Object",
"deepCopy",
"(",
"Object",
"fromBean",
")",
"{",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"XMLEncoder",
"out",
"=",
"new",
"XMLEncoder",
"(",
"bos",
")",
";",
"out",
".",
"writeObject",
"(",
"fromBean",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"ByteArrayInputStream",
"bis",
"=",
"new",
"ByteArrayInputStream",
"(",
"bos",
".",
"toByteArray",
"(",
")",
")",
";",
"XMLDecoder",
"in",
"=",
"new",
"XMLDecoder",
"(",
"bis",
",",
"null",
",",
"null",
",",
"JsonDBTemplate",
".",
"class",
".",
"getClassLoader",
"(",
")",
")",
";",
"Object",
"toBean",
"=",
"in",
".",
"readObject",
"(",
")",
";",
"in",
".",
"close",
"(",
")",
";",
"return",
"toBean",
";",
"}"
] |
A utility method that creates a deep clone of the specified object.
There is no other way of doing this reliably.
@param fromBean java bean to be cloned.
@return a new java bean cloned from fromBean.
|
[
"A",
"utility",
"method",
"that",
"creates",
"a",
"deep",
"clone",
"of",
"the",
"specified",
"object",
".",
"There",
"is",
"no",
"other",
"way",
"of",
"doing",
"this",
"reliably",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/Util.java#L177-L188
|
144,821
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/Util.java
|
Util.stampVersion
|
public static boolean stampVersion(JsonDBConfig dbConfig, File f, String version) {
FileOutputStream fos = null;
OutputStreamWriter osr = null;
BufferedWriter writer = null;
try {
fos = new FileOutputStream(f);
osr = new OutputStreamWriter(fos, dbConfig.getCharset());
writer = new BufferedWriter(osr);
String versionData = dbConfig.getObjectMapper().writeValueAsString(new SchemaVersion(version));
writer.write(versionData);
writer.newLine();
} catch (JsonProcessingException e) {
logger.error("Failed to serialize SchemaVersion to Json string", e);
return false;
} catch (IOException e) {
logger.error("Failed to write SchemaVersion to the new .json file {}", f, e);
return false;
} finally {
try {
writer.close();
} catch (IOException e) {
logger.error("Failed to close BufferedWriter for new collection file {}", f, e);
}
try {
osr.close();
} catch (IOException e) {
logger.error("Failed to close OutputStreamWriter for new collection file {}", f, e);
}
try {
fos.close();
} catch (IOException e) {
logger.error("Failed to close FileOutputStream for new collection file {}", f, e);
}
}
return true;
}
|
java
|
public static boolean stampVersion(JsonDBConfig dbConfig, File f, String version) {
FileOutputStream fos = null;
OutputStreamWriter osr = null;
BufferedWriter writer = null;
try {
fos = new FileOutputStream(f);
osr = new OutputStreamWriter(fos, dbConfig.getCharset());
writer = new BufferedWriter(osr);
String versionData = dbConfig.getObjectMapper().writeValueAsString(new SchemaVersion(version));
writer.write(versionData);
writer.newLine();
} catch (JsonProcessingException e) {
logger.error("Failed to serialize SchemaVersion to Json string", e);
return false;
} catch (IOException e) {
logger.error("Failed to write SchemaVersion to the new .json file {}", f, e);
return false;
} finally {
try {
writer.close();
} catch (IOException e) {
logger.error("Failed to close BufferedWriter for new collection file {}", f, e);
}
try {
osr.close();
} catch (IOException e) {
logger.error("Failed to close OutputStreamWriter for new collection file {}", f, e);
}
try {
fos.close();
} catch (IOException e) {
logger.error("Failed to close FileOutputStream for new collection file {}", f, e);
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"stampVersion",
"(",
"JsonDBConfig",
"dbConfig",
",",
"File",
"f",
",",
"String",
"version",
")",
"{",
"FileOutputStream",
"fos",
"=",
"null",
";",
"OutputStreamWriter",
"osr",
"=",
"null",
";",
"BufferedWriter",
"writer",
"=",
"null",
";",
"try",
"{",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"f",
")",
";",
"osr",
"=",
"new",
"OutputStreamWriter",
"(",
"fos",
",",
"dbConfig",
".",
"getCharset",
"(",
")",
")",
";",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"osr",
")",
";",
"String",
"versionData",
"=",
"dbConfig",
".",
"getObjectMapper",
"(",
")",
".",
"writeValueAsString",
"(",
"new",
"SchemaVersion",
"(",
"version",
")",
")",
";",
"writer",
".",
"write",
"(",
"versionData",
")",
";",
"writer",
".",
"newLine",
"(",
")",
";",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to serialize SchemaVersion to Json string\"",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to write SchemaVersion to the new .json file {}\"",
",",
"f",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"try",
"{",
"writer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to close BufferedWriter for new collection file {}\"",
",",
"f",
",",
"e",
")",
";",
"}",
"try",
"{",
"osr",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to close OutputStreamWriter for new collection file {}\"",
",",
"f",
",",
"e",
")",
";",
"}",
"try",
"{",
"fos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Failed to close FileOutputStream for new collection file {}\"",
",",
"f",
",",
"e",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Utility to stamp the version into a newly created .json File
This method is expected to be invoked on a newly created .json file before it is usable.
So no locking code required.
@param dbConfig all the settings used by Json DB
@param f the target .json file on which to stamp the version
@param version the actual version string to stamp
@return true if success.
|
[
"Utility",
"to",
"stamp",
"the",
"version",
"into",
"a",
"newly",
"created",
".",
"json",
"File",
"This",
"method",
"is",
"expected",
"to",
"be",
"invoked",
"on",
"a",
"newly",
"created",
".",
"json",
"file",
"before",
"it",
"is",
"usable",
".",
"So",
"no",
"locking",
"code",
"required",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/Util.java#L200-L237
|
144,822
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/crypto/DefaultAESCBCCipher.java
|
DefaultAESCBCCipher.decrypt
|
@Override
public String decrypt(String cipherText) {
this.decryptionLock.lock();
try{
String decryptedValue = null;
try {
byte[] bytes = Base64.getDecoder().decode(cipherText);
decryptedValue = new String(decryptCipher.doFinal(bytes), charset);
} catch (UnsupportedEncodingException | IllegalBlockSizeException | BadPaddingException e) {
logger.error("DefaultAESCBCCipher failed to decrypt text", e);
throw new JsonDBException("DefaultAESCBCCipher failed to decrypt text", e);
}
return decryptedValue;
} finally{
this.decryptionLock.unlock();
}
}
|
java
|
@Override
public String decrypt(String cipherText) {
this.decryptionLock.lock();
try{
String decryptedValue = null;
try {
byte[] bytes = Base64.getDecoder().decode(cipherText);
decryptedValue = new String(decryptCipher.doFinal(bytes), charset);
} catch (UnsupportedEncodingException | IllegalBlockSizeException | BadPaddingException e) {
logger.error("DefaultAESCBCCipher failed to decrypt text", e);
throw new JsonDBException("DefaultAESCBCCipher failed to decrypt text", e);
}
return decryptedValue;
} finally{
this.decryptionLock.unlock();
}
}
|
[
"@",
"Override",
"public",
"String",
"decrypt",
"(",
"String",
"cipherText",
")",
"{",
"this",
".",
"decryptionLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"String",
"decryptedValue",
"=",
"null",
";",
"try",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"decode",
"(",
"cipherText",
")",
";",
"decryptedValue",
"=",
"new",
"String",
"(",
"decryptCipher",
".",
"doFinal",
"(",
"bytes",
")",
",",
"charset",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"|",
"IllegalBlockSizeException",
"|",
"BadPaddingException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"DefaultAESCBCCipher failed to decrypt text\"",
",",
"e",
")",
";",
"throw",
"new",
"JsonDBException",
"(",
"\"DefaultAESCBCCipher failed to decrypt text\"",
",",
"e",
")",
";",
"}",
"return",
"decryptedValue",
";",
"}",
"finally",
"{",
"this",
".",
"decryptionLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
A method to decrypt the provided cipher text.
@param cipherText AES encrypted cipherText
@return decrypted text
|
[
"A",
"method",
"to",
"decrypt",
"the",
"provided",
"cipher",
"text",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/crypto/DefaultAESCBCCipher.java#L180-L196
|
144,823
|
Jsondb/jsondb-core
|
src/main/java/io/jsondb/DefaultSchemaVersionComparator.java
|
DefaultSchemaVersionComparator.compare
|
@Override
public int compare(String expected, String actual) {
String[] vals1 = expected.split("\\.");
String[] vals2 = actual.split("\\.");
int i = 0;
while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
i++;
}
if (i < vals1.length && i < vals2.length) {
int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
return Integer.signum(diff);
} else {
return Integer.signum(vals1.length - vals2.length);
}
}
|
java
|
@Override
public int compare(String expected, String actual) {
String[] vals1 = expected.split("\\.");
String[] vals2 = actual.split("\\.");
int i = 0;
while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
i++;
}
if (i < vals1.length && i < vals2.length) {
int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
return Integer.signum(diff);
} else {
return Integer.signum(vals1.length - vals2.length);
}
}
|
[
"@",
"Override",
"public",
"int",
"compare",
"(",
"String",
"expected",
",",
"String",
"actual",
")",
"{",
"String",
"[",
"]",
"vals1",
"=",
"expected",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"String",
"[",
"]",
"vals2",
"=",
"actual",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"vals1",
".",
"length",
"&&",
"i",
"<",
"vals2",
".",
"length",
"&&",
"vals1",
"[",
"i",
"]",
".",
"equals",
"(",
"vals2",
"[",
"i",
"]",
")",
")",
"{",
"i",
"++",
";",
"}",
"if",
"(",
"i",
"<",
"vals1",
".",
"length",
"&&",
"i",
"<",
"vals2",
".",
"length",
")",
"{",
"int",
"diff",
"=",
"Integer",
".",
"valueOf",
"(",
"vals1",
"[",
"i",
"]",
")",
".",
"compareTo",
"(",
"Integer",
".",
"valueOf",
"(",
"vals2",
"[",
"i",
"]",
")",
")",
";",
"return",
"Integer",
".",
"signum",
"(",
"diff",
")",
";",
"}",
"else",
"{",
"return",
"Integer",
".",
"signum",
"(",
"vals1",
".",
"length",
"-",
"vals2",
".",
"length",
")",
";",
"}",
"}"
] |
compare the expected version with the actual version.
Checkout: http://stackoverflow.com/questions/6701948/efficient-way-to-compare-version-strings-in-java
@param expected the version that is obtained from @Document annotation
@param actual the version that is read from the .json file
@return a negative integer, zero, or a positive integer as the first argument is less
than, equal to, or greater than the second.
|
[
"compare",
"the",
"expected",
"version",
"with",
"the",
"actual",
"version",
"."
] |
c49654d1eee2ace4d5ca5be19730652a966ce7f4
|
https://github.com/Jsondb/jsondb-core/blob/c49654d1eee2ace4d5ca5be19730652a966ce7f4/src/main/java/io/jsondb/DefaultSchemaVersionComparator.java#L44-L60
|
144,824
|
cognitect/transit-java
|
src/main/java/com/cognitect/transit/TransitFactory.java
|
TransitFactory.keyword
|
public static Keyword keyword(Object o) {
if (o instanceof Keyword)
return (Keyword) o;
else if (o instanceof String) {
String s = (String) o;
if (s.charAt(0) == ':')
return new KeywordImpl(s.substring(1));
else
return new KeywordImpl(s);
}
else throw new IllegalArgumentException("Cannot make keyword from " + o.getClass().getSimpleName());
}
|
java
|
public static Keyword keyword(Object o) {
if (o instanceof Keyword)
return (Keyword) o;
else if (o instanceof String) {
String s = (String) o;
if (s.charAt(0) == ':')
return new KeywordImpl(s.substring(1));
else
return new KeywordImpl(s);
}
else throw new IllegalArgumentException("Cannot make keyword from " + o.getClass().getSimpleName());
}
|
[
"public",
"static",
"Keyword",
"keyword",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Keyword",
")",
"return",
"(",
"Keyword",
")",
"o",
";",
"else",
"if",
"(",
"o",
"instanceof",
"String",
")",
"{",
"String",
"s",
"=",
"(",
"String",
")",
"o",
";",
"if",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"return",
"new",
"KeywordImpl",
"(",
"s",
".",
"substring",
"(",
"1",
")",
")",
";",
"else",
"return",
"new",
"KeywordImpl",
"(",
"s",
")",
";",
"}",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot make keyword from \"",
"+",
"o",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}"
] |
Converts a string or keyword to a keyword
@param o A string or a keyword
@return a keyword
|
[
"Converts",
"a",
"string",
"or",
"keyword",
"to",
"a",
"keyword"
] |
a1d5edc2862fe9469c51483b9c53dbf6534e9c43
|
https://github.com/cognitect/transit-java/blob/a1d5edc2862fe9469c51483b9c53dbf6534e9c43/src/main/java/com/cognitect/transit/TransitFactory.java#L177-L188
|
144,825
|
cognitect/transit-java
|
src/main/java/com/cognitect/transit/TransitFactory.java
|
TransitFactory.symbol
|
public static Symbol symbol(Object o) {
if (o instanceof Symbol)
return (Symbol) o;
else if (o instanceof String) {
String s = (String) o;
if (s.charAt(0) == ':')
return new SymbolImpl(s.substring(1));
else
return new SymbolImpl(s);
}
else throw new IllegalArgumentException("Cannot make symbol from " + o.getClass().getSimpleName());
}
|
java
|
public static Symbol symbol(Object o) {
if (o instanceof Symbol)
return (Symbol) o;
else if (o instanceof String) {
String s = (String) o;
if (s.charAt(0) == ':')
return new SymbolImpl(s.substring(1));
else
return new SymbolImpl(s);
}
else throw new IllegalArgumentException("Cannot make symbol from " + o.getClass().getSimpleName());
}
|
[
"public",
"static",
"Symbol",
"symbol",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Symbol",
")",
"return",
"(",
"Symbol",
")",
"o",
";",
"else",
"if",
"(",
"o",
"instanceof",
"String",
")",
"{",
"String",
"s",
"=",
"(",
"String",
")",
"o",
";",
"if",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"return",
"new",
"SymbolImpl",
"(",
"s",
".",
"substring",
"(",
"1",
")",
")",
";",
"else",
"return",
"new",
"SymbolImpl",
"(",
"s",
")",
";",
"}",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot make symbol from \"",
"+",
"o",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}"
] |
Converts a string or a symbol to a symbol
@param o a string or a symbol
@return a symbol
|
[
"Converts",
"a",
"string",
"or",
"a",
"symbol",
"to",
"a",
"symbol"
] |
a1d5edc2862fe9469c51483b9c53dbf6534e9c43
|
https://github.com/cognitect/transit-java/blob/a1d5edc2862fe9469c51483b9c53dbf6534e9c43/src/main/java/com/cognitect/transit/TransitFactory.java#L195-L206
|
144,826
|
cognitect/transit-java
|
src/main/java/com/cognitect/transit/TransitFactory.java
|
TransitFactory.taggedValue
|
public static <T> TaggedValue<T> taggedValue(String tag, T rep) {
return new TaggedValueImpl<T>(tag, rep);
}
|
java
|
public static <T> TaggedValue<T> taggedValue(String tag, T rep) {
return new TaggedValueImpl<T>(tag, rep);
}
|
[
"public",
"static",
"<",
"T",
">",
"TaggedValue",
"<",
"T",
">",
"taggedValue",
"(",
"String",
"tag",
",",
"T",
"rep",
")",
"{",
"return",
"new",
"TaggedValueImpl",
"<",
"T",
">",
"(",
"tag",
",",
"rep",
")",
";",
"}"
] |
Creates a TaggedValue
@param tag tag string
@param rep value representation
@return a tagged value
|
[
"Creates",
"a",
"TaggedValue"
] |
a1d5edc2862fe9469c51483b9c53dbf6534e9c43
|
https://github.com/cognitect/transit-java/blob/a1d5edc2862fe9469c51483b9c53dbf6534e9c43/src/main/java/com/cognitect/transit/TransitFactory.java#L214-L216
|
144,827
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readNumber
|
private long readNumber(int firstChar, boolean isNeg) throws IOException {
out.unsafeWrite(firstChar); // unsafe OK since we know output is big enough
// We build up the number in the negative plane since it's larger (by one) than
// the positive plane.
long v = '0' - firstChar;
// can't overflow a long in 18 decimal digits (i.e. 17 additional after the first).
// we also need 22 additional to handle double so we'll handle in 2 separate loops.
int i;
for (i=0; i<17; i++) {
int ch = getChar();
// TODO: is this switch faster as an if-then-else?
switch(ch) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v = v*10 - (ch-'0');
out.unsafeWrite(ch);
continue;
case '.':
out.unsafeWrite('.');
valstate = readFrac(out,22-i);
return 0;
case 'e':
case 'E':
out.unsafeWrite(ch);
nstate=0;
valstate = readExp(out,22-i);
return 0;
default:
// return the number, relying on nextEvent() to return an error
// for invalid chars following the number.
if (ch!=-1) --start; // push back last char if not EOF
valstate = LONG;
return isNeg ? v : -v;
}
}
// after this, we could overflow a long and need to do extra checking
boolean overflow = false;
long maxval = isNeg ? Long.MIN_VALUE : -Long.MAX_VALUE;
for (; i<22; i++) {
int ch = getChar();
switch(ch) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (v < (0x8000000000000000L/10)) overflow=true; // can't multiply by 10 w/o overflowing
v *= 10;
int digit = ch - '0';
if (v < maxval + digit) overflow=true; // can't add digit w/o overflowing
v -= digit;
out.unsafeWrite(ch);
continue;
case '.':
out.unsafeWrite('.');
valstate = readFrac(out,22-i);
return 0;
case 'e':
case 'E':
out.unsafeWrite(ch);
nstate=0;
valstate = readExp(out,22-i);
return 0;
default:
// return the number, relying on nextEvent() to return an error
// for invalid chars following the number.
if (ch!=-1) --start; // push back last char if not EOF
valstate = overflow ? BIGNUMBER : LONG;
return isNeg ? v : -v;
}
}
nstate=0;
valstate = BIGNUMBER;
return 0;
}
|
java
|
private long readNumber(int firstChar, boolean isNeg) throws IOException {
out.unsafeWrite(firstChar); // unsafe OK since we know output is big enough
// We build up the number in the negative plane since it's larger (by one) than
// the positive plane.
long v = '0' - firstChar;
// can't overflow a long in 18 decimal digits (i.e. 17 additional after the first).
// we also need 22 additional to handle double so we'll handle in 2 separate loops.
int i;
for (i=0; i<17; i++) {
int ch = getChar();
// TODO: is this switch faster as an if-then-else?
switch(ch) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
v = v*10 - (ch-'0');
out.unsafeWrite(ch);
continue;
case '.':
out.unsafeWrite('.');
valstate = readFrac(out,22-i);
return 0;
case 'e':
case 'E':
out.unsafeWrite(ch);
nstate=0;
valstate = readExp(out,22-i);
return 0;
default:
// return the number, relying on nextEvent() to return an error
// for invalid chars following the number.
if (ch!=-1) --start; // push back last char if not EOF
valstate = LONG;
return isNeg ? v : -v;
}
}
// after this, we could overflow a long and need to do extra checking
boolean overflow = false;
long maxval = isNeg ? Long.MIN_VALUE : -Long.MAX_VALUE;
for (; i<22; i++) {
int ch = getChar();
switch(ch) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (v < (0x8000000000000000L/10)) overflow=true; // can't multiply by 10 w/o overflowing
v *= 10;
int digit = ch - '0';
if (v < maxval + digit) overflow=true; // can't add digit w/o overflowing
v -= digit;
out.unsafeWrite(ch);
continue;
case '.':
out.unsafeWrite('.');
valstate = readFrac(out,22-i);
return 0;
case 'e':
case 'E':
out.unsafeWrite(ch);
nstate=0;
valstate = readExp(out,22-i);
return 0;
default:
// return the number, relying on nextEvent() to return an error
// for invalid chars following the number.
if (ch!=-1) --start; // push back last char if not EOF
valstate = overflow ? BIGNUMBER : LONG;
return isNeg ? v : -v;
}
}
nstate=0;
valstate = BIGNUMBER;
return 0;
}
|
[
"private",
"long",
"readNumber",
"(",
"int",
"firstChar",
",",
"boolean",
"isNeg",
")",
"throws",
"IOException",
"{",
"out",
".",
"unsafeWrite",
"(",
"firstChar",
")",
";",
"// unsafe OK since we know output is big enough",
"// We build up the number in the negative plane since it's larger (by one) than",
"// the positive plane.",
"long",
"v",
"=",
"'",
"'",
"-",
"firstChar",
";",
"// can't overflow a long in 18 decimal digits (i.e. 17 additional after the first).",
"// we also need 22 additional to handle double so we'll handle in 2 separate loops.",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"17",
";",
"i",
"++",
")",
"{",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"// TODO: is this switch faster as an if-then-else?",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"v",
"=",
"v",
"*",
"10",
"-",
"(",
"ch",
"-",
"'",
"'",
")",
";",
"out",
".",
"unsafeWrite",
"(",
"ch",
")",
";",
"continue",
";",
"case",
"'",
"'",
":",
"out",
".",
"unsafeWrite",
"(",
"'",
"'",
")",
";",
"valstate",
"=",
"readFrac",
"(",
"out",
",",
"22",
"-",
"i",
")",
";",
"return",
"0",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"out",
".",
"unsafeWrite",
"(",
"ch",
")",
";",
"nstate",
"=",
"0",
";",
"valstate",
"=",
"readExp",
"(",
"out",
",",
"22",
"-",
"i",
")",
";",
"return",
"0",
";",
"default",
":",
"// return the number, relying on nextEvent() to return an error",
"// for invalid chars following the number.",
"if",
"(",
"ch",
"!=",
"-",
"1",
")",
"--",
"start",
";",
"// push back last char if not EOF",
"valstate",
"=",
"LONG",
";",
"return",
"isNeg",
"?",
"v",
":",
"-",
"v",
";",
"}",
"}",
"// after this, we could overflow a long and need to do extra checking",
"boolean",
"overflow",
"=",
"false",
";",
"long",
"maxval",
"=",
"isNeg",
"?",
"Long",
".",
"MIN_VALUE",
":",
"-",
"Long",
".",
"MAX_VALUE",
";",
"for",
"(",
";",
"i",
"<",
"22",
";",
"i",
"++",
")",
"{",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"if",
"(",
"v",
"<",
"(",
"0x8000000000000000",
"L",
"/",
"10",
")",
")",
"overflow",
"=",
"true",
";",
"// can't multiply by 10 w/o overflowing",
"v",
"*=",
"10",
";",
"int",
"digit",
"=",
"ch",
"-",
"'",
"'",
";",
"if",
"(",
"v",
"<",
"maxval",
"+",
"digit",
")",
"overflow",
"=",
"true",
";",
"// can't add digit w/o overflowing",
"v",
"-=",
"digit",
";",
"out",
".",
"unsafeWrite",
"(",
"ch",
")",
";",
"continue",
";",
"case",
"'",
"'",
":",
"out",
".",
"unsafeWrite",
"(",
"'",
"'",
")",
";",
"valstate",
"=",
"readFrac",
"(",
"out",
",",
"22",
"-",
"i",
")",
";",
"return",
"0",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"out",
".",
"unsafeWrite",
"(",
"ch",
")",
";",
"nstate",
"=",
"0",
";",
"valstate",
"=",
"readExp",
"(",
"out",
",",
"22",
"-",
"i",
")",
";",
"return",
"0",
";",
"default",
":",
"// return the number, relying on nextEvent() to return an error",
"// for invalid chars following the number.",
"if",
"(",
"ch",
"!=",
"-",
"1",
")",
"--",
"start",
";",
"// push back last char if not EOF",
"valstate",
"=",
"overflow",
"?",
"BIGNUMBER",
":",
"LONG",
";",
"return",
"isNeg",
"?",
"v",
":",
"-",
"v",
";",
"}",
"}",
"nstate",
"=",
"0",
";",
"valstate",
"=",
"BIGNUMBER",
";",
"return",
"0",
";",
"}"
] |
Returns the long read... only significant if valstate==LONG after
this call. firstChar should be the first numeric digit read.
|
[
"Returns",
"the",
"long",
"read",
"...",
"only",
"significant",
"if",
"valstate",
"==",
"LONG",
"after",
"this",
"call",
".",
"firstChar",
"should",
"be",
"the",
"first",
"numeric",
"digit",
"read",
"."
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L449-L542
|
144,828
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readFrac
|
private int readFrac(CharArr arr, int lim) throws IOException {
nstate = HAS_FRACTION; // deliberate set instead of '|'
while(--lim>=0) {
int ch = getChar();
if (ch>='0' && ch<='9') {
arr.write(ch);
} else if (ch=='e' || ch=='E') {
arr.write(ch);
return readExp(arr,lim);
} else {
if (ch!=-1) start--; // back up
return NUMBER;
}
}
return BIGNUMBER;
}
|
java
|
private int readFrac(CharArr arr, int lim) throws IOException {
nstate = HAS_FRACTION; // deliberate set instead of '|'
while(--lim>=0) {
int ch = getChar();
if (ch>='0' && ch<='9') {
arr.write(ch);
} else if (ch=='e' || ch=='E') {
arr.write(ch);
return readExp(arr,lim);
} else {
if (ch!=-1) start--; // back up
return NUMBER;
}
}
return BIGNUMBER;
}
|
[
"private",
"int",
"readFrac",
"(",
"CharArr",
"arr",
",",
"int",
"lim",
")",
"throws",
"IOException",
"{",
"nstate",
"=",
"HAS_FRACTION",
";",
"// deliberate set instead of '|'",
"while",
"(",
"--",
"lim",
">=",
"0",
")",
"{",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"if",
"(",
"ch",
">=",
"'",
"'",
"&&",
"ch",
"<=",
"'",
"'",
")",
"{",
"arr",
".",
"write",
"(",
"ch",
")",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
")",
"{",
"arr",
".",
"write",
"(",
"ch",
")",
";",
"return",
"readExp",
"(",
"arr",
",",
"lim",
")",
";",
"}",
"else",
"{",
"if",
"(",
"ch",
"!=",
"-",
"1",
")",
"start",
"--",
";",
"// back up",
"return",
"NUMBER",
";",
"}",
"}",
"return",
"BIGNUMBER",
";",
"}"
] |
read digits right of decimal point
|
[
"read",
"digits",
"right",
"of",
"decimal",
"point"
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L546-L561
|
144,829
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readExp
|
private int readExp(CharArr arr, int lim) throws IOException {
nstate |= HAS_EXPONENT;
int ch = getChar(); lim--;
if (ch=='+' || ch=='-') {
arr.write(ch);
ch = getChar(); lim--;
}
// make sure at least one digit is read.
if (ch<'0' || ch>'9') {
throw err("missing exponent number");
}
arr.write(ch);
return readExpDigits(arr,lim);
}
|
java
|
private int readExp(CharArr arr, int lim) throws IOException {
nstate |= HAS_EXPONENT;
int ch = getChar(); lim--;
if (ch=='+' || ch=='-') {
arr.write(ch);
ch = getChar(); lim--;
}
// make sure at least one digit is read.
if (ch<'0' || ch>'9') {
throw err("missing exponent number");
}
arr.write(ch);
return readExpDigits(arr,lim);
}
|
[
"private",
"int",
"readExp",
"(",
"CharArr",
"arr",
",",
"int",
"lim",
")",
"throws",
"IOException",
"{",
"nstate",
"|=",
"HAS_EXPONENT",
";",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"lim",
"--",
";",
"if",
"(",
"ch",
"==",
"'",
"'",
"||",
"ch",
"==",
"'",
"'",
")",
"{",
"arr",
".",
"write",
"(",
"ch",
")",
";",
"ch",
"=",
"getChar",
"(",
")",
";",
"lim",
"--",
";",
"}",
"// make sure at least one digit is read.",
"if",
"(",
"ch",
"<",
"'",
"'",
"||",
"ch",
">",
"'",
"'",
")",
"{",
"throw",
"err",
"(",
"\"missing exponent number\"",
")",
";",
"}",
"arr",
".",
"write",
"(",
"ch",
")",
";",
"return",
"readExpDigits",
"(",
"arr",
",",
"lim",
")",
";",
"}"
] |
call after 'e' or 'E' has been seen to read the rest of the exponent
|
[
"call",
"after",
"e",
"or",
"E",
"has",
"been",
"seen",
"to",
"read",
"the",
"rest",
"of",
"the",
"exponent"
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L565-L581
|
144,830
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readExpDigits
|
private int readExpDigits(CharArr arr, int lim) throws IOException {
while (--lim>=0) {
int ch = getChar();
if (ch>='0' && ch<='9') {
arr.write(ch);
} else {
if (ch!=-1) start--; // back up
return NUMBER;
}
}
return BIGNUMBER;
}
|
java
|
private int readExpDigits(CharArr arr, int lim) throws IOException {
while (--lim>=0) {
int ch = getChar();
if (ch>='0' && ch<='9') {
arr.write(ch);
} else {
if (ch!=-1) start--; // back up
return NUMBER;
}
}
return BIGNUMBER;
}
|
[
"private",
"int",
"readExpDigits",
"(",
"CharArr",
"arr",
",",
"int",
"lim",
")",
"throws",
"IOException",
"{",
"while",
"(",
"--",
"lim",
">=",
"0",
")",
"{",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"if",
"(",
"ch",
">=",
"'",
"'",
"&&",
"ch",
"<=",
"'",
"'",
")",
"{",
"arr",
".",
"write",
"(",
"ch",
")",
";",
"}",
"else",
"{",
"if",
"(",
"ch",
"!=",
"-",
"1",
")",
"start",
"--",
";",
"// back up",
"return",
"NUMBER",
";",
"}",
"}",
"return",
"BIGNUMBER",
";",
"}"
] |
continuation of readExpStart
|
[
"continuation",
"of",
"readExpStart"
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L584-L595
|
144,831
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readEscapedChar
|
private char readEscapedChar() throws IOException {
int ch = getChar();
switch (ch) {
case '"' : return '"';
case '\'' : return '\'';
case '\\' : return '\\';
case '/' : return '/';
case 'n' : return '\n';
case 'r' : return '\r';
case 't' : return '\t';
case 'f' : return '\f';
case 'b' : return '\b';
case 'u' :
return (char)(
(hexval(getChar()) << 12)
| (hexval(getChar()) << 8)
| (hexval(getChar()) << 4)
| (hexval(getChar())));
}
if ( (flags & ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER) != 0 && ch != EOF) {
return (char)ch;
}
throw err("Invalid character escape");
}
|
java
|
private char readEscapedChar() throws IOException {
int ch = getChar();
switch (ch) {
case '"' : return '"';
case '\'' : return '\'';
case '\\' : return '\\';
case '/' : return '/';
case 'n' : return '\n';
case 'r' : return '\r';
case 't' : return '\t';
case 'f' : return '\f';
case 'b' : return '\b';
case 'u' :
return (char)(
(hexval(getChar()) << 12)
| (hexval(getChar()) << 8)
| (hexval(getChar()) << 4)
| (hexval(getChar())));
}
if ( (flags & ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER) != 0 && ch != EOF) {
return (char)ch;
}
throw err("Invalid character escape");
}
|
[
"private",
"char",
"readEscapedChar",
"(",
")",
"throws",
"IOException",
"{",
"int",
"ch",
"=",
"getChar",
"(",
")",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"'",
"'",
";",
"case",
"'",
"'",
":",
"return",
"(",
"char",
")",
"(",
"(",
"hexval",
"(",
"getChar",
"(",
")",
")",
"<<",
"12",
")",
"|",
"(",
"hexval",
"(",
"getChar",
"(",
")",
")",
"<<",
"8",
")",
"|",
"(",
"hexval",
"(",
"getChar",
"(",
")",
")",
"<<",
"4",
")",
"|",
"(",
"hexval",
"(",
"getChar",
"(",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"(",
"flags",
"&",
"ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER",
")",
"!=",
"0",
"&&",
"ch",
"!=",
"EOF",
")",
"{",
"return",
"(",
"char",
")",
"ch",
";",
"}",
"throw",
"err",
"(",
"\"Invalid character escape\"",
")",
";",
"}"
] |
backslash has already been read when this is called
|
[
"backslash",
"has",
"already",
"been",
"read",
"when",
"this",
"is",
"called"
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L641-L664
|
144,832
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.readStringChars2
|
private void readStringChars2(CharArr arr, int middle) throws IOException {
if (stringTerm == 0) {
readStringBare(arr);
return;
}
char terminator = (char) stringTerm;
for (;;) {
if (middle>=end) {
arr.write(buf,start,middle-start);
start=middle;
getMore();
middle=start;
}
int ch = buf[middle++];
if (ch == terminator) {
int len = middle-start-1;
if (len>0) arr.write(buf,start,len);
start=middle;
return;
} else if (ch=='\\') {
int len = middle-start-1;
if (len>0) arr.write(buf,start,len);
start=middle;
arr.write(readEscapedChar());
middle=start;
}
}
}
|
java
|
private void readStringChars2(CharArr arr, int middle) throws IOException {
if (stringTerm == 0) {
readStringBare(arr);
return;
}
char terminator = (char) stringTerm;
for (;;) {
if (middle>=end) {
arr.write(buf,start,middle-start);
start=middle;
getMore();
middle=start;
}
int ch = buf[middle++];
if (ch == terminator) {
int len = middle-start-1;
if (len>0) arr.write(buf,start,len);
start=middle;
return;
} else if (ch=='\\') {
int len = middle-start-1;
if (len>0) arr.write(buf,start,len);
start=middle;
arr.write(readEscapedChar());
middle=start;
}
}
}
|
[
"private",
"void",
"readStringChars2",
"(",
"CharArr",
"arr",
",",
"int",
"middle",
")",
"throws",
"IOException",
"{",
"if",
"(",
"stringTerm",
"==",
"0",
")",
"{",
"readStringBare",
"(",
"arr",
")",
";",
"return",
";",
"}",
"char",
"terminator",
"=",
"(",
"char",
")",
"stringTerm",
";",
"for",
"(",
";",
";",
")",
"{",
"if",
"(",
"middle",
">=",
"end",
")",
"{",
"arr",
".",
"write",
"(",
"buf",
",",
"start",
",",
"middle",
"-",
"start",
")",
";",
"start",
"=",
"middle",
";",
"getMore",
"(",
")",
";",
"middle",
"=",
"start",
";",
"}",
"int",
"ch",
"=",
"buf",
"[",
"middle",
"++",
"]",
";",
"if",
"(",
"ch",
"==",
"terminator",
")",
"{",
"int",
"len",
"=",
"middle",
"-",
"start",
"-",
"1",
";",
"if",
"(",
"len",
">",
"0",
")",
"arr",
".",
"write",
"(",
"buf",
",",
"start",
",",
"len",
")",
";",
"start",
"=",
"middle",
";",
"return",
";",
"}",
"else",
"if",
"(",
"ch",
"==",
"'",
"'",
")",
"{",
"int",
"len",
"=",
"middle",
"-",
"start",
"-",
"1",
";",
"if",
"(",
"len",
">",
"0",
")",
"arr",
".",
"write",
"(",
"buf",
",",
"start",
",",
"len",
")",
";",
"start",
"=",
"middle",
";",
"arr",
".",
"write",
"(",
"readEscapedChar",
"(",
")",
")",
";",
"middle",
"=",
"start",
";",
"}",
"}",
"}"
] |
this should be faster for strings with fewer escapes, but probably slower for many escapes.
|
[
"this",
"should",
"be",
"faster",
"for",
"strings",
"with",
"fewer",
"escapes",
"but",
"probably",
"slower",
"for",
"many",
"escapes",
"."
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L697-L726
|
144,833
|
yonik/noggit
|
src/main/java/org/noggit/JSONParser.java
|
JSONParser.getNumberChars
|
public void getNumberChars(CharArr output) throws IOException {
int ev=0;
if (valstate==0) ev=nextEvent();
if (valstate == LONG || valstate == NUMBER) output.write(this.out);
else if (valstate==BIGNUMBER) {
continueNumber(output);
} else {
throw err("Unexpected " + ev);
}
valstate=0;
}
|
java
|
public void getNumberChars(CharArr output) throws IOException {
int ev=0;
if (valstate==0) ev=nextEvent();
if (valstate == LONG || valstate == NUMBER) output.write(this.out);
else if (valstate==BIGNUMBER) {
continueNumber(output);
} else {
throw err("Unexpected " + ev);
}
valstate=0;
}
|
[
"public",
"void",
"getNumberChars",
"(",
"CharArr",
"output",
")",
"throws",
"IOException",
"{",
"int",
"ev",
"=",
"0",
";",
"if",
"(",
"valstate",
"==",
"0",
")",
"ev",
"=",
"nextEvent",
"(",
")",
";",
"if",
"(",
"valstate",
"==",
"LONG",
"||",
"valstate",
"==",
"NUMBER",
")",
"output",
".",
"write",
"(",
"this",
".",
"out",
")",
";",
"else",
"if",
"(",
"valstate",
"==",
"BIGNUMBER",
")",
"{",
"continueNumber",
"(",
"output",
")",
";",
"}",
"else",
"{",
"throw",
"err",
"(",
"\"Unexpected \"",
"+",
"ev",
")",
";",
"}",
"valstate",
"=",
"0",
";",
"}"
] |
Reads a JSON numeric value into the output.
|
[
"Reads",
"a",
"JSON",
"numeric",
"value",
"into",
"the",
"output",
"."
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/JSONParser.java#L1200-L1210
|
144,834
|
yonik/noggit
|
src/main/java/org/noggit/CharUtil.java
|
CharUtil.parseLong
|
public long parseLong(char[] arr, int start, int end) {
long x = 0;
boolean negative = arr[start] == '-';
for (int i=negative ? start+1 : start; i<end; i++) {
// If constructing the largest negative number, this will overflow
// to the largest negative number. This is OK since the negation of
// the largest negative number is itself in two's complement.
x = x * 10 + (arr[i] - '0');
}
// could replace conditional-move with multiplication of sign... not sure
// which is faster.
return negative ? -x : x;
}
|
java
|
public long parseLong(char[] arr, int start, int end) {
long x = 0;
boolean negative = arr[start] == '-';
for (int i=negative ? start+1 : start; i<end; i++) {
// If constructing the largest negative number, this will overflow
// to the largest negative number. This is OK since the negation of
// the largest negative number is itself in two's complement.
x = x * 10 + (arr[i] - '0');
}
// could replace conditional-move with multiplication of sign... not sure
// which is faster.
return negative ? -x : x;
}
|
[
"public",
"long",
"parseLong",
"(",
"char",
"[",
"]",
"arr",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"long",
"x",
"=",
"0",
";",
"boolean",
"negative",
"=",
"arr",
"[",
"start",
"]",
"==",
"'",
"'",
";",
"for",
"(",
"int",
"i",
"=",
"negative",
"?",
"start",
"+",
"1",
":",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"// If constructing the largest negative number, this will overflow",
"// to the largest negative number. This is OK since the negation of",
"// the largest negative number is itself in two's complement.",
"x",
"=",
"x",
"*",
"10",
"+",
"(",
"arr",
"[",
"i",
"]",
"-",
"'",
"'",
")",
";",
"}",
"// could replace conditional-move with multiplication of sign... not sure",
"// which is faster.",
"return",
"negative",
"?",
"-",
"x",
":",
"x",
";",
"}"
] |
belongs in number utils or charutil?
|
[
"belongs",
"in",
"number",
"utils",
"or",
"charutil?"
] |
8febcdc7f88126bde8a1909519b4644655f78106
|
https://github.com/yonik/noggit/blob/8febcdc7f88126bde8a1909519b4644655f78106/src/main/java/org/noggit/CharUtil.java#L27-L39
|
144,835
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/net/MultiPooledSocketFactory.java
|
MultiPooledSocketFactory.createSocketFactory
|
protected SocketFactory createSocketFactory(InetAddress address,
int port,
InetAddress localAddr,
int localPort,
long timeout)
{
SocketFactory factory;
factory = new PlainSocketFactory
(address, port, localAddr, localPort, timeout);
factory = new PooledSocketFactory(factory);
factory = new LazySocketFactory(factory);
return factory;
}
|
java
|
protected SocketFactory createSocketFactory(InetAddress address,
int port,
InetAddress localAddr,
int localPort,
long timeout)
{
SocketFactory factory;
factory = new PlainSocketFactory
(address, port, localAddr, localPort, timeout);
factory = new PooledSocketFactory(factory);
factory = new LazySocketFactory(factory);
return factory;
}
|
[
"protected",
"SocketFactory",
"createSocketFactory",
"(",
"InetAddress",
"address",
",",
"int",
"port",
",",
"InetAddress",
"localAddr",
",",
"int",
"localPort",
",",
"long",
"timeout",
")",
"{",
"SocketFactory",
"factory",
";",
"factory",
"=",
"new",
"PlainSocketFactory",
"(",
"address",
",",
"port",
",",
"localAddr",
",",
"localPort",
",",
"timeout",
")",
";",
"factory",
"=",
"new",
"PooledSocketFactory",
"(",
"factory",
")",
";",
"factory",
"=",
"new",
"LazySocketFactory",
"(",
"factory",
")",
";",
"return",
"factory",
";",
"}"
] |
Create socket factories for newly resolved addresses. Default
implementation returns a LazySocketFactory wrapping a
PooledSocketFactory wrapping a PlainSocketFactory.
|
[
"Create",
"socket",
"factories",
"for",
"newly",
"resolved",
"addresses",
".",
"Default",
"implementation",
"returns",
"a",
"LazySocketFactory",
"wrapping",
"a",
"PooledSocketFactory",
"wrapping",
"a",
"PlainSocketFactory",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/MultiPooledSocketFactory.java#L137-L149
|
144,836
|
teatrove/teatrove
|
teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java
|
EncodingContext.encodeIntArray
|
public String encodeIntArray(int[] input) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
int length = input.length;
dos.writeInt(length);
for (int i=0; i < length; i++) {
dos.writeInt(input[i]);
}
return new String(Base64.encodeBase64URLSafe(bos.toByteArray()));
}
|
java
|
public String encodeIntArray(int[] input) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
int length = input.length;
dos.writeInt(length);
for (int i=0; i < length; i++) {
dos.writeInt(input[i]);
}
return new String(Base64.encodeBase64URLSafe(bos.toByteArray()));
}
|
[
"public",
"String",
"encodeIntArray",
"(",
"int",
"[",
"]",
"input",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"DataOutputStream",
"dos",
"=",
"new",
"DataOutputStream",
"(",
"bos",
")",
";",
"int",
"length",
"=",
"input",
".",
"length",
";",
"dos",
".",
"writeInt",
"(",
"length",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"dos",
".",
"writeInt",
"(",
"input",
"[",
"i",
"]",
")",
";",
"}",
"return",
"new",
"String",
"(",
"Base64",
".",
"encodeBase64URLSafe",
"(",
"bos",
".",
"toByteArray",
"(",
")",
")",
")",
";",
"}"
] |
Encode the given integer array into Base64 format.
@param input The array of integers to encode
@return The Base64 encoded data
@throws IOException if an error occurs encoding the array stream
@see #decodeIntArray(String)
|
[
"Encode",
"the",
"given",
"integer",
"array",
"into",
"Base64",
"format",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java#L82-L92
|
144,837
|
teatrove/teatrove
|
teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java
|
EncodingContext.decodeIntArray
|
public int[] decodeIntArray(String input) throws IOException {
int[] result = null;
ByteArrayInputStream bis =
new ByteArrayInputStream(Base64.decodeBase64(input));
DataInputStream dis = new DataInputStream(bis);
int length = dis.readInt();
result = new int[length];
for (int i=0; i < length; i++) {
result[i] = dis.readInt();
}
return result;
}
|
java
|
public int[] decodeIntArray(String input) throws IOException {
int[] result = null;
ByteArrayInputStream bis =
new ByteArrayInputStream(Base64.decodeBase64(input));
DataInputStream dis = new DataInputStream(bis);
int length = dis.readInt();
result = new int[length];
for (int i=0; i < length; i++) {
result[i] = dis.readInt();
}
return result;
}
|
[
"public",
"int",
"[",
"]",
"decodeIntArray",
"(",
"String",
"input",
")",
"throws",
"IOException",
"{",
"int",
"[",
"]",
"result",
"=",
"null",
";",
"ByteArrayInputStream",
"bis",
"=",
"new",
"ByteArrayInputStream",
"(",
"Base64",
".",
"decodeBase64",
"(",
"input",
")",
")",
";",
"DataInputStream",
"dis",
"=",
"new",
"DataInputStream",
"(",
"bis",
")",
";",
"int",
"length",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"result",
"=",
"new",
"int",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"dis",
".",
"readInt",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Decode the given Base64 encoded value into an integer array.
@param input The Base64 encoded value to decode
@return The array of decoded integers
@throws IOException if an error occurs decoding the array stream
@see #encodeIntArray(int[])
|
[
"Decode",
"the",
"given",
"Base64",
"encoded",
"value",
"into",
"an",
"integer",
"array",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java#L105-L116
|
144,838
|
teatrove/teatrove
|
teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java
|
EncodingContext.decodeHexToString
|
public String decodeHexToString(String str) throws DecoderException {
String result = null;
byte[] bytes = Hex.decodeHex(str.toCharArray());
if (bytes != null && bytes.length > 0) {
result = new String(bytes);
}
return result;
}
|
java
|
public String decodeHexToString(String str) throws DecoderException {
String result = null;
byte[] bytes = Hex.decodeHex(str.toCharArray());
if (bytes != null && bytes.length > 0) {
result = new String(bytes);
}
return result;
}
|
[
"public",
"String",
"decodeHexToString",
"(",
"String",
"str",
")",
"throws",
"DecoderException",
"{",
"String",
"result",
"=",
"null",
";",
"byte",
"[",
"]",
"bytes",
"=",
"Hex",
".",
"decodeHex",
"(",
"str",
".",
"toCharArray",
"(",
")",
")",
";",
"if",
"(",
"bytes",
"!=",
"null",
"&&",
"bytes",
".",
"length",
">",
"0",
")",
"{",
"result",
"=",
"new",
"String",
"(",
"bytes",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Decode the given hexidecimal formatted value into a string representing
the bytes of the decoded value.
@param str The hexidecimal formatted value
@return The string representing the decoded bytes
@throws DecoderException if an error occurs during decoding
@see #decodeHex(String)
|
[
"Decode",
"the",
"given",
"hexidecimal",
"formatted",
"value",
"into",
"a",
"string",
"representing",
"the",
"bytes",
"of",
"the",
"decoded",
"value",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/EncodingContext.java#L299-L306
|
144,839
|
teatrove/teatrove
|
teaservlet/src/main/java/org/teatrove/teatools/FeatureDescription.java
|
FeatureDescription.getName
|
public String getName() {
FeatureDescriptor fd = getFeatureDescriptor();
if (fd == null) {
return null;
}
return fd.getName();
}
|
java
|
public String getName() {
FeatureDescriptor fd = getFeatureDescriptor();
if (fd == null) {
return null;
}
return fd.getName();
}
|
[
"public",
"String",
"getName",
"(",
")",
"{",
"FeatureDescriptor",
"fd",
"=",
"getFeatureDescriptor",
"(",
")",
";",
"if",
"(",
"fd",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"fd",
".",
"getName",
"(",
")",
";",
"}"
] |
Returns the feature name
|
[
"Returns",
"the",
"feature",
"name"
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/FeatureDescription.java#L40-L47
|
144,840
|
teatrove/teatrove
|
teaservlet/src/main/java/org/teatrove/teatools/FeatureDescription.java
|
FeatureDescription.getDescription
|
public String getDescription() {
FeatureDescriptor fd = getFeatureDescriptor();
if (fd == null) {
return "";
}
return getTeaToolsUtils().getDescription(fd);
}
|
java
|
public String getDescription() {
FeatureDescriptor fd = getFeatureDescriptor();
if (fd == null) {
return "";
}
return getTeaToolsUtils().getDescription(fd);
}
|
[
"public",
"String",
"getDescription",
"(",
")",
"{",
"FeatureDescriptor",
"fd",
"=",
"getFeatureDescriptor",
"(",
")",
";",
"if",
"(",
"fd",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"getTeaToolsUtils",
"(",
")",
".",
"getDescription",
"(",
"fd",
")",
";",
"}"
] |
Returns the shortDescription or "" if the
shortDescription is the same as the displayName.
|
[
"Returns",
"the",
"shortDescription",
"or",
"if",
"the",
"shortDescription",
"is",
"the",
"same",
"as",
"the",
"displayName",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teatools/FeatureDescription.java#L53-L60
|
144,841
|
teatrove/teatrove
|
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java
|
ClassDoc.getQualifiedTypeNameForFile
|
public String getQualifiedTypeNameForFile() {
String typeName = getTypeNameForFile();
String qualifiedTypeName = mDoc.qualifiedTypeName();
int packageLength = qualifiedTypeName.length() - typeName.length();
if (packageLength <= 0) {
return typeName;
}
String packagePath = qualifiedTypeName.substring(0, packageLength);
return packagePath + typeName;
}
|
java
|
public String getQualifiedTypeNameForFile() {
String typeName = getTypeNameForFile();
String qualifiedTypeName = mDoc.qualifiedTypeName();
int packageLength = qualifiedTypeName.length() - typeName.length();
if (packageLength <= 0) {
return typeName;
}
String packagePath = qualifiedTypeName.substring(0, packageLength);
return packagePath + typeName;
}
|
[
"public",
"String",
"getQualifiedTypeNameForFile",
"(",
")",
"{",
"String",
"typeName",
"=",
"getTypeNameForFile",
"(",
")",
";",
"String",
"qualifiedTypeName",
"=",
"mDoc",
".",
"qualifiedTypeName",
"(",
")",
";",
"int",
"packageLength",
"=",
"qualifiedTypeName",
".",
"length",
"(",
")",
"-",
"typeName",
".",
"length",
"(",
")",
";",
"if",
"(",
"packageLength",
"<=",
"0",
")",
"{",
"return",
"typeName",
";",
"}",
"String",
"packagePath",
"=",
"qualifiedTypeName",
".",
"substring",
"(",
"0",
",",
"packageLength",
")",
";",
"return",
"packagePath",
"+",
"typeName",
";",
"}"
] |
Converts inner class names.
|
[
"Converts",
"inner",
"class",
"names",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java#L201-L214
|
144,842
|
teatrove/teatrove
|
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java
|
ClassDoc.getMatchingMethod
|
public MethodDoc getMatchingMethod(MethodDoc method) {
MethodDoc[] methods = getMethods();
for (int i = 0; i < methods.length; i++) {
if (method.getName().equals(methods[i].getName()) &&
method.getSignature().equals(methods[i].getSignature())) {
return methods[i];
}
}
return null;
}
|
java
|
public MethodDoc getMatchingMethod(MethodDoc method) {
MethodDoc[] methods = getMethods();
for (int i = 0; i < methods.length; i++) {
if (method.getName().equals(methods[i].getName()) &&
method.getSignature().equals(methods[i].getSignature())) {
return methods[i];
}
}
return null;
}
|
[
"public",
"MethodDoc",
"getMatchingMethod",
"(",
"MethodDoc",
"method",
")",
"{",
"MethodDoc",
"[",
"]",
"methods",
"=",
"getMethods",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"methods",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
"&&",
"method",
".",
"getSignature",
"(",
")",
".",
"equals",
"(",
"methods",
"[",
"i",
"]",
".",
"getSignature",
"(",
")",
")",
")",
"{",
"return",
"methods",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get a MethodDoc in this ClassDoc with a name and signature
matching that of the specified MethodDoc
|
[
"Get",
"a",
"MethodDoc",
"in",
"this",
"ClassDoc",
"with",
"a",
"name",
"and",
"signature",
"matching",
"that",
"of",
"the",
"specified",
"MethodDoc"
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java#L239-L251
|
144,843
|
teatrove/teatrove
|
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java
|
ClassDoc.getMatchingMethod
|
public MethodDoc getMatchingMethod(MethodDoc method, MethodFinder mf) {
MethodDoc md = getMatchingMethod(method);
if (md != null) {
if (mf.checkMethod(md)) {
return md;
}
}
return null;
}
|
java
|
public MethodDoc getMatchingMethod(MethodDoc method, MethodFinder mf) {
MethodDoc md = getMatchingMethod(method);
if (md != null) {
if (mf.checkMethod(md)) {
return md;
}
}
return null;
}
|
[
"public",
"MethodDoc",
"getMatchingMethod",
"(",
"MethodDoc",
"method",
",",
"MethodFinder",
"mf",
")",
"{",
"MethodDoc",
"md",
"=",
"getMatchingMethod",
"(",
"method",
")",
";",
"if",
"(",
"md",
"!=",
"null",
")",
"{",
"if",
"(",
"mf",
".",
"checkMethod",
"(",
"md",
")",
")",
"{",
"return",
"md",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get a MethodDoc in this ClassDoc with a name and signature
matching that of the specified MethodDoc and accepted by the
specified MethodFinder
|
[
"Get",
"a",
"MethodDoc",
"in",
"this",
"ClassDoc",
"with",
"a",
"name",
"and",
"signature",
"matching",
"that",
"of",
"the",
"specified",
"MethodDoc",
"and",
"accepted",
"by",
"the",
"specified",
"MethodFinder"
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java#L258-L268
|
144,844
|
teatrove/teatrove
|
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java
|
ClassDoc.findMatchingMethod
|
public MethodDoc findMatchingMethod(MethodDoc method, MethodFinder mf) {
// Look in this class's interface set
MethodDoc md = findMatchingInterfaceMethod(method, mf);
if (md != null) {
return md;
}
// Look in this class's superclass ancestry
ClassDoc superClass = getSuperclass();
if (superClass != null) {
md = superClass.getMatchingMethod(method, mf);
if (md != null) {
return md;
}
return superClass.findMatchingMethod(method, mf);
}
return null;
}
|
java
|
public MethodDoc findMatchingMethod(MethodDoc method, MethodFinder mf) {
// Look in this class's interface set
MethodDoc md = findMatchingInterfaceMethod(method, mf);
if (md != null) {
return md;
}
// Look in this class's superclass ancestry
ClassDoc superClass = getSuperclass();
if (superClass != null) {
md = superClass.getMatchingMethod(method, mf);
if (md != null) {
return md;
}
return superClass.findMatchingMethod(method, mf);
}
return null;
}
|
[
"public",
"MethodDoc",
"findMatchingMethod",
"(",
"MethodDoc",
"method",
",",
"MethodFinder",
"mf",
")",
"{",
"// Look in this class's interface set",
"MethodDoc",
"md",
"=",
"findMatchingInterfaceMethod",
"(",
"method",
",",
"mf",
")",
";",
"if",
"(",
"md",
"!=",
"null",
")",
"{",
"return",
"md",
";",
"}",
"// Look in this class's superclass ancestry",
"ClassDoc",
"superClass",
"=",
"getSuperclass",
"(",
")",
";",
"if",
"(",
"superClass",
"!=",
"null",
")",
"{",
"md",
"=",
"superClass",
".",
"getMatchingMethod",
"(",
"method",
",",
"mf",
")",
";",
"if",
"(",
"md",
"!=",
"null",
")",
"{",
"return",
"md",
";",
"}",
"return",
"superClass",
".",
"findMatchingMethod",
"(",
"method",
",",
"mf",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Find a MethodDoc with a name and signature
matching that of the specified MethodDoc and accepted by the
specified MethodFinder. This method searches the interfaces and
super class ancestry of the class represented by this ClassDoc for
a matching method.
|
[
"Find",
"a",
"MethodDoc",
"with",
"a",
"name",
"and",
"signature",
"matching",
"that",
"of",
"the",
"specified",
"MethodDoc",
"and",
"accepted",
"by",
"the",
"specified",
"MethodFinder",
".",
"This",
"method",
"searches",
"the",
"interfaces",
"and",
"super",
"class",
"ancestry",
"of",
"the",
"class",
"represented",
"by",
"this",
"ClassDoc",
"for",
"a",
"matching",
"method",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/ClassDoc.java#L277-L299
|
144,845
|
teatrove/teatrove
|
build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/Doc.java
|
Doc.getTagValue
|
public String getTagValue(String tagName) {
Tag[] tags = getTagMap().get(tagName);
if (tags == null || tags.length == 0) {
return null;
}
return tags[tags.length - 1].getText();
}
|
java
|
public String getTagValue(String tagName) {
Tag[] tags = getTagMap().get(tagName);
if (tags == null || tags.length == 0) {
return null;
}
return tags[tags.length - 1].getText();
}
|
[
"public",
"String",
"getTagValue",
"(",
"String",
"tagName",
")",
"{",
"Tag",
"[",
"]",
"tags",
"=",
"getTagMap",
"(",
")",
".",
"get",
"(",
"tagName",
")",
";",
"if",
"(",
"tags",
"==",
"null",
"||",
"tags",
".",
"length",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"return",
"tags",
"[",
"tags",
".",
"length",
"-",
"1",
"]",
".",
"getText",
"(",
")",
";",
"}"
] |
Gets the text value of the first tag in doc that matches tagName
|
[
"Gets",
"the",
"text",
"value",
"of",
"the",
"first",
"tag",
"in",
"doc",
"that",
"matches",
"tagName"
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/toolbox/src/main/java/org/teatrove/toolbox/beandoc/teadoc/Doc.java#L79-L87
|
144,846
|
teatrove/teatrove
|
tea/src/main/java/org/teatrove/tea/util/BeanAnalyzer.java
|
BeanAnalyzer.getAllProperties
|
public static Map<String, PropertyDescriptor>
getAllProperties(GenericType root)
throws IntrospectionException {
Map<String, PropertyDescriptor> properties =
cPropertiesCache.get(root);
if (properties == null) {
GenericType rootType = root.getRootType();
if (rootType == null) {
rootType = root;
}
properties = Collections.unmodifiableMap
(
createProperties(rootType, root)
);
cPropertiesCache.put(root, properties);
}
return properties;
}
|
java
|
public static Map<String, PropertyDescriptor>
getAllProperties(GenericType root)
throws IntrospectionException {
Map<String, PropertyDescriptor> properties =
cPropertiesCache.get(root);
if (properties == null) {
GenericType rootType = root.getRootType();
if (rootType == null) {
rootType = root;
}
properties = Collections.unmodifiableMap
(
createProperties(rootType, root)
);
cPropertiesCache.put(root, properties);
}
return properties;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"PropertyDescriptor",
">",
"getAllProperties",
"(",
"GenericType",
"root",
")",
"throws",
"IntrospectionException",
"{",
"Map",
"<",
"String",
",",
"PropertyDescriptor",
">",
"properties",
"=",
"cPropertiesCache",
".",
"get",
"(",
"root",
")",
";",
"if",
"(",
"properties",
"==",
"null",
")",
"{",
"GenericType",
"rootType",
"=",
"root",
".",
"getRootType",
"(",
")",
";",
"if",
"(",
"rootType",
"==",
"null",
")",
"{",
"rootType",
"=",
"root",
";",
"}",
"properties",
"=",
"Collections",
".",
"unmodifiableMap",
"(",
"createProperties",
"(",
"rootType",
",",
"root",
")",
")",
";",
"cPropertiesCache",
".",
"put",
"(",
"root",
",",
"properties",
")",
";",
"}",
"return",
"properties",
";",
"}"
] |
A function that returns a Map of all the available properties on
a given class including write-only properties. The properties returned
is mostly a superset of those returned from the standard JavaBeans
Introspector except pure indexed properties are discarded.
<p>Interfaces receive all the properties available in Object. Arrays,
Strings and Collections all receive a "length" property. An array's
"length" PropertyDescriptor has no read or write methods.
<p>Instead of indexed properties, there may be keyed properties in the
map, represented by a {@link KeyedPropertyDescriptor}. Arrays, Strings
and Lists always have keyed properties with a key type of int.
<p>Because the value returned from a keyed property method may be more
specific than the method signature describes (such is often the case
with collections), a bean class can contain a special field that
indicates what that specific type should be. The signature of this field
is as follows:
<tt>public static final Class ELEMENT_TYPE = <type>.class;</tt>.
@return an unmodifiable mapping of property names (Strings) to
PropertyDescriptor objects.
|
[
"A",
"function",
"that",
"returns",
"a",
"Map",
"of",
"all",
"the",
"available",
"properties",
"on",
"a",
"given",
"class",
"including",
"write",
"-",
"only",
"properties",
".",
"The",
"properties",
"returned",
"is",
"mostly",
"a",
"superset",
"of",
"those",
"returned",
"from",
"the",
"standard",
"JavaBeans",
"Introspector",
"except",
"pure",
"indexed",
"properties",
"are",
"discarded",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/util/BeanAnalyzer.java#L98-L117
|
144,847
|
teatrove/teatrove
|
build-tools/teatools/src/main/java/org/teatrove/teatools/TeaCompiler.java
|
TeaCompiler.findTemplateName
|
public static String findTemplateName(org.teatrove.tea.compiler.Scanner scanner) {
// System.out.println("<-- findTemplateName -->");
Token token;
String name = null;
try {
while (((token = scanner.readToken()).getID()) != Token.EOF) {
/*
System.out.println("Token [Code: " +
token.getCode() + "] [Image: " +
token.getImage() + "] [Value: " +
token.getStringValue() + "] [Id: " +
token.getID() + "]");
*/
if (token.getID() == Token.TEMPLATE) {
token = scanner.readToken();
if (token.getID() == Token.IDENT) {
name = token.getStringValue();
}
break;
}
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
return name;
}
|
java
|
public static String findTemplateName(org.teatrove.tea.compiler.Scanner scanner) {
// System.out.println("<-- findTemplateName -->");
Token token;
String name = null;
try {
while (((token = scanner.readToken()).getID()) != Token.EOF) {
/*
System.out.println("Token [Code: " +
token.getCode() + "] [Image: " +
token.getImage() + "] [Value: " +
token.getStringValue() + "] [Id: " +
token.getID() + "]");
*/
if (token.getID() == Token.TEMPLATE) {
token = scanner.readToken();
if (token.getID() == Token.IDENT) {
name = token.getStringValue();
}
break;
}
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
return name;
}
|
[
"public",
"static",
"String",
"findTemplateName",
"(",
"org",
".",
"teatrove",
".",
"tea",
".",
"compiler",
".",
"Scanner",
"scanner",
")",
"{",
"// System.out.println(\"<-- findTemplateName -->\");",
"Token",
"token",
";",
"String",
"name",
"=",
"null",
";",
"try",
"{",
"while",
"(",
"(",
"(",
"token",
"=",
"scanner",
".",
"readToken",
"(",
")",
")",
".",
"getID",
"(",
")",
")",
"!=",
"Token",
".",
"EOF",
")",
"{",
"/*\n System.out.println(\"Token [Code: \" +\n token.getCode() + \"] [Image: \" +\n token.getImage() + \"] [Value: \" +\n token.getStringValue() + \"] [Id: \" +\n token.getID() + \"]\");\n */",
"if",
"(",
"token",
".",
"getID",
"(",
")",
"==",
"Token",
".",
"TEMPLATE",
")",
"{",
"token",
"=",
"scanner",
".",
"readToken",
"(",
")",
";",
"if",
"(",
"token",
".",
"getID",
"(",
")",
"==",
"Token",
".",
"IDENT",
")",
"{",
"name",
"=",
"token",
".",
"getStringValue",
"(",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"ioe",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Finds the name of the template using the specified tea scanner.
@param scanner the Tea scanner.
@return the name of the template
|
[
"Finds",
"the",
"name",
"of",
"the",
"template",
"using",
"the",
"specified",
"tea",
"scanner",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/TeaCompiler.java#L51-L78
|
144,848
|
teatrove/teatrove
|
build-tools/teatools/src/main/java/org/teatrove/teatools/TeaCompiler.java
|
TeaCompiler.parseTeaTemplate
|
public Template parseTeaTemplate(String templateName) throws IOException {
if (templateName == null) {
return null;
}
preserveParseTree(templateName);
compile(templateName);
CompilationUnit unit = getCompilationUnit(templateName, null);
if (unit == null) {
return null;
}
return unit.getParseTree();
}
|
java
|
public Template parseTeaTemplate(String templateName) throws IOException {
if (templateName == null) {
return null;
}
preserveParseTree(templateName);
compile(templateName);
CompilationUnit unit = getCompilationUnit(templateName, null);
if (unit == null) {
return null;
}
return unit.getParseTree();
}
|
[
"public",
"Template",
"parseTeaTemplate",
"(",
"String",
"templateName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"templateName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"preserveParseTree",
"(",
"templateName",
")",
";",
"compile",
"(",
"templateName",
")",
";",
"CompilationUnit",
"unit",
"=",
"getCompilationUnit",
"(",
"templateName",
",",
"null",
")",
";",
"if",
"(",
"unit",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"unit",
".",
"getParseTree",
"(",
")",
";",
"}"
] |
Perform Tea "parsing." This method will compile the named template.
@param templateName the name of the template to parse
@return a Template object that represents the root node of the Tea
parse tree.
|
[
"Perform",
"Tea",
"parsing",
".",
"This",
"method",
"will",
"compile",
"the",
"named",
"template",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/build-tools/teatools/src/main/java/org/teatrove/teatools/TeaCompiler.java#L225-L239
|
144,849
|
teatrove/teatrove
|
tea/src/main/java/org/teatrove/tea/parsetree/NumberLiteral.java
|
NumberLiteral.isValueKnown
|
public boolean isValueKnown() {
Type type = getType();
if (type != null) {
Class<?> clazz = type.getObjectClass();
return Number.class.isAssignableFrom(clazz) ||
clazz.isAssignableFrom(Number.class);
}
else {
return false;
}
}
|
java
|
public boolean isValueKnown() {
Type type = getType();
if (type != null) {
Class<?> clazz = type.getObjectClass();
return Number.class.isAssignableFrom(clazz) ||
clazz.isAssignableFrom(Number.class);
}
else {
return false;
}
}
|
[
"public",
"boolean",
"isValueKnown",
"(",
")",
"{",
"Type",
"type",
"=",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"type",
".",
"getObjectClass",
"(",
")",
";",
"return",
"Number",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
"||",
"clazz",
".",
"isAssignableFrom",
"(",
"Number",
".",
"class",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Value is known only if type is a number or can be assigned a number.
|
[
"Value",
"is",
"known",
"only",
"if",
"type",
"is",
"a",
"number",
"or",
"can",
"be",
"assigned",
"a",
"number",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/tea/src/main/java/org/teatrove/tea/parsetree/NumberLiteral.java#L96-L106
|
144,850
|
teatrove/teatrove
|
teaapps/src/main/java/org/teatrove/teaapps/contexts/ArrayContext.java
|
ArrayContext.cloneArray
|
public Object[] cloneArray(Object[] array) {
Class<?> clazz = array.getClass().getComponentType();
Object newArray = Array.newInstance(clazz, array.length);
System.arraycopy(array, 0, newArray, 0, array.length);
return (Object[]) newArray;
}
|
java
|
public Object[] cloneArray(Object[] array) {
Class<?> clazz = array.getClass().getComponentType();
Object newArray = Array.newInstance(clazz, array.length);
System.arraycopy(array, 0, newArray, 0, array.length);
return (Object[]) newArray;
}
|
[
"public",
"Object",
"[",
"]",
"cloneArray",
"(",
"Object",
"[",
"]",
"array",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"array",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
";",
"Object",
"newArray",
"=",
"Array",
".",
"newInstance",
"(",
"clazz",
",",
"array",
".",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"0",
",",
"newArray",
",",
"0",
",",
"array",
".",
"length",
")",
";",
"return",
"(",
"Object",
"[",
"]",
")",
"newArray",
";",
"}"
] |
Clone the given array into a new instance of the same type and
dimensions. The values are directly copied by memory, so this is not
a deep clone operation. However, manipulation of the contents of the
array will not impact the given array.
@param array The array to clone
@return The new cloned array
|
[
"Clone",
"the",
"given",
"array",
"into",
"a",
"new",
"instance",
"of",
"the",
"same",
"type",
"and",
"dimensions",
".",
"The",
"values",
"are",
"directly",
"copied",
"by",
"memory",
"so",
"this",
"is",
"not",
"a",
"deep",
"clone",
"operation",
".",
"However",
"manipulation",
"of",
"the",
"contents",
"of",
"the",
"array",
"will",
"not",
"impact",
"the",
"given",
"array",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaapps/src/main/java/org/teatrove/teaapps/contexts/ArrayContext.java#L38-L43
|
144,851
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/net/HttpClient.java
|
HttpClient.setHeader
|
public HttpClient setHeader(String name, Object value) {
if (mHeaders == null) {
mHeaders = new HttpHeaderMap();
}
mHeaders.put(name, value);
return this;
}
|
java
|
public HttpClient setHeader(String name, Object value) {
if (mHeaders == null) {
mHeaders = new HttpHeaderMap();
}
mHeaders.put(name, value);
return this;
}
|
[
"public",
"HttpClient",
"setHeader",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"mHeaders",
"==",
"null",
")",
"{",
"mHeaders",
"=",
"new",
"HttpHeaderMap",
"(",
")",
";",
"}",
"mHeaders",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Set a header name-value pair to the request.
@return 'this', so that addtional calls may be chained together
|
[
"Set",
"a",
"header",
"name",
"-",
"value",
"pair",
"to",
"the",
"request",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/HttpClient.java#L116-L122
|
144,852
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/net/HttpClient.java
|
HttpClient.addHeader
|
public HttpClient addHeader(String name, Object value) {
if (mHeaders == null) {
mHeaders = new HttpHeaderMap();
}
mHeaders.add(name, value);
return this;
}
|
java
|
public HttpClient addHeader(String name, Object value) {
if (mHeaders == null) {
mHeaders = new HttpHeaderMap();
}
mHeaders.add(name, value);
return this;
}
|
[
"public",
"HttpClient",
"addHeader",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"mHeaders",
"==",
"null",
")",
"{",
"mHeaders",
"=",
"new",
"HttpHeaderMap",
"(",
")",
";",
"}",
"mHeaders",
".",
"add",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Add a header name-value pair to the request in order for multiple values
to be specified.
@return 'this', so that addtional calls may be chained together
|
[
"Add",
"a",
"header",
"name",
"-",
"value",
"pair",
"to",
"the",
"request",
"in",
"order",
"for",
"multiple",
"values",
"to",
"be",
"specified",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/HttpClient.java#L130-L136
|
144,853
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/net/HttpClient.java
|
HttpClient.getResponse
|
public Response getResponse(PostData postData)
throws ConnectException, SocketException
{
CheckedSocket socket = mFactory.getSocket(mSession);
try {
CharToByteBuffer request = new FastCharToByteBuffer
(new DefaultByteBuffer(), "8859_1");
request = new InternedCharToByteBuffer(request);
request.append(mMethod);
request.append(' ');
request.append(mURI);
request.append(' ');
request.append(mProtocol);
request.append("\r\n");
if (mHeaders != null) {
mHeaders.appendTo(request);
}
request.append("\r\n");
Response response;
try {
response = sendRequest(socket, request, postData);
}
catch (InterruptedIOException e) {
// If timed out, throw exception rather than risk double
// posting.
throw e;
}
catch (IOException e) {
response = null;
}
if (response == null) {
// Try again with new connection. Persistent connection may
// have timed out and been closed by server.
try {
socket.close();
}
catch (IOException e) {
}
socket = mFactory.createSocket(mSession);
response = sendRequest(socket, request, postData);
if (response == null) {
throw new ConnectException("No response from server " + socket.getInetAddress() + ":" +
socket.getPort());
}
}
return response;
}
catch (SocketException e) {
throw e;
}
catch (InterruptedIOException e) {
throw new ConnectException("Read timeout expired: " +
mReadTimeout + ", " + e);
}
catch (IOException e) {
throw new SocketException(e.toString());
}
}
|
java
|
public Response getResponse(PostData postData)
throws ConnectException, SocketException
{
CheckedSocket socket = mFactory.getSocket(mSession);
try {
CharToByteBuffer request = new FastCharToByteBuffer
(new DefaultByteBuffer(), "8859_1");
request = new InternedCharToByteBuffer(request);
request.append(mMethod);
request.append(' ');
request.append(mURI);
request.append(' ');
request.append(mProtocol);
request.append("\r\n");
if (mHeaders != null) {
mHeaders.appendTo(request);
}
request.append("\r\n");
Response response;
try {
response = sendRequest(socket, request, postData);
}
catch (InterruptedIOException e) {
// If timed out, throw exception rather than risk double
// posting.
throw e;
}
catch (IOException e) {
response = null;
}
if (response == null) {
// Try again with new connection. Persistent connection may
// have timed out and been closed by server.
try {
socket.close();
}
catch (IOException e) {
}
socket = mFactory.createSocket(mSession);
response = sendRequest(socket, request, postData);
if (response == null) {
throw new ConnectException("No response from server " + socket.getInetAddress() + ":" +
socket.getPort());
}
}
return response;
}
catch (SocketException e) {
throw e;
}
catch (InterruptedIOException e) {
throw new ConnectException("Read timeout expired: " +
mReadTimeout + ", " + e);
}
catch (IOException e) {
throw new SocketException(e.toString());
}
}
|
[
"public",
"Response",
"getResponse",
"(",
"PostData",
"postData",
")",
"throws",
"ConnectException",
",",
"SocketException",
"{",
"CheckedSocket",
"socket",
"=",
"mFactory",
".",
"getSocket",
"(",
"mSession",
")",
";",
"try",
"{",
"CharToByteBuffer",
"request",
"=",
"new",
"FastCharToByteBuffer",
"(",
"new",
"DefaultByteBuffer",
"(",
")",
",",
"\"8859_1\"",
")",
";",
"request",
"=",
"new",
"InternedCharToByteBuffer",
"(",
"request",
")",
";",
"request",
".",
"append",
"(",
"mMethod",
")",
";",
"request",
".",
"append",
"(",
"'",
"'",
")",
";",
"request",
".",
"append",
"(",
"mURI",
")",
";",
"request",
".",
"append",
"(",
"'",
"'",
")",
";",
"request",
".",
"append",
"(",
"mProtocol",
")",
";",
"request",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"if",
"(",
"mHeaders",
"!=",
"null",
")",
"{",
"mHeaders",
".",
"appendTo",
"(",
"request",
")",
";",
"}",
"request",
".",
"append",
"(",
"\"\\r\\n\"",
")",
";",
"Response",
"response",
";",
"try",
"{",
"response",
"=",
"sendRequest",
"(",
"socket",
",",
"request",
",",
"postData",
")",
";",
"}",
"catch",
"(",
"InterruptedIOException",
"e",
")",
"{",
"// If timed out, throw exception rather than risk double",
"// posting.",
"throw",
"e",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"response",
"=",
"null",
";",
"}",
"if",
"(",
"response",
"==",
"null",
")",
"{",
"// Try again with new connection. Persistent connection may",
"// have timed out and been closed by server.",
"try",
"{",
"socket",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"}",
"socket",
"=",
"mFactory",
".",
"createSocket",
"(",
"mSession",
")",
";",
"response",
"=",
"sendRequest",
"(",
"socket",
",",
"request",
",",
"postData",
")",
";",
"if",
"(",
"response",
"==",
"null",
")",
"{",
"throw",
"new",
"ConnectException",
"(",
"\"No response from server \"",
"+",
"socket",
".",
"getInetAddress",
"(",
")",
"+",
"\":\"",
"+",
"socket",
".",
"getPort",
"(",
")",
")",
";",
"}",
"}",
"return",
"response",
";",
"}",
"catch",
"(",
"SocketException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"InterruptedIOException",
"e",
")",
"{",
"throw",
"new",
"ConnectException",
"(",
"\"Read timeout expired: \"",
"+",
"mReadTimeout",
"+",
"\", \"",
"+",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SocketException",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Opens a connection, passes on the current request settings, and returns
the server's response. The optional PostData parameter is used to
supply post data to the server. The Content-Length header specifies
how much data will be read from the PostData InputStream. If it is not
specified, data will be read from the InputStream until EOF is reached.
@param postData additional data to supply to the server, if request
method is POST
|
[
"Opens",
"a",
"connection",
"passes",
"on",
"the",
"current",
"request",
"settings",
"and",
"returns",
"the",
"server",
"s",
"response",
".",
"The",
"optional",
"PostData",
"parameter",
"is",
"used",
"to",
"supply",
"post",
"data",
"to",
"the",
"server",
".",
"The",
"Content",
"-",
"Length",
"header",
"specifies",
"how",
"much",
"data",
"will",
"be",
"read",
"from",
"the",
"PostData",
"InputStream",
".",
"If",
"it",
"is",
"not",
"specified",
"data",
"will",
"be",
"read",
"from",
"the",
"InputStream",
"until",
"EOF",
"is",
"reached",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/net/HttpClient.java#L215-L279
|
144,854
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.addRootLogListener
|
public void addRootLogListener(LogListener listener) {
if (mParent == null) {
addLogListener(listener);
}
else {
mParent.addRootLogListener(listener);
}
}
|
java
|
public void addRootLogListener(LogListener listener) {
if (mParent == null) {
addLogListener(listener);
}
else {
mParent.addRootLogListener(listener);
}
}
|
[
"public",
"void",
"addRootLogListener",
"(",
"LogListener",
"listener",
")",
"{",
"if",
"(",
"mParent",
"==",
"null",
")",
"{",
"addLogListener",
"(",
"listener",
")",
";",
"}",
"else",
"{",
"mParent",
".",
"addRootLogListener",
"(",
"listener",
")",
";",
"}",
"}"
] |
adds a listener to the root log, the log with a null parent
|
[
"adds",
"a",
"listener",
"to",
"the",
"root",
"log",
"the",
"log",
"with",
"a",
"null",
"parent"
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L150-L157
|
144,855
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.debug
|
public void debug(String s) {
if (isEnabled() && isDebugEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.DEBUG_TYPE, s));
}
}
|
java
|
public void debug(String s) {
if (isEnabled() && isDebugEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.DEBUG_TYPE, s));
}
}
|
[
"public",
"void",
"debug",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isDebugEnabled",
"(",
")",
")",
"{",
"dispatchLogMessage",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"DEBUG_TYPE",
",",
"s",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single debugging message.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"debugging",
"message",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L233-L237
|
144,856
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.debug
|
public void debug(Throwable t) {
if (isEnabled() && isDebugEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.DEBUG_TYPE, t));
}
}
|
java
|
public void debug(Throwable t) {
if (isEnabled() && isDebugEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.DEBUG_TYPE, t));
}
}
|
[
"public",
"void",
"debug",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isDebugEnabled",
"(",
")",
")",
"{",
"dispatchLogException",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"DEBUG_TYPE",
",",
"t",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single debugging exception.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"debugging",
"exception",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L242-L246
|
144,857
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.info
|
public void info(String s) {
if (isEnabled() && isInfoEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.INFO_TYPE, s));
}
}
|
java
|
public void info(String s) {
if (isEnabled() && isInfoEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.INFO_TYPE, s));
}
}
|
[
"public",
"void",
"info",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isInfoEnabled",
"(",
")",
")",
"{",
"dispatchLogMessage",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"INFO_TYPE",
",",
"s",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single information message.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"information",
"message",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L258-L262
|
144,858
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.info
|
public void info(Throwable t) {
if (isEnabled() && isInfoEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.INFO_TYPE, t));
}
}
|
java
|
public void info(Throwable t) {
if (isEnabled() && isInfoEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.INFO_TYPE, t));
}
}
|
[
"public",
"void",
"info",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isInfoEnabled",
"(",
")",
")",
"{",
"dispatchLogException",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"INFO_TYPE",
",",
"t",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single information exception.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"information",
"exception",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L267-L271
|
144,859
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.warn
|
public void warn(String s) {
if (isEnabled() && isWarnEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.WARN_TYPE, s));
}
}
|
java
|
public void warn(String s) {
if (isEnabled() && isWarnEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.WARN_TYPE, s));
}
}
|
[
"public",
"void",
"warn",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isWarnEnabled",
"(",
")",
")",
"{",
"dispatchLogMessage",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"WARN_TYPE",
",",
"s",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single warning message.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"warning",
"message",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L283-L287
|
144,860
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.warn
|
public void warn(Throwable t) {
if (isEnabled() && isWarnEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.WARN_TYPE, t));
}
}
|
java
|
public void warn(Throwable t) {
if (isEnabled() && isWarnEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.WARN_TYPE, t));
}
}
|
[
"public",
"void",
"warn",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isWarnEnabled",
"(",
")",
")",
"{",
"dispatchLogException",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"WARN_TYPE",
",",
"t",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single warning exception.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"warning",
"exception",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L292-L296
|
144,861
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.error
|
public void error(String s) {
if (isEnabled() && isErrorEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.ERROR_TYPE, s));
}
}
|
java
|
public void error(String s) {
if (isEnabled() && isErrorEnabled()) {
dispatchLogMessage(new LogEvent(this, LogEvent.ERROR_TYPE, s));
}
}
|
[
"public",
"void",
"error",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isErrorEnabled",
"(",
")",
")",
"{",
"dispatchLogMessage",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"ERROR_TYPE",
",",
"s",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single error message.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"error",
"message",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L308-L312
|
144,862
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.error
|
public void error(Throwable t) {
if (isEnabled() && isErrorEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.ERROR_TYPE, t));
}
}
|
java
|
public void error(Throwable t) {
if (isEnabled() && isErrorEnabled()) {
dispatchLogException(new LogEvent(this, LogEvent.ERROR_TYPE, t));
}
}
|
[
"public",
"void",
"error",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
"&&",
"isErrorEnabled",
"(",
")",
")",
"{",
"dispatchLogException",
"(",
"new",
"LogEvent",
"(",
"this",
",",
"LogEvent",
".",
"ERROR_TYPE",
",",
"t",
")",
")",
";",
"}",
"}"
] |
Simple method for logging a single error exception.
|
[
"Simple",
"method",
"for",
"logging",
"a",
"single",
"error",
"exception",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L317-L321
|
144,863
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.getChildren
|
public Log[] getChildren() {
Collection copy;
synchronized (mChildren) {
copy = new ArrayList(mChildren.size());
Iterator it = mChildren.iterator();
while (it.hasNext()) {
Log child = (Log)((WeakReference)it.next()).get();
if (child == null) {
it.remove();
}
else {
copy.add(child);
}
}
}
return (Log[])copy.toArray(new Log[copy.size()]);
}
|
java
|
public Log[] getChildren() {
Collection copy;
synchronized (mChildren) {
copy = new ArrayList(mChildren.size());
Iterator it = mChildren.iterator();
while (it.hasNext()) {
Log child = (Log)((WeakReference)it.next()).get();
if (child == null) {
it.remove();
}
else {
copy.add(child);
}
}
}
return (Log[])copy.toArray(new Log[copy.size()]);
}
|
[
"public",
"Log",
"[",
"]",
"getChildren",
"(",
")",
"{",
"Collection",
"copy",
";",
"synchronized",
"(",
"mChildren",
")",
"{",
"copy",
"=",
"new",
"ArrayList",
"(",
"mChildren",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"it",
"=",
"mChildren",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Log",
"child",
"=",
"(",
"Log",
")",
"(",
"(",
"WeakReference",
")",
"it",
".",
"next",
"(",
")",
")",
".",
"get",
"(",
")",
";",
"if",
"(",
"child",
"==",
"null",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"else",
"{",
"copy",
".",
"add",
"(",
"child",
")",
";",
"}",
"}",
"}",
"return",
"(",
"Log",
"[",
"]",
")",
"copy",
".",
"toArray",
"(",
"new",
"Log",
"[",
"copy",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Returns a copy of the children Logs.
|
[
"Returns",
"a",
"copy",
"of",
"the",
"children",
"Logs",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L326-L344
|
144,864
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.setEnabled
|
public void setEnabled(boolean enabled) {
setEnabled(enabled, ENABLED_MASK);
if (enabled) {
Log parent;
if ((parent = mParent) != null) {
parent.setEnabled(true);
}
}
}
|
java
|
public void setEnabled(boolean enabled) {
setEnabled(enabled, ENABLED_MASK);
if (enabled) {
Log parent;
if ((parent = mParent) != null) {
parent.setEnabled(true);
}
}
}
|
[
"public",
"void",
"setEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"setEnabled",
"(",
"enabled",
",",
"ENABLED_MASK",
")",
";",
"if",
"(",
"enabled",
")",
"{",
"Log",
"parent",
";",
"if",
"(",
"(",
"parent",
"=",
"mParent",
")",
"!=",
"null",
")",
"{",
"parent",
".",
"setEnabled",
"(",
"true",
")",
";",
"}",
"}",
"}"
] |
When this Log is enabled, all parent Logs are also enabled. When this
Log is disabled, parent Logs are unaffected.
|
[
"When",
"this",
"Log",
"is",
"enabled",
"all",
"parent",
"Logs",
"are",
"also",
"enabled",
".",
"When",
"this",
"Log",
"is",
"disabled",
"parent",
"Logs",
"are",
"unaffected",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L379-L387
|
144,865
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/log/Log.java
|
Log.applyProperties
|
public void applyProperties(Map properties) {
if (properties.containsKey("enabled")) {
setEnabled(!"false".equalsIgnoreCase
((String)properties.get("enabled")));
}
if (properties.containsKey("debug")) {
setDebugEnabled(!"false".equalsIgnoreCase
((String)properties.get("debug")));
}
if (properties.containsKey("info")) {
setInfoEnabled(!"false".equalsIgnoreCase
((String)properties.get("info")));
}
if (properties.containsKey("warn")) {
setWarnEnabled(!"false".equalsIgnoreCase
((String)properties.get("warn")));
}
if (properties.containsKey("error")) {
setErrorEnabled(!"false".equalsIgnoreCase
((String)properties.get("error")));
}
}
|
java
|
public void applyProperties(Map properties) {
if (properties.containsKey("enabled")) {
setEnabled(!"false".equalsIgnoreCase
((String)properties.get("enabled")));
}
if (properties.containsKey("debug")) {
setDebugEnabled(!"false".equalsIgnoreCase
((String)properties.get("debug")));
}
if (properties.containsKey("info")) {
setInfoEnabled(!"false".equalsIgnoreCase
((String)properties.get("info")));
}
if (properties.containsKey("warn")) {
setWarnEnabled(!"false".equalsIgnoreCase
((String)properties.get("warn")));
}
if (properties.containsKey("error")) {
setErrorEnabled(!"false".equalsIgnoreCase
((String)properties.get("error")));
}
}
|
[
"public",
"void",
"applyProperties",
"(",
"Map",
"properties",
")",
"{",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"\"enabled\"",
")",
")",
"{",
"setEnabled",
"(",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"\"enabled\"",
")",
")",
")",
";",
"}",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"\"debug\"",
")",
")",
"{",
"setDebugEnabled",
"(",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"\"debug\"",
")",
")",
")",
";",
"}",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"\"info\"",
")",
")",
"{",
"setInfoEnabled",
"(",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"\"info\"",
")",
")",
")",
";",
"}",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"\"warn\"",
")",
")",
"{",
"setWarnEnabled",
"(",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"\"warn\"",
")",
")",
")",
";",
"}",
"if",
"(",
"properties",
".",
"containsKey",
"(",
"\"error\"",
")",
")",
"{",
"setErrorEnabled",
"(",
"!",
"\"false\"",
".",
"equalsIgnoreCase",
"(",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"\"error\"",
")",
")",
")",
";",
"}",
"}"
] |
Understands and applies the following boolean properties. True is the
default value if the value doesn't equal "false", ignoring case.
<ul>
<li>enabled
<li>debug
<li>info
<li>warn
<li>error
</ul>
|
[
"Understands",
"and",
"applies",
"the",
"following",
"boolean",
"properties",
".",
"True",
"is",
"the",
"default",
"value",
"if",
"the",
"value",
"doesn",
"t",
"equal",
"false",
"ignoring",
"case",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/log/Log.java#L481-L506
|
144,866
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/BeanPropertyAccessor.java
|
BeanPropertyAccessor.getBeanProperties
|
private static PropertyDescriptor[][] getBeanProperties(Class<?> beanType) {
List<PropertyDescriptor> readProperties =
new ArrayList<PropertyDescriptor>();
List<PropertyDescriptor> writeProperties =
new ArrayList<PropertyDescriptor>();
try {
Map<?, ?> map = CompleteIntrospector.getAllProperties(beanType);
Iterator<?> it = map.values().iterator();
while (it.hasNext()) {
PropertyDescriptor pd = (PropertyDescriptor)it.next();
if (pd.getReadMethod() != null) {
readProperties.add(pd);
}
if (pd.getWriteMethod() != null) {
writeProperties.add(pd);
}
}
}
catch (IntrospectionException e) {
throw new RuntimeException(e.toString());
}
PropertyDescriptor[][] props = new PropertyDescriptor[2][];
props[0] = new PropertyDescriptor[readProperties.size()];
readProperties.toArray(props[0]);
props[1] = new PropertyDescriptor[writeProperties.size()];
writeProperties.toArray(props[1]);
return props;
}
|
java
|
private static PropertyDescriptor[][] getBeanProperties(Class<?> beanType) {
List<PropertyDescriptor> readProperties =
new ArrayList<PropertyDescriptor>();
List<PropertyDescriptor> writeProperties =
new ArrayList<PropertyDescriptor>();
try {
Map<?, ?> map = CompleteIntrospector.getAllProperties(beanType);
Iterator<?> it = map.values().iterator();
while (it.hasNext()) {
PropertyDescriptor pd = (PropertyDescriptor)it.next();
if (pd.getReadMethod() != null) {
readProperties.add(pd);
}
if (pd.getWriteMethod() != null) {
writeProperties.add(pd);
}
}
}
catch (IntrospectionException e) {
throw new RuntimeException(e.toString());
}
PropertyDescriptor[][] props = new PropertyDescriptor[2][];
props[0] = new PropertyDescriptor[readProperties.size()];
readProperties.toArray(props[0]);
props[1] = new PropertyDescriptor[writeProperties.size()];
writeProperties.toArray(props[1]);
return props;
}
|
[
"private",
"static",
"PropertyDescriptor",
"[",
"]",
"[",
"]",
"getBeanProperties",
"(",
"Class",
"<",
"?",
">",
"beanType",
")",
"{",
"List",
"<",
"PropertyDescriptor",
">",
"readProperties",
"=",
"new",
"ArrayList",
"<",
"PropertyDescriptor",
">",
"(",
")",
";",
"List",
"<",
"PropertyDescriptor",
">",
"writeProperties",
"=",
"new",
"ArrayList",
"<",
"PropertyDescriptor",
">",
"(",
")",
";",
"try",
"{",
"Map",
"<",
"?",
",",
"?",
">",
"map",
"=",
"CompleteIntrospector",
".",
"getAllProperties",
"(",
"beanType",
")",
";",
"Iterator",
"<",
"?",
">",
"it",
"=",
"map",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"PropertyDescriptor",
"pd",
"=",
"(",
"PropertyDescriptor",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"pd",
".",
"getReadMethod",
"(",
")",
"!=",
"null",
")",
"{",
"readProperties",
".",
"add",
"(",
"pd",
")",
";",
"}",
"if",
"(",
"pd",
".",
"getWriteMethod",
"(",
")",
"!=",
"null",
")",
"{",
"writeProperties",
".",
"add",
"(",
"pd",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IntrospectionException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"PropertyDescriptor",
"[",
"]",
"[",
"]",
"props",
"=",
"new",
"PropertyDescriptor",
"[",
"2",
"]",
"[",
"",
"]",
";",
"props",
"[",
"0",
"]",
"=",
"new",
"PropertyDescriptor",
"[",
"readProperties",
".",
"size",
"(",
")",
"]",
";",
"readProperties",
".",
"toArray",
"(",
"props",
"[",
"0",
"]",
")",
";",
"props",
"[",
"1",
"]",
"=",
"new",
"PropertyDescriptor",
"[",
"writeProperties",
".",
"size",
"(",
")",
"]",
";",
"writeProperties",
".",
"toArray",
"(",
"props",
"[",
"1",
"]",
")",
";",
"return",
"props",
";",
"}"
] |
Returns two arrays of PropertyDescriptors. Array 0 has contains read
PropertyDescriptors, array 1 contains the write PropertyDescriptors.
|
[
"Returns",
"two",
"arrays",
"of",
"PropertyDescriptors",
".",
"Array",
"0",
"has",
"contains",
"read",
"PropertyDescriptors",
"array",
"1",
"contains",
"the",
"write",
"PropertyDescriptors",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/BeanPropertyAccessor.java#L419-L452
|
144,867
|
teatrove/teatrove
|
teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationResponseImpl.java
|
ApplicationResponseImpl.writeShort
|
static void writeShort(OutputStream out, int i) throws IOException {
out.write((byte)i);
out.write((byte)(i >> 8));
}
|
java
|
static void writeShort(OutputStream out, int i) throws IOException {
out.write((byte)i);
out.write((byte)(i >> 8));
}
|
[
"static",
"void",
"writeShort",
"(",
"OutputStream",
"out",
",",
"int",
"i",
")",
"throws",
"IOException",
"{",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"i",
")",
";",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"i",
">>",
"8",
")",
")",
";",
"}"
] |
Writes a short in Intel byte order.
|
[
"Writes",
"a",
"short",
"in",
"Intel",
"byte",
"order",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationResponseImpl.java#L66-L69
|
144,868
|
teatrove/teatrove
|
teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationResponseImpl.java
|
ApplicationResponseImpl.appendCompressed
|
void appendCompressed(ByteData compressed, ByteData original)
throws IOException
{
mCompressedSegments++;
mBuffer.appendSurrogate(new CompressedData(compressed, original));
}
|
java
|
void appendCompressed(ByteData compressed, ByteData original)
throws IOException
{
mCompressedSegments++;
mBuffer.appendSurrogate(new CompressedData(compressed, original));
}
|
[
"void",
"appendCompressed",
"(",
"ByteData",
"compressed",
",",
"ByteData",
"original",
")",
"throws",
"IOException",
"{",
"mCompressedSegments",
"++",
";",
"mBuffer",
".",
"appendSurrogate",
"(",
"new",
"CompressedData",
"(",
"compressed",
",",
"original",
")",
")",
";",
"}"
] |
Called from DetachedResponseImpl.
|
[
"Called",
"from",
"DetachedResponseImpl",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/ApplicationResponseImpl.java#L366-L371
|
144,869
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/DecimalConvertor.java
|
DecimalConvertor.toDecimalDigits
|
public static int toDecimalDigits(float v,
char[] digits, int offset, int maxDigits,
int maxFractDigits, int roundMode)
{
int bits = Float.floatToIntBits(v);
int f = bits & 0x7fffff;
int e = (bits >> 23) & 0xff;
if (e != 0) {
// Normalized number.
return toDecimalDigits(f + 0x800000, e - 126, 24, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
else {
// Denormalized number.
return toDecimalDigits(f, -125, 23, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
}
|
java
|
public static int toDecimalDigits(float v,
char[] digits, int offset, int maxDigits,
int maxFractDigits, int roundMode)
{
int bits = Float.floatToIntBits(v);
int f = bits & 0x7fffff;
int e = (bits >> 23) & 0xff;
if (e != 0) {
// Normalized number.
return toDecimalDigits(f + 0x800000, e - 126, 24, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
else {
// Denormalized number.
return toDecimalDigits(f, -125, 23, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
}
|
[
"public",
"static",
"int",
"toDecimalDigits",
"(",
"float",
"v",
",",
"char",
"[",
"]",
"digits",
",",
"int",
"offset",
",",
"int",
"maxDigits",
",",
"int",
"maxFractDigits",
",",
"int",
"roundMode",
")",
"{",
"int",
"bits",
"=",
"Float",
".",
"floatToIntBits",
"(",
"v",
")",
";",
"int",
"f",
"=",
"bits",
"&",
"0x7fffff",
";",
"int",
"e",
"=",
"(",
"bits",
">>",
"23",
")",
"&",
"0xff",
";",
"if",
"(",
"e",
"!=",
"0",
")",
"{",
"// Normalized number.",
"return",
"toDecimalDigits",
"(",
"f",
"+",
"0x800000",
",",
"e",
"-",
"126",
",",
"24",
",",
"digits",
",",
"offset",
",",
"maxDigits",
",",
"maxFractDigits",
",",
"roundMode",
")",
";",
"}",
"else",
"{",
"// Denormalized number.",
"return",
"toDecimalDigits",
"(",
"f",
",",
"-",
"125",
",",
"23",
",",
"digits",
",",
"offset",
",",
"maxDigits",
",",
"maxFractDigits",
",",
"roundMode",
")",
";",
"}",
"}"
] |
Produces decimal digits for non-zero, finite floating point values.
The sign of the value is discarded. Passing in Infinity or NaN produces
invalid digits. The maximum number of decimal digits that this
function will likely produce is 9.
@param v value
@param digits buffer to receive decimal digits
@param offset offset into digit buffer
@param maxDigits maximum number of digits to produce
@param maxFractDigits maximum number of fractional digits to produce
@param roundMode i.e. ROUND_HALF_UP
@return Upper 16 bits: decimal point offset; lower 16 bits: number of
digits produced
|
[
"Produces",
"decimal",
"digits",
"for",
"non",
"-",
"zero",
"finite",
"floating",
"point",
"values",
".",
"The",
"sign",
"of",
"the",
"value",
"is",
"discarded",
".",
"Passing",
"in",
"Infinity",
"or",
"NaN",
"produces",
"invalid",
"digits",
".",
"The",
"maximum",
"number",
"of",
"decimal",
"digits",
"that",
"this",
"function",
"will",
"likely",
"produce",
"is",
"9",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/DecimalConvertor.java#L819-L836
|
144,870
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/DecimalConvertor.java
|
DecimalConvertor.toDecimalDigits
|
public static int toDecimalDigits(double v,
char[] digits, int offset, int maxDigits,
int maxFractDigits, int roundMode)
{
// NOTE: The value 144115188075855872 is converted to
// 144115188075855870, which is as correct as possible. Java's
// Double.toString method doesn't round off the last digit.
long bits = Double.doubleToLongBits(v);
long f = bits & 0xfffffffffffffL;
int e = (int)((bits >> 52) & 0x7ff);
if (e != 0) {
// Normalized number.
return toDecimalDigits(f + 0x10000000000000L, e - 1022, 53,
digits, offset, maxDigits, maxFractDigits,
roundMode);
}
else {
// Denormalized number.
return toDecimalDigits(f, -1023, 52, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
}
|
java
|
public static int toDecimalDigits(double v,
char[] digits, int offset, int maxDigits,
int maxFractDigits, int roundMode)
{
// NOTE: The value 144115188075855872 is converted to
// 144115188075855870, which is as correct as possible. Java's
// Double.toString method doesn't round off the last digit.
long bits = Double.doubleToLongBits(v);
long f = bits & 0xfffffffffffffL;
int e = (int)((bits >> 52) & 0x7ff);
if (e != 0) {
// Normalized number.
return toDecimalDigits(f + 0x10000000000000L, e - 1022, 53,
digits, offset, maxDigits, maxFractDigits,
roundMode);
}
else {
// Denormalized number.
return toDecimalDigits(f, -1023, 52, digits, offset,
maxDigits, maxFractDigits, roundMode);
}
}
|
[
"public",
"static",
"int",
"toDecimalDigits",
"(",
"double",
"v",
",",
"char",
"[",
"]",
"digits",
",",
"int",
"offset",
",",
"int",
"maxDigits",
",",
"int",
"maxFractDigits",
",",
"int",
"roundMode",
")",
"{",
"// NOTE: The value 144115188075855872 is converted to",
"// 144115188075855870, which is as correct as possible. Java's",
"// Double.toString method doesn't round off the last digit.",
"long",
"bits",
"=",
"Double",
".",
"doubleToLongBits",
"(",
"v",
")",
";",
"long",
"f",
"=",
"bits",
"&",
"0xfffffffffffff",
"",
"L",
";",
"int",
"e",
"=",
"(",
"int",
")",
"(",
"(",
"bits",
">>",
"52",
")",
"&",
"0x7ff",
")",
";",
"if",
"(",
"e",
"!=",
"0",
")",
"{",
"// Normalized number.",
"return",
"toDecimalDigits",
"(",
"f",
"+",
"0x10000000000000",
"L",
",",
"e",
"-",
"1022",
",",
"53",
",",
"digits",
",",
"offset",
",",
"maxDigits",
",",
"maxFractDigits",
",",
"roundMode",
")",
";",
"}",
"else",
"{",
"// Denormalized number.",
"return",
"toDecimalDigits",
"(",
"f",
",",
"-",
"1023",
",",
"52",
",",
"digits",
",",
"offset",
",",
"maxDigits",
",",
"maxFractDigits",
",",
"roundMode",
")",
";",
"}",
"}"
] |
Produces decimal digits for non-zero, finite floating point values.
The sign of the value is discarded. Passing in Infinity or NaN produces
invalid digits. The maximum number of decimal digits that this
function will likely produce is 18.
@param v value
@param digits buffer to receive decimal digits
@param offset offset into digit buffer
@param maxDigits maximum number of digits to produce
@param maxFractDigits maximum number of fractional digits to produce
@param roundMode i.e. ROUND_HALF_UP
@return Upper 16 bits: decimal point offset; lower 16 bits: number of
digits produced
|
[
"Produces",
"decimal",
"digits",
"for",
"non",
"-",
"zero",
"finite",
"floating",
"point",
"values",
".",
"The",
"sign",
"of",
"the",
"value",
"is",
"discarded",
".",
"Passing",
"in",
"Infinity",
"or",
"NaN",
"produces",
"invalid",
"digits",
".",
"The",
"maximum",
"number",
"of",
"decimal",
"digits",
"that",
"this",
"function",
"will",
"likely",
"produce",
"is",
"18",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/DecimalConvertor.java#L853-L875
|
144,871
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueueData.java
|
TransactionQueueData.add
|
public TransactionQueueData add(TransactionQueueData data) {
return new TransactionQueueData
(null,
Math.min(mSnapshotStart, data.mSnapshotStart),
Math.max(mSnapshotEnd, data.mSnapshotEnd),
mQueueSize + data.mQueueSize,
mThreadCount + data.mThreadCount,
mServicingCount + data.mServicingCount,
Math.max(mPeakQueueSize, data.mPeakQueueSize),
Math.max(mPeakThreadCount, data.mPeakThreadCount),
Math.max(mPeakServicingCount, data.mPeakServicingCount),
mTotalEnqueueAttempts + data.mTotalEnqueueAttempts,
mTotalEnqueued + data.mTotalEnqueued,
mTotalServiced + data.mTotalServiced,
mTotalExpired + data.mTotalExpired,
mTotalServiceExceptions + data.mTotalServiceExceptions,
mTotalUncaughtExceptions + data.mTotalUncaughtExceptions,
mTotalQueueDuration + data.mTotalQueueDuration,
mTotalServiceDuration + data.mTotalServiceDuration
);
}
|
java
|
public TransactionQueueData add(TransactionQueueData data) {
return new TransactionQueueData
(null,
Math.min(mSnapshotStart, data.mSnapshotStart),
Math.max(mSnapshotEnd, data.mSnapshotEnd),
mQueueSize + data.mQueueSize,
mThreadCount + data.mThreadCount,
mServicingCount + data.mServicingCount,
Math.max(mPeakQueueSize, data.mPeakQueueSize),
Math.max(mPeakThreadCount, data.mPeakThreadCount),
Math.max(mPeakServicingCount, data.mPeakServicingCount),
mTotalEnqueueAttempts + data.mTotalEnqueueAttempts,
mTotalEnqueued + data.mTotalEnqueued,
mTotalServiced + data.mTotalServiced,
mTotalExpired + data.mTotalExpired,
mTotalServiceExceptions + data.mTotalServiceExceptions,
mTotalUncaughtExceptions + data.mTotalUncaughtExceptions,
mTotalQueueDuration + data.mTotalQueueDuration,
mTotalServiceDuration + data.mTotalServiceDuration
);
}
|
[
"public",
"TransactionQueueData",
"add",
"(",
"TransactionQueueData",
"data",
")",
"{",
"return",
"new",
"TransactionQueueData",
"(",
"null",
",",
"Math",
".",
"min",
"(",
"mSnapshotStart",
",",
"data",
".",
"mSnapshotStart",
")",
",",
"Math",
".",
"max",
"(",
"mSnapshotEnd",
",",
"data",
".",
"mSnapshotEnd",
")",
",",
"mQueueSize",
"+",
"data",
".",
"mQueueSize",
",",
"mThreadCount",
"+",
"data",
".",
"mThreadCount",
",",
"mServicingCount",
"+",
"data",
".",
"mServicingCount",
",",
"Math",
".",
"max",
"(",
"mPeakQueueSize",
",",
"data",
".",
"mPeakQueueSize",
")",
",",
"Math",
".",
"max",
"(",
"mPeakThreadCount",
",",
"data",
".",
"mPeakThreadCount",
")",
",",
"Math",
".",
"max",
"(",
"mPeakServicingCount",
",",
"data",
".",
"mPeakServicingCount",
")",
",",
"mTotalEnqueueAttempts",
"+",
"data",
".",
"mTotalEnqueueAttempts",
",",
"mTotalEnqueued",
"+",
"data",
".",
"mTotalEnqueued",
",",
"mTotalServiced",
"+",
"data",
".",
"mTotalServiced",
",",
"mTotalExpired",
"+",
"data",
".",
"mTotalExpired",
",",
"mTotalServiceExceptions",
"+",
"data",
".",
"mTotalServiceExceptions",
",",
"mTotalUncaughtExceptions",
"+",
"data",
".",
"mTotalUncaughtExceptions",
",",
"mTotalQueueDuration",
"+",
"data",
".",
"mTotalQueueDuration",
",",
"mTotalServiceDuration",
"+",
"data",
".",
"mTotalServiceDuration",
")",
";",
"}"
] |
Adds TransactionQueueData to another.
|
[
"Adds",
"TransactionQueueData",
"to",
"another",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/tq/TransactionQueueData.java#L89-L109
|
144,872
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/WrappedCache.java
|
WrappedCache.get
|
public Object get(Object key) {
Object value = mCacheMap.get(key);
if (value != null || mCacheMap.containsKey(key)) {
return value;
}
value = mBackingMap.get(key);
if (value != null || mBackingMap.containsKey(key)) {
mCacheMap.put(key, value);
}
return value;
}
|
java
|
public Object get(Object key) {
Object value = mCacheMap.get(key);
if (value != null || mCacheMap.containsKey(key)) {
return value;
}
value = mBackingMap.get(key);
if (value != null || mBackingMap.containsKey(key)) {
mCacheMap.put(key, value);
}
return value;
}
|
[
"public",
"Object",
"get",
"(",
"Object",
"key",
")",
"{",
"Object",
"value",
"=",
"mCacheMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"||",
"mCacheMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"return",
"value",
";",
"}",
"value",
"=",
"mBackingMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"||",
"mBackingMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"mCacheMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Returns the value from the cache, or if not found, the backing map.
If the backing map is accessed, the value is saved in the cache for
future gets.
|
[
"Returns",
"the",
"value",
"from",
"the",
"cache",
"or",
"if",
"not",
"found",
"the",
"backing",
"map",
".",
"If",
"the",
"backing",
"map",
"is",
"accessed",
"the",
"value",
"is",
"saved",
"in",
"the",
"cache",
"for",
"future",
"gets",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/WrappedCache.java#L80-L90
|
144,873
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/WrappedCache.java
|
WrappedCache.put
|
public Object put(Object key, Object value) {
mCacheMap.put(key, value);
return mBackingMap.put(key, value);
}
|
java
|
public Object put(Object key, Object value) {
mCacheMap.put(key, value);
return mBackingMap.put(key, value);
}
|
[
"public",
"Object",
"put",
"(",
"Object",
"key",
",",
"Object",
"value",
")",
"{",
"mCacheMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"mBackingMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Puts the entry into both the cache and backing map. The old value in
the backing map is returned.
|
[
"Puts",
"the",
"entry",
"into",
"both",
"the",
"cache",
"and",
"backing",
"map",
".",
"The",
"old",
"value",
"in",
"the",
"backing",
"map",
"is",
"returned",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/WrappedCache.java#L96-L99
|
144,874
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/WrappedCache.java
|
WrappedCache.remove
|
public Object remove(Object key) {
mCacheMap.remove(key);
return mBackingMap.remove(key);
}
|
java
|
public Object remove(Object key) {
mCacheMap.remove(key);
return mBackingMap.remove(key);
}
|
[
"public",
"Object",
"remove",
"(",
"Object",
"key",
")",
"{",
"mCacheMap",
".",
"remove",
"(",
"key",
")",
";",
"return",
"mBackingMap",
".",
"remove",
"(",
"key",
")",
";",
"}"
] |
Removes the key from both the cache and backing map. The old value in
the backing map is returned.
|
[
"Removes",
"the",
"key",
"from",
"both",
"the",
"cache",
"and",
"backing",
"map",
".",
"The",
"old",
"value",
"in",
"the",
"backing",
"map",
"is",
"returned",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/WrappedCache.java#L105-L108
|
144,875
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/plugin/PluginConfigSupport.java
|
PluginConfigSupport.getPlugin
|
public Plugin getPlugin(String name) {
if (mPluginContext != null) {
return mPluginContext.getPlugin(name);
}
return null;
}
|
java
|
public Plugin getPlugin(String name) {
if (mPluginContext != null) {
return mPluginContext.getPlugin(name);
}
return null;
}
|
[
"public",
"Plugin",
"getPlugin",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"mPluginContext",
"!=",
"null",
")",
"{",
"return",
"mPluginContext",
".",
"getPlugin",
"(",
"name",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns a Plugin by name.
@param name the name of the Plugin.
@return Plugin the Plugin object.
|
[
"Returns",
"a",
"Plugin",
"by",
"name",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/plugin/PluginConfigSupport.java#L66-L71
|
144,876
|
teatrove/teatrove
|
trove/src/main/java/org/teatrove/trove/util/plugin/PluginConfigSupport.java
|
PluginConfigSupport.getPlugins
|
public Plugin[] getPlugins() {
if (mPluginContext != null) {
Collection c = mPluginContext.getPlugins().values();
if (c != null) {
return (Plugin[])c.toArray(new Plugin[c.size()]);
}
}
return new Plugin[0];
}
|
java
|
public Plugin[] getPlugins() {
if (mPluginContext != null) {
Collection c = mPluginContext.getPlugins().values();
if (c != null) {
return (Plugin[])c.toArray(new Plugin[c.size()]);
}
}
return new Plugin[0];
}
|
[
"public",
"Plugin",
"[",
"]",
"getPlugins",
"(",
")",
"{",
"if",
"(",
"mPluginContext",
"!=",
"null",
")",
"{",
"Collection",
"c",
"=",
"mPluginContext",
".",
"getPlugins",
"(",
")",
".",
"values",
"(",
")",
";",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"return",
"(",
"Plugin",
"[",
"]",
")",
"c",
".",
"toArray",
"(",
"new",
"Plugin",
"[",
"c",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"}",
"return",
"new",
"Plugin",
"[",
"0",
"]",
";",
"}"
] |
Returns an array of all of the Plugins.
@return the array of Plugins.
|
[
"Returns",
"an",
"array",
"of",
"all",
"of",
"the",
"Plugins",
"."
] |
7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea
|
https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/trove/src/main/java/org/teatrove/trove/util/plugin/PluginConfigSupport.java#L78-L86
|
144,877
|
LevelFourAB/commons
|
commons-serialization/src/main/java/se/l4/commons/serialization/format/BinaryOutput.java
|
BinaryOutput.writeStringNoTag
|
private void writeStringNoTag(String value)
throws IOException
{
writeIntegerNoTag(value.length());
for(int i=0, n=value.length(); i<n; i++)
{
char c = value.charAt(i);
if(c <= 0x007f)
{
out.write((byte) c);
}
else if(c > 0x07ff)
{
out.write((byte) (0xe0 | c >> 12 & 0x0f));
out.write((byte) (0x80 | c >> 6 & 0x3f));
out.write((byte) (0x80 | c >> 0 & 0x3f));
}
else
{
out.write((byte) (0xc0 | c >> 6 & 0x1f));
out.write((byte) (0x80 | c >> 0 & 0x3f));
}
}
}
|
java
|
private void writeStringNoTag(String value)
throws IOException
{
writeIntegerNoTag(value.length());
for(int i=0, n=value.length(); i<n; i++)
{
char c = value.charAt(i);
if(c <= 0x007f)
{
out.write((byte) c);
}
else if(c > 0x07ff)
{
out.write((byte) (0xe0 | c >> 12 & 0x0f));
out.write((byte) (0x80 | c >> 6 & 0x3f));
out.write((byte) (0x80 | c >> 0 & 0x3f));
}
else
{
out.write((byte) (0xc0 | c >> 6 & 0x1f));
out.write((byte) (0x80 | c >> 0 & 0x3f));
}
}
}
|
[
"private",
"void",
"writeStringNoTag",
"(",
"String",
"value",
")",
"throws",
"IOException",
"{",
"writeIntegerNoTag",
"(",
"value",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"value",
".",
"length",
"(",
")",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"<=",
"0x007f",
")",
"{",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"c",
")",
";",
"}",
"else",
"if",
"(",
"c",
">",
"0x07ff",
")",
"{",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"0xe0",
"|",
"c",
">>",
"12",
"&",
"0x0f",
")",
")",
";",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"0x80",
"|",
"c",
">>",
"6",
"&",
"0x3f",
")",
")",
";",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"0x80",
"|",
"c",
">>",
"0",
"&",
"0x3f",
")",
")",
";",
"}",
"else",
"{",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"0xc0",
"|",
"c",
">>",
"6",
"&",
"0x1f",
")",
")",
";",
"out",
".",
"write",
"(",
"(",
"byte",
")",
"(",
"0x80",
"|",
"c",
">>",
"0",
"&",
"0x3f",
")",
")",
";",
"}",
"}",
"}"
] |
Write a string to the output without tagging that its actually a string.
@param value
@throws IOException
|
[
"Write",
"a",
"string",
"to",
"the",
"output",
"without",
"tagging",
"that",
"its",
"actually",
"a",
"string",
"."
] |
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
|
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-serialization/src/main/java/se/l4/commons/serialization/format/BinaryOutput.java#L226-L249
|
144,878
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.indexOf
|
public static int indexOf(final String input, final char delim, final int fromIndex) {
if (input == null) return -1;
int index = input.indexOf(delim, fromIndex);
if (index != 0) {
while (index != -1 && index != (input.length() - 1)) {
if (input.charAt(index - 1) != '\\') break;
index = input.indexOf(delim, index + 1);
}
}
return index;
}
|
java
|
public static int indexOf(final String input, final char delim, final int fromIndex) {
if (input == null) return -1;
int index = input.indexOf(delim, fromIndex);
if (index != 0) {
while (index != -1 && index != (input.length() - 1)) {
if (input.charAt(index - 1) != '\\') break;
index = input.indexOf(delim, index + 1);
}
}
return index;
}
|
[
"public",
"static",
"int",
"indexOf",
"(",
"final",
"String",
"input",
",",
"final",
"char",
"delim",
",",
"final",
"int",
"fromIndex",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"return",
"-",
"1",
";",
"int",
"index",
"=",
"input",
".",
"indexOf",
"(",
"delim",
",",
"fromIndex",
")",
";",
"if",
"(",
"index",
"!=",
"0",
")",
"{",
"while",
"(",
"index",
"!=",
"-",
"1",
"&&",
"index",
"!=",
"(",
"input",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"index",
"-",
"1",
")",
"!=",
"'",
"'",
")",
"break",
";",
"index",
"=",
"input",
".",
"indexOf",
"(",
"delim",
",",
"index",
"+",
"1",
")",
";",
"}",
"}",
"return",
"index",
";",
"}"
] |
Gets the first index of a character after fromIndex. Ignoring characters that have been escaped
@param input The string to be searched
@param delim The character to be found
@param fromIndex Start searching from this index
@return The index of the found character or -1 if the character wasn't found
|
[
"Gets",
"the",
"first",
"index",
"of",
"a",
"character",
"after",
"fromIndex",
".",
"Ignoring",
"characters",
"that",
"have",
"been",
"escaped"
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L229-L239
|
144,879
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.lastIndexOf
|
public static int lastIndexOf(final String input, final char delim) {
return input == null ? -1 : lastIndexOf(input, delim, input.length());
}
|
java
|
public static int lastIndexOf(final String input, final char delim) {
return input == null ? -1 : lastIndexOf(input, delim, input.length());
}
|
[
"public",
"static",
"int",
"lastIndexOf",
"(",
"final",
"String",
"input",
",",
"final",
"char",
"delim",
")",
"{",
"return",
"input",
"==",
"null",
"?",
"-",
"1",
":",
"lastIndexOf",
"(",
"input",
",",
"delim",
",",
"input",
".",
"length",
"(",
")",
")",
";",
"}"
] |
Gets the last index of a character ignoring characters that have been escaped
@param input The string to be searched
@param delim The character to be found
@return The index of the found character or -1 if the character wasn't found
|
[
"Gets",
"the",
"last",
"index",
"of",
"a",
"character",
"ignoring",
"characters",
"that",
"have",
"been",
"escaped"
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L248-L250
|
144,880
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.lastIndexOf
|
public static int lastIndexOf(final String input, final char delim, final int fromIndex) {
if (input == null) return -1;
int index = input.lastIndexOf(delim, fromIndex);
while (index != -1 && index != 0) {
if (input.charAt(index - 1) != '\\') break;
index = input.lastIndexOf(delim, index - 1);
}
return index;
}
|
java
|
public static int lastIndexOf(final String input, final char delim, final int fromIndex) {
if (input == null) return -1;
int index = input.lastIndexOf(delim, fromIndex);
while (index != -1 && index != 0) {
if (input.charAt(index - 1) != '\\') break;
index = input.lastIndexOf(delim, index - 1);
}
return index;
}
|
[
"public",
"static",
"int",
"lastIndexOf",
"(",
"final",
"String",
"input",
",",
"final",
"char",
"delim",
",",
"final",
"int",
"fromIndex",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"return",
"-",
"1",
";",
"int",
"index",
"=",
"input",
".",
"lastIndexOf",
"(",
"delim",
",",
"fromIndex",
")",
";",
"while",
"(",
"index",
"!=",
"-",
"1",
"&&",
"index",
"!=",
"0",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"index",
"-",
"1",
")",
"!=",
"'",
"'",
")",
"break",
";",
"index",
"=",
"input",
".",
"lastIndexOf",
"(",
"delim",
",",
"index",
"-",
"1",
")",
";",
"}",
"return",
"index",
";",
"}"
] |
Gets the last index of a character starting at fromIndex. Ignoring characters that have been escaped
@param input The string to be searched
@param delim The character to be found
@param fromIndex Start searching from this index
@return The index of the found character or -1 if the character wasn't found
|
[
"Gets",
"the",
"last",
"index",
"of",
"a",
"character",
"starting",
"at",
"fromIndex",
".",
"Ignoring",
"characters",
"that",
"have",
"been",
"escaped"
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L260-L268
|
144,881
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.isAlphanumeric
|
public static boolean isAlphanumeric(final String input) {
for (int i = 0; i < input.length(); i++) {
if (!Character.isLetterOrDigit(input.charAt(i))) return false;
}
return true;
}
|
java
|
public static boolean isAlphanumeric(final String input) {
for (int i = 0; i < input.length(); i++) {
if (!Character.isLetterOrDigit(input.charAt(i))) return false;
}
return true;
}
|
[
"public",
"static",
"boolean",
"isAlphanumeric",
"(",
"final",
"String",
"input",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"input",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isLetterOrDigit",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks to see if a string entered is alpha numeric
@param input The string to be tested
@return True if the string is alpha numeric otherwise false
|
[
"Checks",
"to",
"see",
"if",
"a",
"string",
"entered",
"is",
"alpha",
"numeric"
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L326-L331
|
144,882
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.convertToRegexString
|
public static String convertToRegexString(final String input) {
return input.replaceAll("\\\\", "\\\\").replaceAll("\\*", "\\*").replaceAll("\\+", "\\+").replaceAll("\\]", "\\]").replaceAll("\\[",
"\\[").replaceAll("\\(", "\\(").replaceAll("\\)", "\\)").replaceAll("\\?", "\\?").replaceAll("\\$", "\\$").replaceAll("\\|",
"\\|").replaceAll("\\^", "\\^").replaceAll("\\.", "\\.");
}
|
java
|
public static String convertToRegexString(final String input) {
return input.replaceAll("\\\\", "\\\\").replaceAll("\\*", "\\*").replaceAll("\\+", "\\+").replaceAll("\\]", "\\]").replaceAll("\\[",
"\\[").replaceAll("\\(", "\\(").replaceAll("\\)", "\\)").replaceAll("\\?", "\\?").replaceAll("\\$", "\\$").replaceAll("\\|",
"\\|").replaceAll("\\^", "\\^").replaceAll("\\.", "\\.");
}
|
[
"public",
"static",
"String",
"convertToRegexString",
"(",
"final",
"String",
"input",
")",
"{",
"return",
"input",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"\"\\\\\\\\\"",
")",
".",
"replaceAll",
"(",
"\"\\\\*\"",
",",
"\"\\\\*\"",
")",
".",
"replaceAll",
"(",
"\"\\\\+\"",
",",
"\"\\\\+\"",
")",
".",
"replaceAll",
"(",
"\"\\\\]\"",
",",
"\"\\\\]\"",
")",
".",
"replaceAll",
"(",
"\"\\\\[\"",
",",
"\"\\\\[\"",
")",
".",
"replaceAll",
"(",
"\"\\\\(\"",
",",
"\"\\\\(\"",
")",
".",
"replaceAll",
"(",
"\"\\\\)\"",
",",
"\"\\\\)\"",
")",
".",
"replaceAll",
"(",
"\"\\\\?\"",
",",
"\"\\\\?\"",
")",
".",
"replaceAll",
"(",
"\"\\\\$\"",
",",
"\"\\\\$\"",
")",
".",
"replaceAll",
"(",
"\"\\\\|\"",
",",
"\"\\\\|\"",
")",
".",
"replaceAll",
"(",
"\"\\\\^\"",
",",
"\"\\\\^\"",
")",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"\\\\.\"",
")",
";",
"}"
] |
Converts a string so that it can be used in a regular expression.
@param input The string to be converted.
@return An escaped string that can be used in a regular expression.
|
[
"Converts",
"a",
"string",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"a",
"regular",
"expression",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L352-L356
|
144,883
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.similarLevenshtein
|
public static double similarLevenshtein(String s1, String s2) {
if (s1.equals(s2)) {
return 1.0;
}
// Make sure s1 is the longest string
if (s1.length() < s2.length()) {
String swap = s1;
s1 = s2;
s2 = swap;
}
int bigLength = s1.length();
return (bigLength - StringUtils.getLevenshteinDistance(s2, s1)) / (double) bigLength;
}
|
java
|
public static double similarLevenshtein(String s1, String s2) {
if (s1.equals(s2)) {
return 1.0;
}
// Make sure s1 is the longest string
if (s1.length() < s2.length()) {
String swap = s1;
s1 = s2;
s2 = swap;
}
int bigLength = s1.length();
return (bigLength - StringUtils.getLevenshteinDistance(s2, s1)) / (double) bigLength;
}
|
[
"public",
"static",
"double",
"similarLevenshtein",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"s1",
".",
"equals",
"(",
"s2",
")",
")",
"{",
"return",
"1.0",
";",
"}",
"// Make sure s1 is the longest string",
"if",
"(",
"s1",
".",
"length",
"(",
")",
"<",
"s2",
".",
"length",
"(",
")",
")",
"{",
"String",
"swap",
"=",
"s1",
";",
"s1",
"=",
"s2",
";",
"s2",
"=",
"swap",
";",
"}",
"int",
"bigLength",
"=",
"s1",
".",
"length",
"(",
")",
";",
"return",
"(",
"bigLength",
"-",
"StringUtils",
".",
"getLevenshteinDistance",
"(",
"s2",
",",
"s1",
")",
")",
"/",
"(",
"double",
")",
"bigLength",
";",
"}"
] |
Checks to see how similar two strings are using the Levenshtein distance algorithm.
@param s1 The first string to compare against.
@param s2 The second string to compare against.
@return A value between 0 and 1.0, where 1.0 is an exact match and 0 is no match at all.
|
[
"Checks",
"to",
"see",
"how",
"similar",
"two",
"strings",
"are",
"using",
"the",
"Levenshtein",
"distance",
"algorithm",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L365-L379
|
144,884
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.similarDamerauLevenshtein
|
public static double similarDamerauLevenshtein(String s1, String s2) {
if (s1.equals(s2)) {
return 1.0;
}
// Make sure s1 is the longest string
if (s1.length() < s2.length()) {
String swap = s1;
s1 = s2;
s2 = swap;
}
int bigLength = s1.length();
return (bigLength - getDamerauLevenshteinDistance(s2, s1)) / (double) bigLength;
}
|
java
|
public static double similarDamerauLevenshtein(String s1, String s2) {
if (s1.equals(s2)) {
return 1.0;
}
// Make sure s1 is the longest string
if (s1.length() < s2.length()) {
String swap = s1;
s1 = s2;
s2 = swap;
}
int bigLength = s1.length();
return (bigLength - getDamerauLevenshteinDistance(s2, s1)) / (double) bigLength;
}
|
[
"public",
"static",
"double",
"similarDamerauLevenshtein",
"(",
"String",
"s1",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"s1",
".",
"equals",
"(",
"s2",
")",
")",
"{",
"return",
"1.0",
";",
"}",
"// Make sure s1 is the longest string",
"if",
"(",
"s1",
".",
"length",
"(",
")",
"<",
"s2",
".",
"length",
"(",
")",
")",
"{",
"String",
"swap",
"=",
"s1",
";",
"s1",
"=",
"s2",
";",
"s2",
"=",
"swap",
";",
"}",
"int",
"bigLength",
"=",
"s1",
".",
"length",
"(",
")",
";",
"return",
"(",
"bigLength",
"-",
"getDamerauLevenshteinDistance",
"(",
"s2",
",",
"s1",
")",
")",
"/",
"(",
"double",
")",
"bigLength",
";",
"}"
] |
Checks to see how similar two strings are using the Damerau-Levenshtein distance algorithm.
@param s1 The first string to compare against.
@param s2 The second string to compare against.
@return A value between 0 and 1.0, where 1.0 is an exact match and 0 is no match at all.
|
[
"Checks",
"to",
"see",
"how",
"similar",
"two",
"strings",
"are",
"using",
"the",
"Damerau",
"-",
"Levenshtein",
"distance",
"algorithm",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L388-L402
|
144,885
|
pressgang-ccms/PressGangCCMSCommonUtilities
|
src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java
|
StringUtilities.isStringNullOrEmpty
|
public static boolean isStringNullOrEmpty(final String input) {
if (input == null || input.trim().isEmpty()) {
return true;
}
return false;
}
|
java
|
public static boolean isStringNullOrEmpty(final String input) {
if (input == null || input.trim().isEmpty()) {
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"isStringNullOrEmpty",
"(",
"final",
"String",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Test to see if a String is null or contains only whitespace.
@param input The String to test
@return true if input is null or contains only whitespace, and false otherwise
|
[
"Test",
"to",
"see",
"if",
"a",
"String",
"is",
"null",
"or",
"contains",
"only",
"whitespace",
"."
] |
5ebf5ed30a94c34c33f4708caa04a8da99cbb15c
|
https://github.com/pressgang-ccms/PressGangCCMSCommonUtilities/blob/5ebf5ed30a94c34c33f4708caa04a8da99cbb15c/src/main/java/org/jboss/pressgang/ccms/utils/common/StringUtilities.java#L470-L476
|
144,886
|
josueeduardo/snappy
|
extensions/discovery/src/main/java/io/joshworks/snappy/extensions/ssr/server/service/ServiceControl.java
|
ServiceControl.getService
|
public Service getService(String name) {
Service service = store.get(name);
if (service == null) {
throw HttpException.notFound("Service not found for name '" + name + "'");
}
return service;
}
|
java
|
public Service getService(String name) {
Service service = store.get(name);
if (service == null) {
throw HttpException.notFound("Service not found for name '" + name + "'");
}
return service;
}
|
[
"public",
"Service",
"getService",
"(",
"String",
"name",
")",
"{",
"Service",
"service",
"=",
"store",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"service",
"==",
"null",
")",
"{",
"throw",
"HttpException",
".",
"notFound",
"(",
"\"Service not found for name '\"",
"+",
"name",
"+",
"\"'\"",
")",
";",
"}",
"return",
"service",
";",
"}"
] |
returns a copy of all the services, including the disabled ones
|
[
"returns",
"a",
"copy",
"of",
"all",
"the",
"services",
"including",
"the",
"disabled",
"ones"
] |
d95a9e811eda3c24a5e53086369208819884fa49
|
https://github.com/josueeduardo/snappy/blob/d95a9e811eda3c24a5e53086369208819884fa49/extensions/discovery/src/main/java/io/joshworks/snappy/extensions/ssr/server/service/ServiceControl.java#L47-L53
|
144,887
|
devcon5io/common
|
cli/src/main/java/io/devcon5/cli/OptionInjector.java
|
OptionInjector.preFlightCheckMethods
|
private <T> void preFlightCheckMethods(final T target, final List<Method> methods) {
methods.forEach(m -> {m.setAccessible(true);
try {
m.invoke(target);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
|
java
|
private <T> void preFlightCheckMethods(final T target, final List<Method> methods) {
methods.forEach(m -> {m.setAccessible(true);
try {
m.invoke(target);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
|
[
"private",
"<",
"T",
">",
"void",
"preFlightCheckMethods",
"(",
"final",
"T",
"target",
",",
"final",
"List",
"<",
"Method",
">",
"methods",
")",
"{",
"methods",
".",
"forEach",
"(",
"m",
"->",
"{",
"m",
".",
"setAccessible",
"(",
"true",
")",
";",
"try",
"{",
"m",
".",
"invoke",
"(",
"target",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Invokes all methods in the list on the target.
@param target
the target on which the methods should be ivoked
@param methods
the methods to be invoked in order of priority
@param <T>
|
[
"Invokes",
"all",
"methods",
"in",
"the",
"list",
"on",
"the",
"target",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/cli/src/main/java/io/devcon5/cli/OptionInjector.java#L122-L131
|
144,888
|
devcon5io/common
|
cli/src/main/java/io/devcon5/cli/OptionInjector.java
|
OptionInjector.injectParameters
|
private void injectParameters(Object target, Map<String, Option> options) {
ClassStreams.selfAndSupertypes(target.getClass()).forEach(type -> {
for (Field f : type.getDeclaredFields()) {
Optional.ofNullable(f.getAnnotation(CliOption.class))
.ifPresent(opt -> populate(f, target, getEffectiveValue(options, opt)));
Optional.ofNullable(f.getAnnotation(CliOptionGroup.class))
.ifPresent(opt -> populate(f, target, options));
}
});
}
|
java
|
private void injectParameters(Object target, Map<String, Option> options) {
ClassStreams.selfAndSupertypes(target.getClass()).forEach(type -> {
for (Field f : type.getDeclaredFields()) {
Optional.ofNullable(f.getAnnotation(CliOption.class))
.ifPresent(opt -> populate(f, target, getEffectiveValue(options, opt)));
Optional.ofNullable(f.getAnnotation(CliOptionGroup.class))
.ifPresent(opt -> populate(f, target, options));
}
});
}
|
[
"private",
"void",
"injectParameters",
"(",
"Object",
"target",
",",
"Map",
"<",
"String",
",",
"Option",
">",
"options",
")",
"{",
"ClassStreams",
".",
"selfAndSupertypes",
"(",
"target",
".",
"getClass",
"(",
")",
")",
".",
"forEach",
"(",
"type",
"->",
"{",
"for",
"(",
"Field",
"f",
":",
"type",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"Optional",
".",
"ofNullable",
"(",
"f",
".",
"getAnnotation",
"(",
"CliOption",
".",
"class",
")",
")",
".",
"ifPresent",
"(",
"opt",
"->",
"populate",
"(",
"f",
",",
"target",
",",
"getEffectiveValue",
"(",
"options",
",",
"opt",
")",
")",
")",
";",
"Optional",
".",
"ofNullable",
"(",
"f",
".",
"getAnnotation",
"(",
"CliOptionGroup",
".",
"class",
")",
")",
".",
"ifPresent",
"(",
"opt",
"->",
"populate",
"(",
"f",
",",
"target",
",",
"options",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Inject parameter values from the map of options.
@param target
the target instance to parse cli parameters
@param options
the map of options, mapping short option names to {@link org.apache.commons.cli.Option} instances
|
[
"Inject",
"parameter",
"values",
"from",
"the",
"map",
"of",
"options",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/cli/src/main/java/io/devcon5/cli/OptionInjector.java#L141-L150
|
144,889
|
devcon5io/common
|
cli/src/main/java/io/devcon5/cli/OptionInjector.java
|
OptionInjector.getEffectiveValue
|
private String getEffectiveValue(Map<String, Option> options, CliOption opt) {
final String shortOpt = opt.value();
if (opt.hasArg()) {
if (options.containsKey(shortOpt)) {
return options.get(shortOpt).getValue();
}
return opt.defaultValue();
}
return Boolean.toString(options.containsKey(opt.value()));
}
|
java
|
private String getEffectiveValue(Map<String, Option> options, CliOption opt) {
final String shortOpt = opt.value();
if (opt.hasArg()) {
if (options.containsKey(shortOpt)) {
return options.get(shortOpt).getValue();
}
return opt.defaultValue();
}
return Boolean.toString(options.containsKey(opt.value()));
}
|
[
"private",
"String",
"getEffectiveValue",
"(",
"Map",
"<",
"String",
",",
"Option",
">",
"options",
",",
"CliOption",
"opt",
")",
"{",
"final",
"String",
"shortOpt",
"=",
"opt",
".",
"value",
"(",
")",
";",
"if",
"(",
"opt",
".",
"hasArg",
"(",
")",
")",
"{",
"if",
"(",
"options",
".",
"containsKey",
"(",
"shortOpt",
")",
")",
"{",
"return",
"options",
".",
"get",
"(",
"shortOpt",
")",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"opt",
".",
"defaultValue",
"(",
")",
";",
"}",
"return",
"Boolean",
".",
"toString",
"(",
"options",
".",
"containsKey",
"(",
"opt",
".",
"value",
"(",
")",
")",
")",
";",
"}"
] |
Returns the effective value for the specified option.
@param options
the parsed option
@param opt
the cli option annotation for which the actual argument should be retrieved
@return the effective value for the given option <ul> <li>If the option should have an argument, and an argument
is provided, the provided argument is returned</li> <li>If the option should have an argument, and none is
specified, the default value is returned</li> <li>If the option has no argument, and is specified, "true" is
returned</li> <li>If the option has no argument, and is not specifeid, "false" is returned</li> </ul>
|
[
"Returns",
"the",
"effective",
"value",
"for",
"the",
"specified",
"option",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/cli/src/main/java/io/devcon5/cli/OptionInjector.java#L165-L174
|
144,890
|
devcon5io/common
|
cli/src/main/java/io/devcon5/cli/OptionInjector.java
|
OptionInjector.toMap
|
private Map<String, Option> toMap(CommandLine cl) {
final Map<String, Option> opts = new HashMap<>();
for (Option opt : cl.getOptions()) {
opts.put(opt.getOpt(), opt);
}
return opts;
}
|
java
|
private Map<String, Option> toMap(CommandLine cl) {
final Map<String, Option> opts = new HashMap<>();
for (Option opt : cl.getOptions()) {
opts.put(opt.getOpt(), opt);
}
return opts;
}
|
[
"private",
"Map",
"<",
"String",
",",
"Option",
">",
"toMap",
"(",
"CommandLine",
"cl",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Option",
">",
"opts",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Option",
"opt",
":",
"cl",
".",
"getOptions",
"(",
")",
")",
"{",
"opts",
".",
"put",
"(",
"opt",
".",
"getOpt",
"(",
")",
",",
"opt",
")",
";",
"}",
"return",
"opts",
";",
"}"
] |
Creates a map of option short-names to the corresponding option instance.
@param cl
the command line containing the parsed option instances
@return a map of parameter short namese to their corresponding option instance.
|
[
"Creates",
"a",
"map",
"of",
"option",
"short",
"-",
"names",
"to",
"the",
"corresponding",
"option",
"instance",
"."
] |
363688e0dc904d559682bf796bd6c836b4e0efc7
|
https://github.com/devcon5io/common/blob/363688e0dc904d559682bf796bd6c836b4e0efc7/cli/src/main/java/io/devcon5/cli/OptionInjector.java#L226-L232
|
144,891
|
NessComputing/service-discovery
|
client/src/main/java/com/nesscomputing/service/discovery/client/internal/KeyUtil.java
|
KeyUtil.getKeyBytes
|
public static Collection<byte[]> getKeyBytes(Collection<String> keys) {
Collection<byte[]> rv=new ArrayList<byte[]>(keys.size());
for(String s : keys) {
rv.add(getKeyBytes(s));
}
return rv;
}
|
java
|
public static Collection<byte[]> getKeyBytes(Collection<String> keys) {
Collection<byte[]> rv=new ArrayList<byte[]>(keys.size());
for(String s : keys) {
rv.add(getKeyBytes(s));
}
return rv;
}
|
[
"public",
"static",
"Collection",
"<",
"byte",
"[",
"]",
">",
"getKeyBytes",
"(",
"Collection",
"<",
"String",
">",
"keys",
")",
"{",
"Collection",
"<",
"byte",
"[",
"]",
">",
"rv",
"=",
"new",
"ArrayList",
"<",
"byte",
"[",
"]",
">",
"(",
"keys",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"String",
"s",
":",
"keys",
")",
"{",
"rv",
".",
"add",
"(",
"getKeyBytes",
"(",
"s",
")",
")",
";",
"}",
"return",
"rv",
";",
"}"
] |
Get the keys in byte form for all of the string keys.
@param keys a collection of keys
@return return a collection of the byte representations of keys
|
[
"Get",
"the",
"keys",
"in",
"byte",
"form",
"for",
"all",
"of",
"the",
"string",
"keys",
"."
] |
5091ffdb1de6b12d216d1c238f72858037c7b765
|
https://github.com/NessComputing/service-discovery/blob/5091ffdb1de6b12d216d1c238f72858037c7b765/client/src/main/java/com/nesscomputing/service/discovery/client/internal/KeyUtil.java#L47-L53
|
144,892
|
LevelFourAB/commons
|
commons-config/src/main/java/se/l4/commons/config/internal/ConfigResolver.java
|
ConfigResolver.resolve
|
public static Map<String, Object> resolve(Map<String, Object> root)
{
Map<String, Object> newRoot = new HashMap<String, Object>();
resolve(newRoot, root, "");
return newRoot;
}
|
java
|
public static Map<String, Object> resolve(Map<String, Object> root)
{
Map<String, Object> newRoot = new HashMap<String, Object>();
resolve(newRoot, root, "");
return newRoot;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"resolve",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"root",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"newRoot",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"resolve",
"(",
"newRoot",
",",
"root",
",",
"\"\"",
")",
";",
"return",
"newRoot",
";",
"}"
] |
Resolve the specified map and return the resolved map.
@param root
@return
|
[
"Resolve",
"the",
"specified",
"map",
"and",
"return",
"the",
"resolved",
"map",
"."
] |
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
|
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-config/src/main/java/se/l4/commons/config/internal/ConfigResolver.java#L29-L34
|
144,893
|
LevelFourAB/commons
|
commons-config/src/main/java/se/l4/commons/config/internal/ConfigResolver.java
|
ConfigResolver.resolveTo
|
public static Map<String, Object> resolveTo(Map<String, Object> root, Map<String, Object> target)
{
resolve(target, root, "");
return target;
}
|
java
|
public static Map<String, Object> resolveTo(Map<String, Object> root, Map<String, Object> target)
{
resolve(target, root, "");
return target;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"resolveTo",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"root",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"target",
")",
"{",
"resolve",
"(",
"target",
",",
"root",
",",
"\"\"",
")",
";",
"return",
"target",
";",
"}"
] |
Resolve the specified map and store it in the specified target.
@param root
@param target
@return
|
[
"Resolve",
"the",
"specified",
"map",
"and",
"store",
"it",
"in",
"the",
"specified",
"target",
"."
] |
aa121b3a5504b43d0c10450a1b984694fcd2b8ee
|
https://github.com/LevelFourAB/commons/blob/aa121b3a5504b43d0c10450a1b984694fcd2b8ee/commons-config/src/main/java/se/l4/commons/config/internal/ConfigResolver.java#L43-L47
|
144,894
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.debugf
|
public final void debugf(Throwable cause, String message, Object... args)
{
logf(Level.DEBUG, cause, message, args);
}
|
java
|
public final void debugf(Throwable cause, String message, Object... args)
{
logf(Level.DEBUG, cause, message, args);
}
|
[
"public",
"final",
"void",
"debugf",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"DEBUG",
",",
"cause",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message and stack trace if DEBUG logging is enabled.
@param cause an exception to print stack trace of
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string
|
[
"Logs",
"a",
"formatted",
"message",
"and",
"stack",
"trace",
"if",
"DEBUG",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L72-L75
|
144,895
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.debugf
|
public final void debugf(String message, Object... args)
{
logf(Level.DEBUG, null, message, args);
}
|
java
|
public final void debugf(String message, Object... args)
{
logf(Level.DEBUG, null, message, args);
}
|
[
"public",
"final",
"void",
"debugf",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"DEBUG",
",",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message if DEBUG logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string
|
[
"Logs",
"a",
"formatted",
"message",
"if",
"DEBUG",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L83-L86
|
144,896
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.infof
|
public final void infof(Throwable cause, String message, Object... args)
{
logf(Level.INFO, cause, message, args);
}
|
java
|
public final void infof(Throwable cause, String message, Object... args)
{
logf(Level.INFO, cause, message, args);
}
|
[
"public",
"final",
"void",
"infof",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"INFO",
",",
"cause",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message and stack trace if INFO logging is enabled.
@param cause an exception to print stack trace of
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string.
|
[
"Logs",
"a",
"formatted",
"message",
"and",
"stack",
"trace",
"if",
"INFO",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L137-L140
|
144,897
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.infof
|
public final void infof(String message, Object... args)
{
logf(Level.INFO, null, message, args);
}
|
java
|
public final void infof(String message, Object... args)
{
logf(Level.INFO, null, message, args);
}
|
[
"public",
"final",
"void",
"infof",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"INFO",
",",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message if INFO logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string.
|
[
"Logs",
"a",
"formatted",
"message",
"if",
"INFO",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L148-L151
|
144,898
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.warnf
|
public final void warnf(Throwable cause, String message, Object... args)
{
logf(Level.WARN, cause, message, args);
}
|
java
|
public final void warnf(Throwable cause, String message, Object... args)
{
logf(Level.WARN, cause, message, args);
}
|
[
"public",
"final",
"void",
"warnf",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"WARN",
",",
"cause",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message and stack trace if WARN logging is enabled.
@param cause an exception to print stack trace of
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string.
|
[
"Logs",
"a",
"formatted",
"message",
"and",
"stack",
"trace",
"if",
"WARN",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L202-L205
|
144,899
|
twilliamson/mogwee-logging
|
src/main/java/com/mogwee/logging/Logger.java
|
Logger.warnf
|
public final void warnf(String message, Object... args)
{
logf(Level.WARN, null, message, args);
}
|
java
|
public final void warnf(String message, Object... args)
{
logf(Level.WARN, null, message, args);
}
|
[
"public",
"final",
"void",
"warnf",
"(",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"WARN",
",",
"null",
",",
"message",
",",
"args",
")",
";",
"}"
] |
Logs a formatted message if WARN logging is enabled.
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string.
|
[
"Logs",
"a",
"formatted",
"message",
"if",
"WARN",
"logging",
"is",
"enabled",
"."
] |
30b99c2649de455432d956a8f6a74316de4cd62c
|
https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L213-L216
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.