repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
wildfly/wildfly-core
|
protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java
|
AbstractMessageHandler.awaitCompletion
|
@Override
public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException {
"""
Await the completion of all currently active operations.
@param timeout the timeout
@param unit the time unit
@return {@code } false if the timeout was reached and there were still active operations
@throws InterruptedException
"""
long deadline = unit.toMillis(timeout) + System.currentTimeMillis();
lock.lock(); try {
assert shutdown;
while(activeCount != 0) {
long remaining = deadline - System.currentTimeMillis();
if (remaining <= 0) {
break;
}
condition.await(remaining, TimeUnit.MILLISECONDS);
}
boolean allComplete = activeCount == 0;
if (!allComplete) {
ProtocolLogger.ROOT_LOGGER.debugf("ActiveOperation(s) %s have not completed within %d %s", activeRequests.keySet(), timeout, unit);
}
return allComplete;
} finally {
lock.unlock();
}
}
|
java
|
@Override
public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException {
long deadline = unit.toMillis(timeout) + System.currentTimeMillis();
lock.lock(); try {
assert shutdown;
while(activeCount != 0) {
long remaining = deadline - System.currentTimeMillis();
if (remaining <= 0) {
break;
}
condition.await(remaining, TimeUnit.MILLISECONDS);
}
boolean allComplete = activeCount == 0;
if (!allComplete) {
ProtocolLogger.ROOT_LOGGER.debugf("ActiveOperation(s) %s have not completed within %d %s", activeRequests.keySet(), timeout, unit);
}
return allComplete;
} finally {
lock.unlock();
}
}
|
[
"@",
"Override",
"public",
"boolean",
"awaitCompletion",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"long",
"deadline",
"=",
"unit",
".",
"toMillis",
"(",
"timeout",
")",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"assert",
"shutdown",
";",
"while",
"(",
"activeCount",
"!=",
"0",
")",
"{",
"long",
"remaining",
"=",
"deadline",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"if",
"(",
"remaining",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"condition",
".",
"await",
"(",
"remaining",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"boolean",
"allComplete",
"=",
"activeCount",
"==",
"0",
";",
"if",
"(",
"!",
"allComplete",
")",
"{",
"ProtocolLogger",
".",
"ROOT_LOGGER",
".",
"debugf",
"(",
"\"ActiveOperation(s) %s have not completed within %d %s\"",
",",
"activeRequests",
".",
"keySet",
"(",
")",
",",
"timeout",
",",
"unit",
")",
";",
"}",
"return",
"allComplete",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Await the completion of all currently active operations.
@param timeout the timeout
@param unit the time unit
@return {@code } false if the timeout was reached and there were still active operations
@throws InterruptedException
|
[
"Await",
"the",
"completion",
"of",
"all",
"currently",
"active",
"operations",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/AbstractMessageHandler.java#L161-L181
|
m-m-m/util
|
core/src/main/java/net/sf/mmm/util/lang/api/StringTokenizer.java
|
StringTokenizer.containsDelimiter
|
private static boolean containsDelimiter(char[] escape, char[] delimiters) {
"""
This method checks that the given {@code escape} sequence does NOT contain any of the {@code delimiters}.
@param escape is the escape-sequence to check.
@param delimiters are the delimiters that should NOT be contained in {@code escape}.
@return {@code true} if {@code escape} contains a character of {@code delimiters}, {@code false} otherwise.
"""
for (char c : escape) {
for (char d : delimiters) {
if (d == c) {
return true;
}
}
}
return false;
}
|
java
|
private static boolean containsDelimiter(char[] escape, char[] delimiters) {
for (char c : escape) {
for (char d : delimiters) {
if (d == c) {
return true;
}
}
}
return false;
}
|
[
"private",
"static",
"boolean",
"containsDelimiter",
"(",
"char",
"[",
"]",
"escape",
",",
"char",
"[",
"]",
"delimiters",
")",
"{",
"for",
"(",
"char",
"c",
":",
"escape",
")",
"{",
"for",
"(",
"char",
"d",
":",
"delimiters",
")",
"{",
"if",
"(",
"d",
"==",
"c",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
This method checks that the given {@code escape} sequence does NOT contain any of the {@code delimiters}.
@param escape is the escape-sequence to check.
@param delimiters are the delimiters that should NOT be contained in {@code escape}.
@return {@code true} if {@code escape} contains a character of {@code delimiters}, {@code false} otherwise.
|
[
"This",
"method",
"checks",
"that",
"the",
"given",
"{",
"@code",
"escape",
"}",
"sequence",
"does",
"NOT",
"contain",
"any",
"of",
"the",
"{",
"@code",
"delimiters",
"}",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/core/src/main/java/net/sf/mmm/util/lang/api/StringTokenizer.java#L159-L169
|
braintree/browser-switch-android
|
browser-switch/src/main/java/com/braintreepayments/browserswitch/BrowserSwitchFragment.java
|
BrowserSwitchFragment.browserSwitch
|
public void browserSwitch(int requestCode, String url) {
"""
Open a browser or <a href="https://developer.chrome.com/multidevice/android/customtabs">Chrome Custom Tab</a>
with the given url.
@param requestCode the request code used to differentiate requests from one another.
@param url the url to open.
"""
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ChromeCustomTabs.addChromeCustomTabsExtras(mContext, intent);
browserSwitch(requestCode, intent);
}
|
java
|
public void browserSwitch(int requestCode, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ChromeCustomTabs.addChromeCustomTabsExtras(mContext, intent);
browserSwitch(requestCode, intent);
}
|
[
"public",
"void",
"browserSwitch",
"(",
"int",
"requestCode",
",",
"String",
"url",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"Intent",
".",
"ACTION_VIEW",
",",
"Uri",
".",
"parse",
"(",
"url",
")",
")",
".",
"addFlags",
"(",
"Intent",
".",
"FLAG_ACTIVITY_NEW_TASK",
")",
";",
"ChromeCustomTabs",
".",
"addChromeCustomTabsExtras",
"(",
"mContext",
",",
"intent",
")",
";",
"browserSwitch",
"(",
"requestCode",
",",
"intent",
")",
";",
"}"
] |
Open a browser or <a href="https://developer.chrome.com/multidevice/android/customtabs">Chrome Custom Tab</a>
with the given url.
@param requestCode the request code used to differentiate requests from one another.
@param url the url to open.
|
[
"Open",
"a",
"browser",
"or",
"<a",
"href",
"=",
"https",
":",
"//",
"developer",
".",
"chrome",
".",
"com",
"/",
"multidevice",
"/",
"android",
"/",
"customtabs",
">",
"Chrome",
"Custom",
"Tab<",
"/",
"a",
">",
"with",
"the",
"given",
"url",
"."
] |
train
|
https://github.com/braintree/browser-switch-android/blob/d830de21bc732b51e658e7296aad7b9037842a19/browser-switch/src/main/java/com/braintreepayments/browserswitch/BrowserSwitchFragment.java#L102-L109
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java
|
RoaringBitmap.selectRangeWithoutCopy
|
private static Iterator<RoaringBitmap> selectRangeWithoutCopy(final
Iterator<? extends RoaringBitmap> bitmaps,
final long rangeStart, final long rangeEnd) {
"""
Return new iterator with only values from rangeStart (inclusive) to rangeEnd (exclusive)
@param bitmaps bitmaps iterator
@param rangeStart inclusive
@param rangeEnd exclusive
@return new iterator of bitmaps
"""
Iterator<RoaringBitmap> bitmapsIterator;
bitmapsIterator = new Iterator<RoaringBitmap>() {
@Override
public boolean hasNext() {
return bitmaps.hasNext();
}
@Override
public RoaringBitmap next() {
RoaringBitmap next = bitmaps.next();
return selectRangeWithoutCopy(next, rangeStart, rangeEnd);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
};
return bitmapsIterator;
}
|
java
|
private static Iterator<RoaringBitmap> selectRangeWithoutCopy(final
Iterator<? extends RoaringBitmap> bitmaps,
final long rangeStart, final long rangeEnd) {
Iterator<RoaringBitmap> bitmapsIterator;
bitmapsIterator = new Iterator<RoaringBitmap>() {
@Override
public boolean hasNext() {
return bitmaps.hasNext();
}
@Override
public RoaringBitmap next() {
RoaringBitmap next = bitmaps.next();
return selectRangeWithoutCopy(next, rangeStart, rangeEnd);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Remove not supported");
}
};
return bitmapsIterator;
}
|
[
"private",
"static",
"Iterator",
"<",
"RoaringBitmap",
">",
"selectRangeWithoutCopy",
"(",
"final",
"Iterator",
"<",
"?",
"extends",
"RoaringBitmap",
">",
"bitmaps",
",",
"final",
"long",
"rangeStart",
",",
"final",
"long",
"rangeEnd",
")",
"{",
"Iterator",
"<",
"RoaringBitmap",
">",
"bitmapsIterator",
";",
"bitmapsIterator",
"=",
"new",
"Iterator",
"<",
"RoaringBitmap",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"bitmaps",
".",
"hasNext",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"RoaringBitmap",
"next",
"(",
")",
"{",
"RoaringBitmap",
"next",
"=",
"bitmaps",
".",
"next",
"(",
")",
";",
"return",
"selectRangeWithoutCopy",
"(",
"next",
",",
"rangeStart",
",",
"rangeEnd",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"remove",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Remove not supported\"",
")",
";",
"}",
"}",
";",
"return",
"bitmapsIterator",
";",
"}"
] |
Return new iterator with only values from rangeStart (inclusive) to rangeEnd (exclusive)
@param bitmaps bitmaps iterator
@param rangeStart inclusive
@param rangeEnd exclusive
@return new iterator of bitmaps
|
[
"Return",
"new",
"iterator",
"with",
"only",
"values",
"from",
"rangeStart",
"(",
"inclusive",
")",
"to",
"rangeEnd",
"(",
"exclusive",
")"
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L2565-L2587
|
FXMisc/Flowless
|
src/main/java/org/fxmisc/flowless/CellPositioner.java
|
CellPositioner.shiftCellBy
|
public void shiftCellBy(C cell, double delta) {
"""
Moves the given cell's node's "layoutY" value by {@code delta}. See {@link OrientationHelper}'s javadoc for more
explanation on what quoted terms mean.
"""
double y = orientation.minY(cell) + delta;
relocate(cell, 0, y);
}
|
java
|
public void shiftCellBy(C cell, double delta) {
double y = orientation.minY(cell) + delta;
relocate(cell, 0, y);
}
|
[
"public",
"void",
"shiftCellBy",
"(",
"C",
"cell",
",",
"double",
"delta",
")",
"{",
"double",
"y",
"=",
"orientation",
".",
"minY",
"(",
"cell",
")",
"+",
"delta",
";",
"relocate",
"(",
"cell",
",",
"0",
",",
"y",
")",
";",
"}"
] |
Moves the given cell's node's "layoutY" value by {@code delta}. See {@link OrientationHelper}'s javadoc for more
explanation on what quoted terms mean.
|
[
"Moves",
"the",
"given",
"cell",
"s",
"node",
"s",
"layoutY",
"value",
"by",
"{"
] |
train
|
https://github.com/FXMisc/Flowless/blob/dce2269ebafed8f79203d00085af41f06f3083bc/src/main/java/org/fxmisc/flowless/CellPositioner.java#L102-L105
|
google/closure-compiler
|
src/com/google/javascript/jscomp/CheckAccessControls.java
|
CheckAccessControls.shouldEmitDeprecationWarning
|
private boolean shouldEmitDeprecationWarning(NodeTraversal t, Node n) {
"""
Determines whether a deprecation warning should be emitted.
@param t The current traversal.
@param n The node which we are checking.
@param parent The parent of the node which we are checking.
"""
// In the global scope, there are only two kinds of accesses that should
// be flagged for warnings:
// 1) Calls of deprecated functions and methods.
// 2) Instantiations of deprecated classes.
// For now, we just let everything else by.
if (t.inGlobalScope()) {
if (!NodeUtil.isInvocationTarget(n) && !n.isNew()) {
return false;
}
}
return !canAccessDeprecatedTypes(t);
}
|
java
|
private boolean shouldEmitDeprecationWarning(NodeTraversal t, Node n) {
// In the global scope, there are only two kinds of accesses that should
// be flagged for warnings:
// 1) Calls of deprecated functions and methods.
// 2) Instantiations of deprecated classes.
// For now, we just let everything else by.
if (t.inGlobalScope()) {
if (!NodeUtil.isInvocationTarget(n) && !n.isNew()) {
return false;
}
}
return !canAccessDeprecatedTypes(t);
}
|
[
"private",
"boolean",
"shouldEmitDeprecationWarning",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"// In the global scope, there are only two kinds of accesses that should",
"// be flagged for warnings:",
"// 1) Calls of deprecated functions and methods.",
"// 2) Instantiations of deprecated classes.",
"// For now, we just let everything else by.",
"if",
"(",
"t",
".",
"inGlobalScope",
"(",
")",
")",
"{",
"if",
"(",
"!",
"NodeUtil",
".",
"isInvocationTarget",
"(",
"n",
")",
"&&",
"!",
"n",
".",
"isNew",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"!",
"canAccessDeprecatedTypes",
"(",
"t",
")",
";",
"}"
] |
Determines whether a deprecation warning should be emitted.
@param t The current traversal.
@param n The node which we are checking.
@param parent The parent of the node which we are checking.
|
[
"Determines",
"whether",
"a",
"deprecation",
"warning",
"should",
"be",
"emitted",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/CheckAccessControls.java#L1057-L1070
|
omadahealth/CircularBarPager
|
library/src/main/java/com/github/omadahealth/circularbarpager/library/CircularBar.java
|
CircularBar.animateProgress
|
public void animateProgress(int start, int end, int duration) {
"""
Animate the change in progress of this view
@param start The value to start from, between 0-100
@param end The value to set it to, between 0-100
@param duration The the time to run the animation over
"""
List<Boolean> list = new ArrayList<>();
list.add(true);
mCirclePieceFillList = list;
setProgress(0);
AnimatorSet set = new AnimatorSet();
set.playTogether(Glider.glide(Skill.QuadEaseInOut, duration, ObjectAnimator.ofFloat(this, "progress", start, end)));
set.setDuration(duration);
set = addListenersToSet(set);
set.start();
}
|
java
|
public void animateProgress(int start, int end, int duration) {
List<Boolean> list = new ArrayList<>();
list.add(true);
mCirclePieceFillList = list;
setProgress(0);
AnimatorSet set = new AnimatorSet();
set.playTogether(Glider.glide(Skill.QuadEaseInOut, duration, ObjectAnimator.ofFloat(this, "progress", start, end)));
set.setDuration(duration);
set = addListenersToSet(set);
set.start();
}
|
[
"public",
"void",
"animateProgress",
"(",
"int",
"start",
",",
"int",
"end",
",",
"int",
"duration",
")",
"{",
"List",
"<",
"Boolean",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"list",
".",
"add",
"(",
"true",
")",
";",
"mCirclePieceFillList",
"=",
"list",
";",
"setProgress",
"(",
"0",
")",
";",
"AnimatorSet",
"set",
"=",
"new",
"AnimatorSet",
"(",
")",
";",
"set",
".",
"playTogether",
"(",
"Glider",
".",
"glide",
"(",
"Skill",
".",
"QuadEaseInOut",
",",
"duration",
",",
"ObjectAnimator",
".",
"ofFloat",
"(",
"this",
",",
"\"progress\"",
",",
"start",
",",
"end",
")",
")",
")",
";",
"set",
".",
"setDuration",
"(",
"duration",
")",
";",
"set",
"=",
"addListenersToSet",
"(",
"set",
")",
";",
"set",
".",
"start",
"(",
")",
";",
"}"
] |
Animate the change in progress of this view
@param start The value to start from, between 0-100
@param end The value to set it to, between 0-100
@param duration The the time to run the animation over
|
[
"Animate",
"the",
"change",
"in",
"progress",
"of",
"this",
"view"
] |
train
|
https://github.com/omadahealth/CircularBarPager/blob/3a43e8828849da727fd13345e83b8432f7271155/library/src/main/java/com/github/omadahealth/circularbarpager/library/CircularBar.java#L602-L612
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Frame.java
|
Frame.getInstanceSlot
|
public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException {
"""
Get the slot the object instance referred to by given instruction is
located in.
@param ins
the Instruction
@param cpg
the ConstantPoolGen for the method
@return stack slot the object instance is in
@throws DataflowAnalysisException
"""
if (!isValid()) {
throw new DataflowAnalysisException("Accessing invalid frame at " + ins);
}
int numConsumed = ins.consumeStack(cpg);
if (numConsumed == Const.UNPREDICTABLE) {
throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins);
}
if (numConsumed > getStackDepth()) {
throw new DataflowAnalysisException("Stack underflow " + ins);
}
return getNumSlots() - numConsumed;
}
|
java
|
public int getInstanceSlot(Instruction ins, ConstantPoolGen cpg) throws DataflowAnalysisException {
if (!isValid()) {
throw new DataflowAnalysisException("Accessing invalid frame at " + ins);
}
int numConsumed = ins.consumeStack(cpg);
if (numConsumed == Const.UNPREDICTABLE) {
throw new DataflowAnalysisException("Unpredictable stack consumption in " + ins);
}
if (numConsumed > getStackDepth()) {
throw new DataflowAnalysisException("Stack underflow " + ins);
}
return getNumSlots() - numConsumed;
}
|
[
"public",
"int",
"getInstanceSlot",
"(",
"Instruction",
"ins",
",",
"ConstantPoolGen",
"cpg",
")",
"throws",
"DataflowAnalysisException",
"{",
"if",
"(",
"!",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"DataflowAnalysisException",
"(",
"\"Accessing invalid frame at \"",
"+",
"ins",
")",
";",
"}",
"int",
"numConsumed",
"=",
"ins",
".",
"consumeStack",
"(",
"cpg",
")",
";",
"if",
"(",
"numConsumed",
"==",
"Const",
".",
"UNPREDICTABLE",
")",
"{",
"throw",
"new",
"DataflowAnalysisException",
"(",
"\"Unpredictable stack consumption in \"",
"+",
"ins",
")",
";",
"}",
"if",
"(",
"numConsumed",
">",
"getStackDepth",
"(",
")",
")",
"{",
"throw",
"new",
"DataflowAnalysisException",
"(",
"\"Stack underflow \"",
"+",
"ins",
")",
";",
"}",
"return",
"getNumSlots",
"(",
")",
"-",
"numConsumed",
";",
"}"
] |
Get the slot the object instance referred to by given instruction is
located in.
@param ins
the Instruction
@param cpg
the ConstantPoolGen for the method
@return stack slot the object instance is in
@throws DataflowAnalysisException
|
[
"Get",
"the",
"slot",
"the",
"object",
"instance",
"referred",
"to",
"by",
"given",
"instruction",
"is",
"located",
"in",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Frame.java#L324-L336
|
spring-projects/spring-retry
|
src/main/java/org/springframework/classify/SubclassClassifier.java
|
SubclassClassifier.setTypeMap
|
public void setTypeMap(Map<Class<? extends T>, C> map) {
"""
Set the classifications up as a map. The keys are types and these will be mapped
along with all their subclasses to the corresponding value. The most specific types
will match first.
@param map a map from type to class
"""
this.classified = new ConcurrentHashMap<Class<? extends T>, C>(map);
}
|
java
|
public void setTypeMap(Map<Class<? extends T>, C> map) {
this.classified = new ConcurrentHashMap<Class<? extends T>, C>(map);
}
|
[
"public",
"void",
"setTypeMap",
"(",
"Map",
"<",
"Class",
"<",
"?",
"extends",
"T",
">",
",",
"C",
">",
"map",
")",
"{",
"this",
".",
"classified",
"=",
"new",
"ConcurrentHashMap",
"<",
"Class",
"<",
"?",
"extends",
"T",
">",
",",
"C",
">",
"(",
"map",
")",
";",
"}"
] |
Set the classifications up as a map. The keys are types and these will be mapped
along with all their subclasses to the corresponding value. The most specific types
will match first.
@param map a map from type to class
|
[
"Set",
"the",
"classifications",
"up",
"as",
"a",
"map",
".",
"The",
"keys",
"are",
"types",
"and",
"these",
"will",
"be",
"mapped",
"along",
"with",
"all",
"their",
"subclasses",
"to",
"the",
"corresponding",
"value",
".",
"The",
"most",
"specific",
"types",
"will",
"match",
"first",
"."
] |
train
|
https://github.com/spring-projects/spring-retry/blob/e2b0555f96594c2321990d0deeac45fc44d4f123/src/main/java/org/springframework/classify/SubclassClassifier.java#L84-L86
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/core/TraceNLSHelper.java
|
TraceNLSHelper.getFormattedMessage
|
public String getFormattedMessage(String key, Object[] args, String defaultString) {
"""
Look for a translated message using the input key. If it is not found, then
the provided default string is returned.
@param key
@param args
@param defaultString
@return String
"""
if (tnls != null)
return tnls.getFormattedMessage(key, args, defaultString);
return defaultString;
}
|
java
|
public String getFormattedMessage(String key, Object[] args, String defaultString) {
if (tnls != null)
return tnls.getFormattedMessage(key, args, defaultString);
return defaultString;
}
|
[
"public",
"String",
"getFormattedMessage",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"args",
",",
"String",
"defaultString",
")",
"{",
"if",
"(",
"tnls",
"!=",
"null",
")",
"return",
"tnls",
".",
"getFormattedMessage",
"(",
"key",
",",
"args",
",",
"defaultString",
")",
";",
"return",
"defaultString",
";",
"}"
] |
Look for a translated message using the input key. If it is not found, then
the provided default string is returned.
@param key
@param args
@param defaultString
@return String
|
[
"Look",
"for",
"a",
"translated",
"message",
"using",
"the",
"input",
"key",
".",
"If",
"it",
"is",
"not",
"found",
"then",
"the",
"provided",
"default",
"string",
"is",
"returned",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ssl/src/com/ibm/ws/ssl/core/TraceNLSHelper.java#L68-L73
|
rampatra/jbot
|
jbot/src/main/java/me/ramswaroop/jbot/core/facebook/Bot.java
|
Bot.startConversation
|
protected final void startConversation(Event event, String methodName) {
"""
Call this method to start a conversation.
@param event received from facebook
"""
startConversation(event.getSender().getId(), methodName);
}
|
java
|
protected final void startConversation(Event event, String methodName) {
startConversation(event.getSender().getId(), methodName);
}
|
[
"protected",
"final",
"void",
"startConversation",
"(",
"Event",
"event",
",",
"String",
"methodName",
")",
"{",
"startConversation",
"(",
"event",
".",
"getSender",
"(",
")",
".",
"getId",
"(",
")",
",",
"methodName",
")",
";",
"}"
] |
Call this method to start a conversation.
@param event received from facebook
|
[
"Call",
"this",
"method",
"to",
"start",
"a",
"conversation",
"."
] |
train
|
https://github.com/rampatra/jbot/blob/0f42e1a6ec4dcbc5d1257e1307704903e771f7b5/jbot/src/main/java/me/ramswaroop/jbot/core/facebook/Bot.java#L229-L231
|
xcesco/kripton
|
kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/ManagedPropertyPersistenceHelper.java
|
ManagedPropertyPersistenceHelper.generateFieldSerialize
|
public static void generateFieldSerialize(BindTypeContext context, PersistType persistType, BindProperty property, Modifier... modifiers) {
"""
generates code to manage field serialization.
@param context the context
@param persistType the persist type
@param property the property
@param modifiers the modifiers
"""
Converter<String, String> format = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_CAMEL);
String methodName = "serialize" + format.convert(property.getName());
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(methodName).addJavadoc("for attribute $L serialization\n", property.getName()).addParameter(ParameterSpec.builder(typeName(property.getElement()), "value").build())
.addModifiers(modifiers);
switch (persistType) {
case STRING:
methodBuilder.returns(className(String.class));
break;
case BYTE:
methodBuilder.returns(TypeUtility.arrayTypeName(Byte.TYPE));
break;
}
// if property type is byte[], return directly the value
if (ArrayTypeName.of(Byte.TYPE).equals(property.getPropertyType().getTypeName()) && persistType == PersistType.BYTE) {
methodBuilder.addStatement("return value");
} else {
methodBuilder.beginControlFlow("if (value==null)");
methodBuilder.addStatement("return null");
methodBuilder.endControlFlow();
methodBuilder.addStatement("$T context=$T.jsonBind()", KriptonJsonContext.class, KriptonBinder.class);
methodBuilder.beginControlFlow("try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))", KriptonByteArrayOutputStream.class, KriptonByteArrayOutputStream.class,
JacksonWrapperSerializer.class);
methodBuilder.addStatement("$T jacksonSerializer=wrapper.jacksonGenerator", JsonGenerator.class);
if (!property.isBindedObject()) {
methodBuilder.addStatement("jacksonSerializer.writeStartObject()");
}
methodBuilder.addStatement("int fieldCount=0");
BindTransform bindTransform = BindTransformer.lookup(property);
String serializerName = "jacksonSerializer";
bindTransform.generateSerializeOnJackson(context, methodBuilder, serializerName, null, "value", property);
if (!property.isBindedObject()) {
methodBuilder.addStatement("jacksonSerializer.writeEndObject()");
}
methodBuilder.addStatement("jacksonSerializer.flush()");
switch (persistType) {
case STRING:
methodBuilder.addStatement("return stream.toString()");
break;
case BYTE:
methodBuilder.addStatement("return stream.toByteArray()");
break;
}
methodBuilder.nextControlFlow("catch($T e)", Exception.class);
methodBuilder.addStatement("throw(new $T(e.getMessage()))", KriptonRuntimeException.class);
methodBuilder.endControlFlow();
}
context.builder.addMethod(methodBuilder.build());
}
|
java
|
public static void generateFieldSerialize(BindTypeContext context, PersistType persistType, BindProperty property, Modifier... modifiers) {
Converter<String, String> format = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_CAMEL);
String methodName = "serialize" + format.convert(property.getName());
MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(methodName).addJavadoc("for attribute $L serialization\n", property.getName()).addParameter(ParameterSpec.builder(typeName(property.getElement()), "value").build())
.addModifiers(modifiers);
switch (persistType) {
case STRING:
methodBuilder.returns(className(String.class));
break;
case BYTE:
methodBuilder.returns(TypeUtility.arrayTypeName(Byte.TYPE));
break;
}
// if property type is byte[], return directly the value
if (ArrayTypeName.of(Byte.TYPE).equals(property.getPropertyType().getTypeName()) && persistType == PersistType.BYTE) {
methodBuilder.addStatement("return value");
} else {
methodBuilder.beginControlFlow("if (value==null)");
methodBuilder.addStatement("return null");
methodBuilder.endControlFlow();
methodBuilder.addStatement("$T context=$T.jsonBind()", KriptonJsonContext.class, KriptonBinder.class);
methodBuilder.beginControlFlow("try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))", KriptonByteArrayOutputStream.class, KriptonByteArrayOutputStream.class,
JacksonWrapperSerializer.class);
methodBuilder.addStatement("$T jacksonSerializer=wrapper.jacksonGenerator", JsonGenerator.class);
if (!property.isBindedObject()) {
methodBuilder.addStatement("jacksonSerializer.writeStartObject()");
}
methodBuilder.addStatement("int fieldCount=0");
BindTransform bindTransform = BindTransformer.lookup(property);
String serializerName = "jacksonSerializer";
bindTransform.generateSerializeOnJackson(context, methodBuilder, serializerName, null, "value", property);
if (!property.isBindedObject()) {
methodBuilder.addStatement("jacksonSerializer.writeEndObject()");
}
methodBuilder.addStatement("jacksonSerializer.flush()");
switch (persistType) {
case STRING:
methodBuilder.addStatement("return stream.toString()");
break;
case BYTE:
methodBuilder.addStatement("return stream.toByteArray()");
break;
}
methodBuilder.nextControlFlow("catch($T e)", Exception.class);
methodBuilder.addStatement("throw(new $T(e.getMessage()))", KriptonRuntimeException.class);
methodBuilder.endControlFlow();
}
context.builder.addMethod(methodBuilder.build());
}
|
[
"public",
"static",
"void",
"generateFieldSerialize",
"(",
"BindTypeContext",
"context",
",",
"PersistType",
"persistType",
",",
"BindProperty",
"property",
",",
"Modifier",
"...",
"modifiers",
")",
"{",
"Converter",
"<",
"String",
",",
"String",
">",
"format",
"=",
"CaseFormat",
".",
"LOWER_CAMEL",
".",
"converterTo",
"(",
"CaseFormat",
".",
"UPPER_CAMEL",
")",
";",
"String",
"methodName",
"=",
"\"serialize\"",
"+",
"format",
".",
"convert",
"(",
"property",
".",
"getName",
"(",
")",
")",
";",
"MethodSpec",
".",
"Builder",
"methodBuilder",
"=",
"MethodSpec",
".",
"methodBuilder",
"(",
"methodName",
")",
".",
"addJavadoc",
"(",
"\"for attribute $L serialization\\n\"",
",",
"property",
".",
"getName",
"(",
")",
")",
".",
"addParameter",
"(",
"ParameterSpec",
".",
"builder",
"(",
"typeName",
"(",
"property",
".",
"getElement",
"(",
")",
")",
",",
"\"value\"",
")",
".",
"build",
"(",
")",
")",
".",
"addModifiers",
"(",
"modifiers",
")",
";",
"switch",
"(",
"persistType",
")",
"{",
"case",
"STRING",
":",
"methodBuilder",
".",
"returns",
"(",
"className",
"(",
"String",
".",
"class",
")",
")",
";",
"break",
";",
"case",
"BYTE",
":",
"methodBuilder",
".",
"returns",
"(",
"TypeUtility",
".",
"arrayTypeName",
"(",
"Byte",
".",
"TYPE",
")",
")",
";",
"break",
";",
"}",
"// if property type is byte[], return directly the value",
"if",
"(",
"ArrayTypeName",
".",
"of",
"(",
"Byte",
".",
"TYPE",
")",
".",
"equals",
"(",
"property",
".",
"getPropertyType",
"(",
")",
".",
"getTypeName",
"(",
")",
")",
"&&",
"persistType",
"==",
"PersistType",
".",
"BYTE",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"\"return value\"",
")",
";",
"}",
"else",
"{",
"methodBuilder",
".",
"beginControlFlow",
"(",
"\"if (value==null)\"",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"return null\"",
")",
";",
"methodBuilder",
".",
"endControlFlow",
"(",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"$T context=$T.jsonBind()\"",
",",
"KriptonJsonContext",
".",
"class",
",",
"KriptonBinder",
".",
"class",
")",
";",
"methodBuilder",
".",
"beginControlFlow",
"(",
"\"try ($T stream=new $T(); $T wrapper=context.createSerializer(stream))\"",
",",
"KriptonByteArrayOutputStream",
".",
"class",
",",
"KriptonByteArrayOutputStream",
".",
"class",
",",
"JacksonWrapperSerializer",
".",
"class",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"$T jacksonSerializer=wrapper.jacksonGenerator\"",
",",
"JsonGenerator",
".",
"class",
")",
";",
"if",
"(",
"!",
"property",
".",
"isBindedObject",
"(",
")",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"\"jacksonSerializer.writeStartObject()\"",
")",
";",
"}",
"methodBuilder",
".",
"addStatement",
"(",
"\"int fieldCount=0\"",
")",
";",
"BindTransform",
"bindTransform",
"=",
"BindTransformer",
".",
"lookup",
"(",
"property",
")",
";",
"String",
"serializerName",
"=",
"\"jacksonSerializer\"",
";",
"bindTransform",
".",
"generateSerializeOnJackson",
"(",
"context",
",",
"methodBuilder",
",",
"serializerName",
",",
"null",
",",
"\"value\"",
",",
"property",
")",
";",
"if",
"(",
"!",
"property",
".",
"isBindedObject",
"(",
")",
")",
"{",
"methodBuilder",
".",
"addStatement",
"(",
"\"jacksonSerializer.writeEndObject()\"",
")",
";",
"}",
"methodBuilder",
".",
"addStatement",
"(",
"\"jacksonSerializer.flush()\"",
")",
";",
"switch",
"(",
"persistType",
")",
"{",
"case",
"STRING",
":",
"methodBuilder",
".",
"addStatement",
"(",
"\"return stream.toString()\"",
")",
";",
"break",
";",
"case",
"BYTE",
":",
"methodBuilder",
".",
"addStatement",
"(",
"\"return stream.toByteArray()\"",
")",
";",
"break",
";",
"}",
"methodBuilder",
".",
"nextControlFlow",
"(",
"\"catch($T e)\"",
",",
"Exception",
".",
"class",
")",
";",
"methodBuilder",
".",
"addStatement",
"(",
"\"throw(new $T(e.getMessage()))\"",
",",
"KriptonRuntimeException",
".",
"class",
")",
";",
"methodBuilder",
".",
"endControlFlow",
"(",
")",
";",
"}",
"context",
".",
"builder",
".",
"addMethod",
"(",
"methodBuilder",
".",
"build",
"(",
")",
")",
";",
"}"
] |
generates code to manage field serialization.
@param context the context
@param persistType the persist type
@param property the property
@param modifiers the modifiers
|
[
"generates",
"code",
"to",
"manage",
"field",
"serialization",
"."
] |
train
|
https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/core/ManagedPropertyPersistenceHelper.java#L101-L163
|
lordcodes/SnackbarBuilder
|
snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/callback/SnackbarCallbackWrapper.java
|
SnackbarCallbackWrapper.onDismissed
|
@Override
public void onDismissed(Snackbar snackbar, @DismissEvent int event) {
"""
Notifies that the Snackbar has been dismissed through some means.
@param snackbar The Snackbar which has been dismissed.
@param event The event which caused the dismissal.
"""
if (callback != null) {
callback.onDismissed(snackbar, event);
}
}
|
java
|
@Override
public void onDismissed(Snackbar snackbar, @DismissEvent int event) {
if (callback != null) {
callback.onDismissed(snackbar, event);
}
}
|
[
"@",
"Override",
"public",
"void",
"onDismissed",
"(",
"Snackbar",
"snackbar",
",",
"@",
"DismissEvent",
"int",
"event",
")",
"{",
"if",
"(",
"callback",
"!=",
"null",
")",
"{",
"callback",
".",
"onDismissed",
"(",
"snackbar",
",",
"event",
")",
";",
"}",
"}"
] |
Notifies that the Snackbar has been dismissed through some means.
@param snackbar The Snackbar which has been dismissed.
@param event The event which caused the dismissal.
|
[
"Notifies",
"that",
"the",
"Snackbar",
"has",
"been",
"dismissed",
"through",
"some",
"means",
"."
] |
train
|
https://github.com/lordcodes/SnackbarBuilder/blob/a104a753c78ed66940c19d295e141a521cf81d73/snackbarbuilder/src/main/java/com/github/andrewlord1990/snackbarbuilder/callback/SnackbarCallbackWrapper.java#L45-L50
|
landawn/AbacusUtil
|
src/com/landawn/abacus/util/stream/Stream.java
|
Stream.parallelConcat
|
@SafeVarargs
public static <T> Stream<T> parallelConcat(final Iterator<? extends T>... a) {
"""
Put the stream in try-catch to stop the back-end reading thread if error happens
<br />
<code>
try (Stream<Integer> stream = Stream.parallelConcat(a,b, ...)) {
stream.forEach(N::println);
}
</code>
@param a
@return
"""
return parallelConcat(a, DEFAULT_READING_THREAD_NUM, calculateQueueSize(a.length));
}
|
java
|
@SafeVarargs
public static <T> Stream<T> parallelConcat(final Iterator<? extends T>... a) {
return parallelConcat(a, DEFAULT_READING_THREAD_NUM, calculateQueueSize(a.length));
}
|
[
"@",
"SafeVarargs",
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"parallelConcat",
"(",
"final",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"...",
"a",
")",
"{",
"return",
"parallelConcat",
"(",
"a",
",",
"DEFAULT_READING_THREAD_NUM",
",",
"calculateQueueSize",
"(",
"a",
".",
"length",
")",
")",
";",
"}"
] |
Put the stream in try-catch to stop the back-end reading thread if error happens
<br />
<code>
try (Stream<Integer> stream = Stream.parallelConcat(a,b, ...)) {
stream.forEach(N::println);
}
</code>
@param a
@return
|
[
"Put",
"the",
"stream",
"in",
"try",
"-",
"catch",
"to",
"stop",
"the",
"back",
"-",
"end",
"reading",
"thread",
"if",
"error",
"happens",
"<br",
"/",
">",
"<code",
">",
"try",
"(",
"Stream<Integer",
">",
"stream",
"=",
"Stream",
".",
"parallelConcat",
"(",
"a",
"b",
"...",
"))",
"{",
"stream",
".",
"forEach",
"(",
"N",
"::",
"println",
")",
";",
"}",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/stream/Stream.java#L4156-L4159
|
apache/flink
|
flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java
|
HadoopOutputFormatBase.open
|
@Override
public void open(int taskNumber, int numTasks) throws IOException {
"""
create the temporary output file for hadoop RecordWriter.
@param taskNumber The number of the parallel instance.
@param numTasks The number of parallel tasks.
@throws java.io.IOException
"""
// enforce sequential open() calls
synchronized (OPEN_MUTEX) {
if (Integer.toString(taskNumber + 1).length() > 6) {
throw new IOException("Task id too large.");
}
this.taskNumber = taskNumber + 1;
// for hadoop 2.2
this.configuration.set("mapreduce.output.basename", "tmp");
TaskAttemptID taskAttemptID = TaskAttemptID.forName("attempt__0000_r_"
+ String.format("%" + (6 - Integer.toString(taskNumber + 1).length()) + "s", " ").replace(" ", "0")
+ Integer.toString(taskNumber + 1)
+ "_0");
this.configuration.set("mapred.task.id", taskAttemptID.toString());
this.configuration.setInt("mapred.task.partition", taskNumber + 1);
// for hadoop 2.2
this.configuration.set("mapreduce.task.attempt.id", taskAttemptID.toString());
this.configuration.setInt("mapreduce.task.partition", taskNumber + 1);
try {
this.context = new TaskAttemptContextImpl(this.configuration, taskAttemptID);
this.outputCommitter = this.mapreduceOutputFormat.getOutputCommitter(this.context);
this.outputCommitter.setupJob(new JobContextImpl(this.configuration, new JobID()));
} catch (Exception e) {
throw new RuntimeException(e);
}
this.context.getCredentials().addAll(this.credentials);
Credentials currentUserCreds = getCredentialsFromUGI(UserGroupInformation.getCurrentUser());
if (currentUserCreds != null) {
this.context.getCredentials().addAll(currentUserCreds);
}
// compatible for hadoop 2.2.0, the temporary output directory is different from hadoop 1.2.1
if (outputCommitter instanceof FileOutputCommitter) {
this.configuration.set("mapreduce.task.output.dir", ((FileOutputCommitter) this.outputCommitter).getWorkPath().toString());
}
try {
this.recordWriter = this.mapreduceOutputFormat.getRecordWriter(this.context);
} catch (InterruptedException e) {
throw new IOException("Could not create RecordWriter.", e);
}
}
}
|
java
|
@Override
public void open(int taskNumber, int numTasks) throws IOException {
// enforce sequential open() calls
synchronized (OPEN_MUTEX) {
if (Integer.toString(taskNumber + 1).length() > 6) {
throw new IOException("Task id too large.");
}
this.taskNumber = taskNumber + 1;
// for hadoop 2.2
this.configuration.set("mapreduce.output.basename", "tmp");
TaskAttemptID taskAttemptID = TaskAttemptID.forName("attempt__0000_r_"
+ String.format("%" + (6 - Integer.toString(taskNumber + 1).length()) + "s", " ").replace(" ", "0")
+ Integer.toString(taskNumber + 1)
+ "_0");
this.configuration.set("mapred.task.id", taskAttemptID.toString());
this.configuration.setInt("mapred.task.partition", taskNumber + 1);
// for hadoop 2.2
this.configuration.set("mapreduce.task.attempt.id", taskAttemptID.toString());
this.configuration.setInt("mapreduce.task.partition", taskNumber + 1);
try {
this.context = new TaskAttemptContextImpl(this.configuration, taskAttemptID);
this.outputCommitter = this.mapreduceOutputFormat.getOutputCommitter(this.context);
this.outputCommitter.setupJob(new JobContextImpl(this.configuration, new JobID()));
} catch (Exception e) {
throw new RuntimeException(e);
}
this.context.getCredentials().addAll(this.credentials);
Credentials currentUserCreds = getCredentialsFromUGI(UserGroupInformation.getCurrentUser());
if (currentUserCreds != null) {
this.context.getCredentials().addAll(currentUserCreds);
}
// compatible for hadoop 2.2.0, the temporary output directory is different from hadoop 1.2.1
if (outputCommitter instanceof FileOutputCommitter) {
this.configuration.set("mapreduce.task.output.dir", ((FileOutputCommitter) this.outputCommitter).getWorkPath().toString());
}
try {
this.recordWriter = this.mapreduceOutputFormat.getRecordWriter(this.context);
} catch (InterruptedException e) {
throw new IOException("Could not create RecordWriter.", e);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"open",
"(",
"int",
"taskNumber",
",",
"int",
"numTasks",
")",
"throws",
"IOException",
"{",
"// enforce sequential open() calls",
"synchronized",
"(",
"OPEN_MUTEX",
")",
"{",
"if",
"(",
"Integer",
".",
"toString",
"(",
"taskNumber",
"+",
"1",
")",
".",
"length",
"(",
")",
">",
"6",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Task id too large.\"",
")",
";",
"}",
"this",
".",
"taskNumber",
"=",
"taskNumber",
"+",
"1",
";",
"// for hadoop 2.2",
"this",
".",
"configuration",
".",
"set",
"(",
"\"mapreduce.output.basename\"",
",",
"\"tmp\"",
")",
";",
"TaskAttemptID",
"taskAttemptID",
"=",
"TaskAttemptID",
".",
"forName",
"(",
"\"attempt__0000_r_\"",
"+",
"String",
".",
"format",
"(",
"\"%\"",
"+",
"(",
"6",
"-",
"Integer",
".",
"toString",
"(",
"taskNumber",
"+",
"1",
")",
".",
"length",
"(",
")",
")",
"+",
"\"s\"",
",",
"\" \"",
")",
".",
"replace",
"(",
"\" \"",
",",
"\"0\"",
")",
"+",
"Integer",
".",
"toString",
"(",
"taskNumber",
"+",
"1",
")",
"+",
"\"_0\"",
")",
";",
"this",
".",
"configuration",
".",
"set",
"(",
"\"mapred.task.id\"",
",",
"taskAttemptID",
".",
"toString",
"(",
")",
")",
";",
"this",
".",
"configuration",
".",
"setInt",
"(",
"\"mapred.task.partition\"",
",",
"taskNumber",
"+",
"1",
")",
";",
"// for hadoop 2.2",
"this",
".",
"configuration",
".",
"set",
"(",
"\"mapreduce.task.attempt.id\"",
",",
"taskAttemptID",
".",
"toString",
"(",
")",
")",
";",
"this",
".",
"configuration",
".",
"setInt",
"(",
"\"mapreduce.task.partition\"",
",",
"taskNumber",
"+",
"1",
")",
";",
"try",
"{",
"this",
".",
"context",
"=",
"new",
"TaskAttemptContextImpl",
"(",
"this",
".",
"configuration",
",",
"taskAttemptID",
")",
";",
"this",
".",
"outputCommitter",
"=",
"this",
".",
"mapreduceOutputFormat",
".",
"getOutputCommitter",
"(",
"this",
".",
"context",
")",
";",
"this",
".",
"outputCommitter",
".",
"setupJob",
"(",
"new",
"JobContextImpl",
"(",
"this",
".",
"configuration",
",",
"new",
"JobID",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"this",
".",
"context",
".",
"getCredentials",
"(",
")",
".",
"addAll",
"(",
"this",
".",
"credentials",
")",
";",
"Credentials",
"currentUserCreds",
"=",
"getCredentialsFromUGI",
"(",
"UserGroupInformation",
".",
"getCurrentUser",
"(",
")",
")",
";",
"if",
"(",
"currentUserCreds",
"!=",
"null",
")",
"{",
"this",
".",
"context",
".",
"getCredentials",
"(",
")",
".",
"addAll",
"(",
"currentUserCreds",
")",
";",
"}",
"// compatible for hadoop 2.2.0, the temporary output directory is different from hadoop 1.2.1",
"if",
"(",
"outputCommitter",
"instanceof",
"FileOutputCommitter",
")",
"{",
"this",
".",
"configuration",
".",
"set",
"(",
"\"mapreduce.task.output.dir\"",
",",
"(",
"(",
"FileOutputCommitter",
")",
"this",
".",
"outputCommitter",
")",
".",
"getWorkPath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"try",
"{",
"this",
".",
"recordWriter",
"=",
"this",
".",
"mapreduceOutputFormat",
".",
"getRecordWriter",
"(",
"this",
".",
"context",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not create RecordWriter.\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
create the temporary output file for hadoop RecordWriter.
@param taskNumber The number of the parallel instance.
@param numTasks The number of parallel tasks.
@throws java.io.IOException
|
[
"create",
"the",
"temporary",
"output",
"file",
"for",
"hadoop",
"RecordWriter",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java#L104-L154
|
lightblueseas/swing-components
|
src/main/java/de/alpharogroup/swing/dialog/factories/JDialogFactory.java
|
JDialogFactory.newJDialog
|
public static JDialog newJDialog(@NonNull JOptionPane pane, String title) {
"""
Factory method for create a {@link JDialog} object over the given {@link JOptionPane}
@param pane
the pane
@param title
the title
@return the new {@link JDialog}
"""
return newJDialog(null, pane, title);
}
|
java
|
public static JDialog newJDialog(@NonNull JOptionPane pane, String title)
{
return newJDialog(null, pane, title);
}
|
[
"public",
"static",
"JDialog",
"newJDialog",
"(",
"@",
"NonNull",
"JOptionPane",
"pane",
",",
"String",
"title",
")",
"{",
"return",
"newJDialog",
"(",
"null",
",",
"pane",
",",
"title",
")",
";",
"}"
] |
Factory method for create a {@link JDialog} object over the given {@link JOptionPane}
@param pane
the pane
@param title
the title
@return the new {@link JDialog}
|
[
"Factory",
"method",
"for",
"create",
"a",
"{",
"@link",
"JDialog",
"}",
"object",
"over",
"the",
"given",
"{",
"@link",
"JOptionPane",
"}"
] |
train
|
https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/dialog/factories/JDialogFactory.java#L113-L116
|
alkacon/opencms-core
|
src/org/opencms/db/CmsSubscriptionManager.java
|
CmsSubscriptionManager.getDateLastVisitedBy
|
public long getDateLastVisitedBy(CmsObject cms, CmsUser user, String resourcePath) throws CmsException {
"""
Returns the date when the resource was last visited by the user.<p>
@param cms the current users context
@param user the user to check the date
@param resourcePath the name of the resource to check the date
@return the date when the resource was last visited by the user
@throws CmsException if something goes wrong
"""
CmsResource resource = cms.readResource(resourcePath, CmsResourceFilter.ALL);
return m_securityManager.getDateLastVisitedBy(cms.getRequestContext(), getPoolName(), user, resource);
}
|
java
|
public long getDateLastVisitedBy(CmsObject cms, CmsUser user, String resourcePath) throws CmsException {
CmsResource resource = cms.readResource(resourcePath, CmsResourceFilter.ALL);
return m_securityManager.getDateLastVisitedBy(cms.getRequestContext(), getPoolName(), user, resource);
}
|
[
"public",
"long",
"getDateLastVisitedBy",
"(",
"CmsObject",
"cms",
",",
"CmsUser",
"user",
",",
"String",
"resourcePath",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"resource",
"=",
"cms",
".",
"readResource",
"(",
"resourcePath",
",",
"CmsResourceFilter",
".",
"ALL",
")",
";",
"return",
"m_securityManager",
".",
"getDateLastVisitedBy",
"(",
"cms",
".",
"getRequestContext",
"(",
")",
",",
"getPoolName",
"(",
")",
",",
"user",
",",
"resource",
")",
";",
"}"
] |
Returns the date when the resource was last visited by the user.<p>
@param cms the current users context
@param user the user to check the date
@param resourcePath the name of the resource to check the date
@return the date when the resource was last visited by the user
@throws CmsException if something goes wrong
|
[
"Returns",
"the",
"date",
"when",
"the",
"resource",
"was",
"last",
"visited",
"by",
"the",
"user",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSubscriptionManager.java#L106-L110
|
treelogic-swe/aws-mock
|
example/java/full/client-usage/StopInstancesExample.java
|
StopInstancesExample.stopInstances
|
public static List<InstanceStateChange> stopInstances(final List<String> instanceIDs) {
"""
Stop specified instances (power-on the instances).
@param instanceIDs
IDs of the instances to stop
@return a list of state changes for the instances
"""
// pass any credentials as aws-mock does not authenticate them at all
AWSCredentials credentials = new BasicAWSCredentials("foo", "bar");
AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials);
// the mock endpoint for ec2 which runs on your computer
String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/";
amazonEC2Client.setEndpoint(ec2Endpoint);
// send the stop request with args as instance IDs to stop running instances
StopInstancesRequest request = new StopInstancesRequest();
request.withInstanceIds(instanceIDs);
StopInstancesResult result = amazonEC2Client.stopInstances(request);
return result.getStoppingInstances();
}
|
java
|
public static List<InstanceStateChange> stopInstances(final List<String> instanceIDs) {
// pass any credentials as aws-mock does not authenticate them at all
AWSCredentials credentials = new BasicAWSCredentials("foo", "bar");
AmazonEC2Client amazonEC2Client = new AmazonEC2Client(credentials);
// the mock endpoint for ec2 which runs on your computer
String ec2Endpoint = "http://localhost:8000/aws-mock/ec2-endpoint/";
amazonEC2Client.setEndpoint(ec2Endpoint);
// send the stop request with args as instance IDs to stop running instances
StopInstancesRequest request = new StopInstancesRequest();
request.withInstanceIds(instanceIDs);
StopInstancesResult result = amazonEC2Client.stopInstances(request);
return result.getStoppingInstances();
}
|
[
"public",
"static",
"List",
"<",
"InstanceStateChange",
">",
"stopInstances",
"(",
"final",
"List",
"<",
"String",
">",
"instanceIDs",
")",
"{",
"// pass any credentials as aws-mock does not authenticate them at all",
"AWSCredentials",
"credentials",
"=",
"new",
"BasicAWSCredentials",
"(",
"\"foo\"",
",",
"\"bar\"",
")",
";",
"AmazonEC2Client",
"amazonEC2Client",
"=",
"new",
"AmazonEC2Client",
"(",
"credentials",
")",
";",
"// the mock endpoint for ec2 which runs on your computer",
"String",
"ec2Endpoint",
"=",
"\"http://localhost:8000/aws-mock/ec2-endpoint/\"",
";",
"amazonEC2Client",
".",
"setEndpoint",
"(",
"ec2Endpoint",
")",
";",
"// send the stop request with args as instance IDs to stop running instances",
"StopInstancesRequest",
"request",
"=",
"new",
"StopInstancesRequest",
"(",
")",
";",
"request",
".",
"withInstanceIds",
"(",
"instanceIDs",
")",
";",
"StopInstancesResult",
"result",
"=",
"amazonEC2Client",
".",
"stopInstances",
"(",
"request",
")",
";",
"return",
"result",
".",
"getStoppingInstances",
"(",
")",
";",
"}"
] |
Stop specified instances (power-on the instances).
@param instanceIDs
IDs of the instances to stop
@return a list of state changes for the instances
|
[
"Stop",
"specified",
"instances",
"(",
"power",
"-",
"on",
"the",
"instances",
")",
"."
] |
train
|
https://github.com/treelogic-swe/aws-mock/blob/1d1058c0ebbd0615efa28695481e36ae3ffc58a0/example/java/full/client-usage/StopInstancesExample.java#L33-L48
|
threerings/narya
|
core/src/main/java/com/threerings/presents/dobj/DObject.java
|
DObject.requestElementUpdate
|
protected void requestElementUpdate (String name, int index, Object value, Object oldValue) {
"""
Called by derived instances when an element updater method was called.
"""
requestElementUpdate(name, index, value, oldValue, Transport.DEFAULT);
}
|
java
|
protected void requestElementUpdate (String name, int index, Object value, Object oldValue)
{
requestElementUpdate(name, index, value, oldValue, Transport.DEFAULT);
}
|
[
"protected",
"void",
"requestElementUpdate",
"(",
"String",
"name",
",",
"int",
"index",
",",
"Object",
"value",
",",
"Object",
"oldValue",
")",
"{",
"requestElementUpdate",
"(",
"name",
",",
"index",
",",
"value",
",",
"oldValue",
",",
"Transport",
".",
"DEFAULT",
")",
";",
"}"
] |
Called by derived instances when an element updater method was called.
|
[
"Called",
"by",
"derived",
"instances",
"when",
"an",
"element",
"updater",
"method",
"was",
"called",
"."
] |
train
|
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L832-L835
|
netty/netty
|
common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java
|
NativeLibraryLoader.loadFirstAvailable
|
public static void loadFirstAvailable(ClassLoader loader, String... names) {
"""
Loads the first available library in the collection with the specified
{@link ClassLoader}.
@throws IllegalArgumentException
if none of the given libraries load successfully.
"""
List<Throwable> suppressed = new ArrayList<Throwable>();
for (String name : names) {
try {
load(name, loader);
return;
} catch (Throwable t) {
suppressed.add(t);
logger.debug("Unable to load the library '{}', trying next name...", name, t);
}
}
IllegalArgumentException iae =
new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names));
ThrowableUtil.addSuppressedAndClear(iae, suppressed);
throw iae;
}
|
java
|
public static void loadFirstAvailable(ClassLoader loader, String... names) {
List<Throwable> suppressed = new ArrayList<Throwable>();
for (String name : names) {
try {
load(name, loader);
return;
} catch (Throwable t) {
suppressed.add(t);
logger.debug("Unable to load the library '{}', trying next name...", name, t);
}
}
IllegalArgumentException iae =
new IllegalArgumentException("Failed to load any of the given libraries: " + Arrays.toString(names));
ThrowableUtil.addSuppressedAndClear(iae, suppressed);
throw iae;
}
|
[
"public",
"static",
"void",
"loadFirstAvailable",
"(",
"ClassLoader",
"loader",
",",
"String",
"...",
"names",
")",
"{",
"List",
"<",
"Throwable",
">",
"suppressed",
"=",
"new",
"ArrayList",
"<",
"Throwable",
">",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"try",
"{",
"load",
"(",
"name",
",",
"loader",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"suppressed",
".",
"add",
"(",
"t",
")",
";",
"logger",
".",
"debug",
"(",
"\"Unable to load the library '{}', trying next name...\"",
",",
"name",
",",
"t",
")",
";",
"}",
"}",
"IllegalArgumentException",
"iae",
"=",
"new",
"IllegalArgumentException",
"(",
"\"Failed to load any of the given libraries: \"",
"+",
"Arrays",
".",
"toString",
"(",
"names",
")",
")",
";",
"ThrowableUtil",
".",
"addSuppressedAndClear",
"(",
"iae",
",",
"suppressed",
")",
";",
"throw",
"iae",
";",
"}"
] |
Loads the first available library in the collection with the specified
{@link ClassLoader}.
@throws IllegalArgumentException
if none of the given libraries load successfully.
|
[
"Loads",
"the",
"first",
"available",
"library",
"in",
"the",
"collection",
"with",
"the",
"specified",
"{",
"@link",
"ClassLoader",
"}",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java#L92-L107
|
apereo/cas
|
support/cas-server-support-openid/src/main/java/org/apereo/cas/web/DelegatingController.java
|
DelegatingController.generateErrorView
|
private ModelAndView generateErrorView(final String code, final Object[] args) {
"""
Generate error view based on {@link #setFailureView(String)}.
@param code the code
@param args the args
@return the model and view
"""
val modelAndView = new ModelAndView(this.failureView);
val convertedDescription = getMessageSourceAccessor().getMessage(code, args, code);
modelAndView.addObject("code", StringEscapeUtils.escapeHtml4(code));
modelAndView.addObject("description", StringEscapeUtils.escapeHtml4(convertedDescription));
return modelAndView;
}
|
java
|
private ModelAndView generateErrorView(final String code, final Object[] args) {
val modelAndView = new ModelAndView(this.failureView);
val convertedDescription = getMessageSourceAccessor().getMessage(code, args, code);
modelAndView.addObject("code", StringEscapeUtils.escapeHtml4(code));
modelAndView.addObject("description", StringEscapeUtils.escapeHtml4(convertedDescription));
return modelAndView;
}
|
[
"private",
"ModelAndView",
"generateErrorView",
"(",
"final",
"String",
"code",
",",
"final",
"Object",
"[",
"]",
"args",
")",
"{",
"val",
"modelAndView",
"=",
"new",
"ModelAndView",
"(",
"this",
".",
"failureView",
")",
";",
"val",
"convertedDescription",
"=",
"getMessageSourceAccessor",
"(",
")",
".",
"getMessage",
"(",
"code",
",",
"args",
",",
"code",
")",
";",
"modelAndView",
".",
"addObject",
"(",
"\"code\"",
",",
"StringEscapeUtils",
".",
"escapeHtml4",
"(",
"code",
")",
")",
";",
"modelAndView",
".",
"addObject",
"(",
"\"description\"",
",",
"StringEscapeUtils",
".",
"escapeHtml4",
"(",
"convertedDescription",
")",
")",
";",
"return",
"modelAndView",
";",
"}"
] |
Generate error view based on {@link #setFailureView(String)}.
@param code the code
@param args the args
@return the model and view
|
[
"Generate",
"error",
"view",
"based",
"on",
"{",
"@link",
"#setFailureView",
"(",
"String",
")",
"}",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-openid/src/main/java/org/apereo/cas/web/DelegatingController.java#L66-L72
|
Azure/azure-sdk-for-java
|
logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountsInner.java
|
IntegrationAccountsInner.getCallbackUrlAsync
|
public Observable<CallbackUrlInner> getCallbackUrlAsync(String resourceGroupName, String integrationAccountName, GetCallbackUrlParameters parameters) {
"""
Gets the integration account callback URL.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param parameters The callback URL parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CallbackUrlInner object
"""
return getCallbackUrlWithServiceResponseAsync(resourceGroupName, integrationAccountName, parameters).map(new Func1<ServiceResponse<CallbackUrlInner>, CallbackUrlInner>() {
@Override
public CallbackUrlInner call(ServiceResponse<CallbackUrlInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<CallbackUrlInner> getCallbackUrlAsync(String resourceGroupName, String integrationAccountName, GetCallbackUrlParameters parameters) {
return getCallbackUrlWithServiceResponseAsync(resourceGroupName, integrationAccountName, parameters).map(new Func1<ServiceResponse<CallbackUrlInner>, CallbackUrlInner>() {
@Override
public CallbackUrlInner call(ServiceResponse<CallbackUrlInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"CallbackUrlInner",
">",
"getCallbackUrlAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
",",
"GetCallbackUrlParameters",
"parameters",
")",
"{",
"return",
"getCallbackUrlWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"integrationAccountName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CallbackUrlInner",
">",
",",
"CallbackUrlInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CallbackUrlInner",
"call",
"(",
"ServiceResponse",
"<",
"CallbackUrlInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets the integration account callback URL.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param parameters The callback URL parameters.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CallbackUrlInner object
|
[
"Gets",
"the",
"integration",
"account",
"callback",
"URL",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountsInner.java#L965-L972
|
jglobus/JGlobus
|
ssl-proxies/src/main/java/org/globus/common/CoGProperties.java
|
CoGProperties.useDevRandom
|
public boolean useDevRandom() {
"""
Returns whether to use the /dev/urandom device
for seed generation.
@return true if the device should be used (if available of course)
Returns true by default unless specified otherwise by the
user.
"""
String value = System.getProperty("org.globus.dev.random");
if (value != null && value.equalsIgnoreCase("no")) {
return false;
}
return getAsBoolean("org.globus.dev.random", true);
}
|
java
|
public boolean useDevRandom() {
String value = System.getProperty("org.globus.dev.random");
if (value != null && value.equalsIgnoreCase("no")) {
return false;
}
return getAsBoolean("org.globus.dev.random", true);
}
|
[
"public",
"boolean",
"useDevRandom",
"(",
")",
"{",
"String",
"value",
"=",
"System",
".",
"getProperty",
"(",
"\"org.globus.dev.random\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"equalsIgnoreCase",
"(",
"\"no\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"getAsBoolean",
"(",
"\"org.globus.dev.random\"",
",",
"true",
")",
";",
"}"
] |
Returns whether to use the /dev/urandom device
for seed generation.
@return true if the device should be used (if available of course)
Returns true by default unless specified otherwise by the
user.
|
[
"Returns",
"whether",
"to",
"use",
"the",
"/",
"dev",
"/",
"urandom",
"device",
"for",
"seed",
"generation",
"."
] |
train
|
https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/common/CoGProperties.java#L479-L485
|
milaboratory/milib
|
src/main/java/com/milaboratory/core/io/util/FileIndexBuilder.java
|
FileIndexBuilder.putMetadata
|
public FileIndexBuilder putMetadata(String key, String value) {
"""
Puts metadata.
@param key metadata key
@param value metadata value
@return this
"""
checkIfDestroyed();
metadata.put(key, value);
return this;
}
|
java
|
public FileIndexBuilder putMetadata(String key, String value) {
checkIfDestroyed();
metadata.put(key, value);
return this;
}
|
[
"public",
"FileIndexBuilder",
"putMetadata",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"checkIfDestroyed",
"(",
")",
";",
"metadata",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Puts metadata.
@param key metadata key
@param value metadata value
@return this
|
[
"Puts",
"metadata",
"."
] |
train
|
https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/io/util/FileIndexBuilder.java#L109-L113
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java
|
FlowController.sendError
|
protected void sendError( String errText, HttpServletRequest request, HttpServletResponse response )
throws IOException {
"""
Send a Page Flow error to the browser.
@param errText the error message to display.
@param response the current HttpServletResponse.
"""
InternalUtils.sendError( "PageFlow_Custom_Error", null, request, response,
new Object[]{ getDisplayName(), errText } );
}
|
java
|
protected void sendError( String errText, HttpServletRequest request, HttpServletResponse response )
throws IOException
{
InternalUtils.sendError( "PageFlow_Custom_Error", null, request, response,
new Object[]{ getDisplayName(), errText } );
}
|
[
"protected",
"void",
"sendError",
"(",
"String",
"errText",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
"{",
"InternalUtils",
".",
"sendError",
"(",
"\"PageFlow_Custom_Error\"",
",",
"null",
",",
"request",
",",
"response",
",",
"new",
"Object",
"[",
"]",
"{",
"getDisplayName",
"(",
")",
",",
"errText",
"}",
")",
";",
"}"
] |
Send a Page Flow error to the browser.
@param errText the error message to display.
@param response the current HttpServletResponse.
|
[
"Send",
"a",
"Page",
"Flow",
"error",
"to",
"the",
"browser",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/pageflow/FlowController.java#L240-L245
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.completeOnTimeout
|
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit) {
"""
Completes this CompletableFuture with the given value if not otherwise completed before the
given timeout.
@param value the value to use upon timeout
@param timeout how long to wait before completing normally with the given value, in units of
{@code unit}
@param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter
@return this CompletableFuture
@since 9
"""
Objects.requireNonNull(unit);
if (result == null)
whenComplete(
new Canceller(Delayer.delay(new DelayedCompleter<T>(this, value), timeout, unit)));
return this;
}
|
java
|
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit) {
Objects.requireNonNull(unit);
if (result == null)
whenComplete(
new Canceller(Delayer.delay(new DelayedCompleter<T>(this, value), timeout, unit)));
return this;
}
|
[
"public",
"CompletableFuture",
"<",
"T",
">",
"completeOnTimeout",
"(",
"T",
"value",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"unit",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"whenComplete",
"(",
"new",
"Canceller",
"(",
"Delayer",
".",
"delay",
"(",
"new",
"DelayedCompleter",
"<",
"T",
">",
"(",
"this",
",",
"value",
")",
",",
"timeout",
",",
"unit",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Completes this CompletableFuture with the given value if not otherwise completed before the
given timeout.
@param value the value to use upon timeout
@param timeout how long to wait before completing normally with the given value, in units of
{@code unit}
@param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter
@return this CompletableFuture
@since 9
|
[
"Completes",
"this",
"CompletableFuture",
"with",
"the",
"given",
"value",
"if",
"not",
"otherwise",
"completed",
"before",
"the",
"given",
"timeout",
"."
] |
train
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1860-L1866
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java
|
ExpressRouteCrossConnectionsInner.beginUpdateTagsAsync
|
public Observable<ExpressRouteCrossConnectionInner> beginUpdateTagsAsync(String resourceGroupName, String crossConnectionName) {
"""
Updates an express route cross connection tags.
@param resourceGroupName The name of the resource group.
@param crossConnectionName The name of the cross connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRouteCrossConnectionInner object
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, crossConnectionName).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<ExpressRouteCrossConnectionInner> beginUpdateTagsAsync(String resourceGroupName, String crossConnectionName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, crossConnectionName).map(new Func1<ServiceResponse<ExpressRouteCrossConnectionInner>, ExpressRouteCrossConnectionInner>() {
@Override
public ExpressRouteCrossConnectionInner call(ServiceResponse<ExpressRouteCrossConnectionInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"ExpressRouteCrossConnectionInner",
">",
"beginUpdateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"crossConnectionName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"crossConnectionName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
",",
"ExpressRouteCrossConnectionInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ExpressRouteCrossConnectionInner",
"call",
"(",
"ServiceResponse",
"<",
"ExpressRouteCrossConnectionInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Updates an express route cross connection tags.
@param resourceGroupName The name of the resource group.
@param crossConnectionName The name of the cross connection.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRouteCrossConnectionInner object
|
[
"Updates",
"an",
"express",
"route",
"cross",
"connection",
"tags",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/ExpressRouteCrossConnectionsInner.java#L778-L785
|
alkacon/opencms-core
|
src/org/opencms/ui/apps/user/CmsOuTree.java
|
CmsOuTree.addOuToTree
|
private void addOuToTree(CmsOrganizationalUnit ou, CmsOrganizationalUnit parent_ou) {
"""
Adds an ou to the tree.<p>
@param ou to be added
@param parent_ou parent ou
"""
Item containerItem;
containerItem = m_treeContainer.addItem(ou);
if (containerItem == null) {
containerItem = getItem(ou);
}
containerItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(ou, CmsOuTreeType.OU));
containerItem.getItemProperty(PROP_TYPE).setValue(CmsOuTreeType.OU);
m_treeContainer.setParent(ou, parent_ou);
}
|
java
|
private void addOuToTree(CmsOrganizationalUnit ou, CmsOrganizationalUnit parent_ou) {
Item containerItem;
containerItem = m_treeContainer.addItem(ou);
if (containerItem == null) {
containerItem = getItem(ou);
}
containerItem.getItemProperty(PROP_NAME).setValue(getIconCaptionHTML(ou, CmsOuTreeType.OU));
containerItem.getItemProperty(PROP_TYPE).setValue(CmsOuTreeType.OU);
m_treeContainer.setParent(ou, parent_ou);
}
|
[
"private",
"void",
"addOuToTree",
"(",
"CmsOrganizationalUnit",
"ou",
",",
"CmsOrganizationalUnit",
"parent_ou",
")",
"{",
"Item",
"containerItem",
";",
"containerItem",
"=",
"m_treeContainer",
".",
"addItem",
"(",
"ou",
")",
";",
"if",
"(",
"containerItem",
"==",
"null",
")",
"{",
"containerItem",
"=",
"getItem",
"(",
"ou",
")",
";",
"}",
"containerItem",
".",
"getItemProperty",
"(",
"PROP_NAME",
")",
".",
"setValue",
"(",
"getIconCaptionHTML",
"(",
"ou",
",",
"CmsOuTreeType",
".",
"OU",
")",
")",
";",
"containerItem",
".",
"getItemProperty",
"(",
"PROP_TYPE",
")",
".",
"setValue",
"(",
"CmsOuTreeType",
".",
"OU",
")",
";",
"m_treeContainer",
".",
"setParent",
"(",
"ou",
",",
"parent_ou",
")",
";",
"}"
] |
Adds an ou to the tree.<p>
@param ou to be added
@param parent_ou parent ou
|
[
"Adds",
"an",
"ou",
"to",
"the",
"tree",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/user/CmsOuTree.java#L376-L386
|
VoltDB/voltdb
|
src/frontend/org/voltdb/compiler/DDLCompiler.java
|
DDLCompiler.loadSchema
|
void loadSchema(Reader reader, Database db, DdlProceduresToLoad whichProcs)
throws VoltCompiler.VoltCompilerException {
"""
Compile a DDL schema from an abstract reader
@param reader abstract DDL reader
@param db database
@param whichProcs which type(s) of procedures to load
@throws VoltCompiler.VoltCompilerException
"""
int currLineNo = 1;
DDLStatement stmt = getNextStatement(reader, m_compiler, currLineNo);
while (stmt != null) {
// Some statements are processed by VoltDB and the rest are handled by HSQL.
processVoltDBStatements(db, whichProcs, stmt);
stmt = getNextStatement(reader, m_compiler, stmt.endLineNo);
}
try {
reader.close();
} catch (IOException e) {
throw m_compiler.new VoltCompilerException("Error closing schema file");
}
// process extra classes
m_tracker.addExtraClasses(m_classMatcher.getMatchedClassList());
// possibly save some memory
m_classMatcher.clear();
}
|
java
|
void loadSchema(Reader reader, Database db, DdlProceduresToLoad whichProcs)
throws VoltCompiler.VoltCompilerException {
int currLineNo = 1;
DDLStatement stmt = getNextStatement(reader, m_compiler, currLineNo);
while (stmt != null) {
// Some statements are processed by VoltDB and the rest are handled by HSQL.
processVoltDBStatements(db, whichProcs, stmt);
stmt = getNextStatement(reader, m_compiler, stmt.endLineNo);
}
try {
reader.close();
} catch (IOException e) {
throw m_compiler.new VoltCompilerException("Error closing schema file");
}
// process extra classes
m_tracker.addExtraClasses(m_classMatcher.getMatchedClassList());
// possibly save some memory
m_classMatcher.clear();
}
|
[
"void",
"loadSchema",
"(",
"Reader",
"reader",
",",
"Database",
"db",
",",
"DdlProceduresToLoad",
"whichProcs",
")",
"throws",
"VoltCompiler",
".",
"VoltCompilerException",
"{",
"int",
"currLineNo",
"=",
"1",
";",
"DDLStatement",
"stmt",
"=",
"getNextStatement",
"(",
"reader",
",",
"m_compiler",
",",
"currLineNo",
")",
";",
"while",
"(",
"stmt",
"!=",
"null",
")",
"{",
"// Some statements are processed by VoltDB and the rest are handled by HSQL.",
"processVoltDBStatements",
"(",
"db",
",",
"whichProcs",
",",
"stmt",
")",
";",
"stmt",
"=",
"getNextStatement",
"(",
"reader",
",",
"m_compiler",
",",
"stmt",
".",
"endLineNo",
")",
";",
"}",
"try",
"{",
"reader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"m_compiler",
".",
"new",
"VoltCompilerException",
"(",
"\"Error closing schema file\"",
")",
";",
"}",
"// process extra classes",
"m_tracker",
".",
"addExtraClasses",
"(",
"m_classMatcher",
".",
"getMatchedClassList",
"(",
")",
")",
";",
"// possibly save some memory",
"m_classMatcher",
".",
"clear",
"(",
")",
";",
"}"
] |
Compile a DDL schema from an abstract reader
@param reader abstract DDL reader
@param db database
@param whichProcs which type(s) of procedures to load
@throws VoltCompiler.VoltCompilerException
|
[
"Compile",
"a",
"DDL",
"schema",
"from",
"an",
"abstract",
"reader"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/DDLCompiler.java#L398-L419
|
astrapi69/jaulp-wicket
|
jaulp-wicket-dialogs/src/main/java/de/alpharogroup/wicket/dialogs/panels/save/SaveDialogPanel.java
|
SaveDialogPanel.newSaveButton
|
protected AjaxButton newSaveButton(final String id, final Form<?> form) {
"""
Factory method for creating a new save {@link AjaxButton}. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a save {@link AjaxButton}.
@param id
the id
@param form
the form
@return the new {@link AjaxButton}
"""
final AjaxButton saveButton = new AjaxButton(id, form)
{
/**
* The serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form)
{
onSave(target, form);
}
};
return saveButton;
}
|
java
|
protected AjaxButton newSaveButton(final String id, final Form<?> form)
{
final AjaxButton saveButton = new AjaxButton(id, form)
{
/**
* The serialVersionUID.
*/
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form)
{
onSave(target, form);
}
};
return saveButton;
}
|
[
"protected",
"AjaxButton",
"newSaveButton",
"(",
"final",
"String",
"id",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"final",
"AjaxButton",
"saveButton",
"=",
"new",
"AjaxButton",
"(",
"id",
",",
"form",
")",
"{",
"/**\n\t\t\t * The serialVersionUID.\n\t\t\t */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n\t\t\t * {@inheritDoc}\n\t\t\t */",
"@",
"Override",
"protected",
"void",
"onSubmit",
"(",
"final",
"AjaxRequestTarget",
"target",
",",
"final",
"Form",
"<",
"?",
">",
"form",
")",
"{",
"onSave",
"(",
"target",
",",
"form",
")",
";",
"}",
"}",
";",
"return",
"saveButton",
";",
"}"
] |
Factory method for creating a new save {@link AjaxButton}. This method is invoked in the
constructor from the derived classes and can be overridden so users can provide their own
version of a save {@link AjaxButton}.
@param id
the id
@param form
the form
@return the new {@link AjaxButton}
|
[
"Factory",
"method",
"for",
"creating",
"a",
"new",
"save",
"{",
"@link",
"AjaxButton",
"}",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"save",
"{",
"@link",
"AjaxButton",
"}",
"."
] |
train
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-dialogs/src/main/java/de/alpharogroup/wicket/dialogs/panels/save/SaveDialogPanel.java#L203-L222
|
ManfredTremmel/gwt-commons-lang3
|
src/main/java/org/apache/commons/lang3/StringUtils.java
|
StringUtils.endsWith
|
private static boolean endsWith(final CharSequence str, final CharSequence suffix, final boolean ignoreCase) {
"""
<p>Check if a CharSequence ends with a specified suffix (optionally case insensitive).</p>
@see java.lang.String#endsWith(String)
@param str the CharSequence to check, may be null
@param suffix the suffix to find, may be null
@param ignoreCase indicates whether the compare should ignore case
(case insensitive) or not.
@return {@code true} if the CharSequence starts with the prefix or
both {@code null}
"""
if (str == null || suffix == null) {
return str == null && suffix == null;
}
if (suffix.length() > str.length()) {
return false;
}
final int strOffset = str.length() - suffix.length();
return CharSequenceUtils.regionMatches(str, ignoreCase, strOffset, suffix, 0, suffix.length());
}
|
java
|
private static boolean endsWith(final CharSequence str, final CharSequence suffix, final boolean ignoreCase) {
if (str == null || suffix == null) {
return str == null && suffix == null;
}
if (suffix.length() > str.length()) {
return false;
}
final int strOffset = str.length() - suffix.length();
return CharSequenceUtils.regionMatches(str, ignoreCase, strOffset, suffix, 0, suffix.length());
}
|
[
"private",
"static",
"boolean",
"endsWith",
"(",
"final",
"CharSequence",
"str",
",",
"final",
"CharSequence",
"suffix",
",",
"final",
"boolean",
"ignoreCase",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"suffix",
"==",
"null",
")",
"{",
"return",
"str",
"==",
"null",
"&&",
"suffix",
"==",
"null",
";",
"}",
"if",
"(",
"suffix",
".",
"length",
"(",
")",
">",
"str",
".",
"length",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"strOffset",
"=",
"str",
".",
"length",
"(",
")",
"-",
"suffix",
".",
"length",
"(",
")",
";",
"return",
"CharSequenceUtils",
".",
"regionMatches",
"(",
"str",
",",
"ignoreCase",
",",
"strOffset",
",",
"suffix",
",",
"0",
",",
"suffix",
".",
"length",
"(",
")",
")",
";",
"}"
] |
<p>Check if a CharSequence ends with a specified suffix (optionally case insensitive).</p>
@see java.lang.String#endsWith(String)
@param str the CharSequence to check, may be null
@param suffix the suffix to find, may be null
@param ignoreCase indicates whether the compare should ignore case
(case insensitive) or not.
@return {@code true} if the CharSequence starts with the prefix or
both {@code null}
|
[
"<p",
">",
"Check",
"if",
"a",
"CharSequence",
"ends",
"with",
"a",
"specified",
"suffix",
"(",
"optionally",
"case",
"insensitive",
")",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/StringUtils.java#L8639-L8648
|
mygreen/excel-cellformatter
|
src/main/java/com/github/mygreen/cellformatter/JXLCellFormatter.java
|
JXLCellFormatter.formatAsString
|
public String formatAsString(final Cell cell, final boolean isStartDate1904) {
"""
セルの値をフォーマットし、文字列として取得する
@param cell フォーマット対象のセル
@param isStartDate1904 ファイルの設定が1904年始まりかどうか。
{@link JXLUtils#isDateStart1904(jxl.Sheet)}で値を調べます。
@return フォーマットしたセルの値。
@throws IllegalArgumentException cell is null.
"""
return formatAsString(cell, Locale.getDefault(), isStartDate1904);
}
|
java
|
public String formatAsString(final Cell cell, final boolean isStartDate1904) {
return formatAsString(cell, Locale.getDefault(), isStartDate1904);
}
|
[
"public",
"String",
"formatAsString",
"(",
"final",
"Cell",
"cell",
",",
"final",
"boolean",
"isStartDate1904",
")",
"{",
"return",
"formatAsString",
"(",
"cell",
",",
"Locale",
".",
"getDefault",
"(",
")",
",",
"isStartDate1904",
")",
";",
"}"
] |
セルの値をフォーマットし、文字列として取得する
@param cell フォーマット対象のセル
@param isStartDate1904 ファイルの設定が1904年始まりかどうか。
{@link JXLUtils#isDateStart1904(jxl.Sheet)}で値を調べます。
@return フォーマットしたセルの値。
@throws IllegalArgumentException cell is null.
|
[
"セルの値をフォーマットし、文字列として取得する"
] |
train
|
https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/JXLCellFormatter.java#L94-L96
|
eiichiro/acidhouse
|
acidhouse-appengine/src/main/java/org/eiichiro/acidhouse/appengine/Translation.java
|
Translation.toObject
|
public static <E> E toObject(Class<E> clazz, List<Entity> entities,
Map<com.google.appengine.api.datastore.Key, Object> references,
AppEngineDatastoreService datastore) {
"""
Translates Google App Engine Datastore entities to Acid House entity with
{@code AppEngineDatastoreService}.
@param <E> The type of Acid House entity.
@param clazz The {@code Class} of Acid House entity.
@param entities Google App Engine Datastore entities.
@param datastore {@code AppEngineDatastoreService}.
@return Acid House entity translated from Google App Engine Datastore
entities.
"""
return toObject(clazz, entities, references, datastore, 0);
}
|
java
|
public static <E> E toObject(Class<E> clazz, List<Entity> entities,
Map<com.google.appengine.api.datastore.Key, Object> references,
AppEngineDatastoreService datastore) {
return toObject(clazz, entities, references, datastore, 0);
}
|
[
"public",
"static",
"<",
"E",
">",
"E",
"toObject",
"(",
"Class",
"<",
"E",
">",
"clazz",
",",
"List",
"<",
"Entity",
">",
"entities",
",",
"Map",
"<",
"com",
".",
"google",
".",
"appengine",
".",
"api",
".",
"datastore",
".",
"Key",
",",
"Object",
">",
"references",
",",
"AppEngineDatastoreService",
"datastore",
")",
"{",
"return",
"toObject",
"(",
"clazz",
",",
"entities",
",",
"references",
",",
"datastore",
",",
"0",
")",
";",
"}"
] |
Translates Google App Engine Datastore entities to Acid House entity with
{@code AppEngineDatastoreService}.
@param <E> The type of Acid House entity.
@param clazz The {@code Class} of Acid House entity.
@param entities Google App Engine Datastore entities.
@param datastore {@code AppEngineDatastoreService}.
@return Acid House entity translated from Google App Engine Datastore
entities.
|
[
"Translates",
"Google",
"App",
"Engine",
"Datastore",
"entities",
"to",
"Acid",
"House",
"entity",
"with",
"{",
"@code",
"AppEngineDatastoreService",
"}",
"."
] |
train
|
https://github.com/eiichiro/acidhouse/blob/c50eaa0bb0f24abb46def4afa611f170637cdd62/acidhouse-appengine/src/main/java/org/eiichiro/acidhouse/appengine/Translation.java#L105-L109
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/handler/impl/CudaZeroHandler.java
|
CudaZeroHandler.memcpySpecial
|
@Override
public void memcpySpecial(DataBuffer dstBuffer, Pointer srcPointer, long length, long dstOffset) {
"""
Special memcpy version, addressing shapeInfoDataBuffer copies
PLEASE NOTE: Blocking H->H, Async H->D
@param dstBuffer
@param srcPointer
@param length
@param dstOffset
"""
CudaContext context = getCudaContext();
AllocationPoint point = ((BaseCudaDataBuffer) dstBuffer).getAllocationPoint();
Pointer dP = new CudaPointer((point.getPointers().getHostPointer().address()) + dstOffset);
val profH = PerformanceTracker.getInstance().helperStartTransaction();
if (nativeOps.memcpyAsync(dP, srcPointer, length, CudaConstants.cudaMemcpyHostToHost, context.getOldStream()) == 0)
throw new ND4JIllegalStateException("memcpyAsync failed");
PerformanceTracker.getInstance().helperRegisterTransaction(point.getDeviceId(), profH, point.getNumberOfBytes(),MemcpyDirection.HOST_TO_HOST);
if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
Pointer rDP = new CudaPointer(point.getPointers().getDevicePointer().address() + dstOffset);
val profD = PerformanceTracker.getInstance().helperStartTransaction();
if (nativeOps.memcpyAsync(rDP, dP, length, CudaConstants.cudaMemcpyHostToDevice, context.getOldStream()) == 0)
throw new ND4JIllegalStateException("memcpyAsync failed");
context.syncOldStream();
PerformanceTracker.getInstance().helperRegisterTransaction(point.getDeviceId(), profD, point.getNumberOfBytes(),MemcpyDirection.HOST_TO_DEVICE);
}
context.syncOldStream();
point.tickDeviceWrite();
}
|
java
|
@Override
public void memcpySpecial(DataBuffer dstBuffer, Pointer srcPointer, long length, long dstOffset) {
CudaContext context = getCudaContext();
AllocationPoint point = ((BaseCudaDataBuffer) dstBuffer).getAllocationPoint();
Pointer dP = new CudaPointer((point.getPointers().getHostPointer().address()) + dstOffset);
val profH = PerformanceTracker.getInstance().helperStartTransaction();
if (nativeOps.memcpyAsync(dP, srcPointer, length, CudaConstants.cudaMemcpyHostToHost, context.getOldStream()) == 0)
throw new ND4JIllegalStateException("memcpyAsync failed");
PerformanceTracker.getInstance().helperRegisterTransaction(point.getDeviceId(), profH, point.getNumberOfBytes(),MemcpyDirection.HOST_TO_HOST);
if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
Pointer rDP = new CudaPointer(point.getPointers().getDevicePointer().address() + dstOffset);
val profD = PerformanceTracker.getInstance().helperStartTransaction();
if (nativeOps.memcpyAsync(rDP, dP, length, CudaConstants.cudaMemcpyHostToDevice, context.getOldStream()) == 0)
throw new ND4JIllegalStateException("memcpyAsync failed");
context.syncOldStream();
PerformanceTracker.getInstance().helperRegisterTransaction(point.getDeviceId(), profD, point.getNumberOfBytes(),MemcpyDirection.HOST_TO_DEVICE);
}
context.syncOldStream();
point.tickDeviceWrite();
}
|
[
"@",
"Override",
"public",
"void",
"memcpySpecial",
"(",
"DataBuffer",
"dstBuffer",
",",
"Pointer",
"srcPointer",
",",
"long",
"length",
",",
"long",
"dstOffset",
")",
"{",
"CudaContext",
"context",
"=",
"getCudaContext",
"(",
")",
";",
"AllocationPoint",
"point",
"=",
"(",
"(",
"BaseCudaDataBuffer",
")",
"dstBuffer",
")",
".",
"getAllocationPoint",
"(",
")",
";",
"Pointer",
"dP",
"=",
"new",
"CudaPointer",
"(",
"(",
"point",
".",
"getPointers",
"(",
")",
".",
"getHostPointer",
"(",
")",
".",
"address",
"(",
")",
")",
"+",
"dstOffset",
")",
";",
"val",
"profH",
"=",
"PerformanceTracker",
".",
"getInstance",
"(",
")",
".",
"helperStartTransaction",
"(",
")",
";",
"if",
"(",
"nativeOps",
".",
"memcpyAsync",
"(",
"dP",
",",
"srcPointer",
",",
"length",
",",
"CudaConstants",
".",
"cudaMemcpyHostToHost",
",",
"context",
".",
"getOldStream",
"(",
")",
")",
"==",
"0",
")",
"throw",
"new",
"ND4JIllegalStateException",
"(",
"\"memcpyAsync failed\"",
")",
";",
"PerformanceTracker",
".",
"getInstance",
"(",
")",
".",
"helperRegisterTransaction",
"(",
"point",
".",
"getDeviceId",
"(",
")",
",",
"profH",
",",
"point",
".",
"getNumberOfBytes",
"(",
")",
",",
"MemcpyDirection",
".",
"HOST_TO_HOST",
")",
";",
"if",
"(",
"point",
".",
"getAllocationStatus",
"(",
")",
"==",
"AllocationStatus",
".",
"DEVICE",
")",
"{",
"Pointer",
"rDP",
"=",
"new",
"CudaPointer",
"(",
"point",
".",
"getPointers",
"(",
")",
".",
"getDevicePointer",
"(",
")",
".",
"address",
"(",
")",
"+",
"dstOffset",
")",
";",
"val",
"profD",
"=",
"PerformanceTracker",
".",
"getInstance",
"(",
")",
".",
"helperStartTransaction",
"(",
")",
";",
"if",
"(",
"nativeOps",
".",
"memcpyAsync",
"(",
"rDP",
",",
"dP",
",",
"length",
",",
"CudaConstants",
".",
"cudaMemcpyHostToDevice",
",",
"context",
".",
"getOldStream",
"(",
")",
")",
"==",
"0",
")",
"throw",
"new",
"ND4JIllegalStateException",
"(",
"\"memcpyAsync failed\"",
")",
";",
"context",
".",
"syncOldStream",
"(",
")",
";",
"PerformanceTracker",
".",
"getInstance",
"(",
")",
".",
"helperRegisterTransaction",
"(",
"point",
".",
"getDeviceId",
"(",
")",
",",
"profD",
",",
"point",
".",
"getNumberOfBytes",
"(",
")",
",",
"MemcpyDirection",
".",
"HOST_TO_DEVICE",
")",
";",
"}",
"context",
".",
"syncOldStream",
"(",
")",
";",
"point",
".",
"tickDeviceWrite",
"(",
")",
";",
"}"
] |
Special memcpy version, addressing shapeInfoDataBuffer copies
PLEASE NOTE: Blocking H->H, Async H->D
@param dstBuffer
@param srcPointer
@param length
@param dstOffset
|
[
"Special",
"memcpy",
"version",
"addressing",
"shapeInfoDataBuffer",
"copies"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/handler/impl/CudaZeroHandler.java#L652-L683
|
couchbase/couchbase-jvm-core
|
src/main/java/com/couchbase/client/core/config/AbstractBucketConfig.java
|
AbstractBucketConfig.nodeInfoFromExtended
|
private List<NodeInfo> nodeInfoFromExtended(final List<PortInfo> nodesExt, final List<NodeInfo> nodeInfos) {
"""
Helper method to create the {@link NodeInfo}s from from the extended node information.
In older server versions (< 3.0.2) the nodesExt part does not carry a hostname, so as a fallback the hostname
is loaded from the node info if needed.
@param nodesExt the extended information.
@return the generated node infos.
"""
List<NodeInfo> converted = new ArrayList<NodeInfo>(nodesExt.size());
for (int i = 0; i < nodesExt.size(); i++) {
NetworkAddress hostname = nodesExt.get(i).hostname();
// Since nodeInfo and nodesExt might not be the same size, this can be null!
NodeInfo nodeInfo = i >= nodeInfos.size() ? null : nodeInfos.get(i);
if (hostname == null) {
if (nodeInfo != null) {
hostname = nodeInfo.hostname();
} else {
// If hostname missing, then node configured using localhost
LOGGER.debug("Hostname is for nodesExt[{}] is not available, falling back to origin.", i);
hostname = origin;
}
}
Map<ServiceType, Integer> ports = nodesExt.get(i).ports();
Map<ServiceType, Integer> sslPorts = nodesExt.get(i).sslPorts();
Map<String, AlternateAddress> aa = nodesExt.get(i).alternateAddresses();
// this is an ephemeral bucket (not supporting views), don't enable views!
if (!bucketCapabilities.contains(BucketCapabilities.COUCHAPI)) {
ports.remove(ServiceType.VIEW);
sslPorts.remove(ServiceType.VIEW);
}
// make sure only kv nodes are added if they are actually also in the nodes
// list and not just in nodesExt, since the kv service might be available
// on the cluster but not yet enabled for this specific bucket.
if (nodeInfo == null) {
ports.remove(ServiceType.BINARY);
sslPorts.remove(ServiceType.BINARY);
}
converted.add(new DefaultNodeInfo(hostname, ports, sslPorts, aa));
}
return converted;
}
|
java
|
private List<NodeInfo> nodeInfoFromExtended(final List<PortInfo> nodesExt, final List<NodeInfo> nodeInfos) {
List<NodeInfo> converted = new ArrayList<NodeInfo>(nodesExt.size());
for (int i = 0; i < nodesExt.size(); i++) {
NetworkAddress hostname = nodesExt.get(i).hostname();
// Since nodeInfo and nodesExt might not be the same size, this can be null!
NodeInfo nodeInfo = i >= nodeInfos.size() ? null : nodeInfos.get(i);
if (hostname == null) {
if (nodeInfo != null) {
hostname = nodeInfo.hostname();
} else {
// If hostname missing, then node configured using localhost
LOGGER.debug("Hostname is for nodesExt[{}] is not available, falling back to origin.", i);
hostname = origin;
}
}
Map<ServiceType, Integer> ports = nodesExt.get(i).ports();
Map<ServiceType, Integer> sslPorts = nodesExt.get(i).sslPorts();
Map<String, AlternateAddress> aa = nodesExt.get(i).alternateAddresses();
// this is an ephemeral bucket (not supporting views), don't enable views!
if (!bucketCapabilities.contains(BucketCapabilities.COUCHAPI)) {
ports.remove(ServiceType.VIEW);
sslPorts.remove(ServiceType.VIEW);
}
// make sure only kv nodes are added if they are actually also in the nodes
// list and not just in nodesExt, since the kv service might be available
// on the cluster but not yet enabled for this specific bucket.
if (nodeInfo == null) {
ports.remove(ServiceType.BINARY);
sslPorts.remove(ServiceType.BINARY);
}
converted.add(new DefaultNodeInfo(hostname, ports, sslPorts, aa));
}
return converted;
}
|
[
"private",
"List",
"<",
"NodeInfo",
">",
"nodeInfoFromExtended",
"(",
"final",
"List",
"<",
"PortInfo",
">",
"nodesExt",
",",
"final",
"List",
"<",
"NodeInfo",
">",
"nodeInfos",
")",
"{",
"List",
"<",
"NodeInfo",
">",
"converted",
"=",
"new",
"ArrayList",
"<",
"NodeInfo",
">",
"(",
"nodesExt",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodesExt",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"NetworkAddress",
"hostname",
"=",
"nodesExt",
".",
"get",
"(",
"i",
")",
".",
"hostname",
"(",
")",
";",
"// Since nodeInfo and nodesExt might not be the same size, this can be null!",
"NodeInfo",
"nodeInfo",
"=",
"i",
">=",
"nodeInfos",
".",
"size",
"(",
")",
"?",
"null",
":",
"nodeInfos",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"hostname",
"==",
"null",
")",
"{",
"if",
"(",
"nodeInfo",
"!=",
"null",
")",
"{",
"hostname",
"=",
"nodeInfo",
".",
"hostname",
"(",
")",
";",
"}",
"else",
"{",
"// If hostname missing, then node configured using localhost",
"LOGGER",
".",
"debug",
"(",
"\"Hostname is for nodesExt[{}] is not available, falling back to origin.\"",
",",
"i",
")",
";",
"hostname",
"=",
"origin",
";",
"}",
"}",
"Map",
"<",
"ServiceType",
",",
"Integer",
">",
"ports",
"=",
"nodesExt",
".",
"get",
"(",
"i",
")",
".",
"ports",
"(",
")",
";",
"Map",
"<",
"ServiceType",
",",
"Integer",
">",
"sslPorts",
"=",
"nodesExt",
".",
"get",
"(",
"i",
")",
".",
"sslPorts",
"(",
")",
";",
"Map",
"<",
"String",
",",
"AlternateAddress",
">",
"aa",
"=",
"nodesExt",
".",
"get",
"(",
"i",
")",
".",
"alternateAddresses",
"(",
")",
";",
"// this is an ephemeral bucket (not supporting views), don't enable views!",
"if",
"(",
"!",
"bucketCapabilities",
".",
"contains",
"(",
"BucketCapabilities",
".",
"COUCHAPI",
")",
")",
"{",
"ports",
".",
"remove",
"(",
"ServiceType",
".",
"VIEW",
")",
";",
"sslPorts",
".",
"remove",
"(",
"ServiceType",
".",
"VIEW",
")",
";",
"}",
"// make sure only kv nodes are added if they are actually also in the nodes",
"// list and not just in nodesExt, since the kv service might be available",
"// on the cluster but not yet enabled for this specific bucket.",
"if",
"(",
"nodeInfo",
"==",
"null",
")",
"{",
"ports",
".",
"remove",
"(",
"ServiceType",
".",
"BINARY",
")",
";",
"sslPorts",
".",
"remove",
"(",
"ServiceType",
".",
"BINARY",
")",
";",
"}",
"converted",
".",
"add",
"(",
"new",
"DefaultNodeInfo",
"(",
"hostname",
",",
"ports",
",",
"sslPorts",
",",
"aa",
")",
")",
";",
"}",
"return",
"converted",
";",
"}"
] |
Helper method to create the {@link NodeInfo}s from from the extended node information.
In older server versions (< 3.0.2) the nodesExt part does not carry a hostname, so as a fallback the hostname
is loaded from the node info if needed.
@param nodesExt the extended information.
@return the generated node infos.
|
[
"Helper",
"method",
"to",
"create",
"the",
"{",
"@link",
"NodeInfo",
"}",
"s",
"from",
"from",
"the",
"extended",
"node",
"information",
"."
] |
train
|
https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/config/AbstractBucketConfig.java#L75-L113
|
likethecolor/Alchemy-API
|
src/main/java/com/likethecolor/alchemy/api/parser/json/NamedEntityParser.java
|
NamedEntityParser.isValidNamedEntity
|
private boolean isValidNamedEntity(final Double score, final String text) {
"""
Return true if at least one of the values is not null/empty.
@param score relevance score
@param text detected entity text
@return true if at least one of the values is not null/empty
"""
return !StringUtils.isBlank(text)
|| score != null;
}
|
java
|
private boolean isValidNamedEntity(final Double score, final String text) {
return !StringUtils.isBlank(text)
|| score != null;
}
|
[
"private",
"boolean",
"isValidNamedEntity",
"(",
"final",
"Double",
"score",
",",
"final",
"String",
"text",
")",
"{",
"return",
"!",
"StringUtils",
".",
"isBlank",
"(",
"text",
")",
"||",
"score",
"!=",
"null",
";",
"}"
] |
Return true if at least one of the values is not null/empty.
@param score relevance score
@param text detected entity text
@return true if at least one of the values is not null/empty
|
[
"Return",
"true",
"if",
"at",
"least",
"one",
"of",
"the",
"values",
"is",
"not",
"null",
"/",
"empty",
"."
] |
train
|
https://github.com/likethecolor/Alchemy-API/blob/5208cfc92a878ceeaff052787af29da92d98db7e/src/main/java/com/likethecolor/alchemy/api/parser/json/NamedEntityParser.java#L129-L132
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java
|
CacheProxyUtil.validateNotNull
|
public static <K, V> void validateNotNull(Map<? extends K, ? extends V> map) {
"""
This validator ensures that no key or value is null in the provided map.
@param map the map to be validated.
@param <K> the type of key.
@param <V> the type of value.
@throws java.lang.NullPointerException if provided map contains a null key or value in the map.
"""
checkNotNull(map, "map is null");
boolean containsNullKey = false;
boolean containsNullValue = false;
// we catch possible NPE since the Map implementation could not support null values
// TODO: is it possible to validate a map more efficiently without try-catch blocks?
try {
containsNullKey = map.containsKey(null);
} catch (NullPointerException e) {
// ignore if null key is not allowed for this map
ignore(e);
}
try {
containsNullValue = map.containsValue(null);
} catch (NullPointerException e) {
// ignore if null value is not allowed for this map
ignore(e);
}
if (containsNullKey) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (containsNullValue) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
}
|
java
|
public static <K, V> void validateNotNull(Map<? extends K, ? extends V> map) {
checkNotNull(map, "map is null");
boolean containsNullKey = false;
boolean containsNullValue = false;
// we catch possible NPE since the Map implementation could not support null values
// TODO: is it possible to validate a map more efficiently without try-catch blocks?
try {
containsNullKey = map.containsKey(null);
} catch (NullPointerException e) {
// ignore if null key is not allowed for this map
ignore(e);
}
try {
containsNullValue = map.containsValue(null);
} catch (NullPointerException e) {
// ignore if null value is not allowed for this map
ignore(e);
}
if (containsNullKey) {
throw new NullPointerException(NULL_KEY_IS_NOT_ALLOWED);
}
if (containsNullValue) {
throw new NullPointerException(NULL_VALUE_IS_NOT_ALLOWED);
}
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"validateNotNull",
"(",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"map",
")",
"{",
"checkNotNull",
"(",
"map",
",",
"\"map is null\"",
")",
";",
"boolean",
"containsNullKey",
"=",
"false",
";",
"boolean",
"containsNullValue",
"=",
"false",
";",
"// we catch possible NPE since the Map implementation could not support null values",
"// TODO: is it possible to validate a map more efficiently without try-catch blocks?",
"try",
"{",
"containsNullKey",
"=",
"map",
".",
"containsKey",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"// ignore if null key is not allowed for this map",
"ignore",
"(",
"e",
")",
";",
"}",
"try",
"{",
"containsNullValue",
"=",
"map",
".",
"containsValue",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"// ignore if null value is not allowed for this map",
"ignore",
"(",
"e",
")",
";",
"}",
"if",
"(",
"containsNullKey",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"NULL_KEY_IS_NOT_ALLOWED",
")",
";",
"}",
"if",
"(",
"containsNullValue",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"NULL_VALUE_IS_NOT_ALLOWED",
")",
";",
"}",
"}"
] |
This validator ensures that no key or value is null in the provided map.
@param map the map to be validated.
@param <K> the type of key.
@param <V> the type of value.
@throws java.lang.NullPointerException if provided map contains a null key or value in the map.
|
[
"This",
"validator",
"ensures",
"that",
"no",
"key",
"or",
"value",
"is",
"null",
"in",
"the",
"provided",
"map",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/CacheProxyUtil.java#L129-L154
|
telly/groundy
|
library/src/main/java/com/telly/groundy/TaskResult.java
|
TaskResult.add
|
public TaskResult add(String key, CharSequence[] value) {
"""
Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing
value for the given key. Either key or value may be null.
@param key a String, or null
@param value a CharSequence array object, or null
"""
mBundle.putCharSequenceArray(key, value);
return this;
}
|
java
|
public TaskResult add(String key, CharSequence[] value) {
mBundle.putCharSequenceArray(key, value);
return this;
}
|
[
"public",
"TaskResult",
"add",
"(",
"String",
"key",
",",
"CharSequence",
"[",
"]",
"value",
")",
"{",
"mBundle",
".",
"putCharSequenceArray",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing
value for the given key. Either key or value may be null.
@param key a String, or null
@param value a CharSequence array object, or null
|
[
"Inserts",
"a",
"CharSequence",
"array",
"value",
"into",
"the",
"mapping",
"of",
"this",
"Bundle",
"replacing",
"any",
"existing",
"value",
"for",
"the",
"given",
"key",
".",
"Either",
"key",
"or",
"value",
"may",
"be",
"null",
"."
] |
train
|
https://github.com/telly/groundy/blob/e90baf9901a8be20b348bd1575d5ad782560cec8/library/src/main/java/com/telly/groundy/TaskResult.java#L384-L387
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-horizonView/src/main/java/net/minidev/ovh/api/ApiOvhHorizonView.java
|
ApiOvhHorizonView.serviceName_accessPoint_POST
|
public ArrayList<OvhTask> serviceName_accessPoint_POST(String serviceName, OvhPoolType poolType, String privateBlock, Long privateVlan, String vrouterPoolPublicIp) throws IOException {
"""
Add new access point to create a new network
REST: POST /horizonView/{serviceName}/accessPoint
@param privateVlan [required] You can customize your pool by choosing its private Vlan ID. (smaller than 4095)
@param privateBlock [required] You can customize your pool by choosing the private network (Ex : 10.0.0.0/16)
@param vrouterPoolPublicIp [required] You need to use a public Ip if you want to deploy a public pool.
@param poolType [required] The type of pool you want to deploy.
@param serviceName [required] Domain of the service
"""
String qPath = "/horizonView/{serviceName}/accessPoint";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "poolType", poolType);
addBody(o, "privateBlock", privateBlock);
addBody(o, "privateVlan", privateVlan);
addBody(o, "vrouterPoolPublicIp", vrouterPoolPublicIp);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, t2);
}
|
java
|
public ArrayList<OvhTask> serviceName_accessPoint_POST(String serviceName, OvhPoolType poolType, String privateBlock, Long privateVlan, String vrouterPoolPublicIp) throws IOException {
String qPath = "/horizonView/{serviceName}/accessPoint";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "poolType", poolType);
addBody(o, "privateBlock", privateBlock);
addBody(o, "privateVlan", privateVlan);
addBody(o, "vrouterPoolPublicIp", vrouterPoolPublicIp);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, t2);
}
|
[
"public",
"ArrayList",
"<",
"OvhTask",
">",
"serviceName_accessPoint_POST",
"(",
"String",
"serviceName",
",",
"OvhPoolType",
"poolType",
",",
"String",
"privateBlock",
",",
"Long",
"privateVlan",
",",
"String",
"vrouterPoolPublicIp",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/horizonView/{serviceName}/accessPoint\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"poolType\"",
",",
"poolType",
")",
";",
"addBody",
"(",
"o",
",",
"\"privateBlock\"",
",",
"privateBlock",
")",
";",
"addBody",
"(",
"o",
",",
"\"privateVlan\"",
",",
"privateVlan",
")",
";",
"addBody",
"(",
"o",
",",
"\"vrouterPoolPublicIp\"",
",",
"vrouterPoolPublicIp",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t2",
")",
";",
"}"
] |
Add new access point to create a new network
REST: POST /horizonView/{serviceName}/accessPoint
@param privateVlan [required] You can customize your pool by choosing its private Vlan ID. (smaller than 4095)
@param privateBlock [required] You can customize your pool by choosing the private network (Ex : 10.0.0.0/16)
@param vrouterPoolPublicIp [required] You need to use a public Ip if you want to deploy a public pool.
@param poolType [required] The type of pool you want to deploy.
@param serviceName [required] Domain of the service
|
[
"Add",
"new",
"access",
"point",
"to",
"create",
"a",
"new",
"network"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-horizonView/src/main/java/net/minidev/ovh/api/ApiOvhHorizonView.java#L250-L260
|
rhuss/jolokia
|
agent/core/src/main/java/org/jolokia/discovery/MulticastUtil.java
|
MulticastUtil.sendQueryAndCollectAnswers
|
public static List<DiscoveryIncomingMessage> sendQueryAndCollectAnswers(DiscoveryOutgoingMessage pOutMsg,
int pTimeout,
LogHandler pLogHandler) throws IOException {
"""
Sent out a message to Jolokia's multicast group over all network interfaces supporting multicasts
@param pOutMsg the message to send
@param pTimeout timeout used for how long to wait for discovery messages
@param pLogHandler a log handler for printing out logging information
@return list of received answers, never null
@throws IOException if something fails during the discovery request
"""
final List<Future<List<DiscoveryIncomingMessage>>> futures = sendDiscoveryRequests(pOutMsg, pTimeout, pLogHandler);
return collectIncomingMessages(pTimeout, futures, pLogHandler);
}
|
java
|
public static List<DiscoveryIncomingMessage> sendQueryAndCollectAnswers(DiscoveryOutgoingMessage pOutMsg,
int pTimeout,
LogHandler pLogHandler) throws IOException {
final List<Future<List<DiscoveryIncomingMessage>>> futures = sendDiscoveryRequests(pOutMsg, pTimeout, pLogHandler);
return collectIncomingMessages(pTimeout, futures, pLogHandler);
}
|
[
"public",
"static",
"List",
"<",
"DiscoveryIncomingMessage",
">",
"sendQueryAndCollectAnswers",
"(",
"DiscoveryOutgoingMessage",
"pOutMsg",
",",
"int",
"pTimeout",
",",
"LogHandler",
"pLogHandler",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"Future",
"<",
"List",
"<",
"DiscoveryIncomingMessage",
">",
">",
">",
"futures",
"=",
"sendDiscoveryRequests",
"(",
"pOutMsg",
",",
"pTimeout",
",",
"pLogHandler",
")",
";",
"return",
"collectIncomingMessages",
"(",
"pTimeout",
",",
"futures",
",",
"pLogHandler",
")",
";",
"}"
] |
Sent out a message to Jolokia's multicast group over all network interfaces supporting multicasts
@param pOutMsg the message to send
@param pTimeout timeout used for how long to wait for discovery messages
@param pLogHandler a log handler for printing out logging information
@return list of received answers, never null
@throws IOException if something fails during the discovery request
|
[
"Sent",
"out",
"a",
"message",
"to",
"Jolokia",
"s",
"multicast",
"group",
"over",
"all",
"network",
"interfaces",
"supporting",
"multicasts"
] |
train
|
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/discovery/MulticastUtil.java#L67-L72
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java
|
ApiOvhEmaildomain.domain_confirmTermination_POST
|
public String domain_confirmTermination_POST(String domain, String commentary, OvhTerminationReasonEnum reason, String token) throws IOException {
"""
Confirm termination of your email service
REST: POST /email/domain/{domain}/confirmTermination
@param reason [required] Reason of your termination request
@param commentary [required] Commentary about your termination request
@param token [required] The termination token sent by mail to the admin contact
@param domain [required] Name of your domain name
"""
String qPath = "/email/domain/{domain}/confirmTermination";
StringBuilder sb = path(qPath, domain);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "commentary", commentary);
addBody(o, "reason", reason);
addBody(o, "token", token);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
}
|
java
|
public String domain_confirmTermination_POST(String domain, String commentary, OvhTerminationReasonEnum reason, String token) throws IOException {
String qPath = "/email/domain/{domain}/confirmTermination";
StringBuilder sb = path(qPath, domain);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "commentary", commentary);
addBody(o, "reason", reason);
addBody(o, "token", token);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
}
|
[
"public",
"String",
"domain_confirmTermination_POST",
"(",
"String",
"domain",
",",
"String",
"commentary",
",",
"OvhTerminationReasonEnum",
"reason",
",",
"String",
"token",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/domain/{domain}/confirmTermination\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"domain",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"commentary\"",
",",
"commentary",
")",
";",
"addBody",
"(",
"o",
",",
"\"reason\"",
",",
"reason",
")",
";",
"addBody",
"(",
"o",
",",
"\"token\"",
",",
"token",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"String",
".",
"class",
")",
";",
"}"
] |
Confirm termination of your email service
REST: POST /email/domain/{domain}/confirmTermination
@param reason [required] Reason of your termination request
@param commentary [required] Commentary about your termination request
@param token [required] The termination token sent by mail to the admin contact
@param domain [required] Name of your domain name
|
[
"Confirm",
"termination",
"of",
"your",
"email",
"service"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emaildomain/src/main/java/net/minidev/ovh/api/ApiOvhEmaildomain.java#L1261-L1270
|
eclipse/xtext-extras
|
org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/AbstractTypeComputer.java
|
AbstractTypeComputer.getCommonSuperType
|
protected LightweightTypeReference getCommonSuperType(List<LightweightTypeReference> types, ITypeComputationState state) {
"""
Computes the common super type for the given list of types. The list may not be empty.
"""
return getCommonSuperType(types, state.getReferenceOwner());
}
|
java
|
protected LightweightTypeReference getCommonSuperType(List<LightweightTypeReference> types, ITypeComputationState state) {
return getCommonSuperType(types, state.getReferenceOwner());
}
|
[
"protected",
"LightweightTypeReference",
"getCommonSuperType",
"(",
"List",
"<",
"LightweightTypeReference",
">",
"types",
",",
"ITypeComputationState",
"state",
")",
"{",
"return",
"getCommonSuperType",
"(",
"types",
",",
"state",
".",
"getReferenceOwner",
"(",
")",
")",
";",
"}"
] |
Computes the common super type for the given list of types. The list may not be empty.
|
[
"Computes",
"the",
"common",
"super",
"type",
"for",
"the",
"given",
"list",
"of",
"types",
".",
"The",
"list",
"may",
"not",
"be",
"empty",
"."
] |
train
|
https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.xbase/src/org/eclipse/xtext/xbase/typesystem/computation/AbstractTypeComputer.java#L125-L127
|
smartsheet-platform/smartsheet-java-sdk
|
src/main/java/com/smartsheet/api/internal/AbstractResources.java
|
AbstractResources.postAndReceiveRowObject
|
protected CopyOrMoveRowResult postAndReceiveRowObject(String path, CopyOrMoveRowDirective objectToPost) throws SmartsheetException {
"""
Post an object to Smartsheet REST API and receive a CopyOrMoveRowResult object from response.
Parameters: - path : the relative path of the resource collections - objectToPost : the object to post -
Returns: the object
Exceptions:
IllegalArgumentException : if any argument is null, or path is empty string
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param path the path
@param objectToPost the object to post
@return the result object
@throws SmartsheetException the smartsheet exception
"""
Util.throwIfNull(path, objectToPost);
Util.throwIfEmpty(path);
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
this.smartsheet.getJsonSerializer().serialize(objectToPost, objectBytesStream);
HttpEntity entity = new HttpEntity();
entity.setContentType("application/json");
entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
entity.setContentLength(objectBytesStream.size());
request.setEntity(entity);
CopyOrMoveRowResult obj = null;
try {
HttpResponse response = this.smartsheet.getHttpClient().request(request);
switch (response.getStatusCode()) {
case 200:
obj = this.smartsheet.getJsonSerializer().deserializeCopyOrMoveRow(
response.getEntity().getContent());
break;
default:
handleError(response);
}
} finally {
smartsheet.getHttpClient().releaseConnection();
}
return obj;
}
|
java
|
protected CopyOrMoveRowResult postAndReceiveRowObject(String path, CopyOrMoveRowDirective objectToPost) throws SmartsheetException {
Util.throwIfNull(path, objectToPost);
Util.throwIfEmpty(path);
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
this.smartsheet.getJsonSerializer().serialize(objectToPost, objectBytesStream);
HttpEntity entity = new HttpEntity();
entity.setContentType("application/json");
entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
entity.setContentLength(objectBytesStream.size());
request.setEntity(entity);
CopyOrMoveRowResult obj = null;
try {
HttpResponse response = this.smartsheet.getHttpClient().request(request);
switch (response.getStatusCode()) {
case 200:
obj = this.smartsheet.getJsonSerializer().deserializeCopyOrMoveRow(
response.getEntity().getContent());
break;
default:
handleError(response);
}
} finally {
smartsheet.getHttpClient().releaseConnection();
}
return obj;
}
|
[
"protected",
"CopyOrMoveRowResult",
"postAndReceiveRowObject",
"(",
"String",
"path",
",",
"CopyOrMoveRowDirective",
"objectToPost",
")",
"throws",
"SmartsheetException",
"{",
"Util",
".",
"throwIfNull",
"(",
"path",
",",
"objectToPost",
")",
";",
"Util",
".",
"throwIfEmpty",
"(",
"path",
")",
";",
"HttpRequest",
"request",
"=",
"createHttpRequest",
"(",
"smartsheet",
".",
"getBaseURI",
"(",
")",
".",
"resolve",
"(",
"path",
")",
",",
"HttpMethod",
".",
"POST",
")",
";",
"ByteArrayOutputStream",
"objectBytesStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"this",
".",
"smartsheet",
".",
"getJsonSerializer",
"(",
")",
".",
"serialize",
"(",
"objectToPost",
",",
"objectBytesStream",
")",
";",
"HttpEntity",
"entity",
"=",
"new",
"HttpEntity",
"(",
")",
";",
"entity",
".",
"setContentType",
"(",
"\"application/json\"",
")",
";",
"entity",
".",
"setContent",
"(",
"new",
"ByteArrayInputStream",
"(",
"objectBytesStream",
".",
"toByteArray",
"(",
")",
")",
")",
";",
"entity",
".",
"setContentLength",
"(",
"objectBytesStream",
".",
"size",
"(",
")",
")",
";",
"request",
".",
"setEntity",
"(",
"entity",
")",
";",
"CopyOrMoveRowResult",
"obj",
"=",
"null",
";",
"try",
"{",
"HttpResponse",
"response",
"=",
"this",
".",
"smartsheet",
".",
"getHttpClient",
"(",
")",
".",
"request",
"(",
"request",
")",
";",
"switch",
"(",
"response",
".",
"getStatusCode",
"(",
")",
")",
"{",
"case",
"200",
":",
"obj",
"=",
"this",
".",
"smartsheet",
".",
"getJsonSerializer",
"(",
")",
".",
"deserializeCopyOrMoveRow",
"(",
"response",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"handleError",
"(",
"response",
")",
";",
"}",
"}",
"finally",
"{",
"smartsheet",
".",
"getHttpClient",
"(",
")",
".",
"releaseConnection",
"(",
")",
";",
"}",
"return",
"obj",
";",
"}"
] |
Post an object to Smartsheet REST API and receive a CopyOrMoveRowResult object from response.
Parameters: - path : the relative path of the resource collections - objectToPost : the object to post -
Returns: the object
Exceptions:
IllegalArgumentException : if any argument is null, or path is empty string
InvalidRequestException : if there is any problem with the REST API request
AuthorizationException : if there is any problem with the REST API authorization(access token)
ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
SmartsheetRestException : if there is any other REST API related error occurred during the operation
SmartsheetException : if there is any other error occurred during the operation
@param path the path
@param objectToPost the object to post
@return the result object
@throws SmartsheetException the smartsheet exception
|
[
"Post",
"an",
"object",
"to",
"Smartsheet",
"REST",
"API",
"and",
"receive",
"a",
"CopyOrMoveRowResult",
"object",
"from",
"response",
"."
] |
train
|
https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/AbstractResources.java#L669-L700
|
DiUS/pact-jvm
|
pact-jvm-consumer-java8/src/main/java/io/pactfoundation/consumer/dsl/LambdaDslObject.java
|
LambdaDslObject.eachKeyMappedToAnArrayLike
|
public LambdaDslObject eachKeyMappedToAnArrayLike(String exampleKey, Consumer<LambdaDslObject> nestedObject) {
"""
Accepts any key, and each key is mapped to a list of items that must match the following object definition.
Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified.
@param exampleKey Example key to use for generating bodies
"""
final PactDslJsonBody objectLike = object.eachKeyMappedToAnArrayLike(exampleKey);
final LambdaDslObject dslObject = new LambdaDslObject(objectLike);
nestedObject.accept(dslObject);
objectLike.closeObject().closeArray();
return this;
}
|
java
|
public LambdaDslObject eachKeyMappedToAnArrayLike(String exampleKey, Consumer<LambdaDslObject> nestedObject) {
final PactDslJsonBody objectLike = object.eachKeyMappedToAnArrayLike(exampleKey);
final LambdaDslObject dslObject = new LambdaDslObject(objectLike);
nestedObject.accept(dslObject);
objectLike.closeObject().closeArray();
return this;
}
|
[
"public",
"LambdaDslObject",
"eachKeyMappedToAnArrayLike",
"(",
"String",
"exampleKey",
",",
"Consumer",
"<",
"LambdaDslObject",
">",
"nestedObject",
")",
"{",
"final",
"PactDslJsonBody",
"objectLike",
"=",
"object",
".",
"eachKeyMappedToAnArrayLike",
"(",
"exampleKey",
")",
";",
"final",
"LambdaDslObject",
"dslObject",
"=",
"new",
"LambdaDslObject",
"(",
"objectLike",
")",
";",
"nestedObject",
".",
"accept",
"(",
"dslObject",
")",
";",
"objectLike",
".",
"closeObject",
"(",
")",
".",
"closeArray",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Accepts any key, and each key is mapped to a list of items that must match the following object definition.
Note: this needs the Java system property "pact.matching.wildcard" set to value "true" when the pact file is verified.
@param exampleKey Example key to use for generating bodies
|
[
"Accepts",
"any",
"key",
"and",
"each",
"key",
"is",
"mapped",
"to",
"a",
"list",
"of",
"items",
"that",
"must",
"match",
"the",
"following",
"object",
"definition",
".",
"Note",
":",
"this",
"needs",
"the",
"Java",
"system",
"property",
"pact",
".",
"matching",
".",
"wildcard",
"set",
"to",
"value",
"true",
"when",
"the",
"pact",
"file",
"is",
"verified",
"."
] |
train
|
https://github.com/DiUS/pact-jvm/blob/2f447e9dd4ac152a6a36b7fcf8962d07de9ef3ef/pact-jvm-consumer-java8/src/main/java/io/pactfoundation/consumer/dsl/LambdaDslObject.java#L651-L657
|
sdl/odata
|
odata_renderer/src/main/java/com/sdl/odata/renderer/atom/writer/AtomDataWriter.java
|
AtomDataWriter.writeData
|
public void writeData(Object entity, EntityType entityType) throws XMLStreamException, ODataRenderException {
"""
Write the data for a given entity.
@param entity The given entity.
@param entityType The entity type.
@throws XMLStreamException if unable to render the entity
@throws ODataRenderException if unable to render the entity
"""
xmlWriter.writeStartElement(ODATA_CONTENT);
xmlWriter.writeAttribute(TYPE, XML.toString());
xmlWriter.writeStartElement(METADATA, ODATA_PROPERTIES, "");
marshall(entity, entityType);
xmlWriter.writeEndElement();
xmlWriter.writeEndElement();
}
|
java
|
public void writeData(Object entity, EntityType entityType) throws XMLStreamException, ODataRenderException {
xmlWriter.writeStartElement(ODATA_CONTENT);
xmlWriter.writeAttribute(TYPE, XML.toString());
xmlWriter.writeStartElement(METADATA, ODATA_PROPERTIES, "");
marshall(entity, entityType);
xmlWriter.writeEndElement();
xmlWriter.writeEndElement();
}
|
[
"public",
"void",
"writeData",
"(",
"Object",
"entity",
",",
"EntityType",
"entityType",
")",
"throws",
"XMLStreamException",
",",
"ODataRenderException",
"{",
"xmlWriter",
".",
"writeStartElement",
"(",
"ODATA_CONTENT",
")",
";",
"xmlWriter",
".",
"writeAttribute",
"(",
"TYPE",
",",
"XML",
".",
"toString",
"(",
")",
")",
";",
"xmlWriter",
".",
"writeStartElement",
"(",
"METADATA",
",",
"ODATA_PROPERTIES",
",",
"\"\"",
")",
";",
"marshall",
"(",
"entity",
",",
"entityType",
")",
";",
"xmlWriter",
".",
"writeEndElement",
"(",
")",
";",
"xmlWriter",
".",
"writeEndElement",
"(",
")",
";",
"}"
] |
Write the data for a given entity.
@param entity The given entity.
@param entityType The entity type.
@throws XMLStreamException if unable to render the entity
@throws ODataRenderException if unable to render the entity
|
[
"Write",
"the",
"data",
"for",
"a",
"given",
"entity",
"."
] |
train
|
https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/renderer/atom/writer/AtomDataWriter.java#L90-L100
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/RouteFiltersInner.java
|
RouteFiltersInner.getByResourceGroup
|
public RouteFilterInner getByResourceGroup(String resourceGroupName, String routeFilterName, String expand) {
"""
Gets the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@param expand Expands referenced express route bgp peering resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the RouteFilterInner object if successful.
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, routeFilterName, expand).toBlocking().single().body();
}
|
java
|
public RouteFilterInner getByResourceGroup(String resourceGroupName, String routeFilterName, String expand) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, routeFilterName, expand).toBlocking().single().body();
}
|
[
"public",
"RouteFilterInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"routeFilterName",
",",
"String",
"expand",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"routeFilterName",
",",
"expand",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Gets the specified route filter.
@param resourceGroupName The name of the resource group.
@param routeFilterName The name of the route filter.
@param expand Expands referenced express route bgp peering resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the RouteFilterInner object if successful.
|
[
"Gets",
"the",
"specified",
"route",
"filter",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/RouteFiltersInner.java#L355-L357
|
alkacon/opencms-core
|
src/org/opencms/file/CmsObject.java
|
CmsObject.deleteGroup
|
public void deleteGroup(CmsUUID groupId, CmsUUID replacementId) throws CmsException {
"""
Deletes a group, where all permissions, users and children of the group
are transfered to a replacement group.<p>
@param groupId the id of the group to be deleted
@param replacementId the id of the group to be transfered, can be <code>null</code>
@throws CmsException if operation was not successful
"""
m_securityManager.deleteGroup(m_context, groupId, replacementId);
}
|
java
|
public void deleteGroup(CmsUUID groupId, CmsUUID replacementId) throws CmsException {
m_securityManager.deleteGroup(m_context, groupId, replacementId);
}
|
[
"public",
"void",
"deleteGroup",
"(",
"CmsUUID",
"groupId",
",",
"CmsUUID",
"replacementId",
")",
"throws",
"CmsException",
"{",
"m_securityManager",
".",
"deleteGroup",
"(",
"m_context",
",",
"groupId",
",",
"replacementId",
")",
";",
"}"
] |
Deletes a group, where all permissions, users and children of the group
are transfered to a replacement group.<p>
@param groupId the id of the group to be deleted
@param replacementId the id of the group to be transfered, can be <code>null</code>
@throws CmsException if operation was not successful
|
[
"Deletes",
"a",
"group",
"where",
"all",
"permissions",
"users",
"and",
"children",
"of",
"the",
"group",
"are",
"transfered",
"to",
"a",
"replacement",
"group",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsObject.java#L923-L926
|
nemerosa/ontrack
|
ontrack-common/src/main/java/net/nemerosa/ontrack/common/Utils.java
|
Utils.asList
|
public static List<String> asList(String text) {
"""
Splits a text in several lines.
@param text Text to split
@return Lines. This can be empty but not null.
"""
if (StringUtils.isBlank(text)) {
return Collections.emptyList();
} else {
try {
return IOUtils.readLines(new StringReader(text));
} catch (IOException e) {
throw new RuntimeException("Cannot get lines", e);
}
}
}
|
java
|
public static List<String> asList(String text) {
if (StringUtils.isBlank(text)) {
return Collections.emptyList();
} else {
try {
return IOUtils.readLines(new StringReader(text));
} catch (IOException e) {
throw new RuntimeException("Cannot get lines", e);
}
}
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"asList",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"text",
")",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"return",
"IOUtils",
".",
"readLines",
"(",
"new",
"StringReader",
"(",
"text",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot get lines\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Splits a text in several lines.
@param text Text to split
@return Lines. This can be empty but not null.
|
[
"Splits",
"a",
"text",
"in",
"several",
"lines",
"."
] |
train
|
https://github.com/nemerosa/ontrack/blob/37b0874cbf387b58aba95cd3c1bc3b15e11bc913/ontrack-common/src/main/java/net/nemerosa/ontrack/common/Utils.java#L52-L62
|
sarl/sarl
|
main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/batch/SarlBatchCompiler.java
|
SarlBatchCompiler.preCompileStubs
|
protected boolean preCompileStubs(File sourceDirectory, File classDirectory, IProgressMonitor progress) {
"""
Compile the stub files before the compilation of the project's files.
@param sourceDirectory the source directory where stubs are stored.
@param classDirectory the output directory, where stub binary files should be generated.
@param progress monitor of the progress of the compilation.
@return the success status. Replies <code>false</code> if the activity is canceled.
"""
assert progress != null;
progress.subTask(Messages.SarlBatchCompiler_50);
return runJavaCompiler(classDirectory, Collections.singletonList(sourceDirectory), getClassPath(),
false, false, progress);
}
|
java
|
protected boolean preCompileStubs(File sourceDirectory, File classDirectory, IProgressMonitor progress) {
assert progress != null;
progress.subTask(Messages.SarlBatchCompiler_50);
return runJavaCompiler(classDirectory, Collections.singletonList(sourceDirectory), getClassPath(),
false, false, progress);
}
|
[
"protected",
"boolean",
"preCompileStubs",
"(",
"File",
"sourceDirectory",
",",
"File",
"classDirectory",
",",
"IProgressMonitor",
"progress",
")",
"{",
"assert",
"progress",
"!=",
"null",
";",
"progress",
".",
"subTask",
"(",
"Messages",
".",
"SarlBatchCompiler_50",
")",
";",
"return",
"runJavaCompiler",
"(",
"classDirectory",
",",
"Collections",
".",
"singletonList",
"(",
"sourceDirectory",
")",
",",
"getClassPath",
"(",
")",
",",
"false",
",",
"false",
",",
"progress",
")",
";",
"}"
] |
Compile the stub files before the compilation of the project's files.
@param sourceDirectory the source directory where stubs are stored.
@param classDirectory the output directory, where stub binary files should be generated.
@param progress monitor of the progress of the compilation.
@return the success status. Replies <code>false</code> if the activity is canceled.
|
[
"Compile",
"the",
"stub",
"files",
"before",
"the",
"compilation",
"of",
"the",
"project",
"s",
"files",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/compiler/batch/SarlBatchCompiler.java#L1678-L1683
|
phax/ph-commons
|
ph-cli/src/main/java/com/helger/cli/HelpFormatter.java
|
HelpFormatter.printUsage
|
public void printUsage (@Nonnull final PrintWriter aPW, final int nWidth, final String sCmdLineSyntax) {
"""
Print the sCmdLineSyntax to the specified writer, using the specified
width.
@param aPW
The printWriter to write the help to
@param nWidth
The number of characters per line for the usage statement.
@param sCmdLineSyntax
The usage statement.
"""
final int nArgPos = sCmdLineSyntax.indexOf (' ') + 1;
printWrapped (aPW, nWidth, getSyntaxPrefix ().length () + nArgPos, getSyntaxPrefix () + sCmdLineSyntax);
}
|
java
|
public void printUsage (@Nonnull final PrintWriter aPW, final int nWidth, final String sCmdLineSyntax)
{
final int nArgPos = sCmdLineSyntax.indexOf (' ') + 1;
printWrapped (aPW, nWidth, getSyntaxPrefix ().length () + nArgPos, getSyntaxPrefix () + sCmdLineSyntax);
}
|
[
"public",
"void",
"printUsage",
"(",
"@",
"Nonnull",
"final",
"PrintWriter",
"aPW",
",",
"final",
"int",
"nWidth",
",",
"final",
"String",
"sCmdLineSyntax",
")",
"{",
"final",
"int",
"nArgPos",
"=",
"sCmdLineSyntax",
".",
"indexOf",
"(",
"'",
"'",
")",
"+",
"1",
";",
"printWrapped",
"(",
"aPW",
",",
"nWidth",
",",
"getSyntaxPrefix",
"(",
")",
".",
"length",
"(",
")",
"+",
"nArgPos",
",",
"getSyntaxPrefix",
"(",
")",
"+",
"sCmdLineSyntax",
")",
";",
"}"
] |
Print the sCmdLineSyntax to the specified writer, using the specified
width.
@param aPW
The printWriter to write the help to
@param nWidth
The number of characters per line for the usage statement.
@param sCmdLineSyntax
The usage statement.
|
[
"Print",
"the",
"sCmdLineSyntax",
"to",
"the",
"specified",
"writer",
"using",
"the",
"specified",
"width",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-cli/src/main/java/com/helger/cli/HelpFormatter.java#L755-L760
|
protostuff/protostuff
|
protostuff-yaml/src/main/java/io/protostuff/YamlIOUtil.java
|
YamlIOUtil.writeTo
|
public static <T> int writeTo(OutputStream out, T message, Schema<T> schema,
LinkedBuffer buffer) throws IOException {
"""
Serializes the {@code message} into an {@link OutputStream} with the supplied buffer.
@return the total bytes written to the output.
"""
if (buffer.start != buffer.offset)
throw new IllegalArgumentException("Buffer previously used and had not been reset.");
final YamlOutput output = new YamlOutput(buffer, out, schema);
output.tail = YamlOutput.writeTag(
schema.messageName(),
false,
output.sink,
output,
output.sink.writeByteArray(
START_DIRECTIVE,
output,
buffer));
schema.writeTo(output, message);
LinkedBuffer.writeTo(out, buffer);
return output.getSize();
}
|
java
|
public static <T> int writeTo(OutputStream out, T message, Schema<T> schema,
LinkedBuffer buffer) throws IOException
{
if (buffer.start != buffer.offset)
throw new IllegalArgumentException("Buffer previously used and had not been reset.");
final YamlOutput output = new YamlOutput(buffer, out, schema);
output.tail = YamlOutput.writeTag(
schema.messageName(),
false,
output.sink,
output,
output.sink.writeByteArray(
START_DIRECTIVE,
output,
buffer));
schema.writeTo(output, message);
LinkedBuffer.writeTo(out, buffer);
return output.getSize();
}
|
[
"public",
"static",
"<",
"T",
">",
"int",
"writeTo",
"(",
"OutputStream",
"out",
",",
"T",
"message",
",",
"Schema",
"<",
"T",
">",
"schema",
",",
"LinkedBuffer",
"buffer",
")",
"throws",
"IOException",
"{",
"if",
"(",
"buffer",
".",
"start",
"!=",
"buffer",
".",
"offset",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Buffer previously used and had not been reset.\"",
")",
";",
"final",
"YamlOutput",
"output",
"=",
"new",
"YamlOutput",
"(",
"buffer",
",",
"out",
",",
"schema",
")",
";",
"output",
".",
"tail",
"=",
"YamlOutput",
".",
"writeTag",
"(",
"schema",
".",
"messageName",
"(",
")",
",",
"false",
",",
"output",
".",
"sink",
",",
"output",
",",
"output",
".",
"sink",
".",
"writeByteArray",
"(",
"START_DIRECTIVE",
",",
"output",
",",
"buffer",
")",
")",
";",
"schema",
".",
"writeTo",
"(",
"output",
",",
"message",
")",
";",
"LinkedBuffer",
".",
"writeTo",
"(",
"out",
",",
"buffer",
")",
";",
"return",
"output",
".",
"getSize",
"(",
")",
";",
"}"
] |
Serializes the {@code message} into an {@link OutputStream} with the supplied buffer.
@return the total bytes written to the output.
|
[
"Serializes",
"the",
"{",
"@code",
"message",
"}",
"into",
"an",
"{",
"@link",
"OutputStream",
"}",
"with",
"the",
"supplied",
"buffer",
"."
] |
train
|
https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-yaml/src/main/java/io/protostuff/YamlIOUtil.java#L107-L130
|
baidubce/bce-sdk-java
|
src/main/java/com/baidubce/services/bmr/BmrClient.java
|
BmrClient.listSteps
|
public ListStepsResponse listSteps(String clusterId, String marker, int maxKeys) {
"""
List all the steps of the target BMR cluster.
@param clusterId The ID of the target BMR cluster.
@param marker The start record of steps.
@param maxKeys The maximum number of steps returned.
@return The response containing a list of the BMR steps owned by the cluster.
The steps' records start from the marker and the size of list is limited below maxKeys.
"""
return listSteps(new ListStepsRequest().withClusterId(clusterId)
.withMaxKeys(maxKeys)
.withMarker(marker));
}
|
java
|
public ListStepsResponse listSteps(String clusterId, String marker, int maxKeys) {
return listSteps(new ListStepsRequest().withClusterId(clusterId)
.withMaxKeys(maxKeys)
.withMarker(marker));
}
|
[
"public",
"ListStepsResponse",
"listSteps",
"(",
"String",
"clusterId",
",",
"String",
"marker",
",",
"int",
"maxKeys",
")",
"{",
"return",
"listSteps",
"(",
"new",
"ListStepsRequest",
"(",
")",
".",
"withClusterId",
"(",
"clusterId",
")",
".",
"withMaxKeys",
"(",
"maxKeys",
")",
".",
"withMarker",
"(",
"marker",
")",
")",
";",
"}"
] |
List all the steps of the target BMR cluster.
@param clusterId The ID of the target BMR cluster.
@param marker The start record of steps.
@param maxKeys The maximum number of steps returned.
@return The response containing a list of the BMR steps owned by the cluster.
The steps' records start from the marker and the size of list is limited below maxKeys.
|
[
"List",
"all",
"the",
"steps",
"of",
"the",
"target",
"BMR",
"cluster",
"."
] |
train
|
https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bmr/BmrClient.java#L533-L537
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUService.java
|
ICUService.registerObject
|
public Factory registerObject(Object obj, String id) {
"""
A convenience override of registerObject(Object, String, boolean)
that defaults visible to true.
"""
return registerObject(obj, id, true);
}
|
java
|
public Factory registerObject(Object obj, String id) {
return registerObject(obj, id, true);
}
|
[
"public",
"Factory",
"registerObject",
"(",
"Object",
"obj",
",",
"String",
"id",
")",
"{",
"return",
"registerObject",
"(",
"obj",
",",
"id",
",",
"true",
")",
";",
"}"
] |
A convenience override of registerObject(Object, String, boolean)
that defaults visible to true.
|
[
"A",
"convenience",
"override",
"of",
"registerObject",
"(",
"Object",
"String",
"boolean",
")",
"that",
"defaults",
"visible",
"to",
"true",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUService.java#L775-L777
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/RegexpParser.java
|
RegexpParser.findAnnotations
|
protected void findAnnotations(final String content, final List<FileAnnotation> warnings) throws ParsingCanceledException {
"""
Parses the specified string content and creates annotations for each
found warning.
@param content
the content to scan
@param warnings
the found annotations
@throws ParsingCanceledException
indicates that the user canceled the operation
"""
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
Warning warning = createWarning(matcher);
if (warning != FALSE_POSITIVE) { // NOPMD
detectPackageName(warning);
warnings.add(warning);
}
if (Thread.interrupted()) {
throw new ParsingCanceledException();
}
}
}
|
java
|
protected void findAnnotations(final String content, final List<FileAnnotation> warnings) throws ParsingCanceledException {
Matcher matcher = pattern.matcher(content);
while (matcher.find()) {
Warning warning = createWarning(matcher);
if (warning != FALSE_POSITIVE) { // NOPMD
detectPackageName(warning);
warnings.add(warning);
}
if (Thread.interrupted()) {
throw new ParsingCanceledException();
}
}
}
|
[
"protected",
"void",
"findAnnotations",
"(",
"final",
"String",
"content",
",",
"final",
"List",
"<",
"FileAnnotation",
">",
"warnings",
")",
"throws",
"ParsingCanceledException",
"{",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"content",
")",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"Warning",
"warning",
"=",
"createWarning",
"(",
"matcher",
")",
";",
"if",
"(",
"warning",
"!=",
"FALSE_POSITIVE",
")",
"{",
"// NOPMD",
"detectPackageName",
"(",
"warning",
")",
";",
"warnings",
".",
"add",
"(",
"warning",
")",
";",
"}",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"{",
"throw",
"new",
"ParsingCanceledException",
"(",
")",
";",
"}",
"}",
"}"
] |
Parses the specified string content and creates annotations for each
found warning.
@param content
the content to scan
@param warnings
the found annotations
@throws ParsingCanceledException
indicates that the user canceled the operation
|
[
"Parses",
"the",
"specified",
"string",
"content",
"and",
"creates",
"annotations",
"for",
"each",
"found",
"warning",
"."
] |
train
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/RegexpParser.java#L83-L96
|
Impetus/Kundera
|
src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java
|
MongoDBClient.findCommaSeparatedArgument
|
private String findCommaSeparatedArgument(String functionBody, int index) {
"""
Find comma separated argument.
@param functionBody
the function body
@param index
the index
@return the string
"""
int start = 0;
int found = -1;
int brackets = 0;
int pos = 0;
int length = functionBody.length();
while (found < index && pos < length)
{
char ch = functionBody.charAt(pos);
switch (ch)
{
case ',':
if (brackets == 0)
{
found++;
if (found < index)
{
start = pos + 1;
}
}
break;
case '(':
case '[':
case '{':
brackets++;
break;
case ')':
case ']':
case '}':
brackets--;
break;
}
pos++;
}
if (found == index)
{
return functionBody.substring(start, pos - 1);
}
else if (pos == length)
{
return functionBody.substring(start);
}
else
{
return "";
}
}
|
java
|
private String findCommaSeparatedArgument(String functionBody, int index)
{
int start = 0;
int found = -1;
int brackets = 0;
int pos = 0;
int length = functionBody.length();
while (found < index && pos < length)
{
char ch = functionBody.charAt(pos);
switch (ch)
{
case ',':
if (brackets == 0)
{
found++;
if (found < index)
{
start = pos + 1;
}
}
break;
case '(':
case '[':
case '{':
brackets++;
break;
case ')':
case ']':
case '}':
brackets--;
break;
}
pos++;
}
if (found == index)
{
return functionBody.substring(start, pos - 1);
}
else if (pos == length)
{
return functionBody.substring(start);
}
else
{
return "";
}
}
|
[
"private",
"String",
"findCommaSeparatedArgument",
"(",
"String",
"functionBody",
",",
"int",
"index",
")",
"{",
"int",
"start",
"=",
"0",
";",
"int",
"found",
"=",
"-",
"1",
";",
"int",
"brackets",
"=",
"0",
";",
"int",
"pos",
"=",
"0",
";",
"int",
"length",
"=",
"functionBody",
".",
"length",
"(",
")",
";",
"while",
"(",
"found",
"<",
"index",
"&&",
"pos",
"<",
"length",
")",
"{",
"char",
"ch",
"=",
"functionBody",
".",
"charAt",
"(",
"pos",
")",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"if",
"(",
"brackets",
"==",
"0",
")",
"{",
"found",
"++",
";",
"if",
"(",
"found",
"<",
"index",
")",
"{",
"start",
"=",
"pos",
"+",
"1",
";",
"}",
"}",
"break",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"brackets",
"++",
";",
"break",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"brackets",
"--",
";",
"break",
";",
"}",
"pos",
"++",
";",
"}",
"if",
"(",
"found",
"==",
"index",
")",
"{",
"return",
"functionBody",
".",
"substring",
"(",
"start",
",",
"pos",
"-",
"1",
")",
";",
"}",
"else",
"if",
"(",
"pos",
"==",
"length",
")",
"{",
"return",
"functionBody",
".",
"substring",
"(",
"start",
")",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
Find comma separated argument.
@param functionBody
the function body
@param index
the index
@return the string
|
[
"Find",
"comma",
"separated",
"argument",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java#L1782-L1833
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java
|
DialogFragmentUtils.supportDismissOnLoaderCallback
|
public static void supportDismissOnLoaderCallback(Handler handler, final android.support.v4.app.FragmentManager manager, final String tag) {
"""
Dismiss {@link android.support.v4.app.DialogFragment} for the tag on the loader callbacks with the specified {@link android.os.Handler}.
@param handler the handler, in most case, this handler is the main handler.
@param manager the manager.
@param tag the tag string that is related to the {@link android.support.v4.app.DialogFragment}.
"""
handler.post(new Runnable() {
@Override
public void run() {
android.support.v4.app.DialogFragment fragment = (android.support.v4.app.DialogFragment) manager.findFragmentByTag(tag);
if (fragment != null) {
fragment.dismiss();
}
}
});
}
|
java
|
public static void supportDismissOnLoaderCallback(Handler handler, final android.support.v4.app.FragmentManager manager, final String tag) {
handler.post(new Runnable() {
@Override
public void run() {
android.support.v4.app.DialogFragment fragment = (android.support.v4.app.DialogFragment) manager.findFragmentByTag(tag);
if (fragment != null) {
fragment.dismiss();
}
}
});
}
|
[
"public",
"static",
"void",
"supportDismissOnLoaderCallback",
"(",
"Handler",
"handler",
",",
"final",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"FragmentManager",
"manager",
",",
"final",
"String",
"tag",
")",
"{",
"handler",
".",
"post",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"DialogFragment",
"fragment",
"=",
"(",
"android",
".",
"support",
".",
"v4",
".",
"app",
".",
"DialogFragment",
")",
"manager",
".",
"findFragmentByTag",
"(",
"tag",
")",
";",
"if",
"(",
"fragment",
"!=",
"null",
")",
"{",
"fragment",
".",
"dismiss",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
Dismiss {@link android.support.v4.app.DialogFragment} for the tag on the loader callbacks with the specified {@link android.os.Handler}.
@param handler the handler, in most case, this handler is the main handler.
@param manager the manager.
@param tag the tag string that is related to the {@link android.support.v4.app.DialogFragment}.
|
[
"Dismiss",
"{"
] |
train
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/app/DialogFragmentUtils.java#L104-L114
|
citrusframework/citrus
|
modules/citrus-ftp/src/main/java/com/consol/citrus/ftp/client/FtpClient.java
|
FtpClient.getLocalFileInputStream
|
protected InputStream getLocalFileInputStream(String path, String dataType, TestContext context) throws IOException {
"""
Constructs local file input stream. When using ASCII data type the test variable replacement is activated otherwise
plain byte stream is used.
@param path
@param dataType
@param context
@return
@throws IOException
"""
if (dataType.equals(DataType.ASCII.name())) {
String content = context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(path)));
return new ByteArrayInputStream(content.getBytes(FileUtils.getDefaultCharset()));
} else {
return FileUtils.getFileResource(path).getInputStream();
}
}
|
java
|
protected InputStream getLocalFileInputStream(String path, String dataType, TestContext context) throws IOException {
if (dataType.equals(DataType.ASCII.name())) {
String content = context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(path)));
return new ByteArrayInputStream(content.getBytes(FileUtils.getDefaultCharset()));
} else {
return FileUtils.getFileResource(path).getInputStream();
}
}
|
[
"protected",
"InputStream",
"getLocalFileInputStream",
"(",
"String",
"path",
",",
"String",
"dataType",
",",
"TestContext",
"context",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dataType",
".",
"equals",
"(",
"DataType",
".",
"ASCII",
".",
"name",
"(",
")",
")",
")",
"{",
"String",
"content",
"=",
"context",
".",
"replaceDynamicContentInString",
"(",
"FileUtils",
".",
"readToString",
"(",
"FileUtils",
".",
"getFileResource",
"(",
"path",
")",
")",
")",
";",
"return",
"new",
"ByteArrayInputStream",
"(",
"content",
".",
"getBytes",
"(",
"FileUtils",
".",
"getDefaultCharset",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"FileUtils",
".",
"getFileResource",
"(",
"path",
")",
".",
"getInputStream",
"(",
")",
";",
"}",
"}"
] |
Constructs local file input stream. When using ASCII data type the test variable replacement is activated otherwise
plain byte stream is used.
@param path
@param dataType
@param context
@return
@throws IOException
|
[
"Constructs",
"local",
"file",
"input",
"stream",
".",
"When",
"using",
"ASCII",
"data",
"type",
"the",
"test",
"variable",
"replacement",
"is",
"activated",
"otherwise",
"plain",
"byte",
"stream",
"is",
"used",
"."
] |
train
|
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-ftp/src/main/java/com/consol/citrus/ftp/client/FtpClient.java#L295-L302
|
threerings/narya
|
core/src/main/java/com/threerings/presents/dobj/DObject.java
|
DObject.requestAttributeChange
|
protected void requestAttributeChange (
String name, Object value, Object oldValue, Transport transport) {
"""
Called by derived instances when an attribute setter method was called.
"""
// dispatch an attribute changed event
postEvent(new AttributeChangedEvent(_oid, name, value).
setOldValue(oldValue).setTransport(transport));
}
|
java
|
protected void requestAttributeChange (
String name, Object value, Object oldValue, Transport transport)
{
// dispatch an attribute changed event
postEvent(new AttributeChangedEvent(_oid, name, value).
setOldValue(oldValue).setTransport(transport));
}
|
[
"protected",
"void",
"requestAttributeChange",
"(",
"String",
"name",
",",
"Object",
"value",
",",
"Object",
"oldValue",
",",
"Transport",
"transport",
")",
"{",
"// dispatch an attribute changed event",
"postEvent",
"(",
"new",
"AttributeChangedEvent",
"(",
"_oid",
",",
"name",
",",
"value",
")",
".",
"setOldValue",
"(",
"oldValue",
")",
".",
"setTransport",
"(",
"transport",
")",
")",
";",
"}"
] |
Called by derived instances when an attribute setter method was called.
|
[
"Called",
"by",
"derived",
"instances",
"when",
"an",
"attribute",
"setter",
"method",
"was",
"called",
"."
] |
train
|
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/dobj/DObject.java#L821-L827
|
apiman/apiman
|
gateway/engine/jdbc/src/main/java/io/apiman/gateway/engine/jdbc/JdbcRegistry.java
|
JdbcRegistry.unregisterApiContracts
|
protected void unregisterApiContracts(Client client, Connection connection) throws SQLException {
"""
Removes all of the api contracts from the database.
@param client
@param connection
@throws SQLException
"""
QueryRunner run = new QueryRunner();
run.update(connection, "DELETE FROM contracts WHERE client_org_id = ? AND client_id = ? AND client_version = ?", //$NON-NLS-1$
client.getOrganizationId(), client.getClientId(), client.getVersion());
}
|
java
|
protected void unregisterApiContracts(Client client, Connection connection) throws SQLException {
QueryRunner run = new QueryRunner();
run.update(connection, "DELETE FROM contracts WHERE client_org_id = ? AND client_id = ? AND client_version = ?", //$NON-NLS-1$
client.getOrganizationId(), client.getClientId(), client.getVersion());
}
|
[
"protected",
"void",
"unregisterApiContracts",
"(",
"Client",
"client",
",",
"Connection",
"connection",
")",
"throws",
"SQLException",
"{",
"QueryRunner",
"run",
"=",
"new",
"QueryRunner",
"(",
")",
";",
"run",
".",
"update",
"(",
"connection",
",",
"\"DELETE FROM contracts WHERE client_org_id = ? AND client_id = ? AND client_version = ?\"",
",",
"//$NON-NLS-1$",
"client",
".",
"getOrganizationId",
"(",
")",
",",
"client",
".",
"getClientId",
"(",
")",
",",
"client",
".",
"getVersion",
"(",
")",
")",
";",
"}"
] |
Removes all of the api contracts from the database.
@param client
@param connection
@throws SQLException
|
[
"Removes",
"all",
"of",
"the",
"api",
"contracts",
"from",
"the",
"database",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/jdbc/src/main/java/io/apiman/gateway/engine/jdbc/JdbcRegistry.java#L139-L143
|
banq/jdonframework
|
src/main/java/com/jdon/aop/interceptor/SessionContextInterceptor.java
|
SessionContextInterceptor.setSessionContext
|
private void setSessionContext(Object targetObject, TargetMetaRequest targetMetaRequest) {
"""
WebServiceAccessorImp create sessionContext and save infomation into it
"""
if (isSessionContextAcceptables.contains(targetMetaRequest.getTargetMetaDef().getName())) {
SessionContextAcceptable myResult = (SessionContextAcceptable) targetObject;
SessionContext sessionContext = targetMetaRequest.getSessionContext();
myResult.setSessionContext(sessionContext);
} else if (isSessionContextAcceptablesAnnotations.containsKey(targetMetaRequest.getTargetMetaDef().getName())) {
Method method = isSessionContextAcceptablesAnnotations.get(targetMetaRequest.getTargetMetaDef().getName());
try {
Object[] sessionContexts = new SessionContext[1];
sessionContexts[0] = targetMetaRequest.getSessionContext();
method.invoke(targetObject, sessionContexts);
} catch (Exception e) {
Debug.logError("[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : " + e, module);
}
}
}
|
java
|
private void setSessionContext(Object targetObject, TargetMetaRequest targetMetaRequest) {
if (isSessionContextAcceptables.contains(targetMetaRequest.getTargetMetaDef().getName())) {
SessionContextAcceptable myResult = (SessionContextAcceptable) targetObject;
SessionContext sessionContext = targetMetaRequest.getSessionContext();
myResult.setSessionContext(sessionContext);
} else if (isSessionContextAcceptablesAnnotations.containsKey(targetMetaRequest.getTargetMetaDef().getName())) {
Method method = isSessionContextAcceptablesAnnotations.get(targetMetaRequest.getTargetMetaDef().getName());
try {
Object[] sessionContexts = new SessionContext[1];
sessionContexts[0] = targetMetaRequest.getSessionContext();
method.invoke(targetObject, sessionContexts);
} catch (Exception e) {
Debug.logError("[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : " + e, module);
}
}
}
|
[
"private",
"void",
"setSessionContext",
"(",
"Object",
"targetObject",
",",
"TargetMetaRequest",
"targetMetaRequest",
")",
"{",
"if",
"(",
"isSessionContextAcceptables",
".",
"contains",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"SessionContextAcceptable",
"myResult",
"=",
"(",
"SessionContextAcceptable",
")",
"targetObject",
";",
"SessionContext",
"sessionContext",
"=",
"targetMetaRequest",
".",
"getSessionContext",
"(",
")",
";",
"myResult",
".",
"setSessionContext",
"(",
"sessionContext",
")",
";",
"}",
"else",
"if",
"(",
"isSessionContextAcceptablesAnnotations",
".",
"containsKey",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"Method",
"method",
"=",
"isSessionContextAcceptablesAnnotations",
".",
"get",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"Object",
"[",
"]",
"sessionContexts",
"=",
"new",
"SessionContext",
"[",
"1",
"]",
";",
"sessionContexts",
"[",
"0",
"]",
"=",
"targetMetaRequest",
".",
"getSessionContext",
"(",
")",
";",
"method",
".",
"invoke",
"(",
"targetObject",
",",
"sessionContexts",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : \"",
"+",
"e",
",",
"module",
")",
";",
"}",
"}",
"}"
] |
WebServiceAccessorImp create sessionContext and save infomation into it
|
[
"WebServiceAccessorImp",
"create",
"sessionContext",
"and",
"save",
"infomation",
"into",
"it"
] |
train
|
https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/interceptor/SessionContextInterceptor.java#L137-L153
|
apache/flink
|
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java
|
CheckpointCoordinator.restoreSavepoint
|
public boolean restoreSavepoint(
String savepointPointer,
boolean allowNonRestored,
Map<JobVertexID, ExecutionJobVertex> tasks,
ClassLoader userClassLoader) throws Exception {
"""
Restore the state with given savepoint.
@param savepointPointer The pointer to the savepoint.
@param allowNonRestored True if allowing checkpoint state that cannot be
mapped to any job vertex in tasks.
@param tasks Map of job vertices to restore. State for these
vertices is restored via
{@link Execution#setInitialState(JobManagerTaskRestore)}.
@param userClassLoader The class loader to resolve serialized classes in
legacy savepoint versions.
"""
Preconditions.checkNotNull(savepointPointer, "The savepoint path cannot be null.");
LOG.info("Starting job {} from savepoint {} ({})",
job, savepointPointer, (allowNonRestored ? "allowing non restored state" : ""));
final CompletedCheckpointStorageLocation checkpointLocation = checkpointStorage.resolveCheckpoint(savepointPointer);
// Load the savepoint as a checkpoint into the system
CompletedCheckpoint savepoint = Checkpoints.loadAndValidateCheckpoint(
job, tasks, checkpointLocation, userClassLoader, allowNonRestored);
completedCheckpointStore.addCheckpoint(savepoint);
// Reset the checkpoint ID counter
long nextCheckpointId = savepoint.getCheckpointID() + 1;
checkpointIdCounter.setCount(nextCheckpointId);
LOG.info("Reset the checkpoint ID of job {} to {}.", job, nextCheckpointId);
return restoreLatestCheckpointedState(tasks, true, allowNonRestored);
}
|
java
|
public boolean restoreSavepoint(
String savepointPointer,
boolean allowNonRestored,
Map<JobVertexID, ExecutionJobVertex> tasks,
ClassLoader userClassLoader) throws Exception {
Preconditions.checkNotNull(savepointPointer, "The savepoint path cannot be null.");
LOG.info("Starting job {} from savepoint {} ({})",
job, savepointPointer, (allowNonRestored ? "allowing non restored state" : ""));
final CompletedCheckpointStorageLocation checkpointLocation = checkpointStorage.resolveCheckpoint(savepointPointer);
// Load the savepoint as a checkpoint into the system
CompletedCheckpoint savepoint = Checkpoints.loadAndValidateCheckpoint(
job, tasks, checkpointLocation, userClassLoader, allowNonRestored);
completedCheckpointStore.addCheckpoint(savepoint);
// Reset the checkpoint ID counter
long nextCheckpointId = savepoint.getCheckpointID() + 1;
checkpointIdCounter.setCount(nextCheckpointId);
LOG.info("Reset the checkpoint ID of job {} to {}.", job, nextCheckpointId);
return restoreLatestCheckpointedState(tasks, true, allowNonRestored);
}
|
[
"public",
"boolean",
"restoreSavepoint",
"(",
"String",
"savepointPointer",
",",
"boolean",
"allowNonRestored",
",",
"Map",
"<",
"JobVertexID",
",",
"ExecutionJobVertex",
">",
"tasks",
",",
"ClassLoader",
"userClassLoader",
")",
"throws",
"Exception",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"savepointPointer",
",",
"\"The savepoint path cannot be null.\"",
")",
";",
"LOG",
".",
"info",
"(",
"\"Starting job {} from savepoint {} ({})\"",
",",
"job",
",",
"savepointPointer",
",",
"(",
"allowNonRestored",
"?",
"\"allowing non restored state\"",
":",
"\"\"",
")",
")",
";",
"final",
"CompletedCheckpointStorageLocation",
"checkpointLocation",
"=",
"checkpointStorage",
".",
"resolveCheckpoint",
"(",
"savepointPointer",
")",
";",
"// Load the savepoint as a checkpoint into the system",
"CompletedCheckpoint",
"savepoint",
"=",
"Checkpoints",
".",
"loadAndValidateCheckpoint",
"(",
"job",
",",
"tasks",
",",
"checkpointLocation",
",",
"userClassLoader",
",",
"allowNonRestored",
")",
";",
"completedCheckpointStore",
".",
"addCheckpoint",
"(",
"savepoint",
")",
";",
"// Reset the checkpoint ID counter",
"long",
"nextCheckpointId",
"=",
"savepoint",
".",
"getCheckpointID",
"(",
")",
"+",
"1",
";",
"checkpointIdCounter",
".",
"setCount",
"(",
"nextCheckpointId",
")",
";",
"LOG",
".",
"info",
"(",
"\"Reset the checkpoint ID of job {} to {}.\"",
",",
"job",
",",
"nextCheckpointId",
")",
";",
"return",
"restoreLatestCheckpointedState",
"(",
"tasks",
",",
"true",
",",
"allowNonRestored",
")",
";",
"}"
] |
Restore the state with given savepoint.
@param savepointPointer The pointer to the savepoint.
@param allowNonRestored True if allowing checkpoint state that cannot be
mapped to any job vertex in tasks.
@param tasks Map of job vertices to restore. State for these
vertices is restored via
{@link Execution#setInitialState(JobManagerTaskRestore)}.
@param userClassLoader The class loader to resolve serialized classes in
legacy savepoint versions.
|
[
"Restore",
"the",
"state",
"with",
"given",
"savepoint",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/CheckpointCoordinator.java#L1144-L1170
|
knowm/Yank
|
src/main/java/org/knowm/yank/Yank.java
|
Yank.queryBeanSQLKey
|
public static <T> T queryBeanSQLKey(
String poolName, String sqlKey, Class<T> beanType, Object[] params)
throws SQLStatementNotFoundException, YankSQLException {
"""
Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a
properties file loaded via Yank.addSQLStatements(...). If more than one row match the query,
only the first row is returned.
@param poolName The name of the connection pool to query against
@param sqlKey The SQL Key found in a properties file corresponding to the desired SQL statement
value
@param params The replacement parameters
@param beanType The Class of the desired return Object matching the table
@return The Object
@throws SQLStatementNotFoundException if an SQL statement could not be found for the given
sqlKey String
"""
String sql = YANK_POOL_MANAGER.getMergedSqlProperties().getProperty(sqlKey);
if (sql == null || sql.equalsIgnoreCase("")) {
throw new SQLStatementNotFoundException();
} else {
return queryBean(poolName, sql, beanType, params);
}
}
|
java
|
public static <T> T queryBeanSQLKey(
String poolName, String sqlKey, Class<T> beanType, Object[] params)
throws SQLStatementNotFoundException, YankSQLException {
String sql = YANK_POOL_MANAGER.getMergedSqlProperties().getProperty(sqlKey);
if (sql == null || sql.equalsIgnoreCase("")) {
throw new SQLStatementNotFoundException();
} else {
return queryBean(poolName, sql, beanType, params);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"queryBeanSQLKey",
"(",
"String",
"poolName",
",",
"String",
"sqlKey",
",",
"Class",
"<",
"T",
">",
"beanType",
",",
"Object",
"[",
"]",
"params",
")",
"throws",
"SQLStatementNotFoundException",
",",
"YankSQLException",
"{",
"String",
"sql",
"=",
"YANK_POOL_MANAGER",
".",
"getMergedSqlProperties",
"(",
")",
".",
"getProperty",
"(",
"sqlKey",
")",
";",
"if",
"(",
"sql",
"==",
"null",
"||",
"sql",
".",
"equalsIgnoreCase",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"SQLStatementNotFoundException",
"(",
")",
";",
"}",
"else",
"{",
"return",
"queryBean",
"(",
"poolName",
",",
"sql",
",",
"beanType",
",",
"params",
")",
";",
"}",
"}"
] |
Return just one Bean given a SQL Key using an SQL statement matching the sqlKey String in a
properties file loaded via Yank.addSQLStatements(...). If more than one row match the query,
only the first row is returned.
@param poolName The name of the connection pool to query against
@param sqlKey The SQL Key found in a properties file corresponding to the desired SQL statement
value
@param params The replacement parameters
@param beanType The Class of the desired return Object matching the table
@return The Object
@throws SQLStatementNotFoundException if an SQL statement could not be found for the given
sqlKey String
|
[
"Return",
"just",
"one",
"Bean",
"given",
"a",
"SQL",
"Key",
"using",
"an",
"SQL",
"statement",
"matching",
"the",
"sqlKey",
"String",
"in",
"a",
"properties",
"file",
"loaded",
"via",
"Yank",
".",
"addSQLStatements",
"(",
"...",
")",
".",
"If",
"more",
"than",
"one",
"row",
"match",
"the",
"query",
"only",
"the",
"first",
"row",
"is",
"returned",
"."
] |
train
|
https://github.com/knowm/Yank/blob/b2071dcd94da99db6904355f9557456b8b292a6b/src/main/java/org/knowm/yank/Yank.java#L358-L368
|
Wikidata/Wikidata-Toolkit
|
wdtk-client/src/main/java/org/wikidata/wdtk/client/DumpProcessingOutputAction.java
|
DumpProcessingOutputAction.getAsynchronousOutputStream
|
protected OutputStream getAsynchronousOutputStream(
final OutputStream outputStream) throws IOException {
"""
Creates a separate thread for writing into the given output stream and
returns a pipe output stream that can be used to pass data to this
thread.
<p>
This code is inspired by
http://stackoverflow.com/questions/12532073/gzipoutputstream
-that-does-its-compression-in-a-separate-thread
@param outputStream
the stream to write to in the thread
@return a new stream that data should be written to
@throws IOException
if the pipes could not be created for some reason
"""
final int SIZE = 1024 * 1024 * 10;
final PipedOutputStream pos = new PipedOutputStream();
final PipedInputStream pis = new PipedInputStream(pos, SIZE);
final FinishableRunnable run = new FinishableRunnable() {
volatile boolean finish = false;
volatile boolean hasFinished = false;
@Override
public void finish() {
this.finish = true;
while (!this.hasFinished) {
// loop until thread is really finished
}
}
@Override
public void run() {
try {
byte[] bytes = new byte[SIZE];
// Note that we finish really gently here, writing all data
// that is still in the input first (in theory, new data
// could arrive asynchronously, so that the thread never
// finishes, but this is not the intended mode of
// operation).
for (int len; (!this.finish || pis.available() > 0)
&& (len = pis.read(bytes)) > 0;) {
outputStream.write(bytes, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
close(pis);
close(outputStream);
this.hasFinished = true;
}
}
};
new Thread(run, "async-output-stream").start();
this.outputStreams.add(new Closeable() {
@Override
public void close() throws IOException {
run.finish();
}
});
return pos;
}
|
java
|
protected OutputStream getAsynchronousOutputStream(
final OutputStream outputStream) throws IOException {
final int SIZE = 1024 * 1024 * 10;
final PipedOutputStream pos = new PipedOutputStream();
final PipedInputStream pis = new PipedInputStream(pos, SIZE);
final FinishableRunnable run = new FinishableRunnable() {
volatile boolean finish = false;
volatile boolean hasFinished = false;
@Override
public void finish() {
this.finish = true;
while (!this.hasFinished) {
// loop until thread is really finished
}
}
@Override
public void run() {
try {
byte[] bytes = new byte[SIZE];
// Note that we finish really gently here, writing all data
// that is still in the input first (in theory, new data
// could arrive asynchronously, so that the thread never
// finishes, but this is not the intended mode of
// operation).
for (int len; (!this.finish || pis.available() > 0)
&& (len = pis.read(bytes)) > 0;) {
outputStream.write(bytes, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
close(pis);
close(outputStream);
this.hasFinished = true;
}
}
};
new Thread(run, "async-output-stream").start();
this.outputStreams.add(new Closeable() {
@Override
public void close() throws IOException {
run.finish();
}
});
return pos;
}
|
[
"protected",
"OutputStream",
"getAsynchronousOutputStream",
"(",
"final",
"OutputStream",
"outputStream",
")",
"throws",
"IOException",
"{",
"final",
"int",
"SIZE",
"=",
"1024",
"*",
"1024",
"*",
"10",
";",
"final",
"PipedOutputStream",
"pos",
"=",
"new",
"PipedOutputStream",
"(",
")",
";",
"final",
"PipedInputStream",
"pis",
"=",
"new",
"PipedInputStream",
"(",
"pos",
",",
"SIZE",
")",
";",
"final",
"FinishableRunnable",
"run",
"=",
"new",
"FinishableRunnable",
"(",
")",
"{",
"volatile",
"boolean",
"finish",
"=",
"false",
";",
"volatile",
"boolean",
"hasFinished",
"=",
"false",
";",
"@",
"Override",
"public",
"void",
"finish",
"(",
")",
"{",
"this",
".",
"finish",
"=",
"true",
";",
"while",
"(",
"!",
"this",
".",
"hasFinished",
")",
"{",
"// loop until thread is really finished",
"}",
"}",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"SIZE",
"]",
";",
"// Note that we finish really gently here, writing all data",
"// that is still in the input first (in theory, new data",
"// could arrive asynchronously, so that the thread never",
"// finishes, but this is not the intended mode of",
"// operation).",
"for",
"(",
"int",
"len",
";",
"(",
"!",
"this",
".",
"finish",
"||",
"pis",
".",
"available",
"(",
")",
">",
"0",
")",
"&&",
"(",
"len",
"=",
"pis",
".",
"read",
"(",
"bytes",
")",
")",
">",
"0",
";",
")",
"{",
"outputStream",
".",
"write",
"(",
"bytes",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"pis",
")",
";",
"close",
"(",
"outputStream",
")",
";",
"this",
".",
"hasFinished",
"=",
"true",
";",
"}",
"}",
"}",
";",
"new",
"Thread",
"(",
"run",
",",
"\"async-output-stream\"",
")",
".",
"start",
"(",
")",
";",
"this",
".",
"outputStreams",
".",
"add",
"(",
"new",
"Closeable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"run",
".",
"finish",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"pos",
";",
"}"
] |
Creates a separate thread for writing into the given output stream and
returns a pipe output stream that can be used to pass data to this
thread.
<p>
This code is inspired by
http://stackoverflow.com/questions/12532073/gzipoutputstream
-that-does-its-compression-in-a-separate-thread
@param outputStream
the stream to write to in the thread
@return a new stream that data should be written to
@throws IOException
if the pipes could not be created for some reason
|
[
"Creates",
"a",
"separate",
"thread",
"for",
"writing",
"into",
"the",
"given",
"output",
"stream",
"and",
"returns",
"a",
"pipe",
"output",
"stream",
"that",
"can",
"be",
"used",
"to",
"pass",
"data",
"to",
"this",
"thread",
".",
"<p",
">",
"This",
"code",
"is",
"inspired",
"by",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"12532073",
"/",
"gzipoutputstream",
"-",
"that",
"-",
"does",
"-",
"its",
"-",
"compression",
"-",
"in",
"-",
"a",
"-",
"separate",
"-",
"thread"
] |
train
|
https://github.com/Wikidata/Wikidata-Toolkit/blob/7732851dda47e1febff406fba27bfec023f4786e/wdtk-client/src/main/java/org/wikidata/wdtk/client/DumpProcessingOutputAction.java#L287-L339
|
susom/database
|
src/main/java/com/github/susom/database/DatabaseProvider.java
|
DatabaseProvider.fromProperties
|
public static Builder fromProperties(Properties properties, String propertyPrefix) {
"""
Configure the database from up to five properties read from the provided properties:
<br/>
<pre>
database.url=... Database connect string (required)
database.user=... Authenticate as this user (optional if provided in url)
database.password=... User password (optional if user and password provided in
url; prompted on standard input if user is provided and
password is not)
database.flavor=... What kind of database it is (optional, will guess based
on the url if this is not provided)
database.driver=... The Java class of the JDBC driver to load (optional, will
guess based on the flavor if this is not provided)
</pre>
@param properties properties will be read from here
@param propertyPrefix if this is null or empty the properties above will be read;
if a value is provided it will be prefixed to each property
(exactly, so if you want to use "my.database.url" you must
pass "my." as the prefix)
@throws DatabaseException if the property file could not be read for any reason
"""
return fromProperties(properties, propertyPrefix, false);
}
|
java
|
public static Builder fromProperties(Properties properties, String propertyPrefix) {
return fromProperties(properties, propertyPrefix, false);
}
|
[
"public",
"static",
"Builder",
"fromProperties",
"(",
"Properties",
"properties",
",",
"String",
"propertyPrefix",
")",
"{",
"return",
"fromProperties",
"(",
"properties",
",",
"propertyPrefix",
",",
"false",
")",
";",
"}"
] |
Configure the database from up to five properties read from the provided properties:
<br/>
<pre>
database.url=... Database connect string (required)
database.user=... Authenticate as this user (optional if provided in url)
database.password=... User password (optional if user and password provided in
url; prompted on standard input if user is provided and
password is not)
database.flavor=... What kind of database it is (optional, will guess based
on the url if this is not provided)
database.driver=... The Java class of the JDBC driver to load (optional, will
guess based on the flavor if this is not provided)
</pre>
@param properties properties will be read from here
@param propertyPrefix if this is null or empty the properties above will be read;
if a value is provided it will be prefixed to each property
(exactly, so if you want to use "my.database.url" you must
pass "my." as the prefix)
@throws DatabaseException if the property file could not be read for any reason
|
[
"Configure",
"the",
"database",
"from",
"up",
"to",
"five",
"properties",
"read",
"from",
"the",
"provided",
"properties",
":",
"<br",
"/",
">",
"<pre",
">",
"database",
".",
"url",
"=",
"...",
"Database",
"connect",
"string",
"(",
"required",
")",
"database",
".",
"user",
"=",
"...",
"Authenticate",
"as",
"this",
"user",
"(",
"optional",
"if",
"provided",
"in",
"url",
")",
"database",
".",
"password",
"=",
"...",
"User",
"password",
"(",
"optional",
"if",
"user",
"and",
"password",
"provided",
"in",
"url",
";",
"prompted",
"on",
"standard",
"input",
"if",
"user",
"is",
"provided",
"and",
"password",
"is",
"not",
")",
"database",
".",
"flavor",
"=",
"...",
"What",
"kind",
"of",
"database",
"it",
"is",
"(",
"optional",
"will",
"guess",
"based",
"on",
"the",
"url",
"if",
"this",
"is",
"not",
"provided",
")",
"database",
".",
"driver",
"=",
"...",
"The",
"Java",
"class",
"of",
"the",
"JDBC",
"driver",
"to",
"load",
"(",
"optional",
"will",
"guess",
"based",
"on",
"the",
"flavor",
"if",
"this",
"is",
"not",
"provided",
")",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/susom/database/blob/25add9e08ad863712f9b5e319b6cb826f6f97640/src/main/java/com/github/susom/database/DatabaseProvider.java#L394-L396
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java
|
Subtypes2.computeFirstCommonSuperclassOfDifferentDimensionArrays
|
private ReferenceType computeFirstCommonSuperclassOfDifferentDimensionArrays(ArrayType aArrType, ArrayType bArrType) {
"""
Get the first common superclass of arrays with different numbers of
dimensions.
@param aArrType
an ArrayType
@param bArrType
another ArrayType
@return ReferenceType representing first common superclass
"""
assert aArrType.getDimensions() != bArrType.getDimensions();
boolean aBaseTypeIsPrimitive = (aArrType.getBasicType() instanceof BasicType);
boolean bBaseTypeIsPrimitive = (bArrType.getBasicType() instanceof BasicType);
if (aBaseTypeIsPrimitive || bBaseTypeIsPrimitive) {
int minDimensions, maxDimensions;
if (aArrType.getDimensions() < bArrType.getDimensions()) {
minDimensions = aArrType.getDimensions();
maxDimensions = bArrType.getDimensions();
} else {
minDimensions = bArrType.getDimensions();
maxDimensions = aArrType.getDimensions();
}
if (minDimensions == 1) {
// One of the types was something like int[].
// The only possible common supertype is Object.
return Type.OBJECT;
} else {
// Weird case: e.g.,
// - first common supertype of int[][] and char[][][] is
// Object[]
// because f.c.s. of int[] and char[][] is Object
// - first common supertype of int[][][] and char[][][][][] is
// Object[][]
// because f.c.s. of int[] and char[][][] is Object
return new ArrayType(Type.OBJECT, maxDimensions - minDimensions);
}
} else {
// Both a and b have base types which are ObjectTypes.
// Since the arrays have different numbers of dimensions, the
// f.c.s. will have Object as its base type.
// E.g., f.c.s. of Cat[] and Dog[][] is Object[]
return new ArrayType(Type.OBJECT, Math.min(aArrType.getDimensions(), bArrType.getDimensions()));
}
}
|
java
|
private ReferenceType computeFirstCommonSuperclassOfDifferentDimensionArrays(ArrayType aArrType, ArrayType bArrType) {
assert aArrType.getDimensions() != bArrType.getDimensions();
boolean aBaseTypeIsPrimitive = (aArrType.getBasicType() instanceof BasicType);
boolean bBaseTypeIsPrimitive = (bArrType.getBasicType() instanceof BasicType);
if (aBaseTypeIsPrimitive || bBaseTypeIsPrimitive) {
int minDimensions, maxDimensions;
if (aArrType.getDimensions() < bArrType.getDimensions()) {
minDimensions = aArrType.getDimensions();
maxDimensions = bArrType.getDimensions();
} else {
minDimensions = bArrType.getDimensions();
maxDimensions = aArrType.getDimensions();
}
if (minDimensions == 1) {
// One of the types was something like int[].
// The only possible common supertype is Object.
return Type.OBJECT;
} else {
// Weird case: e.g.,
// - first common supertype of int[][] and char[][][] is
// Object[]
// because f.c.s. of int[] and char[][] is Object
// - first common supertype of int[][][] and char[][][][][] is
// Object[][]
// because f.c.s. of int[] and char[][][] is Object
return new ArrayType(Type.OBJECT, maxDimensions - minDimensions);
}
} else {
// Both a and b have base types which are ObjectTypes.
// Since the arrays have different numbers of dimensions, the
// f.c.s. will have Object as its base type.
// E.g., f.c.s. of Cat[] and Dog[][] is Object[]
return new ArrayType(Type.OBJECT, Math.min(aArrType.getDimensions(), bArrType.getDimensions()));
}
}
|
[
"private",
"ReferenceType",
"computeFirstCommonSuperclassOfDifferentDimensionArrays",
"(",
"ArrayType",
"aArrType",
",",
"ArrayType",
"bArrType",
")",
"{",
"assert",
"aArrType",
".",
"getDimensions",
"(",
")",
"!=",
"bArrType",
".",
"getDimensions",
"(",
")",
";",
"boolean",
"aBaseTypeIsPrimitive",
"=",
"(",
"aArrType",
".",
"getBasicType",
"(",
")",
"instanceof",
"BasicType",
")",
";",
"boolean",
"bBaseTypeIsPrimitive",
"=",
"(",
"bArrType",
".",
"getBasicType",
"(",
")",
"instanceof",
"BasicType",
")",
";",
"if",
"(",
"aBaseTypeIsPrimitive",
"||",
"bBaseTypeIsPrimitive",
")",
"{",
"int",
"minDimensions",
",",
"maxDimensions",
";",
"if",
"(",
"aArrType",
".",
"getDimensions",
"(",
")",
"<",
"bArrType",
".",
"getDimensions",
"(",
")",
")",
"{",
"minDimensions",
"=",
"aArrType",
".",
"getDimensions",
"(",
")",
";",
"maxDimensions",
"=",
"bArrType",
".",
"getDimensions",
"(",
")",
";",
"}",
"else",
"{",
"minDimensions",
"=",
"bArrType",
".",
"getDimensions",
"(",
")",
";",
"maxDimensions",
"=",
"aArrType",
".",
"getDimensions",
"(",
")",
";",
"}",
"if",
"(",
"minDimensions",
"==",
"1",
")",
"{",
"// One of the types was something like int[].",
"// The only possible common supertype is Object.",
"return",
"Type",
".",
"OBJECT",
";",
"}",
"else",
"{",
"// Weird case: e.g.,",
"// - first common supertype of int[][] and char[][][] is",
"// Object[]",
"// because f.c.s. of int[] and char[][] is Object",
"// - first common supertype of int[][][] and char[][][][][] is",
"// Object[][]",
"// because f.c.s. of int[] and char[][][] is Object",
"return",
"new",
"ArrayType",
"(",
"Type",
".",
"OBJECT",
",",
"maxDimensions",
"-",
"minDimensions",
")",
";",
"}",
"}",
"else",
"{",
"// Both a and b have base types which are ObjectTypes.",
"// Since the arrays have different numbers of dimensions, the",
"// f.c.s. will have Object as its base type.",
"// E.g., f.c.s. of Cat[] and Dog[][] is Object[]",
"return",
"new",
"ArrayType",
"(",
"Type",
".",
"OBJECT",
",",
"Math",
".",
"min",
"(",
"aArrType",
".",
"getDimensions",
"(",
")",
",",
"bArrType",
".",
"getDimensions",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Get the first common superclass of arrays with different numbers of
dimensions.
@param aArrType
an ArrayType
@param bArrType
another ArrayType
@return ReferenceType representing first common superclass
|
[
"Get",
"the",
"first",
"common",
"superclass",
"of",
"arrays",
"with",
"different",
"numbers",
"of",
"dimensions",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/ch/Subtypes2.java#L643-L680
|
alkacon/opencms-core
|
src/org/opencms/ade/configuration/CmsADEManager.java
|
CmsADEManager.getDetailPage
|
public String getDetailPage(CmsObject cms, String pageRootPath, String originPath) {
"""
Gets the detail page for a content element.<p>
@param cms the CMS context
@param pageRootPath the element's root path
@param originPath the path in which the the detail page is being requested
@return the detail page for the content element
"""
return getDetailPage(cms, pageRootPath, originPath, null);
}
|
java
|
public String getDetailPage(CmsObject cms, String pageRootPath, String originPath) {
return getDetailPage(cms, pageRootPath, originPath, null);
}
|
[
"public",
"String",
"getDetailPage",
"(",
"CmsObject",
"cms",
",",
"String",
"pageRootPath",
",",
"String",
"originPath",
")",
"{",
"return",
"getDetailPage",
"(",
"cms",
",",
"pageRootPath",
",",
"originPath",
",",
"null",
")",
";",
"}"
] |
Gets the detail page for a content element.<p>
@param cms the CMS context
@param pageRootPath the element's root path
@param originPath the path in which the the detail page is being requested
@return the detail page for the content element
|
[
"Gets",
"the",
"detail",
"page",
"for",
"a",
"content",
"element",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L427-L430
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/CollationRootElements.java
|
CollationRootElements.getPrimaryBefore
|
long getPrimaryBefore(long p, boolean isCompressible) {
"""
Returns the primary weight before p.
p must be greater than the first root primary.
"""
int index = findPrimary(p);
int step;
long q = elements[index];
if(p == (q & 0xffffff00L)) {
// Found p itself. Return the previous primary.
// See if p is at the end of a previous range.
step = (int)q & PRIMARY_STEP_MASK;
if(step == 0) {
// p is not at the end of a range. Look for the previous primary.
do {
p = elements[--index];
} while((p & SEC_TER_DELTA_FLAG) != 0);
return p & 0xffffff00L;
}
} else {
// p is in a range, and not at the start.
long nextElement = elements[index + 1];
assert(isEndOfPrimaryRange(nextElement));
step = (int)nextElement & PRIMARY_STEP_MASK;
}
// Return the previous range primary.
if((p & 0xffff) == 0) {
return Collation.decTwoBytePrimaryByOneStep(p, isCompressible, step);
} else {
return Collation.decThreeBytePrimaryByOneStep(p, isCompressible, step);
}
}
|
java
|
long getPrimaryBefore(long p, boolean isCompressible) {
int index = findPrimary(p);
int step;
long q = elements[index];
if(p == (q & 0xffffff00L)) {
// Found p itself. Return the previous primary.
// See if p is at the end of a previous range.
step = (int)q & PRIMARY_STEP_MASK;
if(step == 0) {
// p is not at the end of a range. Look for the previous primary.
do {
p = elements[--index];
} while((p & SEC_TER_DELTA_FLAG) != 0);
return p & 0xffffff00L;
}
} else {
// p is in a range, and not at the start.
long nextElement = elements[index + 1];
assert(isEndOfPrimaryRange(nextElement));
step = (int)nextElement & PRIMARY_STEP_MASK;
}
// Return the previous range primary.
if((p & 0xffff) == 0) {
return Collation.decTwoBytePrimaryByOneStep(p, isCompressible, step);
} else {
return Collation.decThreeBytePrimaryByOneStep(p, isCompressible, step);
}
}
|
[
"long",
"getPrimaryBefore",
"(",
"long",
"p",
",",
"boolean",
"isCompressible",
")",
"{",
"int",
"index",
"=",
"findPrimary",
"(",
"p",
")",
";",
"int",
"step",
";",
"long",
"q",
"=",
"elements",
"[",
"index",
"]",
";",
"if",
"(",
"p",
"==",
"(",
"q",
"&",
"0xffffff00",
"L",
")",
")",
"{",
"// Found p itself. Return the previous primary.",
"// See if p is at the end of a previous range.",
"step",
"=",
"(",
"int",
")",
"q",
"&",
"PRIMARY_STEP_MASK",
";",
"if",
"(",
"step",
"==",
"0",
")",
"{",
"// p is not at the end of a range. Look for the previous primary.",
"do",
"{",
"p",
"=",
"elements",
"[",
"--",
"index",
"]",
";",
"}",
"while",
"(",
"(",
"p",
"&",
"SEC_TER_DELTA_FLAG",
")",
"!=",
"0",
")",
";",
"return",
"p",
"&",
"0xffffff00",
"",
"L",
";",
"}",
"}",
"else",
"{",
"// p is in a range, and not at the start.",
"long",
"nextElement",
"=",
"elements",
"[",
"index",
"+",
"1",
"]",
";",
"assert",
"(",
"isEndOfPrimaryRange",
"(",
"nextElement",
")",
")",
";",
"step",
"=",
"(",
"int",
")",
"nextElement",
"&",
"PRIMARY_STEP_MASK",
";",
"}",
"// Return the previous range primary.",
"if",
"(",
"(",
"p",
"&",
"0xffff",
")",
"==",
"0",
")",
"{",
"return",
"Collation",
".",
"decTwoBytePrimaryByOneStep",
"(",
"p",
",",
"isCompressible",
",",
"step",
")",
";",
"}",
"else",
"{",
"return",
"Collation",
".",
"decThreeBytePrimaryByOneStep",
"(",
"p",
",",
"isCompressible",
",",
"step",
")",
";",
"}",
"}"
] |
Returns the primary weight before p.
p must be greater than the first root primary.
|
[
"Returns",
"the",
"primary",
"weight",
"before",
"p",
".",
"p",
"must",
"be",
"greater",
"than",
"the",
"first",
"root",
"primary",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/coll/CollationRootElements.java#L220-L247
|
deeplearning4j/deeplearning4j
|
deeplearning4j/deeplearning4j-nearestneighbors-parent/nearestneighbor-core/src/main/java/org/deeplearning4j/clustering/randomprojection/RPUtils.java
|
RPUtils.scanForLeaves
|
public static void scanForLeaves(List<RPNode> nodes,RPNode current) {
"""
Scan for leaves accumulating
the nodes in the passed in list
@param nodes the nodes so far
"""
if(current.getLeft() == null && current.getRight() == null)
nodes.add(current);
if(current.getLeft() != null)
scanForLeaves(nodes,current.getLeft());
if(current.getRight() != null)
scanForLeaves(nodes,current.getRight());
}
|
java
|
public static void scanForLeaves(List<RPNode> nodes,RPNode current) {
if(current.getLeft() == null && current.getRight() == null)
nodes.add(current);
if(current.getLeft() != null)
scanForLeaves(nodes,current.getLeft());
if(current.getRight() != null)
scanForLeaves(nodes,current.getRight());
}
|
[
"public",
"static",
"void",
"scanForLeaves",
"(",
"List",
"<",
"RPNode",
">",
"nodes",
",",
"RPNode",
"current",
")",
"{",
"if",
"(",
"current",
".",
"getLeft",
"(",
")",
"==",
"null",
"&&",
"current",
".",
"getRight",
"(",
")",
"==",
"null",
")",
"nodes",
".",
"add",
"(",
"current",
")",
";",
"if",
"(",
"current",
".",
"getLeft",
"(",
")",
"!=",
"null",
")",
"scanForLeaves",
"(",
"nodes",
",",
"current",
".",
"getLeft",
"(",
")",
")",
";",
"if",
"(",
"current",
".",
"getRight",
"(",
")",
"!=",
"null",
")",
"scanForLeaves",
"(",
"nodes",
",",
"current",
".",
"getRight",
"(",
")",
")",
";",
"}"
] |
Scan for leaves accumulating
the nodes in the passed in list
@param nodes the nodes so far
|
[
"Scan",
"for",
"leaves",
"accumulating",
"the",
"nodes",
"in",
"the",
"passed",
"in",
"list"
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nearestneighbors-parent/nearestneighbor-core/src/main/java/org/deeplearning4j/clustering/randomprojection/RPUtils.java#L460-L467
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/NodeSetDTM.java
|
NodeSetDTM.addElement
|
public void addElement(int value) {
"""
Append a Node onto the vector.
@param value The node to be added.
@throws RuntimeException thrown if this NodeSetDTM is not of
a mutable type.
"""
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.addElement(value);
}
|
java
|
public void addElement(int value)
{
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.addElement(value);
}
|
[
"public",
"void",
"addElement",
"(",
"int",
"value",
")",
"{",
"if",
"(",
"!",
"m_mutable",
")",
"throw",
"new",
"RuntimeException",
"(",
"XSLMessages",
".",
"createXPATHMessage",
"(",
"XPATHErrorResources",
".",
"ER_NODESETDTM_NOT_MUTABLE",
",",
"null",
")",
")",
";",
"//\"This NodeSetDTM is not mutable!\");",
"super",
".",
"addElement",
"(",
"value",
")",
";",
"}"
] |
Append a Node onto the vector.
@param value The node to be added.
@throws RuntimeException thrown if this NodeSetDTM is not of
a mutable type.
|
[
"Append",
"a",
"Node",
"onto",
"the",
"vector",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/NodeSetDTM.java#L893-L900
|
JOML-CI/JOML
|
src/org/joml/Matrix4f.java
|
Matrix4f.perspectiveLH
|
public Matrix4f perspectiveLH(float fovy, float aspect, float zNear, float zFar, boolean zZeroToOne, Matrix4f dest) {
"""
Apply a symmetric perspective projection frustum transformation for a left-handed coordinate system
using the given NDC z range to this matrix and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>P</code> the perspective projection matrix,
then the new matrix will be <code>M * P</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * P * v</code>,
the perspective projection will be applied first!
<p>
In order to set the matrix to a perspective frustum transformation without post-multiplying,
use {@link #setPerspectiveLH(float, float, float, float, boolean) setPerspectiveLH}.
@see #setPerspectiveLH(float, float, float, float, boolean)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@param dest
will hold the result
@return dest
"""
if ((properties & PROPERTY_IDENTITY) != 0)
return dest.setPerspectiveLH(fovy, aspect, zNear, zFar, zZeroToOne);
return perspectiveLHGeneric(fovy, aspect, zNear, zFar, zZeroToOne, dest);
}
|
java
|
public Matrix4f perspectiveLH(float fovy, float aspect, float zNear, float zFar, boolean zZeroToOne, Matrix4f dest) {
if ((properties & PROPERTY_IDENTITY) != 0)
return dest.setPerspectiveLH(fovy, aspect, zNear, zFar, zZeroToOne);
return perspectiveLHGeneric(fovy, aspect, zNear, zFar, zZeroToOne, dest);
}
|
[
"public",
"Matrix4f",
"perspectiveLH",
"(",
"float",
"fovy",
",",
"float",
"aspect",
",",
"float",
"zNear",
",",
"float",
"zFar",
",",
"boolean",
"zZeroToOne",
",",
"Matrix4f",
"dest",
")",
"{",
"if",
"(",
"(",
"properties",
"&",
"PROPERTY_IDENTITY",
")",
"!=",
"0",
")",
"return",
"dest",
".",
"setPerspectiveLH",
"(",
"fovy",
",",
"aspect",
",",
"zNear",
",",
"zFar",
",",
"zZeroToOne",
")",
";",
"return",
"perspectiveLHGeneric",
"(",
"fovy",
",",
"aspect",
",",
"zNear",
",",
"zFar",
",",
"zZeroToOne",
",",
"dest",
")",
";",
"}"
] |
Apply a symmetric perspective projection frustum transformation for a left-handed coordinate system
using the given NDC z range to this matrix and store the result in <code>dest</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>P</code> the perspective projection matrix,
then the new matrix will be <code>M * P</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * P * v</code>,
the perspective projection will be applied first!
<p>
In order to set the matrix to a perspective frustum transformation without post-multiplying,
use {@link #setPerspectiveLH(float, float, float, float, boolean) setPerspectiveLH}.
@see #setPerspectiveLH(float, float, float, float, boolean)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zZeroToOne
whether to use Vulkan's and Direct3D's NDC z range of <code>[0..+1]</code> when <code>true</code>
or whether to use OpenGL's NDC z range of <code>[-1..+1]</code> when <code>false</code>
@param dest
will hold the result
@return dest
|
[
"Apply",
"a",
"symmetric",
"perspective",
"projection",
"frustum",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"using",
"the",
"given",
"NDC",
"z",
"range",
"to",
"this",
"matrix",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"P<",
"/",
"code",
">",
"the",
"perspective",
"projection",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"P<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"P",
"*",
"v<",
"/",
"code",
">",
"the",
"perspective",
"projection",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"perspective",
"frustum",
"transformation",
"without",
"post",
"-",
"multiplying",
"use",
"{",
"@link",
"#setPerspectiveLH",
"(",
"float",
"float",
"float",
"float",
"boolean",
")",
"setPerspectiveLH",
"}",
"."
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L10064-L10068
|
Azure/azure-sdk-for-java
|
keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java
|
KeyVaultClientBaseImpl.recoverDeletedStorageAccountAsync
|
public ServiceFuture<StorageBundle> recoverDeletedStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<StorageBundle> serviceCallback) {
"""
Recovers the deleted storage account.
Recovers the deleted storage account in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/recover permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(recoverDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
}
|
java
|
public ServiceFuture<StorageBundle> recoverDeletedStorageAccountAsync(String vaultBaseUrl, String storageAccountName, final ServiceCallback<StorageBundle> serviceCallback) {
return ServiceFuture.fromResponse(recoverDeletedStorageAccountWithServiceResponseAsync(vaultBaseUrl, storageAccountName), serviceCallback);
}
|
[
"public",
"ServiceFuture",
"<",
"StorageBundle",
">",
"recoverDeletedStorageAccountAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"storageAccountName",
",",
"final",
"ServiceCallback",
"<",
"StorageBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"recoverDeletedStorageAccountWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"storageAccountName",
")",
",",
"serviceCallback",
")",
";",
"}"
] |
Recovers the deleted storage account.
Recovers the deleted storage account in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation requires the storage/recover permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param storageAccountName The name of the storage account.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
|
[
"Recovers",
"the",
"deleted",
"storage",
"account",
".",
"Recovers",
"the",
"deleted",
"storage",
"account",
"in",
"the",
"specified",
"vault",
".",
"This",
"operation",
"can",
"only",
"be",
"performed",
"on",
"a",
"soft",
"-",
"delete",
"enabled",
"vault",
".",
"This",
"operation",
"requires",
"the",
"storage",
"/",
"recover",
"permission",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L9446-L9448
|
adorsys/hbci4java-adorsys
|
src/main/java/org/kapott/cryptalgs/PKCS1_PSS.java
|
PKCS1_PSS.emsa_pss_verify
|
public static boolean emsa_pss_verify(SignatureParamSpec spec, byte[] msg, byte[] EM, int emBits) {
"""
--- stuff from the PKCS#1-PSS specification ---------------------------
"""
int emLen = emBits >> 3;
if ((emBits & 7) != 0) {
emLen++;
}
byte[] mHash = hash(spec, msg);
// System.out.println("mHash: "+Utils.bytes2String(mHash));
MessageDigest dig = getMessageDigest(spec);
int hLen = dig.getDigestLength();
// System.out.println("hLen: "+hLen);
int sLen = hLen;
if (EM[EM.length - 1] != (byte) 0xBC) {
// System.out.println("no BC at the end");
return false;
}
byte[] maskedDB = new byte[emLen - hLen - 1];
byte[] H = new byte[hLen];
System.arraycopy(EM, 0, maskedDB, 0, emLen - hLen - 1);
System.arraycopy(EM, emLen - hLen - 1, H, 0, hLen);
// TODO: verify if first X bits of maskedDB are zero
byte[] dbMask = mgf1(spec, H, emLen - hLen - 1);
byte[] DB = xor_os(maskedDB, dbMask);
// set leftmost X bits of DB to zero
int tooMuchBits = (emLen << 3) - emBits;
byte mask = (byte) (0xFF >>> tooMuchBits);
DB[0] &= mask;
// TODO: another consistency check
byte[] salt = new byte[sLen];
System.arraycopy(DB, DB.length - sLen, salt, 0, sLen);
byte[] zeroes = new byte[8];
byte[] m2 = concat(concat(zeroes, mHash), salt);
byte[] H2 = hash(spec, m2);
return Arrays.equals(H, H2);
}
|
java
|
public static boolean emsa_pss_verify(SignatureParamSpec spec, byte[] msg, byte[] EM, int emBits) {
int emLen = emBits >> 3;
if ((emBits & 7) != 0) {
emLen++;
}
byte[] mHash = hash(spec, msg);
// System.out.println("mHash: "+Utils.bytes2String(mHash));
MessageDigest dig = getMessageDigest(spec);
int hLen = dig.getDigestLength();
// System.out.println("hLen: "+hLen);
int sLen = hLen;
if (EM[EM.length - 1] != (byte) 0xBC) {
// System.out.println("no BC at the end");
return false;
}
byte[] maskedDB = new byte[emLen - hLen - 1];
byte[] H = new byte[hLen];
System.arraycopy(EM, 0, maskedDB, 0, emLen - hLen - 1);
System.arraycopy(EM, emLen - hLen - 1, H, 0, hLen);
// TODO: verify if first X bits of maskedDB are zero
byte[] dbMask = mgf1(spec, H, emLen - hLen - 1);
byte[] DB = xor_os(maskedDB, dbMask);
// set leftmost X bits of DB to zero
int tooMuchBits = (emLen << 3) - emBits;
byte mask = (byte) (0xFF >>> tooMuchBits);
DB[0] &= mask;
// TODO: another consistency check
byte[] salt = new byte[sLen];
System.arraycopy(DB, DB.length - sLen, salt, 0, sLen);
byte[] zeroes = new byte[8];
byte[] m2 = concat(concat(zeroes, mHash), salt);
byte[] H2 = hash(spec, m2);
return Arrays.equals(H, H2);
}
|
[
"public",
"static",
"boolean",
"emsa_pss_verify",
"(",
"SignatureParamSpec",
"spec",
",",
"byte",
"[",
"]",
"msg",
",",
"byte",
"[",
"]",
"EM",
",",
"int",
"emBits",
")",
"{",
"int",
"emLen",
"=",
"emBits",
">>",
"3",
";",
"if",
"(",
"(",
"emBits",
"&",
"7",
")",
"!=",
"0",
")",
"{",
"emLen",
"++",
";",
"}",
"byte",
"[",
"]",
"mHash",
"=",
"hash",
"(",
"spec",
",",
"msg",
")",
";",
"// System.out.println(\"mHash: \"+Utils.bytes2String(mHash));",
"MessageDigest",
"dig",
"=",
"getMessageDigest",
"(",
"spec",
")",
";",
"int",
"hLen",
"=",
"dig",
".",
"getDigestLength",
"(",
")",
";",
"// System.out.println(\"hLen: \"+hLen);",
"int",
"sLen",
"=",
"hLen",
";",
"if",
"(",
"EM",
"[",
"EM",
".",
"length",
"-",
"1",
"]",
"!=",
"(",
"byte",
")",
"0xBC",
")",
"{",
"// System.out.println(\"no BC at the end\");",
"return",
"false",
";",
"}",
"byte",
"[",
"]",
"maskedDB",
"=",
"new",
"byte",
"[",
"emLen",
"-",
"hLen",
"-",
"1",
"]",
";",
"byte",
"[",
"]",
"H",
"=",
"new",
"byte",
"[",
"hLen",
"]",
";",
"System",
".",
"arraycopy",
"(",
"EM",
",",
"0",
",",
"maskedDB",
",",
"0",
",",
"emLen",
"-",
"hLen",
"-",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"EM",
",",
"emLen",
"-",
"hLen",
"-",
"1",
",",
"H",
",",
"0",
",",
"hLen",
")",
";",
"// TODO: verify if first X bits of maskedDB are zero",
"byte",
"[",
"]",
"dbMask",
"=",
"mgf1",
"(",
"spec",
",",
"H",
",",
"emLen",
"-",
"hLen",
"-",
"1",
")",
";",
"byte",
"[",
"]",
"DB",
"=",
"xor_os",
"(",
"maskedDB",
",",
"dbMask",
")",
";",
"// set leftmost X bits of DB to zero",
"int",
"tooMuchBits",
"=",
"(",
"emLen",
"<<",
"3",
")",
"-",
"emBits",
";",
"byte",
"mask",
"=",
"(",
"byte",
")",
"(",
"0xFF",
">>>",
"tooMuchBits",
")",
";",
"DB",
"[",
"0",
"]",
"&=",
"mask",
";",
"// TODO: another consistency check",
"byte",
"[",
"]",
"salt",
"=",
"new",
"byte",
"[",
"sLen",
"]",
";",
"System",
".",
"arraycopy",
"(",
"DB",
",",
"DB",
".",
"length",
"-",
"sLen",
",",
"salt",
",",
"0",
",",
"sLen",
")",
";",
"byte",
"[",
"]",
"zeroes",
"=",
"new",
"byte",
"[",
"8",
"]",
";",
"byte",
"[",
"]",
"m2",
"=",
"concat",
"(",
"concat",
"(",
"zeroes",
",",
"mHash",
")",
",",
"salt",
")",
";",
"byte",
"[",
"]",
"H2",
"=",
"hash",
"(",
"spec",
",",
"m2",
")",
";",
"return",
"Arrays",
".",
"equals",
"(",
"H",
",",
"H2",
")",
";",
"}"
] |
--- stuff from the PKCS#1-PSS specification ---------------------------
|
[
"---",
"stuff",
"from",
"the",
"PKCS#1",
"-",
"PSS",
"specification",
"---------------------------"
] |
train
|
https://github.com/adorsys/hbci4java-adorsys/blob/5e24f7e429d6b555e1d993196b4cf1adda6433cf/src/main/java/org/kapott/cryptalgs/PKCS1_PSS.java#L215-L259
|
qiujiayu/AutoLoadCache
|
src/main/java/com/jarvis/cache/CacheUtil.java
|
CacheUtil.getDefaultCacheKey
|
public static String getDefaultCacheKey(String className, String method, Object[] arguments) {
"""
生成缓存Key
@param className 类名称
@param method 方法名称
@param arguments 参数
@return CacheKey 缓存Key
"""
StringBuilder sb = new StringBuilder();
sb.append(getDefaultCacheKeyPrefix(className, method, arguments));
if (null != arguments && arguments.length > 0) {
sb.append(getUniqueHashStr(arguments));
}
return sb.toString();
}
|
java
|
public static String getDefaultCacheKey(String className, String method, Object[] arguments) {
StringBuilder sb = new StringBuilder();
sb.append(getDefaultCacheKeyPrefix(className, method, arguments));
if (null != arguments && arguments.length > 0) {
sb.append(getUniqueHashStr(arguments));
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"getDefaultCacheKey",
"(",
"String",
"className",
",",
"String",
"method",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"getDefaultCacheKeyPrefix",
"(",
"className",
",",
"method",
",",
"arguments",
")",
")",
";",
"if",
"(",
"null",
"!=",
"arguments",
"&&",
"arguments",
".",
"length",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"getUniqueHashStr",
"(",
"arguments",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
生成缓存Key
@param className 类名称
@param method 方法名称
@param arguments 参数
@return CacheKey 缓存Key
|
[
"生成缓存Key"
] |
train
|
https://github.com/qiujiayu/AutoLoadCache/blob/8121c146f1a420fa6d6832e849acadb547c13622/src/main/java/com/jarvis/cache/CacheUtil.java#L100-L107
|
moparisthebest/beehive
|
beehive-netui-core/src/main/java/org/apache/beehive/netui/util/Bundle.java
|
Bundle.getString
|
public static String getString(String aKey) {
"""
Returns the string specified by aKey from the errors.properties bundle.
"""
try
{
return getBundle().getString(aKey);
}
catch(Exception e)
{
return getString("System_StringNotFound",new Object[]{aKey});
}
}
|
java
|
public static String getString(String aKey)
{
try
{
return getBundle().getString(aKey);
}
catch(Exception e)
{
return getString("System_StringNotFound",new Object[]{aKey});
}
}
|
[
"public",
"static",
"String",
"getString",
"(",
"String",
"aKey",
")",
"{",
"try",
"{",
"return",
"getBundle",
"(",
")",
".",
"getString",
"(",
"aKey",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"getString",
"(",
"\"System_StringNotFound\"",
",",
"new",
"Object",
"[",
"]",
"{",
"aKey",
"}",
")",
";",
"}",
"}"
] |
Returns the string specified by aKey from the errors.properties bundle.
|
[
"Returns",
"the",
"string",
"specified",
"by",
"aKey",
"from",
"the",
"errors",
".",
"properties",
"bundle",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-core/src/main/java/org/apache/beehive/netui/util/Bundle.java#L48-L58
|
alkacon/opencms-core
|
src/org/opencms/db/CmsSecurityManager.java
|
CmsSecurityManager.restoreDeletedResource
|
public void restoreDeletedResource(CmsRequestContext context, CmsUUID structureId) throws CmsException {
"""
Restores a deleted resource identified by its structure id from the historical archive.<p>
@param context the current request context
@param structureId the structure id of the resource to restore
@throws CmsException if something goes wrong
@see CmsObject#restoreDeletedResource(CmsUUID)
"""
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
try {
checkOfflineProject(dbc);
// write permissions on parent folder are checked later
m_driverManager.restoreDeletedResource(dbc, structureId);
} catch (Exception e) {
dbc.report(null, Messages.get().container(Messages.ERR_RESTORE_DELETED_RESOURCE_1, structureId), e);
} finally {
dbc.clear();
}
}
|
java
|
public void restoreDeletedResource(CmsRequestContext context, CmsUUID structureId) throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
try {
checkOfflineProject(dbc);
// write permissions on parent folder are checked later
m_driverManager.restoreDeletedResource(dbc, structureId);
} catch (Exception e) {
dbc.report(null, Messages.get().container(Messages.ERR_RESTORE_DELETED_RESOURCE_1, structureId), e);
} finally {
dbc.clear();
}
}
|
[
"public",
"void",
"restoreDeletedResource",
"(",
"CmsRequestContext",
"context",
",",
"CmsUUID",
"structureId",
")",
"throws",
"CmsException",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"try",
"{",
"checkOfflineProject",
"(",
"dbc",
")",
";",
"// write permissions on parent folder are checked later",
"m_driverManager",
".",
"restoreDeletedResource",
"(",
"dbc",
",",
"structureId",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"dbc",
".",
"report",
"(",
"null",
",",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_RESTORE_DELETED_RESOURCE_1",
",",
"structureId",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"dbc",
".",
"clear",
"(",
")",
";",
"}",
"}"
] |
Restores a deleted resource identified by its structure id from the historical archive.<p>
@param context the current request context
@param structureId the structure id of the resource to restore
@throws CmsException if something goes wrong
@see CmsObject#restoreDeletedResource(CmsUUID)
|
[
"Restores",
"a",
"deleted",
"resource",
"identified",
"by",
"its",
"structure",
"id",
"from",
"the",
"historical",
"archive",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L5813-L5825
|
mgm-tp/jfunk
|
jfunk-common/src/main/java/com/mgmtp/jfunk/common/cli/CliUtils.java
|
CliUtils.executeCommandLine
|
public static CliOutput executeCommandLine(final Commandline cli, final String loggerName) {
"""
Executes the specified command line and blocks until the process has finished. The output of
the process is captured, returned, as well as logged with info (stdout) and error (stderr)
level, respectively.
@param cli
the command line
@param loggerName
the name of the logger to use (passed to {@link LoggerFactory#getLogger(String)});
if {@code null} this class' name is used
@return the process' output
"""
return executeCommandLine(cli, loggerName, null);
}
|
java
|
public static CliOutput executeCommandLine(final Commandline cli, final String loggerName) {
return executeCommandLine(cli, loggerName, null);
}
|
[
"public",
"static",
"CliOutput",
"executeCommandLine",
"(",
"final",
"Commandline",
"cli",
",",
"final",
"String",
"loggerName",
")",
"{",
"return",
"executeCommandLine",
"(",
"cli",
",",
"loggerName",
",",
"null",
")",
";",
"}"
] |
Executes the specified command line and blocks until the process has finished. The output of
the process is captured, returned, as well as logged with info (stdout) and error (stderr)
level, respectively.
@param cli
the command line
@param loggerName
the name of the logger to use (passed to {@link LoggerFactory#getLogger(String)});
if {@code null} this class' name is used
@return the process' output
|
[
"Executes",
"the",
"specified",
"command",
"line",
"and",
"blocks",
"until",
"the",
"process",
"has",
"finished",
".",
"The",
"output",
"of",
"the",
"process",
"is",
"captured",
"returned",
"as",
"well",
"as",
"logged",
"with",
"info",
"(",
"stdout",
")",
"and",
"error",
"(",
"stderr",
")",
"level",
"respectively",
"."
] |
train
|
https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-common/src/main/java/com/mgmtp/jfunk/common/cli/CliUtils.java#L62-L64
|
petergeneric/stdlib
|
guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/logging/HibernateObservingInterceptor.java
|
HibernateObservingInterceptor.startSQLLogger
|
public HibernateSQLLogger startSQLLogger(final String tracingOperationId) {
"""
Start a new logger which records SQL Prepared Statements created by Hibernate in this Thread. Must be closed (or treated as
autoclose)
@param tracingOperationId the tracing operation this sql logger should be associated with
@return
"""
final HibernateSQLLogger logger = new HibernateSQLLogger(this, tracingOperationId);
logger.start();
return logger;
}
|
java
|
public HibernateSQLLogger startSQLLogger(final String tracingOperationId)
{
final HibernateSQLLogger logger = new HibernateSQLLogger(this, tracingOperationId);
logger.start();
return logger;
}
|
[
"public",
"HibernateSQLLogger",
"startSQLLogger",
"(",
"final",
"String",
"tracingOperationId",
")",
"{",
"final",
"HibernateSQLLogger",
"logger",
"=",
"new",
"HibernateSQLLogger",
"(",
"this",
",",
"tracingOperationId",
")",
";",
"logger",
".",
"start",
"(",
")",
";",
"return",
"logger",
";",
"}"
] |
Start a new logger which records SQL Prepared Statements created by Hibernate in this Thread. Must be closed (or treated as
autoclose)
@param tracingOperationId the tracing operation this sql logger should be associated with
@return
|
[
"Start",
"a",
"new",
"logger",
"which",
"records",
"SQL",
"Prepared",
"Statements",
"created",
"by",
"Hibernate",
"in",
"this",
"Thread",
".",
"Must",
"be",
"closed",
"(",
"or",
"treated",
"as",
"autoclose",
")"
] |
train
|
https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/hibernate/src/main/java/com/peterphi/std/guice/hibernate/module/logging/HibernateObservingInterceptor.java#L73-L80
|
lessthanoptimal/BoofCV
|
integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java
|
ConvertBitmap.grayToBitmap
|
public static Bitmap grayToBitmap( GrayU8 input , Bitmap.Config config ) {
"""
Converts GrayU8 into a new Bitmap.
@param input Input gray scale image.
@param config Type of Bitmap image to create.
"""
Bitmap output = Bitmap.createBitmap(input.width, input.height, config);
grayToBitmap(input,output,null);
return output;
}
|
java
|
public static Bitmap grayToBitmap( GrayU8 input , Bitmap.Config config ) {
Bitmap output = Bitmap.createBitmap(input.width, input.height, config);
grayToBitmap(input,output,null);
return output;
}
|
[
"public",
"static",
"Bitmap",
"grayToBitmap",
"(",
"GrayU8",
"input",
",",
"Bitmap",
".",
"Config",
"config",
")",
"{",
"Bitmap",
"output",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"input",
".",
"width",
",",
"input",
".",
"height",
",",
"config",
")",
";",
"grayToBitmap",
"(",
"input",
",",
"output",
",",
"null",
")",
";",
"return",
"output",
";",
"}"
] |
Converts GrayU8 into a new Bitmap.
@param input Input gray scale image.
@param config Type of Bitmap image to create.
|
[
"Converts",
"GrayU8",
"into",
"a",
"new",
"Bitmap",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L386-L392
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java
|
BootstrapConfig.put
|
public String put(final String key, String value) {
"""
Set new property into set of initial properties. No effect (and returns
null) if key is null.
@param key
Property key string
@param value
Property value object
@return current/replaced value
"""
if (key == null || initProps == null)
return null;
return initProps.put(key, value);
}
|
java
|
public String put(final String key, String value) {
if (key == null || initProps == null)
return null;
return initProps.put(key, value);
}
|
[
"public",
"String",
"put",
"(",
"final",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"initProps",
"==",
"null",
")",
"return",
"null",
";",
"return",
"initProps",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] |
Set new property into set of initial properties. No effect (and returns
null) if key is null.
@param key
Property key string
@param value
Property value object
@return current/replaced value
|
[
"Set",
"new",
"property",
"into",
"set",
"of",
"initial",
"properties",
".",
"No",
"effect",
"(",
"and",
"returns",
"null",
")",
"if",
"key",
"is",
"null",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/BootstrapConfig.java#L475-L480
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java
|
PortablePositionNavigator.createPositionForReadAccess
|
private static PortablePosition createPositionForReadAccess(
PortableNavigatorContext ctx, PortablePathCursor path) throws IOException {
"""
Special case of the position creation, where there's no quantifier, so the index does not count.
"""
int notArrayCellAccessIndex = -1;
return createPositionForReadAccess(ctx, path, notArrayCellAccessIndex);
}
|
java
|
private static PortablePosition createPositionForReadAccess(
PortableNavigatorContext ctx, PortablePathCursor path) throws IOException {
int notArrayCellAccessIndex = -1;
return createPositionForReadAccess(ctx, path, notArrayCellAccessIndex);
}
|
[
"private",
"static",
"PortablePosition",
"createPositionForReadAccess",
"(",
"PortableNavigatorContext",
"ctx",
",",
"PortablePathCursor",
"path",
")",
"throws",
"IOException",
"{",
"int",
"notArrayCellAccessIndex",
"=",
"-",
"1",
";",
"return",
"createPositionForReadAccess",
"(",
"ctx",
",",
"path",
",",
"notArrayCellAccessIndex",
")",
";",
"}"
] |
Special case of the position creation, where there's no quantifier, so the index does not count.
|
[
"Special",
"case",
"of",
"the",
"position",
"creation",
"where",
"there",
"s",
"no",
"quantifier",
"so",
"the",
"index",
"does",
"not",
"count",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/serialization/impl/PortablePositionNavigator.java#L488-L492
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateFormat.java
|
DateFormat.getInstanceForSkeleton
|
public final static DateFormat getInstanceForSkeleton(Calendar cal, String skeleton, Locale locale) {
"""
<strong>[icu]</strong> Creates a {@link DateFormat} object that can be used to format dates and
times in the calendar system specified by <code>cal</code>.
@param cal The calendar system for which a date/time format is desired.
@param skeleton The skeleton that selects the fields to be formatted. (Uses the
{@link DateTimePatternGenerator}.) This can be
{@link DateFormat#ABBR_MONTH}, {@link DateFormat#MONTH_WEEKDAY_DAY},
etc.
@param locale The locale for which the date/time format is desired.
"""
return getPatternInstance(cal, skeleton, ULocale.forLocale(locale));
}
|
java
|
public final static DateFormat getInstanceForSkeleton(Calendar cal, String skeleton, Locale locale) {
return getPatternInstance(cal, skeleton, ULocale.forLocale(locale));
}
|
[
"public",
"final",
"static",
"DateFormat",
"getInstanceForSkeleton",
"(",
"Calendar",
"cal",
",",
"String",
"skeleton",
",",
"Locale",
"locale",
")",
"{",
"return",
"getPatternInstance",
"(",
"cal",
",",
"skeleton",
",",
"ULocale",
".",
"forLocale",
"(",
"locale",
")",
")",
";",
"}"
] |
<strong>[icu]</strong> Creates a {@link DateFormat} object that can be used to format dates and
times in the calendar system specified by <code>cal</code>.
@param cal The calendar system for which a date/time format is desired.
@param skeleton The skeleton that selects the fields to be formatted. (Uses the
{@link DateTimePatternGenerator}.) This can be
{@link DateFormat#ABBR_MONTH}, {@link DateFormat#MONTH_WEEKDAY_DAY},
etc.
@param locale The locale for which the date/time format is desired.
|
[
"<strong",
">",
"[",
"icu",
"]",
"<",
"/",
"strong",
">",
"Creates",
"a",
"{",
"@link",
"DateFormat",
"}",
"object",
"that",
"can",
"be",
"used",
"to",
"format",
"dates",
"and",
"times",
"in",
"the",
"calendar",
"system",
"specified",
"by",
"<code",
">",
"cal<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/DateFormat.java#L1996-L1998
|
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticPropertyList.java
|
SyntheticPropertyList.addProperty
|
public void addProperty(String propertyName, Direction direction) {
"""
Adds a property to this index, with the specified direction.
@param propertyName name of property to add to index
@param direction optional direction of property
"""
if (propertyName == null) {
throw new IllegalArgumentException();
}
if (direction == null) {
direction = Direction.UNSPECIFIED;
}
if (direction != Direction.UNSPECIFIED) {
if (propertyName.length() > 0) {
if (propertyName.charAt(0) == '-' || propertyName.charAt(0) == '+') {
// Overrule the direction.
propertyName = propertyName.substring(1);
}
}
propertyName = direction.toCharacter() + propertyName;
}
mPropertyList.add(propertyName);
}
|
java
|
public void addProperty(String propertyName, Direction direction) {
if (propertyName == null) {
throw new IllegalArgumentException();
}
if (direction == null) {
direction = Direction.UNSPECIFIED;
}
if (direction != Direction.UNSPECIFIED) {
if (propertyName.length() > 0) {
if (propertyName.charAt(0) == '-' || propertyName.charAt(0) == '+') {
// Overrule the direction.
propertyName = propertyName.substring(1);
}
}
propertyName = direction.toCharacter() + propertyName;
}
mPropertyList.add(propertyName);
}
|
[
"public",
"void",
"addProperty",
"(",
"String",
"propertyName",
",",
"Direction",
"direction",
")",
"{",
"if",
"(",
"propertyName",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"direction",
"==",
"null",
")",
"{",
"direction",
"=",
"Direction",
".",
"UNSPECIFIED",
";",
"}",
"if",
"(",
"direction",
"!=",
"Direction",
".",
"UNSPECIFIED",
")",
"{",
"if",
"(",
"propertyName",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"propertyName",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
"||",
"propertyName",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"// Overrule the direction.\r",
"propertyName",
"=",
"propertyName",
".",
"substring",
"(",
"1",
")",
";",
"}",
"}",
"propertyName",
"=",
"direction",
".",
"toCharacter",
"(",
")",
"+",
"propertyName",
";",
"}",
"mPropertyList",
".",
"add",
"(",
"propertyName",
")",
";",
"}"
] |
Adds a property to this index, with the specified direction.
@param propertyName name of property to add to index
@param direction optional direction of property
|
[
"Adds",
"a",
"property",
"to",
"this",
"index",
"with",
"the",
"specified",
"direction",
"."
] |
train
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticPropertyList.java#L56-L75
|
redkale/redkale
|
src/org/redkale/source/ColumnValue.java
|
ColumnValue.mul
|
public static ColumnValue mul(String column, Serializable value) {
"""
返回 {column} = {column} * {value} 操作
@param column 字段名
@param value 字段值
@return ColumnValue
"""
return new ColumnValue(column, MUL, value);
}
|
java
|
public static ColumnValue mul(String column, Serializable value) {
return new ColumnValue(column, MUL, value);
}
|
[
"public",
"static",
"ColumnValue",
"mul",
"(",
"String",
"column",
",",
"Serializable",
"value",
")",
"{",
"return",
"new",
"ColumnValue",
"(",
"column",
",",
"MUL",
",",
"value",
")",
";",
"}"
] |
返回 {column} = {column} * {value} 操作
@param column 字段名
@param value 字段值
@return ColumnValue
|
[
"返回",
"{",
"column",
"}",
"=",
"{",
"column",
"}",
"*",
"{",
"value",
"}",
"操作"
] |
train
|
https://github.com/redkale/redkale/blob/ea5169b5c5ea7412fd762331c0c497165832e901/src/org/redkale/source/ColumnValue.java#L85-L87
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/utils/Messages.java
|
Messages.loadResourceBundle
|
private ListResourceBundle loadResourceBundle(String resourceBundle)
throws MissingResourceException {
"""
Return a named ResourceBundle for a particular locale. This method mimics the behavior
of ResourceBundle.getBundle().
@param className the name of the class that implements ListResourceBundle,
without language suffix.
@return the ResourceBundle
@throws MissingResourceException
@xsl.usage internal
"""
m_resourceBundleName = resourceBundle;
Locale locale = getLocale();
ListResourceBundle lrb;
try
{
ResourceBundle rb =
ResourceBundle.getBundle(m_resourceBundleName, locale);
lrb = (ListResourceBundle) rb;
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
lrb =
(ListResourceBundle) ResourceBundle.getBundle(
m_resourceBundleName,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles." + m_resourceBundleName,
m_resourceBundleName,
"");
}
}
m_resourceBundle = lrb;
return lrb;
}
|
java
|
private ListResourceBundle loadResourceBundle(String resourceBundle)
throws MissingResourceException
{
m_resourceBundleName = resourceBundle;
Locale locale = getLocale();
ListResourceBundle lrb;
try
{
ResourceBundle rb =
ResourceBundle.getBundle(m_resourceBundleName, locale);
lrb = (ListResourceBundle) rb;
}
catch (MissingResourceException e)
{
try // try to fall back to en_US if we can't load
{
// Since we can't find the localized property file,
// fall back to en_US.
lrb =
(ListResourceBundle) ResourceBundle.getBundle(
m_resourceBundleName,
new Locale("en", "US"));
}
catch (MissingResourceException e2)
{
// Now we are really in trouble.
// very bad, definitely very bad...not going to get very far
throw new MissingResourceException(
"Could not load any resource bundles." + m_resourceBundleName,
m_resourceBundleName,
"");
}
}
m_resourceBundle = lrb;
return lrb;
}
|
[
"private",
"ListResourceBundle",
"loadResourceBundle",
"(",
"String",
"resourceBundle",
")",
"throws",
"MissingResourceException",
"{",
"m_resourceBundleName",
"=",
"resourceBundle",
";",
"Locale",
"locale",
"=",
"getLocale",
"(",
")",
";",
"ListResourceBundle",
"lrb",
";",
"try",
"{",
"ResourceBundle",
"rb",
"=",
"ResourceBundle",
".",
"getBundle",
"(",
"m_resourceBundleName",
",",
"locale",
")",
";",
"lrb",
"=",
"(",
"ListResourceBundle",
")",
"rb",
";",
"}",
"catch",
"(",
"MissingResourceException",
"e",
")",
"{",
"try",
"// try to fall back to en_US if we can't load",
"{",
"// Since we can't find the localized property file,",
"// fall back to en_US.",
"lrb",
"=",
"(",
"ListResourceBundle",
")",
"ResourceBundle",
".",
"getBundle",
"(",
"m_resourceBundleName",
",",
"new",
"Locale",
"(",
"\"en\"",
",",
"\"US\"",
")",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"e2",
")",
"{",
"// Now we are really in trouble.",
"// very bad, definitely very bad...not going to get very far",
"throw",
"new",
"MissingResourceException",
"(",
"\"Could not load any resource bundles.\"",
"+",
"m_resourceBundleName",
",",
"m_resourceBundleName",
",",
"\"\"",
")",
";",
"}",
"}",
"m_resourceBundle",
"=",
"lrb",
";",
"return",
"lrb",
";",
"}"
] |
Return a named ResourceBundle for a particular locale. This method mimics the behavior
of ResourceBundle.getBundle().
@param className the name of the class that implements ListResourceBundle,
without language suffix.
@return the ResourceBundle
@throws MissingResourceException
@xsl.usage internal
|
[
"Return",
"a",
"named",
"ResourceBundle",
"for",
"a",
"particular",
"locale",
".",
"This",
"method",
"mimics",
"the",
"behavior",
"of",
"ResourceBundle",
".",
"getBundle",
"()",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/utils/Messages.java#L304-L344
|
QSFT/Doradus
|
doradus-server/src/main/java/com/dell/doradus/service/olap/OLAPService.java
|
OLAPService.getStats
|
public SegmentStats getStats(ApplicationDefinition appDef, String shard) {
"""
Get statistics for the given shard, owned by the given application. Statistics are
returned as a {@link SegmentStats} object. If there is no information for the given
shard, an IllegalArgumentException is thrown.
@param appDef OLAP application definition.
@param shard Shard name.
@return Shard statistics as a {@link SegmentStats} object.
"""
checkServiceState();
return m_olap.getStats(appDef, shard);
}
|
java
|
public SegmentStats getStats(ApplicationDefinition appDef, String shard) {
checkServiceState();
return m_olap.getStats(appDef, shard);
}
|
[
"public",
"SegmentStats",
"getStats",
"(",
"ApplicationDefinition",
"appDef",
",",
"String",
"shard",
")",
"{",
"checkServiceState",
"(",
")",
";",
"return",
"m_olap",
".",
"getStats",
"(",
"appDef",
",",
"shard",
")",
";",
"}"
] |
Get statistics for the given shard, owned by the given application. Statistics are
returned as a {@link SegmentStats} object. If there is no information for the given
shard, an IllegalArgumentException is thrown.
@param appDef OLAP application definition.
@param shard Shard name.
@return Shard statistics as a {@link SegmentStats} object.
|
[
"Get",
"statistics",
"for",
"the",
"given",
"shard",
"owned",
"by",
"the",
"given",
"application",
".",
"Statistics",
"are",
"returned",
"as",
"a",
"{",
"@link",
"SegmentStats",
"}",
"object",
".",
"If",
"there",
"is",
"no",
"information",
"for",
"the",
"given",
"shard",
"an",
"IllegalArgumentException",
"is",
"thrown",
"."
] |
train
|
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/olap/OLAPService.java#L292-L295
|
gallandarakhneorg/afc
|
core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d1/Transform1D.java
|
Transform1D.toTransform2D
|
@Pure
public final Transform2D toTransform2D(Segment1D<?, ?> segment) {
"""
Replies a 2D transformation that is corresponding to this transformation.
@param segment is the segment.
@return the 2D transformation or <code>null</code> if the segment could not be mapped
to 2D.
"""
assert segment != null : AssertMessages.notNullParameter(0);
final Point2D<?, ?> a = segment.getFirstPoint();
if (a == null) {
return null;
}
final Point2D<?, ?> b = segment.getLastPoint();
if (b == null) {
return null;
}
return toTransform2D(a.getX(), a.getY(), b.getX(), b.getY());
}
|
java
|
@Pure
public final Transform2D toTransform2D(Segment1D<?, ?> segment) {
assert segment != null : AssertMessages.notNullParameter(0);
final Point2D<?, ?> a = segment.getFirstPoint();
if (a == null) {
return null;
}
final Point2D<?, ?> b = segment.getLastPoint();
if (b == null) {
return null;
}
return toTransform2D(a.getX(), a.getY(), b.getX(), b.getY());
}
|
[
"@",
"Pure",
"public",
"final",
"Transform2D",
"toTransform2D",
"(",
"Segment1D",
"<",
"?",
",",
"?",
">",
"segment",
")",
"{",
"assert",
"segment",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"0",
")",
";",
"final",
"Point2D",
"<",
"?",
",",
"?",
">",
"a",
"=",
"segment",
".",
"getFirstPoint",
"(",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"Point2D",
"<",
"?",
",",
"?",
">",
"b",
"=",
"segment",
".",
"getLastPoint",
"(",
")",
";",
"if",
"(",
"b",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"toTransform2D",
"(",
"a",
".",
"getX",
"(",
")",
",",
"a",
".",
"getY",
"(",
")",
",",
"b",
".",
"getX",
"(",
")",
",",
"b",
".",
"getY",
"(",
")",
")",
";",
"}"
] |
Replies a 2D transformation that is corresponding to this transformation.
@param segment is the segment.
@return the 2D transformation or <code>null</code> if the segment could not be mapped
to 2D.
|
[
"Replies",
"a",
"2D",
"transformation",
"that",
"is",
"corresponding",
"to",
"this",
"transformation",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/maths/mathgeom/src/main/java/org/arakhne/afc/math/geometry/d1/Transform1D.java#L614-L626
|
apereo/cas
|
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/trigger/RestEndpointMultifactorAuthenticationTrigger.java
|
RestEndpointMultifactorAuthenticationTrigger.callRestEndpointForMultifactor
|
protected String callRestEndpointForMultifactor(final Principal principal, final Service resolvedService) {
"""
Call rest endpoint for multifactor.
@param principal the principal
@param resolvedService the resolved service
@return return the rest response, typically the mfa id.
"""
val restTemplate = new RestTemplate();
val restEndpoint = casProperties.getAuthn().getMfa().getRestEndpoint();
val entity = new RestEndpointEntity(principal.getId(), resolvedService.getId());
val responseEntity = restTemplate.postForEntity(restEndpoint, entity, String.class);
if (responseEntity.getStatusCode() == HttpStatus.OK) {
return responseEntity.getBody();
}
return null;
}
|
java
|
protected String callRestEndpointForMultifactor(final Principal principal, final Service resolvedService) {
val restTemplate = new RestTemplate();
val restEndpoint = casProperties.getAuthn().getMfa().getRestEndpoint();
val entity = new RestEndpointEntity(principal.getId(), resolvedService.getId());
val responseEntity = restTemplate.postForEntity(restEndpoint, entity, String.class);
if (responseEntity.getStatusCode() == HttpStatus.OK) {
return responseEntity.getBody();
}
return null;
}
|
[
"protected",
"String",
"callRestEndpointForMultifactor",
"(",
"final",
"Principal",
"principal",
",",
"final",
"Service",
"resolvedService",
")",
"{",
"val",
"restTemplate",
"=",
"new",
"RestTemplate",
"(",
")",
";",
"val",
"restEndpoint",
"=",
"casProperties",
".",
"getAuthn",
"(",
")",
".",
"getMfa",
"(",
")",
".",
"getRestEndpoint",
"(",
")",
";",
"val",
"entity",
"=",
"new",
"RestEndpointEntity",
"(",
"principal",
".",
"getId",
"(",
")",
",",
"resolvedService",
".",
"getId",
"(",
")",
")",
";",
"val",
"responseEntity",
"=",
"restTemplate",
".",
"postForEntity",
"(",
"restEndpoint",
",",
"entity",
",",
"String",
".",
"class",
")",
";",
"if",
"(",
"responseEntity",
".",
"getStatusCode",
"(",
")",
"==",
"HttpStatus",
".",
"OK",
")",
"{",
"return",
"responseEntity",
".",
"getBody",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Call rest endpoint for multifactor.
@param principal the principal
@param resolvedService the resolved service
@return return the rest response, typically the mfa id.
|
[
"Call",
"rest",
"endpoint",
"for",
"multifactor",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/trigger/RestEndpointMultifactorAuthenticationTrigger.java#L84-L93
|
ist-dresden/composum
|
sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java
|
LinkUtil.getExtension
|
public static String getExtension(ResourceHandle resource, String extension) {
"""
Returns the extension for a URL to a resource based on a predefined value (can be null or '').
The result is always not 'null' and can be added without check; it starts with a '.' if not blank.
@param resource the referenced resource
@param extension the predefined extension (can be 'null' or blank for determination)
@return the string which has to add to the resources path; '' if nothing should add
"""
return getExtension(resource, extension, false);
}
|
java
|
public static String getExtension(ResourceHandle resource, String extension) {
return getExtension(resource, extension, false);
}
|
[
"public",
"static",
"String",
"getExtension",
"(",
"ResourceHandle",
"resource",
",",
"String",
"extension",
")",
"{",
"return",
"getExtension",
"(",
"resource",
",",
"extension",
",",
"false",
")",
";",
"}"
] |
Returns the extension for a URL to a resource based on a predefined value (can be null or '').
The result is always not 'null' and can be added without check; it starts with a '.' if not blank.
@param resource the referenced resource
@param extension the predefined extension (can be 'null' or blank for determination)
@return the string which has to add to the resources path; '' if nothing should add
|
[
"Returns",
"the",
"extension",
"for",
"a",
"URL",
"to",
"a",
"resource",
"based",
"on",
"a",
"predefined",
"value",
"(",
"can",
"be",
"null",
"or",
")",
".",
"The",
"result",
"is",
"always",
"not",
"null",
"and",
"can",
"be",
"added",
"without",
"check",
";",
"it",
"starts",
"with",
"a",
".",
"if",
"not",
"blank",
"."
] |
train
|
https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java#L335-L337
|
aws/aws-sdk-java
|
aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/TagResourceRequest.java
|
TagResourceRequest.withTags
|
public TagResourceRequest withTags(java.util.Map<String, String> tags) {
"""
<p>
A map that contains tag keys and tag values that are attached to the resource.
</p>
@param tags
A map that contains tag keys and tag values that are attached to the resource.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
}
|
java
|
public TagResourceRequest withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
}
|
[
"public",
"TagResourceRequest",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A map that contains tag keys and tag values that are attached to the resource.
</p>
@param tags
A map that contains tag keys and tag values that are attached to the resource.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"map",
"that",
"contains",
"tag",
"keys",
"and",
"tag",
"values",
"that",
"are",
"attached",
"to",
"the",
"resource",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-robomaker/src/main/java/com/amazonaws/services/robomaker/model/TagResourceRequest.java#L116-L119
|
banq/jdonframework
|
src/main/java/com/jdon/util/UtilValidate.java
|
UtilValidate.isIntegerInRange
|
public static boolean isIntegerInRange(String s, int a, int b) {
"""
isIntegerInRange returns true if string s is an integer
within the range of integer arguments a and b, inclusive.
"""
if (isEmpty(s)) return defaultEmptyOK;
// Catch non-integer strings to avoid creating a NaN below,
// which isn't available on JavaScript 1.0 for Windows.
if (!isSignedInteger(s)) return false;
// Now, explicitly change the type to integer via parseInt
// so that the comparison code below will work both on
// JavaScript 1.2(which typechecks in equality comparisons)
// and JavaScript 1.1 and before(which doesn't).
int num = Integer.parseInt(s);
return ((num >= a) && (num <= b));
}
|
java
|
public static boolean isIntegerInRange(String s, int a, int b) {
if (isEmpty(s)) return defaultEmptyOK;
// Catch non-integer strings to avoid creating a NaN below,
// which isn't available on JavaScript 1.0 for Windows.
if (!isSignedInteger(s)) return false;
// Now, explicitly change the type to integer via parseInt
// so that the comparison code below will work both on
// JavaScript 1.2(which typechecks in equality comparisons)
// and JavaScript 1.1 and before(which doesn't).
int num = Integer.parseInt(s);
return ((num >= a) && (num <= b));
}
|
[
"public",
"static",
"boolean",
"isIntegerInRange",
"(",
"String",
"s",
",",
"int",
"a",
",",
"int",
"b",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"s",
")",
")",
"return",
"defaultEmptyOK",
";",
"// Catch non-integer strings to avoid creating a NaN below,\r",
"// which isn't available on JavaScript 1.0 for Windows.\r",
"if",
"(",
"!",
"isSignedInteger",
"(",
"s",
")",
")",
"return",
"false",
";",
"// Now, explicitly change the type to integer via parseInt\r",
"// so that the comparison code below will work both on\r",
"// JavaScript 1.2(which typechecks in equality comparisons)\r",
"// and JavaScript 1.1 and before(which doesn't).\r",
"int",
"num",
"=",
"Integer",
".",
"parseInt",
"(",
"s",
")",
";",
"return",
"(",
"(",
"num",
">=",
"a",
")",
"&&",
"(",
"num",
"<=",
"b",
")",
")",
";",
"}"
] |
isIntegerInRange returns true if string s is an integer
within the range of integer arguments a and b, inclusive.
|
[
"isIntegerInRange",
"returns",
"true",
"if",
"string",
"s",
"is",
"an",
"integer",
"within",
"the",
"range",
"of",
"integer",
"arguments",
"a",
"and",
"b",
"inclusive",
"."
] |
train
|
https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/UtilValidate.java#L694-L706
|
ops4j/org.ops4j.base
|
ops4j-base-util/src/main/java/org/ops4j/util/environment/Environment.java
|
Environment.readEnvironment
|
private static int readEnvironment( String cmdExec, Properties properties ) {
"""
Reads the environment variables and stores them in a Properties object.
@param cmdExec The command to execute to get hold of the environment variables.
@param properties The Properties object to be populated with the environment variables.
@return The exit value of the OS level process upon its termination.
"""
// fire up the shell and get echo'd results on stdout
BufferedReader reader = null;
Process process = null;
int exitValue = 99;
try
{
String[] args = new String[]{ cmdExec };
process = startProcess( args );
reader = createReader( process );
processLinesOfEnvironmentVariables( reader, properties );
process.waitFor();
reader.close();
}
catch( InterruptedException t )
{
throw new EnvironmentException( "NA", t );
}
catch( IOException t )
{
throw new EnvironmentException( "NA", t );
}
finally
{
if( process != null )
{
process.destroy();
exitValue = process.exitValue();
}
close( reader );
}
return exitValue;
}
|
java
|
private static int readEnvironment( String cmdExec, Properties properties )
{
// fire up the shell and get echo'd results on stdout
BufferedReader reader = null;
Process process = null;
int exitValue = 99;
try
{
String[] args = new String[]{ cmdExec };
process = startProcess( args );
reader = createReader( process );
processLinesOfEnvironmentVariables( reader, properties );
process.waitFor();
reader.close();
}
catch( InterruptedException t )
{
throw new EnvironmentException( "NA", t );
}
catch( IOException t )
{
throw new EnvironmentException( "NA", t );
}
finally
{
if( process != null )
{
process.destroy();
exitValue = process.exitValue();
}
close( reader );
}
return exitValue;
}
|
[
"private",
"static",
"int",
"readEnvironment",
"(",
"String",
"cmdExec",
",",
"Properties",
"properties",
")",
"{",
"// fire up the shell and get echo'd results on stdout",
"BufferedReader",
"reader",
"=",
"null",
";",
"Process",
"process",
"=",
"null",
";",
"int",
"exitValue",
"=",
"99",
";",
"try",
"{",
"String",
"[",
"]",
"args",
"=",
"new",
"String",
"[",
"]",
"{",
"cmdExec",
"}",
";",
"process",
"=",
"startProcess",
"(",
"args",
")",
";",
"reader",
"=",
"createReader",
"(",
"process",
")",
";",
"processLinesOfEnvironmentVariables",
"(",
"reader",
",",
"properties",
")",
";",
"process",
".",
"waitFor",
"(",
")",
";",
"reader",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"t",
")",
"{",
"throw",
"new",
"EnvironmentException",
"(",
"\"NA\"",
",",
"t",
")",
";",
"}",
"catch",
"(",
"IOException",
"t",
")",
"{",
"throw",
"new",
"EnvironmentException",
"(",
"\"NA\"",
",",
"t",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"process",
"!=",
"null",
")",
"{",
"process",
".",
"destroy",
"(",
")",
";",
"exitValue",
"=",
"process",
".",
"exitValue",
"(",
")",
";",
"}",
"close",
"(",
"reader",
")",
";",
"}",
"return",
"exitValue",
";",
"}"
] |
Reads the environment variables and stores them in a Properties object.
@param cmdExec The command to execute to get hold of the environment variables.
@param properties The Properties object to be populated with the environment variables.
@return The exit value of the OS level process upon its termination.
|
[
"Reads",
"the",
"environment",
"variables",
"and",
"stores",
"them",
"in",
"a",
"Properties",
"object",
"."
] |
train
|
https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util/src/main/java/org/ops4j/util/environment/Environment.java#L621-L654
|
iipc/openwayback
|
wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java
|
WaybackRequest.createUrlQueryRequest
|
public static WaybackRequest createUrlQueryRequest(String url, String start, String end) {
"""
create WaybackRequet for URL-Query request.
@param url target URL
@param start start timestamp (14-digit)
@param end end timestamp (14-digit)
@return WaybackRequest
"""
WaybackRequest r = new WaybackRequest();
r.setUrlQueryRequest();
r.setRequestUrl(url);
r.setStartTimestamp(start);
r.setEndTimestamp(end);
return r;
}
|
java
|
public static WaybackRequest createUrlQueryRequest(String url, String start, String end) {
WaybackRequest r = new WaybackRequest();
r.setUrlQueryRequest();
r.setRequestUrl(url);
r.setStartTimestamp(start);
r.setEndTimestamp(end);
return r;
}
|
[
"public",
"static",
"WaybackRequest",
"createUrlQueryRequest",
"(",
"String",
"url",
",",
"String",
"start",
",",
"String",
"end",
")",
"{",
"WaybackRequest",
"r",
"=",
"new",
"WaybackRequest",
"(",
")",
";",
"r",
".",
"setUrlQueryRequest",
"(",
")",
";",
"r",
".",
"setRequestUrl",
"(",
"url",
")",
";",
"r",
".",
"setStartTimestamp",
"(",
"start",
")",
";",
"r",
".",
"setEndTimestamp",
"(",
"end",
")",
";",
"return",
"r",
";",
"}"
] |
create WaybackRequet for URL-Query request.
@param url target URL
@param start start timestamp (14-digit)
@param end end timestamp (14-digit)
@return WaybackRequest
|
[
"create",
"WaybackRequet",
"for",
"URL",
"-",
"Query",
"request",
"."
] |
train
|
https://github.com/iipc/openwayback/blob/da74c3a59a5b5a5c365bd4702dcb45d263535794/wayback-core/src/main/java/org/archive/wayback/core/WaybackRequest.java#L469-L476
|
buschmais/jqa-maven-plugin
|
src/main/java/com/buschmais/jqassistant/scm/maven/ProjectResolver.java
|
ProjectResolver.getRootModule
|
static MavenProject getRootModule(MavenProject module, List<MavenProject> reactor, String rulesDirectory, boolean useExecutionRootAsProjectRoot)
throws MojoExecutionException {
"""
Return the {@link MavenProject} which is the base module for scanning
and analysis.
The base module is by searching with the module tree starting from the current module over its parents until a module is found containing a
directory "jqassistant" or no parent can be determined.
@param module The current module.
@param rulesDirectory The name of the directory used for identifying the root module.
@param useExecutionRootAsProjectRoot `true` if the execution root shall be used as project root.
@return The {@link MavenProject} containing a rules directory.
@throws MojoExecutionException If the directory cannot be resolved.
"""
String rootModuleContextKey = ProjectResolver.class.getName() + "#rootModule";
MavenProject rootModule = (MavenProject) module.getContextValue(rootModuleContextKey);
if (rootModule == null) {
if (useExecutionRootAsProjectRoot) {
rootModule = getRootModule(reactor);
} else {
rootModule = getRootModule(module, rulesDirectory);
}
module.setContextValue(rootModuleContextKey, rootModule);
}
return rootModule;
}
|
java
|
static MavenProject getRootModule(MavenProject module, List<MavenProject> reactor, String rulesDirectory, boolean useExecutionRootAsProjectRoot)
throws MojoExecutionException {
String rootModuleContextKey = ProjectResolver.class.getName() + "#rootModule";
MavenProject rootModule = (MavenProject) module.getContextValue(rootModuleContextKey);
if (rootModule == null) {
if (useExecutionRootAsProjectRoot) {
rootModule = getRootModule(reactor);
} else {
rootModule = getRootModule(module, rulesDirectory);
}
module.setContextValue(rootModuleContextKey, rootModule);
}
return rootModule;
}
|
[
"static",
"MavenProject",
"getRootModule",
"(",
"MavenProject",
"module",
",",
"List",
"<",
"MavenProject",
">",
"reactor",
",",
"String",
"rulesDirectory",
",",
"boolean",
"useExecutionRootAsProjectRoot",
")",
"throws",
"MojoExecutionException",
"{",
"String",
"rootModuleContextKey",
"=",
"ProjectResolver",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\"#rootModule\"",
";",
"MavenProject",
"rootModule",
"=",
"(",
"MavenProject",
")",
"module",
".",
"getContextValue",
"(",
"rootModuleContextKey",
")",
";",
"if",
"(",
"rootModule",
"==",
"null",
")",
"{",
"if",
"(",
"useExecutionRootAsProjectRoot",
")",
"{",
"rootModule",
"=",
"getRootModule",
"(",
"reactor",
")",
";",
"}",
"else",
"{",
"rootModule",
"=",
"getRootModule",
"(",
"module",
",",
"rulesDirectory",
")",
";",
"}",
"module",
".",
"setContextValue",
"(",
"rootModuleContextKey",
",",
"rootModule",
")",
";",
"}",
"return",
"rootModule",
";",
"}"
] |
Return the {@link MavenProject} which is the base module for scanning
and analysis.
The base module is by searching with the module tree starting from the current module over its parents until a module is found containing a
directory "jqassistant" or no parent can be determined.
@param module The current module.
@param rulesDirectory The name of the directory used for identifying the root module.
@param useExecutionRootAsProjectRoot `true` if the execution root shall be used as project root.
@return The {@link MavenProject} containing a rules directory.
@throws MojoExecutionException If the directory cannot be resolved.
|
[
"Return",
"the",
"{",
"@link",
"MavenProject",
"}",
"which",
"is",
"the",
"base",
"module",
"for",
"scanning",
"and",
"analysis",
"."
] |
train
|
https://github.com/buschmais/jqa-maven-plugin/blob/5c21a8058fc1b013333081907fbf00d3525e11c3/src/main/java/com/buschmais/jqassistant/scm/maven/ProjectResolver.java#L47-L60
|
wildfly/wildfly-core
|
cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java
|
ParserUtil.parseOperationRequest
|
public static String parseOperationRequest(String commandLine, final CommandLineParser.CallbackHandler handler) throws CommandFormatException {
"""
Returns the string which was actually parsed with all the substitutions performed
"""
SubstitutedLine sl = parseOperationRequestLine(commandLine, handler, null);
return sl == null ? null : sl.getSubstitued();
}
|
java
|
public static String parseOperationRequest(String commandLine, final CommandLineParser.CallbackHandler handler) throws CommandFormatException {
SubstitutedLine sl = parseOperationRequestLine(commandLine, handler, null);
return sl == null ? null : sl.getSubstitued();
}
|
[
"public",
"static",
"String",
"parseOperationRequest",
"(",
"String",
"commandLine",
",",
"final",
"CommandLineParser",
".",
"CallbackHandler",
"handler",
")",
"throws",
"CommandFormatException",
"{",
"SubstitutedLine",
"sl",
"=",
"parseOperationRequestLine",
"(",
"commandLine",
",",
"handler",
",",
"null",
")",
";",
"return",
"sl",
"==",
"null",
"?",
"null",
":",
"sl",
".",
"getSubstitued",
"(",
")",
";",
"}"
] |
Returns the string which was actually parsed with all the substitutions performed
|
[
"Returns",
"the",
"string",
"which",
"was",
"actually",
"parsed",
"with",
"all",
"the",
"substitutions",
"performed"
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/parsing/ParserUtil.java#L99-L102
|
m-m-m/util
|
pojo/src/main/java/net/sf/mmm/util/pojo/descriptor/base/accessor/AbstractPojoPropertyAccessorBuilder.java
|
AbstractPojoPropertyAccessorBuilder.getPropertyName
|
protected String getPropertyName(String methodName, String prefix, String suffix) {
"""
This method gets the according {@link net.sf.mmm.util.pojo.descriptor.api.PojoPropertyDescriptor#getName()
property-name} for the given {@code methodName}. <br>
This is the un-capitalized substring of the {@code methodName} after between the given {@code prefix} and
{@code suffix}.
@param methodName is the {@link java.lang.reflect.Method#getName() name} of the
{@link net.sf.mmm.util.pojo.descriptor.api.accessor.PojoPropertyAccessor#getAccessibleObject()
accessor-method}.
@param prefix is the prefix (e.g. "get", "set" or "is").
@param suffix is the suffix (e.g. "" or "Size").
@return the requested property-name or {@code null} if NOT available. ({@code methodName} does NOT
{@link String#startsWith(String) start with} {@code prefix} or does NOT {@link String#endsWith(String) end
with} {@code suffix}).
"""
if (methodName.startsWith(prefix) && methodName.endsWith(suffix)) {
return getPropertyName(methodName, prefix.length(), suffix.length());
}
return null;
}
|
java
|
protected String getPropertyName(String methodName, String prefix, String suffix) {
if (methodName.startsWith(prefix) && methodName.endsWith(suffix)) {
return getPropertyName(methodName, prefix.length(), suffix.length());
}
return null;
}
|
[
"protected",
"String",
"getPropertyName",
"(",
"String",
"methodName",
",",
"String",
"prefix",
",",
"String",
"suffix",
")",
"{",
"if",
"(",
"methodName",
".",
"startsWith",
"(",
"prefix",
")",
"&&",
"methodName",
".",
"endsWith",
"(",
"suffix",
")",
")",
"{",
"return",
"getPropertyName",
"(",
"methodName",
",",
"prefix",
".",
"length",
"(",
")",
",",
"suffix",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
This method gets the according {@link net.sf.mmm.util.pojo.descriptor.api.PojoPropertyDescriptor#getName()
property-name} for the given {@code methodName}. <br>
This is the un-capitalized substring of the {@code methodName} after between the given {@code prefix} and
{@code suffix}.
@param methodName is the {@link java.lang.reflect.Method#getName() name} of the
{@link net.sf.mmm.util.pojo.descriptor.api.accessor.PojoPropertyAccessor#getAccessibleObject()
accessor-method}.
@param prefix is the prefix (e.g. "get", "set" or "is").
@param suffix is the suffix (e.g. "" or "Size").
@return the requested property-name or {@code null} if NOT available. ({@code methodName} does NOT
{@link String#startsWith(String) start with} {@code prefix} or does NOT {@link String#endsWith(String) end
with} {@code suffix}).
|
[
"This",
"method",
"gets",
"the",
"according",
"{",
"@link",
"net",
".",
"sf",
".",
"mmm",
".",
"util",
".",
"pojo",
".",
"descriptor",
".",
"api",
".",
"PojoPropertyDescriptor#getName",
"()",
"property",
"-",
"name",
"}",
"for",
"the",
"given",
"{",
"@code",
"methodName",
"}",
".",
"<br",
">",
"This",
"is",
"the",
"un",
"-",
"capitalized",
"substring",
"of",
"the",
"{",
"@code",
"methodName",
"}",
"after",
"between",
"the",
"given",
"{",
"@code",
"prefix",
"}",
"and",
"{",
"@code",
"suffix",
"}",
"."
] |
train
|
https://github.com/m-m-m/util/blob/f0e4e084448f8dfc83ca682a9e1618034a094ce6/pojo/src/main/java/net/sf/mmm/util/pojo/descriptor/base/accessor/AbstractPojoPropertyAccessorBuilder.java#L112-L118
|
facebookarchive/hadoop-20
|
src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaJobHistory.java
|
CoronaJobHistory.logTaskUpdates
|
public void logTaskUpdates(TaskID taskId, long finishTime) {
"""
Update the finish time of task.
@param taskId task id
@param finishTime finish time of task in ms
"""
if (disableHistory) {
return;
}
JobID id = taskId.getJobID();
if (!this.jobId.equals(id)) {
throw new RuntimeException("JobId from task: " + id +
" does not match expected: " + jobId);
}
if (null != writers) {
log(writers, RecordTypes.Task,
new Keys[]{Keys.TASKID, Keys.FINISH_TIME},
new String[]{ taskId.toString(),
String.valueOf(finishTime)});
}
}
|
java
|
public void logTaskUpdates(TaskID taskId, long finishTime) {
if (disableHistory) {
return;
}
JobID id = taskId.getJobID();
if (!this.jobId.equals(id)) {
throw new RuntimeException("JobId from task: " + id +
" does not match expected: " + jobId);
}
if (null != writers) {
log(writers, RecordTypes.Task,
new Keys[]{Keys.TASKID, Keys.FINISH_TIME},
new String[]{ taskId.toString(),
String.valueOf(finishTime)});
}
}
|
[
"public",
"void",
"logTaskUpdates",
"(",
"TaskID",
"taskId",
",",
"long",
"finishTime",
")",
"{",
"if",
"(",
"disableHistory",
")",
"{",
"return",
";",
"}",
"JobID",
"id",
"=",
"taskId",
".",
"getJobID",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"jobId",
".",
"equals",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"JobId from task: \"",
"+",
"id",
"+",
"\" does not match expected: \"",
"+",
"jobId",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"writers",
")",
"{",
"log",
"(",
"writers",
",",
"RecordTypes",
".",
"Task",
",",
"new",
"Keys",
"[",
"]",
"{",
"Keys",
".",
"TASKID",
",",
"Keys",
".",
"FINISH_TIME",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"taskId",
".",
"toString",
"(",
")",
",",
"String",
".",
"valueOf",
"(",
"finishTime",
")",
"}",
")",
";",
"}",
"}"
] |
Update the finish time of task.
@param taskId task id
@param finishTime finish time of task in ms
|
[
"Update",
"the",
"finish",
"time",
"of",
"task",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/contrib/corona/src/java/org/apache/hadoop/mapred/CoronaJobHistory.java#L536-L553
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java
|
AbstractMastersListener.syncConnection
|
public void syncConnection(Protocol from, Protocol to) throws SQLException {
"""
When switching between 2 connections, report existing connection parameter to the new used
connection.
@param from used connection
@param to will-be-current connection
@throws SQLException if catalog cannot be set
"""
if (from != null) {
proxy.lock.lock();
try {
to.resetStateAfterFailover(from.getMaxRows(), from.getTransactionIsolationLevel(),
from.getDatabase(), from.getAutocommit());
} finally {
proxy.lock.unlock();
}
}
}
|
java
|
public void syncConnection(Protocol from, Protocol to) throws SQLException {
if (from != null) {
proxy.lock.lock();
try {
to.resetStateAfterFailover(from.getMaxRows(), from.getTransactionIsolationLevel(),
from.getDatabase(), from.getAutocommit());
} finally {
proxy.lock.unlock();
}
}
}
|
[
"public",
"void",
"syncConnection",
"(",
"Protocol",
"from",
",",
"Protocol",
"to",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"from",
"!=",
"null",
")",
"{",
"proxy",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"to",
".",
"resetStateAfterFailover",
"(",
"from",
".",
"getMaxRows",
"(",
")",
",",
"from",
".",
"getTransactionIsolationLevel",
"(",
")",
",",
"from",
".",
"getDatabase",
"(",
")",
",",
"from",
".",
"getAutocommit",
"(",
")",
")",
";",
"}",
"finally",
"{",
"proxy",
".",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}",
"}"
] |
When switching between 2 connections, report existing connection parameter to the new used
connection.
@param from used connection
@param to will-be-current connection
@throws SQLException if catalog cannot be set
|
[
"When",
"switching",
"between",
"2",
"connections",
"report",
"existing",
"connection",
"parameter",
"to",
"the",
"new",
"used",
"connection",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/failover/AbstractMastersListener.java#L409-L422
|
lucee/Lucee
|
core/src/main/java/lucee/runtime/db/QoQ.java
|
QoQ.executeColumn
|
private Object executeColumn(SQL sql, Query qr, Column column, int row) throws PageException {
"""
Executes a constant value
@param sql
@param qr
@param column
@param row
@return result
@throws PageException
"""
if (column.getColumn().equals("?")) {
int pos = column.getColumnIndex();
if (sql.getItems().length <= pos) throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
return sql.getItems()[pos].getValueForCF();
}
return column.getValue(qr, row);
// return qr.getAt(column.getColumn(),row);
}
|
java
|
private Object executeColumn(SQL sql, Query qr, Column column, int row) throws PageException {
if (column.getColumn().equals("?")) {
int pos = column.getColumnIndex();
if (sql.getItems().length <= pos) throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
return sql.getItems()[pos].getValueForCF();
}
return column.getValue(qr, row);
// return qr.getAt(column.getColumn(),row);
}
|
[
"private",
"Object",
"executeColumn",
"(",
"SQL",
"sql",
",",
"Query",
"qr",
",",
"Column",
"column",
",",
"int",
"row",
")",
"throws",
"PageException",
"{",
"if",
"(",
"column",
".",
"getColumn",
"(",
")",
".",
"equals",
"(",
"\"?\"",
")",
")",
"{",
"int",
"pos",
"=",
"column",
".",
"getColumnIndex",
"(",
")",
";",
"if",
"(",
"sql",
".",
"getItems",
"(",
")",
".",
"length",
"<=",
"pos",
")",
"throw",
"new",
"DatabaseException",
"(",
"\"invalid syntax for SQL Statement\"",
",",
"null",
",",
"sql",
",",
"null",
")",
";",
"return",
"sql",
".",
"getItems",
"(",
")",
"[",
"pos",
"]",
".",
"getValueForCF",
"(",
")",
";",
"}",
"return",
"column",
".",
"getValue",
"(",
"qr",
",",
"row",
")",
";",
"// return qr.getAt(column.getColumn(),row);",
"}"
] |
Executes a constant value
@param sql
@param qr
@param column
@param row
@return result
@throws PageException
|
[
"Executes",
"a",
"constant",
"value"
] |
train
|
https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/db/QoQ.java#L845-L853
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/planner/PlannerWriter.java
|
PlannerWriter.processExceptionDays
|
private void processExceptionDays(ProjectCalendar mpxjCalendar, List<net.sf.mpxj.planner.schema.Day> dayList) {
"""
Process exception days.
@param mpxjCalendar MPXJ Calendar instance
@param dayList Planner list of exception days
"""
for (ProjectCalendarException mpxjCalendarException : mpxjCalendar.getCalendarExceptions())
{
Date rangeStartDay = mpxjCalendarException.getFromDate();
Date rangeEndDay = mpxjCalendarException.getToDate();
if (DateHelper.getDayStartDate(rangeStartDay).getTime() == DateHelper.getDayEndDate(rangeEndDay).getTime())
{
//
// Exception covers a single day
//
net.sf.mpxj.planner.schema.Day day = m_factory.createDay();
dayList.add(day);
day.setType("day-type");
day.setDate(getDateString(mpxjCalendarException.getFromDate()));
day.setId(mpxjCalendarException.getWorking() ? "0" : "1");
}
else
{
//
// Exception covers a range of days
//
Calendar cal = DateHelper.popCalendar(rangeStartDay);
while (cal.getTime().getTime() < rangeEndDay.getTime())
{
net.sf.mpxj.planner.schema.Day day = m_factory.createDay();
dayList.add(day);
day.setType("day-type");
day.setDate(getDateString(cal.getTime()));
day.setId(mpxjCalendarException.getWorking() ? "0" : "1");
cal.add(Calendar.DAY_OF_YEAR, 1);
}
DateHelper.pushCalendar(cal);
}
/**
* @TODO we need to deal with date ranges here
*/
}
}
|
java
|
private void processExceptionDays(ProjectCalendar mpxjCalendar, List<net.sf.mpxj.planner.schema.Day> dayList)
{
for (ProjectCalendarException mpxjCalendarException : mpxjCalendar.getCalendarExceptions())
{
Date rangeStartDay = mpxjCalendarException.getFromDate();
Date rangeEndDay = mpxjCalendarException.getToDate();
if (DateHelper.getDayStartDate(rangeStartDay).getTime() == DateHelper.getDayEndDate(rangeEndDay).getTime())
{
//
// Exception covers a single day
//
net.sf.mpxj.planner.schema.Day day = m_factory.createDay();
dayList.add(day);
day.setType("day-type");
day.setDate(getDateString(mpxjCalendarException.getFromDate()));
day.setId(mpxjCalendarException.getWorking() ? "0" : "1");
}
else
{
//
// Exception covers a range of days
//
Calendar cal = DateHelper.popCalendar(rangeStartDay);
while (cal.getTime().getTime() < rangeEndDay.getTime())
{
net.sf.mpxj.planner.schema.Day day = m_factory.createDay();
dayList.add(day);
day.setType("day-type");
day.setDate(getDateString(cal.getTime()));
day.setId(mpxjCalendarException.getWorking() ? "0" : "1");
cal.add(Calendar.DAY_OF_YEAR, 1);
}
DateHelper.pushCalendar(cal);
}
/**
* @TODO we need to deal with date ranges here
*/
}
}
|
[
"private",
"void",
"processExceptionDays",
"(",
"ProjectCalendar",
"mpxjCalendar",
",",
"List",
"<",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Day",
">",
"dayList",
")",
"{",
"for",
"(",
"ProjectCalendarException",
"mpxjCalendarException",
":",
"mpxjCalendar",
".",
"getCalendarExceptions",
"(",
")",
")",
"{",
"Date",
"rangeStartDay",
"=",
"mpxjCalendarException",
".",
"getFromDate",
"(",
")",
";",
"Date",
"rangeEndDay",
"=",
"mpxjCalendarException",
".",
"getToDate",
"(",
")",
";",
"if",
"(",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeStartDay",
")",
".",
"getTime",
"(",
")",
"==",
"DateHelper",
".",
"getDayEndDate",
"(",
"rangeEndDay",
")",
".",
"getTime",
"(",
")",
")",
"{",
"//",
"// Exception covers a single day",
"//",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Day",
"day",
"=",
"m_factory",
".",
"createDay",
"(",
")",
";",
"dayList",
".",
"add",
"(",
"day",
")",
";",
"day",
".",
"setType",
"(",
"\"day-type\"",
")",
";",
"day",
".",
"setDate",
"(",
"getDateString",
"(",
"mpxjCalendarException",
".",
"getFromDate",
"(",
")",
")",
")",
";",
"day",
".",
"setId",
"(",
"mpxjCalendarException",
".",
"getWorking",
"(",
")",
"?",
"\"0\"",
":",
"\"1\"",
")",
";",
"}",
"else",
"{",
"//",
"// Exception covers a range of days",
"//",
"Calendar",
"cal",
"=",
"DateHelper",
".",
"popCalendar",
"(",
"rangeStartDay",
")",
";",
"while",
"(",
"cal",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
"<",
"rangeEndDay",
".",
"getTime",
"(",
")",
")",
"{",
"net",
".",
"sf",
".",
"mpxj",
".",
"planner",
".",
"schema",
".",
"Day",
"day",
"=",
"m_factory",
".",
"createDay",
"(",
")",
";",
"dayList",
".",
"add",
"(",
"day",
")",
";",
"day",
".",
"setType",
"(",
"\"day-type\"",
")",
";",
"day",
".",
"setDate",
"(",
"getDateString",
"(",
"cal",
".",
"getTime",
"(",
")",
")",
")",
";",
"day",
".",
"setId",
"(",
"mpxjCalendarException",
".",
"getWorking",
"(",
")",
"?",
"\"0\"",
":",
"\"1\"",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DAY_OF_YEAR",
",",
"1",
")",
";",
"}",
"DateHelper",
".",
"pushCalendar",
"(",
"cal",
")",
";",
"}",
"/**\n * @TODO we need to deal with date ranges here\n */",
"}",
"}"
] |
Process exception days.
@param mpxjCalendar MPXJ Calendar instance
@param dayList Planner list of exception days
|
[
"Process",
"exception",
"days",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/planner/PlannerWriter.java#L329-L370
|
RoaringBitmap/RoaringBitmap
|
roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java
|
RoaringBitmap.contains
|
public boolean contains(RoaringBitmap subset) {
"""
Checks whether the parameter is a subset of this RoaringBitmap or not
@param subset the potential subset
@return true if the parameter is a subset of this RoaringBitmap
"""
if(subset.getCardinality() > getCardinality()) {
return false;
}
final int length1 = this.highLowContainer.size;
final int length2 = subset.highLowContainer.size;
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = this.highLowContainer.getKeyAtIndex(pos1);
final short s2 = subset.highLowContainer.getKeyAtIndex(pos2);
if (s1 == s2) {
Container c1 = this.highLowContainer.getContainerAtIndex(pos1);
Container c2 = subset.highLowContainer.getContainerAtIndex(pos2);
if(!c1.contains(c2)) {
return false;
}
++pos1;
++pos2;
} else if (Util.compareUnsigned(s1, s2) > 0) {
return false;
} else {
pos1 = subset.highLowContainer.advanceUntil(s2, pos1);
}
}
return pos2 == length2;
}
|
java
|
public boolean contains(RoaringBitmap subset) {
if(subset.getCardinality() > getCardinality()) {
return false;
}
final int length1 = this.highLowContainer.size;
final int length2 = subset.highLowContainer.size;
int pos1 = 0, pos2 = 0;
while (pos1 < length1 && pos2 < length2) {
final short s1 = this.highLowContainer.getKeyAtIndex(pos1);
final short s2 = subset.highLowContainer.getKeyAtIndex(pos2);
if (s1 == s2) {
Container c1 = this.highLowContainer.getContainerAtIndex(pos1);
Container c2 = subset.highLowContainer.getContainerAtIndex(pos2);
if(!c1.contains(c2)) {
return false;
}
++pos1;
++pos2;
} else if (Util.compareUnsigned(s1, s2) > 0) {
return false;
} else {
pos1 = subset.highLowContainer.advanceUntil(s2, pos1);
}
}
return pos2 == length2;
}
|
[
"public",
"boolean",
"contains",
"(",
"RoaringBitmap",
"subset",
")",
"{",
"if",
"(",
"subset",
".",
"getCardinality",
"(",
")",
">",
"getCardinality",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"length1",
"=",
"this",
".",
"highLowContainer",
".",
"size",
";",
"final",
"int",
"length2",
"=",
"subset",
".",
"highLowContainer",
".",
"size",
";",
"int",
"pos1",
"=",
"0",
",",
"pos2",
"=",
"0",
";",
"while",
"(",
"pos1",
"<",
"length1",
"&&",
"pos2",
"<",
"length2",
")",
"{",
"final",
"short",
"s1",
"=",
"this",
".",
"highLowContainer",
".",
"getKeyAtIndex",
"(",
"pos1",
")",
";",
"final",
"short",
"s2",
"=",
"subset",
".",
"highLowContainer",
".",
"getKeyAtIndex",
"(",
"pos2",
")",
";",
"if",
"(",
"s1",
"==",
"s2",
")",
"{",
"Container",
"c1",
"=",
"this",
".",
"highLowContainer",
".",
"getContainerAtIndex",
"(",
"pos1",
")",
";",
"Container",
"c2",
"=",
"subset",
".",
"highLowContainer",
".",
"getContainerAtIndex",
"(",
"pos2",
")",
";",
"if",
"(",
"!",
"c1",
".",
"contains",
"(",
"c2",
")",
")",
"{",
"return",
"false",
";",
"}",
"++",
"pos1",
";",
"++",
"pos2",
";",
"}",
"else",
"if",
"(",
"Util",
".",
"compareUnsigned",
"(",
"s1",
",",
"s2",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"pos1",
"=",
"subset",
".",
"highLowContainer",
".",
"advanceUntil",
"(",
"s2",
",",
"pos1",
")",
";",
"}",
"}",
"return",
"pos2",
"==",
"length2",
";",
"}"
] |
Checks whether the parameter is a subset of this RoaringBitmap or not
@param subset the potential subset
@return true if the parameter is a subset of this RoaringBitmap
|
[
"Checks",
"whether",
"the",
"parameter",
"is",
"a",
"subset",
"of",
"this",
"RoaringBitmap",
"or",
"not"
] |
train
|
https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L2287-L2312
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.