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
|
---|---|---|---|---|---|---|---|---|---|---|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java
|
LdapAdapter.getString
|
@Trivial
private String getString(boolean isOctet, Object ldapValue) {
"""
Convert the value into an appropriate string value.
@param isOctet
@param ldapValue
@return
"""
if (isOctet) {
return LdapHelper.getOctetString((byte[]) ldapValue);
} else {
return ldapValue.toString();
}
}
|
java
|
@Trivial
private String getString(boolean isOctet, Object ldapValue) {
if (isOctet) {
return LdapHelper.getOctetString((byte[]) ldapValue);
} else {
return ldapValue.toString();
}
}
|
[
"@",
"Trivial",
"private",
"String",
"getString",
"(",
"boolean",
"isOctet",
",",
"Object",
"ldapValue",
")",
"{",
"if",
"(",
"isOctet",
")",
"{",
"return",
"LdapHelper",
".",
"getOctetString",
"(",
"(",
"byte",
"[",
"]",
")",
"ldapValue",
")",
";",
"}",
"else",
"{",
"return",
"ldapValue",
".",
"toString",
"(",
")",
";",
"}",
"}"
] |
Convert the value into an appropriate string value.
@param isOctet
@param ldapValue
@return
|
[
"Convert",
"the",
"value",
"into",
"an",
"appropriate",
"string",
"value",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.wim.adapter.ldap/src/com/ibm/ws/security/wim/adapter/ldap/LdapAdapter.java#L1082-L1089
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.logging.core/src/com/ibm/websphere/logging/hpel/LogRecordContext.java
|
LogRecordContext.registerExtension
|
public static void registerExtension(String key, Extension extension) {
"""
Registers new context extension. To avoid memory leaks Extensions are
stored as weak references. It means that caller need to keep strong
reference (a static field for example) to keep that extension in the
registration map.
@param key
String key to associate with the registered extension
@param extension
{@link Extension} implementation returning extension runtime
values
@throws IllegalArgumentException
if parameter <code>key</code> or <code>extension</code> are
<code>null</code>; or if <code>key</code> already has
extension associated with it.
"""
if (key == null || extension == null) {
throw new IllegalArgumentException(
"Neither 'key' nor 'extension' parameter can be null.");
}
w.lock();
try {
if (extensionMap.containsKey(key)) {
throw new IllegalArgumentException("Extension with the key "
+ key + " is registered already");
}
extensionMap.put(key, new WeakReference<Extension>(extension));
} finally {
w.unlock();
}
}
|
java
|
public static void registerExtension(String key, Extension extension) {
if (key == null || extension == null) {
throw new IllegalArgumentException(
"Neither 'key' nor 'extension' parameter can be null.");
}
w.lock();
try {
if (extensionMap.containsKey(key)) {
throw new IllegalArgumentException("Extension with the key "
+ key + " is registered already");
}
extensionMap.put(key, new WeakReference<Extension>(extension));
} finally {
w.unlock();
}
}
|
[
"public",
"static",
"void",
"registerExtension",
"(",
"String",
"key",
",",
"Extension",
"extension",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"extension",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Neither 'key' nor 'extension' parameter can be null.\"",
")",
";",
"}",
"w",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"extensionMap",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Extension with the key \"",
"+",
"key",
"+",
"\" is registered already\"",
")",
";",
"}",
"extensionMap",
".",
"put",
"(",
"key",
",",
"new",
"WeakReference",
"<",
"Extension",
">",
"(",
"extension",
")",
")",
";",
"}",
"finally",
"{",
"w",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Registers new context extension. To avoid memory leaks Extensions are
stored as weak references. It means that caller need to keep strong
reference (a static field for example) to keep that extension in the
registration map.
@param key
String key to associate with the registered extension
@param extension
{@link Extension} implementation returning extension runtime
values
@throws IllegalArgumentException
if parameter <code>key</code> or <code>extension</code> are
<code>null</code>; or if <code>key</code> already has
extension associated with it.
|
[
"Registers",
"new",
"context",
"extension",
".",
"To",
"avoid",
"memory",
"leaks",
"Extensions",
"are",
"stored",
"as",
"weak",
"references",
".",
"It",
"means",
"that",
"caller",
"need",
"to",
"keep",
"strong",
"reference",
"(",
"a",
"static",
"field",
"for",
"example",
")",
"to",
"keep",
"that",
"extension",
"in",
"the",
"registration",
"map",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.core/src/com/ibm/websphere/logging/hpel/LogRecordContext.java#L241-L256
|
jparsec/jparsec
|
jparsec/src/main/java/org/jparsec/Parsers.java
|
Parsers.or
|
public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2) {
"""
A {@link Parser} that tries 2 alternative parser objects.
Fallback happens regardless of partial match.
"""
return alt(p1, p2).cast();
}
|
java
|
public static <T> Parser<T> or(Parser<? extends T> p1, Parser<? extends T> p2) {
return alt(p1, p2).cast();
}
|
[
"public",
"static",
"<",
"T",
">",
"Parser",
"<",
"T",
">",
"or",
"(",
"Parser",
"<",
"?",
"extends",
"T",
">",
"p1",
",",
"Parser",
"<",
"?",
"extends",
"T",
">",
"p2",
")",
"{",
"return",
"alt",
"(",
"p1",
",",
"p2",
")",
".",
"cast",
"(",
")",
";",
"}"
] |
A {@link Parser} that tries 2 alternative parser objects.
Fallback happens regardless of partial match.
|
[
"A",
"{"
] |
train
|
https://github.com/jparsec/jparsec/blob/df1280259f5da9eb5ffc537437569dddba66cb94/jparsec/src/main/java/org/jparsec/Parsers.java#L618-L620
|
aws/aws-sdk-java
|
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/CodeGenerator.java
|
CodeGenerator.execute
|
public void execute() {
"""
load ServiceModel. load code gen configuration from individual client. load Waiters. generate intermediate model. generate
code.
"""
try {
final IntermediateModel intermediateModel =
new IntermediateModelBuilder(models, codeGenBinDirectory).build();
// Dump the intermediate model to a file
writeIntermediateModel(intermediateModel);
emitCode(intermediateModel);
} catch (Exception e) {
throw new RuntimeException(
"Failed to generate code. Exception message : "
+ e.getMessage(), e);
}
}
|
java
|
public void execute() {
try {
final IntermediateModel intermediateModel =
new IntermediateModelBuilder(models, codeGenBinDirectory).build();
// Dump the intermediate model to a file
writeIntermediateModel(intermediateModel);
emitCode(intermediateModel);
} catch (Exception e) {
throw new RuntimeException(
"Failed to generate code. Exception message : "
+ e.getMessage(), e);
}
}
|
[
"public",
"void",
"execute",
"(",
")",
"{",
"try",
"{",
"final",
"IntermediateModel",
"intermediateModel",
"=",
"new",
"IntermediateModelBuilder",
"(",
"models",
",",
"codeGenBinDirectory",
")",
".",
"build",
"(",
")",
";",
"// Dump the intermediate model to a file",
"writeIntermediateModel",
"(",
"intermediateModel",
")",
";",
"emitCode",
"(",
"intermediateModel",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to generate code. Exception message : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
load ServiceModel. load code gen configuration from individual client. load Waiters. generate intermediate model. generate
code.
|
[
"load",
"ServiceModel",
".",
"load",
"code",
"gen",
"configuration",
"from",
"individual",
"client",
".",
"load",
"Waiters",
".",
"generate",
"intermediate",
"model",
".",
"generate",
"code",
"."
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/CodeGenerator.java#L59-L75
|
hdbeukel/james-core
|
src/main/java/org/jamesframework/core/search/algo/tabu/TabuSearch.java
|
TabuSearch.setCurrentSolution
|
@Override
public void setCurrentSolution(SolutionType solution) {
"""
Updates the tabu memory when a custom current/initial solution is set. Note that this method
may only be called when the search is idle.
@param solution manually specified current solution
@throws SearchException if the search is not idle
@throws NullPointerException if <code>solution</code> is <code>null</code>
"""
// call super (also verifies search status)
super.setCurrentSolution(solution);
// update tabu memory (no move has been applied to obtain this solution, pass null)
tabuMemory.registerVisitedSolution(solution, null);
}
|
java
|
@Override
public void setCurrentSolution(SolutionType solution){
// call super (also verifies search status)
super.setCurrentSolution(solution);
// update tabu memory (no move has been applied to obtain this solution, pass null)
tabuMemory.registerVisitedSolution(solution, null);
}
|
[
"@",
"Override",
"public",
"void",
"setCurrentSolution",
"(",
"SolutionType",
"solution",
")",
"{",
"// call super (also verifies search status)",
"super",
".",
"setCurrentSolution",
"(",
"solution",
")",
";",
"// update tabu memory (no move has been applied to obtain this solution, pass null)",
"tabuMemory",
".",
"registerVisitedSolution",
"(",
"solution",
",",
"null",
")",
";",
"}"
] |
Updates the tabu memory when a custom current/initial solution is set. Note that this method
may only be called when the search is idle.
@param solution manually specified current solution
@throws SearchException if the search is not idle
@throws NullPointerException if <code>solution</code> is <code>null</code>
|
[
"Updates",
"the",
"tabu",
"memory",
"when",
"a",
"custom",
"current",
"/",
"initial",
"solution",
"is",
"set",
".",
"Note",
"that",
"this",
"method",
"may",
"only",
"be",
"called",
"when",
"the",
"search",
"is",
"idle",
"."
] |
train
|
https://github.com/hdbeukel/james-core/blob/4e85c20c142902373e5b5e8b5d12a2558650f66d/src/main/java/org/jamesframework/core/search/algo/tabu/TabuSearch.java#L154-L160
|
lessthanoptimal/BoofCV
|
examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java
|
ExampleDetectDescribe.createFromPremade
|
public static <T extends ImageGray<T>, TD extends TupleDesc>
DetectDescribePoint<T, TD> createFromPremade( Class<T> imageType ) {
"""
For some features, there are pre-made implementations of DetectDescribePoint. This has only been done
in situations where there was a performance advantage or that it was a very common combination.
"""
return (DetectDescribePoint)FactoryDetectDescribe.surfStable(
new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType);
// return (DetectDescribePoint)FactoryDetectDescribe.sift(new ConfigCompleteSift(-1,5,300));
}
|
java
|
public static <T extends ImageGray<T>, TD extends TupleDesc>
DetectDescribePoint<T, TD> createFromPremade( Class<T> imageType ) {
return (DetectDescribePoint)FactoryDetectDescribe.surfStable(
new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType);
// return (DetectDescribePoint)FactoryDetectDescribe.sift(new ConfigCompleteSift(-1,5,300));
}
|
[
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"TD",
"extends",
"TupleDesc",
">",
"DetectDescribePoint",
"<",
"T",
",",
"TD",
">",
"createFromPremade",
"(",
"Class",
"<",
"T",
">",
"imageType",
")",
"{",
"return",
"(",
"DetectDescribePoint",
")",
"FactoryDetectDescribe",
".",
"surfStable",
"(",
"new",
"ConfigFastHessian",
"(",
"1",
",",
"2",
",",
"200",
",",
"1",
",",
"9",
",",
"4",
",",
"4",
")",
",",
"null",
",",
"null",
",",
"imageType",
")",
";",
"//\t\treturn (DetectDescribePoint)FactoryDetectDescribe.sift(new ConfigCompleteSift(-1,5,300));",
"}"
] |
For some features, there are pre-made implementations of DetectDescribePoint. This has only been done
in situations where there was a performance advantage or that it was a very common combination.
|
[
"For",
"some",
"features",
"there",
"are",
"pre",
"-",
"made",
"implementations",
"of",
"DetectDescribePoint",
".",
"This",
"has",
"only",
"been",
"done",
"in",
"situations",
"where",
"there",
"was",
"a",
"performance",
"advantage",
"or",
"that",
"it",
"was",
"a",
"very",
"common",
"combination",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java#L61-L66
|
gmessner/gitlab4j-api
|
src/main/java/org/gitlab4j/api/MilestonesApi.java
|
MilestonesApi.createMilestone
|
public Milestone createMilestone(Object projectIdOrPath, String title, String description, Date dueDate, Date startDate) throws GitLabApiException {
"""
Create a milestone.
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param title the title for the milestone
@param description the description for the milestone
@param dueDate the due date for the milestone
@param startDate the start date for the milestone
@return the created Milestone instance
@throws GitLabApiException if any exception occurs
"""
GitLabApiForm formData = new GitLabApiForm()
.withParam("title", title, true)
.withParam("description", description)
.withParam("due_date", dueDate)
.withParam("start_date", startDate);
Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "milestones");
return (response.readEntity(Milestone.class));
}
|
java
|
public Milestone createMilestone(Object projectIdOrPath, String title, String description, Date dueDate, Date startDate) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("title", title, true)
.withParam("description", description)
.withParam("due_date", dueDate)
.withParam("start_date", startDate);
Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "milestones");
return (response.readEntity(Milestone.class));
}
|
[
"public",
"Milestone",
"createMilestone",
"(",
"Object",
"projectIdOrPath",
",",
"String",
"title",
",",
"String",
"description",
",",
"Date",
"dueDate",
",",
"Date",
"startDate",
")",
"throws",
"GitLabApiException",
"{",
"GitLabApiForm",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"title\"",
",",
"title",
",",
"true",
")",
".",
"withParam",
"(",
"\"description\"",
",",
"description",
")",
".",
"withParam",
"(",
"\"due_date\"",
",",
"dueDate",
")",
".",
"withParam",
"(",
"\"start_date\"",
",",
"startDate",
")",
";",
"Response",
"response",
"=",
"post",
"(",
"Response",
".",
"Status",
".",
"CREATED",
",",
"formData",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"milestones\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"Milestone",
".",
"class",
")",
")",
";",
"}"
] |
Create a milestone.
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param title the title for the milestone
@param description the description for the milestone
@param dueDate the due date for the milestone
@param startDate the start date for the milestone
@return the created Milestone instance
@throws GitLabApiException if any exception occurs
|
[
"Create",
"a",
"milestone",
"."
] |
train
|
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/MilestonesApi.java#L410-L419
|
scireum/server-sass
|
src/main/java/org/serversass/Generator.java
|
Generator.combineSelectors
|
private void combineSelectors(List<String> selector, List<String> parentSelectors) {
"""
/*
If a child selector starts with & e.g. &.test we have to marry the last element of
the parent selector with the first element of the child selector to create
"ul nav.test" (if the parent as "ul nav"). Without the & this would become
"ul nav .test"...
"""
String firstChild = selector.get(1);
selector.remove(0);
selector.remove(0);
List<String> selectorsToAdd = new ArrayList<>(parentSelectors);
String lastParent = selectorsToAdd.get(selectorsToAdd.size() - 1);
selectorsToAdd.remove(selectorsToAdd.size() - 1);
selector.add(0, lastParent + firstChild);
selector.addAll(0, selectorsToAdd);
}
|
java
|
private void combineSelectors(List<String> selector, List<String> parentSelectors) {
String firstChild = selector.get(1);
selector.remove(0);
selector.remove(0);
List<String> selectorsToAdd = new ArrayList<>(parentSelectors);
String lastParent = selectorsToAdd.get(selectorsToAdd.size() - 1);
selectorsToAdd.remove(selectorsToAdd.size() - 1);
selector.add(0, lastParent + firstChild);
selector.addAll(0, selectorsToAdd);
}
|
[
"private",
"void",
"combineSelectors",
"(",
"List",
"<",
"String",
">",
"selector",
",",
"List",
"<",
"String",
">",
"parentSelectors",
")",
"{",
"String",
"firstChild",
"=",
"selector",
".",
"get",
"(",
"1",
")",
";",
"selector",
".",
"remove",
"(",
"0",
")",
";",
"selector",
".",
"remove",
"(",
"0",
")",
";",
"List",
"<",
"String",
">",
"selectorsToAdd",
"=",
"new",
"ArrayList",
"<>",
"(",
"parentSelectors",
")",
";",
"String",
"lastParent",
"=",
"selectorsToAdd",
".",
"get",
"(",
"selectorsToAdd",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"selectorsToAdd",
".",
"remove",
"(",
"selectorsToAdd",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"selector",
".",
"add",
"(",
"0",
",",
"lastParent",
"+",
"firstChild",
")",
";",
"selector",
".",
"addAll",
"(",
"0",
",",
"selectorsToAdd",
")",
";",
"}"
] |
/*
If a child selector starts with & e.g. &.test we have to marry the last element of
the parent selector with the first element of the child selector to create
"ul nav.test" (if the parent as "ul nav"). Without the & this would become
"ul nav .test"...
|
[
"/",
"*",
"If",
"a",
"child",
"selector",
"starts",
"with",
"&",
"e",
".",
"g",
".",
"&",
".",
"test",
"we",
"have",
"to",
"marry",
"the",
"last",
"element",
"of",
"the",
"parent",
"selector",
"with",
"the",
"first",
"element",
"of",
"the",
"child",
"selector",
"to",
"create",
"ul",
"nav",
".",
"test",
"(",
"if",
"the",
"parent",
"as",
"ul",
"nav",
")",
".",
"Without",
"the",
"&",
"this",
"would",
"become",
"ul",
"nav",
".",
"test",
"..."
] |
train
|
https://github.com/scireum/server-sass/blob/e74af983567f10c43420d70cd31165dd080ba8fc/src/main/java/org/serversass/Generator.java#L345-L354
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java
|
Hierarchy.getInnerClassAccess
|
public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException {
"""
Get the InnerClassAccess for access method called by given INVOKESTATIC.
@param inv
the INVOKESTATIC instruction
@param cpg
the ConstantPoolGen for the method
@return the InnerClassAccess, or null if the instruction is not an
inner-class access
"""
String className = inv.getClassName(cpg);
String methodName = inv.getName(cpg);
String methodSig = inv.getSignature(cpg);
InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap()
.getInnerClassAccess(className, methodName);
return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null;
}
|
java
|
public static InnerClassAccess getInnerClassAccess(INVOKESTATIC inv, ConstantPoolGen cpg) throws ClassNotFoundException {
String className = inv.getClassName(cpg);
String methodName = inv.getName(cpg);
String methodSig = inv.getSignature(cpg);
InnerClassAccess access = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap()
.getInnerClassAccess(className, methodName);
return (access != null && access.getMethodSignature().equals(methodSig)) ? access : null;
}
|
[
"public",
"static",
"InnerClassAccess",
"getInnerClassAccess",
"(",
"INVOKESTATIC",
"inv",
",",
"ConstantPoolGen",
"cpg",
")",
"throws",
"ClassNotFoundException",
"{",
"String",
"className",
"=",
"inv",
".",
"getClassName",
"(",
"cpg",
")",
";",
"String",
"methodName",
"=",
"inv",
".",
"getName",
"(",
"cpg",
")",
";",
"String",
"methodSig",
"=",
"inv",
".",
"getSignature",
"(",
"cpg",
")",
";",
"InnerClassAccess",
"access",
"=",
"AnalysisContext",
".",
"currentAnalysisContext",
"(",
")",
".",
"getInnerClassAccessMap",
"(",
")",
".",
"getInnerClassAccess",
"(",
"className",
",",
"methodName",
")",
";",
"return",
"(",
"access",
"!=",
"null",
"&&",
"access",
".",
"getMethodSignature",
"(",
")",
".",
"equals",
"(",
"methodSig",
")",
")",
"?",
"access",
":",
"null",
";",
"}"
] |
Get the InnerClassAccess for access method called by given INVOKESTATIC.
@param inv
the INVOKESTATIC instruction
@param cpg
the ConstantPoolGen for the method
@return the InnerClassAccess, or null if the instruction is not an
inner-class access
|
[
"Get",
"the",
"InnerClassAccess",
"for",
"access",
"method",
"called",
"by",
"given",
"INVOKESTATIC",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L985-L994
|
javamelody/javamelody
|
javamelody-swing/src/main/java/net/bull/javamelody/swing/Utilities.java
|
Utilities.showTextInPopup
|
public static void showTextInPopup(Component component, String title, String text) {
"""
Affiche un texte scrollable non éditable dans une popup.
@param component Parent
@param title Titre de la popup
@param text Texte
"""
final JTextArea textArea = new JTextArea();
textArea.setText(text);
textArea.setEditable(false);
textArea.setCaretPosition(0);
// background nécessaire avec la plupart des look and feels dont Nimbus,
// sinon il reste blanc malgré editable false
textArea.setBackground(Color.decode("#E6E6E6"));
final JScrollPane scrollPane = new JScrollPane(textArea);
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
final MButton clipBoardButton = new MButton(
I18NAdapter.getString("Copier_dans_presse-papiers"));
clipBoardButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textArea.selectAll();
textArea.copy();
textArea.setCaretPosition(0);
}
});
buttonPanel.setOpaque(false);
buttonPanel.add(clipBoardButton);
final Window window = SwingUtilities.getWindowAncestor(component);
final JDialog dialog = new JDialog((JFrame) window, title, true);
final JPanel contentPane = new JPanel(new BorderLayout());
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
dialog.setContentPane(contentPane);
dialog.pack();
dialog.setLocationRelativeTo(window);
dialog.setVisible(true);
}
|
java
|
public static void showTextInPopup(Component component, String title, String text) {
final JTextArea textArea = new JTextArea();
textArea.setText(text);
textArea.setEditable(false);
textArea.setCaretPosition(0);
// background nécessaire avec la plupart des look and feels dont Nimbus,
// sinon il reste blanc malgré editable false
textArea.setBackground(Color.decode("#E6E6E6"));
final JScrollPane scrollPane = new JScrollPane(textArea);
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
final MButton clipBoardButton = new MButton(
I18NAdapter.getString("Copier_dans_presse-papiers"));
clipBoardButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
textArea.selectAll();
textArea.copy();
textArea.setCaretPosition(0);
}
});
buttonPanel.setOpaque(false);
buttonPanel.add(clipBoardButton);
final Window window = SwingUtilities.getWindowAncestor(component);
final JDialog dialog = new JDialog((JFrame) window, title, true);
final JPanel contentPane = new JPanel(new BorderLayout());
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
dialog.setContentPane(contentPane);
dialog.pack();
dialog.setLocationRelativeTo(window);
dialog.setVisible(true);
}
|
[
"public",
"static",
"void",
"showTextInPopup",
"(",
"Component",
"component",
",",
"String",
"title",
",",
"String",
"text",
")",
"{",
"final",
"JTextArea",
"textArea",
"=",
"new",
"JTextArea",
"(",
")",
";",
"textArea",
".",
"setText",
"(",
"text",
")",
";",
"textArea",
".",
"setEditable",
"(",
"false",
")",
";",
"textArea",
".",
"setCaretPosition",
"(",
"0",
")",
";",
"// background nécessaire avec la plupart des look and feels dont Nimbus,\r",
"// sinon il reste blanc malgré editable false\r",
"textArea",
".",
"setBackground",
"(",
"Color",
".",
"decode",
"(",
"\"#E6E6E6\"",
")",
")",
";",
"final",
"JScrollPane",
"scrollPane",
"=",
"new",
"JScrollPane",
"(",
"textArea",
")",
";",
"final",
"JPanel",
"buttonPanel",
"=",
"new",
"JPanel",
"(",
"new",
"FlowLayout",
"(",
"FlowLayout",
".",
"RIGHT",
",",
"0",
",",
"5",
")",
")",
";",
"final",
"MButton",
"clipBoardButton",
"=",
"new",
"MButton",
"(",
"I18NAdapter",
".",
"getString",
"(",
"\"Copier_dans_presse-papiers\"",
")",
")",
";",
"clipBoardButton",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"textArea",
".",
"selectAll",
"(",
")",
";",
"textArea",
".",
"copy",
"(",
")",
";",
"textArea",
".",
"setCaretPosition",
"(",
"0",
")",
";",
"}",
"}",
")",
";",
"buttonPanel",
".",
"setOpaque",
"(",
"false",
")",
";",
"buttonPanel",
".",
"add",
"(",
"clipBoardButton",
")",
";",
"final",
"Window",
"window",
"=",
"SwingUtilities",
".",
"getWindowAncestor",
"(",
"component",
")",
";",
"final",
"JDialog",
"dialog",
"=",
"new",
"JDialog",
"(",
"(",
"JFrame",
")",
"window",
",",
"title",
",",
"true",
")",
";",
"final",
"JPanel",
"contentPane",
"=",
"new",
"JPanel",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"contentPane",
".",
"add",
"(",
"scrollPane",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"contentPane",
".",
"add",
"(",
"buttonPanel",
",",
"BorderLayout",
".",
"SOUTH",
")",
";",
"dialog",
".",
"setContentPane",
"(",
"contentPane",
")",
";",
"dialog",
".",
"pack",
"(",
")",
";",
"dialog",
".",
"setLocationRelativeTo",
"(",
"window",
")",
";",
"dialog",
".",
"setVisible",
"(",
"true",
")",
";",
"}"
] |
Affiche un texte scrollable non éditable dans une popup.
@param component Parent
@param title Titre de la popup
@param text Texte
|
[
"Affiche",
"un",
"texte",
"scrollable",
"non",
"éditable",
"dans",
"une",
"popup",
"."
] |
train
|
https://github.com/javamelody/javamelody/blob/18ad583ddeb5dcadd797dfda295409c6983ffd71/javamelody-swing/src/main/java/net/bull/javamelody/swing/Utilities.java#L129-L162
|
facebookarchive/hadoop-20
|
src/mapred/org/apache/hadoop/mapreduce/lib/output/FileOutputCommitter.java
|
FileOutputCommitter.markOutputDirSuccessful
|
private void markOutputDirSuccessful(JobContext context)
throws IOException {
"""
Mark the output dir of the job for which the context is passed.
"""
if (outputPath != null) {
FileSystem fileSys = outputPath.getFileSystem(context.getConfiguration());
if (fileSys.exists(outputPath)) {
// create a file in the folder to mark it
Path filePath = new Path(outputPath, SUCCEEDED_FILE_NAME);
fileSys.create(filePath).close();
}
}
}
|
java
|
private void markOutputDirSuccessful(JobContext context)
throws IOException {
if (outputPath != null) {
FileSystem fileSys = outputPath.getFileSystem(context.getConfiguration());
if (fileSys.exists(outputPath)) {
// create a file in the folder to mark it
Path filePath = new Path(outputPath, SUCCEEDED_FILE_NAME);
fileSys.create(filePath).close();
}
}
}
|
[
"private",
"void",
"markOutputDirSuccessful",
"(",
"JobContext",
"context",
")",
"throws",
"IOException",
"{",
"if",
"(",
"outputPath",
"!=",
"null",
")",
"{",
"FileSystem",
"fileSys",
"=",
"outputPath",
".",
"getFileSystem",
"(",
"context",
".",
"getConfiguration",
"(",
")",
")",
";",
"if",
"(",
"fileSys",
".",
"exists",
"(",
"outputPath",
")",
")",
"{",
"// create a file in the folder to mark it",
"Path",
"filePath",
"=",
"new",
"Path",
"(",
"outputPath",
",",
"SUCCEEDED_FILE_NAME",
")",
";",
"fileSys",
".",
"create",
"(",
"filePath",
")",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Mark the output dir of the job for which the context is passed.
|
[
"Mark",
"the",
"output",
"dir",
"of",
"the",
"job",
"for",
"which",
"the",
"context",
"is",
"passed",
"."
] |
train
|
https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/mapred/org/apache/hadoop/mapreduce/lib/output/FileOutputCommitter.java#L93-L103
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTemplateElement.java
|
ElemTemplateElement.getNamespaceForPrefix
|
public String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context) {
"""
Fullfill the PrefixResolver interface. Calling this for this class
will throw an error.
@param prefix The prefix to look up, which may be an empty string ("")
for the default Namespace.
@param context The node context from which to look up the URI.
@return null if the error listener does not choose to throw an exception.
"""
this.error(XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, null);
return null;
}
|
java
|
public String getNamespaceForPrefix(String prefix, org.w3c.dom.Node context)
{
this.error(XSLTErrorResources.ER_CANT_RESOLVE_NSPREFIX, null);
return null;
}
|
[
"public",
"String",
"getNamespaceForPrefix",
"(",
"String",
"prefix",
",",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"context",
")",
"{",
"this",
".",
"error",
"(",
"XSLTErrorResources",
".",
"ER_CANT_RESOLVE_NSPREFIX",
",",
"null",
")",
";",
"return",
"null",
";",
"}"
] |
Fullfill the PrefixResolver interface. Calling this for this class
will throw an error.
@param prefix The prefix to look up, which may be an empty string ("")
for the default Namespace.
@param context The node context from which to look up the URI.
@return null if the error listener does not choose to throw an exception.
|
[
"Fullfill",
"the",
"PrefixResolver",
"interface",
".",
"Calling",
"this",
"for",
"this",
"class",
"will",
"throw",
"an",
"error",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xalan/templates/ElemTemplateElement.java#L887-L892
|
overturetool/overture
|
ide/ui/src/main/java/org/overture/ide/ui/VdmPluginImages.java
|
VdmPluginImages.createUnManagedCached
|
private static ImageDescriptor createUnManagedCached(String prefix,
String name) {
"""
/*
Creates an image descriptor for the given prefix and name in the JDT UI bundle and let tye descriptor cache the
image data. If no image could be found, the 'missing image descriptor' is returned.
"""
return new CachedImageDescriptor(create(prefix, name, true));
}
|
java
|
private static ImageDescriptor createUnManagedCached(String prefix,
String name)
{
return new CachedImageDescriptor(create(prefix, name, true));
}
|
[
"private",
"static",
"ImageDescriptor",
"createUnManagedCached",
"(",
"String",
"prefix",
",",
"String",
"name",
")",
"{",
"return",
"new",
"CachedImageDescriptor",
"(",
"create",
"(",
"prefix",
",",
"name",
",",
"true",
")",
")",
";",
"}"
] |
/*
Creates an image descriptor for the given prefix and name in the JDT UI bundle and let tye descriptor cache the
image data. If no image could be found, the 'missing image descriptor' is returned.
|
[
"/",
"*",
"Creates",
"an",
"image",
"descriptor",
"for",
"the",
"given",
"prefix",
"and",
"name",
"in",
"the",
"JDT",
"UI",
"bundle",
"and",
"let",
"tye",
"descriptor",
"cache",
"the",
"image",
"data",
".",
"If",
"no",
"image",
"could",
"be",
"found",
"the",
"missing",
"image",
"descriptor",
"is",
"returned",
"."
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/ide/ui/src/main/java/org/overture/ide/ui/VdmPluginImages.java#L802-L806
|
apache/flink
|
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TimerService.java
|
TimerService.isValid
|
public boolean isValid(K key, UUID ticket) {
"""
Check whether the timeout for the given key and ticket is still valid (not yet unregistered
and not yet overwritten).
@param key for which to check the timeout
@param ticket of the timeout
@return True if the timeout ticket is still valid; otherwise false
"""
if (timeouts.containsKey(key)) {
Timeout<K> timeout = timeouts.get(key);
return timeout.getTicket().equals(ticket);
} else {
return false;
}
}
|
java
|
public boolean isValid(K key, UUID ticket) {
if (timeouts.containsKey(key)) {
Timeout<K> timeout = timeouts.get(key);
return timeout.getTicket().equals(ticket);
} else {
return false;
}
}
|
[
"public",
"boolean",
"isValid",
"(",
"K",
"key",
",",
"UUID",
"ticket",
")",
"{",
"if",
"(",
"timeouts",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"Timeout",
"<",
"K",
">",
"timeout",
"=",
"timeouts",
".",
"get",
"(",
"key",
")",
";",
"return",
"timeout",
".",
"getTicket",
"(",
")",
".",
"equals",
"(",
"ticket",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Check whether the timeout for the given key and ticket is still valid (not yet unregistered
and not yet overwritten).
@param key for which to check the timeout
@param ticket of the timeout
@return True if the timeout ticket is still valid; otherwise false
|
[
"Check",
"whether",
"the",
"timeout",
"for",
"the",
"given",
"key",
"and",
"ticket",
"is",
"still",
"valid",
"(",
"not",
"yet",
"unregistered",
"and",
"not",
"yet",
"overwritten",
")",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TimerService.java#L143-L151
|
moparisthebest/beehive
|
beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java
|
JdbcControlImpl.invoke
|
public Object invoke(Method method, Object[] args) throws Throwable {
"""
Called by the Controls runtime to handle calls to methods of an extensible control.
@param method The extended operation that was called.
@param args Parameters of the operation.
@return The value that should be returned by the operation.
@throws Throwable any exception declared on the extended operation may be
thrown. If a checked exception is thrown from the implementation that is not declared
on the original interface, it will be wrapped in a ControlException.
"""
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enter: invoke()");
}
assert _connection.isClosed() == false : "invoke(): JDBC Connection has been closed!!!!";
return execPreparedStatement(method, args);
}
|
java
|
public Object invoke(Method method, Object[] args) throws Throwable {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enter: invoke()");
}
assert _connection.isClosed() == false : "invoke(): JDBC Connection has been closed!!!!";
return execPreparedStatement(method, args);
}
|
[
"public",
"Object",
"invoke",
"(",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Enter: invoke()\"",
")",
";",
"}",
"assert",
"_connection",
".",
"isClosed",
"(",
")",
"==",
"false",
":",
"\"invoke(): JDBC Connection has been closed!!!!\"",
";",
"return",
"execPreparedStatement",
"(",
"method",
",",
"args",
")",
";",
"}"
] |
Called by the Controls runtime to handle calls to methods of an extensible control.
@param method The extended operation that was called.
@param args Parameters of the operation.
@return The value that should be returned by the operation.
@throws Throwable any exception declared on the extended operation may be
thrown. If a checked exception is thrown from the implementation that is not declared
on the original interface, it will be wrapped in a ControlException.
|
[
"Called",
"by",
"the",
"Controls",
"runtime",
"to",
"handle",
"calls",
"to",
"methods",
"of",
"an",
"extensible",
"control",
"."
] |
train
|
https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/JdbcControlImpl.java#L217-L224
|
blinkfox/zealot
|
src/main/java/com/blinkfox/zealot/core/ZealotKhala.java
|
ZealotKhala.andLessEqual
|
public ZealotKhala andLessEqual(String field, Object value) {
"""
生成带" AND "前缀小于等于查询的SQL片段.
@param field 数据库字段
@param value 值
@return ZealotKhala实例
"""
return this.doNormal(ZealotConst.AND_PREFIX, field, value, ZealotConst.LTE_SUFFIX, true);
}
|
java
|
public ZealotKhala andLessEqual(String field, Object value) {
return this.doNormal(ZealotConst.AND_PREFIX, field, value, ZealotConst.LTE_SUFFIX, true);
}
|
[
"public",
"ZealotKhala",
"andLessEqual",
"(",
"String",
"field",
",",
"Object",
"value",
")",
"{",
"return",
"this",
".",
"doNormal",
"(",
"ZealotConst",
".",
"AND_PREFIX",
",",
"field",
",",
"value",
",",
"ZealotConst",
".",
"LTE_SUFFIX",
",",
"true",
")",
";",
"}"
] |
生成带" AND "前缀小于等于查询的SQL片段.
@param field 数据库字段
@param value 值
@return ZealotKhala实例
|
[
"生成带",
"AND",
"前缀小于等于查询的SQL片段",
"."
] |
train
|
https://github.com/blinkfox/zealot/blob/21b00fa3e4ed42188eef3116d494e112e7a4194c/src/main/java/com/blinkfox/zealot/core/ZealotKhala.java#L858-L860
|
structurizr/java
|
structurizr-core/src/com/structurizr/documentation/Arc42DocumentationTemplate.java
|
Arc42DocumentationTemplate.addArchitecturalDecisionsSection
|
public Section addArchitecturalDecisionsSection(SoftwareSystem softwareSystem, File... files) throws IOException {
"""
Adds an "Architectural Decisions" section relating to a {@link SoftwareSystem} from one or more files.
@param softwareSystem the {@link SoftwareSystem} the documentation content relates to
@param files one or more File objects that point to the documentation content
@return a documentation {@link Section}
@throws IOException if there is an error reading the files
"""
return addSection(softwareSystem, "Architectural Decisions", files);
}
|
java
|
public Section addArchitecturalDecisionsSection(SoftwareSystem softwareSystem, File... files) throws IOException {
return addSection(softwareSystem, "Architectural Decisions", files);
}
|
[
"public",
"Section",
"addArchitecturalDecisionsSection",
"(",
"SoftwareSystem",
"softwareSystem",
",",
"File",
"...",
"files",
")",
"throws",
"IOException",
"{",
"return",
"addSection",
"(",
"softwareSystem",
",",
"\"Architectural Decisions\"",
",",
"files",
")",
";",
"}"
] |
Adds an "Architectural Decisions" section relating to a {@link SoftwareSystem} from one or more files.
@param softwareSystem the {@link SoftwareSystem} the documentation content relates to
@param files one or more File objects that point to the documentation content
@return a documentation {@link Section}
@throws IOException if there is an error reading the files
|
[
"Adds",
"an",
"Architectural",
"Decisions",
"section",
"relating",
"to",
"a",
"{",
"@link",
"SoftwareSystem",
"}",
"from",
"one",
"or",
"more",
"files",
"."
] |
train
|
https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/documentation/Arc42DocumentationTemplate.java#L241-L243
|
codeprimate-software/cp-elements
|
src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java
|
ElementsExceptionsFactory.newFormatException
|
public static FormatException newFormatException(Throwable cause, String message, Object... args) {
"""
Constructs and initializes a new {@link FormatException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link FormatException} was thrown.
@param message {@link String} describing the {@link FormatException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link FormatException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.text.FormatException
"""
return new FormatException(format(message, args), cause);
}
|
java
|
public static FormatException newFormatException(Throwable cause, String message, Object... args) {
return new FormatException(format(message, args), cause);
}
|
[
"public",
"static",
"FormatException",
"newFormatException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"FormatException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] |
Constructs and initializes a new {@link FormatException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link FormatException} was thrown.
@param message {@link String} describing the {@link FormatException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link FormatException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.text.FormatException
|
[
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"FormatException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] |
train
|
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L717-L719
|
biojava/biojava
|
biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java
|
WorkSheet.changeColumnsHeaders
|
public void changeColumnsHeaders(LinkedHashMap<String, String> newColumnValues) throws Exception {
"""
Change the columns in the HashMap Key to the name of the value
@param newColumnValues
@throws Exception
"""
for (String oldColumn : newColumnValues.keySet()) {
String newColumn = newColumnValues.get(oldColumn);
changeColumnHeader(oldColumn, newColumn);
}
}
|
java
|
public void changeColumnsHeaders(LinkedHashMap<String, String> newColumnValues) throws Exception {
for (String oldColumn : newColumnValues.keySet()) {
String newColumn = newColumnValues.get(oldColumn);
changeColumnHeader(oldColumn, newColumn);
}
}
|
[
"public",
"void",
"changeColumnsHeaders",
"(",
"LinkedHashMap",
"<",
"String",
",",
"String",
">",
"newColumnValues",
")",
"throws",
"Exception",
"{",
"for",
"(",
"String",
"oldColumn",
":",
"newColumnValues",
".",
"keySet",
"(",
")",
")",
"{",
"String",
"newColumn",
"=",
"newColumnValues",
".",
"get",
"(",
"oldColumn",
")",
";",
"changeColumnHeader",
"(",
"oldColumn",
",",
"newColumn",
")",
";",
"}",
"}"
] |
Change the columns in the HashMap Key to the name of the value
@param newColumnValues
@throws Exception
|
[
"Change",
"the",
"columns",
"in",
"the",
"HashMap",
"Key",
"to",
"the",
"name",
"of",
"the",
"value"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/data/WorkSheet.java#L960-L966
|
jblas-project/jblas
|
src/main/java/org/jblas/Solve.java
|
Solve.solvePositive
|
public static FloatMatrix solvePositive(FloatMatrix A, FloatMatrix B) {
"""
Solves the linear equation A*X = B for symmetric and positive definite A.
"""
A.assertSquare();
FloatMatrix X = B.dup();
SimpleBlas.posv('U', A.dup(), X);
return X;
}
|
java
|
public static FloatMatrix solvePositive(FloatMatrix A, FloatMatrix B) {
A.assertSquare();
FloatMatrix X = B.dup();
SimpleBlas.posv('U', A.dup(), X);
return X;
}
|
[
"public",
"static",
"FloatMatrix",
"solvePositive",
"(",
"FloatMatrix",
"A",
",",
"FloatMatrix",
"B",
")",
"{",
"A",
".",
"assertSquare",
"(",
")",
";",
"FloatMatrix",
"X",
"=",
"B",
".",
"dup",
"(",
")",
";",
"SimpleBlas",
".",
"posv",
"(",
"'",
"'",
",",
"A",
".",
"dup",
"(",
")",
",",
"X",
")",
";",
"return",
"X",
";",
"}"
] |
Solves the linear equation A*X = B for symmetric and positive definite A.
|
[
"Solves",
"the",
"linear",
"equation",
"A",
"*",
"X",
"=",
"B",
"for",
"symmetric",
"and",
"positive",
"definite",
"A",
"."
] |
train
|
https://github.com/jblas-project/jblas/blob/2818f231228e655cda80dfd8e0b87709fdfd8a70/src/main/java/org/jblas/Solve.java#L131-L136
|
google/j2objc
|
xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/SerializerBase.java
|
SerializerBase.setDoctype
|
public void setDoctype(String doctypeSystem, String doctypePublic) {
"""
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
@param doctypeSystem the system identifier to be used in the DOCTYPE
declaration in the output document.
@param doctypePublic the public identifier to be used in the DOCTYPE
declaration in the output document.
"""
setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
}
|
java
|
public void setDoctype(String doctypeSystem, String doctypePublic)
{
setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctypeSystem);
setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctypePublic);
}
|
[
"public",
"void",
"setDoctype",
"(",
"String",
"doctypeSystem",
",",
"String",
"doctypePublic",
")",
"{",
"setOutputProperty",
"(",
"OutputKeys",
".",
"DOCTYPE_SYSTEM",
",",
"doctypeSystem",
")",
";",
"setOutputProperty",
"(",
"OutputKeys",
".",
"DOCTYPE_PUBLIC",
",",
"doctypePublic",
")",
";",
"}"
] |
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
@param doctypeSystem the system identifier to be used in the DOCTYPE
declaration in the output document.
@param doctypePublic the public identifier to be used in the DOCTYPE
declaration in the output document.
|
[
"Set",
"the",
"value",
"coming",
"from",
"the",
"xsl",
":",
"output",
"doctype",
"-",
"public",
"and",
"doctype",
"-",
"system",
"stylesheet",
"properties"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/SerializerBase.java#L643-L647
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java
|
TrainingsImpl.getIterationPerformance
|
public IterationPerformance getIterationPerformance(UUID projectId, UUID iterationId, GetIterationPerformanceOptionalParameter getIterationPerformanceOptionalParameter) {
"""
Get detailed performance information about an iteration.
@param projectId The id of the project the iteration belongs to
@param iterationId The id of the iteration to get
@param getIterationPerformanceOptionalParameter the object representing the optional parameters to be set before calling this API
@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 IterationPerformance object if successful.
"""
return getIterationPerformanceWithServiceResponseAsync(projectId, iterationId, getIterationPerformanceOptionalParameter).toBlocking().single().body();
}
|
java
|
public IterationPerformance getIterationPerformance(UUID projectId, UUID iterationId, GetIterationPerformanceOptionalParameter getIterationPerformanceOptionalParameter) {
return getIterationPerformanceWithServiceResponseAsync(projectId, iterationId, getIterationPerformanceOptionalParameter).toBlocking().single().body();
}
|
[
"public",
"IterationPerformance",
"getIterationPerformance",
"(",
"UUID",
"projectId",
",",
"UUID",
"iterationId",
",",
"GetIterationPerformanceOptionalParameter",
"getIterationPerformanceOptionalParameter",
")",
"{",
"return",
"getIterationPerformanceWithServiceResponseAsync",
"(",
"projectId",
",",
"iterationId",
",",
"getIterationPerformanceOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Get detailed performance information about an iteration.
@param projectId The id of the project the iteration belongs to
@param iterationId The id of the iteration to get
@param getIterationPerformanceOptionalParameter the object representing the optional parameters to be set before calling this API
@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 IterationPerformance object if successful.
|
[
"Get",
"detailed",
"performance",
"information",
"about",
"an",
"iteration",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L1616-L1618
|
algolia/algoliasearch-client-java
|
src/main/java/com/algolia/search/saas/Index.java
|
Index.waitTask
|
public void waitTask(String taskID, long timeToWait) throws AlgoliaException {
"""
Wait the publication of a task on the server.
All server task are asynchronous and you can check with this method that the task is published.
@param taskID the id of the task returned by server
@param timeToWait time to sleep seed
"""
this.waitTask(taskID, timeToWait, RequestOptions.empty);
}
|
java
|
public void waitTask(String taskID, long timeToWait) throws AlgoliaException {
this.waitTask(taskID, timeToWait, RequestOptions.empty);
}
|
[
"public",
"void",
"waitTask",
"(",
"String",
"taskID",
",",
"long",
"timeToWait",
")",
"throws",
"AlgoliaException",
"{",
"this",
".",
"waitTask",
"(",
"taskID",
",",
"timeToWait",
",",
"RequestOptions",
".",
"empty",
")",
";",
"}"
] |
Wait the publication of a task on the server.
All server task are asynchronous and you can check with this method that the task is published.
@param taskID the id of the task returned by server
@param timeToWait time to sleep seed
|
[
"Wait",
"the",
"publication",
"of",
"a",
"task",
"on",
"the",
"server",
".",
"All",
"server",
"task",
"are",
"asynchronous",
"and",
"you",
"can",
"check",
"with",
"this",
"method",
"that",
"the",
"task",
"is",
"published",
"."
] |
train
|
https://github.com/algolia/algoliasearch-client-java/blob/a05da2f66c099fe6f77295c7b6a8a12c24e95f9b/src/main/java/com/algolia/search/saas/Index.java#L841-L843
|
kiegroup/drools
|
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
|
DRL5Parser.nestedConstraint
|
private void nestedConstraint( PatternDescrBuilder< ? > pattern, String prefix ) throws RecognitionException {
"""
nestedConstraint := ( ID ( DOT | HASH ) )* ID DOT LEFT_PAREN constraints RIGHT_PAREN
@param pattern
@throws RecognitionException
"""
int prefixLenght = getNestedConstraintPrefixLenght();
int prefixStart = input.index();
prefix += input.toString( prefixStart, prefixStart + prefixLenght - 2 );
for (int i = 0; i < prefixLenght; i++) {
input.consume();
}
constraints( pattern, prefix );
match( input,
DRL5Lexer.RIGHT_PAREN,
null,
null,
DroolsEditorType.SYMBOL );
}
|
java
|
private void nestedConstraint( PatternDescrBuilder< ? > pattern, String prefix ) throws RecognitionException {
int prefixLenght = getNestedConstraintPrefixLenght();
int prefixStart = input.index();
prefix += input.toString( prefixStart, prefixStart + prefixLenght - 2 );
for (int i = 0; i < prefixLenght; i++) {
input.consume();
}
constraints( pattern, prefix );
match( input,
DRL5Lexer.RIGHT_PAREN,
null,
null,
DroolsEditorType.SYMBOL );
}
|
[
"private",
"void",
"nestedConstraint",
"(",
"PatternDescrBuilder",
"<",
"?",
">",
"pattern",
",",
"String",
"prefix",
")",
"throws",
"RecognitionException",
"{",
"int",
"prefixLenght",
"=",
"getNestedConstraintPrefixLenght",
"(",
")",
";",
"int",
"prefixStart",
"=",
"input",
".",
"index",
"(",
")",
";",
"prefix",
"+=",
"input",
".",
"toString",
"(",
"prefixStart",
",",
"prefixStart",
"+",
"prefixLenght",
"-",
"2",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"prefixLenght",
";",
"i",
"++",
")",
"{",
"input",
".",
"consume",
"(",
")",
";",
"}",
"constraints",
"(",
"pattern",
",",
"prefix",
")",
";",
"match",
"(",
"input",
",",
"DRL5Lexer",
".",
"RIGHT_PAREN",
",",
"null",
",",
"null",
",",
"DroolsEditorType",
".",
"SYMBOL",
")",
";",
"}"
] |
nestedConstraint := ( ID ( DOT | HASH ) )* ID DOT LEFT_PAREN constraints RIGHT_PAREN
@param pattern
@throws RecognitionException
|
[
"nestedConstraint",
":",
"=",
"(",
"ID",
"(",
"DOT",
"|",
"HASH",
")",
")",
"*",
"ID",
"DOT",
"LEFT_PAREN",
"constraints",
"RIGHT_PAREN"
] |
train
|
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L3294-L3309
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/message/record/BaseRecordMessageFilter.java
|
BaseRecordMessageFilter.linkRemoteSession
|
public BaseMessageFilter linkRemoteSession(Object remoteSession) {
"""
Link this filter to this remote session.
This is ONLY used in the server (remote) version of a filter.
Override this to finish setting up the filter (such as behavior to adjust this filter).
In this case, the source cannot be passed to the remote session because it is the
record, so the record must be re-linked to this (remote) session.
"""
if (remoteSession instanceof RemoteSession)
if (remoteSession instanceof RecordOwner) // Always
if (m_source == null)
{
String strTableName = (String)this.getProperties().get(TABLE_NAME);
Record record = (Record)((RecordOwner)remoteSession).getRecord(strTableName);
if (record != null)
{
record.addListener(new SyncRecordMessageFilterHandler(this, true));
m_source = record;
}
}
return super.linkRemoteSession(remoteSession);
}
|
java
|
public BaseMessageFilter linkRemoteSession(Object remoteSession)
{
if (remoteSession instanceof RemoteSession)
if (remoteSession instanceof RecordOwner) // Always
if (m_source == null)
{
String strTableName = (String)this.getProperties().get(TABLE_NAME);
Record record = (Record)((RecordOwner)remoteSession).getRecord(strTableName);
if (record != null)
{
record.addListener(new SyncRecordMessageFilterHandler(this, true));
m_source = record;
}
}
return super.linkRemoteSession(remoteSession);
}
|
[
"public",
"BaseMessageFilter",
"linkRemoteSession",
"(",
"Object",
"remoteSession",
")",
"{",
"if",
"(",
"remoteSession",
"instanceof",
"RemoteSession",
")",
"if",
"(",
"remoteSession",
"instanceof",
"RecordOwner",
")",
"// Always",
"if",
"(",
"m_source",
"==",
"null",
")",
"{",
"String",
"strTableName",
"=",
"(",
"String",
")",
"this",
".",
"getProperties",
"(",
")",
".",
"get",
"(",
"TABLE_NAME",
")",
";",
"Record",
"record",
"=",
"(",
"Record",
")",
"(",
"(",
"RecordOwner",
")",
"remoteSession",
")",
".",
"getRecord",
"(",
"strTableName",
")",
";",
"if",
"(",
"record",
"!=",
"null",
")",
"{",
"record",
".",
"addListener",
"(",
"new",
"SyncRecordMessageFilterHandler",
"(",
"this",
",",
"true",
")",
")",
";",
"m_source",
"=",
"record",
";",
"}",
"}",
"return",
"super",
".",
"linkRemoteSession",
"(",
"remoteSession",
")",
";",
"}"
] |
Link this filter to this remote session.
This is ONLY used in the server (remote) version of a filter.
Override this to finish setting up the filter (such as behavior to adjust this filter).
In this case, the source cannot be passed to the remote session because it is the
record, so the record must be re-linked to this (remote) session.
|
[
"Link",
"this",
"filter",
"to",
"this",
"remote",
"session",
".",
"This",
"is",
"ONLY",
"used",
"in",
"the",
"server",
"(",
"remote",
")",
"version",
"of",
"a",
"filter",
".",
"Override",
"this",
"to",
"finish",
"setting",
"up",
"the",
"filter",
"(",
"such",
"as",
"behavior",
"to",
"adjust",
"this",
"filter",
")",
".",
"In",
"this",
"case",
"the",
"source",
"cannot",
"be",
"passed",
"to",
"the",
"remote",
"session",
"because",
"it",
"is",
"the",
"record",
"so",
"the",
"record",
"must",
"be",
"re",
"-",
"linked",
"to",
"this",
"(",
"remote",
")",
"session",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/message/record/BaseRecordMessageFilter.java#L177-L192
|
apache/reef
|
lang/java/reef-experimental/src/main/java/org/apache/reef/experimental/parquet/ParquetReader.java
|
ParquetReader.createAvroSchema
|
private Schema createAvroSchema(final Configuration configuration, final MetadataFilter filter) throws IOException {
"""
Retrieve avro schema from parquet file.
@param configuration Hadoop configuration.
@param filter Filter for Avro metadata.
@return avro schema from parquet file.
@throws IOException if the Avro schema couldn't be parsed from the parquet file.
"""
final ParquetMetadata footer = ParquetFileReader.readFooter(configuration, parquetFilePath, filter);
final AvroSchemaConverter converter = new AvroSchemaConverter();
final MessageType schema = footer.getFileMetaData().getSchema();
return converter.convert(schema);
}
|
java
|
private Schema createAvroSchema(final Configuration configuration, final MetadataFilter filter) throws IOException {
final ParquetMetadata footer = ParquetFileReader.readFooter(configuration, parquetFilePath, filter);
final AvroSchemaConverter converter = new AvroSchemaConverter();
final MessageType schema = footer.getFileMetaData().getSchema();
return converter.convert(schema);
}
|
[
"private",
"Schema",
"createAvroSchema",
"(",
"final",
"Configuration",
"configuration",
",",
"final",
"MetadataFilter",
"filter",
")",
"throws",
"IOException",
"{",
"final",
"ParquetMetadata",
"footer",
"=",
"ParquetFileReader",
".",
"readFooter",
"(",
"configuration",
",",
"parquetFilePath",
",",
"filter",
")",
";",
"final",
"AvroSchemaConverter",
"converter",
"=",
"new",
"AvroSchemaConverter",
"(",
")",
";",
"final",
"MessageType",
"schema",
"=",
"footer",
".",
"getFileMetaData",
"(",
")",
".",
"getSchema",
"(",
")",
";",
"return",
"converter",
".",
"convert",
"(",
"schema",
")",
";",
"}"
] |
Retrieve avro schema from parquet file.
@param configuration Hadoop configuration.
@param filter Filter for Avro metadata.
@return avro schema from parquet file.
@throws IOException if the Avro schema couldn't be parsed from the parquet file.
|
[
"Retrieve",
"avro",
"schema",
"from",
"parquet",
"file",
"."
] |
train
|
https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-experimental/src/main/java/org/apache/reef/experimental/parquet/ParquetReader.java#L95-L100
|
apache/reef
|
lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java
|
AggregateContainer.taskletComplete
|
public void taskletComplete(final int taskletId, final Object result) {
"""
Reported when an associated tasklet is complete and adds it to the completion pool.
"""
final boolean aggregateOnCount;
synchronized (stateLock) {
completedTasklets.add(new ImmutablePair<>(taskletId, result));
removePendingTaskletReferenceCount(taskletId);
aggregateOnCount = aggregateOnCount();
}
if (aggregateOnCount) {
aggregateTasklets(AggregateTriggerType.COUNT);
}
}
|
java
|
public void taskletComplete(final int taskletId, final Object result) {
final boolean aggregateOnCount;
synchronized (stateLock) {
completedTasklets.add(new ImmutablePair<>(taskletId, result));
removePendingTaskletReferenceCount(taskletId);
aggregateOnCount = aggregateOnCount();
}
if (aggregateOnCount) {
aggregateTasklets(AggregateTriggerType.COUNT);
}
}
|
[
"public",
"void",
"taskletComplete",
"(",
"final",
"int",
"taskletId",
",",
"final",
"Object",
"result",
")",
"{",
"final",
"boolean",
"aggregateOnCount",
";",
"synchronized",
"(",
"stateLock",
")",
"{",
"completedTasklets",
".",
"add",
"(",
"new",
"ImmutablePair",
"<>",
"(",
"taskletId",
",",
"result",
")",
")",
";",
"removePendingTaskletReferenceCount",
"(",
"taskletId",
")",
";",
"aggregateOnCount",
"=",
"aggregateOnCount",
"(",
")",
";",
"}",
"if",
"(",
"aggregateOnCount",
")",
"{",
"aggregateTasklets",
"(",
"AggregateTriggerType",
".",
"COUNT",
")",
";",
"}",
"}"
] |
Reported when an associated tasklet is complete and adds it to the completion pool.
|
[
"Reported",
"when",
"an",
"associated",
"tasklet",
"is",
"complete",
"and",
"adds",
"it",
"to",
"the",
"completion",
"pool",
"."
] |
train
|
https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java#L185-L196
|
pmwmedia/tinylog
|
tinylog-api/src/main/java/org/tinylog/runtime/RuntimeProvider.java
|
RuntimeProvider.createTimestampFormatter
|
public static TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale) {
"""
Creates a formatter for {@link Timestamp Timestamps}.
@param pattern
Format pattern that is compatible with {@link DateTimeFormatter}
@param locale
Locale for formatting
@return Formatter for formatting timestamps
"""
return dialect.createTimestampFormatter(pattern, locale);
}
|
java
|
public static TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale) {
return dialect.createTimestampFormatter(pattern, locale);
}
|
[
"public",
"static",
"TimestampFormatter",
"createTimestampFormatter",
"(",
"final",
"String",
"pattern",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"dialect",
".",
"createTimestampFormatter",
"(",
"pattern",
",",
"locale",
")",
";",
"}"
] |
Creates a formatter for {@link Timestamp Timestamps}.
@param pattern
Format pattern that is compatible with {@link DateTimeFormatter}
@param locale
Locale for formatting
@return Formatter for formatting timestamps
|
[
"Creates",
"a",
"formatter",
"for",
"{",
"@link",
"Timestamp",
"Timestamps",
"}",
"."
] |
train
|
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/runtime/RuntimeProvider.java#L114-L116
|
Azure/azure-sdk-for-java
|
automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ConnectionTypesInner.java
|
ConnectionTypesInner.createOrUpdate
|
public ConnectionTypeInner createOrUpdate(String resourceGroupName, String automationAccountName, String connectionTypeName, ConnectionTypeCreateOrUpdateParameters parameters) {
"""
Create a connectiontype.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param connectionTypeName The parameters supplied to the create or update connectiontype operation.
@param parameters The parameters supplied to the create or update connectiontype operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ConnectionTypeInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionTypeName, parameters).toBlocking().single().body();
}
|
java
|
public ConnectionTypeInner createOrUpdate(String resourceGroupName, String automationAccountName, String connectionTypeName, ConnectionTypeCreateOrUpdateParameters parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, automationAccountName, connectionTypeName, parameters).toBlocking().single().body();
}
|
[
"public",
"ConnectionTypeInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"String",
"connectionTypeName",
",",
"ConnectionTypeCreateOrUpdateParameters",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"connectionTypeName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Create a connectiontype.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param connectionTypeName The parameters supplied to the create or update connectiontype operation.
@param parameters The parameters supplied to the create or update connectiontype operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ConnectionTypeInner object if successful.
|
[
"Create",
"a",
"connectiontype",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/ConnectionTypesInner.java#L281-L283
|
loldevs/riotapi
|
rtmp/src/main/java/net/boreeas/riotapi/rtmp/RtmpClient.java
|
RtmpClient.sendRpc
|
@Deprecated
public int sendRpc(String service, String method, Object... args) {
"""
<p>
Send a remote procedure call.
</p>
<p>
Note that due to varargs ambiguity, this method will not work if the first argument to the call is a string.
In that case, use the explicit {@link #sendRpcWithEndpoint(String, String, String, Object...)} with endpoint
"my-rtmps" instead, or use {@link #sendRpcToDefault(String, String, Object...)}
</p>
@param service The service handling the call
@param method The method to call
@param args Optional arguments to the call
@return The invoke id callback
@deprecated Use the explicit {@link #sendRpcToDefault(String, String, Object...)} instead
"""
return sendRpc("my-rtmps", service, method, args);
}
|
java
|
@Deprecated
public int sendRpc(String service, String method, Object... args) {
return sendRpc("my-rtmps", service, method, args);
}
|
[
"@",
"Deprecated",
"public",
"int",
"sendRpc",
"(",
"String",
"service",
",",
"String",
"method",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"sendRpc",
"(",
"\"my-rtmps\"",
",",
"service",
",",
"method",
",",
"args",
")",
";",
"}"
] |
<p>
Send a remote procedure call.
</p>
<p>
Note that due to varargs ambiguity, this method will not work if the first argument to the call is a string.
In that case, use the explicit {@link #sendRpcWithEndpoint(String, String, String, Object...)} with endpoint
"my-rtmps" instead, or use {@link #sendRpcToDefault(String, String, Object...)}
</p>
@param service The service handling the call
@param method The method to call
@param args Optional arguments to the call
@return The invoke id callback
@deprecated Use the explicit {@link #sendRpcToDefault(String, String, Object...)} instead
|
[
"<p",
">",
"Send",
"a",
"remote",
"procedure",
"call",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Note",
"that",
"due",
"to",
"varargs",
"ambiguity",
"this",
"method",
"will",
"not",
"work",
"if",
"the",
"first",
"argument",
"to",
"the",
"call",
"is",
"a",
"string",
".",
"In",
"that",
"case",
"use",
"the",
"explicit",
"{"
] |
train
|
https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rtmp/src/main/java/net/boreeas/riotapi/rtmp/RtmpClient.java#L584-L587
|
heroku/heroku.jar
|
heroku-api/src/main/java/com/heroku/api/HerokuAPI.java
|
HerokuAPI.removeCollaborator
|
public void removeCollaborator(String appName, String collaborator) {
"""
Remove a collaborator from an app.
@param appName App name. See {@link #listApps} for a list of apps that can be used.
@param collaborator See {@link #listCollaborators} for collaborators that can be removed from the app.
"""
connection.execute(new SharingRemove(appName, collaborator), apiKey);
}
|
java
|
public void removeCollaborator(String appName, String collaborator) {
connection.execute(new SharingRemove(appName, collaborator), apiKey);
}
|
[
"public",
"void",
"removeCollaborator",
"(",
"String",
"appName",
",",
"String",
"collaborator",
")",
"{",
"connection",
".",
"execute",
"(",
"new",
"SharingRemove",
"(",
"appName",
",",
"collaborator",
")",
",",
"apiKey",
")",
";",
"}"
] |
Remove a collaborator from an app.
@param appName App name. See {@link #listApps} for a list of apps that can be used.
@param collaborator See {@link #listCollaborators} for collaborators that can be removed from the app.
|
[
"Remove",
"a",
"collaborator",
"from",
"an",
"app",
"."
] |
train
|
https://github.com/heroku/heroku.jar/blob/d9e52991293159498c10c498c6f91fcdd637378e/heroku-api/src/main/java/com/heroku/api/HerokuAPI.java#L320-L322
|
qspin/qtaste
|
plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/StructureAnalyzer.java
|
StructureAnalyzer.executeCommand
|
@Override
Object executeCommand(int timeout, String componentName, Object... data) throws QTasteException {
"""
Analyze the structure of a java application and save it in the specified filename in the current working directory.
@return null
"""
try {
prepareWriter(data[0].toString());
for (Window window : getDisplayableWindows()) {
analyzeComponent(window, 1);
}
mWriter.write("</root>");
mWriter.flush();
mWriter.close();
} catch (IOException e) {
throw new QTasteTestFailException("Error saving to file" + data[0].toString() + ":", e);
}
return null;
}
|
java
|
@Override
Object executeCommand(int timeout, String componentName, Object... data) throws QTasteException {
try {
prepareWriter(data[0].toString());
for (Window window : getDisplayableWindows()) {
analyzeComponent(window, 1);
}
mWriter.write("</root>");
mWriter.flush();
mWriter.close();
} catch (IOException e) {
throw new QTasteTestFailException("Error saving to file" + data[0].toString() + ":", e);
}
return null;
}
|
[
"@",
"Override",
"Object",
"executeCommand",
"(",
"int",
"timeout",
",",
"String",
"componentName",
",",
"Object",
"...",
"data",
")",
"throws",
"QTasteException",
"{",
"try",
"{",
"prepareWriter",
"(",
"data",
"[",
"0",
"]",
".",
"toString",
"(",
")",
")",
";",
"for",
"(",
"Window",
"window",
":",
"getDisplayableWindows",
"(",
")",
")",
"{",
"analyzeComponent",
"(",
"window",
",",
"1",
")",
";",
"}",
"mWriter",
".",
"write",
"(",
"\"</root>\"",
")",
";",
"mWriter",
".",
"flush",
"(",
")",
";",
"mWriter",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"QTasteTestFailException",
"(",
"\"Error saving to file\"",
"+",
"data",
"[",
"0",
"]",
".",
"toString",
"(",
")",
"+",
"\":\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Analyze the structure of a java application and save it in the specified filename in the current working directory.
@return null
|
[
"Analyze",
"the",
"structure",
"of",
"a",
"java",
"application",
"and",
"save",
"it",
"in",
"the",
"specified",
"filename",
"in",
"the",
"current",
"working",
"directory",
"."
] |
train
|
https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/StructureAnalyzer.java#L46-L61
|
apache/incubator-gobblin
|
gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/orc/HiveOrcSerDeManager.java
|
HiveOrcSerDeManager.addSchemaPropertiesHelper
|
protected void addSchemaPropertiesHelper(Path path, HiveRegistrationUnit hiveUnit) throws IOException {
"""
Extensible if there's other source-of-truth for fetching schema instead of interacting with HDFS.
For purpose of initializing {@link org.apache.hadoop.hive.ql.io.orc.OrcSerde} object, it will require:
org.apache.hadoop.hive.serde.serdeConstants#LIST_COLUMNS and
org.apache.hadoop.hive.serde.serdeConstants#LIST_COLUMN_TYPES
Keeping {@link #SCHEMA_LITERAL} will be a nice-to-have thing but not actually necessary in terms of functionality.
"""
TypeInfo schema = getSchemaFromLatestFile(path, this.fs);
if (schema instanceof StructTypeInfo) {
StructTypeInfo structTypeInfo = (StructTypeInfo) schema;
hiveUnit.setSerDeProp(SCHEMA_LITERAL, schema);
hiveUnit.setSerDeProp(serdeConstants.LIST_COLUMNS,
Joiner.on(",").join(structTypeInfo.getAllStructFieldNames()));
hiveUnit.setSerDeProp(serdeConstants.LIST_COLUMN_TYPES,
Joiner.on(",").join(
structTypeInfo.getAllStructFieldTypeInfos().stream().map(x -> x.getTypeName())
.collect(Collectors.toList())));
} else {
// Hive always uses a struct with a field for each of the top-level columns as the root object type.
// So for here we assume to-be-registered ORC files follow this pattern.
throw new IllegalStateException("A valid ORC schema should be an instance of struct");
}
}
|
java
|
protected void addSchemaPropertiesHelper(Path path, HiveRegistrationUnit hiveUnit) throws IOException {
TypeInfo schema = getSchemaFromLatestFile(path, this.fs);
if (schema instanceof StructTypeInfo) {
StructTypeInfo structTypeInfo = (StructTypeInfo) schema;
hiveUnit.setSerDeProp(SCHEMA_LITERAL, schema);
hiveUnit.setSerDeProp(serdeConstants.LIST_COLUMNS,
Joiner.on(",").join(structTypeInfo.getAllStructFieldNames()));
hiveUnit.setSerDeProp(serdeConstants.LIST_COLUMN_TYPES,
Joiner.on(",").join(
structTypeInfo.getAllStructFieldTypeInfos().stream().map(x -> x.getTypeName())
.collect(Collectors.toList())));
} else {
// Hive always uses a struct with a field for each of the top-level columns as the root object type.
// So for here we assume to-be-registered ORC files follow this pattern.
throw new IllegalStateException("A valid ORC schema should be an instance of struct");
}
}
|
[
"protected",
"void",
"addSchemaPropertiesHelper",
"(",
"Path",
"path",
",",
"HiveRegistrationUnit",
"hiveUnit",
")",
"throws",
"IOException",
"{",
"TypeInfo",
"schema",
"=",
"getSchemaFromLatestFile",
"(",
"path",
",",
"this",
".",
"fs",
")",
";",
"if",
"(",
"schema",
"instanceof",
"StructTypeInfo",
")",
"{",
"StructTypeInfo",
"structTypeInfo",
"=",
"(",
"StructTypeInfo",
")",
"schema",
";",
"hiveUnit",
".",
"setSerDeProp",
"(",
"SCHEMA_LITERAL",
",",
"schema",
")",
";",
"hiveUnit",
".",
"setSerDeProp",
"(",
"serdeConstants",
".",
"LIST_COLUMNS",
",",
"Joiner",
".",
"on",
"(",
"\",\"",
")",
".",
"join",
"(",
"structTypeInfo",
".",
"getAllStructFieldNames",
"(",
")",
")",
")",
";",
"hiveUnit",
".",
"setSerDeProp",
"(",
"serdeConstants",
".",
"LIST_COLUMN_TYPES",
",",
"Joiner",
".",
"on",
"(",
"\",\"",
")",
".",
"join",
"(",
"structTypeInfo",
".",
"getAllStructFieldTypeInfos",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"x",
"->",
"x",
".",
"getTypeName",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"// Hive always uses a struct with a field for each of the top-level columns as the root object type.",
"// So for here we assume to-be-registered ORC files follow this pattern.",
"throw",
"new",
"IllegalStateException",
"(",
"\"A valid ORC schema should be an instance of struct\"",
")",
";",
"}",
"}"
] |
Extensible if there's other source-of-truth for fetching schema instead of interacting with HDFS.
For purpose of initializing {@link org.apache.hadoop.hive.ql.io.orc.OrcSerde} object, it will require:
org.apache.hadoop.hive.serde.serdeConstants#LIST_COLUMNS and
org.apache.hadoop.hive.serde.serdeConstants#LIST_COLUMN_TYPES
Keeping {@link #SCHEMA_LITERAL} will be a nice-to-have thing but not actually necessary in terms of functionality.
|
[
"Extensible",
"if",
"there",
"s",
"other",
"source",
"-",
"of",
"-",
"truth",
"for",
"fetching",
"schema",
"instead",
"of",
"interacting",
"with",
"HDFS",
"."
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/orc/HiveOrcSerDeManager.java#L257-L274
|
bbottema/simple-java-mail
|
modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java
|
EmailConverter.emlToMimeMessage
|
public static MimeMessage emlToMimeMessage(@Nonnull final String eml, @Nonnull final Session session) {
"""
Relies on JavaMail's native parser of EML data, {@link MimeMessage#MimeMessage(Session, InputStream)}.
"""
checkNonEmptyArgument(session, "session");
checkNonEmptyArgument(eml, "eml");
try {
return new MimeMessage(session, new ByteArrayInputStream(eml.getBytes(UTF_8)));
} catch (final MessagingException e) {
throw new EmailConverterException(format(EmailConverterException.PARSE_ERROR_EML, e.getMessage()), e);
}
}
|
java
|
public static MimeMessage emlToMimeMessage(@Nonnull final String eml, @Nonnull final Session session) {
checkNonEmptyArgument(session, "session");
checkNonEmptyArgument(eml, "eml");
try {
return new MimeMessage(session, new ByteArrayInputStream(eml.getBytes(UTF_8)));
} catch (final MessagingException e) {
throw new EmailConverterException(format(EmailConverterException.PARSE_ERROR_EML, e.getMessage()), e);
}
}
|
[
"public",
"static",
"MimeMessage",
"emlToMimeMessage",
"(",
"@",
"Nonnull",
"final",
"String",
"eml",
",",
"@",
"Nonnull",
"final",
"Session",
"session",
")",
"{",
"checkNonEmptyArgument",
"(",
"session",
",",
"\"session\"",
")",
";",
"checkNonEmptyArgument",
"(",
"eml",
",",
"\"eml\"",
")",
";",
"try",
"{",
"return",
"new",
"MimeMessage",
"(",
"session",
",",
"new",
"ByteArrayInputStream",
"(",
"eml",
".",
"getBytes",
"(",
"UTF_8",
")",
")",
")",
";",
"}",
"catch",
"(",
"final",
"MessagingException",
"e",
")",
"{",
"throw",
"new",
"EmailConverterException",
"(",
"format",
"(",
"EmailConverterException",
".",
"PARSE_ERROR_EML",
",",
"e",
".",
"getMessage",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Relies on JavaMail's native parser of EML data, {@link MimeMessage#MimeMessage(Session, InputStream)}.
|
[
"Relies",
"on",
"JavaMail",
"s",
"native",
"parser",
"of",
"EML",
"data",
"{"
] |
train
|
https://github.com/bbottema/simple-java-mail/blob/b03635328aeecd525e35eddfef8f5b9a184559d8/modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java#L241-L249
|
Mozu/mozu-java
|
mozu-java-core/src/main/java/com/mozu/api/urls/content/documentlists/DocumentUrl.java
|
DocumentUrl.getDocumentUrl
|
public static MozuUrl getDocumentUrl(String documentId, String documentListName, Boolean includeInactive, String responseFields) {
"""
Get Resource Url for GetDocument
@param documentId Unique identifier for a document, used by content and document calls. Document IDs are associated with document types, document type lists, sites, and tenants.
@param documentListName Name of content documentListName to delete
@param includeInactive Include inactive content.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/content/documentlists/{documentListName}/documents/{documentId}?includeInactive={includeInactive}&responseFields={responseFields}");
formatter.formatUrl("documentId", documentId);
formatter.formatUrl("documentListName", documentListName);
formatter.formatUrl("includeInactive", includeInactive);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
java
|
public static MozuUrl getDocumentUrl(String documentId, String documentListName, Boolean includeInactive, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/content/documentlists/{documentListName}/documents/{documentId}?includeInactive={includeInactive}&responseFields={responseFields}");
formatter.formatUrl("documentId", documentId);
formatter.formatUrl("documentListName", documentListName);
formatter.formatUrl("includeInactive", includeInactive);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"getDocumentUrl",
"(",
"String",
"documentId",
",",
"String",
"documentListName",
",",
"Boolean",
"includeInactive",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/content/documentlists/{documentListName}/documents/{documentId}?includeInactive={includeInactive}&responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"documentId\"",
",",
"documentId",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"documentListName\"",
",",
"documentListName",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"includeInactive\"",
",",
"includeInactive",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] |
Get Resource Url for GetDocument
@param documentId Unique identifier for a document, used by content and document calls. Document IDs are associated with document types, document type lists, sites, and tenants.
@param documentListName Name of content documentListName to delete
@param includeInactive Include inactive content.
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
|
[
"Get",
"Resource",
"Url",
"for",
"GetDocument"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/content/documentlists/DocumentUrl.java#L66-L74
|
udoprog/ffwd-client-java
|
src/main/java/com/google/protobuf250/DynamicMessage.java
|
DynamicMessage.parseFrom
|
public static DynamicMessage parseFrom(Descriptor type, InputStream input)
throws IOException {
"""
Parse a message of the given type from {@code input} and return it.
"""
return newBuilder(type).mergeFrom(input).buildParsed();
}
|
java
|
public static DynamicMessage parseFrom(Descriptor type, InputStream input)
throws IOException {
return newBuilder(type).mergeFrom(input).buildParsed();
}
|
[
"public",
"static",
"DynamicMessage",
"parseFrom",
"(",
"Descriptor",
"type",
",",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"return",
"newBuilder",
"(",
"type",
")",
".",
"mergeFrom",
"(",
"input",
")",
".",
"buildParsed",
"(",
")",
";",
"}"
] |
Parse a message of the given type from {@code input} and return it.
|
[
"Parse",
"a",
"message",
"of",
"the",
"given",
"type",
"from",
"{"
] |
train
|
https://github.com/udoprog/ffwd-client-java/blob/b4161d2b138e3edb8fa9420cc3cc653d5764cf5b/src/main/java/com/google/protobuf250/DynamicMessage.java#L115-L118
|
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/ExtendedRelationsDao.java
|
ExtendedRelationsDao.getBaseTableRelations
|
public List<ExtendedRelation> getBaseTableRelations(String baseTable)
throws SQLException {
"""
Get the relations to the base table
@param baseTable
base table
@return extended relations
@throws SQLException
upon failure
"""
return queryForEq(ExtendedRelation.COLUMN_BASE_TABLE_NAME, baseTable);
}
|
java
|
public List<ExtendedRelation> getBaseTableRelations(String baseTable)
throws SQLException {
return queryForEq(ExtendedRelation.COLUMN_BASE_TABLE_NAME, baseTable);
}
|
[
"public",
"List",
"<",
"ExtendedRelation",
">",
"getBaseTableRelations",
"(",
"String",
"baseTable",
")",
"throws",
"SQLException",
"{",
"return",
"queryForEq",
"(",
"ExtendedRelation",
".",
"COLUMN_BASE_TABLE_NAME",
",",
"baseTable",
")",
";",
"}"
] |
Get the relations to the base table
@param baseTable
base table
@return extended relations
@throws SQLException
upon failure
|
[
"Get",
"the",
"relations",
"to",
"the",
"base",
"table"
] |
train
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/ExtendedRelationsDao.java#L83-L86
|
kaazing/gateway
|
mina.core/core/src/main/java/org/apache/mina/filter/util/SessionAttributeInitializingFilter.java
|
SessionAttributeInitializingFilter.sessionCreated
|
@Override
public void sessionCreated(NextFilter nextFilter, IoSession session)
throws Exception {
"""
Puts all pre-configured attributes into the actual session attribute
map and forward the event to the next filter.
"""
for (Map.Entry<String, Object> e : attributes.entrySet()) {
session.setAttribute(e.getKey(), e.getValue());
}
nextFilter.sessionCreated(session);
}
|
java
|
@Override
public void sessionCreated(NextFilter nextFilter, IoSession session)
throws Exception {
for (Map.Entry<String, Object> e : attributes.entrySet()) {
session.setAttribute(e.getKey(), e.getValue());
}
nextFilter.sessionCreated(session);
}
|
[
"@",
"Override",
"public",
"void",
"sessionCreated",
"(",
"NextFilter",
"nextFilter",
",",
"IoSession",
"session",
")",
"throws",
"Exception",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"e",
":",
"attributes",
".",
"entrySet",
"(",
")",
")",
"{",
"session",
".",
"setAttribute",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
")",
";",
"}",
"nextFilter",
".",
"sessionCreated",
"(",
"session",
")",
";",
"}"
] |
Puts all pre-configured attributes into the actual session attribute
map and forward the event to the next filter.
|
[
"Puts",
"all",
"pre",
"-",
"configured",
"attributes",
"into",
"the",
"actual",
"session",
"attribute",
"map",
"and",
"forward",
"the",
"event",
"to",
"the",
"next",
"filter",
"."
] |
train
|
https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/filter/util/SessionAttributeInitializingFilter.java#L138-L146
|
couchbase/couchbase-jvm-core
|
src/main/java/com/couchbase/client/core/message/query/GenericQueryRequest.java
|
GenericQueryRequest.jsonQuery
|
public static GenericQueryRequest jsonQuery(String jsonQuery, String bucket, String username, String password, String contextId, String statement) {
"""
Create a {@link GenericQueryRequest} and mark it as containing a full N1QL query in Json form
(including additional query parameters like named arguments, etc...).
The simplest form of such a query is a single statement encapsulated in a json query object:
<pre>{"statement":"SELECT * FROM default"}</pre>.
@param jsonQuery the N1QL query in json form.
@param bucket the bucket on which to perform the query.
@param username the user authorized for bucket access.
@param password the password for the user.
@param contextId the context id to store and use for tracing purposes.
@return a {@link GenericQueryRequest} for this full query.
"""
return new GenericQueryRequest(jsonQuery, true, bucket, username, password, null,
contextId, statement);
}
|
java
|
public static GenericQueryRequest jsonQuery(String jsonQuery, String bucket, String username, String password, String contextId, String statement) {
return new GenericQueryRequest(jsonQuery, true, bucket, username, password, null,
contextId, statement);
}
|
[
"public",
"static",
"GenericQueryRequest",
"jsonQuery",
"(",
"String",
"jsonQuery",
",",
"String",
"bucket",
",",
"String",
"username",
",",
"String",
"password",
",",
"String",
"contextId",
",",
"String",
"statement",
")",
"{",
"return",
"new",
"GenericQueryRequest",
"(",
"jsonQuery",
",",
"true",
",",
"bucket",
",",
"username",
",",
"password",
",",
"null",
",",
"contextId",
",",
"statement",
")",
";",
"}"
] |
Create a {@link GenericQueryRequest} and mark it as containing a full N1QL query in Json form
(including additional query parameters like named arguments, etc...).
The simplest form of such a query is a single statement encapsulated in a json query object:
<pre>{"statement":"SELECT * FROM default"}</pre>.
@param jsonQuery the N1QL query in json form.
@param bucket the bucket on which to perform the query.
@param username the user authorized for bucket access.
@param password the password for the user.
@param contextId the context id to store and use for tracing purposes.
@return a {@link GenericQueryRequest} for this full query.
|
[
"Create",
"a",
"{",
"@link",
"GenericQueryRequest",
"}",
"and",
"mark",
"it",
"as",
"containing",
"a",
"full",
"N1QL",
"query",
"in",
"Json",
"form",
"(",
"including",
"additional",
"query",
"parameters",
"like",
"named",
"arguments",
"etc",
"...",
")",
"."
] |
train
|
https://github.com/couchbase/couchbase-jvm-core/blob/97f0427112c2168fee1d6499904f5fa0e24c6797/src/main/java/com/couchbase/client/core/message/query/GenericQueryRequest.java#L143-L146
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractDefinitionComparator.java
|
AbstractDefinitionComparator.isResidualMatch
|
protected boolean isResidualMatch(InternalQName itemName, T[] recipientDefinition) {
"""
Return true if recipientDefinition contains Constants.JCR_ANY_NAME and
doesn't contain definition with name itemName.
@param itemName
@param recipientDefinition
@return
"""
boolean containsResidual = false;
for (int i = 0; i < recipientDefinition.length; i++)
{
if (itemName.equals(recipientDefinition[i].getName()))
return false;
else if (Constants.JCR_ANY_NAME.equals(recipientDefinition[i].getName()))
containsResidual = true;
}
return containsResidual;
}
|
java
|
protected boolean isResidualMatch(InternalQName itemName, T[] recipientDefinition)
{
boolean containsResidual = false;
for (int i = 0; i < recipientDefinition.length; i++)
{
if (itemName.equals(recipientDefinition[i].getName()))
return false;
else if (Constants.JCR_ANY_NAME.equals(recipientDefinition[i].getName()))
containsResidual = true;
}
return containsResidual;
}
|
[
"protected",
"boolean",
"isResidualMatch",
"(",
"InternalQName",
"itemName",
",",
"T",
"[",
"]",
"recipientDefinition",
")",
"{",
"boolean",
"containsResidual",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"recipientDefinition",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"itemName",
".",
"equals",
"(",
"recipientDefinition",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
")",
"return",
"false",
";",
"else",
"if",
"(",
"Constants",
".",
"JCR_ANY_NAME",
".",
"equals",
"(",
"recipientDefinition",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
")",
"containsResidual",
"=",
"true",
";",
"}",
"return",
"containsResidual",
";",
"}"
] |
Return true if recipientDefinition contains Constants.JCR_ANY_NAME and
doesn't contain definition with name itemName.
@param itemName
@param recipientDefinition
@return
|
[
"Return",
"true",
"if",
"recipientDefinition",
"contains",
"Constants",
".",
"JCR_ANY_NAME",
"and",
"doesn",
"t",
"contain",
"definition",
"with",
"name",
"itemName",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractDefinitionComparator.java#L101-L112
|
rwl/CSparseJ
|
src/main/java/edu/emory/mathcs/csparsej/tdcomplex/DZcs_house.java
|
DZcs_house.cs_house
|
public static double [] cs_house(DZcsa x, int x_offset, double[] beta, int n) {
"""
Compute a Householder reflection [v,beta,s]=house(x), overwrite x with v,
where (I-beta*v*v')*x = s*e1 and e1 = [1 0 ... 0]'.
Note that this CXSparseJ version is different than CSparseJ. See Higham,
Accuracy & Stability of Num Algorithms, 2nd ed, 2002, page 357.
@param x
x on output, v on input
@param beta
scalar beta
@param n
the length of x
@return norm2(x), -1 on error
"""
double[] s = cs_czero() ;
int i ;
if (x == null) return new double [] {-1.0, 0.0} ; /* check inputs */
/* s = norm(x) */
for (i = 0 ; i < n ; i++) // TODO: check i = 1
s = cs_cplus(s, cs_cmult(x.get(x_offset + i), cs_conj(x.get(x_offset + i)))) ;
s = cs_csqrt(s) ;
if (cs_cequal(s, cs_czero()))
{
beta [0] = 0.0 ;
x.set(x_offset + 0, 1.0, 0.0) ;
}
else
{
/* s = sign(x[0]) * norm (x) ; */
if (!cs_cequal(x.get(x_offset + 0), cs_czero()))
{
s = cs_cmult(s, cs_cdiv(x.get(x_offset + 0), new double [] {cs_cabs(x.get(x_offset + 0)), 0.0})) ;
}
x.set(x_offset + 0, cs_cplus(x.get(x_offset + 0), s)) ;
beta [0] = 1 / cs_creal( cs_cmult(cs_conj(s), x.get(x_offset + 0)) ) ;
}
return cs_cmult(s, -1) ;
}
|
java
|
public static double [] cs_house(DZcsa x, int x_offset, double[] beta, int n)
{
double[] s = cs_czero() ;
int i ;
if (x == null) return new double [] {-1.0, 0.0} ; /* check inputs */
/* s = norm(x) */
for (i = 0 ; i < n ; i++) // TODO: check i = 1
s = cs_cplus(s, cs_cmult(x.get(x_offset + i), cs_conj(x.get(x_offset + i)))) ;
s = cs_csqrt(s) ;
if (cs_cequal(s, cs_czero()))
{
beta [0] = 0.0 ;
x.set(x_offset + 0, 1.0, 0.0) ;
}
else
{
/* s = sign(x[0]) * norm (x) ; */
if (!cs_cequal(x.get(x_offset + 0), cs_czero()))
{
s = cs_cmult(s, cs_cdiv(x.get(x_offset + 0), new double [] {cs_cabs(x.get(x_offset + 0)), 0.0})) ;
}
x.set(x_offset + 0, cs_cplus(x.get(x_offset + 0), s)) ;
beta [0] = 1 / cs_creal( cs_cmult(cs_conj(s), x.get(x_offset + 0)) ) ;
}
return cs_cmult(s, -1) ;
}
|
[
"public",
"static",
"double",
"[",
"]",
"cs_house",
"(",
"DZcsa",
"x",
",",
"int",
"x_offset",
",",
"double",
"[",
"]",
"beta",
",",
"int",
"n",
")",
"{",
"double",
"[",
"]",
"s",
"=",
"cs_czero",
"(",
")",
";",
"int",
"i",
";",
"if",
"(",
"x",
"==",
"null",
")",
"return",
"new",
"double",
"[",
"]",
"{",
"-",
"1.0",
",",
"0.0",
"}",
";",
"/* check inputs */",
"/* s = norm(x) */",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"// TODO: check i = 1\r",
"s",
"=",
"cs_cplus",
"(",
"s",
",",
"cs_cmult",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"i",
")",
",",
"cs_conj",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"i",
")",
")",
")",
")",
";",
"s",
"=",
"cs_csqrt",
"(",
"s",
")",
";",
"if",
"(",
"cs_cequal",
"(",
"s",
",",
"cs_czero",
"(",
")",
")",
")",
"{",
"beta",
"[",
"0",
"]",
"=",
"0.0",
";",
"x",
".",
"set",
"(",
"x_offset",
"+",
"0",
",",
"1.0",
",",
"0.0",
")",
";",
"}",
"else",
"{",
"/* s = sign(x[0]) * norm (x) ; */",
"if",
"(",
"!",
"cs_cequal",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"0",
")",
",",
"cs_czero",
"(",
")",
")",
")",
"{",
"s",
"=",
"cs_cmult",
"(",
"s",
",",
"cs_cdiv",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"0",
")",
",",
"new",
"double",
"[",
"]",
"{",
"cs_cabs",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"0",
")",
")",
",",
"0.0",
"}",
")",
")",
";",
"}",
"x",
".",
"set",
"(",
"x_offset",
"+",
"0",
",",
"cs_cplus",
"(",
"x",
".",
"get",
"(",
"x_offset",
"+",
"0",
")",
",",
"s",
")",
")",
";",
"beta",
"[",
"0",
"]",
"=",
"1",
"/",
"cs_creal",
"(",
"cs_cmult",
"(",
"cs_conj",
"(",
"s",
")",
",",
"x",
".",
"get",
"(",
"x_offset",
"+",
"0",
")",
")",
")",
";",
"}",
"return",
"cs_cmult",
"(",
"s",
",",
"-",
"1",
")",
";",
"}"
] |
Compute a Householder reflection [v,beta,s]=house(x), overwrite x with v,
where (I-beta*v*v')*x = s*e1 and e1 = [1 0 ... 0]'.
Note that this CXSparseJ version is different than CSparseJ. See Higham,
Accuracy & Stability of Num Algorithms, 2nd ed, 2002, page 357.
@param x
x on output, v on input
@param beta
scalar beta
@param n
the length of x
@return norm2(x), -1 on error
|
[
"Compute",
"a",
"Householder",
"reflection",
"[",
"v",
"beta",
"s",
"]",
"=",
"house",
"(",
"x",
")",
"overwrite",
"x",
"with",
"v",
"where",
"(",
"I",
"-",
"beta",
"*",
"v",
"*",
"v",
")",
"*",
"x",
"=",
"s",
"*",
"e1",
"and",
"e1",
"=",
"[",
"1",
"0",
"...",
"0",
"]",
".",
"Note",
"that",
"this",
"CXSparseJ",
"version",
"is",
"different",
"than",
"CSparseJ",
".",
"See",
"Higham",
"Accuracy",
"&",
"Stability",
"of",
"Num",
"Algorithms",
"2nd",
"ed",
"2002",
"page",
"357",
"."
] |
train
|
https://github.com/rwl/CSparseJ/blob/6a6f66bccce1558156a961494358952603b0ac84/src/main/java/edu/emory/mathcs/csparsej/tdcomplex/DZcs_house.java#L62-L87
|
svenkubiak/mangooio
|
mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java
|
Validator.expectMax
|
public void expectMax(String name, double maxLength) {
"""
Validates a given field to have a maximum length
@param maxLength The maximum length
@param name The field to check
"""
expectMax(name, maxLength, messages.get(Validation.MAX_KEY.name(), name, maxLength));
}
|
java
|
public void expectMax(String name, double maxLength) {
expectMax(name, maxLength, messages.get(Validation.MAX_KEY.name(), name, maxLength));
}
|
[
"public",
"void",
"expectMax",
"(",
"String",
"name",
",",
"double",
"maxLength",
")",
"{",
"expectMax",
"(",
"name",
",",
"maxLength",
",",
"messages",
".",
"get",
"(",
"Validation",
".",
"MAX_KEY",
".",
"name",
"(",
")",
",",
"name",
",",
"maxLength",
")",
")",
";",
"}"
] |
Validates a given field to have a maximum length
@param maxLength The maximum length
@param name The field to check
|
[
"Validates",
"a",
"given",
"field",
"to",
"have",
"a",
"maximum",
"length"
] |
train
|
https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/routing/bindings/Validator.java#L116-L118
|
deeplearning4j/deeplearning4j
|
nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationCalibration.java
|
EvaluationCalibration.getResidualPlotAllClasses
|
public Histogram getResidualPlotAllClasses() {
"""
Get the residual plot for all classes combined. The residual plot is defined as a histogram of<br>
|label_i - prob(class_i | input)| for all classes i and examples.<br>
In general, small residuals indicate a superior classifier to large residuals.
@return Residual plot (histogram) - all predictions/classes
"""
String title = "Residual Plot - All Predictions and Classes";
int[] counts = residualPlotOverall.data().asInt();
return new Histogram(title, 0.0, 1.0, counts);
}
|
java
|
public Histogram getResidualPlotAllClasses() {
String title = "Residual Plot - All Predictions and Classes";
int[] counts = residualPlotOverall.data().asInt();
return new Histogram(title, 0.0, 1.0, counts);
}
|
[
"public",
"Histogram",
"getResidualPlotAllClasses",
"(",
")",
"{",
"String",
"title",
"=",
"\"Residual Plot - All Predictions and Classes\"",
";",
"int",
"[",
"]",
"counts",
"=",
"residualPlotOverall",
".",
"data",
"(",
")",
".",
"asInt",
"(",
")",
";",
"return",
"new",
"Histogram",
"(",
"title",
",",
"0.0",
",",
"1.0",
",",
"counts",
")",
";",
"}"
] |
Get the residual plot for all classes combined. The residual plot is defined as a histogram of<br>
|label_i - prob(class_i | input)| for all classes i and examples.<br>
In general, small residuals indicate a superior classifier to large residuals.
@return Residual plot (histogram) - all predictions/classes
|
[
"Get",
"the",
"residual",
"plot",
"for",
"all",
"classes",
"combined",
".",
"The",
"residual",
"plot",
"is",
"defined",
"as",
"a",
"histogram",
"of<br",
">",
"|label_i",
"-",
"prob",
"(",
"class_i",
"|",
"input",
")",
"|",
"for",
"all",
"classes",
"i",
"and",
"examples",
".",
"<br",
">",
"In",
"general",
"small",
"residuals",
"indicate",
"a",
"superior",
"classifier",
"to",
"large",
"residuals",
"."
] |
train
|
https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/classification/EvaluationCalibration.java#L428-L432
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualNetworkGatewaysInner.java
|
VirtualNetworkGatewaysInner.beginResetVpnClientSharedKeyAsync
|
public Observable<Void> beginResetVpnClientSharedKeyAsync(String resourceGroupName, String virtualNetworkGatewayName) {
"""
Resets the VPN client shared key of the virtual network gateway in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginResetVpnClientSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
java
|
public Observable<Void> beginResetVpnClientSharedKeyAsync(String resourceGroupName, String virtualNetworkGatewayName) {
return beginResetVpnClientSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayName).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Void",
">",
"beginResetVpnClientSharedKeyAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayName",
")",
"{",
"return",
"beginResetVpnClientSharedKeyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Resets the VPN client shared key of the virtual network gateway in the specified resource group.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayName The name of the virtual network gateway.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
|
[
"Resets",
"the",
"VPN",
"client",
"shared",
"key",
"of",
"the",
"virtual",
"network",
"gateway",
"in",
"the",
"specified",
"resource",
"group",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/VirtualNetworkGatewaysInner.java#L1562-L1569
|
eurekaclinical/protempa
|
protempa-framework/src/main/java/org/protempa/PropositionCopier.java
|
PropositionCopier.visit
|
@Override
public void visit(Constant constant) {
"""
Creates a derived constant with the id specified in the
constructor and the same characteristics (e.g., data source type,
interval, value, etc.).
@param constant a {@link Constant}. Cannot be <code>null</code>.
"""
assert this.kh != null : "kh wasn't set";
Constant newConstant = new Constant(propId, this.uniqueIdProvider.getInstance());
newConstant.setSourceSystem(SourceSystem.DERIVED);
newConstant.setCreateDate(new Date());
this.kh.insertLogical(newConstant);
this.derivationsBuilder.propositionAsserted(constant, newConstant);
LOGGER.log(Level.FINER, "Asserted derived proposition {0}", newConstant);
}
|
java
|
@Override
public void visit(Constant constant) {
assert this.kh != null : "kh wasn't set";
Constant newConstant = new Constant(propId, this.uniqueIdProvider.getInstance());
newConstant.setSourceSystem(SourceSystem.DERIVED);
newConstant.setCreateDate(new Date());
this.kh.insertLogical(newConstant);
this.derivationsBuilder.propositionAsserted(constant, newConstant);
LOGGER.log(Level.FINER, "Asserted derived proposition {0}", newConstant);
}
|
[
"@",
"Override",
"public",
"void",
"visit",
"(",
"Constant",
"constant",
")",
"{",
"assert",
"this",
".",
"kh",
"!=",
"null",
":",
"\"kh wasn't set\"",
";",
"Constant",
"newConstant",
"=",
"new",
"Constant",
"(",
"propId",
",",
"this",
".",
"uniqueIdProvider",
".",
"getInstance",
"(",
")",
")",
";",
"newConstant",
".",
"setSourceSystem",
"(",
"SourceSystem",
".",
"DERIVED",
")",
";",
"newConstant",
".",
"setCreateDate",
"(",
"new",
"Date",
"(",
")",
")",
";",
"this",
".",
"kh",
".",
"insertLogical",
"(",
"newConstant",
")",
";",
"this",
".",
"derivationsBuilder",
".",
"propositionAsserted",
"(",
"constant",
",",
"newConstant",
")",
";",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINER",
",",
"\"Asserted derived proposition {0}\"",
",",
"newConstant",
")",
";",
"}"
] |
Creates a derived constant with the id specified in the
constructor and the same characteristics (e.g., data source type,
interval, value, etc.).
@param constant a {@link Constant}. Cannot be <code>null</code>.
|
[
"Creates",
"a",
"derived",
"constant",
"with",
"the",
"id",
"specified",
"in",
"the",
"constructor",
"and",
"the",
"same",
"characteristics",
"(",
"e",
".",
"g",
".",
"data",
"source",
"type",
"interval",
"value",
"etc",
".",
")",
"."
] |
train
|
https://github.com/eurekaclinical/protempa/blob/5a620d1a407c7a5426d1cf17d47b97717cf71634/protempa-framework/src/main/java/org/protempa/PropositionCopier.java#L177-L186
|
netty/netty
|
codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java
|
HttpHeaders.containsValue
|
public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase) {
"""
Returns {@code true} if a header with the {@code name} and {@code value} exists, {@code false} otherwise.
This also handles multiple values that are separated with a {@code ,}.
<p>
If {@code ignoreCase} is {@code true} then a case insensitive compare is done on the value.
@param name the name of the header to find
@param value the value of the header to find
@param ignoreCase {@code true} then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.
"""
Iterator<? extends CharSequence> itr = valueCharSequenceIterator(name);
while (itr.hasNext()) {
if (containsCommaSeparatedTrimmed(itr.next(), value, ignoreCase)) {
return true;
}
}
return false;
}
|
java
|
public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase) {
Iterator<? extends CharSequence> itr = valueCharSequenceIterator(name);
while (itr.hasNext()) {
if (containsCommaSeparatedTrimmed(itr.next(), value, ignoreCase)) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"containsValue",
"(",
"CharSequence",
"name",
",",
"CharSequence",
"value",
",",
"boolean",
"ignoreCase",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"CharSequence",
">",
"itr",
"=",
"valueCharSequenceIterator",
"(",
"name",
")",
";",
"while",
"(",
"itr",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"containsCommaSeparatedTrimmed",
"(",
"itr",
".",
"next",
"(",
")",
",",
"value",
",",
"ignoreCase",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns {@code true} if a header with the {@code name} and {@code value} exists, {@code false} otherwise.
This also handles multiple values that are separated with a {@code ,}.
<p>
If {@code ignoreCase} is {@code true} then a case insensitive compare is done on the value.
@param name the name of the header to find
@param value the value of the header to find
@param ignoreCase {@code true} then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.
|
[
"Returns",
"{"
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpHeaders.java#L1598-L1606
|
shrinkwrap/resolver
|
maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java
|
MavenRepositorySystem.resolveVersionRange
|
public VersionRangeResult resolveVersionRange(final RepositorySystemSession session, final VersionRangeRequest request)
throws VersionRangeResolutionException {
"""
Resolves versions range
@param session The current Maven session
@param request The request to be computed
@return version range result
@throws VersionRangeResolutionException
If the requested range could not be parsed. Note that an empty range does not raise an exception.
"""
return system.resolveVersionRange(session, request);
}
|
java
|
public VersionRangeResult resolveVersionRange(final RepositorySystemSession session, final VersionRangeRequest request)
throws VersionRangeResolutionException {
return system.resolveVersionRange(session, request);
}
|
[
"public",
"VersionRangeResult",
"resolveVersionRange",
"(",
"final",
"RepositorySystemSession",
"session",
",",
"final",
"VersionRangeRequest",
"request",
")",
"throws",
"VersionRangeResolutionException",
"{",
"return",
"system",
".",
"resolveVersionRange",
"(",
"session",
",",
"request",
")",
";",
"}"
] |
Resolves versions range
@param session The current Maven session
@param request The request to be computed
@return version range result
@throws VersionRangeResolutionException
If the requested range could not be parsed. Note that an empty range does not raise an exception.
|
[
"Resolves",
"versions",
"range"
] |
train
|
https://github.com/shrinkwrap/resolver/blob/e881a84b8cff5b0a014f2a5ebf612be3eb9db01f/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenRepositorySystem.java#L148-L151
|
before/uadetector
|
modules/uadetector-core/src/main/java/net/sf/uadetector/parser/AbstractUserAgentStringParser.java
|
AbstractUserAgentStringParser.examineOperatingSystem
|
private static void examineOperatingSystem(final UserAgent.Builder builder, final Data data) {
"""
Examines the operating system of the user agent string, if not available.
@param userAgent
String of an user agent
@param builder
Builder for an user agent information
"""
if (net.sf.uadetector.OperatingSystem.EMPTY.equals(builder.getOperatingSystem())) {
for (final Entry<OperatingSystemPattern, OperatingSystem> entry : data.getPatternToOperatingSystemMap().entrySet()) {
final Matcher matcher = entry.getKey().getPattern().matcher(builder.getUserAgentString());
if (matcher.find()) {
entry.getValue().copyTo(builder);
break;
}
}
}
}
|
java
|
private static void examineOperatingSystem(final UserAgent.Builder builder, final Data data) {
if (net.sf.uadetector.OperatingSystem.EMPTY.equals(builder.getOperatingSystem())) {
for (final Entry<OperatingSystemPattern, OperatingSystem> entry : data.getPatternToOperatingSystemMap().entrySet()) {
final Matcher matcher = entry.getKey().getPattern().matcher(builder.getUserAgentString());
if (matcher.find()) {
entry.getValue().copyTo(builder);
break;
}
}
}
}
|
[
"private",
"static",
"void",
"examineOperatingSystem",
"(",
"final",
"UserAgent",
".",
"Builder",
"builder",
",",
"final",
"Data",
"data",
")",
"{",
"if",
"(",
"net",
".",
"sf",
".",
"uadetector",
".",
"OperatingSystem",
".",
"EMPTY",
".",
"equals",
"(",
"builder",
".",
"getOperatingSystem",
"(",
")",
")",
")",
"{",
"for",
"(",
"final",
"Entry",
"<",
"OperatingSystemPattern",
",",
"OperatingSystem",
">",
"entry",
":",
"data",
".",
"getPatternToOperatingSystemMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"Matcher",
"matcher",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"getPattern",
"(",
")",
".",
"matcher",
"(",
"builder",
".",
"getUserAgentString",
"(",
")",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"entry",
".",
"getValue",
"(",
")",
".",
"copyTo",
"(",
"builder",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Examines the operating system of the user agent string, if not available.
@param userAgent
String of an user agent
@param builder
Builder for an user agent information
|
[
"Examines",
"the",
"operating",
"system",
"of",
"the",
"user",
"agent",
"string",
"if",
"not",
"available",
"."
] |
train
|
https://github.com/before/uadetector/blob/215fb652723c52866572cff885f52a3fe67b9db5/modules/uadetector-core/src/main/java/net/sf/uadetector/parser/AbstractUserAgentStringParser.java#L163-L173
|
aws/aws-sdk-java
|
aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/ComplianceItem.java
|
ComplianceItem.withDetails
|
public ComplianceItem withDetails(java.util.Map<String, String> details) {
"""
<p>
A "Key": "Value" tag combination for the compliance item.
</p>
@param details
A "Key": "Value" tag combination for the compliance item.
@return Returns a reference to this object so that method calls can be chained together.
"""
setDetails(details);
return this;
}
|
java
|
public ComplianceItem withDetails(java.util.Map<String, String> details) {
setDetails(details);
return this;
}
|
[
"public",
"ComplianceItem",
"withDetails",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"details",
")",
"{",
"setDetails",
"(",
"details",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
A "Key": "Value" tag combination for the compliance item.
</p>
@param details
A "Key": "Value" tag combination for the compliance item.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"A",
"Key",
":",
"Value",
"tag",
"combination",
"for",
"the",
"compliance",
"item",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/ComplianceItem.java#L520-L523
|
spring-projects/spring-hateoas
|
src/main/java/org/springframework/hateoas/mediatype/hal/HalConfiguration.java
|
HalConfiguration.withRenderSingleLinksFor
|
public HalConfiguration withRenderSingleLinksFor(String pattern, RenderSingleLinks renderSingleLinks) {
"""
Configures how to render a single link for the given link relation pattern, i.e. this can be either a fixed link
relation (like {@code search}), take wildcards to e.g. match links of a given curie (like {@code acme:*}) or even
complete URIs (like {@code https://api.acme.com/foo/**}).
@param pattern must not be {@literal null}.
@param renderSingleLinks must not be {@literal null}.
@return @see PathMatcher
"""
Map<String, RenderSingleLinks> map = new LinkedHashMap<>(singleLinksPerPattern);
map.put(pattern, renderSingleLinks);
return withSingleLinksPerPattern(map);
}
|
java
|
public HalConfiguration withRenderSingleLinksFor(String pattern, RenderSingleLinks renderSingleLinks) {
Map<String, RenderSingleLinks> map = new LinkedHashMap<>(singleLinksPerPattern);
map.put(pattern, renderSingleLinks);
return withSingleLinksPerPattern(map);
}
|
[
"public",
"HalConfiguration",
"withRenderSingleLinksFor",
"(",
"String",
"pattern",
",",
"RenderSingleLinks",
"renderSingleLinks",
")",
"{",
"Map",
"<",
"String",
",",
"RenderSingleLinks",
">",
"map",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
"singleLinksPerPattern",
")",
";",
"map",
".",
"put",
"(",
"pattern",
",",
"renderSingleLinks",
")",
";",
"return",
"withSingleLinksPerPattern",
"(",
"map",
")",
";",
"}"
] |
Configures how to render a single link for the given link relation pattern, i.e. this can be either a fixed link
relation (like {@code search}), take wildcards to e.g. match links of a given curie (like {@code acme:*}) or even
complete URIs (like {@code https://api.acme.com/foo/**}).
@param pattern must not be {@literal null}.
@param renderSingleLinks must not be {@literal null}.
@return @see PathMatcher
|
[
"Configures",
"how",
"to",
"render",
"a",
"single",
"link",
"for",
"the",
"given",
"link",
"relation",
"pattern",
"i",
".",
"e",
".",
"this",
"can",
"be",
"either",
"a",
"fixed",
"link",
"relation",
"(",
"like",
"{",
"@code",
"search",
"}",
")",
"take",
"wildcards",
"to",
"e",
".",
"g",
".",
"match",
"links",
"of",
"a",
"given",
"curie",
"(",
"like",
"{",
"@code",
"acme",
":",
"*",
"}",
")",
"or",
"even",
"complete",
"URIs",
"(",
"like",
"{",
"@code",
"https",
":",
"//",
"api",
".",
"acme",
".",
"com",
"/",
"foo",
"/",
"**",
"}",
")",
"."
] |
train
|
https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/mediatype/hal/HalConfiguration.java#L85-L91
|
rometools/rome
|
rome/src/main/java/com/rometools/rome/io/WireFeedOutput.java
|
WireFeedOutput.outputString
|
public String outputString(final WireFeed feed, final boolean prettyPrint) throws IllegalArgumentException, FeedException {
"""
Creates a String with the XML representation for the given WireFeed.
<p>
If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
the responsibility of the developer to ensure that if the String is written to a character
stream the stream charset is the same as the feed encoding property.
<p>
NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
<p>
@param feed Abstract feed to create XML representation from. The type of the WireFeed must
match the type given to the FeedOuptut constructor.
@param prettyPrint pretty-print XML (true) oder collapsed
@return a String with the XML representation for the given WireFeed.
@throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
don't match.
@throws FeedException thrown if the XML representation for the feed could not be created.
"""
final Document doc = outputJDom(feed);
final String encoding = feed.getEncoding();
Format format;
if (prettyPrint) {
format = Format.getPrettyFormat();
} else {
format = Format.getCompactFormat();
}
if (encoding != null) {
format.setEncoding(encoding);
}
final XMLOutputter outputter = new XMLOutputter(format);
return outputter.outputString(doc);
}
|
java
|
public String outputString(final WireFeed feed, final boolean prettyPrint) throws IllegalArgumentException, FeedException {
final Document doc = outputJDom(feed);
final String encoding = feed.getEncoding();
Format format;
if (prettyPrint) {
format = Format.getPrettyFormat();
} else {
format = Format.getCompactFormat();
}
if (encoding != null) {
format.setEncoding(encoding);
}
final XMLOutputter outputter = new XMLOutputter(format);
return outputter.outputString(doc);
}
|
[
"public",
"String",
"outputString",
"(",
"final",
"WireFeed",
"feed",
",",
"final",
"boolean",
"prettyPrint",
")",
"throws",
"IllegalArgumentException",
",",
"FeedException",
"{",
"final",
"Document",
"doc",
"=",
"outputJDom",
"(",
"feed",
")",
";",
"final",
"String",
"encoding",
"=",
"feed",
".",
"getEncoding",
"(",
")",
";",
"Format",
"format",
";",
"if",
"(",
"prettyPrint",
")",
"{",
"format",
"=",
"Format",
".",
"getPrettyFormat",
"(",
")",
";",
"}",
"else",
"{",
"format",
"=",
"Format",
".",
"getCompactFormat",
"(",
")",
";",
"}",
"if",
"(",
"encoding",
"!=",
"null",
")",
"{",
"format",
".",
"setEncoding",
"(",
"encoding",
")",
";",
"}",
"final",
"XMLOutputter",
"outputter",
"=",
"new",
"XMLOutputter",
"(",
"format",
")",
";",
"return",
"outputter",
".",
"outputString",
"(",
"doc",
")",
";",
"}"
] |
Creates a String with the XML representation for the given WireFeed.
<p>
If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
the responsibility of the developer to ensure that if the String is written to a character
stream the stream charset is the same as the feed encoding property.
<p>
NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
<p>
@param feed Abstract feed to create XML representation from. The type of the WireFeed must
match the type given to the FeedOuptut constructor.
@param prettyPrint pretty-print XML (true) oder collapsed
@return a String with the XML representation for the given WireFeed.
@throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
don't match.
@throws FeedException thrown if the XML representation for the feed could not be created.
|
[
"Creates",
"a",
"String",
"with",
"the",
"XML",
"representation",
"for",
"the",
"given",
"WireFeed",
".",
"<p",
">",
"If",
"the",
"feed",
"encoding",
"is",
"not",
"NULL",
"it",
"will",
"be",
"used",
"in",
"the",
"XML",
"prolog",
"encoding",
"attribute",
".",
"It",
"is",
"the",
"responsibility",
"of",
"the",
"developer",
"to",
"ensure",
"that",
"if",
"the",
"String",
"is",
"written",
"to",
"a",
"character",
"stream",
"the",
"stream",
"charset",
"is",
"the",
"same",
"as",
"the",
"feed",
"encoding",
"property",
".",
"<p",
">",
"NOTE",
":",
"This",
"method",
"delages",
"to",
"the",
"Document",
"WireFeedOutput#outputJDom",
"(",
"WireFeed",
")",
".",
"<p",
">"
] |
train
|
https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome/src/main/java/com/rometools/rome/io/WireFeedOutput.java#L121-L135
|
molgenis/molgenis
|
molgenis-data/src/main/java/org/molgenis/data/util/EntityUtils.java
|
EntityUtils.getTypedValue
|
public static Object getTypedValue(String valueStr, Attribute attr) {
"""
Convert a string value to a typed value based on a non-entity-referencing attribute data type.
@param valueStr string value
@param attr non-entity-referencing attribute
@return typed value
@throws MolgenisDataException if attribute references another entity
"""
// Reference types cannot be processed because we lack an entityManager in this route.
if (EntityTypeUtils.isReferenceType(attr)) {
throw new MolgenisDataException(
"getTypedValue(String, AttributeMetadata) can't be used for attributes referencing entities");
}
return getTypedValue(valueStr, attr, null);
}
|
java
|
public static Object getTypedValue(String valueStr, Attribute attr) {
// Reference types cannot be processed because we lack an entityManager in this route.
if (EntityTypeUtils.isReferenceType(attr)) {
throw new MolgenisDataException(
"getTypedValue(String, AttributeMetadata) can't be used for attributes referencing entities");
}
return getTypedValue(valueStr, attr, null);
}
|
[
"public",
"static",
"Object",
"getTypedValue",
"(",
"String",
"valueStr",
",",
"Attribute",
"attr",
")",
"{",
"// Reference types cannot be processed because we lack an entityManager in this route.",
"if",
"(",
"EntityTypeUtils",
".",
"isReferenceType",
"(",
"attr",
")",
")",
"{",
"throw",
"new",
"MolgenisDataException",
"(",
"\"getTypedValue(String, AttributeMetadata) can't be used for attributes referencing entities\"",
")",
";",
"}",
"return",
"getTypedValue",
"(",
"valueStr",
",",
"attr",
",",
"null",
")",
";",
"}"
] |
Convert a string value to a typed value based on a non-entity-referencing attribute data type.
@param valueStr string value
@param attr non-entity-referencing attribute
@return typed value
@throws MolgenisDataException if attribute references another entity
|
[
"Convert",
"a",
"string",
"value",
"to",
"a",
"typed",
"value",
"based",
"on",
"a",
"non",
"-",
"entity",
"-",
"referencing",
"attribute",
"data",
"type",
"."
] |
train
|
https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-data/src/main/java/org/molgenis/data/util/EntityUtils.java#L38-L45
|
apiman/apiman
|
manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java
|
EsMarshalling.unmarshallPolicyDefinition
|
public static PolicyDefinitionBean unmarshallPolicyDefinition(Map<String, Object> source) {
"""
Unmarshals the given map source into a bean.
@param source the source
@return the policy definition
"""
if (source == null) {
return null;
}
PolicyDefinitionBean bean = new PolicyDefinitionBean();
bean.setId(asString(source.get("id")));
bean.setName(asString(source.get("name")));
bean.setDescription(asString(source.get("description")));
bean.setForm(asString(source.get("form")));
bean.setFormType(asEnum(source.get("formType"), PolicyFormType.class));
bean.setIcon(asString(source.get("icon")));
bean.setPluginId(asLong(source.get("pluginId")));
bean.setPolicyImpl(asString(source.get("policyImpl")));
bean.setDeleted(asBoolean(source.get("deleted")));
@SuppressWarnings("unchecked")
List<Map<String, Object>> templates = (List<Map<String, Object>>) source.get("templates");
if (templates != null && !templates.isEmpty()) {
bean.setTemplates(new HashSet<>());
for (Map<String, Object> templateMap : templates) {
PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
template.setLanguage(asString(templateMap.get("language")));
template.setTemplate(asString(templateMap.get("template")));
bean.getTemplates().add(template);
}
}
postMarshall(bean);
return bean;
}
|
java
|
public static PolicyDefinitionBean unmarshallPolicyDefinition(Map<String, Object> source) {
if (source == null) {
return null;
}
PolicyDefinitionBean bean = new PolicyDefinitionBean();
bean.setId(asString(source.get("id")));
bean.setName(asString(source.get("name")));
bean.setDescription(asString(source.get("description")));
bean.setForm(asString(source.get("form")));
bean.setFormType(asEnum(source.get("formType"), PolicyFormType.class));
bean.setIcon(asString(source.get("icon")));
bean.setPluginId(asLong(source.get("pluginId")));
bean.setPolicyImpl(asString(source.get("policyImpl")));
bean.setDeleted(asBoolean(source.get("deleted")));
@SuppressWarnings("unchecked")
List<Map<String, Object>> templates = (List<Map<String, Object>>) source.get("templates");
if (templates != null && !templates.isEmpty()) {
bean.setTemplates(new HashSet<>());
for (Map<String, Object> templateMap : templates) {
PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
template.setLanguage(asString(templateMap.get("language")));
template.setTemplate(asString(templateMap.get("template")));
bean.getTemplates().add(template);
}
}
postMarshall(bean);
return bean;
}
|
[
"public",
"static",
"PolicyDefinitionBean",
"unmarshallPolicyDefinition",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"source",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"PolicyDefinitionBean",
"bean",
"=",
"new",
"PolicyDefinitionBean",
"(",
")",
";",
"bean",
".",
"setId",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"id\"",
")",
")",
")",
";",
"bean",
".",
"setName",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"name\"",
")",
")",
")",
";",
"bean",
".",
"setDescription",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"description\"",
")",
")",
")",
";",
"bean",
".",
"setForm",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"form\"",
")",
")",
")",
";",
"bean",
".",
"setFormType",
"(",
"asEnum",
"(",
"source",
".",
"get",
"(",
"\"formType\"",
")",
",",
"PolicyFormType",
".",
"class",
")",
")",
";",
"bean",
".",
"setIcon",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"icon\"",
")",
")",
")",
";",
"bean",
".",
"setPluginId",
"(",
"asLong",
"(",
"source",
".",
"get",
"(",
"\"pluginId\"",
")",
")",
")",
";",
"bean",
".",
"setPolicyImpl",
"(",
"asString",
"(",
"source",
".",
"get",
"(",
"\"policyImpl\"",
")",
")",
")",
";",
"bean",
".",
"setDeleted",
"(",
"asBoolean",
"(",
"source",
".",
"get",
"(",
"\"deleted\"",
")",
")",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"templates",
"=",
"(",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
")",
"source",
".",
"get",
"(",
"\"templates\"",
")",
";",
"if",
"(",
"templates",
"!=",
"null",
"&&",
"!",
"templates",
".",
"isEmpty",
"(",
")",
")",
"{",
"bean",
".",
"setTemplates",
"(",
"new",
"HashSet",
"<>",
"(",
")",
")",
";",
"for",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"templateMap",
":",
"templates",
")",
"{",
"PolicyDefinitionTemplateBean",
"template",
"=",
"new",
"PolicyDefinitionTemplateBean",
"(",
")",
";",
"template",
".",
"setLanguage",
"(",
"asString",
"(",
"templateMap",
".",
"get",
"(",
"\"language\"",
")",
")",
")",
";",
"template",
".",
"setTemplate",
"(",
"asString",
"(",
"templateMap",
".",
"get",
"(",
"\"template\"",
")",
")",
")",
";",
"bean",
".",
"getTemplates",
"(",
")",
".",
"add",
"(",
"template",
")",
";",
"}",
"}",
"postMarshall",
"(",
"bean",
")",
";",
"return",
"bean",
";",
"}"
] |
Unmarshals the given map source into a bean.
@param source the source
@return the policy definition
|
[
"Unmarshals",
"the",
"given",
"map",
"source",
"into",
"a",
"bean",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L1249-L1276
|
wso2/transport-http
|
components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/http2/Http2ClientChannel.java
|
Http2ClientChannel.putInFlightMessage
|
public void putInFlightMessage(int streamId, OutboundMsgHolder inFlightMessage) {
"""
Adds a in-flight message.
@param streamId stream id
@param inFlightMessage {@link OutboundMsgHolder} which holds the in-flight message
"""
if (LOG.isDebugEnabled()) {
LOG.debug("In flight message added to channel: {} with stream id: {} ", this, streamId);
}
inFlightMessages.put(streamId, inFlightMessage);
}
|
java
|
public void putInFlightMessage(int streamId, OutboundMsgHolder inFlightMessage) {
if (LOG.isDebugEnabled()) {
LOG.debug("In flight message added to channel: {} with stream id: {} ", this, streamId);
}
inFlightMessages.put(streamId, inFlightMessage);
}
|
[
"public",
"void",
"putInFlightMessage",
"(",
"int",
"streamId",
",",
"OutboundMsgHolder",
"inFlightMessage",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"In flight message added to channel: {} with stream id: {} \"",
",",
"this",
",",
"streamId",
")",
";",
"}",
"inFlightMessages",
".",
"put",
"(",
"streamId",
",",
"inFlightMessage",
")",
";",
"}"
] |
Adds a in-flight message.
@param streamId stream id
@param inFlightMessage {@link OutboundMsgHolder} which holds the in-flight message
|
[
"Adds",
"a",
"in",
"-",
"flight",
"message",
"."
] |
train
|
https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/sender/http2/Http2ClientChannel.java#L127-L132
|
OpenBEL/openbel-framework
|
org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java
|
PhaseApplication.getCommandLineOptions
|
@Override
public List<Option> getCommandLineOptions() {
"""
Returns a list of phase-agnostic command-line options.
@return List of options
"""
final List<Option> ret = new LinkedList<Option>();
String help;
help = TIME_HELP;
ret.add(new Option(SHORT_OPT_TIME, LONG_OPT_TIME, false, help));
help = WARNINGS_AS_ERRORS;
ret.add(new Option(null, LONG_OPT_PEDANTIC, false, help));
help = SYSTEM_CONFIG_PATH;
Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help);
o.setArgName(ARG_SYSCFG);
ret.add(o);
return ret;
}
|
java
|
@Override
public List<Option> getCommandLineOptions() {
final List<Option> ret = new LinkedList<Option>();
String help;
help = TIME_HELP;
ret.add(new Option(SHORT_OPT_TIME, LONG_OPT_TIME, false, help));
help = WARNINGS_AS_ERRORS;
ret.add(new Option(null, LONG_OPT_PEDANTIC, false, help));
help = SYSTEM_CONFIG_PATH;
Option o = new Option(SHRT_OPT_SYSCFG, LONG_OPT_SYSCFG, true, help);
o.setArgName(ARG_SYSCFG);
ret.add(o);
return ret;
}
|
[
"@",
"Override",
"public",
"List",
"<",
"Option",
">",
"getCommandLineOptions",
"(",
")",
"{",
"final",
"List",
"<",
"Option",
">",
"ret",
"=",
"new",
"LinkedList",
"<",
"Option",
">",
"(",
")",
";",
"String",
"help",
";",
"help",
"=",
"TIME_HELP",
";",
"ret",
".",
"add",
"(",
"new",
"Option",
"(",
"SHORT_OPT_TIME",
",",
"LONG_OPT_TIME",
",",
"false",
",",
"help",
")",
")",
";",
"help",
"=",
"WARNINGS_AS_ERRORS",
";",
"ret",
".",
"add",
"(",
"new",
"Option",
"(",
"null",
",",
"LONG_OPT_PEDANTIC",
",",
"false",
",",
"help",
")",
")",
";",
"help",
"=",
"SYSTEM_CONFIG_PATH",
";",
"Option",
"o",
"=",
"new",
"Option",
"(",
"SHRT_OPT_SYSCFG",
",",
"LONG_OPT_SYSCFG",
",",
"true",
",",
"help",
")",
";",
"o",
".",
"setArgName",
"(",
"ARG_SYSCFG",
")",
";",
"ret",
".",
"add",
"(",
"o",
")",
";",
"return",
"ret",
";",
"}"
] |
Returns a list of phase-agnostic command-line options.
@return List of options
|
[
"Returns",
"a",
"list",
"of",
"phase",
"-",
"agnostic",
"command",
"-",
"line",
"options",
"."
] |
train
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.tools/src/main/java/org/openbel/framework/tools/PhaseApplication.java#L162-L180
|
prestodb/presto
|
presto-spi/src/main/java/com/facebook/presto/spi/block/BlockUtil.java
|
BlockUtil.arraySame
|
static boolean arraySame(Object[] array1, Object[] array2) {
"""
Returns <tt>true</tt> if the two specified arrays contain the same object in every position.
Unlike the {@link Arrays#equals(Object[], Object[])} method, this method compares using reference equals.
"""
if (array1 == null || array2 == null || array1.length != array2.length) {
throw new IllegalArgumentException("array1 and array2 cannot be null and should have same length");
}
for (int i = 0; i < array1.length; i++) {
if (array1[i] != array2[i]) {
return false;
}
}
return true;
}
|
java
|
static boolean arraySame(Object[] array1, Object[] array2)
{
if (array1 == null || array2 == null || array1.length != array2.length) {
throw new IllegalArgumentException("array1 and array2 cannot be null and should have same length");
}
for (int i = 0; i < array1.length; i++) {
if (array1[i] != array2[i]) {
return false;
}
}
return true;
}
|
[
"static",
"boolean",
"arraySame",
"(",
"Object",
"[",
"]",
"array1",
",",
"Object",
"[",
"]",
"array2",
")",
"{",
"if",
"(",
"array1",
"==",
"null",
"||",
"array2",
"==",
"null",
"||",
"array1",
".",
"length",
"!=",
"array2",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"array1 and array2 cannot be null and should have same length\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array1",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"array1",
"[",
"i",
"]",
"!=",
"array2",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns <tt>true</tt> if the two specified arrays contain the same object in every position.
Unlike the {@link Arrays#equals(Object[], Object[])} method, this method compares using reference equals.
|
[
"Returns",
"<tt",
">",
"true<",
"/",
"tt",
">",
"if",
"the",
"two",
"specified",
"arrays",
"contain",
"the",
"same",
"object",
"in",
"every",
"position",
".",
"Unlike",
"the",
"{"
] |
train
|
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-spi/src/main/java/com/facebook/presto/spi/block/BlockUtil.java#L198-L210
|
overturetool/overture
|
core/parser/src/main/java/org/overture/parser/lex/LexTokenReader.java
|
LexTokenReader.throwMessage
|
private void throwMessage(int number, String msg) throws LexException {
"""
Throw a {@link LexException} with the given message and details of the current file and position appended.
@param number
The error number.
@param msg
The basic error message.
@throws LexException
"""
throwMessage(number, linecount, charpos, msg);
}
|
java
|
private void throwMessage(int number, String msg) throws LexException
{
throwMessage(number, linecount, charpos, msg);
}
|
[
"private",
"void",
"throwMessage",
"(",
"int",
"number",
",",
"String",
"msg",
")",
"throws",
"LexException",
"{",
"throwMessage",
"(",
"number",
",",
"linecount",
",",
"charpos",
",",
"msg",
")",
";",
"}"
] |
Throw a {@link LexException} with the given message and details of the current file and position appended.
@param number
The error number.
@param msg
The basic error message.
@throws LexException
|
[
"Throw",
"a",
"{",
"@link",
"LexException",
"}",
"with",
"the",
"given",
"message",
"and",
"details",
"of",
"the",
"current",
"file",
"and",
"position",
"appended",
"."
] |
train
|
https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/parser/src/main/java/org/overture/parser/lex/LexTokenReader.java#L296-L299
|
citrusframework/citrus
|
modules/citrus-core/src/main/java/com/consol/citrus/config/xml/MessageSelectorParser.java
|
MessageSelectorParser.doParse
|
public static void doParse(Element element, BeanDefinitionBuilder builder) {
"""
Static parse method taking care of test action description.
@param element
@param builder
"""
Element messageSelectorElement = DomUtils.getChildElementByTagName(element, "selector");
if (messageSelectorElement != null) {
Element selectorStringElement = DomUtils.getChildElementByTagName(messageSelectorElement, "value");
if (selectorStringElement != null) {
builder.addPropertyValue("messageSelector", DomUtils.getTextValue(selectorStringElement));
}
Map<String, String> messageSelectorMap = new HashMap<>();
List<?> messageSelectorElements = DomUtils.getChildElementsByTagName(messageSelectorElement, "element");
for (Iterator<?> iter = messageSelectorElements.iterator(); iter.hasNext();) {
Element selectorElement = (Element) iter.next();
messageSelectorMap.put(selectorElement.getAttribute("name"), selectorElement.getAttribute("value"));
}
builder.addPropertyValue("messageSelectorMap", messageSelectorMap);
}
}
|
java
|
public static void doParse(Element element, BeanDefinitionBuilder builder) {
Element messageSelectorElement = DomUtils.getChildElementByTagName(element, "selector");
if (messageSelectorElement != null) {
Element selectorStringElement = DomUtils.getChildElementByTagName(messageSelectorElement, "value");
if (selectorStringElement != null) {
builder.addPropertyValue("messageSelector", DomUtils.getTextValue(selectorStringElement));
}
Map<String, String> messageSelectorMap = new HashMap<>();
List<?> messageSelectorElements = DomUtils.getChildElementsByTagName(messageSelectorElement, "element");
for (Iterator<?> iter = messageSelectorElements.iterator(); iter.hasNext();) {
Element selectorElement = (Element) iter.next();
messageSelectorMap.put(selectorElement.getAttribute("name"), selectorElement.getAttribute("value"));
}
builder.addPropertyValue("messageSelectorMap", messageSelectorMap);
}
}
|
[
"public",
"static",
"void",
"doParse",
"(",
"Element",
"element",
",",
"BeanDefinitionBuilder",
"builder",
")",
"{",
"Element",
"messageSelectorElement",
"=",
"DomUtils",
".",
"getChildElementByTagName",
"(",
"element",
",",
"\"selector\"",
")",
";",
"if",
"(",
"messageSelectorElement",
"!=",
"null",
")",
"{",
"Element",
"selectorStringElement",
"=",
"DomUtils",
".",
"getChildElementByTagName",
"(",
"messageSelectorElement",
",",
"\"value\"",
")",
";",
"if",
"(",
"selectorStringElement",
"!=",
"null",
")",
"{",
"builder",
".",
"addPropertyValue",
"(",
"\"messageSelector\"",
",",
"DomUtils",
".",
"getTextValue",
"(",
"selectorStringElement",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"messageSelectorMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"List",
"<",
"?",
">",
"messageSelectorElements",
"=",
"DomUtils",
".",
"getChildElementsByTagName",
"(",
"messageSelectorElement",
",",
"\"element\"",
")",
";",
"for",
"(",
"Iterator",
"<",
"?",
">",
"iter",
"=",
"messageSelectorElements",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Element",
"selectorElement",
"=",
"(",
"Element",
")",
"iter",
".",
"next",
"(",
")",
";",
"messageSelectorMap",
".",
"put",
"(",
"selectorElement",
".",
"getAttribute",
"(",
"\"name\"",
")",
",",
"selectorElement",
".",
"getAttribute",
"(",
"\"value\"",
")",
")",
";",
"}",
"builder",
".",
"addPropertyValue",
"(",
"\"messageSelectorMap\"",
",",
"messageSelectorMap",
")",
";",
"}",
"}"
] |
Static parse method taking care of test action description.
@param element
@param builder
|
[
"Static",
"parse",
"method",
"taking",
"care",
"of",
"test",
"action",
"description",
"."
] |
train
|
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-core/src/main/java/com/consol/citrus/config/xml/MessageSelectorParser.java#L43-L59
|
google/j2objc
|
jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterName.java
|
UCharacterName.getGroupLengths
|
public int getGroupLengths(int index, char offsets[], char lengths[]) {
"""
Reads a block of compressed lengths of 32 strings and expands them into
offsets and lengths for each string. Lengths are stored with a
variable-width encoding in consecutive nibbles:
If a nibble<0xc, then it is the length itself (0 = empty string).
If a nibble>=0xc, then it forms a length value with the following
nibble.
The offsets and lengths arrays must be at least 33 (one more) long
because there is no check here at the end if the last nibble is still
used.
@param index of group string object in array
@param offsets array to store the value of the string offsets
@param lengths array to store the value of the string length
@return next index of the data string immediately after the lengths
in terms of byte address
"""
char length = 0xffff;
byte b = 0,
n = 0;
int shift;
index = index * m_groupsize_; // byte count offsets of group strings
int stringoffset = UCharacterUtility.toInt(
m_groupinfo_[index + OFFSET_HIGH_OFFSET_],
m_groupinfo_[index + OFFSET_LOW_OFFSET_]);
offsets[0] = 0;
// all 32 lengths must be read to get the offset of the first group
// string
for (int i = 0; i < LINES_PER_GROUP_; stringoffset ++) {
b = m_groupstring_[stringoffset];
shift = 4;
while (shift >= 0) {
// getting nibble
n = (byte)((b >> shift) & 0x0F);
if (length == 0xffff && n > SINGLE_NIBBLE_MAX_) {
length = (char)((n - 12) << 4);
}
else {
if (length != 0xffff) {
lengths[i] = (char)((length | n) + 12);
}
else {
lengths[i] = (char)n;
}
if (i < LINES_PER_GROUP_) {
offsets[i + 1] = (char)(offsets[i] + lengths[i]);
}
length = 0xffff;
i ++;
}
shift -= 4;
}
}
return stringoffset;
}
|
java
|
public int getGroupLengths(int index, char offsets[], char lengths[])
{
char length = 0xffff;
byte b = 0,
n = 0;
int shift;
index = index * m_groupsize_; // byte count offsets of group strings
int stringoffset = UCharacterUtility.toInt(
m_groupinfo_[index + OFFSET_HIGH_OFFSET_],
m_groupinfo_[index + OFFSET_LOW_OFFSET_]);
offsets[0] = 0;
// all 32 lengths must be read to get the offset of the first group
// string
for (int i = 0; i < LINES_PER_GROUP_; stringoffset ++) {
b = m_groupstring_[stringoffset];
shift = 4;
while (shift >= 0) {
// getting nibble
n = (byte)((b >> shift) & 0x0F);
if (length == 0xffff && n > SINGLE_NIBBLE_MAX_) {
length = (char)((n - 12) << 4);
}
else {
if (length != 0xffff) {
lengths[i] = (char)((length | n) + 12);
}
else {
lengths[i] = (char)n;
}
if (i < LINES_PER_GROUP_) {
offsets[i + 1] = (char)(offsets[i] + lengths[i]);
}
length = 0xffff;
i ++;
}
shift -= 4;
}
}
return stringoffset;
}
|
[
"public",
"int",
"getGroupLengths",
"(",
"int",
"index",
",",
"char",
"offsets",
"[",
"]",
",",
"char",
"lengths",
"[",
"]",
")",
"{",
"char",
"length",
"=",
"0xffff",
";",
"byte",
"b",
"=",
"0",
",",
"n",
"=",
"0",
";",
"int",
"shift",
";",
"index",
"=",
"index",
"*",
"m_groupsize_",
";",
"// byte count offsets of group strings",
"int",
"stringoffset",
"=",
"UCharacterUtility",
".",
"toInt",
"(",
"m_groupinfo_",
"[",
"index",
"+",
"OFFSET_HIGH_OFFSET_",
"]",
",",
"m_groupinfo_",
"[",
"index",
"+",
"OFFSET_LOW_OFFSET_",
"]",
")",
";",
"offsets",
"[",
"0",
"]",
"=",
"0",
";",
"// all 32 lengths must be read to get the offset of the first group",
"// string",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"LINES_PER_GROUP_",
";",
"stringoffset",
"++",
")",
"{",
"b",
"=",
"m_groupstring_",
"[",
"stringoffset",
"]",
";",
"shift",
"=",
"4",
";",
"while",
"(",
"shift",
">=",
"0",
")",
"{",
"// getting nibble",
"n",
"=",
"(",
"byte",
")",
"(",
"(",
"b",
">>",
"shift",
")",
"&",
"0x0F",
")",
";",
"if",
"(",
"length",
"==",
"0xffff",
"&&",
"n",
">",
"SINGLE_NIBBLE_MAX_",
")",
"{",
"length",
"=",
"(",
"char",
")",
"(",
"(",
"n",
"-",
"12",
")",
"<<",
"4",
")",
";",
"}",
"else",
"{",
"if",
"(",
"length",
"!=",
"0xffff",
")",
"{",
"lengths",
"[",
"i",
"]",
"=",
"(",
"char",
")",
"(",
"(",
"length",
"|",
"n",
")",
"+",
"12",
")",
";",
"}",
"else",
"{",
"lengths",
"[",
"i",
"]",
"=",
"(",
"char",
")",
"n",
";",
"}",
"if",
"(",
"i",
"<",
"LINES_PER_GROUP_",
")",
"{",
"offsets",
"[",
"i",
"+",
"1",
"]",
"=",
"(",
"char",
")",
"(",
"offsets",
"[",
"i",
"]",
"+",
"lengths",
"[",
"i",
"]",
")",
";",
"}",
"length",
"=",
"0xffff",
";",
"i",
"++",
";",
"}",
"shift",
"-=",
"4",
";",
"}",
"}",
"return",
"stringoffset",
";",
"}"
] |
Reads a block of compressed lengths of 32 strings and expands them into
offsets and lengths for each string. Lengths are stored with a
variable-width encoding in consecutive nibbles:
If a nibble<0xc, then it is the length itself (0 = empty string).
If a nibble>=0xc, then it forms a length value with the following
nibble.
The offsets and lengths arrays must be at least 33 (one more) long
because there is no check here at the end if the last nibble is still
used.
@param index of group string object in array
@param offsets array to store the value of the string offsets
@param lengths array to store the value of the string length
@return next index of the data string immediately after the lengths
in terms of byte address
|
[
"Reads",
"a",
"block",
"of",
"compressed",
"lengths",
"of",
"32",
"strings",
"and",
"expands",
"them",
"into",
"offsets",
"and",
"lengths",
"for",
"each",
"string",
".",
"Lengths",
"are",
"stored",
"with",
"a",
"variable",
"-",
"width",
"encoding",
"in",
"consecutive",
"nibbles",
":",
"If",
"a",
"nibble<0xc",
"then",
"it",
"is",
"the",
"length",
"itself",
"(",
"0",
"=",
"empty",
"string",
")",
".",
"If",
"a",
"nibble",
">",
"=",
"0xc",
"then",
"it",
"forms",
"a",
"length",
"value",
"with",
"the",
"following",
"nibble",
".",
"The",
"offsets",
"and",
"lengths",
"arrays",
"must",
"be",
"at",
"least",
"33",
"(",
"one",
"more",
")",
"long",
"because",
"there",
"is",
"no",
"check",
"here",
"at",
"the",
"end",
"if",
"the",
"last",
"nibble",
"is",
"still",
"used",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCharacterName.java#L177-L222
|
anotheria/configureme
|
src/main/java/org/configureme/sources/ConfigurationSourceKey.java
|
ConfigurationSourceKey.jsonFile
|
public static final ConfigurationSourceKey jsonFile(final String name) {
"""
Creates a new configuration source key for json files.
@param name name of the json file.
@return a new configuration source key instance for json files
"""
return new ConfigurationSourceKey(Type.FILE, Format.JSON, name);
}
|
java
|
public static final ConfigurationSourceKey jsonFile(final String name){
return new ConfigurationSourceKey(Type.FILE, Format.JSON, name);
}
|
[
"public",
"static",
"final",
"ConfigurationSourceKey",
"jsonFile",
"(",
"final",
"String",
"name",
")",
"{",
"return",
"new",
"ConfigurationSourceKey",
"(",
"Type",
".",
"FILE",
",",
"Format",
".",
"JSON",
",",
"name",
")",
";",
"}"
] |
Creates a new configuration source key for json files.
@param name name of the json file.
@return a new configuration source key instance for json files
|
[
"Creates",
"a",
"new",
"configuration",
"source",
"key",
"for",
"json",
"files",
"."
] |
train
|
https://github.com/anotheria/configureme/blob/1f52dd9109349623190586bdf5a592de8016e1fa/src/main/java/org/configureme/sources/ConfigurationSourceKey.java#L221-L223
|
kiegroup/drools
|
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/CompiledFEELSemanticMappings.java
|
CompiledFEELSemanticMappings.exists
|
public static Boolean exists(
EvaluationContext ctx,
Object tests,
Object target) {
"""
Returns true when at least one of the elements of the list matches the target.
The list may contain both objects (equals) and UnaryTests (apply)
"""
if (!(tests instanceof List)) {
if (tests == null) {
ctx.notifyEvt(() -> new ASTEventBase(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.IS_NULL, "value"), null));
return null;
}
return applyUnaryTest(ctx, tests, target);
}
for (Object test : (List) tests) {
Boolean r = applyUnaryTest(ctx, test, target);
if (Boolean.TRUE.equals(r)) {
return true;
}
}
return false;
}
|
java
|
public static Boolean exists(
EvaluationContext ctx,
Object tests,
Object target) {
if (!(tests instanceof List)) {
if (tests == null) {
ctx.notifyEvt(() -> new ASTEventBase(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.IS_NULL, "value"), null));
return null;
}
return applyUnaryTest(ctx, tests, target);
}
for (Object test : (List) tests) {
Boolean r = applyUnaryTest(ctx, test, target);
if (Boolean.TRUE.equals(r)) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"Boolean",
"exists",
"(",
"EvaluationContext",
"ctx",
",",
"Object",
"tests",
",",
"Object",
"target",
")",
"{",
"if",
"(",
"!",
"(",
"tests",
"instanceof",
"List",
")",
")",
"{",
"if",
"(",
"tests",
"==",
"null",
")",
"{",
"ctx",
".",
"notifyEvt",
"(",
"(",
")",
"->",
"new",
"ASTEventBase",
"(",
"FEELEvent",
".",
"Severity",
".",
"ERROR",
",",
"Msg",
".",
"createMessage",
"(",
"Msg",
".",
"IS_NULL",
",",
"\"value\"",
")",
",",
"null",
")",
")",
";",
"return",
"null",
";",
"}",
"return",
"applyUnaryTest",
"(",
"ctx",
",",
"tests",
",",
"target",
")",
";",
"}",
"for",
"(",
"Object",
"test",
":",
"(",
"List",
")",
"tests",
")",
"{",
"Boolean",
"r",
"=",
"applyUnaryTest",
"(",
"ctx",
",",
"test",
",",
"target",
")",
";",
"if",
"(",
"Boolean",
".",
"TRUE",
".",
"equals",
"(",
"r",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true when at least one of the elements of the list matches the target.
The list may contain both objects (equals) and UnaryTests (apply)
|
[
"Returns",
"true",
"when",
"at",
"least",
"one",
"of",
"the",
"elements",
"of",
"the",
"list",
"matches",
"the",
"target",
".",
"The",
"list",
"may",
"contain",
"both",
"objects",
"(",
"equals",
")",
"and",
"UnaryTests",
"(",
"apply",
")"
] |
train
|
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/codegen/feel11/CompiledFEELSemanticMappings.java#L109-L130
|
aws/aws-sdk-java
|
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java
|
AmazonS3Client.setBucketAcl
|
public void setBucketAcl(String bucketName, AccessControlList acl,
RequestMetricCollector requestMetricCollector) {
"""
Same as {@link #setBucketAcl(String, AccessControlList)}
but allows specifying a request metric collector.
"""
SetBucketAclRequest request = new SetBucketAclRequest(bucketName, acl)
.withRequestMetricCollector(requestMetricCollector);
setBucketAcl(request);
}
|
java
|
public void setBucketAcl(String bucketName, AccessControlList acl,
RequestMetricCollector requestMetricCollector) {
SetBucketAclRequest request = new SetBucketAclRequest(bucketName, acl)
.withRequestMetricCollector(requestMetricCollector);
setBucketAcl(request);
}
|
[
"public",
"void",
"setBucketAcl",
"(",
"String",
"bucketName",
",",
"AccessControlList",
"acl",
",",
"RequestMetricCollector",
"requestMetricCollector",
")",
"{",
"SetBucketAclRequest",
"request",
"=",
"new",
"SetBucketAclRequest",
"(",
"bucketName",
",",
"acl",
")",
".",
"withRequestMetricCollector",
"(",
"requestMetricCollector",
")",
";",
"setBucketAcl",
"(",
"request",
")",
";",
"}"
] |
Same as {@link #setBucketAcl(String, AccessControlList)}
but allows specifying a request metric collector.
|
[
"Same",
"as",
"{"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L1239-L1244
|
grails/grails-core
|
grails-web/src/main/groovy/org/grails/web/servlet/context/GrailsConfigUtils.java
|
GrailsConfigUtils.isConfigTrue
|
public static boolean isConfigTrue(GrailsApplication application, String propertyName) {
"""
Checks if a Config parameter is true or a System property with the same name is true
@param application
@param propertyName
@return true if the Config parameter is true or the System property with the same name is true
"""
return application.getConfig().getProperty(propertyName, Boolean.class, false);
}
|
java
|
public static boolean isConfigTrue(GrailsApplication application, String propertyName) {
return application.getConfig().getProperty(propertyName, Boolean.class, false);
}
|
[
"public",
"static",
"boolean",
"isConfigTrue",
"(",
"GrailsApplication",
"application",
",",
"String",
"propertyName",
")",
"{",
"return",
"application",
".",
"getConfig",
"(",
")",
".",
"getProperty",
"(",
"propertyName",
",",
"Boolean",
".",
"class",
",",
"false",
")",
";",
"}"
] |
Checks if a Config parameter is true or a System property with the same name is true
@param application
@param propertyName
@return true if the Config parameter is true or the System property with the same name is true
|
[
"Checks",
"if",
"a",
"Config",
"parameter",
"is",
"true",
"or",
"a",
"System",
"property",
"with",
"the",
"same",
"name",
"is",
"true"
] |
train
|
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web/src/main/groovy/org/grails/web/servlet/context/GrailsConfigUtils.java#L117-L119
|
codeprimate-software/cp-elements
|
src/main/java/org/cp/elements/data/conversion/provider/SimpleConversionService.java
|
SimpleConversionService.useDefault
|
protected boolean useDefault(Object value, Class<?> toType) {
"""
Determines whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@param value {@link Object value} to convert.
@param toType {@link Class type} to convert the {@link Object value} into.
@return a boolean value indicating whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@see #isDefaultValuesEnabled()
"""
return value == null && isDefaultValuesEnabled() && this.defaultValues.containsKey(toType);
}
|
java
|
protected boolean useDefault(Object value, Class<?> toType) {
return value == null && isDefaultValuesEnabled() && this.defaultValues.containsKey(toType);
}
|
[
"protected",
"boolean",
"useDefault",
"(",
"Object",
"value",
",",
"Class",
"<",
"?",
">",
"toType",
")",
"{",
"return",
"value",
"==",
"null",
"&&",
"isDefaultValuesEnabled",
"(",
")",
"&&",
"this",
".",
"defaultValues",
".",
"containsKey",
"(",
"toType",
")",
";",
"}"
] |
Determines whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@param value {@link Object value} to convert.
@param toType {@link Class type} to convert the {@link Object value} into.
@return a boolean value indicating whether the {@link Object default value} for the specified {@link Class type}
should be used as the converted {@link Object value} when the converted {@link Object value}
is {@literal null}.
@see #isDefaultValuesEnabled()
|
[
"Determines",
"whether",
"the",
"{",
"@link",
"Object",
"default",
"value",
"}",
"for",
"the",
"specified",
"{",
"@link",
"Class",
"type",
"}",
"should",
"be",
"used",
"as",
"the",
"converted",
"{",
"@link",
"Object",
"value",
"}",
"when",
"the",
"converted",
"{",
"@link",
"Object",
"value",
"}",
"is",
"{",
"@literal",
"null",
"}",
"."
] |
train
|
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/data/conversion/provider/SimpleConversionService.java#L406-L408
|
MariaDB/mariadb-connector-j
|
src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ClearPasswordPlugin.java
|
ClearPasswordPlugin.process
|
public Buffer process(PacketOutputStream out, PacketInputStream in, AtomicInteger sequence) throws IOException {
"""
Send password in clear text to server.
@param out out stream
@param in in stream
@param sequence packet sequence
@return response packet
@throws IOException if socket error
"""
if (password == null || password.isEmpty()) {
out.writeEmptyPacket(sequence.incrementAndGet());
} else {
out.startPacket(sequence.incrementAndGet());
byte[] bytePwd;
if (passwordCharacterEncoding != null && !passwordCharacterEncoding.isEmpty()) {
bytePwd = password.getBytes(passwordCharacterEncoding);
} else {
bytePwd = password.getBytes();
}
out.write(bytePwd);
out.write(0);
out.flush();
}
Buffer buffer = in.getPacket(true);
sequence.set(in.getLastPacketSeq());
return buffer;
}
|
java
|
public Buffer process(PacketOutputStream out, PacketInputStream in, AtomicInteger sequence) throws IOException {
if (password == null || password.isEmpty()) {
out.writeEmptyPacket(sequence.incrementAndGet());
} else {
out.startPacket(sequence.incrementAndGet());
byte[] bytePwd;
if (passwordCharacterEncoding != null && !passwordCharacterEncoding.isEmpty()) {
bytePwd = password.getBytes(passwordCharacterEncoding);
} else {
bytePwd = password.getBytes();
}
out.write(bytePwd);
out.write(0);
out.flush();
}
Buffer buffer = in.getPacket(true);
sequence.set(in.getLastPacketSeq());
return buffer;
}
|
[
"public",
"Buffer",
"process",
"(",
"PacketOutputStream",
"out",
",",
"PacketInputStream",
"in",
",",
"AtomicInteger",
"sequence",
")",
"throws",
"IOException",
"{",
"if",
"(",
"password",
"==",
"null",
"||",
"password",
".",
"isEmpty",
"(",
")",
")",
"{",
"out",
".",
"writeEmptyPacket",
"(",
"sequence",
".",
"incrementAndGet",
"(",
")",
")",
";",
"}",
"else",
"{",
"out",
".",
"startPacket",
"(",
"sequence",
".",
"incrementAndGet",
"(",
")",
")",
";",
"byte",
"[",
"]",
"bytePwd",
";",
"if",
"(",
"passwordCharacterEncoding",
"!=",
"null",
"&&",
"!",
"passwordCharacterEncoding",
".",
"isEmpty",
"(",
")",
")",
"{",
"bytePwd",
"=",
"password",
".",
"getBytes",
"(",
"passwordCharacterEncoding",
")",
";",
"}",
"else",
"{",
"bytePwd",
"=",
"password",
".",
"getBytes",
"(",
")",
";",
"}",
"out",
".",
"write",
"(",
"bytePwd",
")",
";",
"out",
".",
"write",
"(",
"0",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"Buffer",
"buffer",
"=",
"in",
".",
"getPacket",
"(",
"true",
")",
";",
"sequence",
".",
"set",
"(",
"in",
".",
"getLastPacketSeq",
"(",
")",
")",
";",
"return",
"buffer",
";",
"}"
] |
Send password in clear text to server.
@param out out stream
@param in in stream
@param sequence packet sequence
@return response packet
@throws IOException if socket error
|
[
"Send",
"password",
"in",
"clear",
"text",
"to",
"server",
"."
] |
train
|
https://github.com/MariaDB/mariadb-connector-j/blob/d148c7cd347c4680617be65d9e511b289d38a30b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/ClearPasswordPlugin.java#L87-L107
|
Netflix/astyanax
|
astyanax-thrift/src/main/java/com/netflix/astyanax/thrift/ThriftConverter.java
|
ThriftConverter.getPredicate
|
public static <C> SlicePredicate getPredicate(ColumnSlice<C> columns, Serializer<C> colSer) {
"""
Return a Hector SlicePredicate based on the provided column slice
@param <C>
@param columns
@param colSer
@return
"""
// Get all the columns
if (columns == null) {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false,
Integer.MAX_VALUE));
return predicate;
}
// Get a specific list of columns
if (columns.getColumns() != null) {
SlicePredicate predicate = new SlicePredicate();
predicate.setColumn_namesIsSet(true);
predicate.column_names = colSer.toBytesList(columns.getColumns());
return predicate;
}
else {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange((columns.getStartColumn() == null) ? ByteBuffer.wrap(new byte[0])
: ByteBuffer.wrap(colSer.toBytes(columns.getStartColumn())),
(columns.getEndColumn() == null) ? ByteBuffer.wrap(new byte[0]) : ByteBuffer.wrap(colSer
.toBytes(columns.getEndColumn())), columns.getReversed(), columns.getLimit()));
return predicate;
}
}
|
java
|
public static <C> SlicePredicate getPredicate(ColumnSlice<C> columns, Serializer<C> colSer) {
// Get all the columns
if (columns == null) {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange(ByteBuffer.wrap(new byte[0]), ByteBuffer.wrap(new byte[0]), false,
Integer.MAX_VALUE));
return predicate;
}
// Get a specific list of columns
if (columns.getColumns() != null) {
SlicePredicate predicate = new SlicePredicate();
predicate.setColumn_namesIsSet(true);
predicate.column_names = colSer.toBytesList(columns.getColumns());
return predicate;
}
else {
SlicePredicate predicate = new SlicePredicate();
predicate.setSlice_range(new SliceRange((columns.getStartColumn() == null) ? ByteBuffer.wrap(new byte[0])
: ByteBuffer.wrap(colSer.toBytes(columns.getStartColumn())),
(columns.getEndColumn() == null) ? ByteBuffer.wrap(new byte[0]) : ByteBuffer.wrap(colSer
.toBytes(columns.getEndColumn())), columns.getReversed(), columns.getLimit()));
return predicate;
}
}
|
[
"public",
"static",
"<",
"C",
">",
"SlicePredicate",
"getPredicate",
"(",
"ColumnSlice",
"<",
"C",
">",
"columns",
",",
"Serializer",
"<",
"C",
">",
"colSer",
")",
"{",
"// Get all the columns",
"if",
"(",
"columns",
"==",
"null",
")",
"{",
"SlicePredicate",
"predicate",
"=",
"new",
"SlicePredicate",
"(",
")",
";",
"predicate",
".",
"setSlice_range",
"(",
"new",
"SliceRange",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"0",
"]",
")",
",",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"0",
"]",
")",
",",
"false",
",",
"Integer",
".",
"MAX_VALUE",
")",
")",
";",
"return",
"predicate",
";",
"}",
"// Get a specific list of columns",
"if",
"(",
"columns",
".",
"getColumns",
"(",
")",
"!=",
"null",
")",
"{",
"SlicePredicate",
"predicate",
"=",
"new",
"SlicePredicate",
"(",
")",
";",
"predicate",
".",
"setColumn_namesIsSet",
"(",
"true",
")",
";",
"predicate",
".",
"column_names",
"=",
"colSer",
".",
"toBytesList",
"(",
"columns",
".",
"getColumns",
"(",
")",
")",
";",
"return",
"predicate",
";",
"}",
"else",
"{",
"SlicePredicate",
"predicate",
"=",
"new",
"SlicePredicate",
"(",
")",
";",
"predicate",
".",
"setSlice_range",
"(",
"new",
"SliceRange",
"(",
"(",
"columns",
".",
"getStartColumn",
"(",
")",
"==",
"null",
")",
"?",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"0",
"]",
")",
":",
"ByteBuffer",
".",
"wrap",
"(",
"colSer",
".",
"toBytes",
"(",
"columns",
".",
"getStartColumn",
"(",
")",
")",
")",
",",
"(",
"columns",
".",
"getEndColumn",
"(",
")",
"==",
"null",
")",
"?",
"ByteBuffer",
".",
"wrap",
"(",
"new",
"byte",
"[",
"0",
"]",
")",
":",
"ByteBuffer",
".",
"wrap",
"(",
"colSer",
".",
"toBytes",
"(",
"columns",
".",
"getEndColumn",
"(",
")",
")",
")",
",",
"columns",
".",
"getReversed",
"(",
")",
",",
"columns",
".",
"getLimit",
"(",
")",
")",
")",
";",
"return",
"predicate",
";",
"}",
"}"
] |
Return a Hector SlicePredicate based on the provided column slice
@param <C>
@param columns
@param colSer
@return
|
[
"Return",
"a",
"Hector",
"SlicePredicate",
"based",
"on",
"the",
"provided",
"column",
"slice"
] |
train
|
https://github.com/Netflix/astyanax/blob/bcc3fd26e2dda05a923751aa32b139f6209fecdf/astyanax-thrift/src/main/java/com/netflix/astyanax/thrift/ThriftConverter.java#L122-L145
|
Omertron/api-tvrage
|
src/main/java/com/omertron/tvrageapi/tools/TVRageParser.java
|
TVRageParser.processSeasonEpisodes
|
private static void processSeasonEpisodes(Element eEpisodeList, EpisodeList epList) {
"""
Process the episodes in the season and add them to the EpisodeList
@param eEpisodeList
@param epList
@return
"""
// Get the season number
String season = eEpisodeList.getAttribute("no");
NodeList nlEpisode = eEpisodeList.getElementsByTagName(EPISODE);
if (nlEpisode == null || nlEpisode.getLength() == 0) {
return;
}
for (int eLoop = 0; eLoop < nlEpisode.getLength(); eLoop++) {
Node nEpisode = nlEpisode.item(eLoop);
if (nEpisode.getNodeType() == Node.ELEMENT_NODE) {
epList.addEpisode(parseEpisode((Element) nEpisode, season));
}
}
}
|
java
|
private static void processSeasonEpisodes(Element eEpisodeList, EpisodeList epList) {
// Get the season number
String season = eEpisodeList.getAttribute("no");
NodeList nlEpisode = eEpisodeList.getElementsByTagName(EPISODE);
if (nlEpisode == null || nlEpisode.getLength() == 0) {
return;
}
for (int eLoop = 0; eLoop < nlEpisode.getLength(); eLoop++) {
Node nEpisode = nlEpisode.item(eLoop);
if (nEpisode.getNodeType() == Node.ELEMENT_NODE) {
epList.addEpisode(parseEpisode((Element) nEpisode, season));
}
}
}
|
[
"private",
"static",
"void",
"processSeasonEpisodes",
"(",
"Element",
"eEpisodeList",
",",
"EpisodeList",
"epList",
")",
"{",
"// Get the season number",
"String",
"season",
"=",
"eEpisodeList",
".",
"getAttribute",
"(",
"\"no\"",
")",
";",
"NodeList",
"nlEpisode",
"=",
"eEpisodeList",
".",
"getElementsByTagName",
"(",
"EPISODE",
")",
";",
"if",
"(",
"nlEpisode",
"==",
"null",
"||",
"nlEpisode",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"eLoop",
"=",
"0",
";",
"eLoop",
"<",
"nlEpisode",
".",
"getLength",
"(",
")",
";",
"eLoop",
"++",
")",
"{",
"Node",
"nEpisode",
"=",
"nlEpisode",
".",
"item",
"(",
"eLoop",
")",
";",
"if",
"(",
"nEpisode",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"epList",
".",
"addEpisode",
"(",
"parseEpisode",
"(",
"(",
"Element",
")",
"nEpisode",
",",
"season",
")",
")",
";",
"}",
"}",
"}"
] |
Process the episodes in the season and add them to the EpisodeList
@param eEpisodeList
@param epList
@return
|
[
"Process",
"the",
"episodes",
"in",
"the",
"season",
"and",
"add",
"them",
"to",
"the",
"EpisodeList"
] |
train
|
https://github.com/Omertron/api-tvrage/blob/4e805a99de812fabea69d97098f2376be14d51bc/src/main/java/com/omertron/tvrageapi/tools/TVRageParser.java#L133-L149
|
EdwardRaff/JSAT
|
JSAT/src/jsat/linear/RowColumnOps.java
|
RowColumnOps.fillRow
|
public static void fillRow(Matrix A, int i, int from, int to, double val) {
"""
Fills the values in a row of the matrix
@param A the matrix in question
@param i the row of the matrix
@param from the first column index to fill (inclusive)
@param to the last column index to fill (exclusive)
@param val the value to fill into the matrix
"""
for(int j = from; j < to; j++)
A.set(i, j, val);
}
|
java
|
public static void fillRow(Matrix A, int i, int from, int to, double val)
{
for(int j = from; j < to; j++)
A.set(i, j, val);
}
|
[
"public",
"static",
"void",
"fillRow",
"(",
"Matrix",
"A",
",",
"int",
"i",
",",
"int",
"from",
",",
"int",
"to",
",",
"double",
"val",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"from",
";",
"j",
"<",
"to",
";",
"j",
"++",
")",
"A",
".",
"set",
"(",
"i",
",",
"j",
",",
"val",
")",
";",
"}"
] |
Fills the values in a row of the matrix
@param A the matrix in question
@param i the row of the matrix
@param from the first column index to fill (inclusive)
@param to the last column index to fill (exclusive)
@param val the value to fill into the matrix
|
[
"Fills",
"the",
"values",
"in",
"a",
"row",
"of",
"the",
"matrix"
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/linear/RowColumnOps.java#L418-L422
|
michel-kraemer/bson4jackson
|
src/main/java/de/undercouch/bson4jackson/io/DynamicOutputBuffer.java
|
DynamicOutputBuffer.putByte
|
public void putByte(int pos, byte b) {
"""
Puts a byte into the buffer at the given position. Does
not increase the write position.
@param pos the position where to put the byte
@param b the byte to put
"""
adaptSize(pos + 1);
ByteBuffer bb = getBuffer(pos);
int i = pos % _bufferSize;
bb.put(i, b);
}
|
java
|
public void putByte(int pos, byte b) {
adaptSize(pos + 1);
ByteBuffer bb = getBuffer(pos);
int i = pos % _bufferSize;
bb.put(i, b);
}
|
[
"public",
"void",
"putByte",
"(",
"int",
"pos",
",",
"byte",
"b",
")",
"{",
"adaptSize",
"(",
"pos",
"+",
"1",
")",
";",
"ByteBuffer",
"bb",
"=",
"getBuffer",
"(",
"pos",
")",
";",
"int",
"i",
"=",
"pos",
"%",
"_bufferSize",
";",
"bb",
".",
"put",
"(",
"i",
",",
"b",
")",
";",
"}"
] |
Puts a byte into the buffer at the given position. Does
not increase the write position.
@param pos the position where to put the byte
@param b the byte to put
|
[
"Puts",
"a",
"byte",
"into",
"the",
"buffer",
"at",
"the",
"given",
"position",
".",
"Does",
"not",
"increase",
"the",
"write",
"position",
"."
] |
train
|
https://github.com/michel-kraemer/bson4jackson/blob/32d2ab3c516b3c07490fdfcf0c5e4ed0a2ee3979/src/main/java/de/undercouch/bson4jackson/io/DynamicOutputBuffer.java#L349-L354
|
biojava/biojava
|
biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java
|
KaplanMeierFigure.getSurvivalTimePercentile
|
public Double getSurvivalTimePercentile(String group, double percentile) {
"""
To get the median percentile for a particular group pass the value of
.50.
@param group
@param percentile
@return
"""
StrataInfo si = sfi.getStrataInfoHashMap().get(group);
ArrayList<Double> percentage = si.getSurv();
Integer percentileIndex = null;
for (int i = 0; i < percentage.size(); i++) {
if (percentage.get(i) == percentile) {
if (i + 1 < percentage.size()) {
percentileIndex = i + 1;
}
break;
} else if (percentage.get(i) < percentile) {
percentileIndex = i;
break;
}
}
if (percentileIndex != null) {
return si.getTime().get(percentileIndex);
} else {
return null;
}
}
|
java
|
public Double getSurvivalTimePercentile(String group, double percentile) {
StrataInfo si = sfi.getStrataInfoHashMap().get(group);
ArrayList<Double> percentage = si.getSurv();
Integer percentileIndex = null;
for (int i = 0; i < percentage.size(); i++) {
if (percentage.get(i) == percentile) {
if (i + 1 < percentage.size()) {
percentileIndex = i + 1;
}
break;
} else if (percentage.get(i) < percentile) {
percentileIndex = i;
break;
}
}
if (percentileIndex != null) {
return si.getTime().get(percentileIndex);
} else {
return null;
}
}
|
[
"public",
"Double",
"getSurvivalTimePercentile",
"(",
"String",
"group",
",",
"double",
"percentile",
")",
"{",
"StrataInfo",
"si",
"=",
"sfi",
".",
"getStrataInfoHashMap",
"(",
")",
".",
"get",
"(",
"group",
")",
";",
"ArrayList",
"<",
"Double",
">",
"percentage",
"=",
"si",
".",
"getSurv",
"(",
")",
";",
"Integer",
"percentileIndex",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"percentage",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"percentage",
".",
"get",
"(",
"i",
")",
"==",
"percentile",
")",
"{",
"if",
"(",
"i",
"+",
"1",
"<",
"percentage",
".",
"size",
"(",
")",
")",
"{",
"percentileIndex",
"=",
"i",
"+",
"1",
";",
"}",
"break",
";",
"}",
"else",
"if",
"(",
"percentage",
".",
"get",
"(",
"i",
")",
"<",
"percentile",
")",
"{",
"percentileIndex",
"=",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"percentileIndex",
"!=",
"null",
")",
"{",
"return",
"si",
".",
"getTime",
"(",
")",
".",
"get",
"(",
"percentileIndex",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
To get the median percentile for a particular group pass the value of
.50.
@param group
@param percentile
@return
|
[
"To",
"get",
"the",
"median",
"percentile",
"for",
"a",
"particular",
"group",
"pass",
"the",
"value",
"of",
".",
"50",
"."
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/kaplanmeier/figure/KaplanMeierFigure.java#L105-L126
|
jillesvangurp/jsonj
|
src/main/java/com/github/jsonj/JsonArray.java
|
JsonArray.replaceObject
|
public boolean replaceObject(JsonObject e1, JsonObject e2, String...path) {
"""
Convenient replace method that allows you to replace an object based on field equality for a specified field.
Useful if you have an id field in your objects. Note, the array may contain non objects as well or objects
without the specified field. Those elements won't be replaced of course.
@param e1 object you want replaced; must have a value at the specified path
@param e2 replacement
@param path path
@return true if something was replaced.
"""
JsonElement compareElement = e1.get(path);
if(compareElement == null) {
throw new IllegalArgumentException("specified path may not be null in object " + StringUtils.join(path));
}
int i=0;
for(JsonElement e: this) {
if(e.isObject()) {
JsonElement fieldValue = e.asObject().get(path);
if(compareElement.equals(fieldValue)) {
set(i,e2);
return true;
}
}
i++;
}
return false;
}
|
java
|
public boolean replaceObject(JsonObject e1, JsonObject e2, String...path) {
JsonElement compareElement = e1.get(path);
if(compareElement == null) {
throw new IllegalArgumentException("specified path may not be null in object " + StringUtils.join(path));
}
int i=0;
for(JsonElement e: this) {
if(e.isObject()) {
JsonElement fieldValue = e.asObject().get(path);
if(compareElement.equals(fieldValue)) {
set(i,e2);
return true;
}
}
i++;
}
return false;
}
|
[
"public",
"boolean",
"replaceObject",
"(",
"JsonObject",
"e1",
",",
"JsonObject",
"e2",
",",
"String",
"...",
"path",
")",
"{",
"JsonElement",
"compareElement",
"=",
"e1",
".",
"get",
"(",
"path",
")",
";",
"if",
"(",
"compareElement",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"specified path may not be null in object \"",
"+",
"StringUtils",
".",
"join",
"(",
"path",
")",
")",
";",
"}",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"JsonElement",
"e",
":",
"this",
")",
"{",
"if",
"(",
"e",
".",
"isObject",
"(",
")",
")",
"{",
"JsonElement",
"fieldValue",
"=",
"e",
".",
"asObject",
"(",
")",
".",
"get",
"(",
"path",
")",
";",
"if",
"(",
"compareElement",
".",
"equals",
"(",
"fieldValue",
")",
")",
"{",
"set",
"(",
"i",
",",
"e2",
")",
";",
"return",
"true",
";",
"}",
"}",
"i",
"++",
";",
"}",
"return",
"false",
";",
"}"
] |
Convenient replace method that allows you to replace an object based on field equality for a specified field.
Useful if you have an id field in your objects. Note, the array may contain non objects as well or objects
without the specified field. Those elements won't be replaced of course.
@param e1 object you want replaced; must have a value at the specified path
@param e2 replacement
@param path path
@return true if something was replaced.
|
[
"Convenient",
"replace",
"method",
"that",
"allows",
"you",
"to",
"replace",
"an",
"object",
"based",
"on",
"field",
"equality",
"for",
"a",
"specified",
"field",
".",
"Useful",
"if",
"you",
"have",
"an",
"id",
"field",
"in",
"your",
"objects",
".",
"Note",
"the",
"array",
"may",
"contain",
"non",
"objects",
"as",
"well",
"or",
"objects",
"without",
"the",
"specified",
"field",
".",
"Those",
"elements",
"won",
"t",
"be",
"replaced",
"of",
"course",
"."
] |
train
|
https://github.com/jillesvangurp/jsonj/blob/1da0c44c5bdb60c0cd806c48d2da5a8a75bf84af/src/main/java/com/github/jsonj/JsonArray.java#L603-L620
|
eFaps/eFaps-Kernel
|
src/main/java/org/efaps/admin/datamodel/Type.java
|
Type.hasAccess
|
public boolean hasAccess(final Instance _instance,
final AccessType _accessType)
throws EFapsException {
"""
Checks, if the current context user has all access defined in the list of
access types for the given instance.
@param _instance instance for which the access must be checked
@param _accessType list of access types which must be checked
@throws EFapsException on error
@return true if user has access, else false
"""
return hasAccess(_instance, _accessType, null);
}
|
java
|
public boolean hasAccess(final Instance _instance,
final AccessType _accessType)
throws EFapsException
{
return hasAccess(_instance, _accessType, null);
}
|
[
"public",
"boolean",
"hasAccess",
"(",
"final",
"Instance",
"_instance",
",",
"final",
"AccessType",
"_accessType",
")",
"throws",
"EFapsException",
"{",
"return",
"hasAccess",
"(",
"_instance",
",",
"_accessType",
",",
"null",
")",
";",
"}"
] |
Checks, if the current context user has all access defined in the list of
access types for the given instance.
@param _instance instance for which the access must be checked
@param _accessType list of access types which must be checked
@throws EFapsException on error
@return true if user has access, else false
|
[
"Checks",
"if",
"the",
"current",
"context",
"user",
"has",
"all",
"access",
"defined",
"in",
"the",
"list",
"of",
"access",
"types",
"for",
"the",
"given",
"instance",
"."
] |
train
|
https://github.com/eFaps/eFaps-Kernel/blob/04b96548f518c2386a93f5ec2b9349f9b9063859/src/main/java/org/efaps/admin/datamodel/Type.java#L697-L702
|
TheHortonMachine/hortonmachine
|
gears/src/main/java/org/hortonmachine/gears/io/las/utils/LasUtils.java
|
LasUtils.tofeature
|
public static SimpleFeature tofeature( LasRecord r, Integer featureId, CoordinateReferenceSystem crs ) {
"""
Convert a record to a feature.
@param r the record to convert.
@param featureId an optional feature id, if not available, the id is set to -1.
@param crs the crs to apply.
@return the feature.
"""
final Point point = toGeometry(r);
double elev = r.z;
if (!Double.isNaN(r.groundElevation)) {
elev = r.groundElevation;
}
if (featureId == null) {
featureId = -1;
}
final Object[] values = new Object[]{point, featureId, elev, r.intensity, r.classification, r.returnNumber,
r.numberOfReturns};
SimpleFeatureBuilder lasFeatureBuilder = getLasFeatureBuilder(crs);
lasFeatureBuilder.addAll(values);
final SimpleFeature feature = lasFeatureBuilder.buildFeature(null);
return feature;
}
|
java
|
public static SimpleFeature tofeature( LasRecord r, Integer featureId, CoordinateReferenceSystem crs ) {
final Point point = toGeometry(r);
double elev = r.z;
if (!Double.isNaN(r.groundElevation)) {
elev = r.groundElevation;
}
if (featureId == null) {
featureId = -1;
}
final Object[] values = new Object[]{point, featureId, elev, r.intensity, r.classification, r.returnNumber,
r.numberOfReturns};
SimpleFeatureBuilder lasFeatureBuilder = getLasFeatureBuilder(crs);
lasFeatureBuilder.addAll(values);
final SimpleFeature feature = lasFeatureBuilder.buildFeature(null);
return feature;
}
|
[
"public",
"static",
"SimpleFeature",
"tofeature",
"(",
"LasRecord",
"r",
",",
"Integer",
"featureId",
",",
"CoordinateReferenceSystem",
"crs",
")",
"{",
"final",
"Point",
"point",
"=",
"toGeometry",
"(",
"r",
")",
";",
"double",
"elev",
"=",
"r",
".",
"z",
";",
"if",
"(",
"!",
"Double",
".",
"isNaN",
"(",
"r",
".",
"groundElevation",
")",
")",
"{",
"elev",
"=",
"r",
".",
"groundElevation",
";",
"}",
"if",
"(",
"featureId",
"==",
"null",
")",
"{",
"featureId",
"=",
"-",
"1",
";",
"}",
"final",
"Object",
"[",
"]",
"values",
"=",
"new",
"Object",
"[",
"]",
"{",
"point",
",",
"featureId",
",",
"elev",
",",
"r",
".",
"intensity",
",",
"r",
".",
"classification",
",",
"r",
".",
"returnNumber",
",",
"r",
".",
"numberOfReturns",
"}",
";",
"SimpleFeatureBuilder",
"lasFeatureBuilder",
"=",
"getLasFeatureBuilder",
"(",
"crs",
")",
";",
"lasFeatureBuilder",
".",
"addAll",
"(",
"values",
")",
";",
"final",
"SimpleFeature",
"feature",
"=",
"lasFeatureBuilder",
".",
"buildFeature",
"(",
"null",
")",
";",
"return",
"feature",
";",
"}"
] |
Convert a record to a feature.
@param r the record to convert.
@param featureId an optional feature id, if not available, the id is set to -1.
@param crs the crs to apply.
@return the feature.
|
[
"Convert",
"a",
"record",
"to",
"a",
"feature",
"."
] |
train
|
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/las/utils/LasUtils.java#L161-L176
|
apache/flink
|
flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java
|
ExecutionConfig.registerTypeWithKryoSerializer
|
@SuppressWarnings("rawtypes")
public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) {
"""
Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use.
"""
if (type == null || serializerClass == null) {
throw new NullPointerException("Cannot register null class or serializer.");
}
@SuppressWarnings("unchecked")
Class<? extends Serializer<?>> castedSerializerClass = (Class<? extends Serializer<?>>) serializerClass;
registeredTypesWithKryoSerializerClasses.put(type, castedSerializerClass);
}
|
java
|
@SuppressWarnings("rawtypes")
public void registerTypeWithKryoSerializer(Class<?> type, Class<? extends Serializer> serializerClass) {
if (type == null || serializerClass == null) {
throw new NullPointerException("Cannot register null class or serializer.");
}
@SuppressWarnings("unchecked")
Class<? extends Serializer<?>> castedSerializerClass = (Class<? extends Serializer<?>>) serializerClass;
registeredTypesWithKryoSerializerClasses.put(type, castedSerializerClass);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"void",
"registerTypeWithKryoSerializer",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"Class",
"<",
"?",
"extends",
"Serializer",
">",
"serializerClass",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"||",
"serializerClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Cannot register null class or serializer.\"",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"?",
"extends",
"Serializer",
"<",
"?",
">",
">",
"castedSerializerClass",
"=",
"(",
"Class",
"<",
"?",
"extends",
"Serializer",
"<",
"?",
">",
">",
")",
"serializerClass",
";",
"registeredTypesWithKryoSerializerClasses",
".",
"put",
"(",
"type",
",",
"castedSerializerClass",
")",
";",
"}"
] |
Registers the given Serializer via its class as a serializer for the given type at the KryoSerializer
@param type The class of the types serialized with the given serializer.
@param serializerClass The class of the serializer to use.
|
[
"Registers",
"the",
"given",
"Serializer",
"via",
"its",
"class",
"as",
"a",
"serializer",
"for",
"the",
"given",
"type",
"at",
"the",
"KryoSerializer"
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/ExecutionConfig.java#L812-L821
|
netty/netty
|
codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java
|
HttpUtil.getCharset
|
public static Charset getCharset(CharSequence contentTypeValue) {
"""
Fetch charset from Content-Type header value.
@param contentTypeValue Content-Type header value to parse
@return the charset from message's Content-Type header or {@link CharsetUtil#ISO_8859_1}
if charset is not presented or unparsable
"""
if (contentTypeValue != null) {
return getCharset(contentTypeValue, CharsetUtil.ISO_8859_1);
} else {
return CharsetUtil.ISO_8859_1;
}
}
|
java
|
public static Charset getCharset(CharSequence contentTypeValue) {
if (contentTypeValue != null) {
return getCharset(contentTypeValue, CharsetUtil.ISO_8859_1);
} else {
return CharsetUtil.ISO_8859_1;
}
}
|
[
"public",
"static",
"Charset",
"getCharset",
"(",
"CharSequence",
"contentTypeValue",
")",
"{",
"if",
"(",
"contentTypeValue",
"!=",
"null",
")",
"{",
"return",
"getCharset",
"(",
"contentTypeValue",
",",
"CharsetUtil",
".",
"ISO_8859_1",
")",
";",
"}",
"else",
"{",
"return",
"CharsetUtil",
".",
"ISO_8859_1",
";",
"}",
"}"
] |
Fetch charset from Content-Type header value.
@param contentTypeValue Content-Type header value to parse
@return the charset from message's Content-Type header or {@link CharsetUtil#ISO_8859_1}
if charset is not presented or unparsable
|
[
"Fetch",
"charset",
"from",
"Content",
"-",
"Type",
"header",
"value",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java#L355-L361
|
Whiley/WhileyCompiler
|
src/main/java/wyil/interpreter/Interpreter.java
|
Interpreter.executeStatement
|
private Status executeStatement(Stmt stmt, CallStack frame, EnclosingScope scope) {
"""
Execute a statement at a given point in the function or method body
@param stmt
--- The statement to be executed
@param frame
--- The current stack frame
@return
"""
switch (stmt.getOpcode()) {
case WyilFile.STMT_assert:
return executeAssert((Stmt.Assert) stmt, frame, scope);
case WyilFile.STMT_assume:
return executeAssume((Stmt.Assume) stmt, frame, scope);
case WyilFile.STMT_assign:
return executeAssign((Stmt.Assign) stmt, frame, scope);
case WyilFile.STMT_break:
return executeBreak((Stmt.Break) stmt, frame, scope);
case WyilFile.STMT_continue:
return executeContinue((Stmt.Continue) stmt, frame, scope);
case WyilFile.STMT_debug:
return executeDebug((Stmt.Debug) stmt, frame, scope);
case WyilFile.STMT_dowhile:
return executeDoWhile((Stmt.DoWhile) stmt, frame, scope);
case WyilFile.STMT_fail:
return executeFail((Stmt.Fail) stmt, frame, scope);
case WyilFile.STMT_if:
case WyilFile.STMT_ifelse:
return executeIf((Stmt.IfElse) stmt, frame, scope);
case WyilFile.EXPR_indirectinvoke:
executeIndirectInvoke((Expr.IndirectInvoke) stmt, frame);
return Status.NEXT;
case WyilFile.EXPR_invoke:
executeInvoke((Expr.Invoke) stmt, frame);
return Status.NEXT;
case WyilFile.STMT_namedblock:
return executeNamedBlock((Stmt.NamedBlock) stmt, frame, scope);
case WyilFile.STMT_while:
return executeWhile((Stmt.While) stmt, frame, scope);
case WyilFile.STMT_return:
return executeReturn((Stmt.Return) stmt, frame, scope);
case WyilFile.STMT_skip:
return executeSkip((Stmt.Skip) stmt, frame, scope);
case WyilFile.STMT_switch:
return executeSwitch((Stmt.Switch) stmt, frame, scope);
case WyilFile.DECL_variableinitialiser:
case WyilFile.DECL_variable:
return executeVariableDeclaration((Decl.Variable) stmt, frame);
}
deadCode(stmt);
return null; // deadcode
}
|
java
|
private Status executeStatement(Stmt stmt, CallStack frame, EnclosingScope scope) {
switch (stmt.getOpcode()) {
case WyilFile.STMT_assert:
return executeAssert((Stmt.Assert) stmt, frame, scope);
case WyilFile.STMT_assume:
return executeAssume((Stmt.Assume) stmt, frame, scope);
case WyilFile.STMT_assign:
return executeAssign((Stmt.Assign) stmt, frame, scope);
case WyilFile.STMT_break:
return executeBreak((Stmt.Break) stmt, frame, scope);
case WyilFile.STMT_continue:
return executeContinue((Stmt.Continue) stmt, frame, scope);
case WyilFile.STMT_debug:
return executeDebug((Stmt.Debug) stmt, frame, scope);
case WyilFile.STMT_dowhile:
return executeDoWhile((Stmt.DoWhile) stmt, frame, scope);
case WyilFile.STMT_fail:
return executeFail((Stmt.Fail) stmt, frame, scope);
case WyilFile.STMT_if:
case WyilFile.STMT_ifelse:
return executeIf((Stmt.IfElse) stmt, frame, scope);
case WyilFile.EXPR_indirectinvoke:
executeIndirectInvoke((Expr.IndirectInvoke) stmt, frame);
return Status.NEXT;
case WyilFile.EXPR_invoke:
executeInvoke((Expr.Invoke) stmt, frame);
return Status.NEXT;
case WyilFile.STMT_namedblock:
return executeNamedBlock((Stmt.NamedBlock) stmt, frame, scope);
case WyilFile.STMT_while:
return executeWhile((Stmt.While) stmt, frame, scope);
case WyilFile.STMT_return:
return executeReturn((Stmt.Return) stmt, frame, scope);
case WyilFile.STMT_skip:
return executeSkip((Stmt.Skip) stmt, frame, scope);
case WyilFile.STMT_switch:
return executeSwitch((Stmt.Switch) stmt, frame, scope);
case WyilFile.DECL_variableinitialiser:
case WyilFile.DECL_variable:
return executeVariableDeclaration((Decl.Variable) stmt, frame);
}
deadCode(stmt);
return null; // deadcode
}
|
[
"private",
"Status",
"executeStatement",
"(",
"Stmt",
"stmt",
",",
"CallStack",
"frame",
",",
"EnclosingScope",
"scope",
")",
"{",
"switch",
"(",
"stmt",
".",
"getOpcode",
"(",
")",
")",
"{",
"case",
"WyilFile",
".",
"STMT_assert",
":",
"return",
"executeAssert",
"(",
"(",
"Stmt",
".",
"Assert",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_assume",
":",
"return",
"executeAssume",
"(",
"(",
"Stmt",
".",
"Assume",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_assign",
":",
"return",
"executeAssign",
"(",
"(",
"Stmt",
".",
"Assign",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_break",
":",
"return",
"executeBreak",
"(",
"(",
"Stmt",
".",
"Break",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_continue",
":",
"return",
"executeContinue",
"(",
"(",
"Stmt",
".",
"Continue",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_debug",
":",
"return",
"executeDebug",
"(",
"(",
"Stmt",
".",
"Debug",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_dowhile",
":",
"return",
"executeDoWhile",
"(",
"(",
"Stmt",
".",
"DoWhile",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_fail",
":",
"return",
"executeFail",
"(",
"(",
"Stmt",
".",
"Fail",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_if",
":",
"case",
"WyilFile",
".",
"STMT_ifelse",
":",
"return",
"executeIf",
"(",
"(",
"Stmt",
".",
"IfElse",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"EXPR_indirectinvoke",
":",
"executeIndirectInvoke",
"(",
"(",
"Expr",
".",
"IndirectInvoke",
")",
"stmt",
",",
"frame",
")",
";",
"return",
"Status",
".",
"NEXT",
";",
"case",
"WyilFile",
".",
"EXPR_invoke",
":",
"executeInvoke",
"(",
"(",
"Expr",
".",
"Invoke",
")",
"stmt",
",",
"frame",
")",
";",
"return",
"Status",
".",
"NEXT",
";",
"case",
"WyilFile",
".",
"STMT_namedblock",
":",
"return",
"executeNamedBlock",
"(",
"(",
"Stmt",
".",
"NamedBlock",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_while",
":",
"return",
"executeWhile",
"(",
"(",
"Stmt",
".",
"While",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_return",
":",
"return",
"executeReturn",
"(",
"(",
"Stmt",
".",
"Return",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_skip",
":",
"return",
"executeSkip",
"(",
"(",
"Stmt",
".",
"Skip",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"STMT_switch",
":",
"return",
"executeSwitch",
"(",
"(",
"Stmt",
".",
"Switch",
")",
"stmt",
",",
"frame",
",",
"scope",
")",
";",
"case",
"WyilFile",
".",
"DECL_variableinitialiser",
":",
"case",
"WyilFile",
".",
"DECL_variable",
":",
"return",
"executeVariableDeclaration",
"(",
"(",
"Decl",
".",
"Variable",
")",
"stmt",
",",
"frame",
")",
";",
"}",
"deadCode",
"(",
"stmt",
")",
";",
"return",
"null",
";",
"// deadcode",
"}"
] |
Execute a statement at a given point in the function or method body
@param stmt
--- The statement to be executed
@param frame
--- The current stack frame
@return
|
[
"Execute",
"a",
"statement",
"at",
"a",
"given",
"point",
"in",
"the",
"function",
"or",
"method",
"body"
] |
train
|
https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/interpreter/Interpreter.java#L183-L227
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/HttpCookie.java
|
HttpCookie.guessCookieVersion
|
private static int guessCookieVersion(String header) {
"""
/*
try to guess the cookie version through set-cookie header string
"""
int version = 0;
header = header.toLowerCase();
if (header.indexOf("expires=") != -1) {
// only netscape cookie using 'expires'
version = 0;
} else if (header.indexOf("version=") != -1) {
// version is mandatory for rfc 2965/2109 cookie
version = 1;
} else if (header.indexOf("max-age") != -1) {
// rfc 2965/2109 use 'max-age'
version = 1;
} else if (startsWithIgnoreCase(header, SET_COOKIE2)) {
// only rfc 2965 cookie starts with 'set-cookie2'
version = 1;
}
return version;
}
|
java
|
private static int guessCookieVersion(String header) {
int version = 0;
header = header.toLowerCase();
if (header.indexOf("expires=") != -1) {
// only netscape cookie using 'expires'
version = 0;
} else if (header.indexOf("version=") != -1) {
// version is mandatory for rfc 2965/2109 cookie
version = 1;
} else if (header.indexOf("max-age") != -1) {
// rfc 2965/2109 use 'max-age'
version = 1;
} else if (startsWithIgnoreCase(header, SET_COOKIE2)) {
// only rfc 2965 cookie starts with 'set-cookie2'
version = 1;
}
return version;
}
|
[
"private",
"static",
"int",
"guessCookieVersion",
"(",
"String",
"header",
")",
"{",
"int",
"version",
"=",
"0",
";",
"header",
"=",
"header",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"header",
".",
"indexOf",
"(",
"\"expires=\"",
")",
"!=",
"-",
"1",
")",
"{",
"// only netscape cookie using 'expires'",
"version",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"header",
".",
"indexOf",
"(",
"\"version=\"",
")",
"!=",
"-",
"1",
")",
"{",
"// version is mandatory for rfc 2965/2109 cookie",
"version",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"header",
".",
"indexOf",
"(",
"\"max-age\"",
")",
"!=",
"-",
"1",
")",
"{",
"// rfc 2965/2109 use 'max-age'",
"version",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"startsWithIgnoreCase",
"(",
"header",
",",
"SET_COOKIE2",
")",
")",
"{",
"// only rfc 2965 cookie starts with 'set-cookie2'",
"version",
"=",
"1",
";",
"}",
"return",
"version",
";",
"}"
] |
/*
try to guess the cookie version through set-cookie header string
|
[
"/",
"*",
"try",
"to",
"guess",
"the",
"cookie",
"version",
"through",
"set",
"-",
"cookie",
"header",
"string"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/HttpCookie.java#L1202-L1221
|
DARIAH-DE/shib-http-client
|
src/main/java/de/tudarmstadt/ukp/shibhttpclient/Utils.java
|
Utils.unmarshallMessage
|
static XMLObject unmarshallMessage(ParserPool parserPool, InputStream messageStream)
throws ClientProtocolException {
"""
Helper method that deserializes and unmarshalls the message from the given stream. This
method has been adapted from {@code org.opensaml.ws.message.decoder.BaseMessageDecoder}.
@param messageStream
input stream containing the message
@return the inbound message
@throws MessageDecodingException
thrown if there is a problem deserializing and unmarshalling the message
"""
try {
Document messageDoc = parserPool.parse(messageStream);
Element messageElem = messageDoc.getDocumentElement();
Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(
messageElem);
if (unmarshaller == null) {
throw new ClientProtocolException(
"Unable to unmarshall message, no unmarshaller registered for message element "
+ XMLHelper.getNodeQName(messageElem));
}
XMLObject message = unmarshaller.unmarshall(messageElem);
return message;
}
catch (XMLParserException e) {
throw new ClientProtocolException(
"Encountered error parsing message into its DOM representation", e);
}
catch (UnmarshallingException e) {
throw new ClientProtocolException(
"Encountered error unmarshalling message from its DOM representation", e);
}
}
|
java
|
static XMLObject unmarshallMessage(ParserPool parserPool, InputStream messageStream)
throws ClientProtocolException
{
try {
Document messageDoc = parserPool.parse(messageStream);
Element messageElem = messageDoc.getDocumentElement();
Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(
messageElem);
if (unmarshaller == null) {
throw new ClientProtocolException(
"Unable to unmarshall message, no unmarshaller registered for message element "
+ XMLHelper.getNodeQName(messageElem));
}
XMLObject message = unmarshaller.unmarshall(messageElem);
return message;
}
catch (XMLParserException e) {
throw new ClientProtocolException(
"Encountered error parsing message into its DOM representation", e);
}
catch (UnmarshallingException e) {
throw new ClientProtocolException(
"Encountered error unmarshalling message from its DOM representation", e);
}
}
|
[
"static",
"XMLObject",
"unmarshallMessage",
"(",
"ParserPool",
"parserPool",
",",
"InputStream",
"messageStream",
")",
"throws",
"ClientProtocolException",
"{",
"try",
"{",
"Document",
"messageDoc",
"=",
"parserPool",
".",
"parse",
"(",
"messageStream",
")",
";",
"Element",
"messageElem",
"=",
"messageDoc",
".",
"getDocumentElement",
"(",
")",
";",
"Unmarshaller",
"unmarshaller",
"=",
"Configuration",
".",
"getUnmarshallerFactory",
"(",
")",
".",
"getUnmarshaller",
"(",
"messageElem",
")",
";",
"if",
"(",
"unmarshaller",
"==",
"null",
")",
"{",
"throw",
"new",
"ClientProtocolException",
"(",
"\"Unable to unmarshall message, no unmarshaller registered for message element \"",
"+",
"XMLHelper",
".",
"getNodeQName",
"(",
"messageElem",
")",
")",
";",
"}",
"XMLObject",
"message",
"=",
"unmarshaller",
".",
"unmarshall",
"(",
"messageElem",
")",
";",
"return",
"message",
";",
"}",
"catch",
"(",
"XMLParserException",
"e",
")",
"{",
"throw",
"new",
"ClientProtocolException",
"(",
"\"Encountered error parsing message into its DOM representation\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"UnmarshallingException",
"e",
")",
"{",
"throw",
"new",
"ClientProtocolException",
"(",
"\"Encountered error unmarshalling message from its DOM representation\"",
",",
"e",
")",
";",
"}",
"}"
] |
Helper method that deserializes and unmarshalls the message from the given stream. This
method has been adapted from {@code org.opensaml.ws.message.decoder.BaseMessageDecoder}.
@param messageStream
input stream containing the message
@return the inbound message
@throws MessageDecodingException
thrown if there is a problem deserializing and unmarshalling the message
|
[
"Helper",
"method",
"that",
"deserializes",
"and",
"unmarshalls",
"the",
"message",
"from",
"the",
"given",
"stream",
".",
"This",
"method",
"has",
"been",
"adapted",
"from",
"{",
"@code",
"org",
".",
"opensaml",
".",
"ws",
".",
"message",
".",
"decoder",
".",
"BaseMessageDecoder",
"}",
"."
] |
train
|
https://github.com/DARIAH-DE/shib-http-client/blob/32b7ec769751c42283f4a2f96b58bd152d931137/src/main/java/de/tudarmstadt/ukp/shibhttpclient/Utils.java#L68-L95
|
cesarferreira/AndroidQuickUtils
|
library/src/main/java/quickutils/core/categories/security.java
|
security.calculateMD5
|
public static String calculateMD5(String string) {
"""
Calculate the MD5 of a given String
@param string
String to be MD5'ed
@return MD5'ed String
"""
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Huh, UTF-8 should be supported?", e);
}
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
int i = (b & 0xFF);
if (i < 0x10)
hex.append('0');
hex.append(Integer.toHexString(i));
}
return hex.toString();
}
|
java
|
public static String calculateMD5(String string) {
byte[] hash;
try {
hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Huh, MD5 should be supported?", e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Huh, UTF-8 should be supported?", e);
}
StringBuilder hex = new StringBuilder(hash.length * 2);
for (byte b : hash) {
int i = (b & 0xFF);
if (i < 0x10)
hex.append('0');
hex.append(Integer.toHexString(i));
}
return hex.toString();
}
|
[
"public",
"static",
"String",
"calculateMD5",
"(",
"String",
"string",
")",
"{",
"byte",
"[",
"]",
"hash",
";",
"try",
"{",
"hash",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
".",
"digest",
"(",
"string",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Huh, MD5 should be supported?\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Huh, UTF-8 should be supported?\"",
",",
"e",
")",
";",
"}",
"StringBuilder",
"hex",
"=",
"new",
"StringBuilder",
"(",
"hash",
".",
"length",
"*",
"2",
")",
";",
"for",
"(",
"byte",
"b",
":",
"hash",
")",
"{",
"int",
"i",
"=",
"(",
"b",
"&",
"0xFF",
")",
";",
"if",
"(",
"i",
"<",
"0x10",
")",
"hex",
".",
"append",
"(",
"'",
"'",
")",
";",
"hex",
".",
"append",
"(",
"Integer",
".",
"toHexString",
"(",
"i",
")",
")",
";",
"}",
"return",
"hex",
".",
"toString",
"(",
")",
";",
"}"
] |
Calculate the MD5 of a given String
@param string
String to be MD5'ed
@return MD5'ed String
|
[
"Calculate",
"the",
"MD5",
"of",
"a",
"given",
"String"
] |
train
|
https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/categories/security.java#L124-L145
|
nguillaumin/slick2d-maven
|
slick2d-core/src/main/java/org/newdawn/slick/Image.java
|
Image.getColor
|
public Color getColor(int x, int y) {
"""
Get the colour of a pixel at a specified location in this image
@param x The x coordinate of the pixel
@param y The y coordinate of the pixel
@return The Color of the pixel at the specified location
"""
if (pixelData == null) {
pixelData = texture.getTextureData();
}
int xo = (int) (textureOffsetX * texture.getTextureWidth());
int yo = (int) (textureOffsetY * texture.getTextureHeight());
if (textureWidth < 0) {
x = xo - x;
} else {
x = xo + x;
}
if (textureHeight < 0) {
y = yo - y;
} else {
y = yo + y;
}
// Clamp to texture dimensions
x %= texture.getTextureWidth();
y %= texture.getTextureHeight();
int offset = x + (y * texture.getTextureWidth());
offset *= texture.hasAlpha() ? 4 : 3;
if (texture.hasAlpha()) {
return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
translate(pixelData[offset+2]),translate(pixelData[offset+3]));
} else {
return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
translate(pixelData[offset+2]));
}
}
|
java
|
public Color getColor(int x, int y) {
if (pixelData == null) {
pixelData = texture.getTextureData();
}
int xo = (int) (textureOffsetX * texture.getTextureWidth());
int yo = (int) (textureOffsetY * texture.getTextureHeight());
if (textureWidth < 0) {
x = xo - x;
} else {
x = xo + x;
}
if (textureHeight < 0) {
y = yo - y;
} else {
y = yo + y;
}
// Clamp to texture dimensions
x %= texture.getTextureWidth();
y %= texture.getTextureHeight();
int offset = x + (y * texture.getTextureWidth());
offset *= texture.hasAlpha() ? 4 : 3;
if (texture.hasAlpha()) {
return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
translate(pixelData[offset+2]),translate(pixelData[offset+3]));
} else {
return new Color(translate(pixelData[offset]),translate(pixelData[offset+1]),
translate(pixelData[offset+2]));
}
}
|
[
"public",
"Color",
"getColor",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"if",
"(",
"pixelData",
"==",
"null",
")",
"{",
"pixelData",
"=",
"texture",
".",
"getTextureData",
"(",
")",
";",
"}",
"int",
"xo",
"=",
"(",
"int",
")",
"(",
"textureOffsetX",
"*",
"texture",
".",
"getTextureWidth",
"(",
")",
")",
";",
"int",
"yo",
"=",
"(",
"int",
")",
"(",
"textureOffsetY",
"*",
"texture",
".",
"getTextureHeight",
"(",
")",
")",
";",
"if",
"(",
"textureWidth",
"<",
"0",
")",
"{",
"x",
"=",
"xo",
"-",
"x",
";",
"}",
"else",
"{",
"x",
"=",
"xo",
"+",
"x",
";",
"}",
"if",
"(",
"textureHeight",
"<",
"0",
")",
"{",
"y",
"=",
"yo",
"-",
"y",
";",
"}",
"else",
"{",
"y",
"=",
"yo",
"+",
"y",
";",
"}",
"// Clamp to texture dimensions\r",
"x",
"%=",
"texture",
".",
"getTextureWidth",
"(",
")",
";",
"y",
"%=",
"texture",
".",
"getTextureHeight",
"(",
")",
";",
"int",
"offset",
"=",
"x",
"+",
"(",
"y",
"*",
"texture",
".",
"getTextureWidth",
"(",
")",
")",
";",
"offset",
"*=",
"texture",
".",
"hasAlpha",
"(",
")",
"?",
"4",
":",
"3",
";",
"if",
"(",
"texture",
".",
"hasAlpha",
"(",
")",
")",
"{",
"return",
"new",
"Color",
"(",
"translate",
"(",
"pixelData",
"[",
"offset",
"]",
")",
",",
"translate",
"(",
"pixelData",
"[",
"offset",
"+",
"1",
"]",
")",
",",
"translate",
"(",
"pixelData",
"[",
"offset",
"+",
"2",
"]",
")",
",",
"translate",
"(",
"pixelData",
"[",
"offset",
"+",
"3",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Color",
"(",
"translate",
"(",
"pixelData",
"[",
"offset",
"]",
")",
",",
"translate",
"(",
"pixelData",
"[",
"offset",
"+",
"1",
"]",
")",
",",
"translate",
"(",
"pixelData",
"[",
"offset",
"+",
"2",
"]",
")",
")",
";",
"}",
"}"
] |
Get the colour of a pixel at a specified location in this image
@param x The x coordinate of the pixel
@param y The y coordinate of the pixel
@return The Color of the pixel at the specified location
|
[
"Get",
"the",
"colour",
"of",
"a",
"pixel",
"at",
"a",
"specified",
"location",
"in",
"this",
"image"
] |
train
|
https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/org/newdawn/slick/Image.java#L1366-L1402
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.org.apache.cxf.cxf.rt.rs.client.3.2/src/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
|
JAXRSClientFactoryBean.setHeaders
|
public void setHeaders(Map<String, String> map) {
"""
Sets the headers new proxy or WebClient instances will be
initialized with.
@param map the headers
"""
headers = new MetadataMap<String, String>();
for (Map.Entry<String, String> entry : map.entrySet()) {
String[] values = entry.getValue().split(",");
for (String v : values) {
if (v.length() != 0) {
headers.add(entry.getKey(), v);
}
}
}
}
|
java
|
public void setHeaders(Map<String, String> map) {
headers = new MetadataMap<String, String>();
for (Map.Entry<String, String> entry : map.entrySet()) {
String[] values = entry.getValue().split(",");
for (String v : values) {
if (v.length() != 0) {
headers.add(entry.getKey(), v);
}
}
}
}
|
[
"public",
"void",
"setHeaders",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"{",
"headers",
"=",
"new",
"MetadataMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"[",
"]",
"values",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"split",
"(",
"\",\"",
")",
";",
"for",
"(",
"String",
"v",
":",
"values",
")",
"{",
"if",
"(",
"v",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"headers",
".",
"add",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"v",
")",
";",
"}",
"}",
"}",
"}"
] |
Sets the headers new proxy or WebClient instances will be
initialized with.
@param map the headers
|
[
"Sets",
"the",
"headers",
"new",
"proxy",
"or",
"WebClient",
"instances",
"will",
"be",
"initialized",
"with",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.org.apache.cxf.cxf.rt.rs.client.3.2/src/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java#L187-L197
|
lkwg82/enforcer-rules
|
src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java
|
RequirePluginVersions.resolvePlugin
|
protected Plugin resolvePlugin( Plugin plugin, MavenProject project ) {
"""
Resolve plugin.
@param plugin the plugin
@param project the project
@return the plugin
"""
@SuppressWarnings( "unchecked" )
List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories();
Artifact artifact =
factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(),
VersionRange.createFromVersion( "LATEST" ) );
try
{
this.resolver.resolve( artifact, pluginRepositories, this.local );
plugin.setVersion( artifact.getVersion() );
}
catch ( ArtifactResolutionException e )
{
}
catch ( ArtifactNotFoundException e )
{
}
return plugin;
}
|
java
|
protected Plugin resolvePlugin( Plugin plugin, MavenProject project )
{
@SuppressWarnings( "unchecked" )
List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories();
Artifact artifact =
factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(),
VersionRange.createFromVersion( "LATEST" ) );
try
{
this.resolver.resolve( artifact, pluginRepositories, this.local );
plugin.setVersion( artifact.getVersion() );
}
catch ( ArtifactResolutionException e )
{
}
catch ( ArtifactNotFoundException e )
{
}
return plugin;
}
|
[
"protected",
"Plugin",
"resolvePlugin",
"(",
"Plugin",
"plugin",
",",
"MavenProject",
"project",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"List",
"<",
"ArtifactRepository",
">",
"pluginRepositories",
"=",
"project",
".",
"getPluginArtifactRepositories",
"(",
")",
";",
"Artifact",
"artifact",
"=",
"factory",
".",
"createPluginArtifact",
"(",
"plugin",
".",
"getGroupId",
"(",
")",
",",
"plugin",
".",
"getArtifactId",
"(",
")",
",",
"VersionRange",
".",
"createFromVersion",
"(",
"\"LATEST\"",
")",
")",
";",
"try",
"{",
"this",
".",
"resolver",
".",
"resolve",
"(",
"artifact",
",",
"pluginRepositories",
",",
"this",
".",
"local",
")",
";",
"plugin",
".",
"setVersion",
"(",
"artifact",
".",
"getVersion",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ArtifactResolutionException",
"e",
")",
"{",
"}",
"catch",
"(",
"ArtifactNotFoundException",
"e",
")",
"{",
"}",
"return",
"plugin",
";",
"}"
] |
Resolve plugin.
@param plugin the plugin
@param project the project
@return the plugin
|
[
"Resolve",
"plugin",
"."
] |
train
|
https://github.com/lkwg82/enforcer-rules/blob/fa2d309af7907b17fc8eaf386f8056d77b654749/src/main/java/org/apache/maven/plugins/enforcer/RequirePluginVersions.java#L554-L576
|
couchbase/couchbase-java-client
|
src/main/java/com/couchbase/client/java/util/Blocking.java
|
Blocking.blockForSingle
|
public static <T> T blockForSingle(final Observable<? extends T> observable, final long timeout,
final TimeUnit tu) {
"""
Blocks on an {@link Observable} and returns a single event or throws an {@link Exception}.
Note that when this method is used, only the first item emitted will be returned. The caller needs to make
sure that the source {@link Observable} only ever returns a single item (or none). The {@link BlockingObservable}
code applies different operators like single, last, first and more, these need to be applied manually.
This code is based on {@link BlockingObservable#blockForSingle}, but does not wait forever. Instead, it
utilizes the internal {@link CountDownLatch} to optimize the timeout case, with less GC and CPU overhead
than chaining in an {@link Observable#timeout(long, TimeUnit)} operator.
If an error happens inside the {@link Observable}, it will be raised as an {@link Exception}. If the timeout
kicks in, a {@link TimeoutException} nested in a {@link RuntimeException} is thrown to be fully compatible
with the {@link Observable#timeout(long, TimeUnit)} behavior.
@param observable the source {@link Observable}
@param timeout the maximum timeout before an exception is thrown.
@param tu the timeout unit.
@param <T> the type returned.
@return the extracted value from the {@link Observable} or throws in an error case.
"""
final CountDownLatch latch = new CountDownLatch(1);
TrackingSubscriber<T> subscriber = new TrackingSubscriber<T>(latch);
Subscription subscription = observable.subscribe(subscriber);
try {
if (!latch.await(timeout, tu)) {
if (!subscription.isUnsubscribed()) {
subscription.unsubscribe();
}
throw new RuntimeException(new TimeoutException());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while waiting for subscription to complete.", e);
}
if (subscriber.returnException() != null) {
if (subscriber.returnException() instanceof RuntimeException) {
throw (RuntimeException) subscriber.returnException();
} else {
throw new RuntimeException(subscriber.returnException());
}
}
return subscriber.returnItem();
}
|
java
|
public static <T> T blockForSingle(final Observable<? extends T> observable, final long timeout,
final TimeUnit tu) {
final CountDownLatch latch = new CountDownLatch(1);
TrackingSubscriber<T> subscriber = new TrackingSubscriber<T>(latch);
Subscription subscription = observable.subscribe(subscriber);
try {
if (!latch.await(timeout, tu)) {
if (!subscription.isUnsubscribed()) {
subscription.unsubscribe();
}
throw new RuntimeException(new TimeoutException());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while waiting for subscription to complete.", e);
}
if (subscriber.returnException() != null) {
if (subscriber.returnException() instanceof RuntimeException) {
throw (RuntimeException) subscriber.returnException();
} else {
throw new RuntimeException(subscriber.returnException());
}
}
return subscriber.returnItem();
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"blockForSingle",
"(",
"final",
"Observable",
"<",
"?",
"extends",
"T",
">",
"observable",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"tu",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"TrackingSubscriber",
"<",
"T",
">",
"subscriber",
"=",
"new",
"TrackingSubscriber",
"<",
"T",
">",
"(",
"latch",
")",
";",
"Subscription",
"subscription",
"=",
"observable",
".",
"subscribe",
"(",
"subscriber",
")",
";",
"try",
"{",
"if",
"(",
"!",
"latch",
".",
"await",
"(",
"timeout",
",",
"tu",
")",
")",
"{",
"if",
"(",
"!",
"subscription",
".",
"isUnsubscribed",
"(",
")",
")",
"{",
"subscription",
".",
"unsubscribe",
"(",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"new",
"TimeoutException",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Interrupted while waiting for subscription to complete.\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"subscriber",
".",
"returnException",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"subscriber",
".",
"returnException",
"(",
")",
"instanceof",
"RuntimeException",
")",
"{",
"throw",
"(",
"RuntimeException",
")",
"subscriber",
".",
"returnException",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"subscriber",
".",
"returnException",
"(",
")",
")",
";",
"}",
"}",
"return",
"subscriber",
".",
"returnItem",
"(",
")",
";",
"}"
] |
Blocks on an {@link Observable} and returns a single event or throws an {@link Exception}.
Note that when this method is used, only the first item emitted will be returned. The caller needs to make
sure that the source {@link Observable} only ever returns a single item (or none). The {@link BlockingObservable}
code applies different operators like single, last, first and more, these need to be applied manually.
This code is based on {@link BlockingObservable#blockForSingle}, but does not wait forever. Instead, it
utilizes the internal {@link CountDownLatch} to optimize the timeout case, with less GC and CPU overhead
than chaining in an {@link Observable#timeout(long, TimeUnit)} operator.
If an error happens inside the {@link Observable}, it will be raised as an {@link Exception}. If the timeout
kicks in, a {@link TimeoutException} nested in a {@link RuntimeException} is thrown to be fully compatible
with the {@link Observable#timeout(long, TimeUnit)} behavior.
@param observable the source {@link Observable}
@param timeout the maximum timeout before an exception is thrown.
@param tu the timeout unit.
@param <T> the type returned.
@return the extracted value from the {@link Observable} or throws in an error case.
|
[
"Blocks",
"on",
"an",
"{",
"@link",
"Observable",
"}",
"and",
"returns",
"a",
"single",
"event",
"or",
"throws",
"an",
"{",
"@link",
"Exception",
"}",
"."
] |
train
|
https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/util/Blocking.java#L65-L93
|
google/j2objc
|
jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/InnerNodeImpl.java
|
InnerNodeImpl.matchesNameOrWildcard
|
private static boolean matchesNameOrWildcard(String pattern, String s) {
"""
Returns true if {@code pattern} equals either "*" or {@code s}. Pattern
may be {@code null}.
"""
return "*".equals(pattern) || Objects.equal(pattern, s);
}
|
java
|
private static boolean matchesNameOrWildcard(String pattern, String s) {
return "*".equals(pattern) || Objects.equal(pattern, s);
}
|
[
"private",
"static",
"boolean",
"matchesNameOrWildcard",
"(",
"String",
"pattern",
",",
"String",
"s",
")",
"{",
"return",
"\"*\"",
".",
"equals",
"(",
"pattern",
")",
"||",
"Objects",
".",
"equal",
"(",
"pattern",
",",
"s",
")",
";",
"}"
] |
Returns true if {@code pattern} equals either "*" or {@code s}. Pattern
may be {@code null}.
|
[
"Returns",
"true",
"if",
"{"
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/main/java/org/apache/harmony/xml/dom/InnerNodeImpl.java#L264-L266
|
jeremylong/DependencyCheck
|
core/src/main/java/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.java
|
DependencyCheckScanAgent.showSummary
|
public static void showSummary(String projectName, Dependency[] dependencies) {
"""
Generates a warning message listing a summary of dependencies and their
associated CPE and CVE entries.
@param projectName the name of the project
@param dependencies a list of dependency objects
"""
final StringBuilder summary = new StringBuilder();
for (Dependency d : dependencies) {
final String ids = d.getVulnerabilities(true).stream()
.map(v -> v.getName())
.collect(Collectors.joining(", "));
if (ids.length() > 0) {
summary.append(d.getFileName()).append(" (");
summary.append(Stream.concat(d.getSoftwareIdentifiers().stream(), d.getVulnerableSoftwareIdentifiers().stream())
.map(i -> i.getValue())
.collect(Collectors.joining(", ")));
summary.append(") : ").append(ids).append(NEW_LINE);
}
}
if (summary.length() > 0) {
if (projectName == null || projectName.isEmpty()) {
LOGGER.warn("\n\nOne or more dependencies were identified with known vulnerabilities:\n\n{}\n\n"
+ "See the dependency-check report for more details.\n\n",
summary.toString());
} else {
LOGGER.warn("\n\nOne or more dependencies were identified with known vulnerabilities in {}:\n\n{}\n\n"
+ "See the dependency-check report for more details.\n\n",
projectName,
summary.toString());
}
}
}
|
java
|
public static void showSummary(String projectName, Dependency[] dependencies) {
final StringBuilder summary = new StringBuilder();
for (Dependency d : dependencies) {
final String ids = d.getVulnerabilities(true).stream()
.map(v -> v.getName())
.collect(Collectors.joining(", "));
if (ids.length() > 0) {
summary.append(d.getFileName()).append(" (");
summary.append(Stream.concat(d.getSoftwareIdentifiers().stream(), d.getVulnerableSoftwareIdentifiers().stream())
.map(i -> i.getValue())
.collect(Collectors.joining(", ")));
summary.append(") : ").append(ids).append(NEW_LINE);
}
}
if (summary.length() > 0) {
if (projectName == null || projectName.isEmpty()) {
LOGGER.warn("\n\nOne or more dependencies were identified with known vulnerabilities:\n\n{}\n\n"
+ "See the dependency-check report for more details.\n\n",
summary.toString());
} else {
LOGGER.warn("\n\nOne or more dependencies were identified with known vulnerabilities in {}:\n\n{}\n\n"
+ "See the dependency-check report for more details.\n\n",
projectName,
summary.toString());
}
}
}
|
[
"public",
"static",
"void",
"showSummary",
"(",
"String",
"projectName",
",",
"Dependency",
"[",
"]",
"dependencies",
")",
"{",
"final",
"StringBuilder",
"summary",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Dependency",
"d",
":",
"dependencies",
")",
"{",
"final",
"String",
"ids",
"=",
"d",
".",
"getVulnerabilities",
"(",
"true",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"v",
"->",
"v",
".",
"getName",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
")",
")",
";",
"if",
"(",
"ids",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"summary",
".",
"append",
"(",
"d",
".",
"getFileName",
"(",
")",
")",
".",
"append",
"(",
"\" (\"",
")",
";",
"summary",
".",
"append",
"(",
"Stream",
".",
"concat",
"(",
"d",
".",
"getSoftwareIdentifiers",
"(",
")",
".",
"stream",
"(",
")",
",",
"d",
".",
"getVulnerableSoftwareIdentifiers",
"(",
")",
".",
"stream",
"(",
")",
")",
".",
"map",
"(",
"i",
"->",
"i",
".",
"getValue",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
")",
")",
")",
";",
"summary",
".",
"append",
"(",
"\") : \"",
")",
".",
"append",
"(",
"ids",
")",
".",
"append",
"(",
"NEW_LINE",
")",
";",
"}",
"}",
"if",
"(",
"summary",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"if",
"(",
"projectName",
"==",
"null",
"||",
"projectName",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"\\n\\nOne or more dependencies were identified with known vulnerabilities:\\n\\n{}\\n\\n\"",
"+",
"\"See the dependency-check report for more details.\\n\\n\"",
",",
"summary",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"\\n\\nOne or more dependencies were identified with known vulnerabilities in {}:\\n\\n{}\\n\\n\"",
"+",
"\"See the dependency-check report for more details.\\n\\n\"",
",",
"projectName",
",",
"summary",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Generates a warning message listing a summary of dependencies and their
associated CPE and CVE entries.
@param projectName the name of the project
@param dependencies a list of dependency objects
|
[
"Generates",
"a",
"warning",
"message",
"listing",
"a",
"summary",
"of",
"dependencies",
"and",
"their",
"associated",
"CPE",
"and",
"CVE",
"entries",
"."
] |
train
|
https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/agent/DependencyCheckScanAgent.java#L1045-L1071
|
sothawo/mapjfx
|
src/main/java/com/sothawo/mapjfx/Extent.java
|
Extent.forCoordinates
|
public static Extent forCoordinates(Collection<? extends Coordinate> coordinates) {
"""
creates the extent of the given coordinates.
@param coordinates
the coordinates
@return Extent for the coorinates
@throws java.lang.IllegalArgumentException
when less than 2 coordinates or null are passed in
@throws NullPointerException
when coordinates is null
"""
requireNonNull(coordinates);
if (coordinates.size() < 2) {
throw new IllegalArgumentException();
}
double minLatitude = Double.MAX_VALUE;
double maxLatitude = -Double.MAX_VALUE;
double minLongitude = Double.MAX_VALUE;
double maxLongitude = -Double.MAX_VALUE;
for (Coordinate coordinate : coordinates) {
minLatitude = Math.min(minLatitude, coordinate.getLatitude());
maxLatitude = Math.max(maxLatitude, coordinate.getLatitude());
minLongitude = Math.min(minLongitude, coordinate.getLongitude());
maxLongitude = Math.max(maxLongitude, coordinate.getLongitude());
}
return new Extent(new Coordinate(minLatitude, minLongitude), new Coordinate(maxLatitude, maxLongitude));
}
|
java
|
public static Extent forCoordinates(Collection<? extends Coordinate> coordinates) {
requireNonNull(coordinates);
if (coordinates.size() < 2) {
throw new IllegalArgumentException();
}
double minLatitude = Double.MAX_VALUE;
double maxLatitude = -Double.MAX_VALUE;
double minLongitude = Double.MAX_VALUE;
double maxLongitude = -Double.MAX_VALUE;
for (Coordinate coordinate : coordinates) {
minLatitude = Math.min(minLatitude, coordinate.getLatitude());
maxLatitude = Math.max(maxLatitude, coordinate.getLatitude());
minLongitude = Math.min(minLongitude, coordinate.getLongitude());
maxLongitude = Math.max(maxLongitude, coordinate.getLongitude());
}
return new Extent(new Coordinate(minLatitude, minLongitude), new Coordinate(maxLatitude, maxLongitude));
}
|
[
"public",
"static",
"Extent",
"forCoordinates",
"(",
"Collection",
"<",
"?",
"extends",
"Coordinate",
">",
"coordinates",
")",
"{",
"requireNonNull",
"(",
"coordinates",
")",
";",
"if",
"(",
"coordinates",
".",
"size",
"(",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"double",
"minLatitude",
"=",
"Double",
".",
"MAX_VALUE",
";",
"double",
"maxLatitude",
"=",
"-",
"Double",
".",
"MAX_VALUE",
";",
"double",
"minLongitude",
"=",
"Double",
".",
"MAX_VALUE",
";",
"double",
"maxLongitude",
"=",
"-",
"Double",
".",
"MAX_VALUE",
";",
"for",
"(",
"Coordinate",
"coordinate",
":",
"coordinates",
")",
"{",
"minLatitude",
"=",
"Math",
".",
"min",
"(",
"minLatitude",
",",
"coordinate",
".",
"getLatitude",
"(",
")",
")",
";",
"maxLatitude",
"=",
"Math",
".",
"max",
"(",
"maxLatitude",
",",
"coordinate",
".",
"getLatitude",
"(",
")",
")",
";",
"minLongitude",
"=",
"Math",
".",
"min",
"(",
"minLongitude",
",",
"coordinate",
".",
"getLongitude",
"(",
")",
")",
";",
"maxLongitude",
"=",
"Math",
".",
"max",
"(",
"maxLongitude",
",",
"coordinate",
".",
"getLongitude",
"(",
")",
")",
";",
"}",
"return",
"new",
"Extent",
"(",
"new",
"Coordinate",
"(",
"minLatitude",
",",
"minLongitude",
")",
",",
"new",
"Coordinate",
"(",
"maxLatitude",
",",
"maxLongitude",
")",
")",
";",
"}"
] |
creates the extent of the given coordinates.
@param coordinates
the coordinates
@return Extent for the coorinates
@throws java.lang.IllegalArgumentException
when less than 2 coordinates or null are passed in
@throws NullPointerException
when coordinates is null
|
[
"creates",
"the",
"extent",
"of",
"the",
"given",
"coordinates",
"."
] |
train
|
https://github.com/sothawo/mapjfx/blob/202091de492ab7a8b000c77efd833029f7f0ef92/src/main/java/com/sothawo/mapjfx/Extent.java#L64-L81
|
JOML-CI/JOML
|
src/org/joml/Matrix4x3f.java
|
Matrix4x3f.rotateLocalY
|
public Matrix4x3f rotateLocalY(float ang, Matrix4x3f dest) {
"""
Pre-multiply a rotation around the Y axis to this matrix by rotating the given amount of radians
about the Y axis and store the result in <code>dest</code>.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix,
then the new matrix will be <code>R * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>R * M * v</code>, the
rotation will be applied last!
<p>
In order to set the matrix to a rotation matrix without pre-multiplying the rotation
transformation, use {@link #rotationY(float) rotationY()}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle">http://en.wikipedia.org</a>
@see #rotationY(float)
@param ang
the angle in radians to rotate about the Y axis
@param dest
will hold the result
@return dest
"""
float sin = (float) Math.sin(ang);
float cos = (float) Math.cosFromSin(sin, ang);
float nm00 = cos * m00 + sin * m02;
float nm02 = -sin * m00 + cos * m02;
float nm10 = cos * m10 + sin * m12;
float nm12 = -sin * m10 + cos * m12;
float nm20 = cos * m20 + sin * m22;
float nm22 = -sin * m20 + cos * m22;
float nm30 = cos * m30 + sin * m32;
float nm32 = -sin * m30 + cos * m32;
dest._m00(nm00);
dest._m01(m01);
dest._m02(nm02);
dest._m10(nm10);
dest._m11(m11);
dest._m12(nm12);
dest._m20(nm20);
dest._m21(m21);
dest._m22(nm22);
dest._m30(nm30);
dest._m31(m31);
dest._m32(nm32);
dest.properties = properties & ~(PROPERTY_IDENTITY | PROPERTY_TRANSLATION);
return dest;
}
|
java
|
public Matrix4x3f rotateLocalY(float ang, Matrix4x3f dest) {
float sin = (float) Math.sin(ang);
float cos = (float) Math.cosFromSin(sin, ang);
float nm00 = cos * m00 + sin * m02;
float nm02 = -sin * m00 + cos * m02;
float nm10 = cos * m10 + sin * m12;
float nm12 = -sin * m10 + cos * m12;
float nm20 = cos * m20 + sin * m22;
float nm22 = -sin * m20 + cos * m22;
float nm30 = cos * m30 + sin * m32;
float nm32 = -sin * m30 + cos * m32;
dest._m00(nm00);
dest._m01(m01);
dest._m02(nm02);
dest._m10(nm10);
dest._m11(m11);
dest._m12(nm12);
dest._m20(nm20);
dest._m21(m21);
dest._m22(nm22);
dest._m30(nm30);
dest._m31(m31);
dest._m32(nm32);
dest.properties = properties & ~(PROPERTY_IDENTITY | PROPERTY_TRANSLATION);
return dest;
}
|
[
"public",
"Matrix4x3f",
"rotateLocalY",
"(",
"float",
"ang",
",",
"Matrix4x3f",
"dest",
")",
"{",
"float",
"sin",
"=",
"(",
"float",
")",
"Math",
".",
"sin",
"(",
"ang",
")",
";",
"float",
"cos",
"=",
"(",
"float",
")",
"Math",
".",
"cosFromSin",
"(",
"sin",
",",
"ang",
")",
";",
"float",
"nm00",
"=",
"cos",
"*",
"m00",
"+",
"sin",
"*",
"m02",
";",
"float",
"nm02",
"=",
"-",
"sin",
"*",
"m00",
"+",
"cos",
"*",
"m02",
";",
"float",
"nm10",
"=",
"cos",
"*",
"m10",
"+",
"sin",
"*",
"m12",
";",
"float",
"nm12",
"=",
"-",
"sin",
"*",
"m10",
"+",
"cos",
"*",
"m12",
";",
"float",
"nm20",
"=",
"cos",
"*",
"m20",
"+",
"sin",
"*",
"m22",
";",
"float",
"nm22",
"=",
"-",
"sin",
"*",
"m20",
"+",
"cos",
"*",
"m22",
";",
"float",
"nm30",
"=",
"cos",
"*",
"m30",
"+",
"sin",
"*",
"m32",
";",
"float",
"nm32",
"=",
"-",
"sin",
"*",
"m30",
"+",
"cos",
"*",
"m32",
";",
"dest",
".",
"_m00",
"(",
"nm00",
")",
";",
"dest",
".",
"_m01",
"(",
"m01",
")",
";",
"dest",
".",
"_m02",
"(",
"nm02",
")",
";",
"dest",
".",
"_m10",
"(",
"nm10",
")",
";",
"dest",
".",
"_m11",
"(",
"m11",
")",
";",
"dest",
".",
"_m12",
"(",
"nm12",
")",
";",
"dest",
".",
"_m20",
"(",
"nm20",
")",
";",
"dest",
".",
"_m21",
"(",
"m21",
")",
";",
"dest",
".",
"_m22",
"(",
"nm22",
")",
";",
"dest",
".",
"_m30",
"(",
"nm30",
")",
";",
"dest",
".",
"_m31",
"(",
"m31",
")",
";",
"dest",
".",
"_m32",
"(",
"nm32",
")",
";",
"dest",
".",
"properties",
"=",
"properties",
"&",
"~",
"(",
"PROPERTY_IDENTITY",
"|",
"PROPERTY_TRANSLATION",
")",
";",
"return",
"dest",
";",
"}"
] |
Pre-multiply a rotation around the Y axis to this matrix by rotating the given amount of radians
about the Y axis and store the result in <code>dest</code>.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix,
then the new matrix will be <code>R * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>R * M * v</code>, the
rotation will be applied last!
<p>
In order to set the matrix to a rotation matrix without pre-multiplying the rotation
transformation, use {@link #rotationY(float) rotationY()}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle">http://en.wikipedia.org</a>
@see #rotationY(float)
@param ang
the angle in radians to rotate about the Y axis
@param dest
will hold the result
@return dest
|
[
"Pre",
"-",
"multiply",
"a",
"rotation",
"around",
"the",
"Y",
"axis",
"to",
"this",
"matrix",
"by",
"rotating",
"the",
"given",
"amount",
"of",
"radians",
"about",
"the",
"Y",
"axis",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"R<",
"/",
"code",
">",
"the",
"rotation",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"R",
"*",
"M<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"R",
"*",
"M",
"*",
"v<",
"/",
"code",
">",
"the",
"rotation",
"will",
"be",
"applied",
"last!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"rotation",
"matrix",
"without",
"pre",
"-",
"multiplying",
"the",
"rotation",
"transformation",
"use",
"{",
"@link",
"#rotationY",
"(",
"float",
")",
"rotationY",
"()",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rotation_matrix#Rotation_matrix_from_axis_and_angle",
">",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org<",
"/",
"a",
">"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L4324-L4349
|
Jasig/spring-portlet-contrib
|
spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java
|
CommonsPortlet2MultipartResolver.resolveMultipart
|
public MultipartResourceRequest resolveMultipart(final ResourceRequest request) throws MultipartException {
"""
<p>resolveMultipart.</p>
@param request a {@link javax.portlet.ResourceRequest} object.
@return a {@link org.jasig.springframework.web.portlet.upload.MultipartResourceRequest} object.
@throws org.springframework.web.multipart.MultipartException if any.
"""
Assert.notNull(request, "Request must not be null");
if (this.resolveLazily) {
return new DefaultMultipartResourceRequest(request) {
@Override
protected void initializeMultipart() {
MultipartParsingResult parsingResult = parseRequest(request);
setMultipartFiles(parsingResult.getMultipartFiles());
setMultipartParameters(parsingResult.getMultipartParameters());
setMultipartParameterContentTypes(parsingResult.getMultipartParameterContentTypes());
}
};
} else {
MultipartParsingResult parsingResult = parseRequest(request);
return new DefaultMultipartResourceRequest(request, parsingResult.getMultipartFiles(),
parsingResult.getMultipartParameters(), parsingResult.getMultipartParameterContentTypes());
}
}
|
java
|
public MultipartResourceRequest resolveMultipart(final ResourceRequest request) throws MultipartException {
Assert.notNull(request, "Request must not be null");
if (this.resolveLazily) {
return new DefaultMultipartResourceRequest(request) {
@Override
protected void initializeMultipart() {
MultipartParsingResult parsingResult = parseRequest(request);
setMultipartFiles(parsingResult.getMultipartFiles());
setMultipartParameters(parsingResult.getMultipartParameters());
setMultipartParameterContentTypes(parsingResult.getMultipartParameterContentTypes());
}
};
} else {
MultipartParsingResult parsingResult = parseRequest(request);
return new DefaultMultipartResourceRequest(request, parsingResult.getMultipartFiles(),
parsingResult.getMultipartParameters(), parsingResult.getMultipartParameterContentTypes());
}
}
|
[
"public",
"MultipartResourceRequest",
"resolveMultipart",
"(",
"final",
"ResourceRequest",
"request",
")",
"throws",
"MultipartException",
"{",
"Assert",
".",
"notNull",
"(",
"request",
",",
"\"Request must not be null\"",
")",
";",
"if",
"(",
"this",
".",
"resolveLazily",
")",
"{",
"return",
"new",
"DefaultMultipartResourceRequest",
"(",
"request",
")",
"{",
"@",
"Override",
"protected",
"void",
"initializeMultipart",
"(",
")",
"{",
"MultipartParsingResult",
"parsingResult",
"=",
"parseRequest",
"(",
"request",
")",
";",
"setMultipartFiles",
"(",
"parsingResult",
".",
"getMultipartFiles",
"(",
")",
")",
";",
"setMultipartParameters",
"(",
"parsingResult",
".",
"getMultipartParameters",
"(",
")",
")",
";",
"setMultipartParameterContentTypes",
"(",
"parsingResult",
".",
"getMultipartParameterContentTypes",
"(",
")",
")",
";",
"}",
"}",
";",
"}",
"else",
"{",
"MultipartParsingResult",
"parsingResult",
"=",
"parseRequest",
"(",
"request",
")",
";",
"return",
"new",
"DefaultMultipartResourceRequest",
"(",
"request",
",",
"parsingResult",
".",
"getMultipartFiles",
"(",
")",
",",
"parsingResult",
".",
"getMultipartParameters",
"(",
")",
",",
"parsingResult",
".",
"getMultipartParameterContentTypes",
"(",
")",
")",
";",
"}",
"}"
] |
<p>resolveMultipart.</p>
@param request a {@link javax.portlet.ResourceRequest} object.
@return a {@link org.jasig.springframework.web.portlet.upload.MultipartResourceRequest} object.
@throws org.springframework.web.multipart.MultipartException if any.
|
[
"<p",
">",
"resolveMultipart",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/Jasig/spring-portlet-contrib/blob/719240fa268ddc69900ce9775d9cad3b9c543c6b/spring-webmvc-portlet-contrib/src/main/java/org/jasig/springframework/web/portlet/upload/CommonsPortlet2MultipartResolver.java#L96-L113
|
kmi/iserve
|
iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java
|
SparqlLogicConceptMatcher.listMatchesAtMostOfType
|
@Override
public Map<URI, MatchResult> listMatchesAtMostOfType(URI origin, MatchType maxType) {
"""
Obtain all the matching resources that have a MatchTyoe with the URI of {@code origin} of the type provided (inclusive) or less.
@param origin URI to match
@param maxType the maximum MatchType we want to obtain
@return an ImmutableMap sorted by value indexed by the URI of the matching resource and containing the particular {@code MatchResult}. If no
result is found the Map should be empty not null.
"""
return listMatchesWithinRange(origin, LogicConceptMatchType.Fail, maxType);
}
|
java
|
@Override
public Map<URI, MatchResult> listMatchesAtMostOfType(URI origin, MatchType maxType) {
return listMatchesWithinRange(origin, LogicConceptMatchType.Fail, maxType);
}
|
[
"@",
"Override",
"public",
"Map",
"<",
"URI",
",",
"MatchResult",
">",
"listMatchesAtMostOfType",
"(",
"URI",
"origin",
",",
"MatchType",
"maxType",
")",
"{",
"return",
"listMatchesWithinRange",
"(",
"origin",
",",
"LogicConceptMatchType",
".",
"Fail",
",",
"maxType",
")",
";",
"}"
] |
Obtain all the matching resources that have a MatchTyoe with the URI of {@code origin} of the type provided (inclusive) or less.
@param origin URI to match
@param maxType the maximum MatchType we want to obtain
@return an ImmutableMap sorted by value indexed by the URI of the matching resource and containing the particular {@code MatchResult}. If no
result is found the Map should be empty not null.
|
[
"Obtain",
"all",
"the",
"matching",
"resources",
"that",
"have",
"a",
"MatchTyoe",
"with",
"the",
"URI",
"of",
"{",
"@code",
"origin",
"}",
"of",
"the",
"type",
"provided",
"(",
"inclusive",
")",
"or",
"less",
"."
] |
train
|
https://github.com/kmi/iserve/blob/13e7016e64c1d5a539b838c6debf1a5cc4aefcb7/iserve-semantic-discovery/src/main/java/uk/ac/open/kmi/iserve/discovery/disco/impl/SparqlLogicConceptMatcher.java#L304-L307
|
datasalt/pangool
|
core/src/main/java/com/datasalt/pangool/tuplemr/MapOnlyJobBuilder.java
|
MapOnlyJobBuilder.addTupleInput
|
public void addTupleInput(Path path, Schema targetSchema, MapOnlyMapper tupleMapper) {
"""
Adds an input file associated with a TupleFile.
<p>
A specific "Target Schema" is specified, which should be backwards-compatible with the Schema in the
Tuple File (new nullable fields are allowed, not used old fields too).
"""
addInput(path, new TupleInputFormat(targetSchema), tupleMapper);
}
|
java
|
public void addTupleInput(Path path, Schema targetSchema, MapOnlyMapper tupleMapper) {
addInput(path, new TupleInputFormat(targetSchema), tupleMapper);
}
|
[
"public",
"void",
"addTupleInput",
"(",
"Path",
"path",
",",
"Schema",
"targetSchema",
",",
"MapOnlyMapper",
"tupleMapper",
")",
"{",
"addInput",
"(",
"path",
",",
"new",
"TupleInputFormat",
"(",
"targetSchema",
")",
",",
"tupleMapper",
")",
";",
"}"
] |
Adds an input file associated with a TupleFile.
<p>
A specific "Target Schema" is specified, which should be backwards-compatible with the Schema in the
Tuple File (new nullable fields are allowed, not used old fields too).
|
[
"Adds",
"an",
"input",
"file",
"associated",
"with",
"a",
"TupleFile",
".",
"<p",
">",
"A",
"specific",
"Target",
"Schema",
"is",
"specified",
"which",
"should",
"be",
"backwards",
"-",
"compatible",
"with",
"the",
"Schema",
"in",
"the",
"Tuple",
"File",
"(",
"new",
"nullable",
"fields",
"are",
"allowed",
"not",
"used",
"old",
"fields",
"too",
")",
"."
] |
train
|
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/MapOnlyJobBuilder.java#L86-L88
|
nohana/Amalgam
|
amalgam/src/main/java/com/amalgam/os/BundleUtils.java
|
BundleUtils.optLong
|
public static long optLong(@Nullable Bundle bundle, @Nullable String key) {
"""
Returns a optional long value. In other words, returns the value mapped by key if it exists and is a long.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns 0.
@param bundle a bundle. If the bundle is null, this method will return 0.
@param key a key for the value.
@return a long value if exists, 0 otherwise.
@see android.os.Bundle#getLong(String)
"""
return optLong(bundle, key, 0L);
}
|
java
|
public static long optLong(@Nullable Bundle bundle, @Nullable String key) {
return optLong(bundle, key, 0L);
}
|
[
"public",
"static",
"long",
"optLong",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
")",
"{",
"return",
"optLong",
"(",
"bundle",
",",
"key",
",",
"0L",
")",
";",
"}"
] |
Returns a optional long value. In other words, returns the value mapped by key if it exists and is a long.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns 0.
@param bundle a bundle. If the bundle is null, this method will return 0.
@param key a key for the value.
@return a long value if exists, 0 otherwise.
@see android.os.Bundle#getLong(String)
|
[
"Returns",
"a",
"optional",
"long",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"long",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
"{"
] |
train
|
https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L631-L633
|
mapbox/mapbox-plugins-android
|
plugin-building/src/main/java/com/mapbox/mapboxsdk/plugins/building/BuildingPlugin.java
|
BuildingPlugin.initLayer
|
private void initLayer(String belowLayer) {
"""
Initialises and adds the fill extrusion layer used by this plugin.
@param belowLayer optionally place the buildings layer below a provided layer id
"""
light = style.getLight();
fillExtrusionLayer = new FillExtrusionLayer(LAYER_ID, "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setMinZoom(minZoomLevel);
fillExtrusionLayer.setProperties(
visibility(visible ? VISIBLE : NONE),
fillExtrusionColor(color),
fillExtrusionHeight(
interpolate(
exponential(1f),
zoom(),
stop(15, literal(0)),
stop(16, get("height"))
)
),
fillExtrusionOpacity(opacity)
);
addLayer(fillExtrusionLayer, belowLayer);
}
|
java
|
private void initLayer(String belowLayer) {
light = style.getLight();
fillExtrusionLayer = new FillExtrusionLayer(LAYER_ID, "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setMinZoom(minZoomLevel);
fillExtrusionLayer.setProperties(
visibility(visible ? VISIBLE : NONE),
fillExtrusionColor(color),
fillExtrusionHeight(
interpolate(
exponential(1f),
zoom(),
stop(15, literal(0)),
stop(16, get("height"))
)
),
fillExtrusionOpacity(opacity)
);
addLayer(fillExtrusionLayer, belowLayer);
}
|
[
"private",
"void",
"initLayer",
"(",
"String",
"belowLayer",
")",
"{",
"light",
"=",
"style",
".",
"getLight",
"(",
")",
";",
"fillExtrusionLayer",
"=",
"new",
"FillExtrusionLayer",
"(",
"LAYER_ID",
",",
"\"composite\"",
")",
";",
"fillExtrusionLayer",
".",
"setSourceLayer",
"(",
"\"building\"",
")",
";",
"fillExtrusionLayer",
".",
"setMinZoom",
"(",
"minZoomLevel",
")",
";",
"fillExtrusionLayer",
".",
"setProperties",
"(",
"visibility",
"(",
"visible",
"?",
"VISIBLE",
":",
"NONE",
")",
",",
"fillExtrusionColor",
"(",
"color",
")",
",",
"fillExtrusionHeight",
"(",
"interpolate",
"(",
"exponential",
"(",
"1f",
")",
",",
"zoom",
"(",
")",
",",
"stop",
"(",
"15",
",",
"literal",
"(",
"0",
")",
")",
",",
"stop",
"(",
"16",
",",
"get",
"(",
"\"height\"",
")",
")",
")",
")",
",",
"fillExtrusionOpacity",
"(",
"opacity",
")",
")",
";",
"addLayer",
"(",
"fillExtrusionLayer",
",",
"belowLayer",
")",
";",
"}"
] |
Initialises and adds the fill extrusion layer used by this plugin.
@param belowLayer optionally place the buildings layer below a provided layer id
|
[
"Initialises",
"and",
"adds",
"the",
"fill",
"extrusion",
"layer",
"used",
"by",
"this",
"plugin",
"."
] |
train
|
https://github.com/mapbox/mapbox-plugins-android/blob/c683cad4d8306945d71838d96fae73b8cbe2e6c9/plugin-building/src/main/java/com/mapbox/mapboxsdk/plugins/building/BuildingPlugin.java#L101-L120
|
adessoAG/wicked-charts
|
showcase/wicked-charts-showcase-wicket7/src/main/java/de/adesso/wickedcharts/showcase/HomepageHighcharts.java
|
HomepageHighcharts.addThemeLinks
|
private void addThemeLinks(PageParameters parameters) {
"""
Adds links to the different themes
@param parameters the page parameters from the page URI
"""
List<INamedParameters.NamedPair> pairs = parameters.getAllNamed();
if (parameters.getAllNamed().size() < 2) {
add(new UpdateThemeLink("defaultTheme", "chart"));
add(new UpdateThemeLink("grid", "chart"));
add(new UpdateThemeLink("skies", "chart"));
add(new UpdateThemeLink("gray", "chart"));
add(new UpdateThemeLink("darkblue", "chart"));
} else {
String chartString = parameters.getAllNamed().get(1).getValue();
add(new UpdateThemeLink("defaultTheme", chartString));
add(new UpdateThemeLink("grid", chartString));
add(new UpdateThemeLink("skies", chartString));
add(new UpdateThemeLink("gray", chartString));
add(new UpdateThemeLink("darkblue", chartString));
}
}
|
java
|
private void addThemeLinks(PageParameters parameters){
List<INamedParameters.NamedPair> pairs = parameters.getAllNamed();
if (parameters.getAllNamed().size() < 2) {
add(new UpdateThemeLink("defaultTheme", "chart"));
add(new UpdateThemeLink("grid", "chart"));
add(new UpdateThemeLink("skies", "chart"));
add(new UpdateThemeLink("gray", "chart"));
add(new UpdateThemeLink("darkblue", "chart"));
} else {
String chartString = parameters.getAllNamed().get(1).getValue();
add(new UpdateThemeLink("defaultTheme", chartString));
add(new UpdateThemeLink("grid", chartString));
add(new UpdateThemeLink("skies", chartString));
add(new UpdateThemeLink("gray", chartString));
add(new UpdateThemeLink("darkblue", chartString));
}
}
|
[
"private",
"void",
"addThemeLinks",
"(",
"PageParameters",
"parameters",
")",
"{",
"List",
"<",
"INamedParameters",
".",
"NamedPair",
">",
"pairs",
"=",
"parameters",
".",
"getAllNamed",
"(",
")",
";",
"if",
"(",
"parameters",
".",
"getAllNamed",
"(",
")",
".",
"size",
"(",
")",
"<",
"2",
")",
"{",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"defaultTheme\"",
",",
"\"chart\"",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"grid\"",
",",
"\"chart\"",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"skies\"",
",",
"\"chart\"",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"gray\"",
",",
"\"chart\"",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"darkblue\"",
",",
"\"chart\"",
")",
")",
";",
"}",
"else",
"{",
"String",
"chartString",
"=",
"parameters",
".",
"getAllNamed",
"(",
")",
".",
"get",
"(",
"1",
")",
".",
"getValue",
"(",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"defaultTheme\"",
",",
"chartString",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"grid\"",
",",
"chartString",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"skies\"",
",",
"chartString",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"gray\"",
",",
"chartString",
")",
")",
";",
"add",
"(",
"new",
"UpdateThemeLink",
"(",
"\"darkblue\"",
",",
"chartString",
")",
")",
";",
"}",
"}"
] |
Adds links to the different themes
@param parameters the page parameters from the page URI
|
[
"Adds",
"links",
"to",
"the",
"different",
"themes"
] |
train
|
https://github.com/adessoAG/wicked-charts/blob/498aceff025f612e22ba5135b26531afeabac03c/showcase/wicked-charts-showcase-wicket7/src/main/java/de/adesso/wickedcharts/showcase/HomepageHighcharts.java#L63-L79
|
jferard/fastods
|
fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java
|
TextBuilder.styledSpan
|
public TextBuilder styledSpan(final String text, final TextStyle ts) {
"""
Adds a TextStyle and text to the footer/header region specified by
region.<br>
The paragraph to be used is paragraph.<br>
The text will be shown in the order it was added with this function.
@param text The string with the text
@param ts The text style to be used
@return this for fluent style
"""
this.curParagraphBuilder.styledSpan(text, ts);
return this;
}
|
java
|
public TextBuilder styledSpan(final String text, final TextStyle ts) {
this.curParagraphBuilder.styledSpan(text, ts);
return this;
}
|
[
"public",
"TextBuilder",
"styledSpan",
"(",
"final",
"String",
"text",
",",
"final",
"TextStyle",
"ts",
")",
"{",
"this",
".",
"curParagraphBuilder",
".",
"styledSpan",
"(",
"text",
",",
"ts",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a TextStyle and text to the footer/header region specified by
region.<br>
The paragraph to be used is paragraph.<br>
The text will be shown in the order it was added with this function.
@param text The string with the text
@param ts The text style to be used
@return this for fluent style
|
[
"Adds",
"a",
"TextStyle",
"and",
"text",
"to",
"the",
"footer",
"/",
"header",
"region",
"specified",
"by",
"region",
".",
"<br",
">",
"The",
"paragraph",
"to",
"be",
"used",
"is",
"paragraph",
".",
"<br",
">",
"The",
"text",
"will",
"be",
"shown",
"in",
"the",
"order",
"it",
"was",
"added",
"with",
"this",
"function",
"."
] |
train
|
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java#L214-L217
|
raydac/java-binary-block-parser
|
jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
|
JBBPDslBuilder.Double
|
public JBBPDslBuilder Double(final String name) {
"""
Add named double field.
@param name name of the field, can be null for anonymous
@return the builder instance, must not be null
"""
final Item item = new Item(BinType.DOUBLE, name, this.byteOrder);
this.addItem(item);
return this;
}
|
java
|
public JBBPDslBuilder Double(final String name) {
final Item item = new Item(BinType.DOUBLE, name, this.byteOrder);
this.addItem(item);
return this;
}
|
[
"public",
"JBBPDslBuilder",
"Double",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"DOUBLE",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
";",
"this",
".",
"addItem",
"(",
"item",
")",
";",
"return",
"this",
";",
"}"
] |
Add named double field.
@param name name of the field, can be null for anonymous
@return the builder instance, must not be null
|
[
"Add",
"named",
"double",
"field",
"."
] |
train
|
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L1289-L1293
|
mytechia/mytechia_commons
|
mytechia_commons_library/src/main/java/com/mytechia/commons/patterns/prototype/PrototypeContainer.java
|
PrototypeContainer.unregisterPrototype
|
public void unregisterPrototype( String key, Class c ) {
"""
Unregisters a prototype associated to the specified key
NOTE: IPrototype pattern
@param key key of the prototype
@param c the prototype to unregister
"""
prototypes.remove(new PrototypeKey(key, c));
}
|
java
|
public void unregisterPrototype( String key, Class c )
{
prototypes.remove(new PrototypeKey(key, c));
}
|
[
"public",
"void",
"unregisterPrototype",
"(",
"String",
"key",
",",
"Class",
"c",
")",
"{",
"prototypes",
".",
"remove",
"(",
"new",
"PrototypeKey",
"(",
"key",
",",
"c",
")",
")",
";",
"}"
] |
Unregisters a prototype associated to the specified key
NOTE: IPrototype pattern
@param key key of the prototype
@param c the prototype to unregister
|
[
"Unregisters",
"a",
"prototype",
"associated",
"to",
"the",
"specified",
"key"
] |
train
|
https://github.com/mytechia/mytechia_commons/blob/02251879085f271a1fb51663a1c8eddc8be78ae7/mytechia_commons_library/src/main/java/com/mytechia/commons/patterns/prototype/PrototypeContainer.java#L153-L158
|
google/error-prone-javac
|
src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
|
SimpleDocTreeVisitor.visitSerialField
|
@Override
public R visitSerialField(SerialFieldTree node, P p) {
"""
{@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction}
"""
return defaultAction(node, p);
}
|
java
|
@Override
public R visitSerialField(SerialFieldTree node, P p) {
return defaultAction(node, p);
}
|
[
"@",
"Override",
"public",
"R",
"visitSerialField",
"(",
"SerialFieldTree",
"node",
",",
"P",
"p",
")",
"{",
"return",
"defaultAction",
"(",
"node",
",",
"p",
")",
";",
"}"
] |
{@inheritDoc} This implementation calls {@code defaultAction}.
@param node {@inheritDoc}
@param p {@inheritDoc}
@return the result of {@code defaultAction}
|
[
"{",
"@inheritDoc",
"}",
"This",
"implementation",
"calls",
"{",
"@code",
"defaultAction",
"}",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java#L369-L372
|
salesforce/Argus
|
ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/NamespaceDto.java
|
NamespaceDto.transformToDto
|
public static List<NamespaceDto> transformToDto(List<Namespace> namespaces) {
"""
Converts list of alert entity objects to list of alertDto objects.
@param namespaces users alerts List of alert entities. Cannot be null.
@return List of alertDto objects.
@throws WebApplicationException If an error occurs.
"""
if (namespaces == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
List<NamespaceDto> result = new ArrayList<>();
for (Namespace namespace : namespaces) {
result.add(transformToDto(namespace));
}
return result;
}
|
java
|
public static List<NamespaceDto> transformToDto(List<Namespace> namespaces) {
if (namespaces == null) {
throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
}
List<NamespaceDto> result = new ArrayList<>();
for (Namespace namespace : namespaces) {
result.add(transformToDto(namespace));
}
return result;
}
|
[
"public",
"static",
"List",
"<",
"NamespaceDto",
">",
"transformToDto",
"(",
"List",
"<",
"Namespace",
">",
"namespaces",
")",
"{",
"if",
"(",
"namespaces",
"==",
"null",
")",
"{",
"throw",
"new",
"WebApplicationException",
"(",
"\"Null entity object cannot be converted to Dto object.\"",
",",
"Status",
".",
"INTERNAL_SERVER_ERROR",
")",
";",
"}",
"List",
"<",
"NamespaceDto",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Namespace",
"namespace",
":",
"namespaces",
")",
"{",
"result",
".",
"add",
"(",
"transformToDto",
"(",
"namespace",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Converts list of alert entity objects to list of alertDto objects.
@param namespaces users alerts List of alert entities. Cannot be null.
@return List of alertDto objects.
@throws WebApplicationException If an error occurs.
|
[
"Converts",
"list",
"of",
"alert",
"entity",
"objects",
"to",
"list",
"of",
"alertDto",
"objects",
"."
] |
train
|
https://github.com/salesforce/Argus/blob/121b59a268da264316cded6a3e9271366a23cd86/ArgusWebServices/src/main/java/com/salesforce/dva/argus/ws/dto/NamespaceDto.java#L96-L107
|
tractionsoftware/gwt-traction
|
src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java
|
RgbaColor.adjustSL
|
private RgbaColor adjustSL(int index, float first, float second) {
"""
Takes two adjustments and applies the one that conforms to the
range. If the first modification moves the value out of range
[0-100], the second modification will be applied <b>and clipped
if necessary</b>.
@param index
The index in HSL
@param first
The first modification that will be applied and
bounds checked
@param second
If 0, the first is always applied
"""
float[] HSL = convertToHsl();
float firstvalue = HSL[index] + first;
// check if it's in bounds
if (slCheck(firstvalue) == firstvalue) {
// it is, keep this transform
HSL[index] = firstvalue;
}
else if (second == 0) {
// just take the first one because there is no second, but
// bounds check it.
HSL[index] = slCheck(firstvalue);
}
else {
// always take the second if the first exceeds bounds
HSL[index] = slCheck(HSL[index] + second);
}
return RgbaColor.fromHsl(HSL);
}
|
java
|
private RgbaColor adjustSL(int index, float first, float second) {
float[] HSL = convertToHsl();
float firstvalue = HSL[index] + first;
// check if it's in bounds
if (slCheck(firstvalue) == firstvalue) {
// it is, keep this transform
HSL[index] = firstvalue;
}
else if (second == 0) {
// just take the first one because there is no second, but
// bounds check it.
HSL[index] = slCheck(firstvalue);
}
else {
// always take the second if the first exceeds bounds
HSL[index] = slCheck(HSL[index] + second);
}
return RgbaColor.fromHsl(HSL);
}
|
[
"private",
"RgbaColor",
"adjustSL",
"(",
"int",
"index",
",",
"float",
"first",
",",
"float",
"second",
")",
"{",
"float",
"[",
"]",
"HSL",
"=",
"convertToHsl",
"(",
")",
";",
"float",
"firstvalue",
"=",
"HSL",
"[",
"index",
"]",
"+",
"first",
";",
"// check if it's in bounds",
"if",
"(",
"slCheck",
"(",
"firstvalue",
")",
"==",
"firstvalue",
")",
"{",
"// it is, keep this transform",
"HSL",
"[",
"index",
"]",
"=",
"firstvalue",
";",
"}",
"else",
"if",
"(",
"second",
"==",
"0",
")",
"{",
"// just take the first one because there is no second, but",
"// bounds check it.",
"HSL",
"[",
"index",
"]",
"=",
"slCheck",
"(",
"firstvalue",
")",
";",
"}",
"else",
"{",
"// always take the second if the first exceeds bounds",
"HSL",
"[",
"index",
"]",
"=",
"slCheck",
"(",
"HSL",
"[",
"index",
"]",
"+",
"second",
")",
";",
"}",
"return",
"RgbaColor",
".",
"fromHsl",
"(",
"HSL",
")",
";",
"}"
] |
Takes two adjustments and applies the one that conforms to the
range. If the first modification moves the value out of range
[0-100], the second modification will be applied <b>and clipped
if necessary</b>.
@param index
The index in HSL
@param first
The first modification that will be applied and
bounds checked
@param second
If 0, the first is always applied
|
[
"Takes",
"two",
"adjustments",
"and",
"applies",
"the",
"one",
"that",
"conforms",
"to",
"the",
"range",
".",
"If",
"the",
"first",
"modification",
"moves",
"the",
"value",
"out",
"of",
"range",
"[",
"0",
"-",
"100",
"]",
"the",
"second",
"modification",
"will",
"be",
"applied",
"<b",
">",
"and",
"clipped",
"if",
"necessary<",
"/",
"b",
">",
"."
] |
train
|
https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/util/RgbaColor.java#L577-L597
|
vlingo/vlingo-actors
|
src/main/java/io/vlingo/actors/Stage.java
|
Stage.actorFor
|
public <T> T actorFor(final Class<T> protocol, final Class<? extends Actor> type, final Object...parameters) {
"""
Answers the {@code T} protocol of the newly created {@code Actor} that implements the {@code protocol}.
@param <T> the protocol type
@param protocol the {@code Class<T>} protocol
@param type the {@code Class<? extends Actor>} of the {@code Actor} to create
@param parameters the {@code Object[]} of constructor parameters
@return T
"""
return actorFor(protocol, Definition.has(type, Arrays.asList(parameters)));
}
|
java
|
public <T> T actorFor(final Class<T> protocol, final Class<? extends Actor> type, final Object...parameters) {
return actorFor(protocol, Definition.has(type, Arrays.asList(parameters)));
}
|
[
"public",
"<",
"T",
">",
"T",
"actorFor",
"(",
"final",
"Class",
"<",
"T",
">",
"protocol",
",",
"final",
"Class",
"<",
"?",
"extends",
"Actor",
">",
"type",
",",
"final",
"Object",
"...",
"parameters",
")",
"{",
"return",
"actorFor",
"(",
"protocol",
",",
"Definition",
".",
"has",
"(",
"type",
",",
"Arrays",
".",
"asList",
"(",
"parameters",
")",
")",
")",
";",
"}"
] |
Answers the {@code T} protocol of the newly created {@code Actor} that implements the {@code protocol}.
@param <T> the protocol type
@param protocol the {@code Class<T>} protocol
@param type the {@code Class<? extends Actor>} of the {@code Actor} to create
@param parameters the {@code Object[]} of constructor parameters
@return T
|
[
"Answers",
"the",
"{"
] |
train
|
https://github.com/vlingo/vlingo-actors/blob/c7d046fd139c0490cf0fd2588d7dc2f792f13493/src/main/java/io/vlingo/actors/Stage.java#L49-L51
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.