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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
149,000
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java
|
JBossRuleCreator.visit
|
@Override
public void visit(SequentialTemporalPatternDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
TemporalExtendedPropositionDefinition lhs = def.getFirstTemporalExtendedPropositionDefinition();
if (lhs != null) {
Rule rule = new Rule("SEQ_TP_" + def.getId());
Pattern sourceP = new Pattern(2, TEMP_PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(lhs, this.cache);
sourceP.addConstraint(new PredicateConstraint(
matchesPredicateExpression));
SubsequentTemporalExtendedPropositionDefinition[] relatedTemporalExtendedPropositionDefinitions = def.getSubsequentTemporalExtendedPropositionDefinitions();
for (int i = 0; i < relatedTemporalExtendedPropositionDefinitions.length; i++) {
SubsequentTemporalExtendedPropositionDefinition rtepd
= relatedTemporalExtendedPropositionDefinitions[i];
GetMatchesPredicateExpression matchesPredicateExpression1 = new GetMatchesPredicateExpression(
rtepd.getRelatedTemporalExtendedPropositionDefinition(), this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression1);
sourceP.addConstraint(c);
}
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP);
rule.setConsequence(new SequentialTemporalPatternConsequence(def,
this.derivationsBuilder));
rule.setSalience(MINUS_TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
java
|
@Override
public void visit(SequentialTemporalPatternDefinition def) throws ProtempaException {
LOGGER.log(Level.FINER, "Creating rule for {0}", def);
try {
TemporalExtendedPropositionDefinition lhs = def.getFirstTemporalExtendedPropositionDefinition();
if (lhs != null) {
Rule rule = new Rule("SEQ_TP_" + def.getId());
Pattern sourceP = new Pattern(2, TEMP_PROP_OT);
GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(lhs, this.cache);
sourceP.addConstraint(new PredicateConstraint(
matchesPredicateExpression));
SubsequentTemporalExtendedPropositionDefinition[] relatedTemporalExtendedPropositionDefinitions = def.getSubsequentTemporalExtendedPropositionDefinitions();
for (int i = 0; i < relatedTemporalExtendedPropositionDefinitions.length; i++) {
SubsequentTemporalExtendedPropositionDefinition rtepd
= relatedTemporalExtendedPropositionDefinitions[i];
GetMatchesPredicateExpression matchesPredicateExpression1 = new GetMatchesPredicateExpression(
rtepd.getRelatedTemporalExtendedPropositionDefinition(), this.cache);
Constraint c = new PredicateConstraint(
matchesPredicateExpression1);
sourceP.addConstraint(c);
}
Pattern resultP = new Pattern(1, 1, ARRAY_LIST_OT, "result");
resultP.setSource(new Collect(sourceP, new Pattern(1, 1,
ARRAY_LIST_OT, "result")));
resultP.addConstraint(new PredicateConstraint(
new CollectionSizeExpression(1)));
rule.addPattern(resultP);
rule.setConsequence(new SequentialTemporalPatternConsequence(def,
this.derivationsBuilder));
rule.setSalience(MINUS_TWO_SALIENCE);
this.ruleToAbstractionDefinition.put(rule, def);
rules.add(rule);
ABSTRACTION_COMBINER.toRules(def, rules, this.derivationsBuilder);
}
} catch (InvalidRuleException e) {
throw new AssertionError(e.getClass().getName() + ": "
+ e.getMessage());
}
}
|
[
"@",
"Override",
"public",
"void",
"visit",
"(",
"SequentialTemporalPatternDefinition",
"def",
")",
"throws",
"ProtempaException",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Creating rule for {0}\"",
",",
"def",
")",
";",
"try",
"{",
"TemporalExtendedPropositionDefinition",
"lhs",
"=",
"def",
".",
"getFirstTemporalExtendedPropositionDefinition",
"(",
")",
";",
"if",
"(",
"lhs",
"!=",
"null",
")",
"{",
"Rule",
"rule",
"=",
"new",
"Rule",
"(",
"\"SEQ_TP_\"",
"+",
"def",
".",
"getId",
"(",
")",
")",
";",
"Pattern",
"sourceP",
"=",
"new",
"Pattern",
"(",
"2",
",",
"TEMP_PROP_OT",
")",
";",
"GetMatchesPredicateExpression",
"matchesPredicateExpression",
"=",
"new",
"GetMatchesPredicateExpression",
"(",
"lhs",
",",
"this",
".",
"cache",
")",
";",
"sourceP",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"matchesPredicateExpression",
")",
")",
";",
"SubsequentTemporalExtendedPropositionDefinition",
"[",
"]",
"relatedTemporalExtendedPropositionDefinitions",
"=",
"def",
".",
"getSubsequentTemporalExtendedPropositionDefinitions",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"relatedTemporalExtendedPropositionDefinitions",
".",
"length",
";",
"i",
"++",
")",
"{",
"SubsequentTemporalExtendedPropositionDefinition",
"rtepd",
"=",
"relatedTemporalExtendedPropositionDefinitions",
"[",
"i",
"]",
";",
"GetMatchesPredicateExpression",
"matchesPredicateExpression1",
"=",
"new",
"GetMatchesPredicateExpression",
"(",
"rtepd",
".",
"getRelatedTemporalExtendedPropositionDefinition",
"(",
")",
",",
"this",
".",
"cache",
")",
";",
"Constraint",
"c",
"=",
"new",
"PredicateConstraint",
"(",
"matchesPredicateExpression1",
")",
";",
"sourceP",
".",
"addConstraint",
"(",
"c",
")",
";",
"}",
"Pattern",
"resultP",
"=",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
";",
"resultP",
".",
"setSource",
"(",
"new",
"Collect",
"(",
"sourceP",
",",
"new",
"Pattern",
"(",
"1",
",",
"1",
",",
"ARRAY_LIST_OT",
",",
"\"result\"",
")",
")",
")",
";",
"resultP",
".",
"addConstraint",
"(",
"new",
"PredicateConstraint",
"(",
"new",
"CollectionSizeExpression",
"(",
"1",
")",
")",
")",
";",
"rule",
".",
"addPattern",
"(",
"resultP",
")",
";",
"rule",
".",
"setConsequence",
"(",
"new",
"SequentialTemporalPatternConsequence",
"(",
"def",
",",
"this",
".",
"derivationsBuilder",
")",
")",
";",
"rule",
".",
"setSalience",
"(",
"MINUS_TWO_SALIENCE",
")",
";",
"this",
".",
"ruleToAbstractionDefinition",
".",
"put",
"(",
"rule",
",",
"def",
")",
";",
"rules",
".",
"add",
"(",
"rule",
")",
";",
"ABSTRACTION_COMBINER",
".",
"toRules",
"(",
"def",
",",
"rules",
",",
"this",
".",
"derivationsBuilder",
")",
";",
"}",
"}",
"catch",
"(",
"InvalidRuleException",
"e",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Translates a sequential temporal pattern definition into rules.
@param def a {@link PairDefinition}. Cannot be <code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.
|
[
"Translates",
"a",
"sequential",
"temporal",
"pattern",
"definition",
"into",
"rules",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L351-L390
|
149,001
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java
|
JBossRuleCreator.getRules
|
List<Rule> getRules() {
List<Rule> rulesToReturn = new ArrayList<>(this.rules);
new DeletedProposition().toRules(rulesToReturn);
return rulesToReturn;
}
|
java
|
List<Rule> getRules() {
List<Rule> rulesToReturn = new ArrayList<>(this.rules);
new DeletedProposition().toRules(rulesToReturn);
return rulesToReturn;
}
|
[
"List",
"<",
"Rule",
">",
"getRules",
"(",
")",
"{",
"List",
"<",
"Rule",
">",
"rulesToReturn",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"rules",
")",
";",
"new",
"DeletedProposition",
"(",
")",
".",
"toRules",
"(",
"rulesToReturn",
")",
";",
"return",
"rulesToReturn",
";",
"}"
] |
Returns a newly-created an array of rules that were generated.
@return a {@link Rule[]}. Guaranteed not <code>null</code>.
|
[
"Returns",
"a",
"newly",
"-",
"created",
"an",
"array",
"of",
"rules",
"that",
"were",
"generated",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/JBossRuleCreator.java#L431-L435
|
149,002
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.addTask
|
public <T> UBench addTask(String name, Supplier<T> task) {
return addTask(name, task, null);
}
|
java
|
public <T> UBench addTask(String name, Supplier<T> task) {
return addTask(name, task, null);
}
|
[
"public",
"<",
"T",
">",
"UBench",
"addTask",
"(",
"String",
"name",
",",
"Supplier",
"<",
"T",
">",
"task",
")",
"{",
"return",
"addTask",
"(",
"name",
",",
"task",
",",
"null",
")",
";",
"}"
] |
Include a named task in to the benchmark.
@param <T>
The type of the return value from the task. It is ignored.
@param name
The name of the task. Only one task with any one name is
allowed.
@param task
The task to perform
@return The same object, for chaining calls.
|
[
"Include",
"a",
"named",
"task",
"in",
"to",
"the",
"benchmark",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L153-L155
|
149,003
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.addIntTask
|
public UBench addIntTask(String name, IntSupplier task) {
return addIntTask(name, task, null);
}
|
java
|
public UBench addIntTask(String name, IntSupplier task) {
return addIntTask(name, task, null);
}
|
[
"public",
"UBench",
"addIntTask",
"(",
"String",
"name",
",",
"IntSupplier",
"task",
")",
"{",
"return",
"addIntTask",
"(",
"name",
",",
"task",
",",
"null",
")",
";",
"}"
] |
Include an int-specialized named task in to the benchmark.
@param name
The name of the task. Only one task with any one name is
allowed.
@param task
The task to perform
@return The same object, for chaining calls.
|
[
"Include",
"an",
"int",
"-",
"specialized",
"named",
"task",
"in",
"to",
"the",
"benchmark",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L192-L194
|
149,004
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.addLongTask
|
public UBench addLongTask(String name, LongSupplier task) {
return addLongTask(name, task, null);
}
|
java
|
public UBench addLongTask(String name, LongSupplier task) {
return addLongTask(name, task, null);
}
|
[
"public",
"UBench",
"addLongTask",
"(",
"String",
"name",
",",
"LongSupplier",
"task",
")",
"{",
"return",
"addLongTask",
"(",
"name",
",",
"task",
",",
"null",
")",
";",
"}"
] |
Include a long-specialized named task in to the benchmark.
@param name
The name of the task. Only one task with any one name is
allowed.
@param task
The task to perform
@return The same object, for chaining calls.
|
[
"Include",
"a",
"long",
"-",
"specialized",
"named",
"task",
"in",
"to",
"the",
"benchmark",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L231-L233
|
149,005
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.addDoubleTask
|
public UBench addDoubleTask(String name, DoubleSupplier task) {
return addDoubleTask(name, task, null);
}
|
java
|
public UBench addDoubleTask(String name, DoubleSupplier task) {
return addDoubleTask(name, task, null);
}
|
[
"public",
"UBench",
"addDoubleTask",
"(",
"String",
"name",
",",
"DoubleSupplier",
"task",
")",
"{",
"return",
"addDoubleTask",
"(",
"name",
",",
"task",
",",
"null",
")",
";",
"}"
] |
Include a double-specialized named task in to the benchmark.
@param name
The name of the task. Only one task with any one name is
allowed.
@param task
The task to perform
@return The same object, for chaining calls.
|
[
"Include",
"a",
"double",
"-",
"specialized",
"named",
"task",
"in",
"to",
"the",
"benchmark",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L270-L272
|
149,006
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.addTask
|
public UBench addTask(String name, Runnable task) {
return putTask(name, () -> {
long start = System.nanoTime();
task.run();
return System.nanoTime() - start;
});
}
|
java
|
public UBench addTask(String name, Runnable task) {
return putTask(name, () -> {
long start = System.nanoTime();
task.run();
return System.nanoTime() - start;
});
}
|
[
"public",
"UBench",
"addTask",
"(",
"String",
"name",
",",
"Runnable",
"task",
")",
"{",
"return",
"putTask",
"(",
"name",
",",
"(",
")",
"->",
"{",
"long",
"start",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"task",
".",
"run",
"(",
")",
";",
"return",
"System",
".",
"nanoTime",
"(",
")",
"-",
"start",
";",
"}",
")",
";",
"}"
] |
Include a named task that has no output value in to the benchmark.
@param name
The name of the task. Only one task with any one name is
allowed.
@param task
The task to perform
@return The same object, for chaining calls.
|
[
"Include",
"a",
"named",
"task",
"that",
"has",
"no",
"output",
"value",
"in",
"to",
"the",
"benchmark",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L285-L291
|
149,007
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UBench.java
|
UBench.press
|
public UReport press(UMode mode, final long timeLimit, final TimeUnit timeUnit) {
return press(mode, 0, 0, 0.0, timeLimit, timeUnit);
}
|
java
|
public UReport press(UMode mode, final long timeLimit, final TimeUnit timeUnit) {
return press(mode, 0, 0, 0.0, timeLimit, timeUnit);
}
|
[
"public",
"UReport",
"press",
"(",
"UMode",
"mode",
",",
"final",
"long",
"timeLimit",
",",
"final",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"press",
"(",
"mode",
",",
"0",
",",
"0",
",",
"0.0",
",",
"timeLimit",
",",
"timeUnit",
")",
";",
"}"
] |
Benchmark all added tasks until they exceed the set time limit
@param mode
The UMode execution model to use for task execution
@param timeLimit
combined with the timeUnit, indicates how long to run tests
for. A value less than or equal to 0 turns off this check.
@param timeUnit
combined with the timeLimit, indicates how long to run tests
for.
@return the results of all completed tasks.
|
[
"Benchmark",
"all",
"added",
"tasks",
"until",
"they",
"exceed",
"the",
"set",
"time",
"limit"
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UBench.java#L351-L353
|
149,008
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.isDouble
|
public static boolean isDouble(String _str, boolean _allowNegative) {
return isDouble(_str, DecimalFormatSymbols.getInstance().getDecimalSeparator(), _allowNegative);
}
|
java
|
public static boolean isDouble(String _str, boolean _allowNegative) {
return isDouble(_str, DecimalFormatSymbols.getInstance().getDecimalSeparator(), _allowNegative);
}
|
[
"public",
"static",
"boolean",
"isDouble",
"(",
"String",
"_str",
",",
"boolean",
"_allowNegative",
")",
"{",
"return",
"isDouble",
"(",
"_str",
",",
"DecimalFormatSymbols",
".",
"getInstance",
"(",
")",
".",
"getDecimalSeparator",
"(",
")",
",",
"_allowNegative",
")",
";",
"}"
] |
Checks if the given string is a valid double.
The used separator is based on the used system locale
@param _str string to validate
@param _allowNegative set to true if negative double should be allowed
@return true if given string is double, false otherwise
|
[
"Checks",
"if",
"the",
"given",
"string",
"is",
"a",
"valid",
"double",
".",
"The",
"used",
"separator",
"is",
"based",
"on",
"the",
"used",
"system",
"locale"
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L65-L67
|
149,009
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.isDouble
|
public static boolean isDouble(String _str, char _separator, boolean _allowNegative) {
String pattern = "\\d+XXX\\d+$";
if (_separator == '.') {
pattern = pattern.replace("XXX", "\\.?");
} else {
pattern = pattern.replace("XXX", _separator + "?");
}
if (_allowNegative) {
pattern = "^-?" + pattern;
} else {
pattern = "^" + pattern;
}
if (_str != null) {
return _str.matches(pattern) || isInteger(_str, _allowNegative);
}
return false;
}
|
java
|
public static boolean isDouble(String _str, char _separator, boolean _allowNegative) {
String pattern = "\\d+XXX\\d+$";
if (_separator == '.') {
pattern = pattern.replace("XXX", "\\.?");
} else {
pattern = pattern.replace("XXX", _separator + "?");
}
if (_allowNegative) {
pattern = "^-?" + pattern;
} else {
pattern = "^" + pattern;
}
if (_str != null) {
return _str.matches(pattern) || isInteger(_str, _allowNegative);
}
return false;
}
|
[
"public",
"static",
"boolean",
"isDouble",
"(",
"String",
"_str",
",",
"char",
"_separator",
",",
"boolean",
"_allowNegative",
")",
"{",
"String",
"pattern",
"=",
"\"\\\\d+XXX\\\\d+$\"",
";",
"if",
"(",
"_separator",
"==",
"'",
"'",
")",
"{",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"\"XXX\"",
",",
"\"\\\\.?\"",
")",
";",
"}",
"else",
"{",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"\"XXX\"",
",",
"_separator",
"+",
"\"?\"",
")",
";",
"}",
"if",
"(",
"_allowNegative",
")",
"{",
"pattern",
"=",
"\"^-?\"",
"+",
"pattern",
";",
"}",
"else",
"{",
"pattern",
"=",
"\"^\"",
"+",
"pattern",
";",
"}",
"if",
"(",
"_str",
"!=",
"null",
")",
"{",
"return",
"_str",
".",
"matches",
"(",
"pattern",
")",
"||",
"isInteger",
"(",
"_str",
",",
"_allowNegative",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the given string is a valid double.
@param _str string to validate
@param _separator seperator used (e.g. "." (dot) or "," (comma))
@param _allowNegative set to true if negative double should be allowed
@return true if given string is double, false otherwise
|
[
"Checks",
"if",
"the",
"given",
"string",
"is",
"a",
"valid",
"double",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L76-L94
|
149,010
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.isInteger
|
public static boolean isInteger(String _str, boolean _allowNegative) {
if (_str == null) {
return false;
}
String regex = "[0-9]+$";
if (_allowNegative) {
regex = "^-?" + regex;
} else {
regex = "^" + regex;
}
return _str.matches(regex);
}
|
java
|
public static boolean isInteger(String _str, boolean _allowNegative) {
if (_str == null) {
return false;
}
String regex = "[0-9]+$";
if (_allowNegative) {
regex = "^-?" + regex;
} else {
regex = "^" + regex;
}
return _str.matches(regex);
}
|
[
"public",
"static",
"boolean",
"isInteger",
"(",
"String",
"_str",
",",
"boolean",
"_allowNegative",
")",
"{",
"if",
"(",
"_str",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"String",
"regex",
"=",
"\"[0-9]+$\"",
";",
"if",
"(",
"_allowNegative",
")",
"{",
"regex",
"=",
"\"^-?\"",
"+",
"regex",
";",
"}",
"else",
"{",
"regex",
"=",
"\"^\"",
"+",
"regex",
";",
"}",
"return",
"_str",
".",
"matches",
"(",
"regex",
")",
";",
"}"
] |
Check if string is an either positive or negative integer.
@param _str string to validate
@param _allowNegative negative integer allowed
@return true if integer, false otherwise
|
[
"Check",
"if",
"string",
"is",
"an",
"either",
"positive",
"or",
"negative",
"integer",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L113-L125
|
149,011
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.createRegExPatternIfValid
|
public static Pattern createRegExPatternIfValid(String _regExStr) {
if (StringUtil.isBlank(_regExStr)) {
return null;
}
Pattern pattern;
try {
pattern = Pattern.compile(_regExStr);
} catch (PatternSyntaxException _ex) {
return null;
}
return pattern;
}
|
java
|
public static Pattern createRegExPatternIfValid(String _regExStr) {
if (StringUtil.isBlank(_regExStr)) {
return null;
}
Pattern pattern;
try {
pattern = Pattern.compile(_regExStr);
} catch (PatternSyntaxException _ex) {
return null;
}
return pattern;
}
|
[
"public",
"static",
"Pattern",
"createRegExPatternIfValid",
"(",
"String",
"_regExStr",
")",
"{",
"if",
"(",
"StringUtil",
".",
"isBlank",
"(",
"_regExStr",
")",
")",
"{",
"return",
"null",
";",
"}",
"Pattern",
"pattern",
";",
"try",
"{",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"_regExStr",
")",
";",
"}",
"catch",
"(",
"PatternSyntaxException",
"_ex",
")",
"{",
"return",
"null",
";",
"}",
"return",
"pattern",
";",
"}"
] |
Creates a RegEx Pattern object, if given String is a valid regular expression.
@param _regExStr regex string to check
@return Pattern-Object or null if given String is no valid RegEx
|
[
"Creates",
"a",
"RegEx",
"Pattern",
"object",
"if",
"given",
"String",
"is",
"a",
"valid",
"regular",
"expression",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L170-L183
|
149,012
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.createList
|
@SafeVarargs
public static <T> List<T> createList(T... _entries) {
List<T> l = new ArrayList<>();
if (_entries != null) {
l.addAll(Arrays.asList(_entries));
}
return l;
}
|
java
|
@SafeVarargs
public static <T> List<T> createList(T... _entries) {
List<T> l = new ArrayList<>();
if (_entries != null) {
l.addAll(Arrays.asList(_entries));
}
return l;
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"createList",
"(",
"T",
"...",
"_entries",
")",
"{",
"List",
"<",
"T",
">",
"l",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"_entries",
"!=",
"null",
")",
"{",
"l",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"_entries",
")",
")",
";",
"}",
"return",
"l",
";",
"}"
] |
Creates a list from a varargs parameter array.
The generic list is created with the same type as the parameters.
@param _entries list entries
@param <T> list type
@return list
|
[
"Creates",
"a",
"list",
"from",
"a",
"varargs",
"parameter",
"array",
".",
"The",
"generic",
"list",
"is",
"created",
"with",
"the",
"same",
"type",
"as",
"the",
"parameters",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L192-L199
|
149,013
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.createMap
|
@SafeVarargs
public static <T> Map<T, T> createMap(T... _args) {
Map<T, T> map = new HashMap<>();
if (_args != null) {
if (_args.length % 2 != 0) {
throw new IllegalArgumentException("Even number of parameters required to create map: " + Arrays.toString(_args));
}
for (int i = 0; i < _args.length;) {
map.put(_args[i], _args[i + 1]);
i += 2;
}
}
return map;
}
|
java
|
@SafeVarargs
public static <T> Map<T, T> createMap(T... _args) {
Map<T, T> map = new HashMap<>();
if (_args != null) {
if (_args.length % 2 != 0) {
throw new IllegalArgumentException("Even number of parameters required to create map: " + Arrays.toString(_args));
}
for (int i = 0; i < _args.length;) {
map.put(_args[i], _args[i + 1]);
i += 2;
}
}
return map;
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"Map",
"<",
"T",
",",
"T",
">",
"createMap",
"(",
"T",
"...",
"_args",
")",
"{",
"Map",
"<",
"T",
",",
"T",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"_args",
"!=",
"null",
")",
"{",
"if",
"(",
"_args",
".",
"length",
"%",
"2",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Even number of parameters required to create map: \"",
"+",
"Arrays",
".",
"toString",
"(",
"_args",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_args",
".",
"length",
";",
")",
"{",
"map",
".",
"put",
"(",
"_args",
"[",
"i",
"]",
",",
"_args",
"[",
"i",
"+",
"1",
"]",
")",
";",
"i",
"+=",
"2",
";",
"}",
"}",
"return",
"map",
";",
"}"
] |
Creates a map from the even-sized parameter array.
@param <T> map type
@param _args parameter array, any type
@return map of parameter type
|
[
"Creates",
"a",
"map",
"from",
"the",
"even",
"-",
"sized",
"parameter",
"array",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L207-L220
|
149,014
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.splitList
|
public static <T> List<List<T>> splitList(List<T> _list, int _elements) {
List<List<T>> partitions = new ArrayList<>();
for (int i = 0; i < _list.size(); i += _elements) {
partitions.add(_list.subList(i,
Math.min(i + _elements, _list.size())));
}
return partitions;
}
|
java
|
public static <T> List<List<T>> splitList(List<T> _list, int _elements) {
List<List<T>> partitions = new ArrayList<>();
for (int i = 0; i < _list.size(); i += _elements) {
partitions.add(_list.subList(i,
Math.min(i + _elements, _list.size())));
}
return partitions;
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"List",
"<",
"T",
">",
">",
"splitList",
"(",
"List",
"<",
"T",
">",
"_list",
",",
"int",
"_elements",
")",
"{",
"List",
"<",
"List",
"<",
"T",
">>",
"partitions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_list",
".",
"size",
"(",
")",
";",
"i",
"+=",
"_elements",
")",
"{",
"partitions",
".",
"add",
"(",
"_list",
".",
"subList",
"(",
"i",
",",
"Math",
".",
"min",
"(",
"i",
"+",
"_elements",
",",
"_list",
".",
"size",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"partitions",
";",
"}"
] |
Split a List into equal parts.
Last list could be shorter than _elements.
@param _list list to split
@param _elements elements per list
@param <T> type
@return list of lists
|
[
"Split",
"a",
"List",
"into",
"equal",
"parts",
".",
"Last",
"list",
"could",
"be",
"shorter",
"than",
"_elements",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L295-L303
|
149,015
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/TypeUtil.java
|
TypeUtil.defaultIfNotInteger
|
public static int defaultIfNotInteger(String _possibleInt, int _default) {
if (isInteger(_possibleInt)) {
return Integer.parseInt(_possibleInt);
}
return _default;
}
|
java
|
public static int defaultIfNotInteger(String _possibleInt, int _default) {
if (isInteger(_possibleInt)) {
return Integer.parseInt(_possibleInt);
}
return _default;
}
|
[
"public",
"static",
"int",
"defaultIfNotInteger",
"(",
"String",
"_possibleInt",
",",
"int",
"_default",
")",
"{",
"if",
"(",
"isInteger",
"(",
"_possibleInt",
")",
")",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"_possibleInt",
")",
";",
"}",
"return",
"_default",
";",
"}"
] |
Returns integer converted from string or default if string could not be converted to int.
@param _possibleInt string to convert
@param _default default to use if string cannot be converted
@return int
|
[
"Returns",
"integer",
"converted",
"from",
"string",
"or",
"default",
"if",
"string",
"could",
"not",
"be",
"converted",
"to",
"int",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/TypeUtil.java#L367-L372
|
149,016
|
openbase/jul
|
schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java
|
Stopwatch.getTime
|
public long getTime() throws NotAvailableException {
synchronized (timeSync) {
try {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
if (endTime == -1) {
return System.currentTimeMillis() - startTime;
}
return endTime - startTime;
} catch (CouldNotPerformException ex) {
throw new NotAvailableException(ContextType.INSTANCE, "time", ex);
}
}
}
|
java
|
public long getTime() throws NotAvailableException {
synchronized (timeSync) {
try {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
if (endTime == -1) {
return System.currentTimeMillis() - startTime;
}
return endTime - startTime;
} catch (CouldNotPerformException ex) {
throw new NotAvailableException(ContextType.INSTANCE, "time", ex);
}
}
}
|
[
"public",
"long",
"getTime",
"(",
")",
"throws",
"NotAvailableException",
"{",
"synchronized",
"(",
"timeSync",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Stopwatch was never started!\"",
")",
";",
"}",
"if",
"(",
"endTime",
"==",
"-",
"1",
")",
"{",
"return",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
";",
"}",
"return",
"endTime",
"-",
"startTime",
";",
"}",
"catch",
"(",
"CouldNotPerformException",
"ex",
")",
"{",
"throw",
"new",
"NotAvailableException",
"(",
"ContextType",
".",
"INSTANCE",
",",
"\"time\"",
",",
"ex",
")",
";",
"}",
"}",
"}"
] |
This method returns the time interval between the start- and end timestamps.
In case the the Stopwatch is still running, the elapsed time since Stopwatch start will be returned.
@return the time interval in milliseconds.
@throws NotAvailableException This exception will thrown in case the timer was never started.
|
[
"This",
"method",
"returns",
"the",
"time",
"interval",
"between",
"the",
"start",
"-",
"and",
"end",
"timestamps",
".",
"In",
"case",
"the",
"the",
"Stopwatch",
"is",
"still",
"running",
"the",
"elapsed",
"time",
"since",
"Stopwatch",
"start",
"will",
"be",
"returned",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java#L92-L108
|
149,017
|
openbase/jul
|
schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java
|
Stopwatch.stop
|
public long stop() throws CouldNotPerformException {
synchronized (timeSync) {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
synchronized (stopWaiter) {
endTime = System.currentTimeMillis();
stopWaiter.notifyAll();
}
return getTime();
}
}
|
java
|
public long stop() throws CouldNotPerformException {
synchronized (timeSync) {
if (!isRunning()) {
throw new InvalidStateException("Stopwatch was never started!");
}
synchronized (stopWaiter) {
endTime = System.currentTimeMillis();
stopWaiter.notifyAll();
}
return getTime();
}
}
|
[
"public",
"long",
"stop",
"(",
")",
"throws",
"CouldNotPerformException",
"{",
"synchronized",
"(",
"timeSync",
")",
"{",
"if",
"(",
"!",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Stopwatch was never started!\"",
")",
";",
"}",
"synchronized",
"(",
"stopWaiter",
")",
"{",
"endTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"stopWaiter",
".",
"notifyAll",
"(",
")",
";",
"}",
"return",
"getTime",
"(",
")",
";",
"}",
"}"
] |
This method stops the Stopwatch and returns the time result.
The internal timestamps are not cleared by this method so the result can still queried by the getTime() method afterwards.
Additionally this method can be called multiply times but only the last stop timestamp will be stored and handled by the getTime() method.
@return the elapsed time interval since start.
@throws org.openbase.jul.exception.CouldNotPerformException is thrown in case the Stopwatch was never started.
|
[
"This",
"method",
"stops",
"the",
"Stopwatch",
"and",
"returns",
"the",
"time",
"result",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/schedule/src/main/java/org/openbase/jul/schedule/Stopwatch.java#L132-L145
|
149,018
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/server/ConfigurationParser.java
|
ConfigurationParser.parse
|
void parse(File file) throws ParseException {
if (file == null) {
Log.warn("parsing NULL file, so fallback on default configuration!");
return;
}
if (!file.exists()) {
Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()));
return;
}
try {
FileReader reader = new FileReader(file);
parse(reader);
} catch (FileNotFoundException fex) {
Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex);
return;
}
}
|
java
|
void parse(File file) throws ParseException {
if (file == null) {
Log.warn("parsing NULL file, so fallback on default configuration!");
return;
}
if (!file.exists()) {
Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()));
return;
}
try {
FileReader reader = new FileReader(file);
parse(reader);
} catch (FileNotFoundException fex) {
Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex);
return;
}
}
|
[
"void",
"parse",
"(",
"File",
"file",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"Log",
".",
"warn",
"(",
"\"parsing NULL file, so fallback on default configuration!\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"Log",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"parsing not existing file %s, so fallback on default configuration!\"",
",",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"return",
";",
"}",
"try",
"{",
"FileReader",
"reader",
"=",
"new",
"FileReader",
"(",
"file",
")",
";",
"parse",
"(",
"reader",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"fex",
")",
"{",
"Log",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"parsing not existing file %s, so fallback on default configuration!\"",
",",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
",",
"fex",
")",
";",
"return",
";",
"}",
"}"
] |
Parse the configuration from file.
|
[
"Parse",
"the",
"configuration",
"from",
"file",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/server/ConfigurationParser.java#L52-L68
|
149,019
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/server/ConfigurationParser.java
|
ConfigurationParser.parse
|
void parse(Reader reader) throws ParseException {
if (reader == null) {
//just log and return default properties
Log.warn("parsing NULL reader, so fallback on default configuration!");
return;
}
BufferedReader br = new BufferedReader(reader);
String line;
try {
while ((line = br.readLine()) != null) {
int commentMarker = line.indexOf('#');
if (commentMarker != -1) {
if (commentMarker == 0) {
//skip its a comment
continue;
} else {
//it's a malformed comment
throw new ParseException(line, commentMarker);
}
} else {
if (line.isEmpty() || line.matches("^\\s*$")) {
//skip it's a black line
continue;
}
//split till the first space
int deilimiterIdx = line.indexOf(' ');
String key = line.substring(0, deilimiterIdx).trim();
String value = line.substring(deilimiterIdx).trim();
m_properties.put(key, value);
}
}
} catch (IOException ex) {
throw new ParseException("Failed to read", 1);
}
}
|
java
|
void parse(Reader reader) throws ParseException {
if (reader == null) {
//just log and return default properties
Log.warn("parsing NULL reader, so fallback on default configuration!");
return;
}
BufferedReader br = new BufferedReader(reader);
String line;
try {
while ((line = br.readLine()) != null) {
int commentMarker = line.indexOf('#');
if (commentMarker != -1) {
if (commentMarker == 0) {
//skip its a comment
continue;
} else {
//it's a malformed comment
throw new ParseException(line, commentMarker);
}
} else {
if (line.isEmpty() || line.matches("^\\s*$")) {
//skip it's a black line
continue;
}
//split till the first space
int deilimiterIdx = line.indexOf(' ');
String key = line.substring(0, deilimiterIdx).trim();
String value = line.substring(deilimiterIdx).trim();
m_properties.put(key, value);
}
}
} catch (IOException ex) {
throw new ParseException("Failed to read", 1);
}
}
|
[
"void",
"parse",
"(",
"Reader",
"reader",
")",
"throws",
"ParseException",
"{",
"if",
"(",
"reader",
"==",
"null",
")",
"{",
"//just log and return default properties",
"Log",
".",
"warn",
"(",
"\"parsing NULL reader, so fallback on default configuration!\"",
")",
";",
"return",
";",
"}",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"reader",
")",
";",
"String",
"line",
";",
"try",
"{",
"while",
"(",
"(",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"int",
"commentMarker",
"=",
"line",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"commentMarker",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"commentMarker",
"==",
"0",
")",
"{",
"//skip its a comment",
"continue",
";",
"}",
"else",
"{",
"//it's a malformed comment",
"throw",
"new",
"ParseException",
"(",
"line",
",",
"commentMarker",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"line",
".",
"isEmpty",
"(",
")",
"||",
"line",
".",
"matches",
"(",
"\"^\\\\s*$\"",
")",
")",
"{",
"//skip it's a black line",
"continue",
";",
"}",
"//split till the first space",
"int",
"deilimiterIdx",
"=",
"line",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"String",
"key",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"deilimiterIdx",
")",
".",
"trim",
"(",
")",
";",
"String",
"value",
"=",
"line",
".",
"substring",
"(",
"deilimiterIdx",
")",
".",
"trim",
"(",
")",
";",
"m_properties",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"\"Failed to read\"",
",",
"1",
")",
";",
"}",
"}"
] |
Parse the configuration
@throws ParseException if the format is not compliant.
|
[
"Parse",
"the",
"configuration"
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/server/ConfigurationParser.java#L75-L112
|
149,020
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/DataSourceBackendId.java
|
DataSourceBackendId.getInstance
|
public static DataSourceBackendId getInstance(String id) {
DataSourceBackendId result = cache.get(id);
if (result == null) {
id = id.intern();
result = new DataSourceBackendId(id);
cache.put(id, result);
}
return result;
}
|
java
|
public static DataSourceBackendId getInstance(String id) {
DataSourceBackendId result = cache.get(id);
if (result == null) {
id = id.intern();
result = new DataSourceBackendId(id);
cache.put(id, result);
}
return result;
}
|
[
"public",
"static",
"DataSourceBackendId",
"getInstance",
"(",
"String",
"id",
")",
"{",
"DataSourceBackendId",
"result",
"=",
"cache",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"id",
"=",
"id",
".",
"intern",
"(",
")",
";",
"result",
"=",
"new",
"DataSourceBackendId",
"(",
"id",
")",
";",
"cache",
".",
"put",
"(",
"id",
",",
"result",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Creates a data source backend id.
@param id the id {@link String}. Cannot be <code>null</code>.
@return a {@link DataSourceBackendId}.
|
[
"Creates",
"a",
"data",
"source",
"backend",
"id",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/DataSourceBackendId.java#L45-L53
|
149,021
|
jbundle/jcalendarbutton
|
src/main/java/org/jbundle/util/jcalendarbutton/JTimeButton.java
|
JTimeButton.init
|
public void init(String param, Date time, String language)
{
if (param == null)
param = JCalendarPopup.DATE_PARAM;
timeParam = param;
targetTime = time;
languageString = language;
this.setName("JTimeButton");
}
|
java
|
public void init(String param, Date time, String language)
{
if (param == null)
param = JCalendarPopup.DATE_PARAM;
timeParam = param;
targetTime = time;
languageString = language;
this.setName("JTimeButton");
}
|
[
"public",
"void",
"init",
"(",
"String",
"param",
",",
"Date",
"time",
",",
"String",
"language",
")",
"{",
"if",
"(",
"param",
"==",
"null",
")",
"param",
"=",
"JCalendarPopup",
".",
"DATE_PARAM",
";",
"timeParam",
"=",
"param",
";",
"targetTime",
"=",
"time",
";",
"languageString",
"=",
"language",
";",
"this",
".",
"setName",
"(",
"\"JTimeButton\"",
")",
";",
"}"
] |
Creates new TimeButton.
@param strDateParam The name of the date property (defaults to 'date').
@param dateTarget The initial date for this button.
@param language The language to use.
|
[
"Creates",
"new",
"TimeButton",
"."
] |
2944e6a0b634b83768d5c0b7b4a2898176421403
|
https://github.com/jbundle/jcalendarbutton/blob/2944e6a0b634b83768d5c0b7b4a2898176421403/src/main/java/org/jbundle/util/jcalendarbutton/JTimeButton.java#L118-L127
|
149,022
|
jbundle/jcalendarbutton
|
src/main/java/org/jbundle/util/jcalendarbutton/JTimeButton.java
|
JTimeButton.actionPerformed
|
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == this)
{
Date dateTarget = this.getTargetDate();
JTimePopup popup = JTimePopup.createTimePopup(this.getTimeParam(), dateTarget, this, languageString);
popup.addPropertyChangeListener(this);
}
}
|
java
|
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == this)
{
Date dateTarget = this.getTargetDate();
JTimePopup popup = JTimePopup.createTimePopup(this.getTimeParam(), dateTarget, this, languageString);
popup.addPropertyChangeListener(this);
}
}
|
[
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getSource",
"(",
")",
"==",
"this",
")",
"{",
"Date",
"dateTarget",
"=",
"this",
".",
"getTargetDate",
"(",
")",
";",
"JTimePopup",
"popup",
"=",
"JTimePopup",
".",
"createTimePopup",
"(",
"this",
".",
"getTimeParam",
"(",
")",
",",
"dateTarget",
",",
"this",
",",
"languageString",
")",
";",
"popup",
".",
"addPropertyChangeListener",
"(",
"this",
")",
";",
"}",
"}"
] |
The user pressed the button, display the JTimePopup.
@param e The ActionEvent.
|
[
"The",
"user",
"pressed",
"the",
"button",
"display",
"the",
"JTimePopup",
"."
] |
2944e6a0b634b83768d5c0b7b4a2898176421403
|
https://github.com/jbundle/jcalendarbutton/blob/2944e6a0b634b83768d5c0b7b4a2898176421403/src/main/java/org/jbundle/util/jcalendarbutton/JTimeButton.java#L176-L184
|
149,023
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java
|
Line3D.setStartEndPoints
|
public final void setStartEndPoints(final Point3D start, final Point3D end) {
final Point3D direction = start.subtract(end);
final Point3D position = start.midpoint(end);
setLength(direction.magnitude());
final Point3D axis = UP.crossProduct(direction.normalize());
super.setVisible(true);
super.setTranslateX(position.getX());
super.setTranslateY(position.getY());
super.setTranslateZ(position.getZ());
super.setRotationAxis(axis);
super.setRotate(UP.angle(direction.normalize()));
}
|
java
|
public final void setStartEndPoints(final Point3D start, final Point3D end) {
final Point3D direction = start.subtract(end);
final Point3D position = start.midpoint(end);
setLength(direction.magnitude());
final Point3D axis = UP.crossProduct(direction.normalize());
super.setVisible(true);
super.setTranslateX(position.getX());
super.setTranslateY(position.getY());
super.setTranslateZ(position.getZ());
super.setRotationAxis(axis);
super.setRotate(UP.angle(direction.normalize()));
}
|
[
"public",
"final",
"void",
"setStartEndPoints",
"(",
"final",
"Point3D",
"start",
",",
"final",
"Point3D",
"end",
")",
"{",
"final",
"Point3D",
"direction",
"=",
"start",
".",
"subtract",
"(",
"end",
")",
";",
"final",
"Point3D",
"position",
"=",
"start",
".",
"midpoint",
"(",
"end",
")",
";",
"setLength",
"(",
"direction",
".",
"magnitude",
"(",
")",
")",
";",
"final",
"Point3D",
"axis",
"=",
"UP",
".",
"crossProduct",
"(",
"direction",
".",
"normalize",
"(",
")",
")",
";",
"super",
".",
"setVisible",
"(",
"true",
")",
";",
"super",
".",
"setTranslateX",
"(",
"position",
".",
"getX",
"(",
")",
")",
";",
"super",
".",
"setTranslateY",
"(",
"position",
".",
"getY",
"(",
")",
")",
";",
"super",
".",
"setTranslateZ",
"(",
"position",
".",
"getZ",
"(",
")",
")",
";",
"super",
".",
"setRotationAxis",
"(",
"axis",
")",
";",
"super",
".",
"setRotate",
"(",
"UP",
".",
"angle",
"(",
"direction",
".",
"normalize",
"(",
")",
")",
")",
";",
"}"
] |
Sets the start and end point of the line.
@param start Start point of the line.
@param end End point of the line.
|
[
"Sets",
"the",
"start",
"and",
"end",
"point",
"of",
"the",
"line",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java#L118-L129
|
149,024
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java
|
Line3D.setMaterial
|
public void setMaterial(final Material material) {
switch (type) {
case BOX:
box.setMaterial(material);
break;
case CYLINDER:
cylinder.setMaterial(material);
break;
default:
break;
}
}
|
java
|
public void setMaterial(final Material material) {
switch (type) {
case BOX:
box.setMaterial(material);
break;
case CYLINDER:
cylinder.setMaterial(material);
break;
default:
break;
}
}
|
[
"public",
"void",
"setMaterial",
"(",
"final",
"Material",
"material",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BOX",
":",
"box",
".",
"setMaterial",
"(",
"material",
")",
";",
"break",
";",
"case",
"CYLINDER",
":",
"cylinder",
".",
"setMaterial",
"(",
"material",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] |
Sets the Material of the line, which can be used to display different
colors.
@param material The line material.
|
[
"Sets",
"the",
"Material",
"of",
"the",
"line",
"which",
"can",
"be",
"used",
"to",
"display",
"different",
"colors",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java#L137-L148
|
149,025
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java
|
Line3D.setWidth
|
public void setWidth(double width) {
switch (type) {
case BOX:
box.setWidth(width);
box.setDepth(width);
break;
case CYLINDER:
cylinder.setRadius(width * 0.5);
break;
default:
break;
}
}
|
java
|
public void setWidth(double width) {
switch (type) {
case BOX:
box.setWidth(width);
box.setDepth(width);
break;
case CYLINDER:
cylinder.setRadius(width * 0.5);
break;
default:
break;
}
}
|
[
"public",
"void",
"setWidth",
"(",
"double",
"width",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BOX",
":",
"box",
".",
"setWidth",
"(",
"width",
")",
";",
"box",
".",
"setDepth",
"(",
"width",
")",
";",
"break",
";",
"case",
"CYLINDER",
":",
"cylinder",
".",
"setRadius",
"(",
"width",
"*",
"0.5",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] |
Sets the width of the line.
@param width The line width.
|
[
"Sets",
"the",
"width",
"of",
"the",
"line",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java#L155-L167
|
149,026
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java
|
Line3D.setLength
|
private void setLength(double length) {
switch (type) {
case BOX:
box.setHeight(length);
break;
case CYLINDER:
cylinder.setHeight(length);
break;
default:
break;
}
}
|
java
|
private void setLength(double length) {
switch (type) {
case BOX:
box.setHeight(length);
break;
case CYLINDER:
cylinder.setHeight(length);
break;
default:
break;
}
}
|
[
"private",
"void",
"setLength",
"(",
"double",
"length",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"BOX",
":",
"box",
".",
"setHeight",
"(",
"length",
")",
";",
"break",
";",
"case",
"CYLINDER",
":",
"cylinder",
".",
"setHeight",
"(",
"length",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] |
Sets the length of the line. This is only used internally to shape the
line correctly.
@param length Length of the line.
|
[
"Sets",
"the",
"length",
"of",
"the",
"line",
".",
"This",
"is",
"only",
"used",
"internally",
"to",
"shape",
"the",
"line",
"correctly",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/Line3D.java#L175-L186
|
149,027
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/backend/asb/java/AbstractJavaAlgorithmBackend.java
|
AbstractJavaAlgorithmBackend.initialize
|
@Override
public final void initialize(BackendInstanceSpec config)
throws BackendInitializationException {
super.initialize(config);
try {
IOUtil.readPropertiesFromResource(algorithmClasses, getClass(),
getAlgorithmsPropertiesResourceName());
} catch (IOException e) {
throw new AlgorithmSourceBackendInitializationException(
"Could not initialize " + getClass(), e);
}
}
|
java
|
@Override
public final void initialize(BackendInstanceSpec config)
throws BackendInitializationException {
super.initialize(config);
try {
IOUtil.readPropertiesFromResource(algorithmClasses, getClass(),
getAlgorithmsPropertiesResourceName());
} catch (IOException e) {
throw new AlgorithmSourceBackendInitializationException(
"Could not initialize " + getClass(), e);
}
}
|
[
"@",
"Override",
"public",
"final",
"void",
"initialize",
"(",
"BackendInstanceSpec",
"config",
")",
"throws",
"BackendInitializationException",
"{",
"super",
".",
"initialize",
"(",
"config",
")",
";",
"try",
"{",
"IOUtil",
".",
"readPropertiesFromResource",
"(",
"algorithmClasses",
",",
"getClass",
"(",
")",
",",
"getAlgorithmsPropertiesResourceName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"AlgorithmSourceBackendInitializationException",
"(",
"\"Could not initialize \"",
"+",
"getClass",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Reads the properties file containing the list of algorithm classes.
|
[
"Reads",
"the",
"properties",
"file",
"containing",
"the",
"list",
"of",
"algorithm",
"classes",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/backend/asb/java/AbstractJavaAlgorithmBackend.java#L68-L79
|
149,028
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/collections/BidiMap.java
|
BidiMap.removeValue
|
public K removeValue(V _val) {
checkParms(_val);
K removedKey = inverseMap.remove(_val);
if (removedKey != null) {
map.remove(removedKey);
}
return removedKey;
}
|
java
|
public K removeValue(V _val) {
checkParms(_val);
K removedKey = inverseMap.remove(_val);
if (removedKey != null) {
map.remove(removedKey);
}
return removedKey;
}
|
[
"public",
"K",
"removeValue",
"(",
"V",
"_val",
")",
"{",
"checkParms",
"(",
"_val",
")",
";",
"K",
"removedKey",
"=",
"inverseMap",
".",
"remove",
"(",
"_val",
")",
";",
"if",
"(",
"removedKey",
"!=",
"null",
")",
"{",
"map",
".",
"remove",
"(",
"removedKey",
")",
";",
"}",
"return",
"removedKey",
";",
"}"
] |
Removes the mapping for a value from this map if it is present.
@param _val value whose mapping is to be removed from the map
@return the previous key associated with <tt>value</tt>.
|
[
"Removes",
"the",
"mapping",
"for",
"a",
"value",
"from",
"this",
"map",
"if",
"it",
"is",
"present",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/collections/BidiMap.java#L109-L116
|
149,029
|
eurekaclinical/protempa
|
protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/RetryableSQLExecutor.java
|
RetryableSQLExecutor.attempt
|
@Override
public SQLException attempt() {
try {
Connection con = this.connectionSpec.getOrCreate();
con.setReadOnly(true);
try {
Statement stmt = con.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(AbstractSQLGenerator.FETCH_SIZE);
if (this.queryTimeout != null) {
stmt.setQueryTimeout(this.queryTimeout);
}
try {
SQLExecutor.executeSQL(con, stmt, this.query,
this.resultProcessor);
stmt.close();
stmt = null;
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
}
}
}
con.close();
con = null;
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
}
}
}
return null;
} catch (SQLException ex) {
return ex;
}
}
|
java
|
@Override
public SQLException attempt() {
try {
Connection con = this.connectionSpec.getOrCreate();
con.setReadOnly(true);
try {
Statement stmt = con.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(AbstractSQLGenerator.FETCH_SIZE);
if (this.queryTimeout != null) {
stmt.setQueryTimeout(this.queryTimeout);
}
try {
SQLExecutor.executeSQL(con, stmt, this.query,
this.resultProcessor);
stmt.close();
stmt = null;
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
}
}
}
con.close();
con = null;
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
}
}
}
return null;
} catch (SQLException ex) {
return ex;
}
}
|
[
"@",
"Override",
"public",
"SQLException",
"attempt",
"(",
")",
"{",
"try",
"{",
"Connection",
"con",
"=",
"this",
".",
"connectionSpec",
".",
"getOrCreate",
"(",
")",
";",
"con",
".",
"setReadOnly",
"(",
"true",
")",
";",
"try",
"{",
"Statement",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
"ResultSet",
".",
"TYPE_FORWARD_ONLY",
",",
"ResultSet",
".",
"CONCUR_READ_ONLY",
")",
";",
"stmt",
".",
"setFetchSize",
"(",
"AbstractSQLGenerator",
".",
"FETCH_SIZE",
")",
";",
"if",
"(",
"this",
".",
"queryTimeout",
"!=",
"null",
")",
"{",
"stmt",
".",
"setQueryTimeout",
"(",
"this",
".",
"queryTimeout",
")",
";",
"}",
"try",
"{",
"SQLExecutor",
".",
"executeSQL",
"(",
"con",
",",
"stmt",
",",
"this",
".",
"query",
",",
"this",
".",
"resultProcessor",
")",
";",
"stmt",
".",
"close",
"(",
")",
";",
"stmt",
"=",
"null",
";",
"}",
"finally",
"{",
"if",
"(",
"stmt",
"!=",
"null",
")",
"{",
"try",
"{",
"stmt",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"}",
"}",
"}",
"con",
".",
"close",
"(",
")",
";",
"con",
"=",
"null",
";",
"}",
"finally",
"{",
"if",
"(",
"con",
"!=",
"null",
")",
"{",
"try",
"{",
"con",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"null",
";",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"return",
"ex",
";",
"}",
"}"
] |
Attempts executing the query specified in the constructor.
@return a {@link SQLException} if execution failed, or <code>null</code>
if execution was successful.
|
[
"Attempts",
"executing",
"the",
"query",
"specified",
"in",
"the",
"constructor",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-dsb-relationaldb/src/main/java/org/protempa/backend/dsb/relationaldb/RetryableSQLExecutor.java#L95-L135
|
149,030
|
foundation-runtime/configuration
|
configuration-lib/src/main/java/com/cisco/oss/foundation/configuration/FoundationCompositeConfiguration.java
|
FoundationCompositeConfiguration.getKeys
|
@Override
@SuppressWarnings("unchecked")
/**
* override to support ordering of returned keys.
*/
public Iterator<String> getKeys() {
final Iterator tempKeysIter = super.getKeys();
final List<String> keys = sortKeys(tempKeysIter);
return keys.iterator();
}
|
java
|
@Override
@SuppressWarnings("unchecked")
/**
* override to support ordering of returned keys.
*/
public Iterator<String> getKeys() {
final Iterator tempKeysIter = super.getKeys();
final List<String> keys = sortKeys(tempKeysIter);
return keys.iterator();
}
|
[
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"/**\n * override to support ordering of returned keys.\n */",
"public",
"Iterator",
"<",
"String",
">",
"getKeys",
"(",
")",
"{",
"final",
"Iterator",
"tempKeysIter",
"=",
"super",
".",
"getKeys",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"keys",
"=",
"sortKeys",
"(",
"tempKeysIter",
")",
";",
"return",
"keys",
".",
"iterator",
"(",
")",
";",
"}"
] |
each call to this method method will first sort the keys and then return
the iterator.
|
[
"each",
"call",
"to",
"this",
"method",
"method",
"will",
"first",
"sort",
"the",
"keys",
"and",
"then",
"return",
"the",
"iterator",
"."
] |
c5bd171a2cca0dc1c8d568f987843ca47c6d1eed
|
https://github.com/foundation-runtime/configuration/blob/c5bd171a2cca0dc1c8d568f987843ca47c6d1eed/configuration-lib/src/main/java/com/cisco/oss/foundation/configuration/FoundationCompositeConfiguration.java#L47-L58
|
149,031
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/ResourceFactory.java
|
ResourceFactory.getGenericResource
|
public static Resource getGenericResource(String resource) {
log.trace("retrieving resource -> " + resource);
try {
final File file = normFile(resource);
if (file.exists()) {
return new ResourceImpl(file.toURI().toURL());
}
if (resource.startsWith("/")) {
throw new IllegalArgumentException("Classpath resource cannot start with '/': " + resource);
}
if (resource.indexOf('\\') != -1) {
throw new IllegalArgumentException("Classpath resource cannot contain '\\': " + resource);
}
URL url = getLoader().getResource(resource);
if (url == null) {
return null;
}
return new ResourceImpl(url);
} catch (Exception e) {
log.error("Could not retrieve resource: " + e.getMessage(), e);
return null;
}
}
|
java
|
public static Resource getGenericResource(String resource) {
log.trace("retrieving resource -> " + resource);
try {
final File file = normFile(resource);
if (file.exists()) {
return new ResourceImpl(file.toURI().toURL());
}
if (resource.startsWith("/")) {
throw new IllegalArgumentException("Classpath resource cannot start with '/': " + resource);
}
if (resource.indexOf('\\') != -1) {
throw new IllegalArgumentException("Classpath resource cannot contain '\\': " + resource);
}
URL url = getLoader().getResource(resource);
if (url == null) {
return null;
}
return new ResourceImpl(url);
} catch (Exception e) {
log.error("Could not retrieve resource: " + e.getMessage(), e);
return null;
}
}
|
[
"public",
"static",
"Resource",
"getGenericResource",
"(",
"String",
"resource",
")",
"{",
"log",
".",
"trace",
"(",
"\"retrieving resource -> \"",
"+",
"resource",
")",
";",
"try",
"{",
"final",
"File",
"file",
"=",
"normFile",
"(",
"resource",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"return",
"new",
"ResourceImpl",
"(",
"file",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
")",
";",
"}",
"if",
"(",
"resource",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Classpath resource cannot start with '/': \"",
"+",
"resource",
")",
";",
"}",
"if",
"(",
"resource",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Classpath resource cannot contain '\\\\': \"",
"+",
"resource",
")",
";",
"}",
"URL",
"url",
"=",
"getLoader",
"(",
")",
".",
"getResource",
"(",
"resource",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ResourceImpl",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Could not retrieve resource: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Gets a generic resource, searching first from the file system then in the classpath if not found.
@param resource The resource name
@return The resource
|
[
"Gets",
"a",
"generic",
"resource",
"searching",
"first",
"from",
"the",
"file",
"system",
"then",
"in",
"the",
"classpath",
"if",
"not",
"found",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/ResourceFactory.java#L100-L124
|
149,032
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/proposition/value/NumberValue.java
|
NumberValue.compare
|
@Override
public ValueComparator compare(Value o) {
if (o == null) {
return ValueComparator.NOT_EQUAL_TO;
}
switch (o.getType()) {
case NUMBERVALUE:
NumberValue other = (NumberValue) o;
int comp = compareTo(other);
return comp > 0 ? ValueComparator.GREATER_THAN
: (comp < 0 ? ValueComparator.LESS_THAN
: ValueComparator.EQUAL_TO);
case INEQUALITYNUMBERVALUE:
InequalityNumberValue other2 = (InequalityNumberValue) o;
int comp2 = num.compareTo((BigDecimal) other2.getNumber());
switch (other2.getComparator()) {
case EQUAL_TO:
return comp2 > 0 ? ValueComparator.GREATER_THAN
: (comp2 < 0 ? ValueComparator.LESS_THAN
: ValueComparator.EQUAL_TO);
case GREATER_THAN:
return comp2 <= 0 ? ValueComparator.LESS_THAN
: ValueComparator.UNKNOWN;
default:
return comp2 >= 0 ? ValueComparator.GREATER_THAN
: ValueComparator.UNKNOWN;
}
case VALUELIST:
ValueList<?> vl = (ValueList<?>) o;
return equals(vl) ? ValueComparator.EQUAL_TO
: ValueComparator.NOT_EQUAL_TO;
default:
return ValueComparator.NOT_EQUAL_TO;
}
}
|
java
|
@Override
public ValueComparator compare(Value o) {
if (o == null) {
return ValueComparator.NOT_EQUAL_TO;
}
switch (o.getType()) {
case NUMBERVALUE:
NumberValue other = (NumberValue) o;
int comp = compareTo(other);
return comp > 0 ? ValueComparator.GREATER_THAN
: (comp < 0 ? ValueComparator.LESS_THAN
: ValueComparator.EQUAL_TO);
case INEQUALITYNUMBERVALUE:
InequalityNumberValue other2 = (InequalityNumberValue) o;
int comp2 = num.compareTo((BigDecimal) other2.getNumber());
switch (other2.getComparator()) {
case EQUAL_TO:
return comp2 > 0 ? ValueComparator.GREATER_THAN
: (comp2 < 0 ? ValueComparator.LESS_THAN
: ValueComparator.EQUAL_TO);
case GREATER_THAN:
return comp2 <= 0 ? ValueComparator.LESS_THAN
: ValueComparator.UNKNOWN;
default:
return comp2 >= 0 ? ValueComparator.GREATER_THAN
: ValueComparator.UNKNOWN;
}
case VALUELIST:
ValueList<?> vl = (ValueList<?>) o;
return equals(vl) ? ValueComparator.EQUAL_TO
: ValueComparator.NOT_EQUAL_TO;
default:
return ValueComparator.NOT_EQUAL_TO;
}
}
|
[
"@",
"Override",
"public",
"ValueComparator",
"compare",
"(",
"Value",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"}",
"switch",
"(",
"o",
".",
"getType",
"(",
")",
")",
"{",
"case",
"NUMBERVALUE",
":",
"NumberValue",
"other",
"=",
"(",
"NumberValue",
")",
"o",
";",
"int",
"comp",
"=",
"compareTo",
"(",
"other",
")",
";",
"return",
"comp",
">",
"0",
"?",
"ValueComparator",
".",
"GREATER_THAN",
":",
"(",
"comp",
"<",
"0",
"?",
"ValueComparator",
".",
"LESS_THAN",
":",
"ValueComparator",
".",
"EQUAL_TO",
")",
";",
"case",
"INEQUALITYNUMBERVALUE",
":",
"InequalityNumberValue",
"other2",
"=",
"(",
"InequalityNumberValue",
")",
"o",
";",
"int",
"comp2",
"=",
"num",
".",
"compareTo",
"(",
"(",
"BigDecimal",
")",
"other2",
".",
"getNumber",
"(",
")",
")",
";",
"switch",
"(",
"other2",
".",
"getComparator",
"(",
")",
")",
"{",
"case",
"EQUAL_TO",
":",
"return",
"comp2",
">",
"0",
"?",
"ValueComparator",
".",
"GREATER_THAN",
":",
"(",
"comp2",
"<",
"0",
"?",
"ValueComparator",
".",
"LESS_THAN",
":",
"ValueComparator",
".",
"EQUAL_TO",
")",
";",
"case",
"GREATER_THAN",
":",
"return",
"comp2",
"<=",
"0",
"?",
"ValueComparator",
".",
"LESS_THAN",
":",
"ValueComparator",
".",
"UNKNOWN",
";",
"default",
":",
"return",
"comp2",
">=",
"0",
"?",
"ValueComparator",
".",
"GREATER_THAN",
":",
"ValueComparator",
".",
"UNKNOWN",
";",
"}",
"case",
"VALUELIST",
":",
"ValueList",
"<",
"?",
">",
"vl",
"=",
"(",
"ValueList",
"<",
"?",
">",
")",
"o",
";",
"return",
"equals",
"(",
"vl",
")",
"?",
"ValueComparator",
".",
"EQUAL_TO",
":",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"default",
":",
"return",
"ValueComparator",
".",
"NOT_EQUAL_TO",
";",
"}",
"}"
] |
Compares this value and another numerically, or checks this number value
for membership in a value list.
@param o a {@link Value}.
@return If the provided value is a {@link NumericalValue}, returns null {@link ValueComparator#GREATER_THAN},
{@link ValueComparator#LESS_THAN} or {@link ValueComparator#EQUAL_TO}
depending on whether this value is numerically greater than, less than or
equal to the value provided as argument. If the provided value is a
{@link ValueList}, returns {@link ValueComparator#IN} if this object is a
member of the list, or {@link ValueComparator#NOT_IN} if not. Otherwise,
returns {@link ValueComparator#UNKNOWN}.
|
[
"Compares",
"this",
"value",
"and",
"another",
"numerically",
"or",
"checks",
"this",
"number",
"value",
"for",
"membership",
"in",
"a",
"value",
"list",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/proposition/value/NumberValue.java#L207-L241
|
149,033
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/BellmanFord.java
|
BellmanFord.hasNegativeCycle
|
public static boolean hasNegativeCycle(Object sourceOrDest,
DirectedGraph g, Mode mode) {
return calcShortestDistances(sourceOrDest, g, mode) == null;
}
|
java
|
public static boolean hasNegativeCycle(Object sourceOrDest,
DirectedGraph g, Mode mode) {
return calcShortestDistances(sourceOrDest, g, mode) == null;
}
|
[
"public",
"static",
"boolean",
"hasNegativeCycle",
"(",
"Object",
"sourceOrDest",
",",
"DirectedGraph",
"g",
",",
"Mode",
"mode",
")",
"{",
"return",
"calcShortestDistances",
"(",
"sourceOrDest",
",",
"g",
",",
"mode",
")",
"==",
"null",
";",
"}"
] |
Determines if there are any negative cycles found.
@param sourceOrDest
a vertex.
@return <code>true</code> if a negative cycle was found,
<code>false</code> otherwise.
|
[
"Determines",
"if",
"there",
"are",
"any",
"negative",
"cycles",
"found",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/BellmanFord.java#L82-L85
|
149,034
|
znerd/xmlenc
|
src/main/java/org/znerd/xmlenc/XMLOutputter.java
|
XMLOutputter.checkInvariants
|
private final void checkInvariants() throws Error {
if (_lineBreak == null) {
throw new Error("_lineBreak == null");
} else if (_lineBreak == LineBreak.NONE && _indentation.length() > 0) {
throw new Error("_lineBreak == LineBreak.NONE && _indentation = \"" + _indentation + "\".");
} else if (_elementStack == null) {
throw new Error("_elementStack (" + _elementStack + " == null");
} else if (_elementStackSize < 0) {
throw new Error("_elementStackSize (" + _elementStackSize + ") < 0");
}
}
|
java
|
private final void checkInvariants() throws Error {
if (_lineBreak == null) {
throw new Error("_lineBreak == null");
} else if (_lineBreak == LineBreak.NONE && _indentation.length() > 0) {
throw new Error("_lineBreak == LineBreak.NONE && _indentation = \"" + _indentation + "\".");
} else if (_elementStack == null) {
throw new Error("_elementStack (" + _elementStack + " == null");
} else if (_elementStackSize < 0) {
throw new Error("_elementStackSize (" + _elementStackSize + ") < 0");
}
}
|
[
"private",
"final",
"void",
"checkInvariants",
"(",
")",
"throws",
"Error",
"{",
"if",
"(",
"_lineBreak",
"==",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_lineBreak == null\"",
")",
";",
"}",
"else",
"if",
"(",
"_lineBreak",
"==",
"LineBreak",
".",
"NONE",
"&&",
"_indentation",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_lineBreak == LineBreak.NONE && _indentation = \\\"\"",
"+",
"_indentation",
"+",
"\"\\\".\"",
")",
";",
"}",
"else",
"if",
"(",
"_elementStack",
"==",
"null",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_elementStack (\"",
"+",
"_elementStack",
"+",
"\" == null\"",
")",
";",
"}",
"else",
"if",
"(",
"_elementStackSize",
"<",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_elementStackSize (\"",
"+",
"_elementStackSize",
"+",
"\") < 0\"",
")",
";",
"}",
"}"
] |
Checks all invariants. This check should be performed at the end of
every method that changes the internal state of this object.
@throws Error if the state of this <code>XMLOutputter</code> is invalid.
|
[
"Checks",
"all",
"invariants",
".",
"This",
"check",
"should",
"be",
"performed",
"at",
"the",
"end",
"of",
"every",
"method",
"that",
"changes",
"the",
"internal",
"state",
"of",
"this",
"object",
"."
] |
6ff483777d9467db9990b7c7ae0158f21a243c31
|
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLOutputter.java#L185-L196
|
149,035
|
znerd/xmlenc
|
src/main/java/org/znerd/xmlenc/XMLOutputter.java
|
XMLOutputter.writeIndentation
|
private final void writeIndentation() throws IOException {
// Write indentation only if there is any
if (_indentation.length() > 0) {
int count = _elementStackSize - 1;
for (int i = 0; i < count; i++) {
_out.write(_indentation);
}
}
}
|
java
|
private final void writeIndentation() throws IOException {
// Write indentation only if there is any
if (_indentation.length() > 0) {
int count = _elementStackSize - 1;
for (int i = 0; i < count; i++) {
_out.write(_indentation);
}
}
}
|
[
"private",
"final",
"void",
"writeIndentation",
"(",
")",
"throws",
"IOException",
"{",
"// Write indentation only if there is any",
"if",
"(",
"_indentation",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"int",
"count",
"=",
"_elementStackSize",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"_out",
".",
"write",
"(",
"_indentation",
")",
";",
"}",
"}",
"}"
] |
Writes the indentation to the output stream.
@throws IOException if an I/O error occurs.
|
[
"Writes",
"the",
"indentation",
"to",
"the",
"output",
"stream",
"."
] |
6ff483777d9467db9990b7c7ae0158f21a243c31
|
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLOutputter.java#L203-L212
|
149,036
|
znerd/xmlenc
|
src/main/java/org/znerd/xmlenc/XMLOutputter.java
|
XMLOutputter.setElementStackCapacity
|
public final void setElementStackCapacity(int newCapacity) throws IllegalArgumentException, OutOfMemoryError {
// Check argument
if (newCapacity < _elementStack.length) {
throw new IllegalArgumentException("newCapacity < getElementStackSize()");
}
int currentCapacity = _elementStack.length;
// Short-circuit if possible
if (currentCapacity == newCapacity) {
return;
}
String[] newStack = new String[newCapacity];
System.arraycopy(_elementStack, 0, newStack, 0, _elementStackSize);
_elementStack = newStack;
// State has changed, check
checkInvariants();
}
|
java
|
public final void setElementStackCapacity(int newCapacity) throws IllegalArgumentException, OutOfMemoryError {
// Check argument
if (newCapacity < _elementStack.length) {
throw new IllegalArgumentException("newCapacity < getElementStackSize()");
}
int currentCapacity = _elementStack.length;
// Short-circuit if possible
if (currentCapacity == newCapacity) {
return;
}
String[] newStack = new String[newCapacity];
System.arraycopy(_elementStack, 0, newStack, 0, _elementStackSize);
_elementStack = newStack;
// State has changed, check
checkInvariants();
}
|
[
"public",
"final",
"void",
"setElementStackCapacity",
"(",
"int",
"newCapacity",
")",
"throws",
"IllegalArgumentException",
",",
"OutOfMemoryError",
"{",
"// Check argument",
"if",
"(",
"newCapacity",
"<",
"_elementStack",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"newCapacity < getElementStackSize()\"",
")",
";",
"}",
"int",
"currentCapacity",
"=",
"_elementStack",
".",
"length",
";",
"// Short-circuit if possible",
"if",
"(",
"currentCapacity",
"==",
"newCapacity",
")",
"{",
"return",
";",
"}",
"String",
"[",
"]",
"newStack",
"=",
"new",
"String",
"[",
"newCapacity",
"]",
";",
"System",
".",
"arraycopy",
"(",
"_elementStack",
",",
"0",
",",
"newStack",
",",
"0",
",",
"_elementStackSize",
")",
";",
"_elementStack",
"=",
"newStack",
";",
"// State has changed, check",
"checkInvariants",
"(",
")",
";",
"}"
] |
Sets the capacity for the stack of open elements. The new capacity must
at least allow the stack to contain the current open elements.
@param newCapacity the new capacity, >= {@link #getElementStackSize()}.
@throws IllegalArgumentException if <code>newCapacity < {@link #getElementStackSize()}</code>.
@throws OutOfMemoryError if a new array cannot be allocated; this object will still be usable,
but the capacity will remain unchanged.
|
[
"Sets",
"the",
"capacity",
"for",
"the",
"stack",
"of",
"open",
"elements",
".",
"The",
"new",
"capacity",
"must",
"at",
"least",
"allow",
"the",
"stack",
"to",
"contain",
"the",
"current",
"open",
"elements",
"."
] |
6ff483777d9467db9990b7c7ae0158f21a243c31
|
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLOutputter.java#L493-L513
|
149,037
|
znerd/xmlenc
|
src/main/java/org/znerd/xmlenc/XMLOutputter.java
|
XMLOutputter.startTag
|
@Override
public final void startTag(String type) throws IllegalStateException, IllegalArgumentException, IOException {
// Check state
if (_state != XMLEventListenerStates.BEFORE_XML_DECLARATION && _state != XMLEventListenerStates.BEFORE_DTD_DECLARATION && _state != XMLEventListenerStates.BEFORE_ROOT_ELEMENT && _state != XMLEventListenerStates.START_TAG_OPEN && _state != XMLEventListenerStates.WITHIN_ELEMENT) {
throw new IllegalStateException("getState() == " + _state);
// Check arguments
} else if (type == null) {
throw new IllegalArgumentException("type == null");
}
// Temporarily set the state to ERROR_STATE. Unless an exception is
// thrown in the write methods, it will be reset to a valid state.
XMLEventListenerState oldState = _state;
_state = XMLEventListenerStates.ERROR_STATE;
// Increase the stack size if necessary
if (_elementStackSize == _elementStack.length) {
String[] newStack;
try {
newStack = new String[(_elementStackSize + 1) * 2];
} catch (OutOfMemoryError error) {
newStack = new String[_elementStackSize + 1];
}
System.arraycopy(_elementStack, 0, newStack, 0, _elementStackSize);
_elementStack = newStack;
}
// Store the element type name on the stack
_elementStack[_elementStackSize] = type;
_elementStackSize++;
// Close start tag if necessary
if (oldState == XMLEventListenerStates.START_TAG_OPEN) {
_out.write('>');
}
// Write line break and indentation, except if this is first output
if (oldState != XMLEventListenerStates.BEFORE_XML_DECLARATION) {
_out.write(_lineBreakChars);
writeIndentation();
}
_out.write('<');
// Escape the element name, if necessary
_out.write(type);
// Change the state
_state = XMLEventListenerStates.START_TAG_OPEN;
// State has changed, check
checkInvariants();
}
|
java
|
@Override
public final void startTag(String type) throws IllegalStateException, IllegalArgumentException, IOException {
// Check state
if (_state != XMLEventListenerStates.BEFORE_XML_DECLARATION && _state != XMLEventListenerStates.BEFORE_DTD_DECLARATION && _state != XMLEventListenerStates.BEFORE_ROOT_ELEMENT && _state != XMLEventListenerStates.START_TAG_OPEN && _state != XMLEventListenerStates.WITHIN_ELEMENT) {
throw new IllegalStateException("getState() == " + _state);
// Check arguments
} else if (type == null) {
throw new IllegalArgumentException("type == null");
}
// Temporarily set the state to ERROR_STATE. Unless an exception is
// thrown in the write methods, it will be reset to a valid state.
XMLEventListenerState oldState = _state;
_state = XMLEventListenerStates.ERROR_STATE;
// Increase the stack size if necessary
if (_elementStackSize == _elementStack.length) {
String[] newStack;
try {
newStack = new String[(_elementStackSize + 1) * 2];
} catch (OutOfMemoryError error) {
newStack = new String[_elementStackSize + 1];
}
System.arraycopy(_elementStack, 0, newStack, 0, _elementStackSize);
_elementStack = newStack;
}
// Store the element type name on the stack
_elementStack[_elementStackSize] = type;
_elementStackSize++;
// Close start tag if necessary
if (oldState == XMLEventListenerStates.START_TAG_OPEN) {
_out.write('>');
}
// Write line break and indentation, except if this is first output
if (oldState != XMLEventListenerStates.BEFORE_XML_DECLARATION) {
_out.write(_lineBreakChars);
writeIndentation();
}
_out.write('<');
// Escape the element name, if necessary
_out.write(type);
// Change the state
_state = XMLEventListenerStates.START_TAG_OPEN;
// State has changed, check
checkInvariants();
}
|
[
"@",
"Override",
"public",
"final",
"void",
"startTag",
"(",
"String",
"type",
")",
"throws",
"IllegalStateException",
",",
"IllegalArgumentException",
",",
"IOException",
"{",
"// Check state",
"if",
"(",
"_state",
"!=",
"XMLEventListenerStates",
".",
"BEFORE_XML_DECLARATION",
"&&",
"_state",
"!=",
"XMLEventListenerStates",
".",
"BEFORE_DTD_DECLARATION",
"&&",
"_state",
"!=",
"XMLEventListenerStates",
".",
"BEFORE_ROOT_ELEMENT",
"&&",
"_state",
"!=",
"XMLEventListenerStates",
".",
"START_TAG_OPEN",
"&&",
"_state",
"!=",
"XMLEventListenerStates",
".",
"WITHIN_ELEMENT",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"getState() == \"",
"+",
"_state",
")",
";",
"// Check arguments",
"}",
"else",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"type == null\"",
")",
";",
"}",
"// Temporarily set the state to ERROR_STATE. Unless an exception is",
"// thrown in the write methods, it will be reset to a valid state.",
"XMLEventListenerState",
"oldState",
"=",
"_state",
";",
"_state",
"=",
"XMLEventListenerStates",
".",
"ERROR_STATE",
";",
"// Increase the stack size if necessary",
"if",
"(",
"_elementStackSize",
"==",
"_elementStack",
".",
"length",
")",
"{",
"String",
"[",
"]",
"newStack",
";",
"try",
"{",
"newStack",
"=",
"new",
"String",
"[",
"(",
"_elementStackSize",
"+",
"1",
")",
"*",
"2",
"]",
";",
"}",
"catch",
"(",
"OutOfMemoryError",
"error",
")",
"{",
"newStack",
"=",
"new",
"String",
"[",
"_elementStackSize",
"+",
"1",
"]",
";",
"}",
"System",
".",
"arraycopy",
"(",
"_elementStack",
",",
"0",
",",
"newStack",
",",
"0",
",",
"_elementStackSize",
")",
";",
"_elementStack",
"=",
"newStack",
";",
"}",
"// Store the element type name on the stack",
"_elementStack",
"[",
"_elementStackSize",
"]",
"=",
"type",
";",
"_elementStackSize",
"++",
";",
"// Close start tag if necessary",
"if",
"(",
"oldState",
"==",
"XMLEventListenerStates",
".",
"START_TAG_OPEN",
")",
"{",
"_out",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"// Write line break and indentation, except if this is first output",
"if",
"(",
"oldState",
"!=",
"XMLEventListenerStates",
".",
"BEFORE_XML_DECLARATION",
")",
"{",
"_out",
".",
"write",
"(",
"_lineBreakChars",
")",
";",
"writeIndentation",
"(",
")",
";",
"}",
"_out",
".",
"write",
"(",
"'",
"'",
")",
";",
"// Escape the element name, if necessary",
"_out",
".",
"write",
"(",
"type",
")",
";",
"// Change the state",
"_state",
"=",
"XMLEventListenerStates",
".",
"START_TAG_OPEN",
";",
"// State has changed, check",
"checkInvariants",
"(",
")",
";",
"}"
] |
Writes an element start tag. The element type name will be stored in the
internal element stack. If necessary, the capacity of this stack will be
extended.
@param type the type of the tag to start, not <code>null</code>.
@throws IllegalStateException if <code>getState() != {@link #BEFORE_XML_DECLARATION} &&
getState() != {@link #BEFORE_DTD_DECLARATION} &&
getState() != {@link #BEFORE_ROOT_ELEMENT} &&
getState() != {@link #START_TAG_OPEN} &&
getState() != {@link #WITHIN_ELEMENT}</code>.
@throws IllegalArgumentException if <code>type == null</code>.
@throws IOException if an I/O error occurs; this will set the state to {@link #ERROR_STATE}.
|
[
"Writes",
"an",
"element",
"start",
"tag",
".",
"The",
"element",
"type",
"name",
"will",
"be",
"stored",
"in",
"the",
"internal",
"element",
"stack",
".",
"If",
"necessary",
"the",
"capacity",
"of",
"this",
"stack",
"will",
"be",
"extended",
"."
] |
6ff483777d9467db9990b7c7ae0158f21a243c31
|
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLOutputter.java#L794-L848
|
149,038
|
znerd/xmlenc
|
src/main/java/org/znerd/xmlenc/XMLOutputter.java
|
XMLOutputter.pcdata
|
@Override
public final void pcdata(char[] ch, int start, int length) throws IllegalStateException, IllegalArgumentException, IndexOutOfBoundsException, InvalidXMLException, IOException {
// Check state
if (_state != XMLEventListenerStates.START_TAG_OPEN && _state != XMLEventListenerStates.WITHIN_ELEMENT) {
throw new IllegalStateException("getState() == " + _state);
// Check arguments
} else if (ch == null) {
throw new IllegalArgumentException("ch == null");
} else if (start < 0) {
throw new IllegalArgumentException("start (" + start + ") < 0");
} else if (start >= ch.length) {
throw new IllegalArgumentException("start (" + start + ") >= ch.length (" + ch.length + ')');
} else if (length < 0) {
throw new IllegalArgumentException("length < 0");
}
// Temporarily set the state to ERROR_STATE. Unless an exception is
// thrown in the write methods, it will be reset to a valid state.
XMLEventListenerState oldState = _state;
_state = XMLEventListenerStates.ERROR_STATE;
// Write output
if (oldState == XMLEventListenerStates.START_TAG_OPEN) {
closeStartTag();
}
_encoder.text(_out, ch, start, length, _escapeAmpersands);
// Change the state
_state = XMLEventListenerStates.WITHIN_ELEMENT;
// State has changed, check
checkInvariants();
}
|
java
|
@Override
public final void pcdata(char[] ch, int start, int length) throws IllegalStateException, IllegalArgumentException, IndexOutOfBoundsException, InvalidXMLException, IOException {
// Check state
if (_state != XMLEventListenerStates.START_TAG_OPEN && _state != XMLEventListenerStates.WITHIN_ELEMENT) {
throw new IllegalStateException("getState() == " + _state);
// Check arguments
} else if (ch == null) {
throw new IllegalArgumentException("ch == null");
} else if (start < 0) {
throw new IllegalArgumentException("start (" + start + ") < 0");
} else if (start >= ch.length) {
throw new IllegalArgumentException("start (" + start + ") >= ch.length (" + ch.length + ')');
} else if (length < 0) {
throw new IllegalArgumentException("length < 0");
}
// Temporarily set the state to ERROR_STATE. Unless an exception is
// thrown in the write methods, it will be reset to a valid state.
XMLEventListenerState oldState = _state;
_state = XMLEventListenerStates.ERROR_STATE;
// Write output
if (oldState == XMLEventListenerStates.START_TAG_OPEN) {
closeStartTag();
}
_encoder.text(_out, ch, start, length, _escapeAmpersands);
// Change the state
_state = XMLEventListenerStates.WITHIN_ELEMENT;
// State has changed, check
checkInvariants();
}
|
[
"@",
"Override",
"public",
"final",
"void",
"pcdata",
"(",
"char",
"[",
"]",
"ch",
",",
"int",
"start",
",",
"int",
"length",
")",
"throws",
"IllegalStateException",
",",
"IllegalArgumentException",
",",
"IndexOutOfBoundsException",
",",
"InvalidXMLException",
",",
"IOException",
"{",
"// Check state",
"if",
"(",
"_state",
"!=",
"XMLEventListenerStates",
".",
"START_TAG_OPEN",
"&&",
"_state",
"!=",
"XMLEventListenerStates",
".",
"WITHIN_ELEMENT",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"getState() == \"",
"+",
"_state",
")",
";",
"// Check arguments",
"}",
"else",
"if",
"(",
"ch",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ch == null\"",
")",
";",
"}",
"else",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"start (\"",
"+",
"start",
"+",
"\") < 0\"",
")",
";",
"}",
"else",
"if",
"(",
"start",
">=",
"ch",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"start (\"",
"+",
"start",
"+",
"\") >= ch.length (\"",
"+",
"ch",
".",
"length",
"+",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"length < 0\"",
")",
";",
"}",
"// Temporarily set the state to ERROR_STATE. Unless an exception is",
"// thrown in the write methods, it will be reset to a valid state.",
"XMLEventListenerState",
"oldState",
"=",
"_state",
";",
"_state",
"=",
"XMLEventListenerStates",
".",
"ERROR_STATE",
";",
"// Write output",
"if",
"(",
"oldState",
"==",
"XMLEventListenerStates",
".",
"START_TAG_OPEN",
")",
"{",
"closeStartTag",
"(",
")",
";",
"}",
"_encoder",
".",
"text",
"(",
"_out",
",",
"ch",
",",
"start",
",",
"length",
",",
"_escapeAmpersands",
")",
";",
"// Change the state",
"_state",
"=",
"XMLEventListenerStates",
".",
"WITHIN_ELEMENT",
";",
"// State has changed, check",
"checkInvariants",
"(",
")",
";",
"}"
] |
Writes the specified character array as PCDATA.
@param ch the character array containing the text to be written, not <code>null</code>.
@param start the start index in the array, must be >= 0 and it must be <
<code>ch.length</code>.
@param length the number of characters to read from the array, must be > 0.
@throws IllegalStateException if <code>getState() != {@link #START_TAG_OPEN} &&
getState() != {@link #WITHIN_ELEMENT}</code>
@throws IllegalArgumentException if <code>ch == null
|| start < 0
|| start >= ch.length
|| length < 0</code>.
@throws IndexOutOfBoundsException if <code>start + length > ch.length</code>.
@throws InvalidXMLException if the specified text contains an invalid character.
@throws IOException if an I/O error occurs; this will set the state to {@link #ERROR_STATE}.
|
[
"Writes",
"the",
"specified",
"character",
"array",
"as",
"PCDATA",
"."
] |
6ff483777d9467db9990b7c7ae0158f21a243c31
|
https://github.com/znerd/xmlenc/blob/6ff483777d9467db9990b7c7ae0158f21a243c31/src/main/java/org/znerd/xmlenc/XMLOutputter.java#L1219-L1253
|
149,039
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/finder/DefaultPropertyEditorFinder.java
|
DefaultPropertyEditorFinder.setEditorSearchPackages
|
public void setEditorSearchPackages(String[] packages) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
this.packages = packages.clone();
}
|
java
|
public void setEditorSearchPackages(String[] packages) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
this.packages = packages.clone();
}
|
[
"public",
"void",
"setEditorSearchPackages",
"(",
"String",
"[",
"]",
"packages",
")",
"{",
"SecurityManager",
"sm",
"=",
"System",
".",
"getSecurityManager",
"(",
")",
";",
"if",
"(",
"sm",
"!=",
"null",
")",
"{",
"sm",
".",
"checkPropertiesAccess",
"(",
")",
";",
"}",
"this",
".",
"packages",
"=",
"packages",
".",
"clone",
"(",
")",
";",
"}"
] |
Sets packages in which editors should be looked up.
@param packages
|
[
"Sets",
"packages",
"in",
"which",
"editors",
"should",
"be",
"looked",
"up",
"."
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/finder/DefaultPropertyEditorFinder.java#L114-L120
|
149,040
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/ScaleDetect.java
|
ScaleDetect.newtonSolve
|
private static double[] newtonSolve(Function<double[], double[]> function, double[] initial, double tolerance) {
RealVector dx = new ArrayRealVector(initial.length);
dx.set(tolerance + 1);
int iterations = 0;
int d = initial.length;
double[] values = Arrays.copyOf(initial, initial.length);
while (dx.getNorm() > tolerance) {
double[] fx = function.apply(values);
Array2DRowRealMatrix df = new Array2DRowRealMatrix(fx.length, d);
ArrayRealVector fxVector = new ArrayRealVector(fx);
for (int i = 0; i < d; i++) {
double originalValue = values[i];
values[i] += H;
double[] fxi = function.apply(values);
values[i] = originalValue;
ArrayRealVector fxiVector = new ArrayRealVector(fxi);
RealVector result = fxiVector.subtract(fxVector);
result = result.mapDivide(H);
df.setColumn(i, result.toArray());
}
dx = new RRQRDecomposition(df).getSolver().solve(fxVector.mapMultiply(-1));
// df has size = initial, and fx has size equal to whatever that function produces.
for (int i = 0; i < values.length; i++) {
values[i] += dx.getEntry(i);
}
iterations++;
if (iterations % 100 == 0) {
tolerance *= 10;
}
}
return values;
}
|
java
|
private static double[] newtonSolve(Function<double[], double[]> function, double[] initial, double tolerance) {
RealVector dx = new ArrayRealVector(initial.length);
dx.set(tolerance + 1);
int iterations = 0;
int d = initial.length;
double[] values = Arrays.copyOf(initial, initial.length);
while (dx.getNorm() > tolerance) {
double[] fx = function.apply(values);
Array2DRowRealMatrix df = new Array2DRowRealMatrix(fx.length, d);
ArrayRealVector fxVector = new ArrayRealVector(fx);
for (int i = 0; i < d; i++) {
double originalValue = values[i];
values[i] += H;
double[] fxi = function.apply(values);
values[i] = originalValue;
ArrayRealVector fxiVector = new ArrayRealVector(fxi);
RealVector result = fxiVector.subtract(fxVector);
result = result.mapDivide(H);
df.setColumn(i, result.toArray());
}
dx = new RRQRDecomposition(df).getSolver().solve(fxVector.mapMultiply(-1));
// df has size = initial, and fx has size equal to whatever that function produces.
for (int i = 0; i < values.length; i++) {
values[i] += dx.getEntry(i);
}
iterations++;
if (iterations % 100 == 0) {
tolerance *= 10;
}
}
return values;
}
|
[
"private",
"static",
"double",
"[",
"]",
"newtonSolve",
"(",
"Function",
"<",
"double",
"[",
"]",
",",
"double",
"[",
"]",
">",
"function",
",",
"double",
"[",
"]",
"initial",
",",
"double",
"tolerance",
")",
"{",
"RealVector",
"dx",
"=",
"new",
"ArrayRealVector",
"(",
"initial",
".",
"length",
")",
";",
"dx",
".",
"set",
"(",
"tolerance",
"+",
"1",
")",
";",
"int",
"iterations",
"=",
"0",
";",
"int",
"d",
"=",
"initial",
".",
"length",
";",
"double",
"[",
"]",
"values",
"=",
"Arrays",
".",
"copyOf",
"(",
"initial",
",",
"initial",
".",
"length",
")",
";",
"while",
"(",
"dx",
".",
"getNorm",
"(",
")",
">",
"tolerance",
")",
"{",
"double",
"[",
"]",
"fx",
"=",
"function",
".",
"apply",
"(",
"values",
")",
";",
"Array2DRowRealMatrix",
"df",
"=",
"new",
"Array2DRowRealMatrix",
"(",
"fx",
".",
"length",
",",
"d",
")",
";",
"ArrayRealVector",
"fxVector",
"=",
"new",
"ArrayRealVector",
"(",
"fx",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"d",
";",
"i",
"++",
")",
"{",
"double",
"originalValue",
"=",
"values",
"[",
"i",
"]",
";",
"values",
"[",
"i",
"]",
"+=",
"H",
";",
"double",
"[",
"]",
"fxi",
"=",
"function",
".",
"apply",
"(",
"values",
")",
";",
"values",
"[",
"i",
"]",
"=",
"originalValue",
";",
"ArrayRealVector",
"fxiVector",
"=",
"new",
"ArrayRealVector",
"(",
"fxi",
")",
";",
"RealVector",
"result",
"=",
"fxiVector",
".",
"subtract",
"(",
"fxVector",
")",
";",
"result",
"=",
"result",
".",
"mapDivide",
"(",
"H",
")",
";",
"df",
".",
"setColumn",
"(",
"i",
",",
"result",
".",
"toArray",
"(",
")",
")",
";",
"}",
"dx",
"=",
"new",
"RRQRDecomposition",
"(",
"df",
")",
".",
"getSolver",
"(",
")",
".",
"solve",
"(",
"fxVector",
".",
"mapMultiply",
"(",
"-",
"1",
")",
")",
";",
"// df has size = initial, and fx has size equal to whatever that function produces.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
"[",
"i",
"]",
"+=",
"dx",
".",
"getEntry",
"(",
"i",
")",
";",
"}",
"iterations",
"++",
";",
"if",
"(",
"iterations",
"%",
"100",
"==",
"0",
")",
"{",
"tolerance",
"*=",
"10",
";",
"}",
"}",
"return",
"values",
";",
"}"
] |
Finding the best fit using least-squares method for an equation system
@param function Equation system to find fit for. Input: Parameters, Output: Residuals.
@param initial Initial 'guess' for function parameters
@param tolerance How much the function parameters may change before a solution is accepted
@return The parameters to the function that causes the least residuals
|
[
"Finding",
"the",
"best",
"fit",
"using",
"least",
"-",
"squares",
"method",
"for",
"an",
"equation",
"system"
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/ScaleDetect.java#L32-L64
|
149,041
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/ScaleDetect.java
|
ScaleDetect.detect
|
public static MathEquation detect(UScale scale) {
return Arrays.stream(rank(scale))
.filter(eq -> eq.isValid())
.findFirst()
.orElse(fit(scale, Models.CONSTANT)); // if no valid is found, it is because of constant data
}
|
java
|
public static MathEquation detect(UScale scale) {
return Arrays.stream(rank(scale))
.filter(eq -> eq.isValid())
.findFirst()
.orElse(fit(scale, Models.CONSTANT)); // if no valid is found, it is because of constant data
}
|
[
"public",
"static",
"MathEquation",
"detect",
"(",
"UScale",
"scale",
")",
"{",
"return",
"Arrays",
".",
"stream",
"(",
"rank",
"(",
"scale",
")",
")",
".",
"filter",
"(",
"eq",
"->",
"eq",
".",
"isValid",
"(",
")",
")",
".",
"findFirst",
"(",
")",
".",
"orElse",
"(",
"fit",
"(",
"scale",
",",
"Models",
".",
"CONSTANT",
")",
")",
";",
"// if no valid is found, it is because of constant data",
"}"
] |
From the results of a UScale run, calculate the best-fit scaling equation
@param scale the results to analyze
@return the best-fit scaling equation.
|
[
"From",
"the",
"results",
"of",
"a",
"UScale",
"run",
"calculate",
"the",
"best",
"-",
"fit",
"scaling",
"equation"
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/ScaleDetect.java#L71-L76
|
149,042
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/ScaleDetect.java
|
ScaleDetect.rank
|
public static MathEquation[] rank(UScale scale) {
double[] x = extractX(scale);
double[] y = extractY(scale);
return rank(x, y);
}
|
java
|
public static MathEquation[] rank(UScale scale) {
double[] x = extractX(scale);
double[] y = extractY(scale);
return rank(x, y);
}
|
[
"public",
"static",
"MathEquation",
"[",
"]",
"rank",
"(",
"UScale",
"scale",
")",
"{",
"double",
"[",
"]",
"x",
"=",
"extractX",
"(",
"scale",
")",
";",
"double",
"[",
"]",
"y",
"=",
"extractY",
"(",
"scale",
")",
";",
"return",
"rank",
"(",
"x",
",",
"y",
")",
";",
"}"
] |
From the scaling results calculate a number of scaling equations, and return their equations in descending order of relevance
@param scale the Scale results to rank
@return the possible equations in best-fit-first order.
|
[
"From",
"the",
"scaling",
"results",
"calculate",
"a",
"number",
"of",
"scaling",
"equations",
"and",
"return",
"their",
"equations",
"in",
"descending",
"order",
"of",
"relevance"
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/ScaleDetect.java#L95-L99
|
149,043
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/DateEditor.java
|
DateEditor.initialize
|
public static void initialize() {
PrivilegedAction action = new PrivilegedAction() {
public Object run() {
String defaultFormat = System.getProperty("org.jboss.common.beans.property.DateEditor.format", "MMM d, yyyy");
String defaultLocale = System.getProperty("org.jboss.common.beans.property.DateEditor.locale");
DateFormat defaultDateFormat;
if (defaultLocale == null || defaultLocale.length() == 0) {
defaultDateFormat = new SimpleDateFormat(defaultFormat);
} else {
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(defaultLocale);
Locale locale = (Locale) localeEditor.getValue();
defaultDateFormat = new SimpleDateFormat(defaultFormat, locale);
}
formats = new DateFormat[] { defaultDateFormat,
// Tue Jan 04 00:00:00 PST 2005
new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"),
// Wed, 4 Jul 2001 12:08:56 -0700
new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z") };
return null;
}
};
AccessController.doPrivileged(action);
}
|
java
|
public static void initialize() {
PrivilegedAction action = new PrivilegedAction() {
public Object run() {
String defaultFormat = System.getProperty("org.jboss.common.beans.property.DateEditor.format", "MMM d, yyyy");
String defaultLocale = System.getProperty("org.jboss.common.beans.property.DateEditor.locale");
DateFormat defaultDateFormat;
if (defaultLocale == null || defaultLocale.length() == 0) {
defaultDateFormat = new SimpleDateFormat(defaultFormat);
} else {
LocaleEditor localeEditor = new LocaleEditor();
localeEditor.setAsText(defaultLocale);
Locale locale = (Locale) localeEditor.getValue();
defaultDateFormat = new SimpleDateFormat(defaultFormat, locale);
}
formats = new DateFormat[] { defaultDateFormat,
// Tue Jan 04 00:00:00 PST 2005
new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy"),
// Wed, 4 Jul 2001 12:08:56 -0700
new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z") };
return null;
}
};
AccessController.doPrivileged(action);
}
|
[
"public",
"static",
"void",
"initialize",
"(",
")",
"{",
"PrivilegedAction",
"action",
"=",
"new",
"PrivilegedAction",
"(",
")",
"{",
"public",
"Object",
"run",
"(",
")",
"{",
"String",
"defaultFormat",
"=",
"System",
".",
"getProperty",
"(",
"\"org.jboss.common.beans.property.DateEditor.format\"",
",",
"\"MMM d, yyyy\"",
")",
";",
"String",
"defaultLocale",
"=",
"System",
".",
"getProperty",
"(",
"\"org.jboss.common.beans.property.DateEditor.locale\"",
")",
";",
"DateFormat",
"defaultDateFormat",
";",
"if",
"(",
"defaultLocale",
"==",
"null",
"||",
"defaultLocale",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"defaultDateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"defaultFormat",
")",
";",
"}",
"else",
"{",
"LocaleEditor",
"localeEditor",
"=",
"new",
"LocaleEditor",
"(",
")",
";",
"localeEditor",
".",
"setAsText",
"(",
"defaultLocale",
")",
";",
"Locale",
"locale",
"=",
"(",
"Locale",
")",
"localeEditor",
".",
"getValue",
"(",
")",
";",
"defaultDateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"defaultFormat",
",",
"locale",
")",
";",
"}",
"formats",
"=",
"new",
"DateFormat",
"[",
"]",
"{",
"defaultDateFormat",
",",
"// Tue Jan 04 00:00:00 PST 2005",
"new",
"SimpleDateFormat",
"(",
"\"EEE MMM d HH:mm:ss z yyyy\"",
")",
",",
"// Wed, 4 Jul 2001 12:08:56 -0700",
"new",
"SimpleDateFormat",
"(",
"\"EEE, d MMM yyyy HH:mm:ss Z\"",
")",
"}",
";",
"return",
"null",
";",
"}",
"}",
";",
"AccessController",
".",
"doPrivileged",
"(",
"action",
")",
";",
"}"
] |
Setup the parsing formats. Offered as a separate static method to allow testing of locale changes, since SimpleDateFormat
will use the default locale upon construction. Should not be normally used!
|
[
"Setup",
"the",
"parsing",
"formats",
".",
"Offered",
"as",
"a",
"separate",
"static",
"method",
"to",
"allow",
"testing",
"of",
"locale",
"changes",
"since",
"SimpleDateFormat",
"will",
"use",
"the",
"default",
"locale",
"upon",
"construction",
".",
"Should",
"not",
"be",
"normally",
"used!"
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/DateEditor.java#L60-L84
|
149,044
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/DateEditor.java
|
DateEditor.setValue
|
@Override
public void setValue(Object value) {
if (value instanceof Date || value == null) {
this.text = null;
super.setValue(value);
} else {
throw new IllegalArgumentException("setValue() expected java.util.Date value, got " + value.getClass().getName());
}
}
|
java
|
@Override
public void setValue(Object value) {
if (value instanceof Date || value == null) {
this.text = null;
super.setValue(value);
} else {
throw new IllegalArgumentException("setValue() expected java.util.Date value, got " + value.getClass().getName());
}
}
|
[
"@",
"Override",
"public",
"void",
"setValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Date",
"||",
"value",
"==",
"null",
")",
"{",
"this",
".",
"text",
"=",
"null",
";",
"super",
".",
"setValue",
"(",
"value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"setValue() expected java.util.Date value, got \"",
"+",
"value",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Sets directly the java.util.Date value
@param value a java.util.Date
|
[
"Sets",
"directly",
"the",
"java",
".",
"util",
".",
"Date",
"value"
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/DateEditor.java#L94-L102
|
149,045
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/ElementEditor.java
|
ElementEditor.setAsText
|
@Override
public void setAsText(String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
setValue(getAsDocument(text).getDocumentElement());
}
|
java
|
@Override
public void setAsText(String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
setValue(getAsDocument(text).getDocumentElement());
}
|
[
"@",
"Override",
"public",
"void",
"setAsText",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"BeanUtils",
".",
"isNull",
"(",
"text",
")",
")",
"{",
"setValue",
"(",
"null",
")",
";",
"return",
";",
"}",
"setValue",
"(",
"getAsDocument",
"(",
"text",
")",
".",
"getDocumentElement",
"(",
")",
")",
";",
"}"
] |
Sets as an Document created from a String.
@throws IllegalArgumentException A parse exception occured
|
[
"Sets",
"as",
"an",
"Document",
"created",
"from",
"a",
"String",
"."
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/ElementEditor.java#L42-L49
|
149,046
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/dnssec/DNSSECResolver.java
|
DNSSECResolver.useBackupDnsServer
|
public void useBackupDnsServer(int index) {
this.selectedDnsServer = backupDnsServers.get(index);
try {
this.simpleResolver = new SimpleResolver(this.selectedDnsServer);
} catch (UnknownHostException ignore) {
}
this.validatingResolver = new ValidatingResolver(this.simpleResolver);
}
|
java
|
public void useBackupDnsServer(int index) {
this.selectedDnsServer = backupDnsServers.get(index);
try {
this.simpleResolver = new SimpleResolver(this.selectedDnsServer);
} catch (UnknownHostException ignore) {
}
this.validatingResolver = new ValidatingResolver(this.simpleResolver);
}
|
[
"public",
"void",
"useBackupDnsServer",
"(",
"int",
"index",
")",
"{",
"this",
".",
"selectedDnsServer",
"=",
"backupDnsServers",
".",
"get",
"(",
"index",
")",
";",
"try",
"{",
"this",
".",
"simpleResolver",
"=",
"new",
"SimpleResolver",
"(",
"this",
".",
"selectedDnsServer",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"ignore",
")",
"{",
"}",
"this",
".",
"validatingResolver",
"=",
"new",
"ValidatingResolver",
"(",
"this",
".",
"simpleResolver",
")",
";",
"}"
] |
Use Backup DNS Server identified by index
@param index of backup DNS server
|
[
"Use",
"Backup",
"DNS",
"Server",
"identified",
"by",
"index"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/dnssec/DNSSECResolver.java#L89-L97
|
149,047
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.callMethod
|
public Value callMethod(ExecutionContext context, Map<String, Value> params) {
validateParameters(params);
fillDefaultValues(params);
return internalCallMethod(context, params);
}
|
java
|
public Value callMethod(ExecutionContext context, Map<String, Value> params) {
validateParameters(params);
fillDefaultValues(params);
return internalCallMethod(context, params);
}
|
[
"public",
"Value",
"callMethod",
"(",
"ExecutionContext",
"context",
",",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
")",
"{",
"validateParameters",
"(",
"params",
")",
";",
"fillDefaultValues",
"(",
"params",
")",
";",
"return",
"internalCallMethod",
"(",
"context",
",",
"params",
")",
";",
"}"
] |
Executes the method call.
@param context The execution context
@param params The parameters to run the method
@return The return value from the method call
|
[
"Executes",
"the",
"method",
"call",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L77-L81
|
149,048
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.validateParameters
|
protected void validateParameters(Map<String, Value> callParameters) {
for (String name : callParameters.keySet()) {
if (!parameters.containsKey(name)) throw new IllegalParametersException("Parameter not supported: " + name);
}
for (Map.Entry<String, MethodParameter> entry : parameters.entrySet()) {
if (entry.getValue().isOptional()) continue;
if (!callParameters.containsKey(entry.getKey())) {
throw new IllegalParametersException("Parameter not supplied: " + entry.getKey());
}
}
}
|
java
|
protected void validateParameters(Map<String, Value> callParameters) {
for (String name : callParameters.keySet()) {
if (!parameters.containsKey(name)) throw new IllegalParametersException("Parameter not supported: " + name);
}
for (Map.Entry<String, MethodParameter> entry : parameters.entrySet()) {
if (entry.getValue().isOptional()) continue;
if (!callParameters.containsKey(entry.getKey())) {
throw new IllegalParametersException("Parameter not supplied: " + entry.getKey());
}
}
}
|
[
"protected",
"void",
"validateParameters",
"(",
"Map",
"<",
"String",
",",
"Value",
">",
"callParameters",
")",
"{",
"for",
"(",
"String",
"name",
":",
"callParameters",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"parameters",
".",
"containsKey",
"(",
"name",
")",
")",
"throw",
"new",
"IllegalParametersException",
"(",
"\"Parameter not supported: \"",
"+",
"name",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"MethodParameter",
">",
"entry",
":",
"parameters",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"isOptional",
"(",
")",
")",
"continue",
";",
"if",
"(",
"!",
"callParameters",
".",
"containsKey",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalParametersException",
"(",
"\"Parameter not supplied: \"",
"+",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Validates the parameters.
@param callParameters The runtime (call) params
|
[
"Validates",
"the",
"parameters",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L103-L113
|
149,049
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.fillDefaultValues
|
protected void fillDefaultValues(Map<String, Value> params) {
for (MethodParameter parameter : parameters.values()) {
if (!parameter.isOptional() || parameter.getDefaultValue() == null || params.get(parameter.getName()) != null) continue;
params.put(parameter.getName(), parameter.getDefaultValue());
}
}
|
java
|
protected void fillDefaultValues(Map<String, Value> params) {
for (MethodParameter parameter : parameters.values()) {
if (!parameter.isOptional() || parameter.getDefaultValue() == null || params.get(parameter.getName()) != null) continue;
params.put(parameter.getName(), parameter.getDefaultValue());
}
}
|
[
"protected",
"void",
"fillDefaultValues",
"(",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
")",
"{",
"for",
"(",
"MethodParameter",
"parameter",
":",
"parameters",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"parameter",
".",
"isOptional",
"(",
")",
"||",
"parameter",
".",
"getDefaultValue",
"(",
")",
"==",
"null",
"||",
"params",
".",
"get",
"(",
"parameter",
".",
"getName",
"(",
")",
")",
"!=",
"null",
")",
"continue",
";",
"params",
".",
"put",
"(",
"parameter",
".",
"getName",
"(",
")",
",",
"parameter",
".",
"getDefaultValue",
"(",
")",
")",
";",
"}",
"}"
] |
Fills in the default values.
@param params The parameters
|
[
"Fills",
"in",
"the",
"default",
"values",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L120-L125
|
149,050
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.asString
|
protected String asString(String name, Map<String, Value> params, ExecutionContext context) {
return coerceToString(params.get(name), context);
}
|
java
|
protected String asString(String name, Map<String, Value> params, ExecutionContext context) {
return coerceToString(params.get(name), context);
}
|
[
"protected",
"String",
"asString",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Value",
">",
"params",
",",
"ExecutionContext",
"context",
")",
"{",
"return",
"coerceToString",
"(",
"params",
".",
"get",
"(",
"name",
")",
",",
"context",
")",
";",
"}"
] |
Gets a parameter value as a Java String.
@param name The parameter name
@param params The parameters
@param context The EC
@return The String
|
[
"Gets",
"a",
"parameter",
"value",
"as",
"a",
"Java",
"String",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L163-L165
|
149,051
|
vtatai/srec
|
core/src/main/java/com/github/srec/command/method/MethodCommand.java
|
MethodCommand.params
|
protected static MethodParameter[] params(Object... params) {
if (params.length == 0) return null;
if (params.length != 1 && params.length % 2 != 0) throw new IllegalParametersException("Incorrect number of params");
if (params.length == 1) {
MethodParameter[] ret = new MethodParameter[1];
ret[0] = new MethodParameter(params[0].toString(), Type.STRING);
return ret;
}
MethodParameter[] ret = new MethodParameter[params.length / 2];
for (int i = 0; i < ret.length; i++) {
String name = (String) params[i * 2];
Type type = (Type) params[i * 2 + 1];
ret[i] = new MethodParameter(name, type);
}
return ret;
}
|
java
|
protected static MethodParameter[] params(Object... params) {
if (params.length == 0) return null;
if (params.length != 1 && params.length % 2 != 0) throw new IllegalParametersException("Incorrect number of params");
if (params.length == 1) {
MethodParameter[] ret = new MethodParameter[1];
ret[0] = new MethodParameter(params[0].toString(), Type.STRING);
return ret;
}
MethodParameter[] ret = new MethodParameter[params.length / 2];
for (int i = 0; i < ret.length; i++) {
String name = (String) params[i * 2];
Type type = (Type) params[i * 2 + 1];
ret[i] = new MethodParameter(name, type);
}
return ret;
}
|
[
"protected",
"static",
"MethodParameter",
"[",
"]",
"params",
"(",
"Object",
"...",
"params",
")",
"{",
"if",
"(",
"params",
".",
"length",
"==",
"0",
")",
"return",
"null",
";",
"if",
"(",
"params",
".",
"length",
"!=",
"1",
"&&",
"params",
".",
"length",
"%",
"2",
"!=",
"0",
")",
"throw",
"new",
"IllegalParametersException",
"(",
"\"Incorrect number of params\"",
")",
";",
"if",
"(",
"params",
".",
"length",
"==",
"1",
")",
"{",
"MethodParameter",
"[",
"]",
"ret",
"=",
"new",
"MethodParameter",
"[",
"1",
"]",
";",
"ret",
"[",
"0",
"]",
"=",
"new",
"MethodParameter",
"(",
"params",
"[",
"0",
"]",
".",
"toString",
"(",
")",
",",
"Type",
".",
"STRING",
")",
";",
"return",
"ret",
";",
"}",
"MethodParameter",
"[",
"]",
"ret",
"=",
"new",
"MethodParameter",
"[",
"params",
".",
"length",
"/",
"2",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ret",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"name",
"=",
"(",
"String",
")",
"params",
"[",
"i",
"*",
"2",
"]",
";",
"Type",
"type",
"=",
"(",
"Type",
")",
"params",
"[",
"i",
"*",
"2",
"+",
"1",
"]",
";",
"ret",
"[",
"i",
"]",
"=",
"new",
"MethodParameter",
"(",
"name",
",",
"type",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Shortcut for creating an array of parameters. The values passed should be the parameter name and the parameter
type, such as "text", Type.STRING, "index", Type.NUMBER. If only one item is passed it is assumed to be of type
STRING.
@param params The array of parameter names and types
@return The array of created MethodParameters
|
[
"Shortcut",
"for",
"creating",
"an",
"array",
"of",
"parameters",
".",
"The",
"values",
"passed",
"should",
"be",
"the",
"parameter",
"name",
"and",
"the",
"parameter",
"type",
"such",
"as",
"text",
"Type",
".",
"STRING",
"index",
"Type",
".",
"NUMBER",
".",
"If",
"only",
"one",
"item",
"is",
"passed",
"it",
"is",
"assumed",
"to",
"be",
"of",
"type",
"STRING",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/command/method/MethodCommand.java#L197-L212
|
149,052
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.closeWindows
|
public static void closeWindows(Window... ignoredWindows) {
Window[] ws = Window.getWindows();
for (Window w : ws) {
if (!contains(ignoredWindows, w)) w.dispose();
}
}
|
java
|
public static void closeWindows(Window... ignoredWindows) {
Window[] ws = Window.getWindows();
for (Window w : ws) {
if (!contains(ignoredWindows, w)) w.dispose();
}
}
|
[
"public",
"static",
"void",
"closeWindows",
"(",
"Window",
"...",
"ignoredWindows",
")",
"{",
"Window",
"[",
"]",
"ws",
"=",
"Window",
".",
"getWindows",
"(",
")",
";",
"for",
"(",
"Window",
"w",
":",
"ws",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"ignoredWindows",
",",
"w",
")",
")",
"w",
".",
"dispose",
"(",
")",
";",
"}",
"}"
] |
Close all windows.
@param ignoredWindows The windows to ignore
|
[
"Close",
"all",
"windows",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L112-L117
|
149,053
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.trimArray
|
public static String[] trimArray(String[] strings) {
for (int i = 0; i < strings.length; i++) {
strings[i] = strings[i].trim();
}
return strings;
}
|
java
|
public static String[] trimArray(String[] strings) {
for (int i = 0; i < strings.length; i++) {
strings[i] = strings[i].trim();
}
return strings;
}
|
[
"public",
"static",
"String",
"[",
"]",
"trimArray",
"(",
"String",
"[",
"]",
"strings",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"strings",
".",
"length",
";",
"i",
"++",
")",
"{",
"strings",
"[",
"i",
"]",
"=",
"strings",
"[",
"i",
"]",
".",
"trim",
"(",
")",
";",
"}",
"return",
"strings",
";",
"}"
] |
Trims all elements inside the array, modifying the original array.
@param strings The string array
@return The passed string array, trimmed
|
[
"Trims",
"all",
"elements",
"inside",
"the",
"array",
"modifying",
"the",
"original",
"array",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L160-L165
|
149,054
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.createParameterMap
|
public static Map<String, ValueCommand> createParameterMap(Object... params) {
assert params.length % 2 == 0;
Map<String, ValueCommand> ret = new HashMap<String, ValueCommand>();
for (int i = 0; i < params.length; i = i + 2) {
String param = params[i].toString();
Value value = convertFromJava(params[i + 1]);
ret.put(param, new LiteralCommand(value));
}
return ret;
}
|
java
|
public static Map<String, ValueCommand> createParameterMap(Object... params) {
assert params.length % 2 == 0;
Map<String, ValueCommand> ret = new HashMap<String, ValueCommand>();
for (int i = 0; i < params.length; i = i + 2) {
String param = params[i].toString();
Value value = convertFromJava(params[i + 1]);
ret.put(param, new LiteralCommand(value));
}
return ret;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"ValueCommand",
">",
"createParameterMap",
"(",
"Object",
"...",
"params",
")",
"{",
"assert",
"params",
".",
"length",
"%",
"2",
"==",
"0",
";",
"Map",
"<",
"String",
",",
"ValueCommand",
">",
"ret",
"=",
"new",
"HashMap",
"<",
"String",
",",
"ValueCommand",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"=",
"i",
"+",
"2",
")",
"{",
"String",
"param",
"=",
"params",
"[",
"i",
"]",
".",
"toString",
"(",
")",
";",
"Value",
"value",
"=",
"convertFromJava",
"(",
"params",
"[",
"i",
"+",
"1",
"]",
")",
";",
"ret",
".",
"put",
"(",
"param",
",",
"new",
"LiteralCommand",
"(",
"value",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Utility method useful for creating a parameter map.
@param params The parameters, should be in the format "name", value
@return The parameters map
|
[
"Utility",
"method",
"useful",
"for",
"creating",
"a",
"parameter",
"map",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L173-L182
|
149,055
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.convertFromJava
|
public static Value convertFromJava(Object o) {
if (o instanceof Long) {
return new NumberValue(new BigDecimal((Long) o));
} else if (o instanceof Integer) {
return new NumberValue(new BigDecimal((Integer) o));
} else if (o instanceof Double) {
return new NumberValue(new BigDecimal((Double) o));
} else if (o instanceof Float) {
return new NumberValue(new BigDecimal((Float) o));
} else if (o instanceof String) {
return new StringValue((String) o);
} else if (o instanceof Date) {
return new DateValue((Date) o);
} else if (o instanceof Boolean) {
return BooleanValue.getInstance((Boolean) o);
} else if (o == null) {
return NilValue.getInstance();
}
throw new CommandExecutionException("Could not convert Java object " + o + " to an equivalent srec value");
}
|
java
|
public static Value convertFromJava(Object o) {
if (o instanceof Long) {
return new NumberValue(new BigDecimal((Long) o));
} else if (o instanceof Integer) {
return new NumberValue(new BigDecimal((Integer) o));
} else if (o instanceof Double) {
return new NumberValue(new BigDecimal((Double) o));
} else if (o instanceof Float) {
return new NumberValue(new BigDecimal((Float) o));
} else if (o instanceof String) {
return new StringValue((String) o);
} else if (o instanceof Date) {
return new DateValue((Date) o);
} else if (o instanceof Boolean) {
return BooleanValue.getInstance((Boolean) o);
} else if (o == null) {
return NilValue.getInstance();
}
throw new CommandExecutionException("Could not convert Java object " + o + " to an equivalent srec value");
}
|
[
"public",
"static",
"Value",
"convertFromJava",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"Long",
")",
"{",
"return",
"new",
"NumberValue",
"(",
"new",
"BigDecimal",
"(",
"(",
"Long",
")",
"o",
")",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Integer",
")",
"{",
"return",
"new",
"NumberValue",
"(",
"new",
"BigDecimal",
"(",
"(",
"Integer",
")",
"o",
")",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Double",
")",
"{",
"return",
"new",
"NumberValue",
"(",
"new",
"BigDecimal",
"(",
"(",
"Double",
")",
"o",
")",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Float",
")",
"{",
"return",
"new",
"NumberValue",
"(",
"new",
"BigDecimal",
"(",
"(",
"Float",
")",
"o",
")",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"String",
")",
"{",
"return",
"new",
"StringValue",
"(",
"(",
"String",
")",
"o",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Date",
")",
"{",
"return",
"new",
"DateValue",
"(",
"(",
"Date",
")",
"o",
")",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Boolean",
")",
"{",
"return",
"BooleanValue",
".",
"getInstance",
"(",
"(",
"Boolean",
")",
"o",
")",
";",
"}",
"else",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"NilValue",
".",
"getInstance",
"(",
")",
";",
"}",
"throw",
"new",
"CommandExecutionException",
"(",
"\"Could not convert Java object \"",
"+",
"o",
"+",
"\" to an equivalent srec value\"",
")",
";",
"}"
] |
Converts a Java object to a srec value.
@param o The Java object
@return The srec value
|
[
"Converts",
"a",
"Java",
"object",
"to",
"a",
"srec",
"value",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L190-L209
|
149,056
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.convertToJava
|
public static Object convertToJava(Value value) {
switch (value.getType()) {
case STRING:
return ((StringValue) value).get();
case BOOLEAN:
return ((BooleanValue) value).get();
case NUMBER:
return ((NumberValue) value).get();
case DATE:
return ((DateValue) value).get();
case NIL:
return null;
case OBJECT:
return value.get();
}
throw new CommandExecutionException("Could not convert value " + value + " to an equivalent Java object");
}
|
java
|
public static Object convertToJava(Value value) {
switch (value.getType()) {
case STRING:
return ((StringValue) value).get();
case BOOLEAN:
return ((BooleanValue) value).get();
case NUMBER:
return ((NumberValue) value).get();
case DATE:
return ((DateValue) value).get();
case NIL:
return null;
case OBJECT:
return value.get();
}
throw new CommandExecutionException("Could not convert value " + value + " to an equivalent Java object");
}
|
[
"public",
"static",
"Object",
"convertToJava",
"(",
"Value",
"value",
")",
"{",
"switch",
"(",
"value",
".",
"getType",
"(",
")",
")",
"{",
"case",
"STRING",
":",
"return",
"(",
"(",
"StringValue",
")",
"value",
")",
".",
"get",
"(",
")",
";",
"case",
"BOOLEAN",
":",
"return",
"(",
"(",
"BooleanValue",
")",
"value",
")",
".",
"get",
"(",
")",
";",
"case",
"NUMBER",
":",
"return",
"(",
"(",
"NumberValue",
")",
"value",
")",
".",
"get",
"(",
")",
";",
"case",
"DATE",
":",
"return",
"(",
"(",
"DateValue",
")",
"value",
")",
".",
"get",
"(",
")",
";",
"case",
"NIL",
":",
"return",
"null",
";",
"case",
"OBJECT",
":",
"return",
"value",
".",
"get",
"(",
")",
";",
"}",
"throw",
"new",
"CommandExecutionException",
"(",
"\"Could not convert value \"",
"+",
"value",
"+",
"\" to an equivalent Java object\"",
")",
";",
"}"
] |
Converts a srec value to a Java object.
@param value The value
@return The Java object
|
[
"Converts",
"a",
"srec",
"value",
"to",
"a",
"Java",
"object",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L217-L233
|
149,057
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.groovyEvaluate
|
public static Object groovyEvaluate(ExecutionContext context, String expression) {
Binding binding = new Binding();
for (Map.Entry<String, CommandSymbol> entry : context.getSymbols().entrySet()) {
final CommandSymbol symbol = entry.getValue();
if (symbol instanceof VarCommand) {
binding.setVariable(entry.getKey(), convertToJava(((VarCommand) symbol).getValue(context)));
}
}
GroovyShell shell = new GroovyShell(binding);
final Object o = shell.evaluate(expression);
if (o instanceof GString) {
return o.toString();
}
return o;
}
|
java
|
public static Object groovyEvaluate(ExecutionContext context, String expression) {
Binding binding = new Binding();
for (Map.Entry<String, CommandSymbol> entry : context.getSymbols().entrySet()) {
final CommandSymbol symbol = entry.getValue();
if (symbol instanceof VarCommand) {
binding.setVariable(entry.getKey(), convertToJava(((VarCommand) symbol).getValue(context)));
}
}
GroovyShell shell = new GroovyShell(binding);
final Object o = shell.evaluate(expression);
if (o instanceof GString) {
return o.toString();
}
return o;
}
|
[
"public",
"static",
"Object",
"groovyEvaluate",
"(",
"ExecutionContext",
"context",
",",
"String",
"expression",
")",
"{",
"Binding",
"binding",
"=",
"new",
"Binding",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"CommandSymbol",
">",
"entry",
":",
"context",
".",
"getSymbols",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"CommandSymbol",
"symbol",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"symbol",
"instanceof",
"VarCommand",
")",
"{",
"binding",
".",
"setVariable",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"convertToJava",
"(",
"(",
"(",
"VarCommand",
")",
"symbol",
")",
".",
"getValue",
"(",
"context",
")",
")",
")",
";",
"}",
"}",
"GroovyShell",
"shell",
"=",
"new",
"GroovyShell",
"(",
"binding",
")",
";",
"final",
"Object",
"o",
"=",
"shell",
".",
"evaluate",
"(",
"expression",
")",
";",
"if",
"(",
"o",
"instanceof",
"GString",
")",
"{",
"return",
"o",
".",
"toString",
"(",
")",
";",
"}",
"return",
"o",
";",
"}"
] |
Evaluates an expression using Groovy. All VarCommands inside the context are used in order to evaluate the given
expression.
@param context The EC
@param expression The expression to evaluate
@return The value
|
[
"Evaluates",
"an",
"expression",
"using",
"Groovy",
".",
"All",
"VarCommands",
"inside",
"the",
"context",
"are",
"used",
"in",
"order",
"to",
"evaluate",
"the",
"given",
"expression",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L243-L257
|
149,058
|
vtatai/srec
|
core/src/main/java/com/github/srec/util/Utils.java
|
Utils.groovyEvaluateConvert
|
public static Value groovyEvaluateConvert(ExecutionContext context, String expression) {
Object obj = groovyEvaluate(context, expression);
return Utils.convertFromJava(obj);
}
|
java
|
public static Value groovyEvaluateConvert(ExecutionContext context, String expression) {
Object obj = groovyEvaluate(context, expression);
return Utils.convertFromJava(obj);
}
|
[
"public",
"static",
"Value",
"groovyEvaluateConvert",
"(",
"ExecutionContext",
"context",
",",
"String",
"expression",
")",
"{",
"Object",
"obj",
"=",
"groovyEvaluate",
"(",
"context",
",",
"expression",
")",
";",
"return",
"Utils",
".",
"convertFromJava",
"(",
"obj",
")",
";",
"}"
] |
Evaluates an expression using Groovy, converting the final value.
@param context The EC
@param expression The expression to evaluate
@return The value converted
|
[
"Evaluates",
"an",
"expression",
"using",
"Groovy",
"converting",
"the",
"final",
"value",
"."
] |
87fa6754a6a5f8569ef628db4d149eea04062568
|
https://github.com/vtatai/srec/blob/87fa6754a6a5f8569ef628db4d149eea04062568/core/src/main/java/com/github/srec/util/Utils.java#L266-L269
|
149,059
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/query/DefaultQueryBuilder.java
|
DefaultQueryBuilder.setPropositionDefinitions
|
public final void setPropositionDefinitions(PropositionDefinition[] propDefs) {
if (propDefs == null) {
propDefs = EMPTY_PROP_DEF_ARRAY;
}
this.propDefs = propDefs.clone();
}
|
java
|
public final void setPropositionDefinitions(PropositionDefinition[] propDefs) {
if (propDefs == null) {
propDefs = EMPTY_PROP_DEF_ARRAY;
}
this.propDefs = propDefs.clone();
}
|
[
"public",
"final",
"void",
"setPropositionDefinitions",
"(",
"PropositionDefinition",
"[",
"]",
"propDefs",
")",
"{",
"if",
"(",
"propDefs",
"==",
"null",
")",
"{",
"propDefs",
"=",
"EMPTY_PROP_DEF_ARRAY",
";",
"}",
"this",
".",
"propDefs",
"=",
"propDefs",
".",
"clone",
"(",
")",
";",
"}"
] |
Returns an optional set of user-specified proposition definitions.
@param propDefs an array of {@link PropositionDefinition}s.
|
[
"Returns",
"an",
"optional",
"set",
"of",
"user",
"-",
"specified",
"proposition",
"definitions",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/query/DefaultQueryBuilder.java#L184-L189
|
149,060
|
ebean-orm/querybean-agent-now-merged-into-ebean-agent-
|
src/main/java/io/ebean/typequery/agent/DetectQueryBean.java
|
DetectQueryBean.isQueryBean
|
boolean isQueryBean(String owner) {
int subPackagePos = owner.lastIndexOf("/query/");
if (subPackagePos > -1) {
String suffix = owner.substring(subPackagePos);
if (isQueryBeanSuffix(suffix)) {
String domainPackage = owner.substring(0, subPackagePos + 1);
return isQueryBeanPackage(domainPackage);
}
}
return false;
}
|
java
|
boolean isQueryBean(String owner) {
int subPackagePos = owner.lastIndexOf("/query/");
if (subPackagePos > -1) {
String suffix = owner.substring(subPackagePos);
if (isQueryBeanSuffix(suffix)) {
String domainPackage = owner.substring(0, subPackagePos + 1);
return isQueryBeanPackage(domainPackage);
}
}
return false;
}
|
[
"boolean",
"isQueryBean",
"(",
"String",
"owner",
")",
"{",
"int",
"subPackagePos",
"=",
"owner",
".",
"lastIndexOf",
"(",
"\"/query/\"",
")",
";",
"if",
"(",
"subPackagePos",
">",
"-",
"1",
")",
"{",
"String",
"suffix",
"=",
"owner",
".",
"substring",
"(",
"subPackagePos",
")",
";",
"if",
"(",
"isQueryBeanSuffix",
"(",
"suffix",
")",
")",
"{",
"String",
"domainPackage",
"=",
"owner",
".",
"substring",
"(",
"0",
",",
"subPackagePos",
"+",
"1",
")",
";",
"return",
"isQueryBeanPackage",
"(",
"domainPackage",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return true if this class is a query bean using naming conventions for query beans.
|
[
"Return",
"true",
"if",
"this",
"class",
"is",
"a",
"query",
"bean",
"using",
"naming",
"conventions",
"for",
"query",
"beans",
"."
] |
a063554fabdbed15ff5e10ad0a0b53b67e039006
|
https://github.com/ebean-orm/querybean-agent-now-merged-into-ebean-agent-/blob/a063554fabdbed15ff5e10ad0a0b53b67e039006/src/main/java/io/ebean/typequery/agent/DetectQueryBean.java#L42-L53
|
149,061
|
openbase/jul
|
exception/src/main/java/org/openbase/jul/exception/FatalImplementationErrorException.java
|
FatalImplementationErrorException.detectClass
|
private Class detectClass(final Object object) {
if (object instanceof Class) {
return (Class) object;
}
return object.getClass();
}
|
java
|
private Class detectClass(final Object object) {
if (object instanceof Class) {
return (Class) object;
}
return object.getClass();
}
|
[
"private",
"Class",
"detectClass",
"(",
"final",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"instanceof",
"Class",
")",
"{",
"return",
"(",
"Class",
")",
"object",
";",
"}",
"return",
"object",
".",
"getClass",
"(",
")",
";",
"}"
] |
Method detects the class of the given instance. In case the instance itself is the class these one is directly returned.
@param object
@return
|
[
"Method",
"detects",
"the",
"class",
"of",
"the",
"given",
"instance",
".",
"In",
"case",
"the",
"instance",
"itself",
"is",
"the",
"class",
"these",
"one",
"is",
"directly",
"returned",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/exception/src/main/java/org/openbase/jul/exception/FatalImplementationErrorException.java#L82-L87
|
149,062
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Algorithms.java
|
Algorithms.getNextAlgorithmObjectId
|
String getNextAlgorithmObjectId() {
if (idsToAlgorithms.size() == Integer.MAX_VALUE) {
throw new IllegalArgumentException(
"Maximum number of algorithm objects reached");
}
while (true) {
String candidate = "ALGORITHM_" + currentAlgorithmId++;
if (isUniqueAlgorithmObjectId(candidate)) {
return candidate;
}
}
}
|
java
|
String getNextAlgorithmObjectId() {
if (idsToAlgorithms.size() == Integer.MAX_VALUE) {
throw new IllegalArgumentException(
"Maximum number of algorithm objects reached");
}
while (true) {
String candidate = "ALGORITHM_" + currentAlgorithmId++;
if (isUniqueAlgorithmObjectId(candidate)) {
return candidate;
}
}
}
|
[
"String",
"getNextAlgorithmObjectId",
"(",
")",
"{",
"if",
"(",
"idsToAlgorithms",
".",
"size",
"(",
")",
"==",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Maximum number of algorithm objects reached\"",
")",
";",
"}",
"while",
"(",
"true",
")",
"{",
"String",
"candidate",
"=",
"\"ALGORITHM_\"",
"+",
"currentAlgorithmId",
"++",
";",
"if",
"(",
"isUniqueAlgorithmObjectId",
"(",
"candidate",
")",
")",
"{",
"return",
"candidate",
";",
"}",
"}",
"}"
] |
Generates an unused algorithm id.
@return an algorithm id <code>String</code>.
|
[
"Generates",
"an",
"unused",
"algorithm",
"id",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Algorithms.java#L71-L82
|
149,063
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Algorithms.java
|
Algorithms.getAlgorithms
|
public Set<Algorithm> getAlgorithms() {
if (algorithms == null) {
algorithms = Collections.unmodifiableSet(new HashSet<>(
this.idsToAlgorithms.values()));
}
return algorithms;
}
|
java
|
public Set<Algorithm> getAlgorithms() {
if (algorithms == null) {
algorithms = Collections.unmodifiableSet(new HashSet<>(
this.idsToAlgorithms.values()));
}
return algorithms;
}
|
[
"public",
"Set",
"<",
"Algorithm",
">",
"getAlgorithms",
"(",
")",
"{",
"if",
"(",
"algorithms",
"==",
"null",
")",
"{",
"algorithms",
"=",
"Collections",
".",
"unmodifiableSet",
"(",
"new",
"HashSet",
"<>",
"(",
"this",
".",
"idsToAlgorithms",
".",
"values",
"(",
")",
")",
")",
";",
"}",
"return",
"algorithms",
";",
"}"
] |
Returns all algorithms.
@return a newly-created <code>Set</code> of <code>Algorithm</code>
objects.
|
[
"Returns",
"all",
"algorithms",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Algorithms.java#L102-L108
|
149,064
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Algorithms.java
|
Algorithms.addAlgorithm
|
public boolean addAlgorithm(Algorithm algorithm) {
if (algorithm == null || idsToAlgorithms.containsKey(algorithm.getId())) {
return false;
}
idsToAlgorithms.put(algorithm.getId(), algorithm);
algorithms = null;
return true;
}
|
java
|
public boolean addAlgorithm(Algorithm algorithm) {
if (algorithm == null || idsToAlgorithms.containsKey(algorithm.getId())) {
return false;
}
idsToAlgorithms.put(algorithm.getId(), algorithm);
algorithms = null;
return true;
}
|
[
"public",
"boolean",
"addAlgorithm",
"(",
"Algorithm",
"algorithm",
")",
"{",
"if",
"(",
"algorithm",
"==",
"null",
"||",
"idsToAlgorithms",
".",
"containsKey",
"(",
"algorithm",
".",
"getId",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"idsToAlgorithms",
".",
"put",
"(",
"algorithm",
".",
"getId",
"(",
")",
",",
"algorithm",
")",
";",
"algorithms",
"=",
"null",
";",
"return",
"true",
";",
"}"
] |
Adds a new algorithm.
@param algorithm
an <code>Algorithm</code> object.
@return <code>true</code> if successful, <code>false</code> if not.
|
[
"Adds",
"a",
"new",
"algorithm",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Algorithms.java#L142-L150
|
149,065
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Algorithms.java
|
Algorithms.removeAlgorithm
|
boolean removeAlgorithm(Algorithm algorithm) {
if (algorithm != null) {
algorithm.close();
}
if (idsToAlgorithms.remove(algorithm.getId()) != null) {
algorithms = null;
return true;
} else {
return false;
}
}
|
java
|
boolean removeAlgorithm(Algorithm algorithm) {
if (algorithm != null) {
algorithm.close();
}
if (idsToAlgorithms.remove(algorithm.getId()) != null) {
algorithms = null;
return true;
} else {
return false;
}
}
|
[
"boolean",
"removeAlgorithm",
"(",
"Algorithm",
"algorithm",
")",
"{",
"if",
"(",
"algorithm",
"!=",
"null",
")",
"{",
"algorithm",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"idsToAlgorithms",
".",
"remove",
"(",
"algorithm",
".",
"getId",
"(",
")",
")",
"!=",
"null",
")",
"{",
"algorithms",
"=",
"null",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Closes and removes an algorithm.
@param algorithm
an <code>Algorithm</code> object.
@return <code>true</code> if successful, <code>false</code> if not.
|
[
"Closes",
"and",
"removes",
"an",
"algorithm",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Algorithms.java#L159-L169
|
149,066
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/Algorithms.java
|
Algorithms.closeAndClear
|
void closeAndClear() {
for (Algorithm a : this.idsToAlgorithms.values()) {
a.close();
}
idsToAlgorithms.clear();
algorithms = null;
}
|
java
|
void closeAndClear() {
for (Algorithm a : this.idsToAlgorithms.values()) {
a.close();
}
idsToAlgorithms.clear();
algorithms = null;
}
|
[
"void",
"closeAndClear",
"(",
")",
"{",
"for",
"(",
"Algorithm",
"a",
":",
"this",
".",
"idsToAlgorithms",
".",
"values",
"(",
")",
")",
"{",
"a",
".",
"close",
"(",
")",
";",
"}",
"idsToAlgorithms",
".",
"clear",
"(",
")",
";",
"algorithms",
"=",
"null",
";",
"}"
] |
Closes and removes all algorithms.
|
[
"Closes",
"and",
"removes",
"all",
"algorithms",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/Algorithms.java#L174-L180
|
149,067
|
netkicorp/java-wns-resolver
|
src/main/java/com/netki/tlsa/CACertService.java
|
CACertService.getCaCertKeystore
|
public KeyStore getCaCertKeystore() {
try {
KeyStore returnKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
returnKeyStore.load(null, null);
Enumeration<String> e = CACertService.caCertKeystore.aliases();
while(e.hasMoreElements()) {
Certificate cert = CACertService.caCertKeystore.getCertificate(e.nextElement());
returnKeyStore.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return CACertService.caCertKeystore;
} catch (KeyStoreException e) {
return null;
} catch (CertificateException e) {
return null;
} catch (NoSuchAlgorithmException e) {
return null;
} catch (IOException e) {
return null;
}
}
|
java
|
public KeyStore getCaCertKeystore() {
try {
KeyStore returnKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
returnKeyStore.load(null, null);
Enumeration<String> e = CACertService.caCertKeystore.aliases();
while(e.hasMoreElements()) {
Certificate cert = CACertService.caCertKeystore.getCertificate(e.nextElement());
returnKeyStore.setCertificateEntry(((X509Certificate) cert).getSubjectDN().toString(), cert);
}
return CACertService.caCertKeystore;
} catch (KeyStoreException e) {
return null;
} catch (CertificateException e) {
return null;
} catch (NoSuchAlgorithmException e) {
return null;
} catch (IOException e) {
return null;
}
}
|
[
"public",
"KeyStore",
"getCaCertKeystore",
"(",
")",
"{",
"try",
"{",
"KeyStore",
"returnKeyStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"KeyStore",
".",
"getDefaultType",
"(",
")",
")",
";",
"returnKeyStore",
".",
"load",
"(",
"null",
",",
"null",
")",
";",
"Enumeration",
"<",
"String",
">",
"e",
"=",
"CACertService",
".",
"caCertKeystore",
".",
"aliases",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Certificate",
"cert",
"=",
"CACertService",
".",
"caCertKeystore",
".",
"getCertificate",
"(",
"e",
".",
"nextElement",
"(",
")",
")",
";",
"returnKeyStore",
".",
"setCertificateEntry",
"(",
"(",
"(",
"X509Certificate",
")",
"cert",
")",
".",
"getSubjectDN",
"(",
")",
".",
"toString",
"(",
")",
",",
"cert",
")",
";",
"}",
"return",
"CACertService",
".",
"caCertKeystore",
";",
"}",
"catch",
"(",
"KeyStoreException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"CertificateException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get a copy of the currently loaded CA Certificate KeyStore
@return Copy of currently loaded CA Certificate KeyStore
|
[
"Get",
"a",
"copy",
"of",
"the",
"currently",
"loaded",
"CA",
"Certificate",
"KeyStore"
] |
a7aad04d96c03feb05536aef189617beb4f011bc
|
https://github.com/netkicorp/java-wns-resolver/blob/a7aad04d96c03feb05536aef189617beb4f011bc/src/main/java/com/netki/tlsa/CACertService.java#L52-L71
|
149,068
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/ShortEditor.java
|
ShortEditor.setAsText
|
public void setAsText(final String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
try {
Object newValue = Short.decode(text);
setValue(newValue);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Failed to parse short.", e);
}
}
|
java
|
public void setAsText(final String text) {
if (BeanUtils.isNull(text)) {
setValue(null);
return;
}
try {
Object newValue = Short.decode(text);
setValue(newValue);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Failed to parse short.", e);
}
}
|
[
"public",
"void",
"setAsText",
"(",
"final",
"String",
"text",
")",
"{",
"if",
"(",
"BeanUtils",
".",
"isNull",
"(",
"text",
")",
")",
"{",
"setValue",
"(",
"null",
")",
";",
"return",
";",
"}",
"try",
"{",
"Object",
"newValue",
"=",
"Short",
".",
"decode",
"(",
"text",
")",
";",
"setValue",
"(",
"newValue",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Failed to parse short.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Map the argument text into and Short using Short.decode.
|
[
"Map",
"the",
"argument",
"text",
"into",
"and",
"Short",
"using",
"Short",
".",
"decode",
"."
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/ShortEditor.java#L38-L49
|
149,069
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java
|
TreeNode.childWithToken
|
TreeNode childWithToken(Token token) {
for (TreeNode child : m_children) {
if (child.getToken().equals(token)) {
return child;
}
}
return null;
}
|
java
|
TreeNode childWithToken(Token token) {
for (TreeNode child : m_children) {
if (child.getToken().equals(token)) {
return child;
}
}
return null;
}
|
[
"TreeNode",
"childWithToken",
"(",
"Token",
"token",
")",
"{",
"for",
"(",
"TreeNode",
"child",
":",
"m_children",
")",
"{",
"if",
"(",
"child",
".",
"getToken",
"(",
")",
".",
"equals",
"(",
"token",
")",
")",
"{",
"return",
"child",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Search for children that has the specified token, if not found return
null;
|
[
"Search",
"for",
"children",
"that",
"has",
"the",
"specified",
"token",
"if",
"not",
"found",
"return",
"null",
";"
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java#L78-L86
|
149,070
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java
|
TreeNode.size
|
int size() {
int res = m_subscriptions.size();
for (TreeNode child : m_children) {
res += child.size();
}
return res;
}
|
java
|
int size() {
int res = m_subscriptions.size();
for (TreeNode child : m_children) {
res += child.size();
}
return res;
}
|
[
"int",
"size",
"(",
")",
"{",
"int",
"res",
"=",
"m_subscriptions",
".",
"size",
"(",
")",
";",
"for",
"(",
"TreeNode",
"child",
":",
"m_children",
")",
"{",
"res",
"+=",
"child",
".",
"size",
"(",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Return the number of registered subscriptions
|
[
"Return",
"the",
"number",
"of",
"registered",
"subscriptions"
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java#L127-L133
|
149,071
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java
|
TreeNode.deactivate
|
void deactivate(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
s.setActive(false);
}
}
//go deep
for (TreeNode child : m_children) {
child.deactivate(clientID);
}
}
|
java
|
void deactivate(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
s.setActive(false);
}
}
//go deep
for (TreeNode child : m_children) {
child.deactivate(clientID);
}
}
|
[
"void",
"deactivate",
"(",
"String",
"clientID",
")",
"{",
"for",
"(",
"Subscription",
"s",
":",
"m_subscriptions",
")",
"{",
"if",
"(",
"s",
".",
"clientId",
".",
"equals",
"(",
"clientID",
")",
")",
"{",
"s",
".",
"setActive",
"(",
"false",
")",
";",
"}",
"}",
"//go deep",
"for",
"(",
"TreeNode",
"child",
":",
"m_children",
")",
"{",
"child",
".",
"deactivate",
"(",
"clientID",
")",
";",
"}",
"}"
] |
Deactivate all topic subscriptions for the given clientID.
|
[
"Deactivate",
"all",
"topic",
"subscriptions",
"for",
"the",
"given",
"clientID",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java#L157-L168
|
149,072
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java
|
TreeNode.activate
|
public void activate(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
s.setActive(true);
}
}
//go deep
for (TreeNode child : m_children) {
child.activate(clientID);
}
}
|
java
|
public void activate(String clientID) {
for (Subscription s : m_subscriptions) {
if (s.clientId.equals(clientID)) {
s.setActive(true);
}
}
//go deep
for (TreeNode child : m_children) {
child.activate(clientID);
}
}
|
[
"public",
"void",
"activate",
"(",
"String",
"clientID",
")",
"{",
"for",
"(",
"Subscription",
"s",
":",
"m_subscriptions",
")",
"{",
"if",
"(",
"s",
".",
"clientId",
".",
"equals",
"(",
"clientID",
")",
")",
"{",
"s",
".",
"setActive",
"(",
"true",
")",
";",
"}",
"}",
"//go deep",
"for",
"(",
"TreeNode",
"child",
":",
"m_children",
")",
"{",
"child",
".",
"activate",
"(",
"clientID",
")",
";",
"}",
"}"
] |
Activate all topic subscriptions for the given clientID.
|
[
"Activate",
"all",
"topic",
"subscriptions",
"for",
"the",
"given",
"clientID",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/messaging/spi/impl/subscriptions/TreeNode.java#L173-L185
|
149,073
|
openbase/jul
|
storage/src/main/java/org/openbase/jul/storage/registry/version/GenericRenameFieldDBVersionConverter.java
|
GenericRenameFieldDBVersionConverter.upgrade
|
@Override
public JsonObject upgrade(final JsonObject outdatedDBEntry, Map<File, JsonObject> dbSnapshot) {
return rename(outdatedDBEntry, newName, path);
}
|
java
|
@Override
public JsonObject upgrade(final JsonObject outdatedDBEntry, Map<File, JsonObject> dbSnapshot) {
return rename(outdatedDBEntry, newName, path);
}
|
[
"@",
"Override",
"public",
"JsonObject",
"upgrade",
"(",
"final",
"JsonObject",
"outdatedDBEntry",
",",
"Map",
"<",
"File",
",",
"JsonObject",
">",
"dbSnapshot",
")",
"{",
"return",
"rename",
"(",
"outdatedDBEntry",
",",
"newName",
",",
"path",
")",
";",
"}"
] |
Generic renaming.
@param outdatedDBEntry the outdated db entry where the upgrade should be applied to.
@param dbSnapshot all entries of the current database which may are partially upgraded.
@return the updated value.
|
[
"Generic",
"renaming",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/storage/src/main/java/org/openbase/jul/storage/registry/version/GenericRenameFieldDBVersionConverter.java#L63-L66
|
149,074
|
openbase/jul
|
storage/src/main/java/org/openbase/jul/storage/registry/version/GenericRenameFieldDBVersionConverter.java
|
GenericRenameFieldDBVersionConverter.rename
|
public static JsonObject rename(final JsonObject outdatedDBEntry, final String newName, final String... path) {
// store root element
JsonObject parent = outdatedDBEntry;
// lookup element to rename
for (int i = 0; i < path.length; i++) {
final String propertyName = path[i];
// property not found so nothing to rename
if (!parent.has(propertyName)) {
return outdatedDBEntry;
}
// if element to rename selected than rename otherwise contine with next element
if (i == path.length - 1) {
parent.add(newName, parent.remove(propertyName));
} else {
// prepare next round
parent = parent.getAsJsonObject(propertyName);
}
}
return outdatedDBEntry;
}
|
java
|
public static JsonObject rename(final JsonObject outdatedDBEntry, final String newName, final String... path) {
// store root element
JsonObject parent = outdatedDBEntry;
// lookup element to rename
for (int i = 0; i < path.length; i++) {
final String propertyName = path[i];
// property not found so nothing to rename
if (!parent.has(propertyName)) {
return outdatedDBEntry;
}
// if element to rename selected than rename otherwise contine with next element
if (i == path.length - 1) {
parent.add(newName, parent.remove(propertyName));
} else {
// prepare next round
parent = parent.getAsJsonObject(propertyName);
}
}
return outdatedDBEntry;
}
|
[
"public",
"static",
"JsonObject",
"rename",
"(",
"final",
"JsonObject",
"outdatedDBEntry",
",",
"final",
"String",
"newName",
",",
"final",
"String",
"...",
"path",
")",
"{",
"// store root element",
"JsonObject",
"parent",
"=",
"outdatedDBEntry",
";",
"// lookup element to rename",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"path",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"String",
"propertyName",
"=",
"path",
"[",
"i",
"]",
";",
"// property not found so nothing to rename",
"if",
"(",
"!",
"parent",
".",
"has",
"(",
"propertyName",
")",
")",
"{",
"return",
"outdatedDBEntry",
";",
"}",
"// if element to rename selected than rename otherwise contine with next element",
"if",
"(",
"i",
"==",
"path",
".",
"length",
"-",
"1",
")",
"{",
"parent",
".",
"add",
"(",
"newName",
",",
"parent",
".",
"remove",
"(",
"propertyName",
")",
")",
";",
"}",
"else",
"{",
"// prepare next round",
"parent",
"=",
"parent",
".",
"getAsJsonObject",
"(",
"propertyName",
")",
";",
"}",
"}",
"return",
"outdatedDBEntry",
";",
"}"
] |
Method to rename a field.
@param outdatedDBEntry the root entry of the path.
@param newName the new name of the field.
@param path the path inclusive the old field.
@return the updated value.
|
[
"Method",
"to",
"rename",
"a",
"field",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/storage/src/main/java/org/openbase/jul/storage/registry/version/GenericRenameFieldDBVersionConverter.java#L77-L101
|
149,075
|
jboss/jboss-common-beans
|
src/main/java/org/jboss/common/beans/property/BeanUtils.java
|
BeanUtils.convertValue
|
public static Object convertValue(String text, String typeName) throws ClassNotFoundException, IntrospectionException {
// see if it is a primitive type first
Class<?> typeClass = getPrimitiveTypeForName(typeName);
if (typeClass == null) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
typeClass = loader.loadClass(typeName);
}
PropertyEditor editor = PropertyEditorFinder.getInstance().find(typeClass);
if (editor == null) {
throw new IntrospectionException("No property editor for type=" + typeClass);
}
editor.setAsText(text);
return editor.getValue();
}
|
java
|
public static Object convertValue(String text, String typeName) throws ClassNotFoundException, IntrospectionException {
// see if it is a primitive type first
Class<?> typeClass = getPrimitiveTypeForName(typeName);
if (typeClass == null) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
typeClass = loader.loadClass(typeName);
}
PropertyEditor editor = PropertyEditorFinder.getInstance().find(typeClass);
if (editor == null) {
throw new IntrospectionException("No property editor for type=" + typeClass);
}
editor.setAsText(text);
return editor.getValue();
}
|
[
"public",
"static",
"Object",
"convertValue",
"(",
"String",
"text",
",",
"String",
"typeName",
")",
"throws",
"ClassNotFoundException",
",",
"IntrospectionException",
"{",
"// see if it is a primitive type first",
"Class",
"<",
"?",
">",
"typeClass",
"=",
"getPrimitiveTypeForName",
"(",
"typeName",
")",
";",
"if",
"(",
"typeClass",
"==",
"null",
")",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"typeClass",
"=",
"loader",
".",
"loadClass",
"(",
"typeName",
")",
";",
"}",
"PropertyEditor",
"editor",
"=",
"PropertyEditorFinder",
".",
"getInstance",
"(",
")",
".",
"find",
"(",
"typeClass",
")",
";",
"if",
"(",
"editor",
"==",
"null",
")",
"{",
"throw",
"new",
"IntrospectionException",
"(",
"\"No property editor for type=\"",
"+",
"typeClass",
")",
";",
"}",
"editor",
".",
"setAsText",
"(",
"text",
")",
";",
"return",
"editor",
".",
"getValue",
"(",
")",
";",
"}"
] |
Convert a string value into the true value for typeName using the PropertyEditor associated with typeName.
@param text the string represention of the value. This is passed to the PropertyEditor.setAsText method.
@param typeName the fully qualified class name of the true value type
@return the PropertyEditor.getValue() result
@exception ClassNotFoundException thrown if the typeName class cannot be found
@exception IntrospectionException thrown if a PropertyEditor for typeName cannot be found
|
[
"Convert",
"a",
"string",
"value",
"into",
"the",
"true",
"value",
"for",
"typeName",
"using",
"the",
"PropertyEditor",
"associated",
"with",
"typeName",
"."
] |
ffb48b1719762534bf92d762eadf91d1815f6748
|
https://github.com/jboss/jboss-common-beans/blob/ffb48b1719762534bf92d762eadf91d1815f6748/src/main/java/org/jboss/common/beans/property/BeanUtils.java#L213-L227
|
149,076
|
openbase/jul
|
exception/src/main/java/org/openbase/jul/exception/ExceptionProcessor.java
|
ExceptionProcessor.getInitialCauseMessage
|
public static String getInitialCauseMessage(final Throwable throwable) {
final Throwable cause = getInitialCause(throwable);
if (cause.getLocalizedMessage() == null) {
return cause.getClass().getSimpleName();
}
return cause.getLocalizedMessage();
}
|
java
|
public static String getInitialCauseMessage(final Throwable throwable) {
final Throwable cause = getInitialCause(throwable);
if (cause.getLocalizedMessage() == null) {
return cause.getClass().getSimpleName();
}
return cause.getLocalizedMessage();
}
|
[
"public",
"static",
"String",
"getInitialCauseMessage",
"(",
"final",
"Throwable",
"throwable",
")",
"{",
"final",
"Throwable",
"cause",
"=",
"getInitialCause",
"(",
"throwable",
")",
";",
"if",
"(",
"cause",
".",
"getLocalizedMessage",
"(",
")",
"==",
"null",
")",
"{",
"return",
"cause",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"}",
"return",
"cause",
".",
"getLocalizedMessage",
"(",
")",
";",
"}"
] |
Method returns the message of the initial cause of the given throwable.
If the throwable does not provide a message its class name is returned.
@param throwable the throwable to detect the message.
@return the message as string.
|
[
"Method",
"returns",
"the",
"message",
"of",
"the",
"initial",
"cause",
"of",
"the",
"given",
"throwable",
".",
"If",
"the",
"throwable",
"does",
"not",
"provide",
"a",
"message",
"its",
"class",
"name",
"is",
"returned",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/exception/src/main/java/org/openbase/jul/exception/ExceptionProcessor.java#L44-L50
|
149,077
|
openbase/jul
|
exception/src/main/java/org/openbase/jul/exception/ExceptionProcessor.java
|
ExceptionProcessor.getInitialCause
|
public static Throwable getInitialCause(final Throwable throwable) {
if (throwable == null) {
new FatalImplementationErrorException(ExceptionProcessor.class, new NotAvailableException("cause"));
}
Throwable cause = throwable;
while (cause.getCause() != null) {
cause = cause.getCause();
}
return cause;
}
|
java
|
public static Throwable getInitialCause(final Throwable throwable) {
if (throwable == null) {
new FatalImplementationErrorException(ExceptionProcessor.class, new NotAvailableException("cause"));
}
Throwable cause = throwable;
while (cause.getCause() != null) {
cause = cause.getCause();
}
return cause;
}
|
[
"public",
"static",
"Throwable",
"getInitialCause",
"(",
"final",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"throwable",
"==",
"null",
")",
"{",
"new",
"FatalImplementationErrorException",
"(",
"ExceptionProcessor",
".",
"class",
",",
"new",
"NotAvailableException",
"(",
"\"cause\"",
")",
")",
";",
"}",
"Throwable",
"cause",
"=",
"throwable",
";",
"while",
"(",
"cause",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"cause",
"=",
"cause",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"cause",
";",
"}"
] |
Method returns the initial cause of the given throwable.
@param throwable the throwable to detect the message.
@return the cause as throwable.
|
[
"Method",
"returns",
"the",
"initial",
"cause",
"of",
"the",
"given",
"throwable",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/exception/src/main/java/org/openbase/jul/exception/ExceptionProcessor.java#L59-L69
|
149,078
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/launch/AbstractFXApplication.java
|
AbstractFXApplication.exit
|
public static void exit(final int exitCode, final Exception ex) {
System.err.println(JPService.getApplicationName() + " crashed...");
ExceptionPrinter.printHistory(ex, System.err);
System.exit(exitCode);
}
|
java
|
public static void exit(final int exitCode, final Exception ex) {
System.err.println(JPService.getApplicationName() + " crashed...");
ExceptionPrinter.printHistory(ex, System.err);
System.exit(exitCode);
}
|
[
"public",
"static",
"void",
"exit",
"(",
"final",
"int",
"exitCode",
",",
"final",
"Exception",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"JPService",
".",
"getApplicationName",
"(",
")",
"+",
"\" crashed...\"",
")",
";",
"ExceptionPrinter",
".",
"printHistory",
"(",
"ex",
",",
"System",
".",
"err",
")",
";",
"System",
".",
"exit",
"(",
"exitCode",
")",
";",
"}"
] |
Method exists the application and prints the given exception as error description.
@param ex the reason for the application exit.
|
[
"Method",
"exists",
"the",
"application",
"and",
"prints",
"the",
"given",
"exception",
"as",
"error",
"description",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/launch/AbstractFXApplication.java#L39-L43
|
149,079
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.value
|
public long value() {
if (isInfinity && !posOrNeg) {
return Long.MIN_VALUE;
} else if (isInfinity && posOrNeg) {
return Long.MAX_VALUE;
} else {
return val;
}
}
|
java
|
public long value() {
if (isInfinity && !posOrNeg) {
return Long.MIN_VALUE;
} else if (isInfinity && posOrNeg) {
return Long.MAX_VALUE;
} else {
return val;
}
}
|
[
"public",
"long",
"value",
"(",
")",
"{",
"if",
"(",
"isInfinity",
"&&",
"!",
"posOrNeg",
")",
"{",
"return",
"Long",
".",
"MIN_VALUE",
";",
"}",
"else",
"if",
"(",
"isInfinity",
"&&",
"posOrNeg",
")",
"{",
"return",
"Long",
".",
"MAX_VALUE",
";",
"}",
"else",
"{",
"return",
"val",
";",
"}",
"}"
] |
Gets the value of this weight.
@return a long representing the value of this weight. If this weight has
a value of positive infinity, <code>Long.MAX_VALUE</code> is
returned. If this weight has a value of negative infinity,
<code>Long.MIN_VALUE</code> is returned.
|
[
"Gets",
"the",
"value",
"of",
"this",
"weight",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L125-L133
|
149,080
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.greaterThan
|
public boolean greaterThan(long val) {
if (isInfinity && posOrNeg) {
return true;
} else if (isInfinity && !posOrNeg) {
return false;
} else {
return this.val > val;
}
}
|
java
|
public boolean greaterThan(long val) {
if (isInfinity && posOrNeg) {
return true;
} else if (isInfinity && !posOrNeg) {
return false;
} else {
return this.val > val;
}
}
|
[
"public",
"boolean",
"greaterThan",
"(",
"long",
"val",
")",
"{",
"if",
"(",
"isInfinity",
"&&",
"posOrNeg",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"isInfinity",
"&&",
"!",
"posOrNeg",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"this",
".",
"val",
">",
"val",
";",
"}",
"}"
] |
Checks to see if this weight is greater than the given long value.
@param val
a long value.
@return true if this weight is greater than the given long value, false
otherwise.
|
[
"Checks",
"to",
"see",
"if",
"this",
"weight",
"is",
"greater",
"than",
"the",
"given",
"long",
"value",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L143-L151
|
149,081
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.lessThan
|
public boolean lessThan(long val) {
if (isInfinity && !posOrNeg) {
return true;
} else if (isInfinity && posOrNeg) {
return false;
} else {
return this.val < val;
}
}
|
java
|
public boolean lessThan(long val) {
if (isInfinity && !posOrNeg) {
return true;
} else if (isInfinity && posOrNeg) {
return false;
} else {
return this.val < val;
}
}
|
[
"public",
"boolean",
"lessThan",
"(",
"long",
"val",
")",
"{",
"if",
"(",
"isInfinity",
"&&",
"!",
"posOrNeg",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"isInfinity",
"&&",
"posOrNeg",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"this",
".",
"val",
"<",
"val",
";",
"}",
"}"
] |
Checks to see if this weight is less than the given long value.
@param val
a long value.
@return true if this weight is less than the given long value, false
otherwise.
|
[
"Checks",
"to",
"see",
"if",
"this",
"weight",
"is",
"less",
"than",
"the",
"given",
"long",
"value",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L171-L179
|
149,082
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.add
|
public Weight add(Weight w) {
if (w == null) {
return new Weight(this);
} else {
boolean wIsInfinity = w.isInfinity;
boolean wPosOrNeg = w.posOrNeg;
if ((isInfinity && posOrNeg && wIsInfinity && !wPosOrNeg)
|| (isInfinity && !posOrNeg && wIsInfinity && wPosOrNeg)) {
throw new IllegalArgumentException("+inf - inf!");
} else if ((isInfinity && posOrNeg) || (w.isInfinity && wPosOrNeg)) {
return WeightFactory.POS_INFINITY;
} else if ((isInfinity && !posOrNeg) || (wIsInfinity && !wPosOrNeg)) {
return WeightFactory.NEG_INFINITY;
} else {
return new Weight(val + w.val);
}
}
}
|
java
|
public Weight add(Weight w) {
if (w == null) {
return new Weight(this);
} else {
boolean wIsInfinity = w.isInfinity;
boolean wPosOrNeg = w.posOrNeg;
if ((isInfinity && posOrNeg && wIsInfinity && !wPosOrNeg)
|| (isInfinity && !posOrNeg && wIsInfinity && wPosOrNeg)) {
throw new IllegalArgumentException("+inf - inf!");
} else if ((isInfinity && posOrNeg) || (w.isInfinity && wPosOrNeg)) {
return WeightFactory.POS_INFINITY;
} else if ((isInfinity && !posOrNeg) || (wIsInfinity && !wPosOrNeg)) {
return WeightFactory.NEG_INFINITY;
} else {
return new Weight(val + w.val);
}
}
}
|
[
"public",
"Weight",
"add",
"(",
"Weight",
"w",
")",
"{",
"if",
"(",
"w",
"==",
"null",
")",
"{",
"return",
"new",
"Weight",
"(",
"this",
")",
";",
"}",
"else",
"{",
"boolean",
"wIsInfinity",
"=",
"w",
".",
"isInfinity",
";",
"boolean",
"wPosOrNeg",
"=",
"w",
".",
"posOrNeg",
";",
"if",
"(",
"(",
"isInfinity",
"&&",
"posOrNeg",
"&&",
"wIsInfinity",
"&&",
"!",
"wPosOrNeg",
")",
"||",
"(",
"isInfinity",
"&&",
"!",
"posOrNeg",
"&&",
"wIsInfinity",
"&&",
"wPosOrNeg",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"+inf - inf!\"",
")",
";",
"}",
"else",
"if",
"(",
"(",
"isInfinity",
"&&",
"posOrNeg",
")",
"||",
"(",
"w",
".",
"isInfinity",
"&&",
"wPosOrNeg",
")",
")",
"{",
"return",
"WeightFactory",
".",
"POS_INFINITY",
";",
"}",
"else",
"if",
"(",
"(",
"isInfinity",
"&&",
"!",
"posOrNeg",
")",
"||",
"(",
"wIsInfinity",
"&&",
"!",
"wPosOrNeg",
")",
")",
"{",
"return",
"WeightFactory",
".",
"NEG_INFINITY",
";",
"}",
"else",
"{",
"return",
"new",
"Weight",
"(",
"val",
"+",
"w",
".",
"val",
")",
";",
"}",
"}",
"}"
] |
Creates a new weight with value equal to the sum of both weights. Note
that +inf and -inf cannot be added. If you try, an
IllegalArgumentException will be thrown.
@param w
a weight.
@return a new weight.
|
[
"Creates",
"a",
"new",
"weight",
"with",
"value",
"equal",
"to",
"the",
"sum",
"of",
"both",
"weights",
".",
"Note",
"that",
"+",
"inf",
"and",
"-",
"inf",
"cannot",
"be",
"added",
".",
"If",
"you",
"try",
"an",
"IllegalArgumentException",
"will",
"be",
"thrown",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L206-L223
|
149,083
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.max
|
public static Weight max(Weight w1, Weight w2) {
if (w1 == null) {
throw new IllegalArgumentException("Argument w1 cannot be null");
}
if (w2 == null) {
throw new IllegalArgumentException("Argument w2 cannot be null");
}
if ((w1.isInfinity && w1.posOrNeg) || (w2.isInfinity && !w2.posOrNeg)) {
return w1;
} else if ((w2.isInfinity && w2.posOrNeg)
|| (w1.isInfinity && !w1.posOrNeg)) {
return w2;
} else if (w1.val >= w2.val) {
return w1;
} else {
return w2;
}
}
|
java
|
public static Weight max(Weight w1, Weight w2) {
if (w1 == null) {
throw new IllegalArgumentException("Argument w1 cannot be null");
}
if (w2 == null) {
throw new IllegalArgumentException("Argument w2 cannot be null");
}
if ((w1.isInfinity && w1.posOrNeg) || (w2.isInfinity && !w2.posOrNeg)) {
return w1;
} else if ((w2.isInfinity && w2.posOrNeg)
|| (w1.isInfinity && !w1.posOrNeg)) {
return w2;
} else if (w1.val >= w2.val) {
return w1;
} else {
return w2;
}
}
|
[
"public",
"static",
"Weight",
"max",
"(",
"Weight",
"w1",
",",
"Weight",
"w2",
")",
"{",
"if",
"(",
"w1",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument w1 cannot be null\"",
")",
";",
"}",
"if",
"(",
"w2",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Argument w2 cannot be null\"",
")",
";",
"}",
"if",
"(",
"(",
"w1",
".",
"isInfinity",
"&&",
"w1",
".",
"posOrNeg",
")",
"||",
"(",
"w2",
".",
"isInfinity",
"&&",
"!",
"w2",
".",
"posOrNeg",
")",
")",
"{",
"return",
"w1",
";",
"}",
"else",
"if",
"(",
"(",
"w2",
".",
"isInfinity",
"&&",
"w2",
".",
"posOrNeg",
")",
"||",
"(",
"w1",
".",
"isInfinity",
"&&",
"!",
"w1",
".",
"posOrNeg",
")",
")",
"{",
"return",
"w2",
";",
"}",
"else",
"if",
"(",
"w1",
".",
"val",
">=",
"w2",
".",
"val",
")",
"{",
"return",
"w1",
";",
"}",
"else",
"{",
"return",
"w2",
";",
"}",
"}"
] |
Gets the larger of the two given weights.
@param w1
a weight. Cannot be <code>null</code>.
@param w2
a weight. Cannot be <code>null</code>.
@return a weight.
|
[
"Gets",
"the",
"larger",
"of",
"the",
"two",
"given",
"weights",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L280-L297
|
149,084
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/graph/Weight.java
|
Weight.invertSign
|
public Weight invertSign() {
if (isInfinity) {
if (posOrNeg) {
return WeightFactory.NEG_INFINITY;
} else {
return WeightFactory.POS_INFINITY;
}
}
return new Weight(-val);
}
|
java
|
public Weight invertSign() {
if (isInfinity) {
if (posOrNeg) {
return WeightFactory.NEG_INFINITY;
} else {
return WeightFactory.POS_INFINITY;
}
}
return new Weight(-val);
}
|
[
"public",
"Weight",
"invertSign",
"(",
")",
"{",
"if",
"(",
"isInfinity",
")",
"{",
"if",
"(",
"posOrNeg",
")",
"{",
"return",
"WeightFactory",
".",
"NEG_INFINITY",
";",
"}",
"else",
"{",
"return",
"WeightFactory",
".",
"POS_INFINITY",
";",
"}",
"}",
"return",
"new",
"Weight",
"(",
"-",
"val",
")",
";",
"}"
] |
Creates a new weight with the opposite sign.
@return a new <code>Weight</code>.
|
[
"Creates",
"a",
"new",
"weight",
"with",
"the",
"opposite",
"sign",
"."
] |
5a620d1a407c7a5426d1cf17d47b97717cf71634
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/graph/Weight.java#L363-L372
|
149,085
|
jbundle/jcalendarbutton
|
src/main/java/org/jbundle/util/jcalendarbutton/JCalendarButton.java
|
JCalendarButton.actionPerformed
|
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == this)
{
Date dateTarget = this.getTargetDate();
JCalendarPopup popup = JCalendarPopup.createCalendarPopup(this.getDateParam(), dateTarget, this, languageString);
popup.addPropertyChangeListener(this);
}
}
|
java
|
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == this)
{
Date dateTarget = this.getTargetDate();
JCalendarPopup popup = JCalendarPopup.createCalendarPopup(this.getDateParam(), dateTarget, this, languageString);
popup.addPropertyChangeListener(this);
}
}
|
[
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getSource",
"(",
")",
"==",
"this",
")",
"{",
"Date",
"dateTarget",
"=",
"this",
".",
"getTargetDate",
"(",
")",
";",
"JCalendarPopup",
"popup",
"=",
"JCalendarPopup",
".",
"createCalendarPopup",
"(",
"this",
".",
"getDateParam",
"(",
")",
",",
"dateTarget",
",",
"this",
",",
"languageString",
")",
";",
"popup",
".",
"addPropertyChangeListener",
"(",
"this",
")",
";",
"}",
"}"
] |
The user pressed the button, display the JCalendarPopup.
@param e The ActionEvent.
|
[
"The",
"user",
"pressed",
"the",
"button",
"display",
"the",
"JCalendarPopup",
"."
] |
2944e6a0b634b83768d5c0b7b4a2898176421403
|
https://github.com/jbundle/jcalendarbutton/blob/2944e6a0b634b83768d5c0b7b4a2898176421403/src/main/java/org/jbundle/util/jcalendarbutton/JCalendarButton.java#L176-L184
|
149,086
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/SasUtils.java
|
SasUtils.encodeStringToInteger
|
public static BigInteger encodeStringToInteger(String str) {
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
byte[] res;
if ((bytes[0] & 0b1000_0000) >> 7 == 1) {
res = new byte[bytes.length + 1];
res[0] = 0;
System.arraycopy(bytes, 0, res, 1, bytes.length);
} else {
res = bytes;
}
BigInteger r = new BigInteger(res);
assert r.compareTo(BigInteger.ZERO) > 0;
return r;
}
|
java
|
public static BigInteger encodeStringToInteger(String str) {
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
byte[] res;
if ((bytes[0] & 0b1000_0000) >> 7 == 1) {
res = new byte[bytes.length + 1];
res[0] = 0;
System.arraycopy(bytes, 0, res, 1, bytes.length);
} else {
res = bytes;
}
BigInteger r = new BigInteger(res);
assert r.compareTo(BigInteger.ZERO) > 0;
return r;
}
|
[
"public",
"static",
"BigInteger",
"encodeStringToInteger",
"(",
"String",
"str",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"str",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"byte",
"[",
"]",
"res",
";",
"if",
"(",
"(",
"bytes",
"[",
"0",
"]",
"&",
"0b1000_0000",
")",
">>",
"7",
"==",
"1",
")",
"{",
"res",
"=",
"new",
"byte",
"[",
"bytes",
".",
"length",
"+",
"1",
"]",
";",
"res",
"[",
"0",
"]",
"=",
"0",
";",
"System",
".",
"arraycopy",
"(",
"bytes",
",",
"0",
",",
"res",
",",
"1",
",",
"bytes",
".",
"length",
")",
";",
"}",
"else",
"{",
"res",
"=",
"bytes",
";",
"}",
"BigInteger",
"r",
"=",
"new",
"BigInteger",
"(",
"res",
")",
";",
"assert",
"r",
".",
"compareTo",
"(",
"BigInteger",
".",
"ZERO",
")",
">",
"0",
";",
"return",
"r",
";",
"}"
] |
Encode any valid Unicode string to integer.
@param str string to encode as integer.
@return integer representation of the secret string.
|
[
"Encode",
"any",
"valid",
"Unicode",
"string",
"to",
"integer",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/SasUtils.java#L49-L62
|
149,087
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/SasUtils.java
|
SasUtils.generateRandomPrimeGreaterThan
|
public static BigInteger generateRandomPrimeGreaterThan(BigInteger num) {
BigInteger res = BigInteger.ZERO;
while (res.compareTo(num) <= 0) {
res = BigInteger.probablePrime(num.bitLength(), RANDOM);
}
return res;
}
|
java
|
public static BigInteger generateRandomPrimeGreaterThan(BigInteger num) {
BigInteger res = BigInteger.ZERO;
while (res.compareTo(num) <= 0) {
res = BigInteger.probablePrime(num.bitLength(), RANDOM);
}
return res;
}
|
[
"public",
"static",
"BigInteger",
"generateRandomPrimeGreaterThan",
"(",
"BigInteger",
"num",
")",
"{",
"BigInteger",
"res",
"=",
"BigInteger",
".",
"ZERO",
";",
"while",
"(",
"res",
".",
"compareTo",
"(",
"num",
")",
"<=",
"0",
")",
"{",
"res",
"=",
"BigInteger",
".",
"probablePrime",
"(",
"num",
".",
"bitLength",
"(",
")",
",",
"RANDOM",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Generate random probable prime guaranteed to be greater than the number specified.
@param num lower bound for the generated probable prime
@return random probable prime greater than the specified number
|
[
"Generate",
"random",
"probable",
"prime",
"guaranteed",
"to",
"be",
"greater",
"than",
"the",
"number",
"specified",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/SasUtils.java#L96-L102
|
149,088
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/SasUtils.java
|
SasUtils.generateRandomIntegerLessThan
|
public static BigInteger generateRandomIntegerLessThan(BigInteger num) {
BigInteger r = null;
while (r == null || r.compareTo(num) >= 0) {
r = new BigInteger(num.bitLength(), RANDOM);
}
return r;
}
|
java
|
public static BigInteger generateRandomIntegerLessThan(BigInteger num) {
BigInteger r = null;
while (r == null || r.compareTo(num) >= 0) {
r = new BigInteger(num.bitLength(), RANDOM);
}
return r;
}
|
[
"public",
"static",
"BigInteger",
"generateRandomIntegerLessThan",
"(",
"BigInteger",
"num",
")",
"{",
"BigInteger",
"r",
"=",
"null",
";",
"while",
"(",
"r",
"==",
"null",
"||",
"r",
".",
"compareTo",
"(",
"num",
")",
">=",
"0",
")",
"{",
"r",
"=",
"new",
"BigInteger",
"(",
"num",
".",
"bitLength",
"(",
")",
",",
"RANDOM",
")",
";",
"}",
"return",
"r",
";",
"}"
] |
Generate random number guaranteed to be less than the number specified.
@param num upper bound of the generated random number
@return random number guaranteed to be less than the specified number
|
[
"Generate",
"random",
"number",
"guaranteed",
"to",
"be",
"less",
"than",
"the",
"number",
"specified",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/SasUtils.java#L110-L116
|
149,089
|
zmarko/sss
|
src/main/java/rs/in/zivanovic/sss/SasUtils.java
|
SasUtils.generateRandomCoefficients
|
public static BigInteger[] generateRandomCoefficients(int n, BigInteger elementZero, BigInteger prime) {
BigInteger[] res = new BigInteger[n];
res[0] = elementZero;
for (int i = 1; i < n; i++) {
res[i] = SasUtils.generateRandomIntegerLessThan(prime);
}
return res;
}
|
java
|
public static BigInteger[] generateRandomCoefficients(int n, BigInteger elementZero, BigInteger prime) {
BigInteger[] res = new BigInteger[n];
res[0] = elementZero;
for (int i = 1; i < n; i++) {
res[i] = SasUtils.generateRandomIntegerLessThan(prime);
}
return res;
}
|
[
"public",
"static",
"BigInteger",
"[",
"]",
"generateRandomCoefficients",
"(",
"int",
"n",
",",
"BigInteger",
"elementZero",
",",
"BigInteger",
"prime",
")",
"{",
"BigInteger",
"[",
"]",
"res",
"=",
"new",
"BigInteger",
"[",
"n",
"]",
";",
"res",
"[",
"0",
"]",
"=",
"elementZero",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"res",
"[",
"i",
"]",
"=",
"SasUtils",
".",
"generateRandomIntegerLessThan",
"(",
"prime",
")",
";",
"}",
"return",
"res",
";",
"}"
] |
Generate random coefficients for the Shamir's Secret Sharing algorithm. First coefficient is filled with a known
value and the rest of the coefficients are randomly generated, keeping them less than the specified prime.
@param n number of coefficients to generate
@param elementZero value of the first coefficient
@param prime upper bound for randomly generated coefficients
@return array of generated coefficients
|
[
"Generate",
"random",
"coefficients",
"for",
"the",
"Shamir",
"s",
"Secret",
"Sharing",
"algorithm",
".",
"First",
"coefficient",
"is",
"filled",
"with",
"a",
"known",
"value",
"and",
"the",
"rest",
"of",
"the",
"coefficients",
"are",
"randomly",
"generated",
"keeping",
"them",
"less",
"than",
"the",
"specified",
"prime",
"."
] |
a41d9d39ca9a4ca1a2719c441c88e209ffc511f5
|
https://github.com/zmarko/sss/blob/a41d9d39ca9a4ca1a2719c441c88e209ffc511f5/src/main/java/rs/in/zivanovic/sss/SasUtils.java#L127-L134
|
149,090
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java
|
SVGProcessor.loadSVGIconFromUri
|
public static List<SVGPath> loadSVGIconFromUri(final String uri, final Class clazz) throws CouldNotPerformException {
try {
InputStream inputStream = clazz.getResourceAsStream(uri);
if (inputStream == null) {
inputStream = clazz.getClassLoader().getResourceAsStream(uri);
if (inputStream == null) {
throw new NotAvailableException(uri);
}
}
return generateSvgPathList(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
} catch (final Exception ex) {
throw new CouldNotPerformException("Could not load URI[" + uri + "]", ex);
}
}
|
java
|
public static List<SVGPath> loadSVGIconFromUri(final String uri, final Class clazz) throws CouldNotPerformException {
try {
InputStream inputStream = clazz.getResourceAsStream(uri);
if (inputStream == null) {
inputStream = clazz.getClassLoader().getResourceAsStream(uri);
if (inputStream == null) {
throw new NotAvailableException(uri);
}
}
return generateSvgPathList(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
} catch (final Exception ex) {
throw new CouldNotPerformException("Could not load URI[" + uri + "]", ex);
}
}
|
[
"public",
"static",
"List",
"<",
"SVGPath",
">",
"loadSVGIconFromUri",
"(",
"final",
"String",
"uri",
",",
"final",
"Class",
"clazz",
")",
"throws",
"CouldNotPerformException",
"{",
"try",
"{",
"InputStream",
"inputStream",
"=",
"clazz",
".",
"getResourceAsStream",
"(",
"uri",
")",
";",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"inputStream",
"=",
"clazz",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"uri",
")",
";",
"if",
"(",
"inputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"NotAvailableException",
"(",
"uri",
")",
";",
"}",
"}",
"return",
"generateSvgPathList",
"(",
"IOUtils",
".",
"toString",
"(",
"inputStream",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"CouldNotPerformException",
"(",
"\"Could not load URI[\"",
"+",
"uri",
"+",
"\"]\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Method tries to build one or more SVGPaths out of the given uri.
By this the content is interpreted as svg xml and new SVGPath instances are generated for each found path element
@param uri the svg xml file
@return a list of SVGPaths instances where each is representing one found path element
@throws CouldNotPerformException is thrown if the file does not exist or it does not contain any path elements.
|
[
"Method",
"tries",
"to",
"build",
"one",
"or",
"more",
"SVGPaths",
"out",
"of",
"the",
"given",
"uri",
".",
"By",
"this",
"the",
"content",
"is",
"interpreted",
"as",
"svg",
"xml",
"and",
"new",
"SVGPath",
"instances",
"are",
"generated",
"for",
"each",
"found",
"path",
"element"
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java#L59-L73
|
149,091
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java
|
SVGProcessor.loadSVGIconFromFile
|
public static List<SVGPath> loadSVGIconFromFile(final File file) throws CouldNotPerformException {
try {
if (!file.exists()) {
throw new NotAvailableException(file.getAbsolutePath());
}
return generateSvgPathList(FileUtils.readFileToString(file, StandardCharsets.UTF_8));
} catch (final Exception ex) {
throw new CouldNotPerformException("Could not load path File[" + file + "]", ex);
}
}
|
java
|
public static List<SVGPath> loadSVGIconFromFile(final File file) throws CouldNotPerformException {
try {
if (!file.exists()) {
throw new NotAvailableException(file.getAbsolutePath());
}
return generateSvgPathList(FileUtils.readFileToString(file, StandardCharsets.UTF_8));
} catch (final Exception ex) {
throw new CouldNotPerformException("Could not load path File[" + file + "]", ex);
}
}
|
[
"public",
"static",
"List",
"<",
"SVGPath",
">",
"loadSVGIconFromFile",
"(",
"final",
"File",
"file",
")",
"throws",
"CouldNotPerformException",
"{",
"try",
"{",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"NotAvailableException",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"return",
"generateSvgPathList",
"(",
"FileUtils",
".",
"readFileToString",
"(",
"file",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"CouldNotPerformException",
"(",
"\"Could not load path File[\"",
"+",
"file",
"+",
"\"]\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Method tries to build one or more SVGPaths out of the passed file.
By this the file content is interpreted as svg xml and new SVGPath instances are generated for each found path element
@param file the svg xml file
@return a list of SVGPaths instances where each is representing one found path element
@throws CouldNotPerformException is thrown if the file does not exist or it does not contain any path elements.
|
[
"Method",
"tries",
"to",
"build",
"one",
"or",
"more",
"SVGPaths",
"out",
"of",
"the",
"passed",
"file",
".",
"By",
"this",
"the",
"file",
"content",
"is",
"interpreted",
"as",
"svg",
"xml",
"and",
"new",
"SVGPath",
"instances",
"are",
"generated",
"for",
"each",
"found",
"path",
"element"
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java#L85-L94
|
149,092
|
openbase/jul
|
visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java
|
SVGProcessor.parseSVGPath
|
public static List<String> parseSVGPath(final String xml) throws NotAvailableException {
final List<String> pathList = new ArrayList<>();
final Matcher matcher = Pattern.compile(PATH_REGEX_PREFIX).matcher(xml);
while (matcher.find()) {
// add group one of match to collection because the regex only defines one.
pathList.add(matcher.group(1));
}
// fail if no pattern was found.
if (pathList.isEmpty()) {
throw new NotAvailableException("Path");
}
// clear prefix and suffix
return pathList;
}
|
java
|
public static List<String> parseSVGPath(final String xml) throws NotAvailableException {
final List<String> pathList = new ArrayList<>();
final Matcher matcher = Pattern.compile(PATH_REGEX_PREFIX).matcher(xml);
while (matcher.find()) {
// add group one of match to collection because the regex only defines one.
pathList.add(matcher.group(1));
}
// fail if no pattern was found.
if (pathList.isEmpty()) {
throw new NotAvailableException("Path");
}
// clear prefix and suffix
return pathList;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"parseSVGPath",
"(",
"final",
"String",
"xml",
")",
"throws",
"NotAvailableException",
"{",
"final",
"List",
"<",
"String",
">",
"pathList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"Matcher",
"matcher",
"=",
"Pattern",
".",
"compile",
"(",
"PATH_REGEX_PREFIX",
")",
".",
"matcher",
"(",
"xml",
")",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"// add group one of match to collection because the regex only defines one.",
"pathList",
".",
"add",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
";",
"}",
"// fail if no pattern was found.",
"if",
"(",
"pathList",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"NotAvailableException",
"(",
"\"Path\"",
")",
";",
"}",
"// clear prefix and suffix",
"return",
"pathList",
";",
"}"
] |
This method extracts all svg paths out of the given xml string.
Its done by returning all value of each \"d" entry. All additional style definitions are ignored.
@param xml the xml string containing at least one icon path.
@return a list of paths.
@throws NotAvailableException is thrown if no path could be detected.
|
[
"This",
"method",
"extracts",
"all",
"svg",
"paths",
"out",
"of",
"the",
"given",
"xml",
"string",
".",
"Its",
"done",
"by",
"returning",
"all",
"value",
"of",
"each",
"\\",
"d",
"entry",
".",
"All",
"additional",
"style",
"definitions",
"are",
"ignored",
"."
] |
662e98c3a853085e475be54c3be3deb72193c72d
|
https://github.com/openbase/jul/blob/662e98c3a853085e475be54c3be3deb72193c72d/visual/javafx/src/main/java/org/openbase/jul/visual/javafx/geometry/svg/SVGProcessor.java#L106-L120
|
149,093
|
rolfl/MicroBench
|
src/main/java/net/tuis/ubench/UStats.java
|
UStats.formatResults
|
public String formatResults(TimeUnit tUnit) {
double avg = getAverage(tUnit);
double fast = getFastest(tUnit);
double slow = getSlowest(tUnit);
double t95p = get95thPercentile(tUnit);
double t99p = get99thPercentile(tUnit);
int width = Math.max(8, DoubleStream.of(avg, fast, slow, t95p, t99p).mapToObj(d -> String.format("%.4f", d))
.mapToInt(String::length).max().getAsInt());
return String.format("Task %s -> %s: (Unit: %s)\n"
+ " Count : %" + width + "d Average : %" + width + ".4f\n"
+ " Fastest : %" + width + ".4f Slowest : %" + width + ".4f\n"
+ " 95Pctile : %" + width + ".4f 99Pctile : %" + width + ".4f\n"
+ " TimeBlock : %s\n"
+ " Histogram : %s\n",
suite, name, unitName[tUnit.ordinal()],
results.length, avg,
fast, slow,
t95p, t99p,
formatZoneTime(getZoneTimes(10, tUnit)),
formatHisto(getDoublingHistogram()));
}
|
java
|
public String formatResults(TimeUnit tUnit) {
double avg = getAverage(tUnit);
double fast = getFastest(tUnit);
double slow = getSlowest(tUnit);
double t95p = get95thPercentile(tUnit);
double t99p = get99thPercentile(tUnit);
int width = Math.max(8, DoubleStream.of(avg, fast, slow, t95p, t99p).mapToObj(d -> String.format("%.4f", d))
.mapToInt(String::length).max().getAsInt());
return String.format("Task %s -> %s: (Unit: %s)\n"
+ " Count : %" + width + "d Average : %" + width + ".4f\n"
+ " Fastest : %" + width + ".4f Slowest : %" + width + ".4f\n"
+ " 95Pctile : %" + width + ".4f 99Pctile : %" + width + ".4f\n"
+ " TimeBlock : %s\n"
+ " Histogram : %s\n",
suite, name, unitName[tUnit.ordinal()],
results.length, avg,
fast, slow,
t95p, t99p,
formatZoneTime(getZoneTimes(10, tUnit)),
formatHisto(getDoublingHistogram()));
}
|
[
"public",
"String",
"formatResults",
"(",
"TimeUnit",
"tUnit",
")",
"{",
"double",
"avg",
"=",
"getAverage",
"(",
"tUnit",
")",
";",
"double",
"fast",
"=",
"getFastest",
"(",
"tUnit",
")",
";",
"double",
"slow",
"=",
"getSlowest",
"(",
"tUnit",
")",
";",
"double",
"t95p",
"=",
"get95thPercentile",
"(",
"tUnit",
")",
";",
"double",
"t99p",
"=",
"get99thPercentile",
"(",
"tUnit",
")",
";",
"int",
"width",
"=",
"Math",
".",
"max",
"(",
"8",
",",
"DoubleStream",
".",
"of",
"(",
"avg",
",",
"fast",
",",
"slow",
",",
"t95p",
",",
"t99p",
")",
".",
"mapToObj",
"(",
"d",
"->",
"String",
".",
"format",
"(",
"\"%.4f\"",
",",
"d",
")",
")",
".",
"mapToInt",
"(",
"String",
"::",
"length",
")",
".",
"max",
"(",
")",
".",
"getAsInt",
"(",
")",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"Task %s -> %s: (Unit: %s)\\n\"",
"+",
"\" Count : %\"",
"+",
"width",
"+",
"\"d Average : %\"",
"+",
"width",
"+",
"\".4f\\n\"",
"+",
"\" Fastest : %\"",
"+",
"width",
"+",
"\".4f Slowest : %\"",
"+",
"width",
"+",
"\".4f\\n\"",
"+",
"\" 95Pctile : %\"",
"+",
"width",
"+",
"\".4f 99Pctile : %\"",
"+",
"width",
"+",
"\".4f\\n\"",
"+",
"\" TimeBlock : %s\\n\"",
"+",
"\" Histogram : %s\\n\"",
",",
"suite",
",",
"name",
",",
"unitName",
"[",
"tUnit",
".",
"ordinal",
"(",
")",
"]",
",",
"results",
".",
"length",
",",
"avg",
",",
"fast",
",",
"slow",
",",
"t95p",
",",
"t99p",
",",
"formatZoneTime",
"(",
"getZoneTimes",
"(",
"10",
",",
"tUnit",
")",
")",
",",
"formatHisto",
"(",
"getDoublingHistogram",
"(",
")",
")",
")",
";",
"}"
] |
Present the results from this task in a formatted string output.
@param tUnit the units in which to display the times (see {@link UStats#getGoodUnit() } for a suggestion).
@return A string representing the statistics.
@see UStats#getGoodUnit()
|
[
"Present",
"the",
"results",
"from",
"this",
"task",
"in",
"a",
"formatted",
"string",
"output",
"."
] |
f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce
|
https://github.com/rolfl/MicroBench/blob/f2bfa92dacd7ea0d6b8eae4d4fe2975139d317ce/src/main/java/net/tuis/ubench/UStats.java#L442-L463
|
149,094
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java
|
XmlUtil.parseXmlString
|
public static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException {
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setValidating(_validating);
try {
return dbFac.newDocumentBuilder().parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
}
|
java
|
public static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException {
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setValidating(_validating);
try {
return dbFac.newDocumentBuilder().parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
}
|
[
"public",
"static",
"Document",
"parseXmlString",
"(",
"String",
"_xmlStr",
",",
"boolean",
"_validating",
",",
"boolean",
"_namespaceAware",
")",
"throws",
"IOException",
"{",
"DocumentBuilderFactory",
"dbFac",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"dbFac",
".",
"setNamespaceAware",
"(",
"_namespaceAware",
")",
";",
"dbFac",
".",
"setValidating",
"(",
"_validating",
")",
";",
"try",
"{",
"return",
"dbFac",
".",
"newDocumentBuilder",
"(",
")",
".",
"parse",
"(",
"new",
"ByteArrayInputStream",
"(",
"_xmlStr",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"throw",
"_ex",
";",
"}",
"catch",
"(",
"Exception",
"_ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to parse \"",
"+",
"StringUtil",
".",
"abbreviate",
"(",
"_xmlStr",
",",
"500",
")",
",",
"_ex",
")",
";",
"}",
"}"
] |
Read the given string as XML document.
@param _xmlStr xml string
@param _validating boolean
@param _namespaceAware boolean
@return {@link org.w3c.dom.Document}
@throws IOException on error
|
[
"Read",
"the",
"given",
"string",
"as",
"XML",
"document",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java#L112-L127
|
149,095
|
hypfvieh/java-utils
|
src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java
|
XmlUtil.parseXmlStringWithXsdValidation
|
public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException {
if (_errorHandler == null) {
_errorHandler = new XmlErrorHandlers.XmlErrorHandlerQuiet();
}
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setValidating(true);
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
DocumentBuilder builder = dbFac.newDocumentBuilder();
builder.setErrorHandler(_errorHandler);
return builder.parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
}
|
java
|
public static Document parseXmlStringWithXsdValidation(String _xmlStr, boolean _namespaceAware, ErrorHandler _errorHandler) throws IOException {
if (_errorHandler == null) {
_errorHandler = new XmlErrorHandlers.XmlErrorHandlerQuiet();
}
DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
dbFac.setValidating(true);
dbFac.setNamespaceAware(_namespaceAware);
dbFac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
DocumentBuilder builder = dbFac.newDocumentBuilder();
builder.setErrorHandler(_errorHandler);
return builder.parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));
} catch (IOException _ex) {
throw _ex;
} catch (Exception _ex) {
throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
}
}
|
[
"public",
"static",
"Document",
"parseXmlStringWithXsdValidation",
"(",
"String",
"_xmlStr",
",",
"boolean",
"_namespaceAware",
",",
"ErrorHandler",
"_errorHandler",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_errorHandler",
"==",
"null",
")",
"{",
"_errorHandler",
"=",
"new",
"XmlErrorHandlers",
".",
"XmlErrorHandlerQuiet",
"(",
")",
";",
"}",
"DocumentBuilderFactory",
"dbFac",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"dbFac",
".",
"setValidating",
"(",
"true",
")",
";",
"dbFac",
".",
"setNamespaceAware",
"(",
"_namespaceAware",
")",
";",
"dbFac",
".",
"setAttribute",
"(",
"\"http://java.sun.com/xml/jaxp/properties/schemaLanguage\"",
",",
"\"http://www.w3.org/2001/XMLSchema\"",
")",
";",
"try",
"{",
"DocumentBuilder",
"builder",
"=",
"dbFac",
".",
"newDocumentBuilder",
"(",
")",
";",
"builder",
".",
"setErrorHandler",
"(",
"_errorHandler",
")",
";",
"return",
"builder",
".",
"parse",
"(",
"new",
"ByteArrayInputStream",
"(",
"_xmlStr",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"_ex",
")",
"{",
"throw",
"_ex",
";",
"}",
"catch",
"(",
"Exception",
"_ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to parse \"",
"+",
"StringUtil",
".",
"abbreviate",
"(",
"_xmlStr",
",",
"500",
")",
",",
"_ex",
")",
";",
"}",
"}"
] |
Loads XML from string and uses referenced XSD to validate the content.
@param _xmlStr string to validate
@param _namespaceAware take care of namespace
@param _errorHandler e.g. {@link XmlErrorHandlers.XmlErrorHandlerQuiet} or {@link XmlErrorHandlers.XmlErrorHandlerRuntimeException}
@return Document
@throws IOException on error
|
[
"Loads",
"XML",
"from",
"string",
"and",
"uses",
"referenced",
"XSD",
"to",
"validate",
"the",
"content",
"."
] |
407c32d6b485596d4d2b644f5f7fc7a02d0169c6
|
https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/xml/XmlUtil.java#L167-L186
|
149,096
|
googolmo/OkVolley
|
okvolley/src/main/java/im/amomo/volley/OkHttpStack.java
|
OkHttpStack.performRequest
|
@Override
public Response performRequest(Request<?> request,
Map<String, String> additionalHeaders) throws IOException, AuthFailureError {
String url = request.getUrl();
HashMap<String, String> map = new HashMap<String, String>();
map.putAll(request.getHeaders());
map.putAll(additionalHeaders);
if (mUrlRewriter != null) {
String rewritten = mUrlRewriter.rewriteUrl(url);
if (rewritten == null) {
throw new IOException("URL blocked by rewriter: " + url);
}
url = rewritten;
}
com.squareup.okhttp.Request.Builder builder = new com.squareup.okhttp.Request.Builder();
builder.url(url);
for (String headerName : map.keySet()) {
builder.header(headerName, map.get(headerName));
// connection.addRequestProperty(headerName, map.get(headerName));
if (VolleyLog.DEBUG) {
// print header message
VolleyLog.d("RequestHeader: %1$s:%2$s", headerName, map.get(headerName));
}
}
setConnectionParametersForRequest(builder, request);
// Initialize HttpResponse with data from the okhttp.
Response okHttpResponse = mClient.newCall(builder.build()).execute();
int responseCode = okHttpResponse.code();
if (responseCode == -1) {
// -1 is returned by getResponseCode() if the response code could not be retrieved.
// Signal to the caller that something was wrong with the connection.
throw new IOException("Could not retrieve response code from HttpUrlConnection.");
}
return okHttpResponse;
}
|
java
|
@Override
public Response performRequest(Request<?> request,
Map<String, String> additionalHeaders) throws IOException, AuthFailureError {
String url = request.getUrl();
HashMap<String, String> map = new HashMap<String, String>();
map.putAll(request.getHeaders());
map.putAll(additionalHeaders);
if (mUrlRewriter != null) {
String rewritten = mUrlRewriter.rewriteUrl(url);
if (rewritten == null) {
throw new IOException("URL blocked by rewriter: " + url);
}
url = rewritten;
}
com.squareup.okhttp.Request.Builder builder = new com.squareup.okhttp.Request.Builder();
builder.url(url);
for (String headerName : map.keySet()) {
builder.header(headerName, map.get(headerName));
// connection.addRequestProperty(headerName, map.get(headerName));
if (VolleyLog.DEBUG) {
// print header message
VolleyLog.d("RequestHeader: %1$s:%2$s", headerName, map.get(headerName));
}
}
setConnectionParametersForRequest(builder, request);
// Initialize HttpResponse with data from the okhttp.
Response okHttpResponse = mClient.newCall(builder.build()).execute();
int responseCode = okHttpResponse.code();
if (responseCode == -1) {
// -1 is returned by getResponseCode() if the response code could not be retrieved.
// Signal to the caller that something was wrong with the connection.
throw new IOException("Could not retrieve response code from HttpUrlConnection.");
}
return okHttpResponse;
}
|
[
"@",
"Override",
"public",
"Response",
"performRequest",
"(",
"Request",
"<",
"?",
">",
"request",
",",
"Map",
"<",
"String",
",",
"String",
">",
"additionalHeaders",
")",
"throws",
"IOException",
",",
"AuthFailureError",
"{",
"String",
"url",
"=",
"request",
".",
"getUrl",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"map",
".",
"putAll",
"(",
"request",
".",
"getHeaders",
"(",
")",
")",
";",
"map",
".",
"putAll",
"(",
"additionalHeaders",
")",
";",
"if",
"(",
"mUrlRewriter",
"!=",
"null",
")",
"{",
"String",
"rewritten",
"=",
"mUrlRewriter",
".",
"rewriteUrl",
"(",
"url",
")",
";",
"if",
"(",
"rewritten",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"URL blocked by rewriter: \"",
"+",
"url",
")",
";",
"}",
"url",
"=",
"rewritten",
";",
"}",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Request",
".",
"Builder",
"builder",
"=",
"new",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Request",
".",
"Builder",
"(",
")",
";",
"builder",
".",
"url",
"(",
"url",
")",
";",
"for",
"(",
"String",
"headerName",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"builder",
".",
"header",
"(",
"headerName",
",",
"map",
".",
"get",
"(",
"headerName",
")",
")",
";",
"// connection.addRequestProperty(headerName, map.get(headerName));",
"if",
"(",
"VolleyLog",
".",
"DEBUG",
")",
"{",
"// print header message",
"VolleyLog",
".",
"d",
"(",
"\"RequestHeader: %1$s:%2$s\"",
",",
"headerName",
",",
"map",
".",
"get",
"(",
"headerName",
")",
")",
";",
"}",
"}",
"setConnectionParametersForRequest",
"(",
"builder",
",",
"request",
")",
";",
"// Initialize HttpResponse with data from the okhttp.",
"Response",
"okHttpResponse",
"=",
"mClient",
".",
"newCall",
"(",
"builder",
".",
"build",
"(",
")",
")",
".",
"execute",
"(",
")",
";",
"int",
"responseCode",
"=",
"okHttpResponse",
".",
"code",
"(",
")",
";",
"if",
"(",
"responseCode",
"==",
"-",
"1",
")",
"{",
"// -1 is returned by getResponseCode() if the response code could not be retrieved.",
"// Signal to the caller that something was wrong with the connection.",
"throw",
"new",
"IOException",
"(",
"\"Could not retrieve response code from HttpUrlConnection.\"",
")",
";",
"}",
"return",
"okHttpResponse",
";",
"}"
] |
perform the request
@param request request
@param additionalHeaders headers
@return http response
@throws java.io.IOException
@throws com.android.volley.AuthFailureError
|
[
"perform",
"the",
"request"
] |
5c41df7cf1a8156c85e179a3c4af8a1c1485ffec
|
https://github.com/googolmo/OkVolley/blob/5c41df7cf1a8156c85e179a3c4af8a1c1485ffec/okvolley/src/main/java/im/amomo/volley/OkHttpStack.java#L111-L150
|
149,097
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java
|
Utils.encodeRemainingLength
|
static ByteBuf encodeRemainingLength(int value) throws CorruptedFrameException {
if (value > MAX_LENGTH_LIMIT || value < 0) {
throw new CorruptedFrameException("Value should in range 0.." + MAX_LENGTH_LIMIT + " found " + value);
}
ByteBuf encoded = Unpooled.buffer(4);
byte digit;
do {
digit = (byte) (value % 128);
value = value / 128;
// if there are more digits to encode, set the top bit of this digit
if (value > 0) {
digit = (byte) (digit | 0x80);
}
encoded.writeByte(digit);
} while (value > 0);
return encoded;
}
|
java
|
static ByteBuf encodeRemainingLength(int value) throws CorruptedFrameException {
if (value > MAX_LENGTH_LIMIT || value < 0) {
throw new CorruptedFrameException("Value should in range 0.." + MAX_LENGTH_LIMIT + " found " + value);
}
ByteBuf encoded = Unpooled.buffer(4);
byte digit;
do {
digit = (byte) (value % 128);
value = value / 128;
// if there are more digits to encode, set the top bit of this digit
if (value > 0) {
digit = (byte) (digit | 0x80);
}
encoded.writeByte(digit);
} while (value > 0);
return encoded;
}
|
[
"static",
"ByteBuf",
"encodeRemainingLength",
"(",
"int",
"value",
")",
"throws",
"CorruptedFrameException",
"{",
"if",
"(",
"value",
">",
"MAX_LENGTH_LIMIT",
"||",
"value",
"<",
"0",
")",
"{",
"throw",
"new",
"CorruptedFrameException",
"(",
"\"Value should in range 0..\"",
"+",
"MAX_LENGTH_LIMIT",
"+",
"\" found \"",
"+",
"value",
")",
";",
"}",
"ByteBuf",
"encoded",
"=",
"Unpooled",
".",
"buffer",
"(",
"4",
")",
";",
"byte",
"digit",
";",
"do",
"{",
"digit",
"=",
"(",
"byte",
")",
"(",
"value",
"%",
"128",
")",
";",
"value",
"=",
"value",
"/",
"128",
";",
"// if there are more digits to encode, set the top bit of this digit",
"if",
"(",
"value",
">",
"0",
")",
"{",
"digit",
"=",
"(",
"byte",
")",
"(",
"digit",
"|",
"0x80",
")",
";",
"}",
"encoded",
".",
"writeByte",
"(",
"digit",
")",
";",
"}",
"while",
"(",
"value",
">",
"0",
")",
";",
"return",
"encoded",
";",
"}"
] |
Encode the value in the format defined in specification as variable length
array.
@throws IllegalArgumentException if the value is not in the specification bounds
[0..268435455].
|
[
"Encode",
"the",
"value",
"in",
"the",
"format",
"defined",
"in",
"specification",
"as",
"variable",
"length",
"array",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java#L90-L107
|
149,098
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java
|
Utils.decodeString
|
static String decodeString(ByteBuf in) throws UnsupportedEncodingException {
if (in.readableBytes() < 2) {
return null;
}
//int strLen = Utils.readWord(in);
int strLen = in.readUnsignedShort();
if (in.readableBytes() < strLen) {
return null;
}
byte[] strRaw = new byte[strLen];
in.readBytes(strRaw);
return new String(strRaw, "UTF-8");
}
|
java
|
static String decodeString(ByteBuf in) throws UnsupportedEncodingException {
if (in.readableBytes() < 2) {
return null;
}
//int strLen = Utils.readWord(in);
int strLen = in.readUnsignedShort();
if (in.readableBytes() < strLen) {
return null;
}
byte[] strRaw = new byte[strLen];
in.readBytes(strRaw);
return new String(strRaw, "UTF-8");
}
|
[
"static",
"String",
"decodeString",
"(",
"ByteBuf",
"in",
")",
"throws",
"UnsupportedEncodingException",
"{",
"if",
"(",
"in",
".",
"readableBytes",
"(",
")",
"<",
"2",
")",
"{",
"return",
"null",
";",
"}",
"//int strLen = Utils.readWord(in);",
"int",
"strLen",
"=",
"in",
".",
"readUnsignedShort",
"(",
")",
";",
"if",
"(",
"in",
".",
"readableBytes",
"(",
")",
"<",
"strLen",
")",
"{",
"return",
"null",
";",
"}",
"byte",
"[",
"]",
"strRaw",
"=",
"new",
"byte",
"[",
"strLen",
"]",
";",
"in",
".",
"readBytes",
"(",
"strRaw",
")",
";",
"return",
"new",
"String",
"(",
"strRaw",
",",
"\"UTF-8\"",
")",
";",
"}"
] |
Load a string from the given buffer, reading first the two bytes of len
and then the UTF-8 bytes of the string.
@return the decoded string or null if NEED_DATA
|
[
"Load",
"a",
"string",
"from",
"the",
"given",
"buffer",
"reading",
"first",
"the",
"two",
"bytes",
"of",
"len",
"and",
"then",
"the",
"UTF",
"-",
"8",
"bytes",
"of",
"the",
"string",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java#L115-L128
|
149,099
|
kevoree/kevoree-library
|
mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java
|
Utils.encodeString
|
static ByteBuf encodeString(String str) {
ByteBuf out = Unpooled.buffer(2);
byte[] raw;
try {
raw = str.getBytes("UTF-8");
//NB every Java platform has got UTF-8 encoding by default, so this
//exception are never raised.
} catch (UnsupportedEncodingException ex) {
Log.error("", ex);
return null;
}
//Utils.writeWord(out, raw.length);
out.writeShort(raw.length);
out.writeBytes(raw);
return out;
}
|
java
|
static ByteBuf encodeString(String str) {
ByteBuf out = Unpooled.buffer(2);
byte[] raw;
try {
raw = str.getBytes("UTF-8");
//NB every Java platform has got UTF-8 encoding by default, so this
//exception are never raised.
} catch (UnsupportedEncodingException ex) {
Log.error("", ex);
return null;
}
//Utils.writeWord(out, raw.length);
out.writeShort(raw.length);
out.writeBytes(raw);
return out;
}
|
[
"static",
"ByteBuf",
"encodeString",
"(",
"String",
"str",
")",
"{",
"ByteBuf",
"out",
"=",
"Unpooled",
".",
"buffer",
"(",
"2",
")",
";",
"byte",
"[",
"]",
"raw",
";",
"try",
"{",
"raw",
"=",
"str",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
";",
"//NB every Java platform has got UTF-8 encoding by default, so this ",
"//exception are never raised.",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"ex",
")",
"{",
"Log",
".",
"error",
"(",
"\"\"",
",",
"ex",
")",
";",
"return",
"null",
";",
"}",
"//Utils.writeWord(out, raw.length);",
"out",
".",
"writeShort",
"(",
"raw",
".",
"length",
")",
";",
"out",
".",
"writeBytes",
"(",
"raw",
")",
";",
"return",
"out",
";",
"}"
] |
Return the IoBuffer with string encoded as MSB, LSB and UTF-8 encoded
string content.
|
[
"Return",
"the",
"IoBuffer",
"with",
"string",
"encoded",
"as",
"MSB",
"LSB",
"and",
"UTF",
"-",
"8",
"encoded",
"string",
"content",
"."
] |
617460e6c5881902ebc488a31ecdea179024d8f1
|
https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/mqttServer/src/main/java/org/dna/mqtt/moquette/parser/netty/Utils.java#L135-L150
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.