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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
155,900
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMResources.java
|
JMResources.getStringAsOptWithClasspath
|
public static Optional<String> getStringAsOptWithClasspath(
String classpath, String charsetName) {
return getResourceInputStreamAsOpt(classpath)
.map(resourceInputStream -> JMInputStream
.toString(resourceInputStream, charsetName));
}
|
java
|
public static Optional<String> getStringAsOptWithClasspath(
String classpath, String charsetName) {
return getResourceInputStreamAsOpt(classpath)
.map(resourceInputStream -> JMInputStream
.toString(resourceInputStream, charsetName));
}
|
[
"public",
"static",
"Optional",
"<",
"String",
">",
"getStringAsOptWithClasspath",
"(",
"String",
"classpath",
",",
"String",
"charsetName",
")",
"{",
"return",
"getResourceInputStreamAsOpt",
"(",
"classpath",
")",
".",
"map",
"(",
"resourceInputStream",
"->",
"JMInputStream",
".",
"toString",
"(",
"resourceInputStream",
",",
"charsetName",
")",
")",
";",
"}"
] |
Gets string as opt with classpath.
@param classpath the classpath
@param charsetName the charset name
@return the string as opt with classpath
|
[
"Gets",
"string",
"as",
"opt",
"with",
"classpath",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMResources.java#L458-L463
|
155,901
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMResources.java
|
JMResources.getResourceBundle
|
public static ResourceBundle getResourceBundle(String baseName,
Locale targetLocale) {
Locale.setDefault(targetLocale);
return ResourceBundle.getBundle(baseName);
}
|
java
|
public static ResourceBundle getResourceBundle(String baseName,
Locale targetLocale) {
Locale.setDefault(targetLocale);
return ResourceBundle.getBundle(baseName);
}
|
[
"public",
"static",
"ResourceBundle",
"getResourceBundle",
"(",
"String",
"baseName",
",",
"Locale",
"targetLocale",
")",
"{",
"Locale",
".",
"setDefault",
"(",
"targetLocale",
")",
";",
"return",
"ResourceBundle",
".",
"getBundle",
"(",
"baseName",
")",
";",
"}"
] |
Gets resource bundle.
@param baseName the base name
@param targetLocale the target locale
@return the resource bundle
|
[
"Gets",
"resource",
"bundle",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMResources.java#L504-L508
|
155,902
|
G2G3Digital/substeps-framework
|
core/src/main/java/com/technophobia/substeps/parser/FileContents.java
|
FileContents.getSourceLineNumberForOffset
|
public int getSourceLineNumberForOffset(final int offset) {
int lineNumber = -1;
lineNumber = 0;
for (; lineNumber < this.lineStartOffsets.length - 1; lineNumber++) {
if (this.lineStartOffsets[lineNumber + 1] > offset) {
break;
}
}
if (offset > lineStartOffsets[lineStartOffsets.length - 1]) {
lineNumber = lineStartOffsets.length - 1;
}
// we now have line number, but it's 0-based. Need to convert to 1-based
return lineNumber + 1;
}
|
java
|
public int getSourceLineNumberForOffset(final int offset) {
int lineNumber = -1;
lineNumber = 0;
for (; lineNumber < this.lineStartOffsets.length - 1; lineNumber++) {
if (this.lineStartOffsets[lineNumber + 1] > offset) {
break;
}
}
if (offset > lineStartOffsets[lineStartOffsets.length - 1]) {
lineNumber = lineStartOffsets.length - 1;
}
// we now have line number, but it's 0-based. Need to convert to 1-based
return lineNumber + 1;
}
|
[
"public",
"int",
"getSourceLineNumberForOffset",
"(",
"final",
"int",
"offset",
")",
"{",
"int",
"lineNumber",
"=",
"-",
"1",
";",
"lineNumber",
"=",
"0",
";",
"for",
"(",
";",
"lineNumber",
"<",
"this",
".",
"lineStartOffsets",
".",
"length",
"-",
"1",
";",
"lineNumber",
"++",
")",
"{",
"if",
"(",
"this",
".",
"lineStartOffsets",
"[",
"lineNumber",
"+",
"1",
"]",
">",
"offset",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"offset",
">",
"lineStartOffsets",
"[",
"lineStartOffsets",
".",
"length",
"-",
"1",
"]",
")",
"{",
"lineNumber",
"=",
"lineStartOffsets",
".",
"length",
"-",
"1",
";",
"}",
"// we now have line number, but it's 0-based. Need to convert to 1-based",
"return",
"lineNumber",
"+",
"1",
";",
"}"
] |
1st character of the line, it was usually returning the following line
|
[
"1st",
"character",
"of",
"the",
"line",
"it",
"was",
"usually",
"returning",
"the",
"following",
"line"
] |
c1ec6487e1673a7dae54b5e7b62a96f602cd280a
|
https://github.com/G2G3Digital/substeps-framework/blob/c1ec6487e1673a7dae54b5e7b62a96f602cd280a/core/src/main/java/com/technophobia/substeps/parser/FileContents.java#L125-L141
|
155,903
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.addChild
|
public void addChild(Command cmd)
{
if (cmd != null)
{
cmd.setContext(this);
commands.add(cmd);
}
}
|
java
|
public void addChild(Command cmd)
{
if (cmd != null)
{
cmd.setContext(this);
commands.add(cmd);
}
}
|
[
"public",
"void",
"addChild",
"(",
"Command",
"cmd",
")",
"{",
"if",
"(",
"cmd",
"!=",
"null",
")",
"{",
"cmd",
".",
"setContext",
"(",
"this",
")",
";",
"commands",
".",
"add",
"(",
"cmd",
")",
";",
"}",
"}"
] |
add child command
|
[
"add",
"child",
"command"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L115-L122
|
155,904
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.removeChild
|
public void removeChild(Command cmd)
{
if ((cmd != null) && commands.remove(cmd))
{
cmd.setContext(null);
}
}
|
java
|
public void removeChild(Command cmd)
{
if ((cmd != null) && commands.remove(cmd))
{
cmd.setContext(null);
}
}
|
[
"public",
"void",
"removeChild",
"(",
"Command",
"cmd",
")",
"{",
"if",
"(",
"(",
"cmd",
"!=",
"null",
")",
"&&",
"commands",
".",
"remove",
"(",
"cmd",
")",
")",
"{",
"cmd",
".",
"setContext",
"(",
"null",
")",
";",
"}",
"}"
] |
remove child command
|
[
"remove",
"child",
"command"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L125-L131
|
155,905
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.isResolved
|
private boolean isResolved()
{
if (getStatus() < Command.CHILDREN_PROCESSED)
{
return false;
}
for (int i = 0; i < arguments.size(); ++i)
{
Command arg = arguments.elementAt(i);
if (!arg.isResolved())
{
return false;
}
}
for (int j = 0; j < operations.size(); ++j)
{
Command opr = operations.elementAt(j);
if (!opr.isResolved())
{
return false;
}
}
return true;
}
|
java
|
private boolean isResolved()
{
if (getStatus() < Command.CHILDREN_PROCESSED)
{
return false;
}
for (int i = 0; i < arguments.size(); ++i)
{
Command arg = arguments.elementAt(i);
if (!arg.isResolved())
{
return false;
}
}
for (int j = 0; j < operations.size(); ++j)
{
Command opr = operations.elementAt(j);
if (!opr.isResolved())
{
return false;
}
}
return true;
}
|
[
"private",
"boolean",
"isResolved",
"(",
")",
"{",
"if",
"(",
"getStatus",
"(",
")",
"<",
"Command",
".",
"CHILDREN_PROCESSED",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Command",
"arg",
"=",
"arguments",
".",
"elementAt",
"(",
"i",
")",
";",
"if",
"(",
"!",
"arg",
".",
"isResolved",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"operations",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"Command",
"opr",
"=",
"operations",
".",
"elementAt",
"(",
"j",
")",
";",
"if",
"(",
"!",
"opr",
".",
"isResolved",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
check if one of arguments or operations is unresolved
|
[
"check",
"if",
"one",
"of",
"arguments",
"or",
"operations",
"is",
"unresolved"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L140-L165
|
155,906
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.exec
|
public int exec(Map<String, Command> references) throws Exception
{
// System.out.println("in exec() status = " + translateStatus(status) +
// "...");
if (status < Command.CHILDREN_PROCESSED)
{
if (status < Command.COMMAND_EXECUTED)
{
if (status < Command.CHILDREN_FILTERED)
{
status = doBeforeRun(references);
// System.out.println("after doBeforeRun() status = " +
// translateStatus(status));
}
if (status == Command.CHILDREN_FILTERED)
{
status = doRun(references);
// System.out.println("after doRun() status = " +
// translateStatus(status));
}
}
if (status == Command.COMMAND_EXECUTED)
{
status = doAfterRun(references);
// System.out.println("after doAfterRun() status = " +
// translateStatus(status));
}
}
// System.out.println("...out of exec() status = " +
// translateStatus(status));
return status;
}
|
java
|
public int exec(Map<String, Command> references) throws Exception
{
// System.out.println("in exec() status = " + translateStatus(status) +
// "...");
if (status < Command.CHILDREN_PROCESSED)
{
if (status < Command.COMMAND_EXECUTED)
{
if (status < Command.CHILDREN_FILTERED)
{
status = doBeforeRun(references);
// System.out.println("after doBeforeRun() status = " +
// translateStatus(status));
}
if (status == Command.CHILDREN_FILTERED)
{
status = doRun(references);
// System.out.println("after doRun() status = " +
// translateStatus(status));
}
}
if (status == Command.COMMAND_EXECUTED)
{
status = doAfterRun(references);
// System.out.println("after doAfterRun() status = " +
// translateStatus(status));
}
}
// System.out.println("...out of exec() status = " +
// translateStatus(status));
return status;
}
|
[
"public",
"int",
"exec",
"(",
"Map",
"<",
"String",
",",
"Command",
">",
"references",
")",
"throws",
"Exception",
"{",
"// System.out.println(\"in exec() status = \" + translateStatus(status) +",
"// \"...\");",
"if",
"(",
"status",
"<",
"Command",
".",
"CHILDREN_PROCESSED",
")",
"{",
"if",
"(",
"status",
"<",
"Command",
".",
"COMMAND_EXECUTED",
")",
"{",
"if",
"(",
"status",
"<",
"Command",
".",
"CHILDREN_FILTERED",
")",
"{",
"status",
"=",
"doBeforeRun",
"(",
"references",
")",
";",
"// System.out.println(\"after doBeforeRun() status = \" +",
"// translateStatus(status));",
"}",
"if",
"(",
"status",
"==",
"Command",
".",
"CHILDREN_FILTERED",
")",
"{",
"status",
"=",
"doRun",
"(",
"references",
")",
";",
"// System.out.println(\"after doRun() status = \" +",
"// translateStatus(status));",
"}",
"}",
"if",
"(",
"status",
"==",
"Command",
".",
"COMMAND_EXECUTED",
")",
"{",
"status",
"=",
"doAfterRun",
"(",
"references",
")",
";",
"// System.out.println(\"after doAfterRun() status = \" +",
"// translateStatus(status));",
"}",
"}",
"// System.out.println(\"...out of exec() status = \" +",
"// translateStatus(status));",
"return",
"status",
";",
"}"
] |
execute command and return execution flags
|
[
"execute",
"command",
"and",
"return",
"execution",
"flags"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L168-L199
|
155,907
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.backtrack
|
public boolean backtrack(Map<String, Command> references) throws Exception
{
for (int i = 0; i < arguments.size(); ++i)
{
Command arg = arguments.elementAt(i);
arg.backtrack(references);
}
for (int i = 0; i < operations.size(); ++i)
{
Command opr = operations.elementAt(i);
opr.backtrack(references);
}
if (status == Command.CHILDREN_FILTERED)
{
status = doRun(references);
}
if (status == Command.COMMAND_EXECUTED)
{
status = doAfterRun(references);
return (getStatus() == Command.CHILDREN_PROCESSED);
}
return false;
}
|
java
|
public boolean backtrack(Map<String, Command> references) throws Exception
{
for (int i = 0; i < arguments.size(); ++i)
{
Command arg = arguments.elementAt(i);
arg.backtrack(references);
}
for (int i = 0; i < operations.size(); ++i)
{
Command opr = operations.elementAt(i);
opr.backtrack(references);
}
if (status == Command.CHILDREN_FILTERED)
{
status = doRun(references);
}
if (status == Command.COMMAND_EXECUTED)
{
status = doAfterRun(references);
return (getStatus() == Command.CHILDREN_PROCESSED);
}
return false;
}
|
[
"public",
"boolean",
"backtrack",
"(",
"Map",
"<",
"String",
",",
"Command",
">",
"references",
")",
"throws",
"Exception",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Command",
"arg",
"=",
"arguments",
".",
"elementAt",
"(",
"i",
")",
";",
"arg",
".",
"backtrack",
"(",
"references",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"operations",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Command",
"opr",
"=",
"operations",
".",
"elementAt",
"(",
"i",
")",
";",
"opr",
".",
"backtrack",
"(",
"references",
")",
";",
"}",
"if",
"(",
"status",
"==",
"Command",
".",
"CHILDREN_FILTERED",
")",
"{",
"status",
"=",
"doRun",
"(",
"references",
")",
";",
"}",
"if",
"(",
"status",
"==",
"Command",
".",
"COMMAND_EXECUTED",
")",
"{",
"status",
"=",
"doAfterRun",
"(",
"references",
")",
";",
"return",
"(",
"getStatus",
"(",
")",
"==",
"Command",
".",
"CHILDREN_PROCESSED",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
execute commands in backtrack order
|
[
"execute",
"commands",
"in",
"backtrack",
"order"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L202-L224
|
155,908
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.doBeforeRun
|
private int doBeforeRun(Map<String, Command> references) throws Exception
{
if (status == Command.INITIALIZED)
{
for (int i = 0; i < commands.size(); ++i)
{
Command cmd = commands.elementAt(i);
// XXX is this correct?
if (cmd.isExecutable())
{
arguments.add(cmd);
}
else
{
operations.add(cmd);
}
}
return Command.CHILDREN_FILTERED;
}
return status;
}
|
java
|
private int doBeforeRun(Map<String, Command> references) throws Exception
{
if (status == Command.INITIALIZED)
{
for (int i = 0; i < commands.size(); ++i)
{
Command cmd = commands.elementAt(i);
// XXX is this correct?
if (cmd.isExecutable())
{
arguments.add(cmd);
}
else
{
operations.add(cmd);
}
}
return Command.CHILDREN_FILTERED;
}
return status;
}
|
[
"private",
"int",
"doBeforeRun",
"(",
"Map",
"<",
"String",
",",
"Command",
">",
"references",
")",
"throws",
"Exception",
"{",
"if",
"(",
"status",
"==",
"Command",
".",
"INITIALIZED",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"commands",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Command",
"cmd",
"=",
"commands",
".",
"elementAt",
"(",
"i",
")",
";",
"// XXX is this correct?",
"if",
"(",
"cmd",
".",
"isExecutable",
"(",
")",
")",
"{",
"arguments",
".",
"add",
"(",
"cmd",
")",
";",
"}",
"else",
"{",
"operations",
".",
"add",
"(",
"cmd",
")",
";",
"}",
"}",
"return",
"Command",
".",
"CHILDREN_FILTERED",
";",
"}",
"return",
"status",
";",
"}"
] |
put command in one of two collections - arguments or operations
|
[
"put",
"command",
"in",
"one",
"of",
"two",
"collections",
"-",
"arguments",
"or",
"operations"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L227-L248
|
155,909
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.doAfterRun
|
private int doAfterRun(Map<String, Command> references) throws Exception
{
if (status == Command.COMMAND_EXECUTED)
{
// System.out.println("doAfterRun(): command " + getResultType() + "
// processed...");
Vector<Command> toBeRemoved = new Vector<Command>();
try
{
Statement[] statements = null;
for (int i = 0; i < operations.size(); ++i)
{
Command cmd = operations.elementAt(i);
if (cmd.isArrayElement())
{
if (cmd.isResolved())
{
if (statements == null)
{
statements = new Statement[operations.size()];
}
statements[i] = new Statement(getResultValue(), "set", new Object[] { Integer.valueOf(i), //$NON-NLS-1$
cmd.getResultValue() });
if ((i + 1) == operations.size())
{
for (int j = 0; j < operations.size(); ++j)
{
statements[j].execute();
}
toBeRemoved.addAll(operations);
}
}
else
{
break;
}
}
else
{
// since the call is Array.set()
if (!isArray())
{
cmd.setTarget(getResultValue());
}
cmd.exec(references);
if (cmd.isResolved())
{
// System.out.println("doAfterRun(): cmd = " +
// cmd.methodName + " is resolved");
toBeRemoved.add(cmd);
}
else
{
// System.out.println("doAfterRun(): cmd = " +
// cmd.methodName + " is unresolved");
break;
}
}
}
}
catch (Exception e)
{
throw new Exception(e);
}
finally
{
operations.removeAll(toBeRemoved);
}
// if (operations.size() == 0) {
// System.out.println("doAfterRun(): command " + getResultType()
// + " completely processed.");
// } else {
// System.out.println("doAfterRun(): command " + getResultType()
// + " contains incomplete " +
// operations.size() + " commands.");
// }
return (operations.size() == 0) ? Command.CHILDREN_PROCESSED : status;
}
return status;
}
|
java
|
private int doAfterRun(Map<String, Command> references) throws Exception
{
if (status == Command.COMMAND_EXECUTED)
{
// System.out.println("doAfterRun(): command " + getResultType() + "
// processed...");
Vector<Command> toBeRemoved = new Vector<Command>();
try
{
Statement[] statements = null;
for (int i = 0; i < operations.size(); ++i)
{
Command cmd = operations.elementAt(i);
if (cmd.isArrayElement())
{
if (cmd.isResolved())
{
if (statements == null)
{
statements = new Statement[operations.size()];
}
statements[i] = new Statement(getResultValue(), "set", new Object[] { Integer.valueOf(i), //$NON-NLS-1$
cmd.getResultValue() });
if ((i + 1) == operations.size())
{
for (int j = 0; j < operations.size(); ++j)
{
statements[j].execute();
}
toBeRemoved.addAll(operations);
}
}
else
{
break;
}
}
else
{
// since the call is Array.set()
if (!isArray())
{
cmd.setTarget(getResultValue());
}
cmd.exec(references);
if (cmd.isResolved())
{
// System.out.println("doAfterRun(): cmd = " +
// cmd.methodName + " is resolved");
toBeRemoved.add(cmd);
}
else
{
// System.out.println("doAfterRun(): cmd = " +
// cmd.methodName + " is unresolved");
break;
}
}
}
}
catch (Exception e)
{
throw new Exception(e);
}
finally
{
operations.removeAll(toBeRemoved);
}
// if (operations.size() == 0) {
// System.out.println("doAfterRun(): command " + getResultType()
// + " completely processed.");
// } else {
// System.out.println("doAfterRun(): command " + getResultType()
// + " contains incomplete " +
// operations.size() + " commands.");
// }
return (operations.size() == 0) ? Command.CHILDREN_PROCESSED : status;
}
return status;
}
|
[
"private",
"int",
"doAfterRun",
"(",
"Map",
"<",
"String",
",",
"Command",
">",
"references",
")",
"throws",
"Exception",
"{",
"if",
"(",
"status",
"==",
"Command",
".",
"COMMAND_EXECUTED",
")",
"{",
"// System.out.println(\"doAfterRun(): command \" + getResultType() + \"",
"// processed...\");",
"Vector",
"<",
"Command",
">",
"toBeRemoved",
"=",
"new",
"Vector",
"<",
"Command",
">",
"(",
")",
";",
"try",
"{",
"Statement",
"[",
"]",
"statements",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"operations",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"Command",
"cmd",
"=",
"operations",
".",
"elementAt",
"(",
"i",
")",
";",
"if",
"(",
"cmd",
".",
"isArrayElement",
"(",
")",
")",
"{",
"if",
"(",
"cmd",
".",
"isResolved",
"(",
")",
")",
"{",
"if",
"(",
"statements",
"==",
"null",
")",
"{",
"statements",
"=",
"new",
"Statement",
"[",
"operations",
".",
"size",
"(",
")",
"]",
";",
"}",
"statements",
"[",
"i",
"]",
"=",
"new",
"Statement",
"(",
"getResultValue",
"(",
")",
",",
"\"set\"",
",",
"new",
"Object",
"[",
"]",
"{",
"Integer",
".",
"valueOf",
"(",
"i",
")",
",",
"//$NON-NLS-1$",
"cmd",
".",
"getResultValue",
"(",
")",
"}",
")",
";",
"if",
"(",
"(",
"i",
"+",
"1",
")",
"==",
"operations",
".",
"size",
"(",
")",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"operations",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"statements",
"[",
"j",
"]",
".",
"execute",
"(",
")",
";",
"}",
"toBeRemoved",
".",
"addAll",
"(",
"operations",
")",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"else",
"{",
"// since the call is Array.set()",
"if",
"(",
"!",
"isArray",
"(",
")",
")",
"{",
"cmd",
".",
"setTarget",
"(",
"getResultValue",
"(",
")",
")",
";",
"}",
"cmd",
".",
"exec",
"(",
"references",
")",
";",
"if",
"(",
"cmd",
".",
"isResolved",
"(",
")",
")",
"{",
"// System.out.println(\"doAfterRun(): cmd = \" +",
"// cmd.methodName + \" is resolved\");",
"toBeRemoved",
".",
"add",
"(",
"cmd",
")",
";",
"}",
"else",
"{",
"// System.out.println(\"doAfterRun(): cmd = \" +",
"// cmd.methodName + \" is unresolved\");",
"break",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"operations",
".",
"removeAll",
"(",
"toBeRemoved",
")",
";",
"}",
"// if (operations.size() == 0) {",
"// System.out.println(\"doAfterRun(): command \" + getResultType()",
"// + \" completely processed.\");",
"// } else {",
"// System.out.println(\"doAfterRun(): command \" + getResultType()",
"// + \" contains incomplete \" +",
"// operations.size() + \" commands.\");",
"// }",
"return",
"(",
"operations",
".",
"size",
"(",
")",
"==",
"0",
")",
"?",
"Command",
".",
"CHILDREN_PROCESSED",
":",
"status",
";",
"}",
"return",
"status",
";",
"}"
] |
run child commands
|
[
"run",
"child",
"commands"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L331-L418
|
155,910
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.isExecutable
|
public boolean isExecutable()
{
boolean result = isTag("object") || isTag("void") && hasAttr("class") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
&& hasAttr("method") || isTag("array") || isPrimitive() //$NON-NLS-1$ //$NON-NLS-2$
|| isTag("class") || isTag("null"); //$NON-NLS-1$ //$NON-NLS-2$
return result;
}
|
java
|
public boolean isExecutable()
{
boolean result = isTag("object") || isTag("void") && hasAttr("class") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
&& hasAttr("method") || isTag("array") || isPrimitive() //$NON-NLS-1$ //$NON-NLS-2$
|| isTag("class") || isTag("null"); //$NON-NLS-1$ //$NON-NLS-2$
return result;
}
|
[
"public",
"boolean",
"isExecutable",
"(",
")",
"{",
"boolean",
"result",
"=",
"isTag",
"(",
"\"object\"",
")",
"||",
"isTag",
"(",
"\"void\"",
")",
"&&",
"hasAttr",
"(",
"\"class\"",
")",
"//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$",
"&&",
"hasAttr",
"(",
"\"method\"",
")",
"||",
"isTag",
"(",
"\"array\"",
")",
"||",
"isPrimitive",
"(",
")",
"//$NON-NLS-1$ //$NON-NLS-2$",
"||",
"isTag",
"(",
"\"class\"",
")",
"||",
"isTag",
"(",
"\"null\"",
")",
";",
"//$NON-NLS-1$ //$NON-NLS-2$",
"return",
"result",
";",
"}"
] |
Checks if the command could generate object
|
[
"Checks",
"if",
"the",
"command",
"could",
"generate",
"object"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L533-L539
|
155,911
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.getTarget
|
private Object getTarget(Map<String, Command> references) throws Exception
{
if (target == null)
{
if (isReference())
{
Command cmd = references.get(getAttr("idref")); //$NON-NLS-1$
target = (cmd != null) ? cmd.getResultValue() : null;
}
else if (isExecutable())
{
String className = null;
if (isPrimitive())
{
className = getPrimitiveClassName(tagName);
}
else if (isTag("class")) { //$NON-NLS-1$
className = getPrimitiveClassName(tagName);
}
else if (isConstructor() || isStaticMethod() || isField())
{
className = getAttr("class"); //$NON-NLS-1$
}
else if (isArray())
{
className = getAttr("class"); //$NON-NLS-1$
Class<?> componentType = isPrimitiveClassName(className) ? getPrimitiveClass(className) : Class.forName(className, true, Thread
.currentThread().getContextClassLoader());
className = Array.newInstance(componentType, 0).getClass().getName();
}
if (className != null)
{
try
{
target = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException e)
{
target = Class.forName(className);
}
if (isField())
{
String fieldName = getAttr("field"); //$NON-NLS-1$
target = ((Class<?>) target).getField(fieldName);
}
}
else
{
throw new Exception(Messages.getString("beans.42", className)); //$NON-NLS-1$
}
}
else if (ctx.isArray())
{
// target = ctx.getTarget(references);
target = Class.forName("java.lang.reflect.Array"); //$NON-NLS-1$
}
}
return target;
}
|
java
|
private Object getTarget(Map<String, Command> references) throws Exception
{
if (target == null)
{
if (isReference())
{
Command cmd = references.get(getAttr("idref")); //$NON-NLS-1$
target = (cmd != null) ? cmd.getResultValue() : null;
}
else if (isExecutable())
{
String className = null;
if (isPrimitive())
{
className = getPrimitiveClassName(tagName);
}
else if (isTag("class")) { //$NON-NLS-1$
className = getPrimitiveClassName(tagName);
}
else if (isConstructor() || isStaticMethod() || isField())
{
className = getAttr("class"); //$NON-NLS-1$
}
else if (isArray())
{
className = getAttr("class"); //$NON-NLS-1$
Class<?> componentType = isPrimitiveClassName(className) ? getPrimitiveClass(className) : Class.forName(className, true, Thread
.currentThread().getContextClassLoader());
className = Array.newInstance(componentType, 0).getClass().getName();
}
if (className != null)
{
try
{
target = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException e)
{
target = Class.forName(className);
}
if (isField())
{
String fieldName = getAttr("field"); //$NON-NLS-1$
target = ((Class<?>) target).getField(fieldName);
}
}
else
{
throw new Exception(Messages.getString("beans.42", className)); //$NON-NLS-1$
}
}
else if (ctx.isArray())
{
// target = ctx.getTarget(references);
target = Class.forName("java.lang.reflect.Array"); //$NON-NLS-1$
}
}
return target;
}
|
[
"private",
"Object",
"getTarget",
"(",
"Map",
"<",
"String",
",",
"Command",
">",
"references",
")",
"throws",
"Exception",
"{",
"if",
"(",
"target",
"==",
"null",
")",
"{",
"if",
"(",
"isReference",
"(",
")",
")",
"{",
"Command",
"cmd",
"=",
"references",
".",
"get",
"(",
"getAttr",
"(",
"\"idref\"",
")",
")",
";",
"//$NON-NLS-1$",
"target",
"=",
"(",
"cmd",
"!=",
"null",
")",
"?",
"cmd",
".",
"getResultValue",
"(",
")",
":",
"null",
";",
"}",
"else",
"if",
"(",
"isExecutable",
"(",
")",
")",
"{",
"String",
"className",
"=",
"null",
";",
"if",
"(",
"isPrimitive",
"(",
")",
")",
"{",
"className",
"=",
"getPrimitiveClassName",
"(",
"tagName",
")",
";",
"}",
"else",
"if",
"(",
"isTag",
"(",
"\"class\"",
")",
")",
"{",
"//$NON-NLS-1$",
"className",
"=",
"getPrimitiveClassName",
"(",
"tagName",
")",
";",
"}",
"else",
"if",
"(",
"isConstructor",
"(",
")",
"||",
"isStaticMethod",
"(",
")",
"||",
"isField",
"(",
")",
")",
"{",
"className",
"=",
"getAttr",
"(",
"\"class\"",
")",
";",
"//$NON-NLS-1$",
"}",
"else",
"if",
"(",
"isArray",
"(",
")",
")",
"{",
"className",
"=",
"getAttr",
"(",
"\"class\"",
")",
";",
"//$NON-NLS-1$",
"Class",
"<",
"?",
">",
"componentType",
"=",
"isPrimitiveClassName",
"(",
"className",
")",
"?",
"getPrimitiveClass",
"(",
"className",
")",
":",
"Class",
".",
"forName",
"(",
"className",
",",
"true",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"className",
"=",
"Array",
".",
"newInstance",
"(",
"componentType",
",",
"0",
")",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"className",
"!=",
"null",
")",
"{",
"try",
"{",
"target",
"=",
"Class",
".",
"forName",
"(",
"className",
",",
"true",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"target",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"}",
"if",
"(",
"isField",
"(",
")",
")",
"{",
"String",
"fieldName",
"=",
"getAttr",
"(",
"\"field\"",
")",
";",
"//$NON-NLS-1$",
"target",
"=",
"(",
"(",
"Class",
"<",
"?",
">",
")",
"target",
")",
".",
"getField",
"(",
"fieldName",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.42\"",
",",
"className",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"}",
"else",
"if",
"(",
"ctx",
".",
"isArray",
"(",
")",
")",
"{",
"// target = ctx.getTarget(references);",
"target",
"=",
"Class",
".",
"forName",
"(",
"\"java.lang.reflect.Array\"",
")",
";",
"//$NON-NLS-1$",
"}",
"}",
"return",
"target",
";",
"}"
] |
get a target through tag and attrs analysis
|
[
"get",
"a",
"target",
"through",
"tag",
"and",
"attrs",
"analysis"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L547-L608
|
155,912
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.getArguments
|
private Argument[] getArguments()
{
Argument[] args = new Argument[auxArguments.size() + arguments.size()];
for (int i = 0; i < auxArguments.size(); ++i)
{
args[i] = auxArguments.elementAt(i);
}
for (int j = 0; j < arguments.size(); ++j)
{
Command cmd = arguments.elementAt(j);
if (cmd.getStatus() >= Command.COMMAND_EXECUTED)
{
args[auxArguments.size() + j] = cmd.getResult();
}
else
{
// System.out.println("arg: " + cmd.getResultValue());
args = null;
break;
}
}
return args;
}
|
java
|
private Argument[] getArguments()
{
Argument[] args = new Argument[auxArguments.size() + arguments.size()];
for (int i = 0; i < auxArguments.size(); ++i)
{
args[i] = auxArguments.elementAt(i);
}
for (int j = 0; j < arguments.size(); ++j)
{
Command cmd = arguments.elementAt(j);
if (cmd.getStatus() >= Command.COMMAND_EXECUTED)
{
args[auxArguments.size() + j] = cmd.getResult();
}
else
{
// System.out.println("arg: " + cmd.getResultValue());
args = null;
break;
}
}
return args;
}
|
[
"private",
"Argument",
"[",
"]",
"getArguments",
"(",
")",
"{",
"Argument",
"[",
"]",
"args",
"=",
"new",
"Argument",
"[",
"auxArguments",
".",
"size",
"(",
")",
"+",
"arguments",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"auxArguments",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"args",
"[",
"i",
"]",
"=",
"auxArguments",
".",
"elementAt",
"(",
"i",
")",
";",
"}",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"arguments",
".",
"size",
"(",
")",
";",
"++",
"j",
")",
"{",
"Command",
"cmd",
"=",
"arguments",
".",
"elementAt",
"(",
"j",
")",
";",
"if",
"(",
"cmd",
".",
"getStatus",
"(",
")",
">=",
"Command",
".",
"COMMAND_EXECUTED",
")",
"{",
"args",
"[",
"auxArguments",
".",
"size",
"(",
")",
"+",
"j",
"]",
"=",
"cmd",
".",
"getResult",
"(",
")",
";",
"}",
"else",
"{",
"// System.out.println(\"arg: \" + cmd.getResultValue());",
"args",
"=",
"null",
";",
"break",
";",
"}",
"}",
"return",
"args",
";",
"}"
] |
return a list of arguments as of Argument type
|
[
"return",
"a",
"list",
"of",
"arguments",
"as",
"of",
"Argument",
"type"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L753-L777
|
155,913
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.getArgumentsValues
|
private Object[] getArgumentsValues()
{
Argument[] args = getArguments();
Object[] result = new Object[args.length];
for (int i = 0; i < args.length; ++i)
{
result[i] = args[i].getValue();
}
return result;
}
|
java
|
private Object[] getArgumentsValues()
{
Argument[] args = getArguments();
Object[] result = new Object[args.length];
for (int i = 0; i < args.length; ++i)
{
result[i] = args[i].getValue();
}
return result;
}
|
[
"private",
"Object",
"[",
"]",
"getArgumentsValues",
"(",
")",
"{",
"Argument",
"[",
"]",
"args",
"=",
"getArguments",
"(",
")",
";",
"Object",
"[",
"]",
"result",
"=",
"new",
"Object",
"[",
"args",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"++",
"i",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"args",
"[",
"i",
"]",
".",
"getValue",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
return argument values
|
[
"return",
"argument",
"values"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L780-L789
|
155,914
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.copyArgumentsToCommands
|
private void copyArgumentsToCommands()
{
Iterator<Command> i = arguments.iterator();
while (i.hasNext())
{
Command cmd = i.next();
cmd.status = Command.CHILDREN_FILTERED;
operations.add(cmd);
}
arguments.clear();
}
|
java
|
private void copyArgumentsToCommands()
{
Iterator<Command> i = arguments.iterator();
while (i.hasNext())
{
Command cmd = i.next();
cmd.status = Command.CHILDREN_FILTERED;
operations.add(cmd);
}
arguments.clear();
}
|
[
"private",
"void",
"copyArgumentsToCommands",
"(",
")",
"{",
"Iterator",
"<",
"Command",
">",
"i",
"=",
"arguments",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"Command",
"cmd",
"=",
"i",
".",
"next",
"(",
")",
";",
"cmd",
".",
"status",
"=",
"Command",
".",
"CHILDREN_FILTERED",
";",
"operations",
".",
"add",
"(",
"cmd",
")",
";",
"}",
"arguments",
".",
"clear",
"(",
")",
";",
"}"
] |
copy arguments to treat as commands
|
[
"copy",
"arguments",
"to",
"treat",
"as",
"commands"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L792-L802
|
155,915
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.isPrimitiveClassName
|
public static boolean isPrimitiveClassName(String className)
{
return className.equalsIgnoreCase("boolean") //$NON-NLS-1$
|| className.equalsIgnoreCase("byte") //$NON-NLS-1$
|| className.equalsIgnoreCase("char") //$NON-NLS-1$
|| className.equalsIgnoreCase("short") //$NON-NLS-1$
|| className.equalsIgnoreCase("int") //$NON-NLS-1$
|| className.equalsIgnoreCase("long") //$NON-NLS-1$
|| className.equalsIgnoreCase("float") //$NON-NLS-1$
|| className.equalsIgnoreCase("double") //$NON-NLS-1$
|| className.equalsIgnoreCase("string"); //$NON-NLS-1$
}
|
java
|
public static boolean isPrimitiveClassName(String className)
{
return className.equalsIgnoreCase("boolean") //$NON-NLS-1$
|| className.equalsIgnoreCase("byte") //$NON-NLS-1$
|| className.equalsIgnoreCase("char") //$NON-NLS-1$
|| className.equalsIgnoreCase("short") //$NON-NLS-1$
|| className.equalsIgnoreCase("int") //$NON-NLS-1$
|| className.equalsIgnoreCase("long") //$NON-NLS-1$
|| className.equalsIgnoreCase("float") //$NON-NLS-1$
|| className.equalsIgnoreCase("double") //$NON-NLS-1$
|| className.equalsIgnoreCase("string"); //$NON-NLS-1$
}
|
[
"public",
"static",
"boolean",
"isPrimitiveClassName",
"(",
"String",
"className",
")",
"{",
"return",
"className",
".",
"equalsIgnoreCase",
"(",
"\"boolean\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"byte\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"char\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"short\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"int\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"long\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"float\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"double\"",
")",
"//$NON-NLS-1$",
"||",
"className",
".",
"equalsIgnoreCase",
"(",
"\"string\"",
")",
";",
"//$NON-NLS-1$",
"}"
] |
Check if the name of class is primitive
|
[
"Check",
"if",
"the",
"name",
"of",
"class",
"is",
"primitive"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L822-L833
|
155,916
|
app55/app55-java
|
src/support/java/org/apache/harmony/beans/Command.java
|
Command.getPrimitiveClassName
|
private String getPrimitiveClassName(String data)
{
String shortClassName = null;
if (data.equals("int")) { //$NON-NLS-1$
shortClassName = "Integer"; //$NON-NLS-1$
}
else if (data.equals("char")) { //$NON-NLS-1$
shortClassName = "Character"; //$NON-NLS-1$
}
else
{
shortClassName = data.substring(0, 1).toUpperCase() + data.substring(1, data.length());
}
return "java.lang." + shortClassName; //$NON-NLS-1$
}
|
java
|
private String getPrimitiveClassName(String data)
{
String shortClassName = null;
if (data.equals("int")) { //$NON-NLS-1$
shortClassName = "Integer"; //$NON-NLS-1$
}
else if (data.equals("char")) { //$NON-NLS-1$
shortClassName = "Character"; //$NON-NLS-1$
}
else
{
shortClassName = data.substring(0, 1).toUpperCase() + data.substring(1, data.length());
}
return "java.lang." + shortClassName; //$NON-NLS-1$
}
|
[
"private",
"String",
"getPrimitiveClassName",
"(",
"String",
"data",
")",
"{",
"String",
"shortClassName",
"=",
"null",
";",
"if",
"(",
"data",
".",
"equals",
"(",
"\"int\"",
")",
")",
"{",
"//$NON-NLS-1$",
"shortClassName",
"=",
"\"Integer\"",
";",
"//$NON-NLS-1$",
"}",
"else",
"if",
"(",
"data",
".",
"equals",
"(",
"\"char\"",
")",
")",
"{",
"//$NON-NLS-1$",
"shortClassName",
"=",
"\"Character\"",
";",
"//$NON-NLS-1$",
"}",
"else",
"{",
"shortClassName",
"=",
"data",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"data",
".",
"substring",
"(",
"1",
",",
"data",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"\"java.lang.\"",
"+",
"shortClassName",
";",
"//$NON-NLS-1$",
"}"
] |
Transforms a primitive class name
|
[
"Transforms",
"a",
"primitive",
"class",
"name"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Command.java#L836-L850
|
155,917
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/LongConverter.java
|
LongConverter.toLongWithDefault
|
public static long toLongWithDefault(Object value, long defaultValue) {
Long result = toNullableLong(value);
return result != null ? (long) result : defaultValue;
}
|
java
|
public static long toLongWithDefault(Object value, long defaultValue) {
Long result = toNullableLong(value);
return result != null ? (long) result : defaultValue;
}
|
[
"public",
"static",
"long",
"toLongWithDefault",
"(",
"Object",
"value",
",",
"long",
"defaultValue",
")",
"{",
"Long",
"result",
"=",
"toNullableLong",
"(",
"value",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"(",
"long",
")",
"result",
":",
"defaultValue",
";",
"}"
] |
Converts value into integer or returns default when conversion is not
possible.
@param value the value to convert.
@param defaultValue the default value.
@return long value or default when conversion is not supported
@see LongConverter#toNullableLong(Object)
|
[
"Converts",
"value",
"into",
"integer",
"or",
"returns",
"default",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/LongConverter.java#L90-L93
|
155,918
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/chr/CharReader.java
|
CharReader.read
|
public Char read() throws IOException {
int cp = in.read();
if (cp < 0) {
return null;
}
if (cp == '\033') {
// We have received an 'esc' and nothing else...
if (!in.ready()) {
return new Unicode(cp);
}
// 'esc' was last char in stream.
int c2 = in.read();
if (c2 < 0) {
return new Unicode(cp);
}
StringBuilder charBuilder = new StringBuilder();
charBuilder.append((char) cp);
charBuilder.append((char) c2);
if (c2 == '\033') {
// Treat double 'esc' as a single 'esc'. Otherwise pressing 'esc'
// will consistently crash the application.
return new Unicode(cp);
} else if (c2 == '[') {
char c3 = expect();
charBuilder.append(c3);
if ('A' <= c3 && c3 <= 'Z') {
// \033 [ A-Z
return new Control(charBuilder.toString());
}
while (('0' <= c3 && c3 <= '9') || c3 == ';') {
c3 = expect();
charBuilder.append(c3);
}
if (c3 == '~' ||
('a' <= c3 && c3 <= 'z') ||
('A' <= c3 && c3 <= 'Z')) {
// \033 [ (number) ~ (F1, F2 ... Fx)
// \033 [ (number...;) [A-D] (numbered cursor movement)
// \033 [ (number...;) [su] (cursor save / restore, ...)
// \033 [ (number...;) m (color)
if (c3 == 'm') {
try {
return new Color(charBuilder.toString());
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage(), e);
}
}
return new Control(charBuilder.toString());
}
} else if (c2 == 'O') {
char c3 = expect();
charBuilder.append(c3);
if ('A' <= c3 && c3 <= 'Z') {
// \033 O [A-Z]
return new Control(charBuilder.toString());
}
} else if (('a' <= c2 && c2 <= 'z') ||
('0' <= c2 && c2 <= '9') ||
('A' <= c2 && c2 <= 'Z')) {
// \033 [a-z]: <alt-{c}> aka <M-{c}>.
// \033 [0-9]: <alt-{c}> aka <M-{c}>.
// \033 [A-N]: <alt-shift-{c}> aka <M-S-{c}>.
// \033 [P-Z]: <alt-shift-{c}> aka <M-S-{c}>.
return new Control(charBuilder.toString());
}
throw new IOException("Invalid escape sequence: \"" + Strings.escape(charBuilder.toString()) + "\"");
} else {
// Make sure to consume both surrogates on 32-bit code-points.
if (Character.isHighSurrogate((char) cp)) {
cp = Character.toCodePoint((char) cp, expect());
}
return new Unicode(cp);
}
}
|
java
|
public Char read() throws IOException {
int cp = in.read();
if (cp < 0) {
return null;
}
if (cp == '\033') {
// We have received an 'esc' and nothing else...
if (!in.ready()) {
return new Unicode(cp);
}
// 'esc' was last char in stream.
int c2 = in.read();
if (c2 < 0) {
return new Unicode(cp);
}
StringBuilder charBuilder = new StringBuilder();
charBuilder.append((char) cp);
charBuilder.append((char) c2);
if (c2 == '\033') {
// Treat double 'esc' as a single 'esc'. Otherwise pressing 'esc'
// will consistently crash the application.
return new Unicode(cp);
} else if (c2 == '[') {
char c3 = expect();
charBuilder.append(c3);
if ('A' <= c3 && c3 <= 'Z') {
// \033 [ A-Z
return new Control(charBuilder.toString());
}
while (('0' <= c3 && c3 <= '9') || c3 == ';') {
c3 = expect();
charBuilder.append(c3);
}
if (c3 == '~' ||
('a' <= c3 && c3 <= 'z') ||
('A' <= c3 && c3 <= 'Z')) {
// \033 [ (number) ~ (F1, F2 ... Fx)
// \033 [ (number...;) [A-D] (numbered cursor movement)
// \033 [ (number...;) [su] (cursor save / restore, ...)
// \033 [ (number...;) m (color)
if (c3 == 'm') {
try {
return new Color(charBuilder.toString());
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage(), e);
}
}
return new Control(charBuilder.toString());
}
} else if (c2 == 'O') {
char c3 = expect();
charBuilder.append(c3);
if ('A' <= c3 && c3 <= 'Z') {
// \033 O [A-Z]
return new Control(charBuilder.toString());
}
} else if (('a' <= c2 && c2 <= 'z') ||
('0' <= c2 && c2 <= '9') ||
('A' <= c2 && c2 <= 'Z')) {
// \033 [a-z]: <alt-{c}> aka <M-{c}>.
// \033 [0-9]: <alt-{c}> aka <M-{c}>.
// \033 [A-N]: <alt-shift-{c}> aka <M-S-{c}>.
// \033 [P-Z]: <alt-shift-{c}> aka <M-S-{c}>.
return new Control(charBuilder.toString());
}
throw new IOException("Invalid escape sequence: \"" + Strings.escape(charBuilder.toString()) + "\"");
} else {
// Make sure to consume both surrogates on 32-bit code-points.
if (Character.isHighSurrogate((char) cp)) {
cp = Character.toCodePoint((char) cp, expect());
}
return new Unicode(cp);
}
}
|
[
"public",
"Char",
"read",
"(",
")",
"throws",
"IOException",
"{",
"int",
"cp",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"cp",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"cp",
"==",
"'",
"'",
")",
"{",
"// We have received an 'esc' and nothing else...",
"if",
"(",
"!",
"in",
".",
"ready",
"(",
")",
")",
"{",
"return",
"new",
"Unicode",
"(",
"cp",
")",
";",
"}",
"// 'esc' was last char in stream.",
"int",
"c2",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"c2",
"<",
"0",
")",
"{",
"return",
"new",
"Unicode",
"(",
"cp",
")",
";",
"}",
"StringBuilder",
"charBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"charBuilder",
".",
"append",
"(",
"(",
"char",
")",
"cp",
")",
";",
"charBuilder",
".",
"append",
"(",
"(",
"char",
")",
"c2",
")",
";",
"if",
"(",
"c2",
"==",
"'",
"'",
")",
"{",
"// Treat double 'esc' as a single 'esc'. Otherwise pressing 'esc'",
"// will consistently crash the application.",
"return",
"new",
"Unicode",
"(",
"cp",
")",
";",
"}",
"else",
"if",
"(",
"c2",
"==",
"'",
"'",
")",
"{",
"char",
"c3",
"=",
"expect",
"(",
")",
";",
"charBuilder",
".",
"append",
"(",
"c3",
")",
";",
"if",
"(",
"'",
"'",
"<=",
"c3",
"&&",
"c3",
"<=",
"'",
"'",
")",
"{",
"// \\033 [ A-Z",
"return",
"new",
"Control",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
";",
"}",
"while",
"(",
"(",
"'",
"'",
"<=",
"c3",
"&&",
"c3",
"<=",
"'",
"'",
")",
"||",
"c3",
"==",
"'",
"'",
")",
"{",
"c3",
"=",
"expect",
"(",
")",
";",
"charBuilder",
".",
"append",
"(",
"c3",
")",
";",
"}",
"if",
"(",
"c3",
"==",
"'",
"'",
"||",
"(",
"'",
"'",
"<=",
"c3",
"&&",
"c3",
"<=",
"'",
"'",
")",
"||",
"(",
"'",
"'",
"<=",
"c3",
"&&",
"c3",
"<=",
"'",
"'",
")",
")",
"{",
"// \\033 [ (number) ~ (F1, F2 ... Fx)",
"// \\033 [ (number...;) [A-D] (numbered cursor movement)",
"// \\033 [ (number...;) [su] (cursor save / restore, ...)",
"// \\033 [ (number...;) m (color)",
"if",
"(",
"c3",
"==",
"'",
"'",
")",
"{",
"try",
"{",
"return",
"new",
"Color",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"return",
"new",
"Control",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"c2",
"==",
"'",
"'",
")",
"{",
"char",
"c3",
"=",
"expect",
"(",
")",
";",
"charBuilder",
".",
"append",
"(",
"c3",
")",
";",
"if",
"(",
"'",
"'",
"<=",
"c3",
"&&",
"c3",
"<=",
"'",
"'",
")",
"{",
"// \\033 O [A-Z]",
"return",
"new",
"Control",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"(",
"'",
"'",
"<=",
"c2",
"&&",
"c2",
"<=",
"'",
"'",
")",
"||",
"(",
"'",
"'",
"<=",
"c2",
"&&",
"c2",
"<=",
"'",
"'",
")",
"||",
"(",
"'",
"'",
"<=",
"c2",
"&&",
"c2",
"<=",
"'",
"'",
")",
")",
"{",
"// \\033 [a-z]: <alt-{c}> aka <M-{c}>.",
"// \\033 [0-9]: <alt-{c}> aka <M-{c}>.",
"// \\033 [A-N]: <alt-shift-{c}> aka <M-S-{c}>.",
"// \\033 [P-Z]: <alt-shift-{c}> aka <M-S-{c}>.",
"return",
"new",
"Control",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"IOException",
"(",
"\"Invalid escape sequence: \\\"\"",
"+",
"Strings",
".",
"escape",
"(",
"charBuilder",
".",
"toString",
"(",
")",
")",
"+",
"\"\\\"\"",
")",
";",
"}",
"else",
"{",
"// Make sure to consume both surrogates on 32-bit code-points.",
"if",
"(",
"Character",
".",
"isHighSurrogate",
"(",
"(",
"char",
")",
"cp",
")",
")",
"{",
"cp",
"=",
"Character",
".",
"toCodePoint",
"(",
"(",
"char",
")",
"cp",
",",
"expect",
"(",
")",
")",
";",
"}",
"return",
"new",
"Unicode",
"(",
"cp",
")",
";",
"}",
"}"
] |
Read the next char.
@return The next char, or null of input stream is closed.
@throws IOException If unable to read a char.
|
[
"Read",
"the",
"next",
"char",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/chr/CharReader.java#L65-L143
|
155,919
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.reset
|
protected void reset() {
writer.flush();
stack.clear();
context = new JsonContext(JsonContext.Mode.VALUE);
}
|
java
|
protected void reset() {
writer.flush();
stack.clear();
context = new JsonContext(JsonContext.Mode.VALUE);
}
|
[
"protected",
"void",
"reset",
"(",
")",
"{",
"writer",
".",
"flush",
"(",
")",
";",
"stack",
".",
"clear",
"(",
")",
";",
"context",
"=",
"new",
"JsonContext",
"(",
"JsonContext",
".",
"Mode",
".",
"VALUE",
")",
";",
"}"
] |
Reset the state of the writer and flush already written content.
|
[
"Reset",
"the",
"state",
"of",
"the",
"writer",
"and",
"flush",
"already",
"written",
"content",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L60-L64
|
155,920
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.object
|
public JsonWriter object() {
startValue();
stack.push(context);
context = new JsonContext(JsonContext.Mode.MAP);
writer.write('{');
return this;
}
|
java
|
public JsonWriter object() {
startValue();
stack.push(context);
context = new JsonContext(JsonContext.Mode.MAP);
writer.write('{');
return this;
}
|
[
"public",
"JsonWriter",
"object",
"(",
")",
"{",
"startValue",
"(",
")",
";",
"stack",
".",
"push",
"(",
"context",
")",
";",
"context",
"=",
"new",
"JsonContext",
"(",
"JsonContext",
".",
"Mode",
".",
"MAP",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Start an object value.
@return The JSON Writer.
|
[
"Start",
"an",
"object",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L78-L86
|
155,921
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.array
|
public JsonWriter array() {
startValue();
stack.push(context);
context = new JsonContext(JsonContext.Mode.LIST);
writer.write('[');
return this;
}
|
java
|
public JsonWriter array() {
startValue();
stack.push(context);
context = new JsonContext(JsonContext.Mode.LIST);
writer.write('[');
return this;
}
|
[
"public",
"JsonWriter",
"array",
"(",
")",
"{",
"startValue",
"(",
")",
";",
"stack",
".",
"push",
"(",
"context",
")",
";",
"context",
"=",
"new",
"JsonContext",
"(",
"JsonContext",
".",
"Mode",
".",
"LIST",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Start an array value.
@return The JSON Writer.
|
[
"Start",
"an",
"array",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L93-L101
|
155,922
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.endObject
|
public JsonWriter endObject() {
if (!context.map()) {
throw new IllegalStateException("Unexpected end, not in object.");
}
if (context.value()) {
throw new IllegalStateException("Expected map value but got end.");
}
writer.write('}');
context = stack.pop();
return this;
}
|
java
|
public JsonWriter endObject() {
if (!context.map()) {
throw new IllegalStateException("Unexpected end, not in object.");
}
if (context.value()) {
throw new IllegalStateException("Expected map value but got end.");
}
writer.write('}');
context = stack.pop();
return this;
}
|
[
"public",
"JsonWriter",
"endObject",
"(",
")",
"{",
"if",
"(",
"!",
"context",
".",
"map",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unexpected end, not in object.\"",
")",
";",
"}",
"if",
"(",
"context",
".",
"value",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected map value but got end.\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"context",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
The the ongoing object.
@return The JSON Writer.
|
[
"The",
"the",
"ongoing",
"object",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L108-L118
|
155,923
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.endArray
|
public JsonWriter endArray() {
if (!context.list()) {
throw new IllegalStateException("Unexpected end, not in list.");
}
writer.write(']');
context = stack.pop();
return this;
}
|
java
|
public JsonWriter endArray() {
if (!context.list()) {
throw new IllegalStateException("Unexpected end, not in list.");
}
writer.write(']');
context = stack.pop();
return this;
}
|
[
"public",
"JsonWriter",
"endArray",
"(",
")",
"{",
"if",
"(",
"!",
"context",
".",
"list",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unexpected end, not in list.\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"context",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
End the ongoing array.
@return The JSON Writer.
|
[
"End",
"the",
"ongoing",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L125-L132
|
155,924
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.key
|
public JsonWriter key(int key) {
startKey();
writer.write('\"');
writer.print(key);
writer.write('\"');
writer.write(':');
return this;
}
|
java
|
public JsonWriter key(int key) {
startKey();
writer.write('\"');
writer.print(key);
writer.write('\"');
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"key",
"(",
"int",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"print",
"(",
"key",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the int as object key.
@param key The int key.
@return The JSON Writer.
|
[
"Write",
"the",
"int",
"as",
"object",
"key",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L185-L193
|
155,925
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.key
|
public JsonWriter key(double key) {
startKey();
writer.write('\"');
final long i = (long) key;
if (key == (double) i) {
writer.print(i);
} else {
writer.print(key);
}
writer.write('\"');
writer.write(':');
return this;
}
|
java
|
public JsonWriter key(double key) {
startKey();
writer.write('\"');
final long i = (long) key;
if (key == (double) i) {
writer.print(i);
} else {
writer.print(key);
}
writer.write('\"');
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"key",
"(",
"double",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"final",
"long",
"i",
"=",
"(",
"long",
")",
"key",
";",
"if",
"(",
"key",
"==",
"(",
"double",
")",
"i",
")",
"{",
"writer",
".",
"print",
"(",
"i",
")",
";",
"}",
"else",
"{",
"writer",
".",
"print",
"(",
"key",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the double as object key.
@param key The double key.
@return The JSON Writer.
|
[
"Write",
"the",
"double",
"as",
"object",
"key",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L217-L230
|
155,926
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.key
|
public JsonWriter key(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writeQuotedAndEscaped(key);
writer.write(':');
return this;
}
|
java
|
public JsonWriter key(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writeQuotedAndEscaped(key);
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"key",
"(",
"CharSequence",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected map key, but got null.\"",
")",
";",
"}",
"writeQuotedAndEscaped",
"(",
"key",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the string as object key.
@param key The string key.
@return The JSON Writer.
|
[
"Write",
"the",
"string",
"as",
"object",
"key",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L238-L248
|
155,927
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.keyUnescaped
|
public JsonWriter keyUnescaped(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write('\"');
writer.write(key.toString());
writer.write('\"');
writer.write(':');
return this;
}
|
java
|
public JsonWriter keyUnescaped(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write('\"');
writer.write(key.toString());
writer.write('\"');
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"keyUnescaped",
"(",
"CharSequence",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected map key, but got null.\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"key",
".",
"toString",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the string as object key without escaping.
@param key The string key.
@return The JSON Writer.
|
[
"Write",
"the",
"string",
"as",
"object",
"key",
"without",
"escaping",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L256-L269
|
155,928
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.key
|
public JsonWriter key(Binary key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write('\"');
writer.write(key.toBase64());
writer.write('\"');
writer.write(':');
return this;
}
|
java
|
public JsonWriter key(Binary key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write('\"');
writer.write(key.toBase64());
writer.write('\"');
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"key",
"(",
"Binary",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected map key, but got null.\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"key",
".",
"toBase64",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the binary as object key.
@param key The binary key.
@return The JSON Writer.
|
[
"Write",
"the",
"binary",
"as",
"object",
"key",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L277-L289
|
155,929
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.keyLiteral
|
public JsonWriter keyLiteral(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write(key.toString());
writer.write(':');
return this;
}
|
java
|
public JsonWriter keyLiteral(CharSequence key) {
startKey();
if (key == null) {
throw new IllegalArgumentException("Expected map key, but got null.");
}
writer.write(key.toString());
writer.write(':');
return this;
}
|
[
"public",
"JsonWriter",
"keyLiteral",
"(",
"CharSequence",
"key",
")",
"{",
"startKey",
"(",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected map key, but got null.\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"key",
".",
"toString",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"return",
"this",
";",
"}"
] |
Write the string key without quoting or escaping.
@param key The raw string key.
@return The JSON Writer.
|
[
"Write",
"the",
"string",
"key",
"without",
"quoting",
"or",
"escaping",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L297-L307
|
155,930
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.value
|
public JsonWriter value(double value) {
startValue();
final long i = (long) value;
if (value == (double) i) {
writer.print(i);
} else {
writer.print(value);
}
return this;
}
|
java
|
public JsonWriter value(double value) {
startValue();
final long i = (long) value;
if (value == (double) i) {
writer.print(i);
} else {
writer.print(value);
}
return this;
}
|
[
"public",
"JsonWriter",
"value",
"(",
"double",
"value",
")",
"{",
"startValue",
"(",
")",
";",
"final",
"long",
"i",
"=",
"(",
"long",
")",
"value",
";",
"if",
"(",
"value",
"==",
"(",
"double",
")",
"i",
")",
"{",
"writer",
".",
"print",
"(",
"i",
")",
";",
"}",
"else",
"{",
"writer",
".",
"print",
"(",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Write double value.
@param value The double value.
@return The JSON Writer.
|
[
"Write",
"double",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L380-L390
|
155,931
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.value
|
public JsonWriter value(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writeQuotedAndEscaped(value);
}
return this;
}
|
java
|
public JsonWriter value(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writeQuotedAndEscaped(value);
}
return this;
}
|
[
"public",
"JsonWriter",
"value",
"(",
"CharSequence",
"value",
")",
"{",
"startValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"kNull",
")",
";",
"}",
"else",
"{",
"writeQuotedAndEscaped",
"(",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Write unicode string value.
@param value The string value.
@return The JSON Writer.
|
[
"Write",
"unicode",
"string",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L398-L407
|
155,932
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.valueUnescaped
|
public JsonWriter valueUnescaped(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write('\"');
writer.write(value.toString());
writer.write('\"');
}
return this;
}
|
java
|
public JsonWriter valueUnescaped(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write('\"');
writer.write(value.toString());
writer.write('\"');
}
return this;
}
|
[
"public",
"JsonWriter",
"valueUnescaped",
"(",
"CharSequence",
"value",
")",
"{",
"startValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"kNull",
")",
";",
"}",
"else",
"{",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Write a string unescaped value.
@param value The string value.
@return The JSON Writer.
|
[
"Write",
"a",
"string",
"unescaped",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L415-L426
|
155,933
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.value
|
public JsonWriter value(Binary value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write('\"');
writer.write(value.toBase64());
writer.write('\"');
}
return this;
}
|
java
|
public JsonWriter value(Binary value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write('\"');
writer.write(value.toBase64());
writer.write('\"');
}
return this;
}
|
[
"public",
"JsonWriter",
"value",
"(",
"Binary",
"value",
")",
"{",
"startValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"kNull",
")",
";",
"}",
"else",
"{",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"value",
".",
"toBase64",
"(",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Write binary value.
@param value The binary value.
@return The JSON Writer.
|
[
"Write",
"binary",
"value",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L434-L445
|
155,934
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.valueLiteral
|
public JsonWriter valueLiteral(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write(value.toString());
}
return this;
}
|
java
|
public JsonWriter valueLiteral(CharSequence value) {
startValue();
if (value == null) {
writer.write(kNull);
} else {
writer.write(value.toString());
}
return this;
}
|
[
"public",
"JsonWriter",
"valueLiteral",
"(",
"CharSequence",
"value",
")",
"{",
"startValue",
"(",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"kNull",
")",
";",
"}",
"else",
"{",
"writer",
".",
"write",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Write a literal string as value. Not quoted and not escaped.
@param value The raw string value.
@return The JSON Writer.
|
[
"Write",
"a",
"literal",
"string",
"as",
"value",
".",
"Not",
"quoted",
"and",
"not",
"escaped",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L453-L462
|
155,935
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/json/JsonWriter.java
|
JsonWriter.writeQuotedAndEscaped
|
private void writeQuotedAndEscaped(CharSequence string) {
if (string != null && string.length() != 0) {
int len = string.length();
writer.write('\"');
for (int i = 0; i < len; ++i) {
char cp = string.charAt(i);
if ((cp < 0x7f &&
cp >= 0x20 &&
cp != '\"' &&
cp != '\\') ||
(cp > 0x7f &&
isConsolePrintable(cp) &&
!isSurrogate(cp))) {
// quick bypass for direct printable chars.
writer.write(cp);
} else {
switch (cp) {
case '\b':
writer.write("\\b");
break;
case '\t':
writer.write("\\t");
break;
case '\n':
writer.write("\\n");
break;
case '\f':
writer.write("\\f");
break;
case '\r':
writer.write("\\r");
break;
case '\"':
case '\\':
writer.write('\\');
writer.write(cp);
break;
default:
if (isSurrogate(cp) && (i + 1) < len) {
char c2 = string.charAt(i + 1);
writer.format("\\u%04x", (int) cp);
writer.format("\\u%04x", (int) c2);
++i;
} else {
writer.format("\\u%04x", (int) cp);
}
break;
}
}
}
writer.write('\"');
} else {
writer.write("\"\"");
}
}
|
java
|
private void writeQuotedAndEscaped(CharSequence string) {
if (string != null && string.length() != 0) {
int len = string.length();
writer.write('\"');
for (int i = 0; i < len; ++i) {
char cp = string.charAt(i);
if ((cp < 0x7f &&
cp >= 0x20 &&
cp != '\"' &&
cp != '\\') ||
(cp > 0x7f &&
isConsolePrintable(cp) &&
!isSurrogate(cp))) {
// quick bypass for direct printable chars.
writer.write(cp);
} else {
switch (cp) {
case '\b':
writer.write("\\b");
break;
case '\t':
writer.write("\\t");
break;
case '\n':
writer.write("\\n");
break;
case '\f':
writer.write("\\f");
break;
case '\r':
writer.write("\\r");
break;
case '\"':
case '\\':
writer.write('\\');
writer.write(cp);
break;
default:
if (isSurrogate(cp) && (i + 1) < len) {
char c2 = string.charAt(i + 1);
writer.format("\\u%04x", (int) cp);
writer.format("\\u%04x", (int) c2);
++i;
} else {
writer.format("\\u%04x", (int) cp);
}
break;
}
}
}
writer.write('\"');
} else {
writer.write("\"\"");
}
}
|
[
"private",
"void",
"writeQuotedAndEscaped",
"(",
"CharSequence",
"string",
")",
"{",
"if",
"(",
"string",
"!=",
"null",
"&&",
"string",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"int",
"len",
"=",
"string",
".",
"length",
"(",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"char",
"cp",
"=",
"string",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"(",
"cp",
"<",
"0x7f",
"&&",
"cp",
">=",
"0x20",
"&&",
"cp",
"!=",
"'",
"'",
"&&",
"cp",
"!=",
"'",
"'",
")",
"||",
"(",
"cp",
">",
"0x7f",
"&&",
"isConsolePrintable",
"(",
"cp",
")",
"&&",
"!",
"isSurrogate",
"(",
"cp",
")",
")",
")",
"{",
"// quick bypass for direct printable chars.",
"writer",
".",
"write",
"(",
"cp",
")",
";",
"}",
"else",
"{",
"switch",
"(",
"cp",
")",
"{",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"\"\\\\b\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"\"\\\\t\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"\"\\\\n\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"\"\\\\f\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"\"\\\\r\"",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"cp",
")",
";",
"break",
";",
"default",
":",
"if",
"(",
"isSurrogate",
"(",
"cp",
")",
"&&",
"(",
"i",
"+",
"1",
")",
"<",
"len",
")",
"{",
"char",
"c2",
"=",
"string",
".",
"charAt",
"(",
"i",
"+",
"1",
")",
";",
"writer",
".",
"format",
"(",
"\"\\\\u%04x\"",
",",
"(",
"int",
")",
"cp",
")",
";",
"writer",
".",
"format",
"(",
"\"\\\\u%04x\"",
",",
"(",
"int",
")",
"c2",
")",
";",
"++",
"i",
";",
"}",
"else",
"{",
"writer",
".",
"format",
"(",
"\"\\\\u%04x\"",
",",
"(",
"int",
")",
"cp",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"writer",
".",
"write",
"(",
"\"\\\"\\\"\"",
")",
";",
"}",
"}"
] |
Ported from org.json JSONObject.quote and modified for local use.
|
[
"Ported",
"from",
"org",
".",
"json",
"JSONObject",
".",
"quote",
"and",
"modified",
"for",
"local",
"use",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/json/JsonWriter.java#L503-L559
|
155,936
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/model/QualifiedElementModel.java
|
QualifiedElementModel.addModifier
|
@Requires("modifier != null")
@Ensures("getModifiers().contains(modifier)")
public void addModifier(ElementModifier modifier) {
switch (modifier) {
case PRIVATE:
case PACKAGE_PRIVATE:
case PROTECTED:
case PUBLIC:
modifiers.remove(ElementModifier.PRIVATE);
modifiers.remove(ElementModifier.PACKAGE_PRIVATE);
modifiers.remove(ElementModifier.PROTECTED);
modifiers.remove(ElementModifier.PUBLIC);
}
modifiers.add(modifier);
}
|
java
|
@Requires("modifier != null")
@Ensures("getModifiers().contains(modifier)")
public void addModifier(ElementModifier modifier) {
switch (modifier) {
case PRIVATE:
case PACKAGE_PRIVATE:
case PROTECTED:
case PUBLIC:
modifiers.remove(ElementModifier.PRIVATE);
modifiers.remove(ElementModifier.PACKAGE_PRIVATE);
modifiers.remove(ElementModifier.PROTECTED);
modifiers.remove(ElementModifier.PUBLIC);
}
modifiers.add(modifier);
}
|
[
"@",
"Requires",
"(",
"\"modifier != null\"",
")",
"@",
"Ensures",
"(",
"\"getModifiers().contains(modifier)\"",
")",
"public",
"void",
"addModifier",
"(",
"ElementModifier",
"modifier",
")",
"{",
"switch",
"(",
"modifier",
")",
"{",
"case",
"PRIVATE",
":",
"case",
"PACKAGE_PRIVATE",
":",
"case",
"PROTECTED",
":",
"case",
"PUBLIC",
":",
"modifiers",
".",
"remove",
"(",
"ElementModifier",
".",
"PRIVATE",
")",
";",
"modifiers",
".",
"remove",
"(",
"ElementModifier",
".",
"PACKAGE_PRIVATE",
")",
";",
"modifiers",
".",
"remove",
"(",
"ElementModifier",
".",
"PROTECTED",
")",
";",
"modifiers",
".",
"remove",
"(",
"ElementModifier",
".",
"PUBLIC",
")",
";",
"}",
"modifiers",
".",
"add",
"(",
"modifier",
")",
";",
"}"
] |
Adds a modifier to this element. This method ensures that exactly
one visibility modifier is set.
|
[
"Adds",
"a",
"modifier",
"to",
"this",
"element",
".",
"This",
"method",
"ensures",
"that",
"exactly",
"one",
"visibility",
"modifier",
"is",
"set",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/model/QualifiedElementModel.java#L74-L88
|
155,937
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/model/QualifiedElementModel.java
|
QualifiedElementModel.removeModifier
|
@Requires("modifier != null")
@Ensures("!getModifiers().contains(modifier)")
public void removeModifier(ElementModifier modifier) {
modifiers.remove(modifier);
switch (modifier) {
case PRIVATE:
case PACKAGE_PRIVATE:
case PROTECTED:
case PUBLIC:
modifiers.add(ElementModifier.PACKAGE_PRIVATE);
}
}
|
java
|
@Requires("modifier != null")
@Ensures("!getModifiers().contains(modifier)")
public void removeModifier(ElementModifier modifier) {
modifiers.remove(modifier);
switch (modifier) {
case PRIVATE:
case PACKAGE_PRIVATE:
case PROTECTED:
case PUBLIC:
modifiers.add(ElementModifier.PACKAGE_PRIVATE);
}
}
|
[
"@",
"Requires",
"(",
"\"modifier != null\"",
")",
"@",
"Ensures",
"(",
"\"!getModifiers().contains(modifier)\"",
")",
"public",
"void",
"removeModifier",
"(",
"ElementModifier",
"modifier",
")",
"{",
"modifiers",
".",
"remove",
"(",
"modifier",
")",
";",
"switch",
"(",
"modifier",
")",
"{",
"case",
"PRIVATE",
":",
"case",
"PACKAGE_PRIVATE",
":",
"case",
"PROTECTED",
":",
"case",
"PUBLIC",
":",
"modifiers",
".",
"add",
"(",
"ElementModifier",
".",
"PACKAGE_PRIVATE",
")",
";",
"}",
"}"
] |
Removes a modifier from this element. This method ensures that
exactly one visibility modifier is set. It defaults to
package-private if no other visibility is set.
|
[
"Removes",
"a",
"modifier",
"from",
"this",
"element",
".",
"This",
"method",
"ensures",
"that",
"exactly",
"one",
"visibility",
"modifier",
"is",
"set",
".",
"It",
"defaults",
"to",
"package",
"-",
"private",
"if",
"no",
"other",
"visibility",
"is",
"set",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/model/QualifiedElementModel.java#L95-L106
|
155,938
|
Sonoport/freesound-java
|
src/main/java/com/sonoport/freesound/query/Query.java
|
Query.processResponse
|
public Response<R> processResponse(
final int httpResponseCode, final String httpResponseStatusString, final S freesoundResponse) {
final Response<R> response = new Response<>(httpResponseCode, httpResponseStatusString);
if (response.isErrorResponse()) {
response.setErrorDetails(extractErrorMessage(freesoundResponse));
} else {
response.setResults(resultsMapper.map(freesoundResponse));
}
return response;
}
|
java
|
public Response<R> processResponse(
final int httpResponseCode, final String httpResponseStatusString, final S freesoundResponse) {
final Response<R> response = new Response<>(httpResponseCode, httpResponseStatusString);
if (response.isErrorResponse()) {
response.setErrorDetails(extractErrorMessage(freesoundResponse));
} else {
response.setResults(resultsMapper.map(freesoundResponse));
}
return response;
}
|
[
"public",
"Response",
"<",
"R",
">",
"processResponse",
"(",
"final",
"int",
"httpResponseCode",
",",
"final",
"String",
"httpResponseStatusString",
",",
"final",
"S",
"freesoundResponse",
")",
"{",
"final",
"Response",
"<",
"R",
">",
"response",
"=",
"new",
"Response",
"<>",
"(",
"httpResponseCode",
",",
"httpResponseStatusString",
")",
";",
"if",
"(",
"response",
".",
"isErrorResponse",
"(",
")",
")",
"{",
"response",
".",
"setErrorDetails",
"(",
"extractErrorMessage",
"(",
"freesoundResponse",
")",
")",
";",
"}",
"else",
"{",
"response",
".",
"setResults",
"(",
"resultsMapper",
".",
"map",
"(",
"freesoundResponse",
")",
")",
";",
"}",
"return",
"response",
";",
"}"
] |
Set the raw response received from the HTTP call. Contents are passed on to sub-classes for mapping to DTOs.
@param httpResponseCode The HTTP response code received
@param httpResponseStatusString The text associated with the HTTP response code
@param freesoundResponse The response received from the HTTP call
@return Results of the query
|
[
"Set",
"the",
"raw",
"response",
"received",
"from",
"the",
"HTTP",
"call",
".",
"Contents",
"are",
"passed",
"on",
"to",
"sub",
"-",
"classes",
"for",
"mapping",
"to",
"DTOs",
"."
] |
ab029e25de068c6f8cc028bc7f916938fd97c036
|
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/query/Query.java#L74-L85
|
155,939
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/collections/JMLimitedList.java
|
JMLimitedList.get
|
public Optional<E> get(int index) {
return getOptional(linkedList)
.filter(getGreaterSize(0).and(getGreaterSize(index)))
.map(l -> l.get(index));
}
|
java
|
public Optional<E> get(int index) {
return getOptional(linkedList)
.filter(getGreaterSize(0).and(getGreaterSize(index)))
.map(l -> l.get(index));
}
|
[
"public",
"Optional",
"<",
"E",
">",
"get",
"(",
"int",
"index",
")",
"{",
"return",
"getOptional",
"(",
"linkedList",
")",
".",
"filter",
"(",
"getGreaterSize",
"(",
"0",
")",
".",
"and",
"(",
"getGreaterSize",
"(",
"index",
")",
")",
")",
".",
"map",
"(",
"l",
"->",
"l",
".",
"get",
"(",
"index",
")",
")",
";",
"}"
] |
Get optional.
@param index the index
@return the optional
|
[
"Get",
"optional",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMLimitedList.java#L63-L67
|
155,940
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/collections/JMLimitedList.java
|
JMLimitedList.getPrevious
|
public Optional<E> getPrevious() {
return Optional.of(currentIndex).filter(getGreater(0))
.map(i -> linkedList.get(--currentIndex));
}
|
java
|
public Optional<E> getPrevious() {
return Optional.of(currentIndex).filter(getGreater(0))
.map(i -> linkedList.get(--currentIndex));
}
|
[
"public",
"Optional",
"<",
"E",
">",
"getPrevious",
"(",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"currentIndex",
")",
".",
"filter",
"(",
"getGreater",
"(",
"0",
")",
")",
".",
"map",
"(",
"i",
"->",
"linkedList",
".",
"get",
"(",
"--",
"currentIndex",
")",
")",
";",
"}"
] |
Gets previous.
@return the previous
|
[
"Gets",
"previous",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMLimitedList.java#L103-L106
|
155,941
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/collections/JMLimitedList.java
|
JMLimitedList.getNext
|
public Optional<E> getNext() {
return Optional.of(currentIndex).filter(getLess(linkedList.size() - 1))
.map(i -> linkedList.get(++currentIndex));
}
|
java
|
public Optional<E> getNext() {
return Optional.of(currentIndex).filter(getLess(linkedList.size() - 1))
.map(i -> linkedList.get(++currentIndex));
}
|
[
"public",
"Optional",
"<",
"E",
">",
"getNext",
"(",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"currentIndex",
")",
".",
"filter",
"(",
"getLess",
"(",
"linkedList",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
".",
"map",
"(",
"i",
"->",
"linkedList",
".",
"get",
"(",
"++",
"currentIndex",
")",
")",
";",
"}"
] |
Gets next.
@return the next
|
[
"Gets",
"next",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/JMLimitedList.java#L113-L116
|
155,942
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/util/Elements.java
|
Elements.filter
|
@Requires({
"elements != null",
"!elements.contains(null)",
"clazz != null",
"kinds != null"
})
@SuppressWarnings("unchecked")
public static <T extends ElementModel> List<? extends T> filter(
List<? extends ElementModel> elements, Class<T> clazz,
ElementKind... kinds) {
ArrayList<T> result = new ArrayList<T>();
List<ElementKind> list = Arrays.asList(kinds);
for (ElementModel element : elements) {
if (list.contains(element.getKind())
&& clazz.isAssignableFrom(element.getClass())) {
result.add((T) element);
}
}
return Collections.unmodifiableList(result);
}
|
java
|
@Requires({
"elements != null",
"!elements.contains(null)",
"clazz != null",
"kinds != null"
})
@SuppressWarnings("unchecked")
public static <T extends ElementModel> List<? extends T> filter(
List<? extends ElementModel> elements, Class<T> clazz,
ElementKind... kinds) {
ArrayList<T> result = new ArrayList<T>();
List<ElementKind> list = Arrays.asList(kinds);
for (ElementModel element : elements) {
if (list.contains(element.getKind())
&& clazz.isAssignableFrom(element.getClass())) {
result.add((T) element);
}
}
return Collections.unmodifiableList(result);
}
|
[
"@",
"Requires",
"(",
"{",
"\"elements != null\"",
",",
"\"!elements.contains(null)\"",
",",
"\"clazz != null\"",
",",
"\"kinds != null\"",
"}",
")",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"ElementModel",
">",
"List",
"<",
"?",
"extends",
"T",
">",
"filter",
"(",
"List",
"<",
"?",
"extends",
"ElementModel",
">",
"elements",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"ElementKind",
"...",
"kinds",
")",
"{",
"ArrayList",
"<",
"T",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"List",
"<",
"ElementKind",
">",
"list",
"=",
"Arrays",
".",
"asList",
"(",
"kinds",
")",
";",
"for",
"(",
"ElementModel",
"element",
":",
"elements",
")",
"{",
"if",
"(",
"list",
".",
"contains",
"(",
"element",
".",
"getKind",
"(",
")",
")",
"&&",
"clazz",
".",
"isAssignableFrom",
"(",
"element",
".",
"getClass",
"(",
")",
")",
")",
"{",
"result",
".",
"add",
"(",
"(",
"T",
")",
"element",
")",
";",
"}",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"result",
")",
";",
"}"
] |
Returns the sublist of all elements of the specified kinds.
|
[
"Returns",
"the",
"sublist",
"of",
"all",
"elements",
"of",
"the",
"specified",
"kinds",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/util/Elements.java#L61-L80
|
155,943
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/util/Elements.java
|
Elements.findEnclosingElement
|
@Requires({
"element != null",
"clazz != null",
"kinds != null"
})
@SuppressWarnings("unchecked")
public static <T extends ElementModel> T findEnclosingElement(
ElementModel element, Class<T> clazz, ElementKind... kinds) {
List<ElementKind> list = Arrays.asList(kinds);
for (;;) {
element = element.getEnclosingElement();
if (element == null) {
return null;
}
if (list.contains(element.getKind())
&& clazz.isAssignableFrom(element.getClass())) {
return (T) element;
}
}
}
|
java
|
@Requires({
"element != null",
"clazz != null",
"kinds != null"
})
@SuppressWarnings("unchecked")
public static <T extends ElementModel> T findEnclosingElement(
ElementModel element, Class<T> clazz, ElementKind... kinds) {
List<ElementKind> list = Arrays.asList(kinds);
for (;;) {
element = element.getEnclosingElement();
if (element == null) {
return null;
}
if (list.contains(element.getKind())
&& clazz.isAssignableFrom(element.getClass())) {
return (T) element;
}
}
}
|
[
"@",
"Requires",
"(",
"{",
"\"element != null\"",
",",
"\"clazz != null\"",
",",
"\"kinds != null\"",
"}",
")",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
"extends",
"ElementModel",
">",
"T",
"findEnclosingElement",
"(",
"ElementModel",
"element",
",",
"Class",
"<",
"T",
">",
"clazz",
",",
"ElementKind",
"...",
"kinds",
")",
"{",
"List",
"<",
"ElementKind",
">",
"list",
"=",
"Arrays",
".",
"asList",
"(",
"kinds",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"element",
"=",
"element",
".",
"getEnclosingElement",
"(",
")",
";",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"list",
".",
"contains",
"(",
"element",
".",
"getKind",
"(",
")",
")",
"&&",
"clazz",
".",
"isAssignableFrom",
"(",
"element",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"T",
")",
"element",
";",
"}",
"}",
"}"
] |
Returns the closest enclosing element of the specified kind.
|
[
"Returns",
"the",
"closest",
"enclosing",
"element",
"of",
"the",
"specified",
"kind",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/util/Elements.java#L85-L104
|
155,944
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/util/Elements.java
|
Elements.getTypeOf
|
@Requires("element != null")
public static TypeModel getTypeOf(ElementModel element) {
return findEnclosingElement(element, TypeModel.class,
ElementKind.CLASS, ElementKind.ENUM, ElementKind.INTERFACE);
}
|
java
|
@Requires("element != null")
public static TypeModel getTypeOf(ElementModel element) {
return findEnclosingElement(element, TypeModel.class,
ElementKind.CLASS, ElementKind.ENUM, ElementKind.INTERFACE);
}
|
[
"@",
"Requires",
"(",
"\"element != null\"",
")",
"public",
"static",
"TypeModel",
"getTypeOf",
"(",
"ElementModel",
"element",
")",
"{",
"return",
"findEnclosingElement",
"(",
"element",
",",
"TypeModel",
".",
"class",
",",
"ElementKind",
".",
"CLASS",
",",
"ElementKind",
".",
"ENUM",
",",
"ElementKind",
".",
"INTERFACE",
")",
";",
"}"
] |
Returns the closest enclosing type of the specified element.
|
[
"Returns",
"the",
"closest",
"enclosing",
"type",
"of",
"the",
"specified",
"element",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/util/Elements.java#L109-L113
|
155,945
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/util/Elements.java
|
Elements.getUriForClass
|
@Requires({
"name != null",
"!name.isEmpty()",
"kind != null"
})
public static URI getUriForClass(String name, Kind kind) {
try {
return new URI("com.google.java.contract://com.google.java.contract/" + name + kind.extension);
} catch (URISyntaxException e) {
throw new IllegalArgumentException();
}
}
|
java
|
@Requires({
"name != null",
"!name.isEmpty()",
"kind != null"
})
public static URI getUriForClass(String name, Kind kind) {
try {
return new URI("com.google.java.contract://com.google.java.contract/" + name + kind.extension);
} catch (URISyntaxException e) {
throw new IllegalArgumentException();
}
}
|
[
"@",
"Requires",
"(",
"{",
"\"name != null\"",
",",
"\"!name.isEmpty()\"",
",",
"\"kind != null\"",
"}",
")",
"public",
"static",
"URI",
"getUriForClass",
"(",
"String",
"name",
",",
"Kind",
"kind",
")",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"\"com.google.java.contract://com.google.java.contract/\"",
"+",
"name",
"+",
"kind",
".",
"extension",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"}"
] |
Returns a Contracts for Java private URI for the specified class name
and kind.
|
[
"Returns",
"a",
"Contracts",
"for",
"Java",
"private",
"URI",
"for",
"the",
"specified",
"class",
"name",
"and",
"kind",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/util/Elements.java#L119-L130
|
155,946
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java
|
LoadBalancerManager.getServiceRRLoadBalancer
|
public ServiceRRLoadBalancer getServiceRRLoadBalancer(String serviceName) {
for (ServiceRRLoadBalancer lb : svcLBList) {
if (lb.getServiceName().equals(serviceName)) {
return lb;
}
}
ServiceRRLoadBalancer lb = new ServiceRRLoadBalancer(lookupService,
serviceName);
svcLBList.add(lb);
return lb;
}
|
java
|
public ServiceRRLoadBalancer getServiceRRLoadBalancer(String serviceName) {
for (ServiceRRLoadBalancer lb : svcLBList) {
if (lb.getServiceName().equals(serviceName)) {
return lb;
}
}
ServiceRRLoadBalancer lb = new ServiceRRLoadBalancer(lookupService,
serviceName);
svcLBList.add(lb);
return lb;
}
|
[
"public",
"ServiceRRLoadBalancer",
"getServiceRRLoadBalancer",
"(",
"String",
"serviceName",
")",
"{",
"for",
"(",
"ServiceRRLoadBalancer",
"lb",
":",
"svcLBList",
")",
"{",
"if",
"(",
"lb",
".",
"getServiceName",
"(",
")",
".",
"equals",
"(",
"serviceName",
")",
")",
"{",
"return",
"lb",
";",
"}",
"}",
"ServiceRRLoadBalancer",
"lb",
"=",
"new",
"ServiceRRLoadBalancer",
"(",
"lookupService",
",",
"serviceName",
")",
";",
"svcLBList",
".",
"add",
"(",
"lb",
")",
";",
"return",
"lb",
";",
"}"
] |
Get the ServiceRRLoadBalancer.
@param serviceName
the service name.
@return
the ServiceRRLoadBalancer.
|
[
"Get",
"the",
"ServiceRRLoadBalancer",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java#L72-L82
|
155,947
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java
|
LoadBalancerManager.getMetadataQueryRRLoadBalancer
|
public MetadataQueryRRLoadBalancer getMetadataQueryRRLoadBalancer(
ServiceInstanceQuery query) {
for (MetadataQueryRRLoadBalancer lb : metaQueryLBList) {
if (lb.getServiceInstanceQuery().equals(query)) {
return lb;
}
}
MetadataQueryRRLoadBalancer lb = new MetadataQueryRRLoadBalancer(
lookupService, query);
metaQueryLBList.add(lb);
return lb;
}
|
java
|
public MetadataQueryRRLoadBalancer getMetadataQueryRRLoadBalancer(
ServiceInstanceQuery query) {
for (MetadataQueryRRLoadBalancer lb : metaQueryLBList) {
if (lb.getServiceInstanceQuery().equals(query)) {
return lb;
}
}
MetadataQueryRRLoadBalancer lb = new MetadataQueryRRLoadBalancer(
lookupService, query);
metaQueryLBList.add(lb);
return lb;
}
|
[
"public",
"MetadataQueryRRLoadBalancer",
"getMetadataQueryRRLoadBalancer",
"(",
"ServiceInstanceQuery",
"query",
")",
"{",
"for",
"(",
"MetadataQueryRRLoadBalancer",
"lb",
":",
"metaQueryLBList",
")",
"{",
"if",
"(",
"lb",
".",
"getServiceInstanceQuery",
"(",
")",
".",
"equals",
"(",
"query",
")",
")",
"{",
"return",
"lb",
";",
"}",
"}",
"MetadataQueryRRLoadBalancer",
"lb",
"=",
"new",
"MetadataQueryRRLoadBalancer",
"(",
"lookupService",
",",
"query",
")",
";",
"metaQueryLBList",
".",
"add",
"(",
"lb",
")",
";",
"return",
"lb",
";",
"}"
] |
Get the MetadataQueryRRLoadBalancer.
@param query
the ServiceInstanceQuery.
@return
the MetadataQueryRRLoadBalancer.
|
[
"Get",
"the",
"MetadataQueryRRLoadBalancer",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java#L92-L103
|
155,948
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java
|
LoadBalancerManager.getServiceQueryRRLoadBalancer
|
public ServiceQueryRRLoadBalancer getServiceQueryRRLoadBalancer(
String serviceName, ServiceInstanceQuery query) {
for (ServiceQueryRRLoadBalancer lb : svcQueryLBList) {
if (lb.getServiceName().equals(serviceName)
&& lb.getServiceInstanceQuery().equals(query)) {
return lb;
}
}
ServiceQueryRRLoadBalancer lb = new ServiceQueryRRLoadBalancer(
lookupService, serviceName, query);
svcQueryLBList.add(lb);
return lb;
}
|
java
|
public ServiceQueryRRLoadBalancer getServiceQueryRRLoadBalancer(
String serviceName, ServiceInstanceQuery query) {
for (ServiceQueryRRLoadBalancer lb : svcQueryLBList) {
if (lb.getServiceName().equals(serviceName)
&& lb.getServiceInstanceQuery().equals(query)) {
return lb;
}
}
ServiceQueryRRLoadBalancer lb = new ServiceQueryRRLoadBalancer(
lookupService, serviceName, query);
svcQueryLBList.add(lb);
return lb;
}
|
[
"public",
"ServiceQueryRRLoadBalancer",
"getServiceQueryRRLoadBalancer",
"(",
"String",
"serviceName",
",",
"ServiceInstanceQuery",
"query",
")",
"{",
"for",
"(",
"ServiceQueryRRLoadBalancer",
"lb",
":",
"svcQueryLBList",
")",
"{",
"if",
"(",
"lb",
".",
"getServiceName",
"(",
")",
".",
"equals",
"(",
"serviceName",
")",
"&&",
"lb",
".",
"getServiceInstanceQuery",
"(",
")",
".",
"equals",
"(",
"query",
")",
")",
"{",
"return",
"lb",
";",
"}",
"}",
"ServiceQueryRRLoadBalancer",
"lb",
"=",
"new",
"ServiceQueryRRLoadBalancer",
"(",
"lookupService",
",",
"serviceName",
",",
"query",
")",
";",
"svcQueryLBList",
".",
"add",
"(",
"lb",
")",
";",
"return",
"lb",
";",
"}"
] |
Get the ServiceQueryRRLoadBalancer.
@param serviceName
the service name.
@param query
the ServiceInstanceQuery.
@return
the ServiceQueryRRLoadBalancer.
|
[
"Get",
"the",
"ServiceQueryRRLoadBalancer",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/LoadBalancerManager.java#L115-L127
|
155,949
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java
|
SpecificationMethodAdapter.onMethodEnter
|
@Override
protected void onMethodEnter() {
if (withPreconditions || withPostconditions || withInvariants) {
enterContractedMethod();
if (withPostconditions) {
allocateOldValues(ContractKind.OLD, oldValueLocals);
allocateOldValues(ContractKind.SIGNAL_OLD, signalOldValueLocals);
}
mark(methodStart);
Label skip = enterBusySection();
if (withInvariants && !statik && !isConstructor && !isStaticInit) {
invokeInvariants();
}
if (withPreconditions) {
invokePreconditions();
}
if (withPostconditions) {
invokeOldValues(ContractKind.OLD, oldValueLocals);
invokeOldValues(ContractKind.SIGNAL_OLD, signalOldValueLocals);
}
leaveBusySection(skip);
}
}
|
java
|
@Override
protected void onMethodEnter() {
if (withPreconditions || withPostconditions || withInvariants) {
enterContractedMethod();
if (withPostconditions) {
allocateOldValues(ContractKind.OLD, oldValueLocals);
allocateOldValues(ContractKind.SIGNAL_OLD, signalOldValueLocals);
}
mark(methodStart);
Label skip = enterBusySection();
if (withInvariants && !statik && !isConstructor && !isStaticInit) {
invokeInvariants();
}
if (withPreconditions) {
invokePreconditions();
}
if (withPostconditions) {
invokeOldValues(ContractKind.OLD, oldValueLocals);
invokeOldValues(ContractKind.SIGNAL_OLD, signalOldValueLocals);
}
leaveBusySection(skip);
}
}
|
[
"@",
"Override",
"protected",
"void",
"onMethodEnter",
"(",
")",
"{",
"if",
"(",
"withPreconditions",
"||",
"withPostconditions",
"||",
"withInvariants",
")",
"{",
"enterContractedMethod",
"(",
")",
";",
"if",
"(",
"withPostconditions",
")",
"{",
"allocateOldValues",
"(",
"ContractKind",
".",
"OLD",
",",
"oldValueLocals",
")",
";",
"allocateOldValues",
"(",
"ContractKind",
".",
"SIGNAL_OLD",
",",
"signalOldValueLocals",
")",
";",
"}",
"mark",
"(",
"methodStart",
")",
";",
"Label",
"skip",
"=",
"enterBusySection",
"(",
")",
";",
"if",
"(",
"withInvariants",
"&&",
"!",
"statik",
"&&",
"!",
"isConstructor",
"&&",
"!",
"isStaticInit",
")",
"{",
"invokeInvariants",
"(",
")",
";",
"}",
"if",
"(",
"withPreconditions",
")",
"{",
"invokePreconditions",
"(",
")",
";",
"}",
"if",
"(",
"withPostconditions",
")",
"{",
"invokeOldValues",
"(",
"ContractKind",
".",
"OLD",
",",
"oldValueLocals",
")",
";",
"invokeOldValues",
"(",
"ContractKind",
".",
"SIGNAL_OLD",
",",
"signalOldValueLocals",
")",
";",
"}",
"leaveBusySection",
"(",
"skip",
")",
";",
"}",
"}"
] |
Advises the method by injecting invariants, precondition
assertions, and old value computations, before the original code.
|
[
"Advises",
"the",
"method",
"by",
"injecting",
"invariants",
"precondition",
"assertions",
"and",
"old",
"value",
"computations",
"before",
"the",
"original",
"code",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java#L198-L227
|
155,950
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java
|
SpecificationMethodAdapter.enterBusySection
|
@Requires({
"contextLocal >= 0",
"checkInvariantsLocal >= 0"
})
@Ensures("result != null")
protected Label enterBusySection() {
Label skip = new Label();
loadLocal(contextLocal);
invokeVirtual(CONTRACT_CONTEXT_TYPE, TRY_ENTER_CONTRACT_METHOD);
ifZCmp(EQ, skip);
return skip;
}
|
java
|
@Requires({
"contextLocal >= 0",
"checkInvariantsLocal >= 0"
})
@Ensures("result != null")
protected Label enterBusySection() {
Label skip = new Label();
loadLocal(contextLocal);
invokeVirtual(CONTRACT_CONTEXT_TYPE, TRY_ENTER_CONTRACT_METHOD);
ifZCmp(EQ, skip);
return skip;
}
|
[
"@",
"Requires",
"(",
"{",
"\"contextLocal >= 0\"",
",",
"\"checkInvariantsLocal >= 0\"",
"}",
")",
"@",
"Ensures",
"(",
"\"result != null\"",
")",
"protected",
"Label",
"enterBusySection",
"(",
")",
"{",
"Label",
"skip",
"=",
"new",
"Label",
"(",
")",
";",
"loadLocal",
"(",
"contextLocal",
")",
";",
"invokeVirtual",
"(",
"CONTRACT_CONTEXT_TYPE",
",",
"TRY_ENTER_CONTRACT_METHOD",
")",
";",
"ifZCmp",
"(",
"EQ",
",",
"skip",
")",
";",
"return",
"skip",
";",
"}"
] |
Marks the beginning of a busy section. A busy section is skipped
if the context is already busy.
|
[
"Marks",
"the",
"beginning",
"of",
"a",
"busy",
"section",
".",
"A",
"busy",
"section",
"is",
"skipped",
"if",
"the",
"context",
"is",
"already",
"busy",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java#L556-L567
|
155,951
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java
|
SpecificationMethodAdapter.leaveBusySection
|
@Requires({
"contextLocal >= 0",
"skip != null"
})
protected void leaveBusySection(Label skip) {
loadLocal(contextLocal);
invokeVirtual(CONTRACT_CONTEXT_TYPE, LEAVE_CONTRACT_METHOD);
mark(skip);
}
|
java
|
@Requires({
"contextLocal >= 0",
"skip != null"
})
protected void leaveBusySection(Label skip) {
loadLocal(contextLocal);
invokeVirtual(CONTRACT_CONTEXT_TYPE, LEAVE_CONTRACT_METHOD);
mark(skip);
}
|
[
"@",
"Requires",
"(",
"{",
"\"contextLocal >= 0\"",
",",
"\"skip != null\"",
"}",
")",
"protected",
"void",
"leaveBusySection",
"(",
"Label",
"skip",
")",
"{",
"loadLocal",
"(",
"contextLocal",
")",
";",
"invokeVirtual",
"(",
"CONTRACT_CONTEXT_TYPE",
",",
"LEAVE_CONTRACT_METHOD",
")",
";",
"mark",
"(",
"skip",
")",
";",
"}"
] |
Marks the end of a busy section.
|
[
"Marks",
"the",
"end",
"of",
"a",
"busy",
"section",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java#L572-L580
|
155,952
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java
|
SpecificationMethodAdapter.enterContractedMethod
|
@Ensures({
"contextLocal >= 0",
"checkInvariantsLocal >= 0"
})
protected void enterContractedMethod() {
contextLocal = newLocal(CONTRACT_CONTEXT_TYPE);
checkInvariantsLocal = newLocal(Type.BOOLEAN_TYPE);
invokeStatic(CONTRACT_RUNTIME_TYPE, GET_CONTEXT_METHOD);
dup();
storeLocal(contextLocal);
if (statik) {
loadThisClass();
} else {
loadThis();
}
invokeVirtual(CONTRACT_CONTEXT_TYPE, TRY_ENTER_METHOD);
storeLocal(checkInvariantsLocal);
}
|
java
|
@Ensures({
"contextLocal >= 0",
"checkInvariantsLocal >= 0"
})
protected void enterContractedMethod() {
contextLocal = newLocal(CONTRACT_CONTEXT_TYPE);
checkInvariantsLocal = newLocal(Type.BOOLEAN_TYPE);
invokeStatic(CONTRACT_RUNTIME_TYPE, GET_CONTEXT_METHOD);
dup();
storeLocal(contextLocal);
if (statik) {
loadThisClass();
} else {
loadThis();
}
invokeVirtual(CONTRACT_CONTEXT_TYPE, TRY_ENTER_METHOD);
storeLocal(checkInvariantsLocal);
}
|
[
"@",
"Ensures",
"(",
"{",
"\"contextLocal >= 0\"",
",",
"\"checkInvariantsLocal >= 0\"",
"}",
")",
"protected",
"void",
"enterContractedMethod",
"(",
")",
"{",
"contextLocal",
"=",
"newLocal",
"(",
"CONTRACT_CONTEXT_TYPE",
")",
";",
"checkInvariantsLocal",
"=",
"newLocal",
"(",
"Type",
".",
"BOOLEAN_TYPE",
")",
";",
"invokeStatic",
"(",
"CONTRACT_RUNTIME_TYPE",
",",
"GET_CONTEXT_METHOD",
")",
";",
"dup",
"(",
")",
";",
"storeLocal",
"(",
"contextLocal",
")",
";",
"if",
"(",
"statik",
")",
"{",
"loadThisClass",
"(",
")",
";",
"}",
"else",
"{",
"loadThis",
"(",
")",
";",
"}",
"invokeVirtual",
"(",
"CONTRACT_CONTEXT_TYPE",
",",
"TRY_ENTER_METHOD",
")",
";",
"storeLocal",
"(",
"checkInvariantsLocal",
")",
";",
"}"
] |
Retrieves busy state of the current object.
|
[
"Retrieves",
"busy",
"state",
"of",
"the",
"current",
"object",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java#L593-L610
|
155,953
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java
|
SpecificationMethodAdapter.leaveContractedMethod
|
@Requires("contextLocal >= 0")
protected void leaveContractedMethod() {
Label skip = new Label();
loadLocal(checkInvariantsLocal);
ifZCmp(EQ, skip);
loadLocal(contextLocal);
if (statik) {
loadThisClass();
} else {
loadThis();
}
invokeVirtual(CONTRACT_CONTEXT_TYPE, LEAVE_METHOD);
mark(skip);
}
|
java
|
@Requires("contextLocal >= 0")
protected void leaveContractedMethod() {
Label skip = new Label();
loadLocal(checkInvariantsLocal);
ifZCmp(EQ, skip);
loadLocal(contextLocal);
if (statik) {
loadThisClass();
} else {
loadThis();
}
invokeVirtual(CONTRACT_CONTEXT_TYPE, LEAVE_METHOD);
mark(skip);
}
|
[
"@",
"Requires",
"(",
"\"contextLocal >= 0\"",
")",
"protected",
"void",
"leaveContractedMethod",
"(",
")",
"{",
"Label",
"skip",
"=",
"new",
"Label",
"(",
")",
";",
"loadLocal",
"(",
"checkInvariantsLocal",
")",
";",
"ifZCmp",
"(",
"EQ",
",",
"skip",
")",
";",
"loadLocal",
"(",
"contextLocal",
")",
";",
"if",
"(",
"statik",
")",
"{",
"loadThisClass",
"(",
")",
";",
"}",
"else",
"{",
"loadThis",
"(",
")",
";",
"}",
"invokeVirtual",
"(",
"CONTRACT_CONTEXT_TYPE",
",",
"LEAVE_METHOD",
")",
";",
"mark",
"(",
"skip",
")",
";",
"}"
] |
Cancels busy state of the current object.
|
[
"Cancels",
"busy",
"state",
"of",
"the",
"current",
"object",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/SpecificationMethodAdapter.java#L615-L630
|
155,954
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.configure
|
@Override
public void configure(ConfigParams config) throws ConfigException {
ConfigParams dependencies = config.getSection("dependencies");
for (String name : dependencies.keySet()) {
String locator = dependencies.get(name);
if (locator == null)
continue;
try {
Descriptor descriptor = Descriptor.fromString(locator);
if (descriptor != null)
_dependencies.put(name, descriptor);
else
_dependencies.put(name, locator);
} catch (Exception ex) {
_dependencies.put(name, locator);
}
}
}
|
java
|
@Override
public void configure(ConfigParams config) throws ConfigException {
ConfigParams dependencies = config.getSection("dependencies");
for (String name : dependencies.keySet()) {
String locator = dependencies.get(name);
if (locator == null)
continue;
try {
Descriptor descriptor = Descriptor.fromString(locator);
if (descriptor != null)
_dependencies.put(name, descriptor);
else
_dependencies.put(name, locator);
} catch (Exception ex) {
_dependencies.put(name, locator);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"configure",
"(",
"ConfigParams",
"config",
")",
"throws",
"ConfigException",
"{",
"ConfigParams",
"dependencies",
"=",
"config",
".",
"getSection",
"(",
"\"dependencies\"",
")",
";",
"for",
"(",
"String",
"name",
":",
"dependencies",
".",
"keySet",
"(",
")",
")",
"{",
"String",
"locator",
"=",
"dependencies",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"continue",
";",
"try",
"{",
"Descriptor",
"descriptor",
"=",
"Descriptor",
".",
"fromString",
"(",
"locator",
")",
";",
"if",
"(",
"descriptor",
"!=",
"null",
")",
"_dependencies",
".",
"put",
"(",
"name",
",",
"descriptor",
")",
";",
"else",
"_dependencies",
".",
"put",
"(",
"name",
",",
"locator",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"_dependencies",
".",
"put",
"(",
"name",
",",
"locator",
")",
";",
"}",
"}",
"}"
] |
Configures the component with specified parameters.
@param config configuration parameters to set.
@throws ConfigException when configuration is wrong.
@see ConfigParams
|
[
"Configures",
"the",
"component",
"with",
"specified",
"parameters",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L108-L126
|
155,955
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.find
|
private Object find(String name) {
if (name == null)
throw new NullPointerException("Dependency name cannot be null");
if (_references == null)
throw new NullPointerException("References shall be set");
return _dependencies.get(name);
}
|
java
|
private Object find(String name) {
if (name == null)
throw new NullPointerException("Dependency name cannot be null");
if (_references == null)
throw new NullPointerException("References shall be set");
return _dependencies.get(name);
}
|
[
"private",
"Object",
"find",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Dependency name cannot be null\"",
")",
";",
"if",
"(",
"_references",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"References shall be set\"",
")",
";",
"return",
"_dependencies",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Gets a dependency locator by its name.
@param name the name of the dependency to locate.
@return the dependency locator or null if locator was not configured.
|
[
"Gets",
"a",
"dependency",
"locator",
"by",
"its",
"name",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L154-L161
|
155,956
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.getOneOptional
|
public Object getOneOptional(String name) {
Object locator = find(name);
return locator != null ? _references.getOneOptional(locator) : null;
}
|
java
|
public Object getOneOptional(String name) {
Object locator = find(name);
return locator != null ? _references.getOneOptional(locator) : null;
}
|
[
"public",
"Object",
"getOneOptional",
"(",
"String",
"name",
")",
"{",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"return",
"locator",
"!=",
"null",
"?",
"_references",
".",
"getOneOptional",
"(",
"locator",
")",
":",
"null",
";",
"}"
] |
Gets one optional dependency by its name.
@param name the dependency name to locate.
@return a dependency reference or null of the dependency was not found
|
[
"Gets",
"one",
"optional",
"dependency",
"by",
"its",
"name",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L227-L230
|
155,957
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.getOneOptional
|
public <T> T getOneOptional(Class<T> type, String name) {
Object locator = find(name);
return locator != null ? _references.getOneOptional(type, locator) : null;
}
|
java
|
public <T> T getOneOptional(Class<T> type, String name) {
Object locator = find(name);
return locator != null ? _references.getOneOptional(type, locator) : null;
}
|
[
"public",
"<",
"T",
">",
"T",
"getOneOptional",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"name",
")",
"{",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"return",
"locator",
"!=",
"null",
"?",
"_references",
".",
"getOneOptional",
"(",
"type",
",",
"locator",
")",
":",
"null",
";",
"}"
] |
Gets one optional dependency by its name and matching to the specified type.
@param type the Class type that defined the type of the result.
@param name the dependency name to locate.
@return a dependency reference or null of the dependency was not found
|
[
"Gets",
"one",
"optional",
"dependency",
"by",
"its",
"name",
"and",
"matching",
"to",
"the",
"specified",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L239-L242
|
155,958
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.getOneRequired
|
public Object getOneRequired(String name) throws ReferenceException {
Object locator = find(name);
if (locator == null)
throw new ReferenceException(null, name);
return _references.getOneRequired(locator);
}
|
java
|
public Object getOneRequired(String name) throws ReferenceException {
Object locator = find(name);
if (locator == null)
throw new ReferenceException(null, name);
return _references.getOneRequired(locator);
}
|
[
"public",
"Object",
"getOneRequired",
"(",
"String",
"name",
")",
"throws",
"ReferenceException",
"{",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"throw",
"new",
"ReferenceException",
"(",
"null",
",",
"name",
")",
";",
"return",
"_references",
".",
"getOneRequired",
"(",
"locator",
")",
";",
"}"
] |
Gets one required dependency by its name. At least one dependency must
present. If the dependency was found it throws a ReferenceException
@param name the dependency name to locate.
@return a dependency reference
@throws ReferenceException if dependency was not found.
|
[
"Gets",
"one",
"required",
"dependency",
"by",
"its",
"name",
".",
"At",
"least",
"one",
"dependency",
"must",
"present",
".",
"If",
"the",
"dependency",
"was",
"found",
"it",
"throws",
"a",
"ReferenceException"
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L253-L259
|
155,959
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.getOneRequired
|
public <T> T getOneRequired(Class<T> type, String name) throws ReferenceException {
Object locator = find(name);
if (locator == null)
throw new ReferenceException(null, name);
return _references.getOneRequired(type, locator);
}
|
java
|
public <T> T getOneRequired(Class<T> type, String name) throws ReferenceException {
Object locator = find(name);
if (locator == null)
throw new ReferenceException(null, name);
return _references.getOneRequired(type, locator);
}
|
[
"public",
"<",
"T",
">",
"T",
"getOneRequired",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"name",
")",
"throws",
"ReferenceException",
"{",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"throw",
"new",
"ReferenceException",
"(",
"null",
",",
"name",
")",
";",
"return",
"_references",
".",
"getOneRequired",
"(",
"type",
",",
"locator",
")",
";",
"}"
] |
Gets one required dependency by its name and matching to the specified type.
At least one dependency must present. If the dependency was found it throws a
ReferenceException
@param type the Class type that defined the type of the result.
@param name the dependency name to locate.
@return a dependency reference
@throws ReferenceException if dependency was not found.
|
[
"Gets",
"one",
"required",
"dependency",
"by",
"its",
"name",
"and",
"matching",
"to",
"the",
"specified",
"type",
".",
"At",
"least",
"one",
"dependency",
"must",
"present",
".",
"If",
"the",
"dependency",
"was",
"found",
"it",
"throws",
"a",
"ReferenceException"
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L272-L278
|
155,960
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.find
|
public List<Object> find(String name, boolean required) throws ReferenceException {
if (name == null || name.length() == 0) {
throw new NullPointerException(name);
}
Object locator = find(name);
if (locator == null) {
if (required) {
throw new ReferenceException(null, name);
}
return null;
}
return _references.find(locator, required);
}
|
java
|
public List<Object> find(String name, boolean required) throws ReferenceException {
if (name == null || name.length() == 0) {
throw new NullPointerException(name);
}
Object locator = find(name);
if (locator == null) {
if (required) {
throw new ReferenceException(null, name);
}
return null;
}
return _references.find(locator, required);
}
|
[
"public",
"List",
"<",
"Object",
">",
"find",
"(",
"String",
"name",
",",
"boolean",
"required",
")",
"throws",
"ReferenceException",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"name",
")",
";",
"}",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"{",
"if",
"(",
"required",
")",
"{",
"throw",
"new",
"ReferenceException",
"(",
"null",
",",
"name",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"_references",
".",
"find",
"(",
"locator",
",",
"required",
")",
";",
"}"
] |
Finds all matching dependencies by their name.
@param name the dependency name to locate.
@param required true to raise an exception when no dependencies are found.
@return a list of found dependencies
@throws ReferenceException of required is true and no dependencies found.
|
[
"Finds",
"all",
"matching",
"dependencies",
"by",
"their",
"name",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L289-L302
|
155,961
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/DependencyResolver.java
|
DependencyResolver.find
|
@SuppressWarnings("unchecked")
public <T> List<T> find(Class<T> type, String name, boolean required) throws ReferenceException {
if (name == null || name.length() == 0) {
throw new NullPointerException(name);
}
Object locator = find(name);
if (locator == null) {
if (required) {
throw new ReferenceException(null, name);
}
return null;
}
return (List<T>) _references.find(locator, required);
}
|
java
|
@SuppressWarnings("unchecked")
public <T> List<T> find(Class<T> type, String name, boolean required) throws ReferenceException {
if (name == null || name.length() == 0) {
throw new NullPointerException(name);
}
Object locator = find(name);
if (locator == null) {
if (required) {
throw new ReferenceException(null, name);
}
return null;
}
return (List<T>) _references.find(locator, required);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"find",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"name",
",",
"boolean",
"required",
")",
"throws",
"ReferenceException",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"name",
")",
";",
"}",
"Object",
"locator",
"=",
"find",
"(",
"name",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"{",
"if",
"(",
"required",
")",
"{",
"throw",
"new",
"ReferenceException",
"(",
"null",
",",
"name",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"(",
"List",
"<",
"T",
">",
")",
"_references",
".",
"find",
"(",
"locator",
",",
"required",
")",
";",
"}"
] |
Finds all matching dependencies by their name and matching to the specified
type.
@param type the Class type that defined the type of the result.
@param name the dependency name to locate.
@param required true to raise an exception when no dependencies are found.
@return a list of found dependencies
@throws ReferenceException of required is true and no dependencies found.
|
[
"Finds",
"all",
"matching",
"dependencies",
"by",
"their",
"name",
"and",
"matching",
"to",
"the",
"specified",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/DependencyResolver.java#L315-L329
|
155,962
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java
|
SubCommandSet.add
|
public SubCommandSet add(SubCommand<SubCommandDef> subCommand) {
if (subCommandMap.containsKey(subCommand.getName())) {
throw new IllegalArgumentException("SubCommand with name " + subCommand.getName() + " already exists");
}
this.subCommands.add(subCommand);
this.subCommandMap.put(subCommand.getName(), subCommand);
for (String alias : subCommand.getAliases()) {
if (subCommandMap.containsKey(alias)) {
throw new IllegalArgumentException("SubCommand (" + subCommand.getName() + ") alias " + alias + " already exists");
}
this.subCommandMap.put(alias, subCommand);
}
return this;
}
|
java
|
public SubCommandSet add(SubCommand<SubCommandDef> subCommand) {
if (subCommandMap.containsKey(subCommand.getName())) {
throw new IllegalArgumentException("SubCommand with name " + subCommand.getName() + " already exists");
}
this.subCommands.add(subCommand);
this.subCommandMap.put(subCommand.getName(), subCommand);
for (String alias : subCommand.getAliases()) {
if (subCommandMap.containsKey(alias)) {
throw new IllegalArgumentException("SubCommand (" + subCommand.getName() + ") alias " + alias + " already exists");
}
this.subCommandMap.put(alias, subCommand);
}
return this;
}
|
[
"public",
"SubCommandSet",
"add",
"(",
"SubCommand",
"<",
"SubCommandDef",
">",
"subCommand",
")",
"{",
"if",
"(",
"subCommandMap",
".",
"containsKey",
"(",
"subCommand",
".",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"SubCommand with name \"",
"+",
"subCommand",
".",
"getName",
"(",
")",
"+",
"\" already exists\"",
")",
";",
"}",
"this",
".",
"subCommands",
".",
"add",
"(",
"subCommand",
")",
";",
"this",
".",
"subCommandMap",
".",
"put",
"(",
"subCommand",
".",
"getName",
"(",
")",
",",
"subCommand",
")",
";",
"for",
"(",
"String",
"alias",
":",
"subCommand",
".",
"getAliases",
"(",
")",
")",
"{",
"if",
"(",
"subCommandMap",
".",
"containsKey",
"(",
"alias",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"SubCommand (\"",
"+",
"subCommand",
".",
"getName",
"(",
")",
"+",
"\") alias \"",
"+",
"alias",
"+",
"\" already exists\"",
")",
";",
"}",
"this",
".",
"subCommandMap",
".",
"put",
"(",
"alias",
",",
"subCommand",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Add a sub-command to the sub-command-set.
@param subCommand The sub-command to add.
@return The sub-command-set.
|
[
"Add",
"a",
"sub",
"-",
"command",
"to",
"the",
"sub",
"-",
"command",
"-",
"set",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java#L126-L139
|
155,963
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java
|
SubCommandSet.addAll
|
@SafeVarargs
public final SubCommandSet addAll(SubCommand<SubCommandDef>... subCommands) {
for (SubCommand<SubCommandDef> subCommand : subCommands) {
add(subCommand);
}
return this;
}
|
java
|
@SafeVarargs
public final SubCommandSet addAll(SubCommand<SubCommandDef>... subCommands) {
for (SubCommand<SubCommandDef> subCommand : subCommands) {
add(subCommand);
}
return this;
}
|
[
"@",
"SafeVarargs",
"public",
"final",
"SubCommandSet",
"addAll",
"(",
"SubCommand",
"<",
"SubCommandDef",
">",
"...",
"subCommands",
")",
"{",
"for",
"(",
"SubCommand",
"<",
"SubCommandDef",
">",
"subCommand",
":",
"subCommands",
")",
"{",
"add",
"(",
"subCommand",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Add a set of sub-commands to the sub-command-set.
@param subCommands The sub-commands to add.
@return The sub-command-set.
|
[
"Add",
"a",
"set",
"of",
"sub",
"-",
"commands",
"to",
"the",
"sub",
"-",
"command",
"-",
"set",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java#L147-L153
|
155,964
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java
|
SubCommandSet.printUsage
|
public void printUsage(OutputStream out, String name, boolean showHidden) {
printUsage(new PrintWriter(new OutputStreamWriter(out, UTF_8)), name, showHidden);
}
|
java
|
public void printUsage(OutputStream out, String name, boolean showHidden) {
printUsage(new PrintWriter(new OutputStreamWriter(out, UTF_8)), name, showHidden);
}
|
[
"public",
"void",
"printUsage",
"(",
"OutputStream",
"out",
",",
"String",
"name",
",",
"boolean",
"showHidden",
")",
"{",
"printUsage",
"(",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"out",
",",
"UTF_8",
")",
")",
",",
"name",
",",
"showHidden",
")",
";",
"}"
] |
Print the option usage list for the command.
@param out The output stream.
@param name The sub-command to print help for.
@param showHidden If hidden sub-commands should be shown.
|
[
"Print",
"the",
"option",
"usage",
"list",
"for",
"the",
"command",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java#L214-L216
|
155,965
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java
|
SubCommandSet.getSingleLineUsage
|
public String getSingleLineUsage(String name) {
for (SubCommand<SubCommandDef> cmd : subCommands) {
if (name.equals(cmd.getName())) {
return cmd.getArgumentParser(cmd.newInstance()).getSingleLineUsage();
}
}
throw new ArgumentException("No such " + getName() + " " + name);
}
|
java
|
public String getSingleLineUsage(String name) {
for (SubCommand<SubCommandDef> cmd : subCommands) {
if (name.equals(cmd.getName())) {
return cmd.getArgumentParser(cmd.newInstance()).getSingleLineUsage();
}
}
throw new ArgumentException("No such " + getName() + " " + name);
}
|
[
"public",
"String",
"getSingleLineUsage",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"SubCommand",
"<",
"SubCommandDef",
">",
"cmd",
":",
"subCommands",
")",
"{",
"if",
"(",
"name",
".",
"equals",
"(",
"cmd",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"cmd",
".",
"getArgumentParser",
"(",
"cmd",
".",
"newInstance",
"(",
")",
")",
".",
"getSingleLineUsage",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"ArgumentException",
"(",
"\"No such \"",
"+",
"getName",
"(",
")",
"+",
"\" \"",
"+",
"name",
")",
";",
"}"
] |
Get the single line usage string for a given sub-command.
@param name The sub-command to print help for.
@return The usage string.
|
[
"Get",
"the",
"single",
"line",
"usage",
"string",
"for",
"a",
"given",
"sub",
"-",
"command",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/args/SubCommandSet.java#L234-L241
|
155,966
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/PPMCodec.java
|
PPMCodec.encodePPM
|
public Bits encodePPM(String text, int context) {
final String original = text;
//if(verbose) System.p.println(String.format("Encoding %s run %s chars of context", text, context));
if (!text.endsWith("\u0000")) text += END_OF_STRING;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
BitOutputStream out = new BitOutputStream(buffer);
String contextStr = "";
try {
while (!text.isEmpty()) {
String right = getRight(contextStr, context);
TrieNode fromNode = inner.matchPredictor(right); // inner.matchEnd(right).getString()
String prefix = fromNode.getString();
// fromNode.getChildrenMap()
TrieNode toNode = fromNode.traverse(text);
int segmentChars = toNode.getDepth() - fromNode.getDepth();
if (toNode.hasChildren()) {
if (prefix.isEmpty() && 0 == segmentChars) {
Optional<? extends TrieNode> child = toNode.getChild(ESCAPE);
assert child.isPresent();
toNode = child.get();
}
else {
toNode = toNode.getChild(FALLBACK).get();
}
}
Interval interval = fromNode.intervalTo(toNode);
Bits segmentData = interval.toBits();
if (verbose) {
System.out.println(String.format(
"Using context \"%s\", encoded \"%s\" (%s chars) as %s -> %s",
fromNode.getDebugString(), toNode.getDebugString(fromNode), segmentChars, interval, segmentData));
}
out.write(segmentData);
if (0 == segmentChars) {
if (prefix.isEmpty()) {
//throw new RuntimeException(String.format("Cannot encode %s in model", text.substring(0,1)));
char exotic = text.charAt(0);
out.write(exotic);
if (verbose) {
System.out.println(String.format(
"Writing exotic character %s -> %s", exotic, new Bits(exotic, 16)));
}
text = text.substring(1);
}
else if (toNode.getChar() == FALLBACK) {
contextStr = prefix.substring(1);
}
else {
throw new RuntimeException("Cannot encode " + text.substring(0, 1));
}
}
else {
contextStr += text.substring(0, segmentChars);
text = text.substring(segmentChars);
}
}
out.flush();
Bits bits = new Bits(buffer.toByteArray(), out.getTotalBitsWritten());
//if(verbose) System.p.println(String.format("Encoded %s to %s", original, bits));
return bits;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public Bits encodePPM(String text, int context) {
final String original = text;
//if(verbose) System.p.println(String.format("Encoding %s run %s chars of context", text, context));
if (!text.endsWith("\u0000")) text += END_OF_STRING;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
BitOutputStream out = new BitOutputStream(buffer);
String contextStr = "";
try {
while (!text.isEmpty()) {
String right = getRight(contextStr, context);
TrieNode fromNode = inner.matchPredictor(right); // inner.matchEnd(right).getString()
String prefix = fromNode.getString();
// fromNode.getChildrenMap()
TrieNode toNode = fromNode.traverse(text);
int segmentChars = toNode.getDepth() - fromNode.getDepth();
if (toNode.hasChildren()) {
if (prefix.isEmpty() && 0 == segmentChars) {
Optional<? extends TrieNode> child = toNode.getChild(ESCAPE);
assert child.isPresent();
toNode = child.get();
}
else {
toNode = toNode.getChild(FALLBACK).get();
}
}
Interval interval = fromNode.intervalTo(toNode);
Bits segmentData = interval.toBits();
if (verbose) {
System.out.println(String.format(
"Using context \"%s\", encoded \"%s\" (%s chars) as %s -> %s",
fromNode.getDebugString(), toNode.getDebugString(fromNode), segmentChars, interval, segmentData));
}
out.write(segmentData);
if (0 == segmentChars) {
if (prefix.isEmpty()) {
//throw new RuntimeException(String.format("Cannot encode %s in model", text.substring(0,1)));
char exotic = text.charAt(0);
out.write(exotic);
if (verbose) {
System.out.println(String.format(
"Writing exotic character %s -> %s", exotic, new Bits(exotic, 16)));
}
text = text.substring(1);
}
else if (toNode.getChar() == FALLBACK) {
contextStr = prefix.substring(1);
}
else {
throw new RuntimeException("Cannot encode " + text.substring(0, 1));
}
}
else {
contextStr += text.substring(0, segmentChars);
text = text.substring(segmentChars);
}
}
out.flush();
Bits bits = new Bits(buffer.toByteArray(), out.getTotalBitsWritten());
//if(verbose) System.p.println(String.format("Encoded %s to %s", original, bits));
return bits;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"Bits",
"encodePPM",
"(",
"String",
"text",
",",
"int",
"context",
")",
"{",
"final",
"String",
"original",
"=",
"text",
";",
"//if(verbose) System.p.println(String.format(\"Encoding %s run %s chars of context\", text, context));",
"if",
"(",
"!",
"text",
".",
"endsWith",
"(",
"\"\\u0000\"",
")",
")",
"text",
"+=",
"END_OF_STRING",
";",
"ByteArrayOutputStream",
"buffer",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"BitOutputStream",
"out",
"=",
"new",
"BitOutputStream",
"(",
"buffer",
")",
";",
"String",
"contextStr",
"=",
"\"\"",
";",
"try",
"{",
"while",
"(",
"!",
"text",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"right",
"=",
"getRight",
"(",
"contextStr",
",",
"context",
")",
";",
"TrieNode",
"fromNode",
"=",
"inner",
".",
"matchPredictor",
"(",
"right",
")",
";",
"// inner.matchEnd(right).getString()",
"String",
"prefix",
"=",
"fromNode",
".",
"getString",
"(",
")",
";",
"// fromNode.getChildrenMap()",
"TrieNode",
"toNode",
"=",
"fromNode",
".",
"traverse",
"(",
"text",
")",
";",
"int",
"segmentChars",
"=",
"toNode",
".",
"getDepth",
"(",
")",
"-",
"fromNode",
".",
"getDepth",
"(",
")",
";",
"if",
"(",
"toNode",
".",
"hasChildren",
"(",
")",
")",
"{",
"if",
"(",
"prefix",
".",
"isEmpty",
"(",
")",
"&&",
"0",
"==",
"segmentChars",
")",
"{",
"Optional",
"<",
"?",
"extends",
"TrieNode",
">",
"child",
"=",
"toNode",
".",
"getChild",
"(",
"ESCAPE",
")",
";",
"assert",
"child",
".",
"isPresent",
"(",
")",
";",
"toNode",
"=",
"child",
".",
"get",
"(",
")",
";",
"}",
"else",
"{",
"toNode",
"=",
"toNode",
".",
"getChild",
"(",
"FALLBACK",
")",
".",
"get",
"(",
")",
";",
"}",
"}",
"Interval",
"interval",
"=",
"fromNode",
".",
"intervalTo",
"(",
"toNode",
")",
";",
"Bits",
"segmentData",
"=",
"interval",
".",
"toBits",
"(",
")",
";",
"if",
"(",
"verbose",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Using context \\\"%s\\\", encoded \\\"%s\\\" (%s chars) as %s -> %s\"",
",",
"fromNode",
".",
"getDebugString",
"(",
")",
",",
"toNode",
".",
"getDebugString",
"(",
"fromNode",
")",
",",
"segmentChars",
",",
"interval",
",",
"segmentData",
")",
")",
";",
"}",
"out",
".",
"write",
"(",
"segmentData",
")",
";",
"if",
"(",
"0",
"==",
"segmentChars",
")",
"{",
"if",
"(",
"prefix",
".",
"isEmpty",
"(",
")",
")",
"{",
"//throw new RuntimeException(String.format(\"Cannot encode %s in model\", text.substring(0,1)));",
"char",
"exotic",
"=",
"text",
".",
"charAt",
"(",
"0",
")",
";",
"out",
".",
"write",
"(",
"exotic",
")",
";",
"if",
"(",
"verbose",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Writing exotic character %s -> %s\"",
",",
"exotic",
",",
"new",
"Bits",
"(",
"exotic",
",",
"16",
")",
")",
")",
";",
"}",
"text",
"=",
"text",
".",
"substring",
"(",
"1",
")",
";",
"}",
"else",
"if",
"(",
"toNode",
".",
"getChar",
"(",
")",
"==",
"FALLBACK",
")",
"{",
"contextStr",
"=",
"prefix",
".",
"substring",
"(",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot encode \"",
"+",
"text",
".",
"substring",
"(",
"0",
",",
"1",
")",
")",
";",
"}",
"}",
"else",
"{",
"contextStr",
"+=",
"text",
".",
"substring",
"(",
"0",
",",
"segmentChars",
")",
";",
"text",
"=",
"text",
".",
"substring",
"(",
"segmentChars",
")",
";",
"}",
"}",
"out",
".",
"flush",
"(",
")",
";",
"Bits",
"bits",
"=",
"new",
"Bits",
"(",
"buffer",
".",
"toByteArray",
"(",
")",
",",
"out",
".",
"getTotalBitsWritten",
"(",
")",
")",
";",
"//if(verbose) System.p.println(String.format(\"Encoded %s to %s\", original, bits));",
"return",
"bits",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Encode ppm bits.
@param text the text
@param context the context
@return the bits
|
[
"Encode",
"ppm",
"bits",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/PPMCodec.java#L155-L220
|
155,967
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java
|
FxCopRuleSet.getNamedTagText
|
private String getNamedTagText(final Element element, final String tagName) {
Element foundElement = XmlElementUtil.getFirstElementByTagName(element, tagName);
if (foundElement == null) {
return "";
} else {
return foundElement.getTextContent();
}
}
|
java
|
private String getNamedTagText(final Element element, final String tagName) {
Element foundElement = XmlElementUtil.getFirstElementByTagName(element, tagName);
if (foundElement == null) {
return "";
} else {
return foundElement.getTextContent();
}
}
|
[
"private",
"String",
"getNamedTagText",
"(",
"final",
"Element",
"element",
",",
"final",
"String",
"tagName",
")",
"{",
"Element",
"foundElement",
"=",
"XmlElementUtil",
".",
"getFirstElementByTagName",
"(",
"element",
",",
"tagName",
")",
";",
"if",
"(",
"foundElement",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"return",
"foundElement",
".",
"getTextContent",
"(",
")",
";",
"}",
"}"
] |
Returns the text value of the named child element if it exists
@param element the element to check look for child elements
@param tagName the name of the child element
@return the text value; or "" if no element was found
|
[
"Returns",
"the",
"text",
"value",
"of",
"the",
"named",
"child",
"element",
"if",
"it",
"exists"
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java#L38-L45
|
155,968
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java
|
FxCopRuleSet.contains
|
public boolean contains(final String category, final String checkId) {
return (rules.containsKey(getRuleKey(category, checkId)));
}
|
java
|
public boolean contains(final String category, final String checkId) {
return (rules.containsKey(getRuleKey(category, checkId)));
}
|
[
"public",
"boolean",
"contains",
"(",
"final",
"String",
"category",
",",
"final",
"String",
"checkId",
")",
"{",
"return",
"(",
"rules",
".",
"containsKey",
"(",
"getRuleKey",
"(",
"category",
",",
"checkId",
")",
")",
")",
";",
"}"
] |
Returns if the rule set contains a rule for the specified category and id
@param category the rule category
@param checkId the rule id
@return
|
[
"Returns",
"if",
"the",
"rule",
"set",
"contains",
"a",
"rule",
"for",
"the",
"specified",
"category",
"and",
"id"
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java#L53-L55
|
155,969
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java
|
FxCopRuleSet.getRule
|
public FxCopRule getRule(final String category, final String checkId) {
String key = getRuleKey(category, checkId);
FxCopRule rule = null;
if (rules.containsKey(key)) {
rule = rules.get(key);
}
return rule;
}
|
java
|
public FxCopRule getRule(final String category, final String checkId) {
String key = getRuleKey(category, checkId);
FxCopRule rule = null;
if (rules.containsKey(key)) {
rule = rules.get(key);
}
return rule;
}
|
[
"public",
"FxCopRule",
"getRule",
"(",
"final",
"String",
"category",
",",
"final",
"String",
"checkId",
")",
"{",
"String",
"key",
"=",
"getRuleKey",
"(",
"category",
",",
"checkId",
")",
";",
"FxCopRule",
"rule",
"=",
"null",
";",
"if",
"(",
"rules",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"rule",
"=",
"rules",
".",
"get",
"(",
"key",
")",
";",
"}",
"return",
"rule",
";",
"}"
] |
Returns the specified rule if it exists
@param category the rule category
@param checkId the id of the rule
@return the rule; null otherwise
|
[
"Returns",
"the",
"specified",
"rule",
"if",
"it",
"exists"
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/fxcop/FxCopRuleSet.java#L63-L70
|
155,970
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.isPrefixFreeCode
|
public static boolean isPrefixFreeCode(final Set<Bits> keySet) {
final TreeSet<Bits> check = new TreeSet<Bits>();
for (final Bits code : keySet) {
final Bits ceiling = check.ceiling(code);
if (null != ceiling
&& (ceiling.startsWith(code) || code.startsWith(ceiling))) {
return false;
}
final Bits floor = check.floor(code);
if (null != floor && (floor.startsWith(code) || code.startsWith(floor))) {
return false;
}
check.add(code);
}
return true;
}
|
java
|
public static boolean isPrefixFreeCode(final Set<Bits> keySet) {
final TreeSet<Bits> check = new TreeSet<Bits>();
for (final Bits code : keySet) {
final Bits ceiling = check.ceiling(code);
if (null != ceiling
&& (ceiling.startsWith(code) || code.startsWith(ceiling))) {
return false;
}
final Bits floor = check.floor(code);
if (null != floor && (floor.startsWith(code) || code.startsWith(floor))) {
return false;
}
check.add(code);
}
return true;
}
|
[
"public",
"static",
"boolean",
"isPrefixFreeCode",
"(",
"final",
"Set",
"<",
"Bits",
">",
"keySet",
")",
"{",
"final",
"TreeSet",
"<",
"Bits",
">",
"check",
"=",
"new",
"TreeSet",
"<",
"Bits",
">",
"(",
")",
";",
"for",
"(",
"final",
"Bits",
"code",
":",
"keySet",
")",
"{",
"final",
"Bits",
"ceiling",
"=",
"check",
".",
"ceiling",
"(",
"code",
")",
";",
"if",
"(",
"null",
"!=",
"ceiling",
"&&",
"(",
"ceiling",
".",
"startsWith",
"(",
"code",
")",
"||",
"code",
".",
"startsWith",
"(",
"ceiling",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"Bits",
"floor",
"=",
"check",
".",
"floor",
"(",
"code",
")",
";",
"if",
"(",
"null",
"!=",
"floor",
"&&",
"(",
"floor",
".",
"startsWith",
"(",
"code",
")",
"||",
"code",
".",
"startsWith",
"(",
"floor",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"check",
".",
"add",
"(",
"code",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Is prefix free code boolean.
@param keySet the key set
@return the boolean
|
[
"Is",
"prefix",
"free",
"code",
"boolean",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L88-L103
|
155,971
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.decode
|
public T decode(final BitInputStream in) throws IOException {
Bits remainder = in.readAhead(0);
Entry<Bits, T> entry = this.forwardIndex.floorEntry(remainder);
while (entry == null || !remainder.startsWith(entry.getKey())) {
remainder = in.readAhead();
entry = this.forwardIndex.floorEntry(remainder);
}
in.read(entry.getKey().bitLength);
return entry.getValue();
}
|
java
|
public T decode(final BitInputStream in) throws IOException {
Bits remainder = in.readAhead(0);
Entry<Bits, T> entry = this.forwardIndex.floorEntry(remainder);
while (entry == null || !remainder.startsWith(entry.getKey())) {
remainder = in.readAhead();
entry = this.forwardIndex.floorEntry(remainder);
}
in.read(entry.getKey().bitLength);
return entry.getValue();
}
|
[
"public",
"T",
"decode",
"(",
"final",
"BitInputStream",
"in",
")",
"throws",
"IOException",
"{",
"Bits",
"remainder",
"=",
"in",
".",
"readAhead",
"(",
"0",
")",
";",
"Entry",
"<",
"Bits",
",",
"T",
">",
"entry",
"=",
"this",
".",
"forwardIndex",
".",
"floorEntry",
"(",
"remainder",
")",
";",
"while",
"(",
"entry",
"==",
"null",
"||",
"!",
"remainder",
".",
"startsWith",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"remainder",
"=",
"in",
".",
"readAhead",
"(",
")",
";",
"entry",
"=",
"this",
".",
"forwardIndex",
".",
"floorEntry",
"(",
"remainder",
")",
";",
"}",
"in",
".",
"read",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"bitLength",
")",
";",
"return",
"entry",
".",
"getValue",
"(",
")",
";",
"}"
] |
Decode t.
@param in the in
@return the t
@throws IOException the io exception
|
[
"Decode",
"t",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L121-L130
|
155,972
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.decode
|
public Entry<Bits, T> decode(final Bits data) {
if (null == data) {
throw new IllegalArgumentException();
}
Entry<Bits, T> entry = this.forwardIndex.floorEntry(data);
// TestUtil.openJson(new JSONObject(forwardIndex));
if (entry != null && !data.startsWith(entry.getKey())) {
entry = null;
}
// assert(null != entry || verifyIndexes());
return entry;
}
|
java
|
public Entry<Bits, T> decode(final Bits data) {
if (null == data) {
throw new IllegalArgumentException();
}
Entry<Bits, T> entry = this.forwardIndex.floorEntry(data);
// TestUtil.openJson(new JSONObject(forwardIndex));
if (entry != null && !data.startsWith(entry.getKey())) {
entry = null;
}
// assert(null != entry || verifyIndexes());
return entry;
}
|
[
"public",
"Entry",
"<",
"Bits",
",",
"T",
">",
"decode",
"(",
"final",
"Bits",
"data",
")",
"{",
"if",
"(",
"null",
"==",
"data",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"Entry",
"<",
"Bits",
",",
"T",
">",
"entry",
"=",
"this",
".",
"forwardIndex",
".",
"floorEntry",
"(",
"data",
")",
";",
"// TestUtil.openJson(new JSONObject(forwardIndex));",
"if",
"(",
"entry",
"!=",
"null",
"&&",
"!",
"data",
".",
"startsWith",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"entry",
"=",
"null",
";",
"}",
"// assert(null != entry || verifyIndexes());",
"return",
"entry",
";",
"}"
] |
Decode entry.
@param data the data
@return the entry
|
[
"Decode",
"entry",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L138-L149
|
155,973
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.encode
|
public Bits encode(final T key) {
final Bits bits = this.reverseIndex.get(key);
assert null != bits || this.verifyIndexes();
return bits;
}
|
java
|
public Bits encode(final T key) {
final Bits bits = this.reverseIndex.get(key);
assert null != bits || this.verifyIndexes();
return bits;
}
|
[
"public",
"Bits",
"encode",
"(",
"final",
"T",
"key",
")",
"{",
"final",
"Bits",
"bits",
"=",
"this",
".",
"reverseIndex",
".",
"get",
"(",
"key",
")",
";",
"assert",
"null",
"!=",
"bits",
"||",
"this",
".",
"verifyIndexes",
"(",
")",
";",
"return",
"bits",
";",
"}"
] |
Encode bits.
@param key the key
@return the bits
|
[
"Encode",
"bits",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L157-L161
|
155,974
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.getCodes
|
public SortedMap<Bits, T> getCodes(final Bits fromKey) {
final Bits next = fromKey.next();
final SortedMap<Bits, T> subMap = null == next ? this.forwardIndex
.tailMap(fromKey) : this.forwardIndex.subMap(fromKey, next);
return subMap;
}
|
java
|
public SortedMap<Bits, T> getCodes(final Bits fromKey) {
final Bits next = fromKey.next();
final SortedMap<Bits, T> subMap = null == next ? this.forwardIndex
.tailMap(fromKey) : this.forwardIndex.subMap(fromKey, next);
return subMap;
}
|
[
"public",
"SortedMap",
"<",
"Bits",
",",
"T",
">",
"getCodes",
"(",
"final",
"Bits",
"fromKey",
")",
"{",
"final",
"Bits",
"next",
"=",
"fromKey",
".",
"next",
"(",
")",
";",
"final",
"SortedMap",
"<",
"Bits",
",",
"T",
">",
"subMap",
"=",
"null",
"==",
"next",
"?",
"this",
".",
"forwardIndex",
".",
"tailMap",
"(",
"fromKey",
")",
":",
"this",
".",
"forwardIndex",
".",
"subMap",
"(",
"fromKey",
",",
"next",
")",
";",
"return",
"subMap",
";",
"}"
] |
Gets codes.
@param fromKey the from key
@return the codes
|
[
"Gets",
"codes",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L169-L174
|
155,975
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java
|
HammingCode.verifyIndexes
|
public boolean verifyIndexes() {
if (!isPrefixFreeCode(this.forwardIndex.keySet())) {
return false;
}
for (final Entry<Bits, T> e : this.forwardIndex.entrySet()) {
if (!e.getKey().equals(this.reverseIndex.get(e.getValue()))) {
return false;
}
if (!e.getValue().equals(this.forwardIndex.get(e.getKey()))) {
return false;
}
}
for (final Entry<T, Bits> e : this.reverseIndex.entrySet()) {
if (!e.getKey().equals(this.forwardIndex.get(e.getValue()))) {
return false;
}
if (!e.getValue().equals(this.reverseIndex.get(e.getKey()))) {
return false;
}
}
return this.reverseIndex.size() == this.forwardIndex.size();
}
|
java
|
public boolean verifyIndexes() {
if (!isPrefixFreeCode(this.forwardIndex.keySet())) {
return false;
}
for (final Entry<Bits, T> e : this.forwardIndex.entrySet()) {
if (!e.getKey().equals(this.reverseIndex.get(e.getValue()))) {
return false;
}
if (!e.getValue().equals(this.forwardIndex.get(e.getKey()))) {
return false;
}
}
for (final Entry<T, Bits> e : this.reverseIndex.entrySet()) {
if (!e.getKey().equals(this.forwardIndex.get(e.getValue()))) {
return false;
}
if (!e.getValue().equals(this.reverseIndex.get(e.getKey()))) {
return false;
}
}
return this.reverseIndex.size() == this.forwardIndex.size();
}
|
[
"public",
"boolean",
"verifyIndexes",
"(",
")",
"{",
"if",
"(",
"!",
"isPrefixFreeCode",
"(",
"this",
".",
"forwardIndex",
".",
"keySet",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"final",
"Entry",
"<",
"Bits",
",",
"T",
">",
"e",
":",
"this",
".",
"forwardIndex",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"e",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"this",
".",
"reverseIndex",
".",
"get",
"(",
"e",
".",
"getValue",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"e",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"this",
".",
"forwardIndex",
".",
"get",
"(",
"e",
".",
"getKey",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"final",
"Entry",
"<",
"T",
",",
"Bits",
">",
"e",
":",
"this",
".",
"reverseIndex",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"e",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"this",
".",
"forwardIndex",
".",
"get",
"(",
"e",
".",
"getValue",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"e",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"this",
".",
"reverseIndex",
".",
"get",
"(",
"e",
".",
"getKey",
"(",
")",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"this",
".",
"reverseIndex",
".",
"size",
"(",
")",
"==",
"this",
".",
"forwardIndex",
".",
"size",
"(",
")",
";",
"}"
] |
Verify indexes boolean.
@return the boolean
|
[
"Verify",
"indexes",
"boolean",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/codes/HammingCode.java#L223-L244
|
155,976
|
foundation-runtime/service-directory
|
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java
|
ServiceInstanceUtils.toServiceInstance
|
public static ServiceInstance toServiceInstance(
ModelServiceInstance modelInstance) {
if (modelInstance==null) throw new NullPointerException();
Map<String, String> meta = new HashMap<>();
if (modelInstance.getMetadata() != null) {
for (Entry<String, String> en : modelInstance.getMetadata()
.entrySet()) {
meta.put(en.getKey(), en.getValue());
}
}
return new ServiceInstance(modelInstance.getServiceName(),
modelInstance.getUri(),
modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
modelInstance.getAddress(),meta, modelInstance.getPort(), modelInstance.getTls_port(), modelInstance.getProtocol());
}
|
java
|
public static ServiceInstance toServiceInstance(
ModelServiceInstance modelInstance) {
if (modelInstance==null) throw new NullPointerException();
Map<String, String> meta = new HashMap<>();
if (modelInstance.getMetadata() != null) {
for (Entry<String, String> en : modelInstance.getMetadata()
.entrySet()) {
meta.put(en.getKey(), en.getValue());
}
}
return new ServiceInstance(modelInstance.getServiceName(),
modelInstance.getUri(),
modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
modelInstance.getAddress(),meta, modelInstance.getPort(), modelInstance.getTls_port(), modelInstance.getProtocol());
}
|
[
"public",
"static",
"ServiceInstance",
"toServiceInstance",
"(",
"ModelServiceInstance",
"modelInstance",
")",
"{",
"if",
"(",
"modelInstance",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"meta",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"modelInstance",
".",
"getMetadata",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"en",
":",
"modelInstance",
".",
"getMetadata",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"meta",
".",
"put",
"(",
"en",
".",
"getKey",
"(",
")",
",",
"en",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"new",
"ServiceInstance",
"(",
"modelInstance",
".",
"getServiceName",
"(",
")",
",",
"modelInstance",
".",
"getUri",
"(",
")",
",",
"modelInstance",
".",
"isMonitorEnabled",
"(",
")",
",",
"modelInstance",
".",
"getStatus",
"(",
")",
",",
"modelInstance",
".",
"getAddress",
"(",
")",
",",
"meta",
",",
"modelInstance",
".",
"getPort",
"(",
")",
",",
"modelInstance",
".",
"getTls_port",
"(",
")",
",",
"modelInstance",
".",
"getProtocol",
"(",
")",
")",
";",
"}"
] |
Convert a ModelServiceInstance to a ServiceInstance object.
It will do the deep clone for the metadata.
@param modelInstance
the ModelServiceInstance object.
@return the ServiceInstance Object.
|
[
"Convert",
"a",
"ModelServiceInstance",
"to",
"a",
"ServiceInstance",
"object",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java#L57-L71
|
155,977
|
foundation-runtime/service-directory
|
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java
|
ServiceInstanceUtils.toServiceInstance11
|
public static ServiceInstance11 toServiceInstance11(ModelServiceInstance11 modelInstance){
if (modelInstance==null) throw new NullPointerException();
Map<String, String> meta = new HashMap<>();
if (modelInstance.getMetadata() != null) {
for (Entry<String, String> en : modelInstance.getMetadata()
.entrySet()) {
meta.put(en.getKey(), en.getValue());
}
}
return new ServiceInstance11(modelInstance.getServiceName(),
modelInstance.getInstanceId(),
modelInstance.getUri(),
modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
modelInstance.getAddress(), modelInstance.getPort(), meta);
}
|
java
|
public static ServiceInstance11 toServiceInstance11(ModelServiceInstance11 modelInstance){
if (modelInstance==null) throw new NullPointerException();
Map<String, String> meta = new HashMap<>();
if (modelInstance.getMetadata() != null) {
for (Entry<String, String> en : modelInstance.getMetadata()
.entrySet()) {
meta.put(en.getKey(), en.getValue());
}
}
return new ServiceInstance11(modelInstance.getServiceName(),
modelInstance.getInstanceId(),
modelInstance.getUri(),
modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
modelInstance.getAddress(), modelInstance.getPort(), meta);
}
|
[
"public",
"static",
"ServiceInstance11",
"toServiceInstance11",
"(",
"ModelServiceInstance11",
"modelInstance",
")",
"{",
"if",
"(",
"modelInstance",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"meta",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"modelInstance",
".",
"getMetadata",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"en",
":",
"modelInstance",
".",
"getMetadata",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"meta",
".",
"put",
"(",
"en",
".",
"getKey",
"(",
")",
",",
"en",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"new",
"ServiceInstance11",
"(",
"modelInstance",
".",
"getServiceName",
"(",
")",
",",
"modelInstance",
".",
"getInstanceId",
"(",
")",
",",
"modelInstance",
".",
"getUri",
"(",
")",
",",
"modelInstance",
".",
"isMonitorEnabled",
"(",
")",
",",
"modelInstance",
".",
"getStatus",
"(",
")",
",",
"modelInstance",
".",
"getAddress",
"(",
")",
",",
"modelInstance",
".",
"getPort",
"(",
")",
",",
"meta",
")",
";",
"}"
] |
convert v1.1 modelServiceInstance to serviceInstance
@param modelInstance the ModelServiceInstance11 object
@return the ServiceInstance11 object
|
[
"convert",
"v1",
".",
"1",
"modelServiceInstance",
"to",
"serviceInstance"
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java#L78-L92
|
155,978
|
foundation-runtime/service-directory
|
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java
|
ServiceInstanceUtils.copyModelInstFrom
|
public static ModelServiceInstance copyModelInstFrom(ModelServiceInstance original) {
ModelServiceInstance copied = new ModelServiceInstance();
copied.setServiceName(original.getServiceName());
copied.setAddress(original.getAddress());
copied.setStatus(original.getStatus());
copied.setUri(original.getUri());
copied.setId(original.getId());
copied.setInstanceId(original.getInstanceId());
copied.setMonitorEnabled(original.isMonitorEnabled());
copied.setCreateTime(original.getCreateTime());
copied.setModifiedTime(original.getModifiedTime());
copied.setHeartbeatTime(original.getHeartbeatTime());
Map<String,String> newMeta = new HashMap<>();
Map<String,String> oldMeta = original.getMetadata();
if (oldMeta!=null) newMeta.putAll(oldMeta);
copied.setMetadata(newMeta);
return copied;
}
|
java
|
public static ModelServiceInstance copyModelInstFrom(ModelServiceInstance original) {
ModelServiceInstance copied = new ModelServiceInstance();
copied.setServiceName(original.getServiceName());
copied.setAddress(original.getAddress());
copied.setStatus(original.getStatus());
copied.setUri(original.getUri());
copied.setId(original.getId());
copied.setInstanceId(original.getInstanceId());
copied.setMonitorEnabled(original.isMonitorEnabled());
copied.setCreateTime(original.getCreateTime());
copied.setModifiedTime(original.getModifiedTime());
copied.setHeartbeatTime(original.getHeartbeatTime());
Map<String,String> newMeta = new HashMap<>();
Map<String,String> oldMeta = original.getMetadata();
if (oldMeta!=null) newMeta.putAll(oldMeta);
copied.setMetadata(newMeta);
return copied;
}
|
[
"public",
"static",
"ModelServiceInstance",
"copyModelInstFrom",
"(",
"ModelServiceInstance",
"original",
")",
"{",
"ModelServiceInstance",
"copied",
"=",
"new",
"ModelServiceInstance",
"(",
")",
";",
"copied",
".",
"setServiceName",
"(",
"original",
".",
"getServiceName",
"(",
")",
")",
";",
"copied",
".",
"setAddress",
"(",
"original",
".",
"getAddress",
"(",
")",
")",
";",
"copied",
".",
"setStatus",
"(",
"original",
".",
"getStatus",
"(",
")",
")",
";",
"copied",
".",
"setUri",
"(",
"original",
".",
"getUri",
"(",
")",
")",
";",
"copied",
".",
"setId",
"(",
"original",
".",
"getId",
"(",
")",
")",
";",
"copied",
".",
"setInstanceId",
"(",
"original",
".",
"getInstanceId",
"(",
")",
")",
";",
"copied",
".",
"setMonitorEnabled",
"(",
"original",
".",
"isMonitorEnabled",
"(",
")",
")",
";",
"copied",
".",
"setCreateTime",
"(",
"original",
".",
"getCreateTime",
"(",
")",
")",
";",
"copied",
".",
"setModifiedTime",
"(",
"original",
".",
"getModifiedTime",
"(",
")",
")",
";",
"copied",
".",
"setHeartbeatTime",
"(",
"original",
".",
"getHeartbeatTime",
"(",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"newMeta",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"oldMeta",
"=",
"original",
".",
"getMetadata",
"(",
")",
";",
"if",
"(",
"oldMeta",
"!=",
"null",
")",
"newMeta",
".",
"putAll",
"(",
"oldMeta",
")",
";",
"copied",
".",
"setMetadata",
"(",
"newMeta",
")",
";",
"return",
"copied",
";",
"}"
] |
Create new copy of ModelServiceInstance from the original one.
|
[
"Create",
"new",
"copy",
"of",
"ModelServiceInstance",
"from",
"the",
"original",
"one",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ServiceInstanceUtils.java#L97-L114
|
155,979
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/grammar/GrammarFile.java
|
GrammarFile.read
|
private void read() throws IOException, GrammarException {
try {
logger.debug("Read grammar file...");
logger.debug("Starting lexer...");
Lexer lexer = new RegExpLexer(uhuraGrammar);
TokenStream tokenStream = lexer.lex(SourceCode.read(reader,
new UnspecifiedSourceCodeLocation()));
logger.debug("Starting parser...");
parse(tokenStream);
logger.debug("done reading grammar file.");
} catch (LexerException e) {
logger.error(e.getMessage(), e);
throw new IOException(e.getMessage(), e);
} catch (ParserException e) {
logger.error(e.getMessage(), e);
throw new IOException(e.getMessage(), e);
}
}
|
java
|
private void read() throws IOException, GrammarException {
try {
logger.debug("Read grammar file...");
logger.debug("Starting lexer...");
Lexer lexer = new RegExpLexer(uhuraGrammar);
TokenStream tokenStream = lexer.lex(SourceCode.read(reader,
new UnspecifiedSourceCodeLocation()));
logger.debug("Starting parser...");
parse(tokenStream);
logger.debug("done reading grammar file.");
} catch (LexerException e) {
logger.error(e.getMessage(), e);
throw new IOException(e.getMessage(), e);
} catch (ParserException e) {
logger.error(e.getMessage(), e);
throw new IOException(e.getMessage(), e);
}
}
|
[
"private",
"void",
"read",
"(",
")",
"throws",
"IOException",
",",
"GrammarException",
"{",
"try",
"{",
"logger",
".",
"debug",
"(",
"\"Read grammar file...\"",
")",
";",
"logger",
".",
"debug",
"(",
"\"Starting lexer...\"",
")",
";",
"Lexer",
"lexer",
"=",
"new",
"RegExpLexer",
"(",
"uhuraGrammar",
")",
";",
"TokenStream",
"tokenStream",
"=",
"lexer",
".",
"lex",
"(",
"SourceCode",
".",
"read",
"(",
"reader",
",",
"new",
"UnspecifiedSourceCodeLocation",
"(",
")",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Starting parser...\"",
")",
";",
"parse",
"(",
"tokenStream",
")",
";",
"logger",
".",
"debug",
"(",
"\"done reading grammar file.\"",
")",
";",
"}",
"catch",
"(",
"LexerException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"ParserException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"IOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
This is the central reading routine which starts all sub routines like
lexer, parser and converter.
@throws IOException
@throws GrammarException
|
[
"This",
"is",
"the",
"central",
"reading",
"routine",
"which",
"starts",
"all",
"sub",
"routines",
"like",
"lexer",
"parser",
"and",
"converter",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/grammar/GrammarFile.java#L92-L109
|
155,980
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/grammar/GrammarFile.java
|
GrammarFile.parse
|
private void parse(TokenStream tokenStream) throws ParserException {
try {
Parser parser = new SLR1Parser(uhuraGrammar);
parserTree = parser.parse(tokenStream);
} catch (GrammarException e) {
logger.error(e.getMessage(), e);
throw new RuntimeException("UhuraGrammar is broken!!!");
}
}
|
java
|
private void parse(TokenStream tokenStream) throws ParserException {
try {
Parser parser = new SLR1Parser(uhuraGrammar);
parserTree = parser.parse(tokenStream);
} catch (GrammarException e) {
logger.error(e.getMessage(), e);
throw new RuntimeException("UhuraGrammar is broken!!!");
}
}
|
[
"private",
"void",
"parse",
"(",
"TokenStream",
"tokenStream",
")",
"throws",
"ParserException",
"{",
"try",
"{",
"Parser",
"parser",
"=",
"new",
"SLR1Parser",
"(",
"uhuraGrammar",
")",
";",
"parserTree",
"=",
"parser",
".",
"parse",
"(",
"tokenStream",
")",
";",
"}",
"catch",
"(",
"GrammarException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"UhuraGrammar is broken!!!\"",
")",
";",
"}",
"}"
] |
This method does the parsing and reacts appropriately to any exceptions.
@param tokenStream
is the token stream to read the grammar from.
@throws ParserException
is thrown in case of a parser issue.
|
[
"This",
"method",
"does",
"the",
"parsing",
"and",
"reacts",
"appropriately",
"to",
"any",
"exceptions",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/grammar/GrammarFile.java#L119-L127
|
155,981
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.getParserForName
|
public static ConfigParser getParserForName(String name) {
int lastDot = name.lastIndexOf(".");
if (lastDot < 0) {
throw new ConfigException("No file suffix in name: " + name);
}
String suffix = name.substring(lastDot);
switch (suffix.toLowerCase()) {
case ".toml":
case ".ini":
return new TomlConfigParser();
case ".json":
return new JsonConfigParser();
case ".properties":
return new PropertiesConfigParser();
default:
throw new ConfigException("Unknown config file suffix: " + suffix);
}
}
|
java
|
public static ConfigParser getParserForName(String name) {
int lastDot = name.lastIndexOf(".");
if (lastDot < 0) {
throw new ConfigException("No file suffix in name: " + name);
}
String suffix = name.substring(lastDot);
switch (suffix.toLowerCase()) {
case ".toml":
case ".ini":
return new TomlConfigParser();
case ".json":
return new JsonConfigParser();
case ".properties":
return new PropertiesConfigParser();
default:
throw new ConfigException("Unknown config file suffix: " + suffix);
}
}
|
[
"public",
"static",
"ConfigParser",
"getParserForName",
"(",
"String",
"name",
")",
"{",
"int",
"lastDot",
"=",
"name",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"if",
"(",
"lastDot",
"<",
"0",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"No file suffix in name: \"",
"+",
"name",
")",
";",
"}",
"String",
"suffix",
"=",
"name",
".",
"substring",
"(",
"lastDot",
")",
";",
"switch",
"(",
"suffix",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"\".toml\"",
":",
"case",
"\".ini\"",
":",
"return",
"new",
"TomlConfigParser",
"(",
")",
";",
"case",
"\".json\"",
":",
"return",
"new",
"JsonConfigParser",
"(",
")",
";",
"case",
"\".properties\"",
":",
"return",
"new",
"PropertiesConfigParser",
"(",
")",
";",
"default",
":",
"throw",
"new",
"ConfigException",
"(",
"\"Unknown config file suffix: \"",
"+",
"suffix",
")",
";",
"}",
"}"
] |
Get the parser that matches the file format associated with the given
file suffix. The given string must include the last '.' in order to be
valid.
@param name The file name.
@return The associated config parser.
@throws ConfigException If no known parser is associated with the file
suffix, or the file name does not have a dot.
|
[
"Get",
"the",
"parser",
"that",
"matches",
"the",
"file",
"format",
"associated",
"with",
"the",
"given",
"file",
"suffix",
".",
"The",
"given",
"string",
"must",
"include",
"the",
"last",
".",
"in",
"order",
"to",
"be",
"valid",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L61-L78
|
155,982
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asDouble
|
public static double asDouble(Object value) {
if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof Numeric) {
return ((Numeric) value).asInteger();
} else if (value instanceof CharSequence) {
try {
return Double.parseDouble(value.toString());
} catch (NumberFormatException nfe) {
throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
"\" to a double", nfe);
}
}
throw new IncompatibleValueException(
"Unable to convert " + value.getClass().getSimpleName() + " to a double");
}
|
java
|
public static double asDouble(Object value) {
if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof Numeric) {
return ((Numeric) value).asInteger();
} else if (value instanceof CharSequence) {
try {
return Double.parseDouble(value.toString());
} catch (NumberFormatException nfe) {
throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
"\" to a double", nfe);
}
}
throw new IncompatibleValueException(
"Unable to convert " + value.getClass().getSimpleName() + " to a double");
}
|
[
"public",
"static",
"double",
"asDouble",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"value",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Numeric",
")",
"{",
"return",
"(",
"(",
"Numeric",
")",
"value",
")",
".",
"asInteger",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"CharSequence",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"throw",
"new",
"IncompatibleValueException",
"(",
"\"Unable to parse string \\\"\"",
"+",
"Strings",
".",
"escape",
"(",
"value",
".",
"toString",
"(",
")",
")",
"+",
"\"\\\" to a double\"",
",",
"nfe",
")",
";",
"}",
"}",
"throw",
"new",
"IncompatibleValueException",
"(",
"\"Unable to convert \"",
"+",
"value",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\" to a double\"",
")",
";",
"}"
] |
Convert the value to a souble.
@param value The value instance.
@return The double value.
|
[
"Convert",
"the",
"value",
"to",
"a",
"souble",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L181-L196
|
155,983
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asDate
|
public static Date asDate(Object value) {
if (value instanceof Date) {
return (Date) value;
} else if (value instanceof CharSequence) {
String date = value.toString().trim();
try {
LocalDateTime time;
if (date.endsWith("Z")) {
time = LocalDateTime.parse((CharSequence) value,
DateTimeFormatter.ISO_INSTANT.withZone(Clock.systemUTC().getZone()));
} else {
time = LocalDateTime.parse((CharSequence) value,
DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(Clock.systemUTC().getZone()));
}
return new Date(time.atZone(Clock.systemUTC()
.getZone()).toInstant().toEpochMilli());
} catch (RuntimeException e) {
throw new ConfigException(e, "Unable to parse date: " + e.getMessage());
}
} else if (value instanceof Long) {
// Longs are assumed to be java time (millis since epoch).
return new Date((Long) value);
} else if (value instanceof Integer) {
// Integers are assumed to be unix time (seconds since epoch).
return new Date(((Integer) value).longValue() * 1000L);
} else {
throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a date");
}
}
|
java
|
public static Date asDate(Object value) {
if (value instanceof Date) {
return (Date) value;
} else if (value instanceof CharSequence) {
String date = value.toString().trim();
try {
LocalDateTime time;
if (date.endsWith("Z")) {
time = LocalDateTime.parse((CharSequence) value,
DateTimeFormatter.ISO_INSTANT.withZone(Clock.systemUTC().getZone()));
} else {
time = LocalDateTime.parse((CharSequence) value,
DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(Clock.systemUTC().getZone()));
}
return new Date(time.atZone(Clock.systemUTC()
.getZone()).toInstant().toEpochMilli());
} catch (RuntimeException e) {
throw new ConfigException(e, "Unable to parse date: " + e.getMessage());
}
} else if (value instanceof Long) {
// Longs are assumed to be java time (millis since epoch).
return new Date((Long) value);
} else if (value instanceof Integer) {
// Integers are assumed to be unix time (seconds since epoch).
return new Date(((Integer) value).longValue() * 1000L);
} else {
throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a date");
}
}
|
[
"public",
"static",
"Date",
"asDate",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"{",
"return",
"(",
"Date",
")",
"value",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"CharSequence",
")",
"{",
"String",
"date",
"=",
"value",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"try",
"{",
"LocalDateTime",
"time",
";",
"if",
"(",
"date",
".",
"endsWith",
"(",
"\"Z\"",
")",
")",
"{",
"time",
"=",
"LocalDateTime",
".",
"parse",
"(",
"(",
"CharSequence",
")",
"value",
",",
"DateTimeFormatter",
".",
"ISO_INSTANT",
".",
"withZone",
"(",
"Clock",
".",
"systemUTC",
"(",
")",
".",
"getZone",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"time",
"=",
"LocalDateTime",
".",
"parse",
"(",
"(",
"CharSequence",
")",
"value",
",",
"DateTimeFormatter",
".",
"ISO_OFFSET_DATE_TIME",
".",
"withZone",
"(",
"Clock",
".",
"systemUTC",
"(",
")",
".",
"getZone",
"(",
")",
")",
")",
";",
"}",
"return",
"new",
"Date",
"(",
"time",
".",
"atZone",
"(",
"Clock",
".",
"systemUTC",
"(",
")",
".",
"getZone",
"(",
")",
")",
".",
"toInstant",
"(",
")",
".",
"toEpochMilli",
"(",
")",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"e",
",",
"\"Unable to parse date: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Long",
")",
"{",
"// Longs are assumed to be java time (millis since epoch).",
"return",
"new",
"Date",
"(",
"(",
"Long",
")",
"value",
")",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Integer",
")",
"{",
"// Integers are assumed to be unix time (seconds since epoch).",
"return",
"new",
"Date",
"(",
"(",
"(",
"Integer",
")",
"value",
")",
".",
"longValue",
"(",
")",
"*",
"1000L",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IncompatibleValueException",
"(",
"\"Unable to convert \"",
"+",
"value",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\" to a date\"",
")",
";",
"}",
"}"
] |
Convert the value to a date.
@param value The value instance.
@return The string value.
|
[
"Convert",
"the",
"value",
"to",
"a",
"date",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L223-L251
|
155,984
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asStringArray
|
public static String[] asStringArray(Object value) {
List<String> collection = asCollection(value).stream()
.map(ConfigUtil::asString)
.collect(Collectors.toList());
return collection.toArray(new String[collection.size()]);
}
|
java
|
public static String[] asStringArray(Object value) {
List<String> collection = asCollection(value).stream()
.map(ConfigUtil::asString)
.collect(Collectors.toList());
return collection.toArray(new String[collection.size()]);
}
|
[
"public",
"static",
"String",
"[",
"]",
"asStringArray",
"(",
"Object",
"value",
")",
"{",
"List",
"<",
"String",
">",
"collection",
"=",
"asCollection",
"(",
"value",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"ConfigUtil",
"::",
"asString",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"return",
"collection",
".",
"toArray",
"(",
"new",
"String",
"[",
"collection",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Make collection into a string array.
@param value The value instance.
@return The array.
|
[
"Make",
"collection",
"into",
"a",
"string",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L275-L280
|
155,985
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asBooleanArray
|
public static boolean[] asBooleanArray(Collection collection) {
boolean[] result = new boolean[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asBoolean(c);
}
return result;
}
|
java
|
public static boolean[] asBooleanArray(Collection collection) {
boolean[] result = new boolean[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asBoolean(c);
}
return result;
}
|
[
"public",
"static",
"boolean",
"[",
"]",
"asBooleanArray",
"(",
"Collection",
"collection",
")",
"{",
"boolean",
"[",
"]",
"result",
"=",
"new",
"boolean",
"[",
"collection",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Object",
"c",
":",
"collection",
")",
"{",
"result",
"[",
"i",
"++",
"]",
"=",
"asBoolean",
"(",
"c",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Make collection into a boolean array.
@param collection The value instance.
@return The array.
|
[
"Make",
"collection",
"into",
"a",
"boolean",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L288-L295
|
155,986
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asIntegerArray
|
public static int[] asIntegerArray(Collection collection) {
int[] result = new int[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asInteger(c);
}
return result;
}
|
java
|
public static int[] asIntegerArray(Collection collection) {
int[] result = new int[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asInteger(c);
}
return result;
}
|
[
"public",
"static",
"int",
"[",
"]",
"asIntegerArray",
"(",
"Collection",
"collection",
")",
"{",
"int",
"[",
"]",
"result",
"=",
"new",
"int",
"[",
"collection",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Object",
"c",
":",
"collection",
")",
"{",
"result",
"[",
"i",
"++",
"]",
"=",
"asInteger",
"(",
"c",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Make collection into an integer array.
@param collection The value instance.
@return The array.
|
[
"Make",
"collection",
"into",
"an",
"integer",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L303-L310
|
155,987
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asLongArray
|
public static long[] asLongArray(Collection collection) {
long[] result = new long[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asLong(c);
}
return result;
}
|
java
|
public static long[] asLongArray(Collection collection) {
long[] result = new long[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asLong(c);
}
return result;
}
|
[
"public",
"static",
"long",
"[",
"]",
"asLongArray",
"(",
"Collection",
"collection",
")",
"{",
"long",
"[",
"]",
"result",
"=",
"new",
"long",
"[",
"collection",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Object",
"c",
":",
"collection",
")",
"{",
"result",
"[",
"i",
"++",
"]",
"=",
"asLong",
"(",
"c",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Make collection into a long array.
@param collection The value instance.
@return The array.
|
[
"Make",
"collection",
"into",
"a",
"long",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L318-L325
|
155,988
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.asDoubleArray
|
public static double[] asDoubleArray(Collection collection) {
double[] result = new double[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asDouble(c);
}
return result;
}
|
java
|
public static double[] asDoubleArray(Collection collection) {
double[] result = new double[collection.size()];
int i = 0;
for (Object c : collection) {
result[i++] = asDouble(c);
}
return result;
}
|
[
"public",
"static",
"double",
"[",
"]",
"asDoubleArray",
"(",
"Collection",
"collection",
")",
"{",
"double",
"[",
"]",
"result",
"=",
"new",
"double",
"[",
"collection",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Object",
"c",
":",
"collection",
")",
"{",
"result",
"[",
"i",
"++",
"]",
"=",
"asDouble",
"(",
"c",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Make collection into a double array.
@param collection The value instance.
@return The array.
|
[
"Make",
"collection",
"into",
"a",
"double",
"array",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L333-L340
|
155,989
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java
|
ConfigUtil.getLayerName
|
public static String getLayerName(Supplier<Config> layer) {
String str = layer.toString();
if (str.contains("$$Lambda$")) {
return String.format("InMemorySupplier{%s}",
layer.get().getClass().getSimpleName());
}
return str;
}
|
java
|
public static String getLayerName(Supplier<Config> layer) {
String str = layer.toString();
if (str.contains("$$Lambda$")) {
return String.format("InMemorySupplier{%s}",
layer.get().getClass().getSimpleName());
}
return str;
}
|
[
"public",
"static",
"String",
"getLayerName",
"(",
"Supplier",
"<",
"Config",
">",
"layer",
")",
"{",
"String",
"str",
"=",
"layer",
".",
"toString",
"(",
")",
";",
"if",
"(",
"str",
".",
"contains",
"(",
"\"$$Lambda$\"",
")",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"InMemorySupplier{%s}\"",
",",
"layer",
".",
"get",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"return",
"str",
";",
"}"
] |
Get the layer name based on the supplier.
@param layer The layer to get the name of.
@return The layer name.
|
[
"Get",
"the",
"layer",
"name",
"based",
"on",
"the",
"supplier",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/util/ConfigUtil.java#L465-L472
|
155,990
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserDescription.java
|
ParserDescription.isInGroup
|
public boolean isInGroup(final String other) {
return ParserRegistry.getParser(group).getGroup().equals(ParserRegistry.getParser(other).getGroup());
}
|
java
|
public boolean isInGroup(final String other) {
return ParserRegistry.getParser(group).getGroup().equals(ParserRegistry.getParser(other).getGroup());
}
|
[
"public",
"boolean",
"isInGroup",
"(",
"final",
"String",
"other",
")",
"{",
"return",
"ParserRegistry",
".",
"getParser",
"(",
"group",
")",
".",
"getGroup",
"(",
")",
".",
"equals",
"(",
"ParserRegistry",
".",
"getParser",
"(",
"other",
")",
".",
"getGroup",
"(",
")",
")",
";",
"}"
] |
Returns whether this parser is in the specified group.
@param other
the name of the group
@return <code>true</code> if this parser is in the specified group
|
[
"Returns",
"whether",
"this",
"parser",
"is",
"in",
"the",
"specified",
"group",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserDescription.java#L44-L46
|
155,991
|
lotaris/jee-validation
|
src/main/java/com/lotaris/jee/validation/AbstractPatchTransferObject.java
|
AbstractPatchTransferObject.markPropertyAsSet
|
public <T> T markPropertyAsSet(String property, T value) {
setProperties.add(property);
return value;
}
|
java
|
public <T> T markPropertyAsSet(String property, T value) {
setProperties.add(property);
return value;
}
|
[
"public",
"<",
"T",
">",
"T",
"markPropertyAsSet",
"(",
"String",
"property",
",",
"T",
"value",
")",
"{",
"setProperties",
".",
"add",
"(",
"property",
")",
";",
"return",
"value",
";",
"}"
] |
Marks the specified property as set and returns the value given as the second argument. This
is meant to be used as a one-liner.
<p><pre>
public void setFirstName(String firstName) {
this.firstName = markPropertyAsSet(FIRST_NAME, firstName);
}
</pre></p>
@param <T> the type of value
@param property the property to mark as set
@param value the value to return
@return the value
|
[
"Marks",
"the",
"specified",
"property",
"as",
"set",
"and",
"returns",
"the",
"value",
"given",
"as",
"the",
"second",
"argument",
".",
"This",
"is",
"meant",
"to",
"be",
"used",
"as",
"a",
"one",
"-",
"liner",
"."
] |
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
|
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/AbstractPatchTransferObject.java#L71-L74
|
155,992
|
lotaris/jee-validation
|
src/main/java/com/lotaris/jee/validation/JsonPointer.java
|
JsonPointer.add
|
public int add(String fragments) {
if (fragments == null) {
return 0;
}
final String[] splitFragments = fragments.replaceFirst("^\\/", "").split("\\/", -1);
final int n = splitFragments.length;
for (int i = 0; i < n; i++) {
pathFragments.add(splitFragments[i]);
}
return n;
}
|
java
|
public int add(String fragments) {
if (fragments == null) {
return 0;
}
final String[] splitFragments = fragments.replaceFirst("^\\/", "").split("\\/", -1);
final int n = splitFragments.length;
for (int i = 0; i < n; i++) {
pathFragments.add(splitFragments[i]);
}
return n;
}
|
[
"public",
"int",
"add",
"(",
"String",
"fragments",
")",
"{",
"if",
"(",
"fragments",
"==",
"null",
")",
"{",
"return",
"0",
";",
"}",
"final",
"String",
"[",
"]",
"splitFragments",
"=",
"fragments",
".",
"replaceFirst",
"(",
"\"^\\\\/\"",
",",
"\"\"",
")",
".",
"split",
"(",
"\"\\\\/\"",
",",
"-",
"1",
")",
";",
"final",
"int",
"n",
"=",
"splitFragments",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"pathFragments",
".",
"add",
"(",
"splitFragments",
"[",
"i",
"]",
")",
";",
"}",
"return",
"n",
";",
"}"
] |
Adds the path fragments contained in the specified string. This method performs no escaping
so reserved JSON Pointer characters should already be escaped.
<p>For example, <tt>add("/foo/bar")</tt> adds two path fragments, <tt>"foo"</tt> and
<tt>"bar"</tt>, and returns 2.</p>
@param fragments the path fragments to add
@return the number of fragments added
|
[
"Adds",
"the",
"path",
"fragments",
"contained",
"in",
"the",
"specified",
"string",
".",
"This",
"method",
"performs",
"no",
"escaping",
"so",
"reserved",
"JSON",
"Pointer",
"characters",
"should",
"already",
"be",
"escaped",
"."
] |
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
|
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/JsonPointer.java#L54-L67
|
155,993
|
RogerParkinson/madura-objects-parent
|
madura-objects/src/main/java/nz/co/senanque/validationengine/Binder.java
|
Binder.unbind
|
public void unbind(ValidationSession session, ValidationObject validationObject,
Map<ValidationObject, ProxyObject> boundMap) {
if (validationObject == null) {
return;
}
// For all the fields: look for attached objects.
ProxyObject proxyObject = session.getProxyObject(validationObject);
Map<String,ProxyField> fieldMap = proxyObject.getFieldMap();
for (String fieldName: fieldMap.keySet()) {
if (fieldName != null) {
final ClassMetadata classMetadata = m_validationEngine.getClassMetadata(validationObject.getClass());
final PropertyMetadata fieldMetadata = classMetadata.getField(fieldName);
if (fieldMetadata == null) {
continue;
}
ProxyField proxyField = proxyObject.getProxyField(fieldName);
Method getter = proxyField.getGetter();
if (getter.getReturnType().isAssignableFrom(List.class)) {
// if this is a list then walk the list and unbind the objects there.
try {
@SuppressWarnings("unchecked")
final List<ValidationObject> validationObjects =
(List<ValidationObject>) getter.invoke(validationObject, new Object[] {});
for (ValidationObject child : validationObjects) {
m_validationEngine.unbind(session, proxyField, child, boundMap);
if (child != null) {
child.setValidationSession(null);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
continue;
}
if (m_validationEngine.getClassMetadata(getter.getReturnType()) != null) {
// if this is a known object then unbind it
try {
ValidationObject child = (ValidationObject) getter
.invoke(validationObject, new Object[] {});
m_validationEngine.unbind(session, proxyField, child, boundMap);
if (child != null) {
child.setValidationSession(null);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
continue;
}
}
}
}
|
java
|
public void unbind(ValidationSession session, ValidationObject validationObject,
Map<ValidationObject, ProxyObject> boundMap) {
if (validationObject == null) {
return;
}
// For all the fields: look for attached objects.
ProxyObject proxyObject = session.getProxyObject(validationObject);
Map<String,ProxyField> fieldMap = proxyObject.getFieldMap();
for (String fieldName: fieldMap.keySet()) {
if (fieldName != null) {
final ClassMetadata classMetadata = m_validationEngine.getClassMetadata(validationObject.getClass());
final PropertyMetadata fieldMetadata = classMetadata.getField(fieldName);
if (fieldMetadata == null) {
continue;
}
ProxyField proxyField = proxyObject.getProxyField(fieldName);
Method getter = proxyField.getGetter();
if (getter.getReturnType().isAssignableFrom(List.class)) {
// if this is a list then walk the list and unbind the objects there.
try {
@SuppressWarnings("unchecked")
final List<ValidationObject> validationObjects =
(List<ValidationObject>) getter.invoke(validationObject, new Object[] {});
for (ValidationObject child : validationObjects) {
m_validationEngine.unbind(session, proxyField, child, boundMap);
if (child != null) {
child.setValidationSession(null);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
continue;
}
if (m_validationEngine.getClassMetadata(getter.getReturnType()) != null) {
// if this is a known object then unbind it
try {
ValidationObject child = (ValidationObject) getter
.invoke(validationObject, new Object[] {});
m_validationEngine.unbind(session, proxyField, child, boundMap);
if (child != null) {
child.setValidationSession(null);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
continue;
}
}
}
}
|
[
"public",
"void",
"unbind",
"(",
"ValidationSession",
"session",
",",
"ValidationObject",
"validationObject",
",",
"Map",
"<",
"ValidationObject",
",",
"ProxyObject",
">",
"boundMap",
")",
"{",
"if",
"(",
"validationObject",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// For all the fields: look for attached objects.",
"ProxyObject",
"proxyObject",
"=",
"session",
".",
"getProxyObject",
"(",
"validationObject",
")",
";",
"Map",
"<",
"String",
",",
"ProxyField",
">",
"fieldMap",
"=",
"proxyObject",
".",
"getFieldMap",
"(",
")",
";",
"for",
"(",
"String",
"fieldName",
":",
"fieldMap",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"fieldName",
"!=",
"null",
")",
"{",
"final",
"ClassMetadata",
"classMetadata",
"=",
"m_validationEngine",
".",
"getClassMetadata",
"(",
"validationObject",
".",
"getClass",
"(",
")",
")",
";",
"final",
"PropertyMetadata",
"fieldMetadata",
"=",
"classMetadata",
".",
"getField",
"(",
"fieldName",
")",
";",
"if",
"(",
"fieldMetadata",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"ProxyField",
"proxyField",
"=",
"proxyObject",
".",
"getProxyField",
"(",
"fieldName",
")",
";",
"Method",
"getter",
"=",
"proxyField",
".",
"getGetter",
"(",
")",
";",
"if",
"(",
"getter",
".",
"getReturnType",
"(",
")",
".",
"isAssignableFrom",
"(",
"List",
".",
"class",
")",
")",
"{",
"// if this is a list then walk the list and unbind the objects there.",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"List",
"<",
"ValidationObject",
">",
"validationObjects",
"=",
"(",
"List",
"<",
"ValidationObject",
">",
")",
"getter",
".",
"invoke",
"(",
"validationObject",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"for",
"(",
"ValidationObject",
"child",
":",
"validationObjects",
")",
"{",
"m_validationEngine",
".",
"unbind",
"(",
"session",
",",
"proxyField",
",",
"child",
",",
"boundMap",
")",
";",
"if",
"(",
"child",
"!=",
"null",
")",
"{",
"child",
".",
"setValidationSession",
"(",
"null",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"m_validationEngine",
".",
"getClassMetadata",
"(",
"getter",
".",
"getReturnType",
"(",
")",
")",
"!=",
"null",
")",
"{",
"// if this is a known object then unbind it",
"try",
"{",
"ValidationObject",
"child",
"=",
"(",
"ValidationObject",
")",
"getter",
".",
"invoke",
"(",
"validationObject",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"m_validationEngine",
".",
"unbind",
"(",
"session",
",",
"proxyField",
",",
"child",
",",
"boundMap",
")",
";",
"if",
"(",
"child",
"!=",
"null",
")",
"{",
"child",
".",
"setValidationSession",
"(",
"null",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"continue",
";",
"}",
"}",
"}",
"}"
] |
Unbind the given object. We have to locate any attached objects and unbind them first.
@param session
@param validationObject
@param boundMap
|
[
"Unbind",
"the",
"given",
"object",
".",
"We",
"have",
"to",
"locate",
"any",
"attached",
"objects",
"and",
"unbind",
"them",
"first",
"."
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/Binder.java#L176-L226
|
155,994
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.registerAndConnect
|
void registerAndConnect(SocketChannel sock, InetSocketAddress addr)
throws IOException {
selectionKey = sock.register(selector, SelectionKey.OP_CONNECT);
boolean immediateConnect = sock.connect(addr);
if(LOGGER.isTraceEnabled()){
LOGGER.trace("Connect to host=" + addr.getHostName() + ", hostString=" + addr.getHostString() + ", port=" + addr.getPort() + ", all=" + addr.getAddress() + ", local=" + sock.socket().getLocalSocketAddress());
}
if (immediateConnect) {
onConnectSucceeded();
}
}
|
java
|
void registerAndConnect(SocketChannel sock, InetSocketAddress addr)
throws IOException {
selectionKey = sock.register(selector, SelectionKey.OP_CONNECT);
boolean immediateConnect = sock.connect(addr);
if(LOGGER.isTraceEnabled()){
LOGGER.trace("Connect to host=" + addr.getHostName() + ", hostString=" + addr.getHostString() + ", port=" + addr.getPort() + ", all=" + addr.getAddress() + ", local=" + sock.socket().getLocalSocketAddress());
}
if (immediateConnect) {
onConnectSucceeded();
}
}
|
[
"void",
"registerAndConnect",
"(",
"SocketChannel",
"sock",
",",
"InetSocketAddress",
"addr",
")",
"throws",
"IOException",
"{",
"selectionKey",
"=",
"sock",
".",
"register",
"(",
"selector",
",",
"SelectionKey",
".",
"OP_CONNECT",
")",
";",
"boolean",
"immediateConnect",
"=",
"sock",
".",
"connect",
"(",
"addr",
")",
";",
"if",
"(",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"Connect to host=\"",
"+",
"addr",
".",
"getHostName",
"(",
")",
"+",
"\", hostString=\"",
"+",
"addr",
".",
"getHostString",
"(",
")",
"+",
"\", port=\"",
"+",
"addr",
".",
"getPort",
"(",
")",
"+",
"\", all=\"",
"+",
"addr",
".",
"getAddress",
"(",
")",
"+",
"\", local=\"",
"+",
"sock",
".",
"socket",
"(",
")",
".",
"getLocalSocketAddress",
"(",
")",
")",
";",
"}",
"if",
"(",
"immediateConnect",
")",
"{",
"onConnectSucceeded",
"(",
")",
";",
"}",
"}"
] |
Register a SocketChannel and connect the remote address.
@param sock
the SocketChannel.
@param addr
the remote address.
@throws IOException
the IOException.
|
[
"Register",
"a",
"SocketChannel",
"and",
"connect",
"the",
"remote",
"address",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L152-L165
|
155,995
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.createSock
|
SocketChannel createSock() throws IOException {
SocketChannel sock;
sock = SocketChannel.open();
sock.configureBlocking(false);
sock.socket().setSoLinger(false, -1);
sock.socket().setTcpNoDelay(true);
return sock;
}
|
java
|
SocketChannel createSock() throws IOException {
SocketChannel sock;
sock = SocketChannel.open();
sock.configureBlocking(false);
sock.socket().setSoLinger(false, -1);
sock.socket().setTcpNoDelay(true);
return sock;
}
|
[
"SocketChannel",
"createSock",
"(",
")",
"throws",
"IOException",
"{",
"SocketChannel",
"sock",
";",
"sock",
"=",
"SocketChannel",
".",
"open",
"(",
")",
";",
"sock",
".",
"configureBlocking",
"(",
"false",
")",
";",
"sock",
".",
"socket",
"(",
")",
".",
"setSoLinger",
"(",
"false",
",",
"-",
"1",
")",
";",
"sock",
".",
"socket",
"(",
")",
".",
"setTcpNoDelay",
"(",
"true",
")",
";",
"return",
"sock",
";",
"}"
] |
Create a SocketChannel.
@return
the SocketChannel.
@throws IOException
the IOException.
|
[
"Create",
"a",
"SocketChannel",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L175-L182
|
155,996
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.readLength
|
protected void readLength() throws IOException {
int len = incomingBuffer.getInt();
if(LOGGER.isTraceEnabled()){
LOGGER.trace("Read length in client - " + len);
}
if (len < 0 || len >= DirectoryConnection.packetLen) {
throw new IOException("Packet len" + len + " is out of range!");
}
incomingBuffer = ByteBuffer.allocate(len);
}
|
java
|
protected void readLength() throws IOException {
int len = incomingBuffer.getInt();
if(LOGGER.isTraceEnabled()){
LOGGER.trace("Read length in client - " + len);
}
if (len < 0 || len >= DirectoryConnection.packetLen) {
throw new IOException("Packet len" + len + " is out of range!");
}
incomingBuffer = ByteBuffer.allocate(len);
}
|
[
"protected",
"void",
"readLength",
"(",
")",
"throws",
"IOException",
"{",
"int",
"len",
"=",
"incomingBuffer",
".",
"getInt",
"(",
")",
";",
"if",
"(",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"Read length in client - \"",
"+",
"len",
")",
";",
"}",
"if",
"(",
"len",
"<",
"0",
"||",
"len",
">=",
"DirectoryConnection",
".",
"packetLen",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Packet len\"",
"+",
"len",
"+",
"\" is out of range!\"",
")",
";",
"}",
"incomingBuffer",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"len",
")",
";",
"}"
] |
Read the buffer message length.
@throws IOException
the IOException.
|
[
"Read",
"the",
"buffer",
"message",
"length",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L305-L314
|
155,997
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.doSocketConnect
|
private void doSocketConnect(InetSocketAddress addr) throws IOException{
SocketChannel sock = createSock();
registerAndConnect(sock, addr);
}
|
java
|
private void doSocketConnect(InetSocketAddress addr) throws IOException{
SocketChannel sock = createSock();
registerAndConnect(sock, addr);
}
|
[
"private",
"void",
"doSocketConnect",
"(",
"InetSocketAddress",
"addr",
")",
"throws",
"IOException",
"{",
"SocketChannel",
"sock",
"=",
"createSock",
"(",
")",
";",
"registerAndConnect",
"(",
"sock",
",",
"addr",
")",
";",
"}"
] |
Do the Socket connect.
@param addr
the remote address.
@throws IOException
the IOException.
|
[
"Do",
"the",
"Socket",
"connect",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L393-L396
|
155,998
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.onConnectSucceeded
|
private void onConnectSucceeded(){
LOGGER.info("Accepted the connection.");
isConnected = true;
isConnecting = false;
enableReadOnly();
synchronized(connectHolder){
connectHolder.notifyAll();
}
}
|
java
|
private void onConnectSucceeded(){
LOGGER.info("Accepted the connection.");
isConnected = true;
isConnecting = false;
enableReadOnly();
synchronized(connectHolder){
connectHolder.notifyAll();
}
}
|
[
"private",
"void",
"onConnectSucceeded",
"(",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Accepted the connection.\"",
")",
";",
"isConnected",
"=",
"true",
";",
"isConnecting",
"=",
"false",
";",
"enableReadOnly",
"(",
")",
";",
"synchronized",
"(",
"connectHolder",
")",
"{",
"connectHolder",
".",
"notifyAll",
"(",
")",
";",
"}",
"}"
] |
On the socked connected.
|
[
"On",
"the",
"socked",
"connected",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L401-L410
|
155,999
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java
|
NIODirectorySocket.onConnectFailed
|
private void onConnectFailed(){
LOGGER.info("Socket failed");
isConnecting = false;
isConnected = false;
cleanup();
synchronized(connectHolder){
connectHolder.notifyAll();
}
}
|
java
|
private void onConnectFailed(){
LOGGER.info("Socket failed");
isConnecting = false;
isConnected = false;
cleanup();
synchronized(connectHolder){
connectHolder.notifyAll();
}
}
|
[
"private",
"void",
"onConnectFailed",
"(",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Socket failed\"",
")",
";",
"isConnecting",
"=",
"false",
";",
"isConnected",
"=",
"false",
";",
"cleanup",
"(",
")",
";",
"synchronized",
"(",
"connectHolder",
")",
"{",
"connectHolder",
".",
"notifyAll",
"(",
")",
";",
"}",
"}"
] |
On the socket connect failed.
|
[
"On",
"the",
"socket",
"connect",
"failed",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/NIODirectorySocket.java#L415-L423
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.