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
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
google/closure-compiler | src/com/google/javascript/jscomp/deps/DepsGenerator.java | DepsGenerator.parseSources | private Map<String, DependencyInfo> parseSources(
Set<String> preparsedFiles) throws IOException {
"""
Parses all source files for dependency information.
@param preparsedFiles A set of closure-relative paths.
Files in this set are not parsed if they are encountered in srcs.
@return Returns a map of closure-relative paths -> DependencyInfo for the
newly parsed files.
@throws IOException Occurs upon an IO error.
"""
Map<String, DependencyInfo> parsedFiles = new LinkedHashMap<>();
JsFileParser jsParser = new JsFileParser(errorManager).setModuleLoader(loader);
Compiler compiler = new Compiler();
compiler.init(ImmutableList.of(), ImmutableList.of(), new CompilerOptions());
for (SourceFile file : srcs) {
String closureRelativePath =
PathUtil.makeRelative(
closurePathAbs, PathUtil.makeAbsolute(file.getName()));
if (logger.isLoggable(Level.FINE)) {
logger.fine("Closure-relative path: " + closureRelativePath);
}
if (InclusionStrategy.WHEN_IN_SRCS == mergeStrategy ||
!preparsedFiles.contains(closureRelativePath)) {
DependencyInfo depInfo =
jsParser.parseFile(
file.getName(), closureRelativePath,
file.getCode());
depInfo = new LazyParsedDependencyInfo(depInfo, new JsAst(file), compiler);
// Kick the source out of memory.
file.clearCachedSource();
parsedFiles.put(closureRelativePath, depInfo);
}
}
return parsedFiles;
} | java | private Map<String, DependencyInfo> parseSources(
Set<String> preparsedFiles) throws IOException {
Map<String, DependencyInfo> parsedFiles = new LinkedHashMap<>();
JsFileParser jsParser = new JsFileParser(errorManager).setModuleLoader(loader);
Compiler compiler = new Compiler();
compiler.init(ImmutableList.of(), ImmutableList.of(), new CompilerOptions());
for (SourceFile file : srcs) {
String closureRelativePath =
PathUtil.makeRelative(
closurePathAbs, PathUtil.makeAbsolute(file.getName()));
if (logger.isLoggable(Level.FINE)) {
logger.fine("Closure-relative path: " + closureRelativePath);
}
if (InclusionStrategy.WHEN_IN_SRCS == mergeStrategy ||
!preparsedFiles.contains(closureRelativePath)) {
DependencyInfo depInfo =
jsParser.parseFile(
file.getName(), closureRelativePath,
file.getCode());
depInfo = new LazyParsedDependencyInfo(depInfo, new JsAst(file), compiler);
// Kick the source out of memory.
file.clearCachedSource();
parsedFiles.put(closureRelativePath, depInfo);
}
}
return parsedFiles;
} | [
"private",
"Map",
"<",
"String",
",",
"DependencyInfo",
">",
"parseSources",
"(",
"Set",
"<",
"String",
">",
"preparsedFiles",
")",
"throws",
"IOException",
"{",
"Map",
"<",
"String",
",",
"DependencyInfo",
">",
"parsedFiles",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"JsFileParser",
"jsParser",
"=",
"new",
"JsFileParser",
"(",
"errorManager",
")",
".",
"setModuleLoader",
"(",
"loader",
")",
";",
"Compiler",
"compiler",
"=",
"new",
"Compiler",
"(",
")",
";",
"compiler",
".",
"init",
"(",
"ImmutableList",
".",
"of",
"(",
")",
",",
"ImmutableList",
".",
"of",
"(",
")",
",",
"new",
"CompilerOptions",
"(",
")",
")",
";",
"for",
"(",
"SourceFile",
"file",
":",
"srcs",
")",
"{",
"String",
"closureRelativePath",
"=",
"PathUtil",
".",
"makeRelative",
"(",
"closurePathAbs",
",",
"PathUtil",
".",
"makeAbsolute",
"(",
"file",
".",
"getName",
"(",
")",
")",
")",
";",
"if",
"(",
"logger",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"logger",
".",
"fine",
"(",
"\"Closure-relative path: \"",
"+",
"closureRelativePath",
")",
";",
"}",
"if",
"(",
"InclusionStrategy",
".",
"WHEN_IN_SRCS",
"==",
"mergeStrategy",
"||",
"!",
"preparsedFiles",
".",
"contains",
"(",
"closureRelativePath",
")",
")",
"{",
"DependencyInfo",
"depInfo",
"=",
"jsParser",
".",
"parseFile",
"(",
"file",
".",
"getName",
"(",
")",
",",
"closureRelativePath",
",",
"file",
".",
"getCode",
"(",
")",
")",
";",
"depInfo",
"=",
"new",
"LazyParsedDependencyInfo",
"(",
"depInfo",
",",
"new",
"JsAst",
"(",
"file",
")",
",",
"compiler",
")",
";",
"// Kick the source out of memory.",
"file",
".",
"clearCachedSource",
"(",
")",
";",
"parsedFiles",
".",
"put",
"(",
"closureRelativePath",
",",
"depInfo",
")",
";",
"}",
"}",
"return",
"parsedFiles",
";",
"}"
] | Parses all source files for dependency information.
@param preparsedFiles A set of closure-relative paths.
Files in this set are not parsed if they are encountered in srcs.
@return Returns a map of closure-relative paths -> DependencyInfo for the
newly parsed files.
@throws IOException Occurs upon an IO error. | [
"Parses",
"all",
"source",
"files",
"for",
"dependency",
"information",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/deps/DepsGenerator.java#L477-L506 |
rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.setCompoundDrawables | public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom) {
"""
Sets the Drawables (if any) to appear to the left of, above, to the
right of, and below the text. Use {@code null} if you do not want a
Drawable there. The Drawables must already have had
{@link Drawable#setBounds} called.
<p>
Calling this method will overwrite any Drawables previously set using
{@link #setCompoundDrawablesRelative} or related methods.
@attr ref android.R.styleable#TextView_drawableLeft
@attr ref android.R.styleable#TextView_drawableTop
@attr ref android.R.styleable#TextView_drawableRight
@attr ref android.R.styleable#TextView_drawableBottom
"""
mInputView.setCompoundDrawables(left, top, right, bottom);
if(mDividerCompoundPadding) {
mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight());
if(mLabelEnable)
mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom());
if(mSupportMode != SUPPORT_MODE_NONE)
mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom());
}
} | java | public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom){
mInputView.setCompoundDrawables(left, top, right, bottom);
if(mDividerCompoundPadding) {
mDivider.setPadding(mInputView.getTotalPaddingLeft(), mInputView.getTotalPaddingRight());
if(mLabelEnable)
mLabelView.setPadding(mDivider.getPaddingLeft(), mLabelView.getPaddingTop(), mDivider.getPaddingRight(), mLabelView.getPaddingBottom());
if(mSupportMode != SUPPORT_MODE_NONE)
mSupportView.setPadding(mDivider.getPaddingLeft(), mSupportView.getPaddingTop(), mDivider.getPaddingRight(), mSupportView.getPaddingBottom());
}
} | [
"public",
"void",
"setCompoundDrawables",
"(",
"Drawable",
"left",
",",
"Drawable",
"top",
",",
"Drawable",
"right",
",",
"Drawable",
"bottom",
")",
"{",
"mInputView",
".",
"setCompoundDrawables",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
")",
";",
"if",
"(",
"mDividerCompoundPadding",
")",
"{",
"mDivider",
".",
"setPadding",
"(",
"mInputView",
".",
"getTotalPaddingLeft",
"(",
")",
",",
"mInputView",
".",
"getTotalPaddingRight",
"(",
")",
")",
";",
"if",
"(",
"mLabelEnable",
")",
"mLabelView",
".",
"setPadding",
"(",
"mDivider",
".",
"getPaddingLeft",
"(",
")",
",",
"mLabelView",
".",
"getPaddingTop",
"(",
")",
",",
"mDivider",
".",
"getPaddingRight",
"(",
")",
",",
"mLabelView",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"if",
"(",
"mSupportMode",
"!=",
"SUPPORT_MODE_NONE",
")",
"mSupportView",
".",
"setPadding",
"(",
"mDivider",
".",
"getPaddingLeft",
"(",
")",
",",
"mSupportView",
".",
"getPaddingTop",
"(",
")",
",",
"mDivider",
".",
"getPaddingRight",
"(",
")",
",",
"mSupportView",
".",
"getPaddingBottom",
"(",
")",
")",
";",
"}",
"}"
] | Sets the Drawables (if any) to appear to the left of, above, to the
right of, and below the text. Use {@code null} if you do not want a
Drawable there. The Drawables must already have had
{@link Drawable#setBounds} called.
<p>
Calling this method will overwrite any Drawables previously set using
{@link #setCompoundDrawablesRelative} or related methods.
@attr ref android.R.styleable#TextView_drawableLeft
@attr ref android.R.styleable#TextView_drawableTop
@attr ref android.R.styleable#TextView_drawableRight
@attr ref android.R.styleable#TextView_drawableBottom | [
"Sets",
"the",
"Drawables",
"(",
"if",
"any",
")",
"to",
"appear",
"to",
"the",
"left",
"of",
"above",
"to",
"the",
"right",
"of",
"and",
"below",
"the",
"text",
".",
"Use",
"{",
"@code",
"null",
"}",
"if",
"you",
"do",
"not",
"want",
"a",
"Drawable",
"there",
".",
"The",
"Drawables",
"must",
"already",
"have",
"had",
"{",
"@link",
"Drawable#setBounds",
"}",
"called",
".",
"<p",
">",
"Calling",
"this",
"method",
"will",
"overwrite",
"any",
"Drawables",
"previously",
"set",
"using",
"{",
"@link",
"#setCompoundDrawablesRelative",
"}",
"or",
"related",
"methods",
"."
] | train | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2693-L2702 |
WASdev/standards.jsr352.jbatch | com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java | JDBCPersistenceManagerImpl.createIfNotExists | private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
"""
Creates tableName using the createTableStatement DDL.
@param tableName
@param createTableStatement
@throws SQLException
"""
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
} | java | private void createIfNotExists(String tableName, String createTableStatement) throws SQLException {
logger.entering(CLASSNAME, "createIfNotExists", new Object[] {tableName, createTableStatement});
Connection conn = getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
ResultSet rs = dbmd.getTables(null, schema, tableName, null);
PreparedStatement ps = null;
if(!rs.next()) {
logger.log(Level.INFO, tableName + " table does not exists. Trying to create it.");
ps = conn.prepareStatement(createTableStatement);
ps.executeUpdate();
}
cleanupConnection(conn, rs, ps);
logger.exiting(CLASSNAME, "createIfNotExists");
} | [
"private",
"void",
"createIfNotExists",
"(",
"String",
"tableName",
",",
"String",
"createTableStatement",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"entering",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
",",
"new",
"Object",
"[",
"]",
"{",
"tableName",
",",
"createTableStatement",
"}",
")",
";",
"Connection",
"conn",
"=",
"getConnection",
"(",
")",
";",
"DatabaseMetaData",
"dbmd",
"=",
"conn",
".",
"getMetaData",
"(",
")",
";",
"ResultSet",
"rs",
"=",
"dbmd",
".",
"getTables",
"(",
"null",
",",
"schema",
",",
"tableName",
",",
"null",
")",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"if",
"(",
"!",
"rs",
".",
"next",
"(",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"tableName",
"+",
"\" table does not exists. Trying to create it.\"",
")",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"createTableStatement",
")",
";",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"}",
"cleanupConnection",
"(",
"conn",
",",
"rs",
",",
"ps",
")",
";",
"logger",
".",
"exiting",
"(",
"CLASSNAME",
",",
"\"createIfNotExists\"",
")",
";",
"}"
] | Creates tableName using the createTableStatement DDL.
@param tableName
@param createTableStatement
@throws SQLException | [
"Creates",
"tableName",
"using",
"the",
"createTableStatement",
"DDL",
"."
] | train | https://github.com/WASdev/standards.jsr352.jbatch/blob/e267e79dccd4f0bd4bf9c2abc41a8a47b65be28f/com.ibm.jbatch.container/src/main/java/com/ibm/jbatch/container/services/impl/JDBCPersistenceManagerImpl.java#L238-L253 |
mguymon/naether | src/main/java/com/tobedevoured/naether/PathClassLoader.java | PathClassLoader.newInstance | public Object newInstance( String name, Object... params ) throws ClassLoaderException {
"""
Create new instance of Object with constructor parameters using the ClassLoader
@param name String
@param params Object parameters for constructor
@return Object
@throws ClassLoaderException exception
"""
return newInstance( name, params, null );
} | java | public Object newInstance( String name, Object... params ) throws ClassLoaderException {
return newInstance( name, params, null );
} | [
"public",
"Object",
"newInstance",
"(",
"String",
"name",
",",
"Object",
"...",
"params",
")",
"throws",
"ClassLoaderException",
"{",
"return",
"newInstance",
"(",
"name",
",",
"params",
",",
"null",
")",
";",
"}"
] | Create new instance of Object with constructor parameters using the ClassLoader
@param name String
@param params Object parameters for constructor
@return Object
@throws ClassLoaderException exception | [
"Create",
"new",
"instance",
"of",
"Object",
"with",
"constructor",
"parameters",
"using",
"the",
"ClassLoader"
] | train | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/java/com/tobedevoured/naether/PathClassLoader.java#L107-L109 |
sagiegurari/fax4j | src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java | HylaFaxClientSpi.resumeFaxJob | protected void resumeFaxJob(HylaFaxJob faxJob,HylaFAXClient client) throws Exception {
"""
This function will resume an existing fax job.
@param client
The client instance
@param faxJob
The fax job object containing the needed information
@throws Exception
Any exception
"""
//get job
Job job=faxJob.getHylaFaxJob();
//get job ID
long faxJobID=job.getId();
//resume job
client.retry(faxJobID);
} | java | protected void resumeFaxJob(HylaFaxJob faxJob,HylaFAXClient client) throws Exception
{
//get job
Job job=faxJob.getHylaFaxJob();
//get job ID
long faxJobID=job.getId();
//resume job
client.retry(faxJobID);
} | [
"protected",
"void",
"resumeFaxJob",
"(",
"HylaFaxJob",
"faxJob",
",",
"HylaFAXClient",
"client",
")",
"throws",
"Exception",
"{",
"//get job",
"Job",
"job",
"=",
"faxJob",
".",
"getHylaFaxJob",
"(",
")",
";",
"//get job ID",
"long",
"faxJobID",
"=",
"job",
".",
"getId",
"(",
")",
";",
"//resume job",
"client",
".",
"retry",
"(",
"faxJobID",
")",
";",
"}"
] | This function will resume an existing fax job.
@param client
The client instance
@param faxJob
The fax job object containing the needed information
@throws Exception
Any exception | [
"This",
"function",
"will",
"resume",
"an",
"existing",
"fax",
"job",
"."
] | train | https://github.com/sagiegurari/fax4j/blob/42fa51acabe7bf279e27ab3dd1cf76146b27955f/src/main/java/org/fax4j/spi/hylafax/HylaFaxClientSpi.java#L469-L479 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | DefaultGroovyMethods.findAll | public static <T> List<T> findAll(List<T> self) {
"""
Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
<p>
Example:
<pre class="groovyTestCase">
def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null]
assert items.findAll() == [1, 2, true, 'foo', [4, 5]]
</pre>
@param self a List
@return a List of the values found
@since 2.4.0
@see Closure#IDENTITY
"""
return findAll(self, Closure.IDENTITY);
} | java | public static <T> List<T> findAll(List<T> self) {
return findAll(self, Closure.IDENTITY);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"findAll",
"(",
"List",
"<",
"T",
">",
"self",
")",
"{",
"return",
"findAll",
"(",
"self",
",",
"Closure",
".",
"IDENTITY",
")",
";",
"}"
] | Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
<p>
Example:
<pre class="groovyTestCase">
def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null]
assert items.findAll() == [1, 2, true, 'foo', [4, 5]]
</pre>
@param self a List
@return a List of the values found
@since 2.4.0
@see Closure#IDENTITY | [
"Finds",
"the",
"items",
"matching",
"the",
"IDENTITY",
"Closure",
"(",
"i",
".",
"e",
".",
" ",
";",
"matching",
"Groovy",
"truth",
")",
".",
"<p",
">",
"Example",
":",
"<pre",
"class",
"=",
"groovyTestCase",
">",
"def",
"items",
"=",
"[",
"1",
"2",
"0",
"false",
"true",
"foo",
"[]",
"[",
"4",
"5",
"]",
"null",
"]",
"assert",
"items",
".",
"findAll",
"()",
"==",
"[",
"1",
"2",
"true",
"foo",
"[",
"4",
"5",
"]]",
"<",
"/",
"pre",
">"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4829-L4831 |
stratosphere/stratosphere | stratosphere-compiler/src/main/java/eu/stratosphere/compiler/dag/BulkIterationNode.java | BulkIterationNode.setNextPartialSolution | public void setNextPartialSolution(OptimizerNode nextPartialSolution, OptimizerNode terminationCriterion) {
"""
Sets the nextPartialSolution for this BulkIterationNode.
@param nextPartialSolution The nextPartialSolution to set.
"""
// check if the root of the step function has the same DOP as the iteration
if (nextPartialSolution.getDegreeOfParallelism() != getDegreeOfParallelism() ||
nextPartialSolution.getSubtasksPerInstance() != getSubtasksPerInstance() )
{
// add a no-op to the root to express the re-partitioning
NoOpNode noop = new NoOpNode();
noop.setDegreeOfParallelism(getDegreeOfParallelism());
noop.setSubtasksPerInstance(getSubtasksPerInstance());
PactConnection noOpConn = new PactConnection(nextPartialSolution, noop);
noop.setIncomingConnection(noOpConn);
nextPartialSolution.addOutgoingConnection(noOpConn);
nextPartialSolution = noop;
}
this.nextPartialSolution = nextPartialSolution;
this.terminationCriterion = terminationCriterion;
if (terminationCriterion == null) {
this.singleRoot = nextPartialSolution;
this.rootConnection = new PactConnection(nextPartialSolution);
}
else {
// we have a termination criterion
SingleRootJoiner singleRootJoiner = new SingleRootJoiner();
this.rootConnection = new PactConnection(nextPartialSolution, singleRootJoiner);
this.terminationCriterionRootConnection = new PactConnection(terminationCriterion, singleRootJoiner);
singleRootJoiner.setInputs(this.rootConnection, this.terminationCriterionRootConnection);
this.singleRoot = singleRootJoiner;
// add connection to terminationCriterion for interesting properties visitor
terminationCriterion.addOutgoingConnection(terminationCriterionRootConnection);
}
nextPartialSolution.addOutgoingConnection(rootConnection);
} | java | public void setNextPartialSolution(OptimizerNode nextPartialSolution, OptimizerNode terminationCriterion) {
// check if the root of the step function has the same DOP as the iteration
if (nextPartialSolution.getDegreeOfParallelism() != getDegreeOfParallelism() ||
nextPartialSolution.getSubtasksPerInstance() != getSubtasksPerInstance() )
{
// add a no-op to the root to express the re-partitioning
NoOpNode noop = new NoOpNode();
noop.setDegreeOfParallelism(getDegreeOfParallelism());
noop.setSubtasksPerInstance(getSubtasksPerInstance());
PactConnection noOpConn = new PactConnection(nextPartialSolution, noop);
noop.setIncomingConnection(noOpConn);
nextPartialSolution.addOutgoingConnection(noOpConn);
nextPartialSolution = noop;
}
this.nextPartialSolution = nextPartialSolution;
this.terminationCriterion = terminationCriterion;
if (terminationCriterion == null) {
this.singleRoot = nextPartialSolution;
this.rootConnection = new PactConnection(nextPartialSolution);
}
else {
// we have a termination criterion
SingleRootJoiner singleRootJoiner = new SingleRootJoiner();
this.rootConnection = new PactConnection(nextPartialSolution, singleRootJoiner);
this.terminationCriterionRootConnection = new PactConnection(terminationCriterion, singleRootJoiner);
singleRootJoiner.setInputs(this.rootConnection, this.terminationCriterionRootConnection);
this.singleRoot = singleRootJoiner;
// add connection to terminationCriterion for interesting properties visitor
terminationCriterion.addOutgoingConnection(terminationCriterionRootConnection);
}
nextPartialSolution.addOutgoingConnection(rootConnection);
} | [
"public",
"void",
"setNextPartialSolution",
"(",
"OptimizerNode",
"nextPartialSolution",
",",
"OptimizerNode",
"terminationCriterion",
")",
"{",
"// check if the root of the step function has the same DOP as the iteration",
"if",
"(",
"nextPartialSolution",
".",
"getDegreeOfParallelism",
"(",
")",
"!=",
"getDegreeOfParallelism",
"(",
")",
"||",
"nextPartialSolution",
".",
"getSubtasksPerInstance",
"(",
")",
"!=",
"getSubtasksPerInstance",
"(",
")",
")",
"{",
"// add a no-op to the root to express the re-partitioning",
"NoOpNode",
"noop",
"=",
"new",
"NoOpNode",
"(",
")",
";",
"noop",
".",
"setDegreeOfParallelism",
"(",
"getDegreeOfParallelism",
"(",
")",
")",
";",
"noop",
".",
"setSubtasksPerInstance",
"(",
"getSubtasksPerInstance",
"(",
")",
")",
";",
"PactConnection",
"noOpConn",
"=",
"new",
"PactConnection",
"(",
"nextPartialSolution",
",",
"noop",
")",
";",
"noop",
".",
"setIncomingConnection",
"(",
"noOpConn",
")",
";",
"nextPartialSolution",
".",
"addOutgoingConnection",
"(",
"noOpConn",
")",
";",
"nextPartialSolution",
"=",
"noop",
";",
"}",
"this",
".",
"nextPartialSolution",
"=",
"nextPartialSolution",
";",
"this",
".",
"terminationCriterion",
"=",
"terminationCriterion",
";",
"if",
"(",
"terminationCriterion",
"==",
"null",
")",
"{",
"this",
".",
"singleRoot",
"=",
"nextPartialSolution",
";",
"this",
".",
"rootConnection",
"=",
"new",
"PactConnection",
"(",
"nextPartialSolution",
")",
";",
"}",
"else",
"{",
"// we have a termination criterion",
"SingleRootJoiner",
"singleRootJoiner",
"=",
"new",
"SingleRootJoiner",
"(",
")",
";",
"this",
".",
"rootConnection",
"=",
"new",
"PactConnection",
"(",
"nextPartialSolution",
",",
"singleRootJoiner",
")",
";",
"this",
".",
"terminationCriterionRootConnection",
"=",
"new",
"PactConnection",
"(",
"terminationCriterion",
",",
"singleRootJoiner",
")",
";",
"singleRootJoiner",
".",
"setInputs",
"(",
"this",
".",
"rootConnection",
",",
"this",
".",
"terminationCriterionRootConnection",
")",
";",
"this",
".",
"singleRoot",
"=",
"singleRootJoiner",
";",
"// add connection to terminationCriterion for interesting properties visitor",
"terminationCriterion",
".",
"addOutgoingConnection",
"(",
"terminationCriterionRootConnection",
")",
";",
"}",
"nextPartialSolution",
".",
"addOutgoingConnection",
"(",
"rootConnection",
")",
";",
"}"
] | Sets the nextPartialSolution for this BulkIterationNode.
@param nextPartialSolution The nextPartialSolution to set. | [
"Sets",
"the",
"nextPartialSolution",
"for",
"this",
"BulkIterationNode",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-compiler/src/main/java/eu/stratosphere/compiler/dag/BulkIterationNode.java#L119-L159 |
GoogleCloudPlatform/appengine-pipelines | java/src/main/java/com/google/appengine/tools/pipeline/impl/model/JobRecord.java | JobRecord.createRootJobRecord | public static JobRecord createRootJobRecord(Job<?> jobInstance, JobSetting[] settings) {
"""
A factory method for root jobs.
@param jobInstance The non-null user-supplied instance of {@code Job} that
implements the Job that the newly created JobRecord represents.
@param settings Array of {@code JobSetting} to apply to the newly created
JobRecord.
"""
Key key = generateKey(null, DATA_STORE_KIND);
return new JobRecord(key, jobInstance, settings);
} | java | public static JobRecord createRootJobRecord(Job<?> jobInstance, JobSetting[] settings) {
Key key = generateKey(null, DATA_STORE_KIND);
return new JobRecord(key, jobInstance, settings);
} | [
"public",
"static",
"JobRecord",
"createRootJobRecord",
"(",
"Job",
"<",
"?",
">",
"jobInstance",
",",
"JobSetting",
"[",
"]",
"settings",
")",
"{",
"Key",
"key",
"=",
"generateKey",
"(",
"null",
",",
"DATA_STORE_KIND",
")",
";",
"return",
"new",
"JobRecord",
"(",
"key",
",",
"jobInstance",
",",
"settings",
")",
";",
"}"
] | A factory method for root jobs.
@param jobInstance The non-null user-supplied instance of {@code Job} that
implements the Job that the newly created JobRecord represents.
@param settings Array of {@code JobSetting} to apply to the newly created
JobRecord. | [
"A",
"factory",
"method",
"for",
"root",
"jobs",
"."
] | train | https://github.com/GoogleCloudPlatform/appengine-pipelines/blob/277394648dac3e8214677af898935d07399ac8e1/java/src/main/java/com/google/appengine/tools/pipeline/impl/model/JobRecord.java#L403-L406 |
alkacon/opencms-core | src/org/opencms/xml/CmsXmlUtils.java | CmsXmlUtils.createXpathElement | public static String createXpathElement(String path, int index) {
"""
Appends the provided index parameter in square brackets to the given name,
like <code>path[index]</code>.<p>
This method is used if it's clear that some path does not have
a square bracket already appended.<p>
@param path the path append the index to
@param index the index to append
@return the simplified Xpath for the given name
"""
StringBuffer result = new StringBuffer(path.length() + 5);
result.append(path);
result.append('[');
result.append(index);
result.append(']');
return result.toString();
} | java | public static String createXpathElement(String path, int index) {
StringBuffer result = new StringBuffer(path.length() + 5);
result.append(path);
result.append('[');
result.append(index);
result.append(']');
return result.toString();
} | [
"public",
"static",
"String",
"createXpathElement",
"(",
"String",
"path",
",",
"int",
"index",
")",
"{",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"path",
".",
"length",
"(",
")",
"+",
"5",
")",
";",
"result",
".",
"append",
"(",
"path",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"result",
".",
"append",
"(",
"index",
")",
";",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Appends the provided index parameter in square brackets to the given name,
like <code>path[index]</code>.<p>
This method is used if it's clear that some path does not have
a square bracket already appended.<p>
@param path the path append the index to
@param index the index to append
@return the simplified Xpath for the given name | [
"Appends",
"the",
"provided",
"index",
"parameter",
"in",
"square",
"brackets",
"to",
"the",
"given",
"name",
"like",
"<code",
">",
"path",
"[",
"index",
"]",
"<",
"/",
"code",
">",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/CmsXmlUtils.java#L213-L221 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java | ApiOvhHostingweb.serviceName_attachedDomain_domain_GET | public OvhAttachedDomain serviceName_attachedDomain_domain_GET(String serviceName, String domain) throws IOException {
"""
Get this object properties
REST: GET /hosting/web/{serviceName}/attachedDomain/{domain}
@param serviceName [required] The internal name of your hosting
@param domain [required] Domain linked (fqdn)
"""
String qPath = "/hosting/web/{serviceName}/attachedDomain/{domain}";
StringBuilder sb = path(qPath, serviceName, domain);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAttachedDomain.class);
} | java | public OvhAttachedDomain serviceName_attachedDomain_domain_GET(String serviceName, String domain) throws IOException {
String qPath = "/hosting/web/{serviceName}/attachedDomain/{domain}";
StringBuilder sb = path(qPath, serviceName, domain);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhAttachedDomain.class);
} | [
"public",
"OvhAttachedDomain",
"serviceName_attachedDomain_domain_GET",
"(",
"String",
"serviceName",
",",
"String",
"domain",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/web/{serviceName}/attachedDomain/{domain}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"domain",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhAttachedDomain",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /hosting/web/{serviceName}/attachedDomain/{domain}
@param serviceName [required] The internal name of your hosting
@param domain [required] Domain linked (fqdn) | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L1948-L1953 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java | MappingUtils.hasFunction | public static boolean hasFunction(Object object, String functionName, Class[] parameters) {
"""
Checks if Instance has specified function
@param object Instance which function would be checked
@param functionName function name
@param parameters function parameters (array of Class)
@return true if function is present in Instance
"""
boolean result = false;
try {
Method method = object.getClass().getMethod(functionName, parameters);
if (method != null) {
result = true;
}
} catch (NoSuchMethodException ex) {
result = false;
}
return result;
} | java | public static boolean hasFunction(Object object, String functionName, Class[] parameters) {
boolean result = false;
try {
Method method = object.getClass().getMethod(functionName, parameters);
if (method != null) {
result = true;
}
} catch (NoSuchMethodException ex) {
result = false;
}
return result;
} | [
"public",
"static",
"boolean",
"hasFunction",
"(",
"Object",
"object",
",",
"String",
"functionName",
",",
"Class",
"[",
"]",
"parameters",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"Method",
"method",
"=",
"object",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"functionName",
",",
"parameters",
")",
";",
"if",
"(",
"method",
"!=",
"null",
")",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"NoSuchMethodException",
"ex",
")",
"{",
"result",
"=",
"false",
";",
"}",
"return",
"result",
";",
"}"
] | Checks if Instance has specified function
@param object Instance which function would be checked
@param functionName function name
@param parameters function parameters (array of Class)
@return true if function is present in Instance | [
"Checks",
"if",
"Instance",
"has",
"specified",
"function"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/utils/MappingUtils.java#L307-L321 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/util/XpathUtils.java | XpathUtils.asInteger | public static Integer asInteger(String expression, Node node)
throws XPathExpressionException {
"""
Evaluates the specified XPath expression and returns the result as an
Integer.
<p>
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
{@link #asDouble(String, Node, XPath)} instead. Note {@link XPath} is
not thread-safe and not reentrant.
@param expression
The XPath expression to evaluate.
@param node
The node to run the expression on.
@return The Integer result.
@throws XPathExpressionException
If there was a problem processing the specified XPath
expression.
"""
return asInteger(expression, node, xpath());
} | java | public static Integer asInteger(String expression, Node node)
throws XPathExpressionException {
return asInteger(expression, node, xpath());
} | [
"public",
"static",
"Integer",
"asInteger",
"(",
"String",
"expression",
",",
"Node",
"node",
")",
"throws",
"XPathExpressionException",
"{",
"return",
"asInteger",
"(",
"expression",
",",
"node",
",",
"xpath",
"(",
")",
")",
";",
"}"
] | Evaluates the specified XPath expression and returns the result as an
Integer.
<p>
This method can be expensive as a new xpath is instantiated per
invocation. Consider passing in the xpath explicitly via {
{@link #asDouble(String, Node, XPath)} instead. Note {@link XPath} is
not thread-safe and not reentrant.
@param expression
The XPath expression to evaluate.
@param node
The node to run the expression on.
@return The Integer result.
@throws XPathExpressionException
If there was a problem processing the specified XPath
expression. | [
"Evaluates",
"the",
"specified",
"XPath",
"expression",
"and",
"returns",
"the",
"result",
"as",
"an",
"Integer",
".",
"<p",
">",
"This",
"method",
"can",
"be",
"expensive",
"as",
"a",
"new",
"xpath",
"is",
"instantiated",
"per",
"invocation",
".",
"Consider",
"passing",
"in",
"the",
"xpath",
"explicitly",
"via",
"{",
"{",
"@link",
"#asDouble",
"(",
"String",
"Node",
"XPath",
")",
"}",
"instead",
".",
"Note",
"{",
"@link",
"XPath",
"}",
"is",
"not",
"thread",
"-",
"safe",
"and",
"not",
"reentrant",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/util/XpathUtils.java#L277-L280 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java | SuspiciousComparatorReturnValues.visitCode | @Override
public void visitCode(Code obj) {
"""
implements the visitor to check to see what Const were returned from a comparator. If no Const were returned it can't determine anything, however if only
Const were returned, it looks to see if negative positive and zero was returned. It also looks to see if a non zero value is returned unconditionally.
While it is possible that later check is ok, it usually means something is wrong.
@param obj
the currently parsed code block
"""
if (getMethod().isSynthetic()) {
return;
}
String methodName = getMethodName();
String methodSig = getMethodSig();
if (methodName.equals(methodInfo.methodName) && methodSig.endsWith(methodInfo.signatureEnding)
&& (SignatureUtils.getNumParameters(methodSig) == methodInfo.argumentCount)) {
stack.resetForMethodEntry(this);
seenNegative = false;
seenPositive = false;
seenZero = false;
seenUnconditionalNonZero = false;
furthestBranchTarget = -1;
sawConstant = null;
try {
super.visitCode(obj);
if (!seenZero || seenUnconditionalNonZero || (obj.getCode().length > 2)) {
boolean seenAll = seenNegative & seenPositive & seenZero;
if (!seenAll || seenUnconditionalNonZero) {
bugReporter.reportBug(
new BugInstance(this, BugType.SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES.name(), seenAll ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, 0));
}
}
} catch (StopOpcodeParsingException e) {
// indeterminate
}
}
} | java | @Override
public void visitCode(Code obj) {
if (getMethod().isSynthetic()) {
return;
}
String methodName = getMethodName();
String methodSig = getMethodSig();
if (methodName.equals(methodInfo.methodName) && methodSig.endsWith(methodInfo.signatureEnding)
&& (SignatureUtils.getNumParameters(methodSig) == methodInfo.argumentCount)) {
stack.resetForMethodEntry(this);
seenNegative = false;
seenPositive = false;
seenZero = false;
seenUnconditionalNonZero = false;
furthestBranchTarget = -1;
sawConstant = null;
try {
super.visitCode(obj);
if (!seenZero || seenUnconditionalNonZero || (obj.getCode().length > 2)) {
boolean seenAll = seenNegative & seenPositive & seenZero;
if (!seenAll || seenUnconditionalNonZero) {
bugReporter.reportBug(
new BugInstance(this, BugType.SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES.name(), seenAll ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this).addMethod(this).addSourceLine(this, 0));
}
}
} catch (StopOpcodeParsingException e) {
// indeterminate
}
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"if",
"(",
"getMethod",
"(",
")",
".",
"isSynthetic",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"methodName",
"=",
"getMethodName",
"(",
")",
";",
"String",
"methodSig",
"=",
"getMethodSig",
"(",
")",
";",
"if",
"(",
"methodName",
".",
"equals",
"(",
"methodInfo",
".",
"methodName",
")",
"&&",
"methodSig",
".",
"endsWith",
"(",
"methodInfo",
".",
"signatureEnding",
")",
"&&",
"(",
"SignatureUtils",
".",
"getNumParameters",
"(",
"methodSig",
")",
"==",
"methodInfo",
".",
"argumentCount",
")",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"seenNegative",
"=",
"false",
";",
"seenPositive",
"=",
"false",
";",
"seenZero",
"=",
"false",
";",
"seenUnconditionalNonZero",
"=",
"false",
";",
"furthestBranchTarget",
"=",
"-",
"1",
";",
"sawConstant",
"=",
"null",
";",
"try",
"{",
"super",
".",
"visitCode",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"seenZero",
"||",
"seenUnconditionalNonZero",
"||",
"(",
"obj",
".",
"getCode",
"(",
")",
".",
"length",
">",
"2",
")",
")",
"{",
"boolean",
"seenAll",
"=",
"seenNegative",
"&",
"seenPositive",
"&",
"seenZero",
";",
"if",
"(",
"!",
"seenAll",
"||",
"seenUnconditionalNonZero",
")",
"{",
"bugReporter",
".",
"reportBug",
"(",
"new",
"BugInstance",
"(",
"this",
",",
"BugType",
".",
"SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES",
".",
"name",
"(",
")",
",",
"seenAll",
"?",
"LOW_PRIORITY",
":",
"NORMAL_PRIORITY",
")",
".",
"addClass",
"(",
"this",
")",
".",
"addMethod",
"(",
"this",
")",
".",
"addSourceLine",
"(",
"this",
",",
"0",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"StopOpcodeParsingException",
"e",
")",
"{",
"// indeterminate",
"}",
"}",
"}"
] | implements the visitor to check to see what Const were returned from a comparator. If no Const were returned it can't determine anything, however if only
Const were returned, it looks to see if negative positive and zero was returned. It also looks to see if a non zero value is returned unconditionally.
While it is possible that later check is ok, it usually means something is wrong.
@param obj
the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"check",
"to",
"see",
"what",
"Const",
"were",
"returned",
"from",
"a",
"comparator",
".",
"If",
"no",
"Const",
"were",
"returned",
"it",
"can",
"t",
"determine",
"anything",
"however",
"if",
"only",
"Const",
"were",
"returned",
"it",
"looks",
"to",
"see",
"if",
"negative",
"positive",
"and",
"zero",
"was",
"returned",
".",
"It",
"also",
"looks",
"to",
"see",
"if",
"a",
"non",
"zero",
"value",
"is",
"returned",
"unconditionally",
".",
"While",
"it",
"is",
"possible",
"that",
"later",
"check",
"is",
"ok",
"it",
"usually",
"means",
"something",
"is",
"wrong",
"."
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java#L119-L150 |
sebastiangraf/treetank | interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java | WorkerHelper.closeWTX | public static void closeWTX(final boolean abortTransaction, final INodeWriteTrx wtx, final ISession ses)
throws TTException {
"""
This method closes all open treetank connections concerning a
NodeWriteTrx.
@param abortTransaction
<code>true</code> if the transaction has to be aborted, <code>false</code> otherwise.
@param wtx
INodeWriteTrx to be closed
@param ses
ISession to be closed
@throws TreetankException
"""
synchronized (ses) {
if (abortTransaction) {
wtx.abort();
}
ses.close();
}
} | java | public static void closeWTX(final boolean abortTransaction, final INodeWriteTrx wtx, final ISession ses)
throws TTException {
synchronized (ses) {
if (abortTransaction) {
wtx.abort();
}
ses.close();
}
} | [
"public",
"static",
"void",
"closeWTX",
"(",
"final",
"boolean",
"abortTransaction",
",",
"final",
"INodeWriteTrx",
"wtx",
",",
"final",
"ISession",
"ses",
")",
"throws",
"TTException",
"{",
"synchronized",
"(",
"ses",
")",
"{",
"if",
"(",
"abortTransaction",
")",
"{",
"wtx",
".",
"abort",
"(",
")",
";",
"}",
"ses",
".",
"close",
"(",
")",
";",
"}",
"}"
] | This method closes all open treetank connections concerning a
NodeWriteTrx.
@param abortTransaction
<code>true</code> if the transaction has to be aborted, <code>false</code> otherwise.
@param wtx
INodeWriteTrx to be closed
@param ses
ISession to be closed
@throws TreetankException | [
"This",
"method",
"closes",
"all",
"open",
"treetank",
"connections",
"concerning",
"a",
"NodeWriteTrx",
"."
] | train | https://github.com/sebastiangraf/treetank/blob/9b96d631b6c2a8502a0cc958dcb02bd6a6fd8b60/interfacemodules/jax-rx/src/main/java/org/treetank/service/jaxrx/util/WorkerHelper.java#L195-L203 |
greenmail-mail-test/greenmail | greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMailUtil.java | GreenMailUtil.copyStream | public static void copyStream(final InputStream src, OutputStream dest) throws IOException {
"""
Writes the content of an input stream to an output stream
@throws IOException
"""
byte[] buffer = new byte[1024];
int read;
while ((read = src.read(buffer)) > -1) {
dest.write(buffer, 0, read);
}
dest.flush();
} | java | public static void copyStream(final InputStream src, OutputStream dest) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = src.read(buffer)) > -1) {
dest.write(buffer, 0, read);
}
dest.flush();
} | [
"public",
"static",
"void",
"copyStream",
"(",
"final",
"InputStream",
"src",
",",
"OutputStream",
"dest",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"int",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"src",
".",
"read",
"(",
"buffer",
")",
")",
">",
"-",
"1",
")",
"{",
"dest",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"read",
")",
";",
"}",
"dest",
".",
"flush",
"(",
")",
";",
"}"
] | Writes the content of an input stream to an output stream
@throws IOException | [
"Writes",
"the",
"content",
"of",
"an",
"input",
"stream",
"to",
"an",
"output",
"stream"
] | train | https://github.com/greenmail-mail-test/greenmail/blob/6d19a62233d1ef6fedbbd1f6fdde2d28e713834a/greenmail-core/src/main/java/com/icegreen/greenmail/util/GreenMailUtil.java#L56-L63 |
kuali/ojb-1.0.4 | src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java | SqlQueryStatement.getIndirectionTableColName | private String getIndirectionTableColName(TableAlias mnAlias, String path) {
"""
Get the column name from the indirection table.
@param mnAlias
@param path
"""
int dotIdx = path.lastIndexOf(".");
String column = path.substring(dotIdx);
return mnAlias.alias + column;
} | java | private String getIndirectionTableColName(TableAlias mnAlias, String path)
{
int dotIdx = path.lastIndexOf(".");
String column = path.substring(dotIdx);
return mnAlias.alias + column;
} | [
"private",
"String",
"getIndirectionTableColName",
"(",
"TableAlias",
"mnAlias",
",",
"String",
"path",
")",
"{",
"int",
"dotIdx",
"=",
"path",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"String",
"column",
"=",
"path",
".",
"substring",
"(",
"dotIdx",
")",
";",
"return",
"mnAlias",
".",
"alias",
"+",
"column",
";",
"}"
] | Get the column name from the indirection table.
@param mnAlias
@param path | [
"Get",
"the",
"column",
"name",
"from",
"the",
"indirection",
"table",
"."
] | train | https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java#L748-L753 |
dasein-cloud/dasein-cloud-aws | src/main/java/org/dasein/cloud/aws/AWSCloud.java | AWSCloud.addIndexedParameters | public static void addIndexedParameters( @Nonnull Map<String, String> parameters, @Nonnull String prefix, String ... values ) {
"""
Helper method for adding indexed member parameters, e.g. <i>AlarmNames.member.N</i>. Will overwrite existing
parameters if present. Assumes indexing starts at 1.
@param parameters the existing parameters map to add to
@param prefix the prefix value for each parameter key
@param values the values to add
"""
if( values == null || values.length == 0 ) {
return;
}
int i = 1;
if( !prefix.endsWith(".") ) {
prefix += ".";
}
for( String value : values ) {
parameters.put(String.format("%s%d", prefix, i), value);
i++;
}
} | java | public static void addIndexedParameters( @Nonnull Map<String, String> parameters, @Nonnull String prefix, String ... values ) {
if( values == null || values.length == 0 ) {
return;
}
int i = 1;
if( !prefix.endsWith(".") ) {
prefix += ".";
}
for( String value : values ) {
parameters.put(String.format("%s%d", prefix, i), value);
i++;
}
} | [
"public",
"static",
"void",
"addIndexedParameters",
"(",
"@",
"Nonnull",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"@",
"Nonnull",
"String",
"prefix",
",",
"String",
"...",
"values",
")",
"{",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
";",
"}",
"int",
"i",
"=",
"1",
";",
"if",
"(",
"!",
"prefix",
".",
"endsWith",
"(",
"\".\"",
")",
")",
"{",
"prefix",
"+=",
"\".\"",
";",
"}",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"parameters",
".",
"put",
"(",
"String",
".",
"format",
"(",
"\"%s%d\"",
",",
"prefix",
",",
"i",
")",
",",
"value",
")",
";",
"i",
"++",
";",
"}",
"}"
] | Helper method for adding indexed member parameters, e.g. <i>AlarmNames.member.N</i>. Will overwrite existing
parameters if present. Assumes indexing starts at 1.
@param parameters the existing parameters map to add to
@param prefix the prefix value for each parameter key
@param values the values to add | [
"Helper",
"method",
"for",
"adding",
"indexed",
"member",
"parameters",
"e",
".",
"g",
".",
"<i",
">",
"AlarmNames",
".",
"member",
".",
"N<",
"/",
"i",
">",
".",
"Will",
"overwrite",
"existing",
"parameters",
"if",
"present",
".",
"Assumes",
"indexing",
"starts",
"at",
"1",
"."
] | train | https://github.com/dasein-cloud/dasein-cloud-aws/blob/05098574197a1f573f77447cadc39a76bf00b99d/src/main/java/org/dasein/cloud/aws/AWSCloud.java#L1393-L1405 |
finmath/finmath-lib | src/main/java/net/finmath/marketdata/model/volatilities/AbstractVolatilitySurface.java | AbstractVolatilitySurface.convertFromTo | public double convertFromTo(double optionMaturity, double optionStrike, double value, QuotingConvention fromQuotingConvention, QuotingConvention toQuotingConvention) {
"""
Convert the value of a caplet from one quoting convention to another quoting convention.
@param optionMaturity Option maturity of the caplet.
@param optionStrike Option strike of the caplet.
@param value Value of the caplet given in the form of <code>fromQuotingConvention</code>.
@param fromQuotingConvention The quoting convention of the given value.
@param toQuotingConvention The quoting convention requested.
@return Value of the caplet given in the form of <code>toQuotingConvention</code>.
"""
return convertFromTo(null, optionMaturity, optionStrike, value, fromQuotingConvention, toQuotingConvention);
} | java | public double convertFromTo(double optionMaturity, double optionStrike, double value, QuotingConvention fromQuotingConvention, QuotingConvention toQuotingConvention) {
return convertFromTo(null, optionMaturity, optionStrike, value, fromQuotingConvention, toQuotingConvention);
} | [
"public",
"double",
"convertFromTo",
"(",
"double",
"optionMaturity",
",",
"double",
"optionStrike",
",",
"double",
"value",
",",
"QuotingConvention",
"fromQuotingConvention",
",",
"QuotingConvention",
"toQuotingConvention",
")",
"{",
"return",
"convertFromTo",
"(",
"null",
",",
"optionMaturity",
",",
"optionStrike",
",",
"value",
",",
"fromQuotingConvention",
",",
"toQuotingConvention",
")",
";",
"}"
] | Convert the value of a caplet from one quoting convention to another quoting convention.
@param optionMaturity Option maturity of the caplet.
@param optionStrike Option strike of the caplet.
@param value Value of the caplet given in the form of <code>fromQuotingConvention</code>.
@param fromQuotingConvention The quoting convention of the given value.
@param toQuotingConvention The quoting convention requested.
@return Value of the caplet given in the form of <code>toQuotingConvention</code>. | [
"Convert",
"the",
"value",
"of",
"a",
"caplet",
"from",
"one",
"quoting",
"convention",
"to",
"another",
"quoting",
"convention",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java/net/finmath/marketdata/model/volatilities/AbstractVolatilitySurface.java#L143-L145 |
moparisthebest/beehive | beehive-controls/src/main/java/org/apache/beehive/controls/runtime/webcontext/ControlBeanContextServicesSupport.java | ControlBeanContextServicesSupport.addService | public boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider) {
"""
Adds a service to this BeanContext.
<code>BeanContextServiceProvider</code>s call this method
to register a particular service with this context.
If the service has not previously been added, the
<code>BeanContextServices</code> associates
the service with the <code>BeanContextServiceProvider</code> and
fires a <code>BeanContextServiceAvailableEvent</code> to all
currently registered <code>BeanContextServicesListeners</code>.
The method then returns <code>true</code>, indicating that
the addition of the service was successful.
If the given service has already been added, this method
simply returns <code>false</code>.
@param serviceClass the service to add
@param serviceProvider the <code>BeanContextServiceProvider</code>
associated with the service
@return true if service was added.
"""
// todo: for multithreaded usage this block needs to be synchronized
if (!_serviceProviders.containsKey(serviceClass)) {
_serviceProviders.put(serviceClass, new ServiceProvider(serviceProvider));
BeanContextServiceAvailableEvent bcsae = new BeanContextServiceAvailableEvent((BeanContextServices)getPeer(), serviceClass);
fireServiceAvailableEvent(bcsae);
return true;
}
// end synchronized
return false;
} | java | public boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider) {
// todo: for multithreaded usage this block needs to be synchronized
if (!_serviceProviders.containsKey(serviceClass)) {
_serviceProviders.put(serviceClass, new ServiceProvider(serviceProvider));
BeanContextServiceAvailableEvent bcsae = new BeanContextServiceAvailableEvent((BeanContextServices)getPeer(), serviceClass);
fireServiceAvailableEvent(bcsae);
return true;
}
// end synchronized
return false;
} | [
"public",
"boolean",
"addService",
"(",
"Class",
"serviceClass",
",",
"BeanContextServiceProvider",
"serviceProvider",
")",
"{",
"// todo: for multithreaded usage this block needs to be synchronized",
"if",
"(",
"!",
"_serviceProviders",
".",
"containsKey",
"(",
"serviceClass",
")",
")",
"{",
"_serviceProviders",
".",
"put",
"(",
"serviceClass",
",",
"new",
"ServiceProvider",
"(",
"serviceProvider",
")",
")",
";",
"BeanContextServiceAvailableEvent",
"bcsae",
"=",
"new",
"BeanContextServiceAvailableEvent",
"(",
"(",
"BeanContextServices",
")",
"getPeer",
"(",
")",
",",
"serviceClass",
")",
";",
"fireServiceAvailableEvent",
"(",
"bcsae",
")",
";",
"return",
"true",
";",
"}",
"// end synchronized",
"return",
"false",
";",
"}"
] | Adds a service to this BeanContext.
<code>BeanContextServiceProvider</code>s call this method
to register a particular service with this context.
If the service has not previously been added, the
<code>BeanContextServices</code> associates
the service with the <code>BeanContextServiceProvider</code> and
fires a <code>BeanContextServiceAvailableEvent</code> to all
currently registered <code>BeanContextServicesListeners</code>.
The method then returns <code>true</code>, indicating that
the addition of the service was successful.
If the given service has already been added, this method
simply returns <code>false</code>.
@param serviceClass the service to add
@param serviceProvider the <code>BeanContextServiceProvider</code>
associated with the service
@return true if service was added. | [
"Adds",
"a",
"service",
"to",
"this",
"BeanContext",
".",
"<code",
">",
"BeanContextServiceProvider<",
"/",
"code",
">",
"s",
"call",
"this",
"method",
"to",
"register",
"a",
"particular",
"service",
"with",
"this",
"context",
".",
"If",
"the",
"service",
"has",
"not",
"previously",
"been",
"added",
"the",
"<code",
">",
"BeanContextServices<",
"/",
"code",
">",
"associates",
"the",
"service",
"with",
"the",
"<code",
">",
"BeanContextServiceProvider<",
"/",
"code",
">",
"and",
"fires",
"a",
"<code",
">",
"BeanContextServiceAvailableEvent<",
"/",
"code",
">",
"to",
"all",
"currently",
"registered",
"<code",
">",
"BeanContextServicesListeners<",
"/",
"code",
">",
".",
"The",
"method",
"then",
"returns",
"<code",
">",
"true<",
"/",
"code",
">",
"indicating",
"that",
"the",
"addition",
"of",
"the",
"service",
"was",
"successful",
".",
"If",
"the",
"given",
"service",
"has",
"already",
"been",
"added",
"this",
"method",
"simply",
"returns",
"<code",
">",
"false<",
"/",
"code",
">",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-controls/src/main/java/org/apache/beehive/controls/runtime/webcontext/ControlBeanContextServicesSupport.java#L86-L96 |
wildfly/wildfly-core | embedded/src/main/java/org/wildfly/core/embedded/EmbeddedProcessFactory.java | EmbeddedProcessFactory.createHostController | public static HostController createHostController(ModuleLoader moduleLoader, File jbossHomeDir, String[] cmdargs) {
"""
Create an embedded host controller with an already established module loader.
@param moduleLoader the module loader. Cannot be {@code null}
@param jbossHomeDir the location of the root of server installation. Cannot be {@code null} or empty.
@param cmdargs any additional arguments to pass to the embedded host controller (e.g. -b=192.168.100.10)
@return the running host controller Will not be {@code null}
"""
return createHostController(
Configuration.Builder.of(jbossHomeDir)
.setModuleLoader(moduleLoader)
.setCommandArguments(cmdargs)
.build()
);
} | java | public static HostController createHostController(ModuleLoader moduleLoader, File jbossHomeDir, String[] cmdargs) {
return createHostController(
Configuration.Builder.of(jbossHomeDir)
.setModuleLoader(moduleLoader)
.setCommandArguments(cmdargs)
.build()
);
} | [
"public",
"static",
"HostController",
"createHostController",
"(",
"ModuleLoader",
"moduleLoader",
",",
"File",
"jbossHomeDir",
",",
"String",
"[",
"]",
"cmdargs",
")",
"{",
"return",
"createHostController",
"(",
"Configuration",
".",
"Builder",
".",
"of",
"(",
"jbossHomeDir",
")",
".",
"setModuleLoader",
"(",
"moduleLoader",
")",
".",
"setCommandArguments",
"(",
"cmdargs",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] | Create an embedded host controller with an already established module loader.
@param moduleLoader the module loader. Cannot be {@code null}
@param jbossHomeDir the location of the root of server installation. Cannot be {@code null} or empty.
@param cmdargs any additional arguments to pass to the embedded host controller (e.g. -b=192.168.100.10)
@return the running host controller Will not be {@code null} | [
"Create",
"an",
"embedded",
"host",
"controller",
"with",
"an",
"already",
"established",
"module",
"loader",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/embedded/src/main/java/org/wildfly/core/embedded/EmbeddedProcessFactory.java#L231-L238 |
radkovo/Pdf2Dom | src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java | CSSBoxTree.renderImage | @Override
protected void renderImage(float x, float y, float width, float height, ImageResource resource) throws IOException {
"""
/*protected void renderRectangle(float x, float y, float width, float height, boolean stroke, boolean fill)
{
DOM element
Element el = createRectangleElement(x, y, width, height, stroke, fill);
curpage.appendChild(el);
Block box
BlockBox block = createBlock(pagebox, el, false);
block.setStyle(createRectangleStyle(x, y, width, height, stroke, fill));
pagebox.addSubBox(block);
}
"""
//DOM element
Element el = createImageElement(x, y, width, height, resource);
curpage.appendChild(el);
//Image box
BlockBox block = createBlock(pagebox, el, true);
block.setStyle(createRectangleStyle(x, y, width, height, false, false));
pagebox.addSubBox(block);
} | java | @Override
protected void renderImage(float x, float y, float width, float height, ImageResource resource) throws IOException
{
//DOM element
Element el = createImageElement(x, y, width, height, resource);
curpage.appendChild(el);
//Image box
BlockBox block = createBlock(pagebox, el, true);
block.setStyle(createRectangleStyle(x, y, width, height, false, false));
pagebox.addSubBox(block);
} | [
"@",
"Override",
"protected",
"void",
"renderImage",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"width",
",",
"float",
"height",
",",
"ImageResource",
"resource",
")",
"throws",
"IOException",
"{",
"//DOM element",
"Element",
"el",
"=",
"createImageElement",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"resource",
")",
";",
"curpage",
".",
"appendChild",
"(",
"el",
")",
";",
"//Image box",
"BlockBox",
"block",
"=",
"createBlock",
"(",
"pagebox",
",",
"el",
",",
"true",
")",
";",
"block",
".",
"setStyle",
"(",
"createRectangleStyle",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"false",
",",
"false",
")",
")",
";",
"pagebox",
".",
"addSubBox",
"(",
"block",
")",
";",
"}"
] | /*protected void renderRectangle(float x, float y, float width, float height, boolean stroke, boolean fill)
{
DOM element
Element el = createRectangleElement(x, y, width, height, stroke, fill);
curpage.appendChild(el);
Block box
BlockBox block = createBlock(pagebox, el, false);
block.setStyle(createRectangleStyle(x, y, width, height, stroke, fill));
pagebox.addSubBox(block);
} | [
"/",
"*",
"protected",
"void",
"renderRectangle",
"(",
"float",
"x",
"float",
"y",
"float",
"width",
"float",
"height",
"boolean",
"stroke",
"boolean",
"fill",
")",
"{",
"DOM",
"element",
"Element",
"el",
"=",
"createRectangleElement",
"(",
"x",
"y",
"width",
"height",
"stroke",
"fill",
")",
";",
"curpage",
".",
"appendChild",
"(",
"el",
")",
";",
"Block",
"box",
"BlockBox",
"block",
"=",
"createBlock",
"(",
"pagebox",
"el",
"false",
")",
";",
"block",
".",
"setStyle",
"(",
"createRectangleStyle",
"(",
"x",
"y",
"width",
"height",
"stroke",
"fill",
"))",
";",
"pagebox",
".",
"addSubBox",
"(",
"block",
")",
";",
"}"
] | train | https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/cssbox/pdf/CSSBoxTree.java#L250-L260 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.getCompositeEntityRoles | public List<EntityRole> getCompositeEntityRoles(UUID appId, String versionId, UUID cEntityId) {
"""
Get All Entity Roles for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@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 List<EntityRole> object if successful.
"""
return getCompositeEntityRolesWithServiceResponseAsync(appId, versionId, cEntityId).toBlocking().single().body();
} | java | public List<EntityRole> getCompositeEntityRoles(UUID appId, String versionId, UUID cEntityId) {
return getCompositeEntityRolesWithServiceResponseAsync(appId, versionId, cEntityId).toBlocking().single().body();
} | [
"public",
"List",
"<",
"EntityRole",
">",
"getCompositeEntityRoles",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"cEntityId",
")",
"{",
"return",
"getCompositeEntityRolesWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"cEntityId",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get All Entity Roles for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@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 List<EntityRole> object if successful. | [
"Get",
"All",
"Entity",
"Roles",
"for",
"a",
"given",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L8779-L8781 |
goldmansachs/gs-collections | collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java | MapIterate.injectIntoIf | public static <IV, K, V> IV injectIntoIf(
IV initialValue,
Map<K, V> map,
final Predicate<? super V> predicate,
final Function2<? super IV, ? super V, ? extends IV> function) {
"""
Same as {@link #injectInto(Object, Map, Function2)}, but only applies the value to the function
if the predicate returns true for the value.
@see #injectInto(Object, Map, Function2)
"""
Function2<IV, ? super V, IV> ifFunction = new Function2<IV, V, IV>()
{
public IV value(IV accumulator, V item)
{
if (predicate.accept(item))
{
return function.value(accumulator, item);
}
return accumulator;
}
};
return Iterate.injectInto(initialValue, map.values(), ifFunction);
} | java | public static <IV, K, V> IV injectIntoIf(
IV initialValue,
Map<K, V> map,
final Predicate<? super V> predicate,
final Function2<? super IV, ? super V, ? extends IV> function)
{
Function2<IV, ? super V, IV> ifFunction = new Function2<IV, V, IV>()
{
public IV value(IV accumulator, V item)
{
if (predicate.accept(item))
{
return function.value(accumulator, item);
}
return accumulator;
}
};
return Iterate.injectInto(initialValue, map.values(), ifFunction);
} | [
"public",
"static",
"<",
"IV",
",",
"K",
",",
"V",
">",
"IV",
"injectIntoIf",
"(",
"IV",
"initialValue",
",",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"final",
"Predicate",
"<",
"?",
"super",
"V",
">",
"predicate",
",",
"final",
"Function2",
"<",
"?",
"super",
"IV",
",",
"?",
"super",
"V",
",",
"?",
"extends",
"IV",
">",
"function",
")",
"{",
"Function2",
"<",
"IV",
",",
"?",
"super",
"V",
",",
"IV",
">",
"ifFunction",
"=",
"new",
"Function2",
"<",
"IV",
",",
"V",
",",
"IV",
">",
"(",
")",
"{",
"public",
"IV",
"value",
"(",
"IV",
"accumulator",
",",
"V",
"item",
")",
"{",
"if",
"(",
"predicate",
".",
"accept",
"(",
"item",
")",
")",
"{",
"return",
"function",
".",
"value",
"(",
"accumulator",
",",
"item",
")",
";",
"}",
"return",
"accumulator",
";",
"}",
"}",
";",
"return",
"Iterate",
".",
"injectInto",
"(",
"initialValue",
",",
"map",
".",
"values",
"(",
")",
",",
"ifFunction",
")",
";",
"}"
] | Same as {@link #injectInto(Object, Map, Function2)}, but only applies the value to the function
if the predicate returns true for the value.
@see #injectInto(Object, Map, Function2) | [
"Same",
"as",
"{",
"@link",
"#injectInto",
"(",
"Object",
"Map",
"Function2",
")",
"}",
"but",
"only",
"applies",
"the",
"value",
"to",
"the",
"function",
"if",
"the",
"predicate",
"returns",
"true",
"for",
"the",
"value",
"."
] | train | https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java#L929-L947 |
alkacon/opencms-core | src/org/opencms/search/solr/CmsSolrFieldConfiguration.java | CmsSolrFieldConfiguration.appendSpellFields | private void appendSpellFields(I_CmsSearchDocument document) {
"""
Copy the content and the title property of the document to a spell field / a language specific spell field.
@param document the document that gets extended by the spell fields.
"""
/*
* Add the content fields (multiple for contents with more than one locale)
*/
// add the content_<locale> fields to this configuration
String title = document.getFieldValueAsString(
CmsPropertyDefinition.PROPERTY_TITLE + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT);
document.addSearchField(
new CmsSolrField(CmsSearchField.FIELD_SPELL, null, null, null),
document.getFieldValueAsString(CmsSearchField.FIELD_CONTENT) + "\n" + title);
for (Locale locale : OpenCms.getLocaleManager().getAvailableLocales()) {
document.addSearchField(
new CmsSolrField(locale + "_" + CmsSearchField.FIELD_SPELL, null, locale, null),
document.getFieldValueAsString(
CmsSearchFieldConfiguration.getLocaleExtendedName(CmsSearchField.FIELD_CONTENT, locale))
+ "\n"
+ title);
}
} | java | private void appendSpellFields(I_CmsSearchDocument document) {
/*
* Add the content fields (multiple for contents with more than one locale)
*/
// add the content_<locale> fields to this configuration
String title = document.getFieldValueAsString(
CmsPropertyDefinition.PROPERTY_TITLE + CmsSearchField.FIELD_DYNAMIC_PROPERTIES_DIRECT);
document.addSearchField(
new CmsSolrField(CmsSearchField.FIELD_SPELL, null, null, null),
document.getFieldValueAsString(CmsSearchField.FIELD_CONTENT) + "\n" + title);
for (Locale locale : OpenCms.getLocaleManager().getAvailableLocales()) {
document.addSearchField(
new CmsSolrField(locale + "_" + CmsSearchField.FIELD_SPELL, null, locale, null),
document.getFieldValueAsString(
CmsSearchFieldConfiguration.getLocaleExtendedName(CmsSearchField.FIELD_CONTENT, locale))
+ "\n"
+ title);
}
} | [
"private",
"void",
"appendSpellFields",
"(",
"I_CmsSearchDocument",
"document",
")",
"{",
"/*\n * Add the content fields (multiple for contents with more than one locale)\n */",
"// add the content_<locale> fields to this configuration",
"String",
"title",
"=",
"document",
".",
"getFieldValueAsString",
"(",
"CmsPropertyDefinition",
".",
"PROPERTY_TITLE",
"+",
"CmsSearchField",
".",
"FIELD_DYNAMIC_PROPERTIES_DIRECT",
")",
";",
"document",
".",
"addSearchField",
"(",
"new",
"CmsSolrField",
"(",
"CmsSearchField",
".",
"FIELD_SPELL",
",",
"null",
",",
"null",
",",
"null",
")",
",",
"document",
".",
"getFieldValueAsString",
"(",
"CmsSearchField",
".",
"FIELD_CONTENT",
")",
"+",
"\"\\n\"",
"+",
"title",
")",
";",
"for",
"(",
"Locale",
"locale",
":",
"OpenCms",
".",
"getLocaleManager",
"(",
")",
".",
"getAvailableLocales",
"(",
")",
")",
"{",
"document",
".",
"addSearchField",
"(",
"new",
"CmsSolrField",
"(",
"locale",
"+",
"\"_\"",
"+",
"CmsSearchField",
".",
"FIELD_SPELL",
",",
"null",
",",
"locale",
",",
"null",
")",
",",
"document",
".",
"getFieldValueAsString",
"(",
"CmsSearchFieldConfiguration",
".",
"getLocaleExtendedName",
"(",
"CmsSearchField",
".",
"FIELD_CONTENT",
",",
"locale",
")",
")",
"+",
"\"\\n\"",
"+",
"title",
")",
";",
"}",
"}"
] | Copy the content and the title property of the document to a spell field / a language specific spell field.
@param document the document that gets extended by the spell fields. | [
"Copy",
"the",
"content",
"and",
"the",
"title",
"property",
"of",
"the",
"document",
"to",
"a",
"spell",
"field",
"/",
"a",
"language",
"specific",
"spell",
"field",
"."
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/solr/CmsSolrFieldConfiguration.java#L871-L890 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveTargetPathHelper.java | HiveTargetPathHelper.resolvePath | protected static Path resolvePath(String pattern, String database, String table) {
"""
Takes a path with tokens {@link #databaseToken} or {@link #tableToken} and replaces these tokens with the actual
database names and table name. For example, if db is myDatabase, table is myTable, then /data/$DB/$TABLE will be
resolved to /data/myDatabase/myTable.
"""
pattern = pattern.replace(HiveDataset.DATABASE_TOKEN, database);
if (pattern.contains(HiveDataset.TABLE_TOKEN)) {
pattern = pattern.replace(HiveDataset.TABLE_TOKEN, table);
return new Path(pattern);
} else {
return new Path(pattern, table);
}
} | java | protected static Path resolvePath(String pattern, String database, String table) {
pattern = pattern.replace(HiveDataset.DATABASE_TOKEN, database);
if (pattern.contains(HiveDataset.TABLE_TOKEN)) {
pattern = pattern.replace(HiveDataset.TABLE_TOKEN, table);
return new Path(pattern);
} else {
return new Path(pattern, table);
}
} | [
"protected",
"static",
"Path",
"resolvePath",
"(",
"String",
"pattern",
",",
"String",
"database",
",",
"String",
"table",
")",
"{",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"HiveDataset",
".",
"DATABASE_TOKEN",
",",
"database",
")",
";",
"if",
"(",
"pattern",
".",
"contains",
"(",
"HiveDataset",
".",
"TABLE_TOKEN",
")",
")",
"{",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"HiveDataset",
".",
"TABLE_TOKEN",
",",
"table",
")",
";",
"return",
"new",
"Path",
"(",
"pattern",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Path",
"(",
"pattern",
",",
"table",
")",
";",
"}",
"}"
] | Takes a path with tokens {@link #databaseToken} or {@link #tableToken} and replaces these tokens with the actual
database names and table name. For example, if db is myDatabase, table is myTable, then /data/$DB/$TABLE will be
resolved to /data/myDatabase/myTable. | [
"Takes",
"a",
"path",
"with",
"tokens",
"{"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveTargetPathHelper.java#L106-L114 |
Bedework/bw-util | bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java | DirRecord.addAttr | public void addAttr(String attr, Object val) throws NamingException {
"""
Add the attribute value to the table. If an attribute already exists
add it to the end of its values.
@param attr String attribute name
@param val Object value
@throws NamingException
"""
// System.out.println("addAttr " + attr);
Attribute a = findAttr(attr);
if (a == null) {
setAttr(attr, val);
} else {
a.add(val);
}
} | java | public void addAttr(String attr, Object val) throws NamingException {
// System.out.println("addAttr " + attr);
Attribute a = findAttr(attr);
if (a == null) {
setAttr(attr, val);
} else {
a.add(val);
}
} | [
"public",
"void",
"addAttr",
"(",
"String",
"attr",
",",
"Object",
"val",
")",
"throws",
"NamingException",
"{",
"// System.out.println(\"addAttr \" + attr);",
"Attribute",
"a",
"=",
"findAttr",
"(",
"attr",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"setAttr",
"(",
"attr",
",",
"val",
")",
";",
"}",
"else",
"{",
"a",
".",
"add",
"(",
"val",
")",
";",
"}",
"}"
] | Add the attribute value to the table. If an attribute already exists
add it to the end of its values.
@param attr String attribute name
@param val Object value
@throws NamingException | [
"Add",
"the",
"attribute",
"value",
"to",
"the",
"table",
".",
"If",
"an",
"attribute",
"already",
"exists",
"add",
"it",
"to",
"the",
"end",
"of",
"its",
"values",
"."
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-directory/src/main/java/org/bedework/util/directory/common/DirRecord.java#L479-L489 |
FasterXML/jackson-jr | jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueReaderLocator.java | ValueReaderLocator.findReader | public ValueReader findReader(Class<?> raw) {
"""
Method used during deserialization to find handler for given
non-generic type.
"""
ClassKey k = (_key == null) ? new ClassKey(raw, _features) : _key.with(raw, _features);
ValueReader vr = _knownReaders.get(k);
if (vr != null) {
return vr;
}
vr = createReader(null, raw, raw);
// 15-Jun-2016, tatu: Let's limit maximum number of readers to prevent
// unbounded memory retention (at least wrt readers)
if (_knownReaders.size() >= MAX_CACHED_READERS) {
_knownReaders.clear();
}
_knownReaders.putIfAbsent(new ClassKey(raw, _features), vr);
return vr;
} | java | public ValueReader findReader(Class<?> raw)
{
ClassKey k = (_key == null) ? new ClassKey(raw, _features) : _key.with(raw, _features);
ValueReader vr = _knownReaders.get(k);
if (vr != null) {
return vr;
}
vr = createReader(null, raw, raw);
// 15-Jun-2016, tatu: Let's limit maximum number of readers to prevent
// unbounded memory retention (at least wrt readers)
if (_knownReaders.size() >= MAX_CACHED_READERS) {
_knownReaders.clear();
}
_knownReaders.putIfAbsent(new ClassKey(raw, _features), vr);
return vr;
} | [
"public",
"ValueReader",
"findReader",
"(",
"Class",
"<",
"?",
">",
"raw",
")",
"{",
"ClassKey",
"k",
"=",
"(",
"_key",
"==",
"null",
")",
"?",
"new",
"ClassKey",
"(",
"raw",
",",
"_features",
")",
":",
"_key",
".",
"with",
"(",
"raw",
",",
"_features",
")",
";",
"ValueReader",
"vr",
"=",
"_knownReaders",
".",
"get",
"(",
"k",
")",
";",
"if",
"(",
"vr",
"!=",
"null",
")",
"{",
"return",
"vr",
";",
"}",
"vr",
"=",
"createReader",
"(",
"null",
",",
"raw",
",",
"raw",
")",
";",
"// 15-Jun-2016, tatu: Let's limit maximum number of readers to prevent",
"// unbounded memory retention (at least wrt readers)",
"if",
"(",
"_knownReaders",
".",
"size",
"(",
")",
">=",
"MAX_CACHED_READERS",
")",
"{",
"_knownReaders",
".",
"clear",
"(",
")",
";",
"}",
"_knownReaders",
".",
"putIfAbsent",
"(",
"new",
"ClassKey",
"(",
"raw",
",",
"_features",
")",
",",
"vr",
")",
";",
"return",
"vr",
";",
"}"
] | Method used during deserialization to find handler for given
non-generic type. | [
"Method",
"used",
"during",
"deserialization",
"to",
"find",
"handler",
"for",
"given",
"non",
"-",
"generic",
"type",
"."
] | train | https://github.com/FasterXML/jackson-jr/blob/62ca7a82bd90a9be77028e0b62364307d7532837/jr-objects/src/main/java/com/fasterxml/jackson/jr/ob/impl/ValueReaderLocator.java#L136-L151 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/sampling/ReservoirItemsUnion.java | ReservoirItemsUnion.toByteArray | public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) {
"""
Returns a byte array representation of this union
@param serDe An instance of ArrayOfItemsSerDe
@return a byte array representation of this union
"""
if ((gadget_ == null) || (gadget_.getNumSamples() == 0)) {
return toByteArray(serDe, null);
} else {
return toByteArray(serDe, gadget_.getValueAtPosition(0).getClass());
}
} | java | public byte[] toByteArray(final ArrayOfItemsSerDe<T> serDe) {
if ((gadget_ == null) || (gadget_.getNumSamples() == 0)) {
return toByteArray(serDe, null);
} else {
return toByteArray(serDe, gadget_.getValueAtPosition(0).getClass());
}
} | [
"public",
"byte",
"[",
"]",
"toByteArray",
"(",
"final",
"ArrayOfItemsSerDe",
"<",
"T",
">",
"serDe",
")",
"{",
"if",
"(",
"(",
"gadget_",
"==",
"null",
")",
"||",
"(",
"gadget_",
".",
"getNumSamples",
"(",
")",
"==",
"0",
")",
")",
"{",
"return",
"toByteArray",
"(",
"serDe",
",",
"null",
")",
";",
"}",
"else",
"{",
"return",
"toByteArray",
"(",
"serDe",
",",
"gadget_",
".",
"getValueAtPosition",
"(",
"0",
")",
".",
"getClass",
"(",
")",
")",
";",
"}",
"}"
] | Returns a byte array representation of this union
@param serDe An instance of ArrayOfItemsSerDe
@return a byte array representation of this union | [
"Returns",
"a",
"byte",
"array",
"representation",
"of",
"this",
"union"
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/sampling/ReservoirItemsUnion.java#L235-L241 |
vincentk/joptimizer | src/main/java/com/joptimizer/util/ColtUtils.java | ColtUtils.zMult | public static final DoubleMatrix1D zMult(final DoubleMatrix2D A, final DoubleMatrix1D b, final double beta) {
"""
Returns v = beta * A.b.
Useful in avoiding the need of the copy() in the colt api.
"""
if(A.columns() != b.size()){
throw new IllegalArgumentException("wrong matrices dimensions");
}
final DoubleMatrix1D ret = DoubleFactory1D.dense.make(A.rows());
if(A instanceof SparseDoubleMatrix2D){
//sparse matrix
A.forEachNonZero(new IntIntDoubleFunction() {
@Override
public double apply(int i, int j, double Aij) {
double vi = 0;
vi += Aij * b.getQuick(j);
ret.setQuick(i, ret.getQuick(i) + beta * vi);
return Aij;
}
});
}else{
//dense matrix
for(int i=0; i<A.rows(); i++){
double vi = 0;
for(int j=0; j<A.columns(); j++){
vi += A.getQuick(i, j) * b.getQuick(j);
}
ret.setQuick(i, beta * vi);
}
}
return ret;
} | java | public static final DoubleMatrix1D zMult(final DoubleMatrix2D A, final DoubleMatrix1D b, final double beta){
if(A.columns() != b.size()){
throw new IllegalArgumentException("wrong matrices dimensions");
}
final DoubleMatrix1D ret = DoubleFactory1D.dense.make(A.rows());
if(A instanceof SparseDoubleMatrix2D){
//sparse matrix
A.forEachNonZero(new IntIntDoubleFunction() {
@Override
public double apply(int i, int j, double Aij) {
double vi = 0;
vi += Aij * b.getQuick(j);
ret.setQuick(i, ret.getQuick(i) + beta * vi);
return Aij;
}
});
}else{
//dense matrix
for(int i=0; i<A.rows(); i++){
double vi = 0;
for(int j=0; j<A.columns(); j++){
vi += A.getQuick(i, j) * b.getQuick(j);
}
ret.setQuick(i, beta * vi);
}
}
return ret;
} | [
"public",
"static",
"final",
"DoubleMatrix1D",
"zMult",
"(",
"final",
"DoubleMatrix2D",
"A",
",",
"final",
"DoubleMatrix1D",
"b",
",",
"final",
"double",
"beta",
")",
"{",
"if",
"(",
"A",
".",
"columns",
"(",
")",
"!=",
"b",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"wrong matrices dimensions\"",
")",
";",
"}",
"final",
"DoubleMatrix1D",
"ret",
"=",
"DoubleFactory1D",
".",
"dense",
".",
"make",
"(",
"A",
".",
"rows",
"(",
")",
")",
";",
"if",
"(",
"A",
"instanceof",
"SparseDoubleMatrix2D",
")",
"{",
"//sparse matrix\r",
"A",
".",
"forEachNonZero",
"(",
"new",
"IntIntDoubleFunction",
"(",
")",
"{",
"@",
"Override",
"public",
"double",
"apply",
"(",
"int",
"i",
",",
"int",
"j",
",",
"double",
"Aij",
")",
"{",
"double",
"vi",
"=",
"0",
";",
"vi",
"+=",
"Aij",
"*",
"b",
".",
"getQuick",
"(",
"j",
")",
";",
"ret",
".",
"setQuick",
"(",
"i",
",",
"ret",
".",
"getQuick",
"(",
"i",
")",
"+",
"beta",
"*",
"vi",
")",
";",
"return",
"Aij",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"//dense matrix\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"A",
".",
"rows",
"(",
")",
";",
"i",
"++",
")",
"{",
"double",
"vi",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"A",
".",
"columns",
"(",
")",
";",
"j",
"++",
")",
"{",
"vi",
"+=",
"A",
".",
"getQuick",
"(",
"i",
",",
"j",
")",
"*",
"b",
".",
"getQuick",
"(",
"j",
")",
";",
"}",
"ret",
".",
"setQuick",
"(",
"i",
",",
"beta",
"*",
"vi",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] | Returns v = beta * A.b.
Useful in avoiding the need of the copy() in the colt api. | [
"Returns",
"v",
"=",
"beta",
"*",
"A",
".",
"b",
".",
"Useful",
"in",
"avoiding",
"the",
"need",
"of",
"the",
"copy",
"()",
"in",
"the",
"colt",
"api",
"."
] | train | https://github.com/vincentk/joptimizer/blob/65064c1bb0b26c7261358021e4c93d06dd43564f/src/main/java/com/joptimizer/util/ColtUtils.java#L199-L228 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/util/ItemUtils.java | ItemUtils.getItemStackFromState | public static ItemStack getItemStackFromState(IBlockState state) {
"""
Gets the {@link ItemStack} matching the specified {@link IBlockState}
@param state the state
@return the item stack from state
"""
if (state == null)
return null;
Item item = Item.getItemFromBlock(state.getBlock());
if (item == null)
return ItemStack.EMPTY;
return new ItemStack(item, 1, state.getBlock().damageDropped(state));
} | java | public static ItemStack getItemStackFromState(IBlockState state)
{
if (state == null)
return null;
Item item = Item.getItemFromBlock(state.getBlock());
if (item == null)
return ItemStack.EMPTY;
return new ItemStack(item, 1, state.getBlock().damageDropped(state));
} | [
"public",
"static",
"ItemStack",
"getItemStackFromState",
"(",
"IBlockState",
"state",
")",
"{",
"if",
"(",
"state",
"==",
"null",
")",
"return",
"null",
";",
"Item",
"item",
"=",
"Item",
".",
"getItemFromBlock",
"(",
"state",
".",
"getBlock",
"(",
")",
")",
";",
"if",
"(",
"item",
"==",
"null",
")",
"return",
"ItemStack",
".",
"EMPTY",
";",
"return",
"new",
"ItemStack",
"(",
"item",
",",
"1",
",",
"state",
".",
"getBlock",
"(",
")",
".",
"damageDropped",
"(",
"state",
")",
")",
";",
"}"
] | Gets the {@link ItemStack} matching the specified {@link IBlockState}
@param state the state
@return the item stack from state | [
"Gets",
"the",
"{",
"@link",
"ItemStack",
"}",
"matching",
"the",
"specified",
"{",
"@link",
"IBlockState",
"}"
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/util/ItemUtils.java#L279-L287 |
liferay/com-liferay-commerce | commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPDefinitionOptionValueRelWrapper.java | CPDefinitionOptionValueRelWrapper.getName | @Override
public String getName(String languageId, boolean useDefault) {
"""
Returns the localized name of this cp definition option value rel in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp definition option value rel
"""
return _cpDefinitionOptionValueRel.getName(languageId, useDefault);
} | java | @Override
public String getName(String languageId, boolean useDefault) {
return _cpDefinitionOptionValueRel.getName(languageId, useDefault);
} | [
"@",
"Override",
"public",
"String",
"getName",
"(",
"String",
"languageId",
",",
"boolean",
"useDefault",
")",
"{",
"return",
"_cpDefinitionOptionValueRel",
".",
"getName",
"(",
"languageId",
",",
"useDefault",
")",
";",
"}"
] | Returns the localized name of this cp definition option value rel in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp definition option value rel | [
"Returns",
"the",
"localized",
"name",
"of",
"this",
"cp",
"definition",
"option",
"value",
"rel",
"in",
"the",
"language",
"optionally",
"using",
"the",
"default",
"language",
"if",
"no",
"localization",
"exists",
"for",
"the",
"requested",
"language",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPDefinitionOptionValueRelWrapper.java#L311-L314 |
advantageous/boon | reflekt/src/main/java/io/advantageous/boon/core/Str.java | Str.slcEnd | public static String slcEnd( String str, int end ) {
"""
Gets end slice of a string.
@param str string
@param end end index of slice
@return new string
"""
return FastStringUtils.noCopyStringFromChars( Chr.slcEnd( FastStringUtils.toCharArray(str), end ) );
} | java | public static String slcEnd( String str, int end ) {
return FastStringUtils.noCopyStringFromChars( Chr.slcEnd( FastStringUtils.toCharArray(str), end ) );
} | [
"public",
"static",
"String",
"slcEnd",
"(",
"String",
"str",
",",
"int",
"end",
")",
"{",
"return",
"FastStringUtils",
".",
"noCopyStringFromChars",
"(",
"Chr",
".",
"slcEnd",
"(",
"FastStringUtils",
".",
"toCharArray",
"(",
"str",
")",
",",
"end",
")",
")",
";",
"}"
] | Gets end slice of a string.
@param str string
@param end end index of slice
@return new string | [
"Gets",
"end",
"slice",
"of",
"a",
"string",
"."
] | train | https://github.com/advantageous/boon/blob/12712d376761aa3b33223a9f1716720ddb67cb5e/reflekt/src/main/java/io/advantageous/boon/core/Str.java#L172-L174 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.addPrebuilt | public List<PrebuiltEntityExtractor> addPrebuilt(UUID appId, String versionId, List<String> prebuiltExtractorNames) {
"""
Adds a list of prebuilt entity extractors to the application.
@param appId The application ID.
@param versionId The version ID.
@param prebuiltExtractorNames An array of prebuilt entity extractor names.
@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 List<PrebuiltEntityExtractor> object if successful.
"""
return addPrebuiltWithServiceResponseAsync(appId, versionId, prebuiltExtractorNames).toBlocking().single().body();
} | java | public List<PrebuiltEntityExtractor> addPrebuilt(UUID appId, String versionId, List<String> prebuiltExtractorNames) {
return addPrebuiltWithServiceResponseAsync(appId, versionId, prebuiltExtractorNames).toBlocking().single().body();
} | [
"public",
"List",
"<",
"PrebuiltEntityExtractor",
">",
"addPrebuilt",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"List",
"<",
"String",
">",
"prebuiltExtractorNames",
")",
"{",
"return",
"addPrebuiltWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"prebuiltExtractorNames",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Adds a list of prebuilt entity extractors to the application.
@param appId The application ID.
@param versionId The version ID.
@param prebuiltExtractorNames An array of prebuilt entity extractor names.
@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 List<PrebuiltEntityExtractor> object if successful. | [
"Adds",
"a",
"list",
"of",
"prebuilt",
"entity",
"extractors",
"to",
"the",
"application",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L2090-L2092 |
caelum/vraptor4 | vraptor-core/src/main/java/br/com/caelum/vraptor/validator/beanvalidation/MethodValidator.java | MethodValidator.extractCategory | protected String extractCategory(ValuedParameter[] params, ConstraintViolation<Object> violation) {
"""
Returns the category for this constraint violation. By default, the category returned
is the full path for property. You can override this method if you prefer another strategy.
"""
Iterator<Node> path = violation.getPropertyPath().iterator();
Node method = path.next();
logger.debug("Constraint violation on method {}: {}", method, violation);
StringBuilder cat = new StringBuilder();
cat.append(params[path.next().as(ParameterNode.class).getParameterIndex()].getName());// parameter name
while (path.hasNext()) {
cat.append(".").append(path.next());
}
return cat.toString();
} | java | protected String extractCategory(ValuedParameter[] params, ConstraintViolation<Object> violation) {
Iterator<Node> path = violation.getPropertyPath().iterator();
Node method = path.next();
logger.debug("Constraint violation on method {}: {}", method, violation);
StringBuilder cat = new StringBuilder();
cat.append(params[path.next().as(ParameterNode.class).getParameterIndex()].getName());// parameter name
while (path.hasNext()) {
cat.append(".").append(path.next());
}
return cat.toString();
} | [
"protected",
"String",
"extractCategory",
"(",
"ValuedParameter",
"[",
"]",
"params",
",",
"ConstraintViolation",
"<",
"Object",
">",
"violation",
")",
"{",
"Iterator",
"<",
"Node",
">",
"path",
"=",
"violation",
".",
"getPropertyPath",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Node",
"method",
"=",
"path",
".",
"next",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Constraint violation on method {}: {}\"",
",",
"method",
",",
"violation",
")",
";",
"StringBuilder",
"cat",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"cat",
".",
"append",
"(",
"params",
"[",
"path",
".",
"next",
"(",
")",
".",
"as",
"(",
"ParameterNode",
".",
"class",
")",
".",
"getParameterIndex",
"(",
")",
"]",
".",
"getName",
"(",
")",
")",
";",
"// parameter name",
"while",
"(",
"path",
".",
"hasNext",
"(",
")",
")",
"{",
"cat",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"path",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"cat",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the category for this constraint violation. By default, the category returned
is the full path for property. You can override this method if you prefer another strategy. | [
"Returns",
"the",
"category",
"for",
"this",
"constraint",
"violation",
".",
"By",
"default",
"the",
"category",
"returned",
"is",
"the",
"full",
"path",
"for",
"property",
".",
"You",
"can",
"override",
"this",
"method",
"if",
"you",
"prefer",
"another",
"strategy",
"."
] | train | https://github.com/caelum/vraptor4/blob/593ce9ad60f9d38c360881b2132417c56b8cc093/vraptor-core/src/main/java/br/com/caelum/vraptor/validator/beanvalidation/MethodValidator.java#L117-L130 |
pf4j/pf4j | pf4j/src/main/java/org/pf4j/util/ClassUtils.java | ClassUtils.getAnnotationValue | public static AnnotationValue getAnnotationValue(TypeElement typeElement, Class<?> annotationClass, String annotationParameter) {
"""
Get a certain annotation parameter of a {@link TypeElement}.
See <a href="https://stackoverflow.com/a/10167558">stackoverflow.com</a> for more information.
@param typeElement the type element, that contains the requested annotation
@param annotationClass the class of the requested annotation
@param annotationParameter the name of the requested annotation parameter
@return the requested parameter or null, if no annotation for the provided class was found or no annotation parameter was found
@throws NullPointerException if <code>typeElement</code> or <code>annotationClass</code> is null
"""
AnnotationMirror annotationMirror = getAnnotationMirror(typeElement, annotationClass);
return (annotationMirror != null) ?
getAnnotationValue(annotationMirror, annotationParameter) :
null;
} | java | public static AnnotationValue getAnnotationValue(TypeElement typeElement, Class<?> annotationClass, String annotationParameter) {
AnnotationMirror annotationMirror = getAnnotationMirror(typeElement, annotationClass);
return (annotationMirror != null) ?
getAnnotationValue(annotationMirror, annotationParameter) :
null;
} | [
"public",
"static",
"AnnotationValue",
"getAnnotationValue",
"(",
"TypeElement",
"typeElement",
",",
"Class",
"<",
"?",
">",
"annotationClass",
",",
"String",
"annotationParameter",
")",
"{",
"AnnotationMirror",
"annotationMirror",
"=",
"getAnnotationMirror",
"(",
"typeElement",
",",
"annotationClass",
")",
";",
"return",
"(",
"annotationMirror",
"!=",
"null",
")",
"?",
"getAnnotationValue",
"(",
"annotationMirror",
",",
"annotationParameter",
")",
":",
"null",
";",
"}"
] | Get a certain annotation parameter of a {@link TypeElement}.
See <a href="https://stackoverflow.com/a/10167558">stackoverflow.com</a> for more information.
@param typeElement the type element, that contains the requested annotation
@param annotationClass the class of the requested annotation
@param annotationParameter the name of the requested annotation parameter
@return the requested parameter or null, if no annotation for the provided class was found or no annotation parameter was found
@throws NullPointerException if <code>typeElement</code> or <code>annotationClass</code> is null | [
"Get",
"a",
"certain",
"annotation",
"parameter",
"of",
"a",
"{",
"@link",
"TypeElement",
"}",
".",
"See",
"<a",
"href",
"=",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"10167558",
">",
"stackoverflow",
".",
"com<",
"/",
"a",
">",
"for",
"more",
"information",
"."
] | train | https://github.com/pf4j/pf4j/blob/6dd7a6069f0e2fbd842c81e2c8c388918b88ea81/pf4j/src/main/java/org/pf4j/util/ClassUtils.java#L127-L132 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.recoverDeletedKeyAsync | public ServiceFuture<KeyBundle> recoverDeletedKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback<KeyBundle> serviceCallback) {
"""
Recovers the deleted key to its latest version.
The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of the deleted key.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(recoverDeletedKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback);
} | java | public ServiceFuture<KeyBundle> recoverDeletedKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback<KeyBundle> serviceCallback) {
return ServiceFuture.fromResponse(recoverDeletedKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"KeyBundle",
">",
"recoverDeletedKeyAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"keyName",
",",
"final",
"ServiceCallback",
"<",
"KeyBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"recoverDeletedKeyWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"keyName",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Recovers the deleted key to its latest version.
The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param keyName The name of the deleted key.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Recovers",
"the",
"deleted",
"key",
"to",
"its",
"latest",
"version",
".",
"The",
"Recover",
"Deleted",
"Key",
"operation",
"is",
"applicable",
"for",
"deleted",
"keys",
"in",
"soft",
"-",
"delete",
"enabled",
"vaults",
".",
"It",
"recovers",
"the",
"deleted",
"key",
"back",
"to",
"its",
"latest",
"version",
"under",
"/",
"keys",
".",
"An",
"attempt",
"to",
"recover",
"an",
"non",
"-",
"deleted",
"key",
"will",
"return",
"an",
"error",
".",
"Consider",
"this",
"the",
"inverse",
"of",
"the",
"delete",
"operation",
"on",
"soft",
"-",
"delete",
"enabled",
"vaults",
".",
"This",
"operation",
"requires",
"the",
"keys",
"/",
"recover",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L3247-L3249 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/UtilColor.java | UtilColor.getDelta | public static double getDelta(ColorRgba a, ColorRgba b) {
"""
Return the delta between two colors.
@param a The first color (must not be <code>null</code>).
@param b The second color (must not be <code>null</code>).
@return The delta between the two colors.
@throws LionEngineException If invalid arguments.
"""
Check.notNull(a);
Check.notNull(b);
final int dr = a.getRed() - b.getRed();
final int dg = a.getGreen() - b.getGreen();
final int db = a.getBlue() - b.getBlue();
return Math.sqrt(dr * dr + dg * dg + db * db);
} | java | public static double getDelta(ColorRgba a, ColorRgba b)
{
Check.notNull(a);
Check.notNull(b);
final int dr = a.getRed() - b.getRed();
final int dg = a.getGreen() - b.getGreen();
final int db = a.getBlue() - b.getBlue();
return Math.sqrt(dr * dr + dg * dg + db * db);
} | [
"public",
"static",
"double",
"getDelta",
"(",
"ColorRgba",
"a",
",",
"ColorRgba",
"b",
")",
"{",
"Check",
".",
"notNull",
"(",
"a",
")",
";",
"Check",
".",
"notNull",
"(",
"b",
")",
";",
"final",
"int",
"dr",
"=",
"a",
".",
"getRed",
"(",
")",
"-",
"b",
".",
"getRed",
"(",
")",
";",
"final",
"int",
"dg",
"=",
"a",
".",
"getGreen",
"(",
")",
"-",
"b",
".",
"getGreen",
"(",
")",
";",
"final",
"int",
"db",
"=",
"a",
".",
"getBlue",
"(",
")",
"-",
"b",
".",
"getBlue",
"(",
")",
";",
"return",
"Math",
".",
"sqrt",
"(",
"dr",
"*",
"dr",
"+",
"dg",
"*",
"dg",
"+",
"db",
"*",
"db",
")",
";",
"}"
] | Return the delta between two colors.
@param a The first color (must not be <code>null</code>).
@param b The second color (must not be <code>null</code>).
@return The delta between the two colors.
@throws LionEngineException If invalid arguments. | [
"Return",
"the",
"delta",
"between",
"two",
"colors",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/graphic/UtilColor.java#L97-L107 |
j-a-w-r/jawr | jawr-core/src/main/java/net/jawr/web/servlet/util/MIMETypesSupport.java | MIMETypesSupport.getSupportedProperties | public static Map<Object, Object> getSupportedProperties(Object ref) {
"""
Returns a Map object containing all the supported media extensions,
paired to their MIME type.
@param ref
An object reference to anchor the classpath (any 'this'
reference does).
@return
"""
if (null == supportedMIMETypes) {
synchronized (MIMETypesSupport.class) {
if (null == supportedMIMETypes) {
// Load the supported MIME types out of a properties file
try (InputStream is = ClassLoaderResourceUtils.getResourceAsStream(MIME_PROPS_LOCATION, ref)) {
supportedMIMETypes = new Properties();
supportedMIMETypes.load(is);
} catch (FileNotFoundException e) {
throw new BundlingProcessException(
"Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings");
} catch (IOException e) {
throw new BundlingProcessException(
"Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings");
}
}
}
}
return supportedMIMETypes;
} | java | public static Map<Object, Object> getSupportedProperties(Object ref) {
if (null == supportedMIMETypes) {
synchronized (MIMETypesSupport.class) {
if (null == supportedMIMETypes) {
// Load the supported MIME types out of a properties file
try (InputStream is = ClassLoaderResourceUtils.getResourceAsStream(MIME_PROPS_LOCATION, ref)) {
supportedMIMETypes = new Properties();
supportedMIMETypes.load(is);
} catch (FileNotFoundException e) {
throw new BundlingProcessException(
"Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings");
} catch (IOException e) {
throw new BundlingProcessException(
"Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings");
}
}
}
}
return supportedMIMETypes;
} | [
"public",
"static",
"Map",
"<",
"Object",
",",
"Object",
">",
"getSupportedProperties",
"(",
"Object",
"ref",
")",
"{",
"if",
"(",
"null",
"==",
"supportedMIMETypes",
")",
"{",
"synchronized",
"(",
"MIMETypesSupport",
".",
"class",
")",
"{",
"if",
"(",
"null",
"==",
"supportedMIMETypes",
")",
"{",
"// Load the supported MIME types out of a properties file",
"try",
"(",
"InputStream",
"is",
"=",
"ClassLoaderResourceUtils",
".",
"getResourceAsStream",
"(",
"MIME_PROPS_LOCATION",
",",
"ref",
")",
")",
"{",
"supportedMIMETypes",
"=",
"new",
"Properties",
"(",
")",
";",
"supportedMIMETypes",
".",
"load",
"(",
"is",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Error retrieving \"",
"+",
"MIME_PROPS_LOCATION",
"+",
"\". Please check your classloader settings\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"BundlingProcessException",
"(",
"\"Error retrieving \"",
"+",
"MIME_PROPS_LOCATION",
"+",
"\". Please check your classloader settings\"",
")",
";",
"}",
"}",
"}",
"}",
"return",
"supportedMIMETypes",
";",
"}"
] | Returns a Map object containing all the supported media extensions,
paired to their MIME type.
@param ref
An object reference to anchor the classpath (any 'this'
reference does).
@return | [
"Returns",
"a",
"Map",
"object",
"containing",
"all",
"the",
"supported",
"media",
"extensions",
"paired",
"to",
"their",
"MIME",
"type",
"."
] | train | https://github.com/j-a-w-r/jawr/blob/1fa7cd46ebcd36908bd90b298ca316fa5b0c1b0d/jawr-core/src/main/java/net/jawr/web/servlet/util/MIMETypesSupport.java#L51-L72 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/StatefulBeanReaper.java | StatefulBeanReaper.beanDoesNotExistOrHasTimedOut | public boolean beanDoesNotExistOrHasTimedOut(TimeoutElement elt, BeanId beanId) {
"""
LIDB2018-1 renamed old beanTimedOut method and clarified description.
"""
if (elt == null) {
// Not in the reaper list, but it might be in local
// failover cache if not in reaper list. So check it if
// there is a local SfFailoverCache object (e.g. when SFSB
// failover is enabled to use failover cache).
if (ivSfFailoverCache != null) {
// Not in reaper list, but SFSB failover enabled.
// Have local SfFailoverCache determine if bean does not exist
// or has timed out.
return ivSfFailoverCache.beanDoesNotExistOrHasTimedOut(beanId);
}
// Return true since bean not found in reaper list
// and SFSB failover is not enabled so not in failover
// cache list.
return true;
}
// SFSB found in reaper list, so return whether it
// has timed out or not.
return elt.isTimedOut(); // F61004.5
} | java | public boolean beanDoesNotExistOrHasTimedOut(TimeoutElement elt, BeanId beanId) {
if (elt == null) {
// Not in the reaper list, but it might be in local
// failover cache if not in reaper list. So check it if
// there is a local SfFailoverCache object (e.g. when SFSB
// failover is enabled to use failover cache).
if (ivSfFailoverCache != null) {
// Not in reaper list, but SFSB failover enabled.
// Have local SfFailoverCache determine if bean does not exist
// or has timed out.
return ivSfFailoverCache.beanDoesNotExistOrHasTimedOut(beanId);
}
// Return true since bean not found in reaper list
// and SFSB failover is not enabled so not in failover
// cache list.
return true;
}
// SFSB found in reaper list, so return whether it
// has timed out or not.
return elt.isTimedOut(); // F61004.5
} | [
"public",
"boolean",
"beanDoesNotExistOrHasTimedOut",
"(",
"TimeoutElement",
"elt",
",",
"BeanId",
"beanId",
")",
"{",
"if",
"(",
"elt",
"==",
"null",
")",
"{",
"// Not in the reaper list, but it might be in local",
"// failover cache if not in reaper list. So check it if",
"// there is a local SfFailoverCache object (e.g. when SFSB",
"// failover is enabled to use failover cache).",
"if",
"(",
"ivSfFailoverCache",
"!=",
"null",
")",
"{",
"// Not in reaper list, but SFSB failover enabled.",
"// Have local SfFailoverCache determine if bean does not exist",
"// or has timed out.",
"return",
"ivSfFailoverCache",
".",
"beanDoesNotExistOrHasTimedOut",
"(",
"beanId",
")",
";",
"}",
"// Return true since bean not found in reaper list",
"// and SFSB failover is not enabled so not in failover",
"// cache list.",
"return",
"true",
";",
"}",
"// SFSB found in reaper list, so return whether it",
"// has timed out or not.",
"return",
"elt",
".",
"isTimedOut",
"(",
")",
";",
"// F61004.5",
"}"
] | LIDB2018-1 renamed old beanTimedOut method and clarified description. | [
"LIDB2018",
"-",
"1",
"renamed",
"old",
"beanTimedOut",
"method",
"and",
"clarified",
"description",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/StatefulBeanReaper.java#L296-L318 |
albfernandez/itext2 | src/main/java/com/lowagie/text/rtf/style/RtfFontList.java | RtfFontList.getFontNumber | public int getFontNumber(RtfFont font) {
"""
Gets the index of the font in the list of fonts. If the font does not
exist in the list, it is added.
@param font The font to get the id for
@return The index of the font
"""
if(font instanceof RtfParagraphStyle) {
font = new RtfFont(this.document, font);
}
int fontIndex = -1;
for(int i = 0; i < fontList.size(); i++) {
if(fontList.get(i).equals(font)) {
fontIndex = i;
}
}
if(fontIndex == -1) {
fontIndex = fontList.size();
fontList.add(font);
}
return fontIndex;
} | java | public int getFontNumber(RtfFont font) {
if(font instanceof RtfParagraphStyle) {
font = new RtfFont(this.document, font);
}
int fontIndex = -1;
for(int i = 0; i < fontList.size(); i++) {
if(fontList.get(i).equals(font)) {
fontIndex = i;
}
}
if(fontIndex == -1) {
fontIndex = fontList.size();
fontList.add(font);
}
return fontIndex;
} | [
"public",
"int",
"getFontNumber",
"(",
"RtfFont",
"font",
")",
"{",
"if",
"(",
"font",
"instanceof",
"RtfParagraphStyle",
")",
"{",
"font",
"=",
"new",
"RtfFont",
"(",
"this",
".",
"document",
",",
"font",
")",
";",
"}",
"int",
"fontIndex",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fontList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fontList",
".",
"get",
"(",
"i",
")",
".",
"equals",
"(",
"font",
")",
")",
"{",
"fontIndex",
"=",
"i",
";",
"}",
"}",
"if",
"(",
"fontIndex",
"==",
"-",
"1",
")",
"{",
"fontIndex",
"=",
"fontList",
".",
"size",
"(",
")",
";",
"fontList",
".",
"add",
"(",
"font",
")",
";",
"}",
"return",
"fontIndex",
";",
"}"
] | Gets the index of the font in the list of fonts. If the font does not
exist in the list, it is added.
@param font The font to get the id for
@return The index of the font | [
"Gets",
"the",
"index",
"of",
"the",
"font",
"in",
"the",
"list",
"of",
"fonts",
".",
"If",
"the",
"font",
"does",
"not",
"exist",
"in",
"the",
"list",
"it",
"is",
"added",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/style/RtfFontList.java#L113-L128 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java | CmsDefaultXmlContentHandler.getSubPath | private String getSubPath(String[] pathElements, int begin) {
"""
Utility method to return a path fragment.<p>
@param pathElements the path elements
@param begin the begin index
@return the path
"""
String result = "";
for (int i = begin; i < pathElements.length; i++) {
result += pathElements[i] + "/";
}
if (result.length() > 0) {
result = result.substring(0, result.length() - 1);
}
return result;
} | java | private String getSubPath(String[] pathElements, int begin) {
String result = "";
for (int i = begin; i < pathElements.length; i++) {
result += pathElements[i] + "/";
}
if (result.length() > 0) {
result = result.substring(0, result.length() - 1);
}
return result;
} | [
"private",
"String",
"getSubPath",
"(",
"String",
"[",
"]",
"pathElements",
",",
"int",
"begin",
")",
"{",
"String",
"result",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"begin",
";",
"i",
"<",
"pathElements",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"pathElements",
"[",
"i",
"]",
"+",
"\"/\"",
";",
"}",
"if",
"(",
"result",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"result",
"=",
"result",
".",
"substring",
"(",
"0",
",",
"result",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Utility method to return a path fragment.<p>
@param pathElements the path elements
@param begin the begin index
@return the path | [
"Utility",
"method",
"to",
"return",
"a",
"path",
"fragment",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java#L3980-L3990 |
liferay/com-liferay-commerce | commerce-user-segment-service/src/main/java/com/liferay/commerce/user/segment/service/persistence/impl/CommerceUserSegmentEntryPersistenceImpl.java | CommerceUserSegmentEntryPersistenceImpl.fetchByG_K | @Override
public CommerceUserSegmentEntry fetchByG_K(long groupId, String key) {
"""
Returns the commerce user segment entry where groupId = ? and key = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param groupId the group ID
@param key the key
@return the matching commerce user segment entry, or <code>null</code> if a matching commerce user segment entry could not be found
"""
return fetchByG_K(groupId, key, true);
} | java | @Override
public CommerceUserSegmentEntry fetchByG_K(long groupId, String key) {
return fetchByG_K(groupId, key, true);
} | [
"@",
"Override",
"public",
"CommerceUserSegmentEntry",
"fetchByG_K",
"(",
"long",
"groupId",
",",
"String",
"key",
")",
"{",
"return",
"fetchByG_K",
"(",
"groupId",
",",
"key",
",",
"true",
")",
";",
"}"
] | Returns the commerce user segment entry where groupId = ? and key = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
@param groupId the group ID
@param key the key
@return the matching commerce user segment entry, or <code>null</code> if a matching commerce user segment entry could not be found | [
"Returns",
"the",
"commerce",
"user",
"segment",
"entry",
"where",
"groupId",
"=",
"?",
";",
"and",
"key",
"=",
"?",
";",
"or",
"returns",
"<code",
">",
"null<",
"/",
"code",
">",
"if",
"it",
"could",
"not",
"be",
"found",
".",
"Uses",
"the",
"finder",
"cache",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-user-segment-service/src/main/java/com/liferay/commerce/user/segment/service/persistence/impl/CommerceUserSegmentEntryPersistenceImpl.java#L1031-L1034 |
banq/jdonframework | src/main/java/com/jdon/container/pico/JdonPicoContainer.java | JdonPicoContainer.registerComponentImplementation | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
"""
{@inheritDoc} The returned ComponentAdapter will be instantiated by the
{@link ComponentAdapterFactory} passed to the container's constructor.
"""
return registerComponentImplementation(componentKey, componentImplementation, (Parameter[]) null);
} | java | public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException {
return registerComponentImplementation(componentKey, componentImplementation, (Parameter[]) null);
} | [
"public",
"ComponentAdapter",
"registerComponentImplementation",
"(",
"Object",
"componentKey",
",",
"Class",
"componentImplementation",
")",
"throws",
"PicoRegistrationException",
"{",
"return",
"registerComponentImplementation",
"(",
"componentKey",
",",
"componentImplementation",
",",
"(",
"Parameter",
"[",
"]",
")",
"null",
")",
";",
"}"
] | {@inheritDoc} The returned ComponentAdapter will be instantiated by the
{@link ComponentAdapterFactory} passed to the container's constructor. | [
"{"
] | train | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/pico/JdonPicoContainer.java#L258-L260 |
h2oai/h2o-2 | src/main/java/water/ga/GoogleAnalytics.java | GoogleAnalytics.processCustomDimensionParameters | private void processCustomDimensionParameters(@SuppressWarnings("rawtypes") GoogleAnalyticsRequest request, List<NameValuePair> postParms) {
"""
Processes the custom dimensions and adds the values to list of parameters, which would be posted to GA.
@param request
@param postParms
"""
Map<String, String> customDimParms = new HashMap<String, String>();
for (String defaultCustomDimKey : defaultRequest.customDimentions().keySet()) {
customDimParms.put(defaultCustomDimKey, defaultRequest.customDimentions().get(defaultCustomDimKey));
}
@SuppressWarnings("unchecked")
Map<String, String> requestCustomDims = request.customDimentions();
for (String requestCustomDimKey : requestCustomDims.keySet()) {
customDimParms.put(requestCustomDimKey, requestCustomDims.get(requestCustomDimKey));
}
for (String key : customDimParms.keySet()) {
postParms.add(new BasicNameValuePair(key, customDimParms.get(key)));
}
} | java | private void processCustomDimensionParameters(@SuppressWarnings("rawtypes") GoogleAnalyticsRequest request, List<NameValuePair> postParms) {
Map<String, String> customDimParms = new HashMap<String, String>();
for (String defaultCustomDimKey : defaultRequest.customDimentions().keySet()) {
customDimParms.put(defaultCustomDimKey, defaultRequest.customDimentions().get(defaultCustomDimKey));
}
@SuppressWarnings("unchecked")
Map<String, String> requestCustomDims = request.customDimentions();
for (String requestCustomDimKey : requestCustomDims.keySet()) {
customDimParms.put(requestCustomDimKey, requestCustomDims.get(requestCustomDimKey));
}
for (String key : customDimParms.keySet()) {
postParms.add(new BasicNameValuePair(key, customDimParms.get(key)));
}
} | [
"private",
"void",
"processCustomDimensionParameters",
"(",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"GoogleAnalyticsRequest",
"request",
",",
"List",
"<",
"NameValuePair",
">",
"postParms",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"customDimParms",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"defaultCustomDimKey",
":",
"defaultRequest",
".",
"customDimentions",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"customDimParms",
".",
"put",
"(",
"defaultCustomDimKey",
",",
"defaultRequest",
".",
"customDimentions",
"(",
")",
".",
"get",
"(",
"defaultCustomDimKey",
")",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"String",
">",
"requestCustomDims",
"=",
"request",
".",
"customDimentions",
"(",
")",
";",
"for",
"(",
"String",
"requestCustomDimKey",
":",
"requestCustomDims",
".",
"keySet",
"(",
")",
")",
"{",
"customDimParms",
".",
"put",
"(",
"requestCustomDimKey",
",",
"requestCustomDims",
".",
"get",
"(",
"requestCustomDimKey",
")",
")",
";",
"}",
"for",
"(",
"String",
"key",
":",
"customDimParms",
".",
"keySet",
"(",
")",
")",
"{",
"postParms",
".",
"add",
"(",
"new",
"BasicNameValuePair",
"(",
"key",
",",
"customDimParms",
".",
"get",
"(",
"key",
")",
")",
")",
";",
"}",
"}"
] | Processes the custom dimensions and adds the values to list of parameters, which would be posted to GA.
@param request
@param postParms | [
"Processes",
"the",
"custom",
"dimensions",
"and",
"adds",
"the",
"values",
"to",
"list",
"of",
"parameters",
"which",
"would",
"be",
"posted",
"to",
"GA",
"."
] | train | https://github.com/h2oai/h2o-2/blob/be350f3f2c2fb6f135cc07c41f83fd0e4f521ac1/src/main/java/water/ga/GoogleAnalytics.java#L217-L232 |
molgenis/molgenis | molgenis-semantic-search/src/main/java/org/molgenis/semanticsearch/repository/TagRepository.java | TagRepository.getTagEntity | public Tag getTagEntity(String objectIRI, String label, Relation relation, String codeSystemIRI) {
"""
Fetches a tag from the repository. Creates a new one if it does not yet exist.
@param objectIRI IRI of the object
@param label label of the object
@param relation {@link Relation} of the tag
@param codeSystemIRI the IRI of the code system of the tag
@return {@link Tag} of type {@link TagMetadata}
"""
Tag tag =
dataService
.query(TAG, Tag.class)
.eq(OBJECT_IRI, objectIRI)
.and()
.eq(RELATION_IRI, relation.getIRI())
.and()
.eq(CODE_SYSTEM, codeSystemIRI)
.findOne();
if (tag == null) {
tag = tagFactory.create();
tag.setId(idGenerator.generateId());
tag.setObjectIri(objectIRI);
tag.setLabel(label);
tag.setRelationIri(relation.getIRI());
tag.setRelationLabel(relation.getLabel());
tag.setCodeSystem(codeSystemIRI);
dataService.add(TAG, tag);
}
return tag;
} | java | public Tag getTagEntity(String objectIRI, String label, Relation relation, String codeSystemIRI) {
Tag tag =
dataService
.query(TAG, Tag.class)
.eq(OBJECT_IRI, objectIRI)
.and()
.eq(RELATION_IRI, relation.getIRI())
.and()
.eq(CODE_SYSTEM, codeSystemIRI)
.findOne();
if (tag == null) {
tag = tagFactory.create();
tag.setId(idGenerator.generateId());
tag.setObjectIri(objectIRI);
tag.setLabel(label);
tag.setRelationIri(relation.getIRI());
tag.setRelationLabel(relation.getLabel());
tag.setCodeSystem(codeSystemIRI);
dataService.add(TAG, tag);
}
return tag;
} | [
"public",
"Tag",
"getTagEntity",
"(",
"String",
"objectIRI",
",",
"String",
"label",
",",
"Relation",
"relation",
",",
"String",
"codeSystemIRI",
")",
"{",
"Tag",
"tag",
"=",
"dataService",
".",
"query",
"(",
"TAG",
",",
"Tag",
".",
"class",
")",
".",
"eq",
"(",
"OBJECT_IRI",
",",
"objectIRI",
")",
".",
"and",
"(",
")",
".",
"eq",
"(",
"RELATION_IRI",
",",
"relation",
".",
"getIRI",
"(",
")",
")",
".",
"and",
"(",
")",
".",
"eq",
"(",
"CODE_SYSTEM",
",",
"codeSystemIRI",
")",
".",
"findOne",
"(",
")",
";",
"if",
"(",
"tag",
"==",
"null",
")",
"{",
"tag",
"=",
"tagFactory",
".",
"create",
"(",
")",
";",
"tag",
".",
"setId",
"(",
"idGenerator",
".",
"generateId",
"(",
")",
")",
";",
"tag",
".",
"setObjectIri",
"(",
"objectIRI",
")",
";",
"tag",
".",
"setLabel",
"(",
"label",
")",
";",
"tag",
".",
"setRelationIri",
"(",
"relation",
".",
"getIRI",
"(",
")",
")",
";",
"tag",
".",
"setRelationLabel",
"(",
"relation",
".",
"getLabel",
"(",
")",
")",
";",
"tag",
".",
"setCodeSystem",
"(",
"codeSystemIRI",
")",
";",
"dataService",
".",
"add",
"(",
"TAG",
",",
"tag",
")",
";",
"}",
"return",
"tag",
";",
"}"
] | Fetches a tag from the repository. Creates a new one if it does not yet exist.
@param objectIRI IRI of the object
@param label label of the object
@param relation {@link Relation} of the tag
@param codeSystemIRI the IRI of the code system of the tag
@return {@link Tag} of type {@link TagMetadata} | [
"Fetches",
"a",
"tag",
"from",
"the",
"repository",
".",
"Creates",
"a",
"new",
"one",
"if",
"it",
"does",
"not",
"yet",
"exist",
"."
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-semantic-search/src/main/java/org/molgenis/semanticsearch/repository/TagRepository.java#L41-L62 |
alkacon/opencms-core | src/org/opencms/db/generic/CmsUserDriver.java | CmsUserDriver.internalCreateResourceForOrgUnit | protected CmsResource internalCreateResourceForOrgUnit(CmsDbContext dbc, String path, int flags)
throws CmsException {
"""
Creates a folder with the given path an properties, offline AND online.<p>
@param dbc the current database context
@param path the path to create the folder
@param flags the resource flags
@return the new created offline folder
@throws CmsException if something goes wrong
"""
// create the offline folder
CmsResource resource = new CmsFolder(
new CmsUUID(),
new CmsUUID(),
path,
CmsResourceTypeFolder.RESOURCE_TYPE_ID,
(CmsResource.FLAG_INTERNAL | flags),
dbc.currentProject().getUuid(),
CmsResource.STATE_NEW,
0,
dbc.currentUser().getId(),
0,
dbc.currentUser().getId(),
CmsResource.DATE_RELEASED_DEFAULT,
CmsResource.DATE_EXPIRED_DEFAULT,
0);
CmsUUID projectId = ((dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID())
? dbc.currentProject().getUuid()
: dbc.getProjectId();
m_driverManager.getVfsDriver(dbc).createResource(dbc, projectId, resource, null);
resource.setState(CmsResource.STATE_UNCHANGED);
m_driverManager.getVfsDriver(dbc).writeResource(dbc, projectId, resource, CmsDriverManager.NOTHING_CHANGED);
if (!dbc.currentProject().isOnlineProject() && dbc.getProjectId().isNullUUID()) {
// online persistence
CmsProject onlineProject = m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID);
m_driverManager.getVfsDriver(dbc).createResource(dbc, onlineProject.getUuid(), resource, null);
}
// clear the internal caches
OpenCms.getMemoryMonitor().clearAccessControlListCache();
OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PROPERTY);
OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PROPERTY_LIST);
// fire an event that a new resource has been created
OpenCms.fireCmsEvent(
new CmsEvent(
I_CmsEventListener.EVENT_RESOURCE_CREATED,
Collections.<String, Object> singletonMap(I_CmsEventListener.KEY_RESOURCE, resource)));
return resource;
} | java | protected CmsResource internalCreateResourceForOrgUnit(CmsDbContext dbc, String path, int flags)
throws CmsException {
// create the offline folder
CmsResource resource = new CmsFolder(
new CmsUUID(),
new CmsUUID(),
path,
CmsResourceTypeFolder.RESOURCE_TYPE_ID,
(CmsResource.FLAG_INTERNAL | flags),
dbc.currentProject().getUuid(),
CmsResource.STATE_NEW,
0,
dbc.currentUser().getId(),
0,
dbc.currentUser().getId(),
CmsResource.DATE_RELEASED_DEFAULT,
CmsResource.DATE_EXPIRED_DEFAULT,
0);
CmsUUID projectId = ((dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID())
? dbc.currentProject().getUuid()
: dbc.getProjectId();
m_driverManager.getVfsDriver(dbc).createResource(dbc, projectId, resource, null);
resource.setState(CmsResource.STATE_UNCHANGED);
m_driverManager.getVfsDriver(dbc).writeResource(dbc, projectId, resource, CmsDriverManager.NOTHING_CHANGED);
if (!dbc.currentProject().isOnlineProject() && dbc.getProjectId().isNullUUID()) {
// online persistence
CmsProject onlineProject = m_driverManager.readProject(dbc, CmsProject.ONLINE_PROJECT_ID);
m_driverManager.getVfsDriver(dbc).createResource(dbc, onlineProject.getUuid(), resource, null);
}
// clear the internal caches
OpenCms.getMemoryMonitor().clearAccessControlListCache();
OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PROPERTY);
OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PROPERTY_LIST);
// fire an event that a new resource has been created
OpenCms.fireCmsEvent(
new CmsEvent(
I_CmsEventListener.EVENT_RESOURCE_CREATED,
Collections.<String, Object> singletonMap(I_CmsEventListener.KEY_RESOURCE, resource)));
return resource;
} | [
"protected",
"CmsResource",
"internalCreateResourceForOrgUnit",
"(",
"CmsDbContext",
"dbc",
",",
"String",
"path",
",",
"int",
"flags",
")",
"throws",
"CmsException",
"{",
"// create the offline folder",
"CmsResource",
"resource",
"=",
"new",
"CmsFolder",
"(",
"new",
"CmsUUID",
"(",
")",
",",
"new",
"CmsUUID",
"(",
")",
",",
"path",
",",
"CmsResourceTypeFolder",
".",
"RESOURCE_TYPE_ID",
",",
"(",
"CmsResource",
".",
"FLAG_INTERNAL",
"|",
"flags",
")",
",",
"dbc",
".",
"currentProject",
"(",
")",
".",
"getUuid",
"(",
")",
",",
"CmsResource",
".",
"STATE_NEW",
",",
"0",
",",
"dbc",
".",
"currentUser",
"(",
")",
".",
"getId",
"(",
")",
",",
"0",
",",
"dbc",
".",
"currentUser",
"(",
")",
".",
"getId",
"(",
")",
",",
"CmsResource",
".",
"DATE_RELEASED_DEFAULT",
",",
"CmsResource",
".",
"DATE_EXPIRED_DEFAULT",
",",
"0",
")",
";",
"CmsUUID",
"projectId",
"=",
"(",
"(",
"dbc",
".",
"getProjectId",
"(",
")",
"==",
"null",
")",
"||",
"dbc",
".",
"getProjectId",
"(",
")",
".",
"isNullUUID",
"(",
")",
")",
"?",
"dbc",
".",
"currentProject",
"(",
")",
".",
"getUuid",
"(",
")",
":",
"dbc",
".",
"getProjectId",
"(",
")",
";",
"m_driverManager",
".",
"getVfsDriver",
"(",
"dbc",
")",
".",
"createResource",
"(",
"dbc",
",",
"projectId",
",",
"resource",
",",
"null",
")",
";",
"resource",
".",
"setState",
"(",
"CmsResource",
".",
"STATE_UNCHANGED",
")",
";",
"m_driverManager",
".",
"getVfsDriver",
"(",
"dbc",
")",
".",
"writeResource",
"(",
"dbc",
",",
"projectId",
",",
"resource",
",",
"CmsDriverManager",
".",
"NOTHING_CHANGED",
")",
";",
"if",
"(",
"!",
"dbc",
".",
"currentProject",
"(",
")",
".",
"isOnlineProject",
"(",
")",
"&&",
"dbc",
".",
"getProjectId",
"(",
")",
".",
"isNullUUID",
"(",
")",
")",
"{",
"// online persistence",
"CmsProject",
"onlineProject",
"=",
"m_driverManager",
".",
"readProject",
"(",
"dbc",
",",
"CmsProject",
".",
"ONLINE_PROJECT_ID",
")",
";",
"m_driverManager",
".",
"getVfsDriver",
"(",
"dbc",
")",
".",
"createResource",
"(",
"dbc",
",",
"onlineProject",
".",
"getUuid",
"(",
")",
",",
"resource",
",",
"null",
")",
";",
"}",
"// clear the internal caches",
"OpenCms",
".",
"getMemoryMonitor",
"(",
")",
".",
"clearAccessControlListCache",
"(",
")",
";",
"OpenCms",
".",
"getMemoryMonitor",
"(",
")",
".",
"flushCache",
"(",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"PROPERTY",
")",
";",
"OpenCms",
".",
"getMemoryMonitor",
"(",
")",
".",
"flushCache",
"(",
"CmsMemoryMonitor",
".",
"CacheType",
".",
"PROPERTY_LIST",
")",
";",
"// fire an event that a new resource has been created",
"OpenCms",
".",
"fireCmsEvent",
"(",
"new",
"CmsEvent",
"(",
"I_CmsEventListener",
".",
"EVENT_RESOURCE_CREATED",
",",
"Collections",
".",
"<",
"String",
",",
"Object",
">",
"singletonMap",
"(",
"I_CmsEventListener",
".",
"KEY_RESOURCE",
",",
"resource",
")",
")",
")",
";",
"return",
"resource",
";",
"}"
] | Creates a folder with the given path an properties, offline AND online.<p>
@param dbc the current database context
@param path the path to create the folder
@param flags the resource flags
@return the new created offline folder
@throws CmsException if something goes wrong | [
"Creates",
"a",
"folder",
"with",
"the",
"given",
"path",
"an",
"properties",
"offline",
"AND",
"online",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/generic/CmsUserDriver.java#L2449-L2495 |
marklogic/java-client-api | marklogic-client-api/src/main/java/com/marklogic/client/DatabaseClientFactory.java | DatabaseClientFactory.newClient | static public DatabaseClient newClient(String host, int port, String database, SecurityContext securityContext) {
"""
Creates a client to access the database by means of a REST server.
The CallManager interface can only call an endpoint for the configured content database
of the appserver. You cannot specify the database when constructing a client for working
with a CallManager.
@param host the host with the REST server
@param port the port for the REST server
@param database the database to access (default: configured database for
the REST server)
@param securityContext the security context created depending upon the
authentication type - BasicAuthContext, DigestAuthContext or KerberosAuthContext
and communication channel type (SSL)
@return a new client for making database requests
"""
return newClient(host, port, database, securityContext, null);
} | java | static public DatabaseClient newClient(String host, int port, String database, SecurityContext securityContext) {
return newClient(host, port, database, securityContext, null);
} | [
"static",
"public",
"DatabaseClient",
"newClient",
"(",
"String",
"host",
",",
"int",
"port",
",",
"String",
"database",
",",
"SecurityContext",
"securityContext",
")",
"{",
"return",
"newClient",
"(",
"host",
",",
"port",
",",
"database",
",",
"securityContext",
",",
"null",
")",
";",
"}"
] | Creates a client to access the database by means of a REST server.
The CallManager interface can only call an endpoint for the configured content database
of the appserver. You cannot specify the database when constructing a client for working
with a CallManager.
@param host the host with the REST server
@param port the port for the REST server
@param database the database to access (default: configured database for
the REST server)
@param securityContext the security context created depending upon the
authentication type - BasicAuthContext, DigestAuthContext or KerberosAuthContext
and communication channel type (SSL)
@return a new client for making database requests | [
"Creates",
"a",
"client",
"to",
"access",
"the",
"database",
"by",
"means",
"of",
"a",
"REST",
"server",
"."
] | train | https://github.com/marklogic/java-client-api/blob/acf60229a928abd4a8cc4b21b641d56957467da7/marklogic-client-api/src/main/java/com/marklogic/client/DatabaseClientFactory.java#L1191-L1193 |
cycorp/api-suite | core-api/src/main/java/com/cyc/kb/wrapper/KbTermWrapper.java | KbTermWrapper.provablyNotInstanceOf | @Override
public boolean provablyNotInstanceOf(KbCollection col, Context ctx) {
"""
====| Public methods |==================================================================//
"""
return wrapped().provablyNotInstanceOf(col, ctx);
} | java | @Override
public boolean provablyNotInstanceOf(KbCollection col, Context ctx) {
return wrapped().provablyNotInstanceOf(col, ctx);
} | [
"@",
"Override",
"public",
"boolean",
"provablyNotInstanceOf",
"(",
"KbCollection",
"col",
",",
"Context",
"ctx",
")",
"{",
"return",
"wrapped",
"(",
")",
".",
"provablyNotInstanceOf",
"(",
"col",
",",
"ctx",
")",
";",
"}"
] | ====| Public methods |==================================================================// | [
"====",
"|",
"Public",
"methods",
"|",
"==================================================================",
"//"
] | train | https://github.com/cycorp/api-suite/blob/1d52affabc4635e3715a059e38741712cbdbf2d5/core-api/src/main/java/com/cyc/kb/wrapper/KbTermWrapper.java#L52-L55 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java | DiagnosticsInner.executeSiteAnalysis | public DiagnosticAnalysisInner executeSiteAnalysis(String resourceGroupName, String siteName, String diagnosticCategory, String analysisName, DateTime startTime, DateTime endTime, String timeGrain) {
"""
Execute Analysis.
Execute Analysis.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param diagnosticCategory Category Name
@param analysisName Analysis Resource Name
@param startTime Start Time
@param endTime End Time
@param timeGrain Time Grain
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticAnalysisInner object if successful.
"""
return executeSiteAnalysisWithServiceResponseAsync(resourceGroupName, siteName, diagnosticCategory, analysisName, startTime, endTime, timeGrain).toBlocking().single().body();
} | java | public DiagnosticAnalysisInner executeSiteAnalysis(String resourceGroupName, String siteName, String diagnosticCategory, String analysisName, DateTime startTime, DateTime endTime, String timeGrain) {
return executeSiteAnalysisWithServiceResponseAsync(resourceGroupName, siteName, diagnosticCategory, analysisName, startTime, endTime, timeGrain).toBlocking().single().body();
} | [
"public",
"DiagnosticAnalysisInner",
"executeSiteAnalysis",
"(",
"String",
"resourceGroupName",
",",
"String",
"siteName",
",",
"String",
"diagnosticCategory",
",",
"String",
"analysisName",
",",
"DateTime",
"startTime",
",",
"DateTime",
"endTime",
",",
"String",
"timeGrain",
")",
"{",
"return",
"executeSiteAnalysisWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"siteName",
",",
"diagnosticCategory",
",",
"analysisName",
",",
"startTime",
",",
"endTime",
",",
"timeGrain",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Execute Analysis.
Execute Analysis.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param siteName Site Name
@param diagnosticCategory Category Name
@param analysisName Analysis Resource Name
@param startTime Start Time
@param endTime End Time
@param timeGrain Time Grain
@throws IllegalArgumentException thrown if parameters fail the validation
@throws DefaultErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DiagnosticAnalysisInner object if successful. | [
"Execute",
"Analysis",
".",
"Execute",
"Analysis",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2018_02_01/src/main/java/com/microsoft/azure/management/appservice/v2018_02_01/implementation/DiagnosticsInner.java#L741-L743 |
looly/hutool | hutool-extra/src/main/java/cn/hutool/extra/ssh/JschUtil.java | JschUtil.getSession | public static Session getSession(String sshHost, int sshPort, String sshUser, String sshPass) {
"""
获得一个SSH会话,重用已经使用的会话
@param sshHost 主机
@param sshPort 端口
@param sshUser 用户名
@param sshPass 密码
@return SSH会话
"""
return JschSessionPool.INSTANCE.getSession(sshHost, sshPort, sshUser, sshPass);
} | java | public static Session getSession(String sshHost, int sshPort, String sshUser, String sshPass) {
return JschSessionPool.INSTANCE.getSession(sshHost, sshPort, sshUser, sshPass);
} | [
"public",
"static",
"Session",
"getSession",
"(",
"String",
"sshHost",
",",
"int",
"sshPort",
",",
"String",
"sshUser",
",",
"String",
"sshPass",
")",
"{",
"return",
"JschSessionPool",
".",
"INSTANCE",
".",
"getSession",
"(",
"sshHost",
",",
"sshPort",
",",
"sshUser",
",",
"sshPass",
")",
";",
"}"
] | 获得一个SSH会话,重用已经使用的会话
@param sshHost 主机
@param sshPort 端口
@param sshUser 用户名
@param sshPass 密码
@return SSH会话 | [
"获得一个SSH会话,重用已经使用的会话"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschUtil.java#L56-L58 |
korpling/ANNIS | annis-visualizers/src/main/java/annis/visualizers/component/grid/GridComponent.java | GridComponent.markCoveredTokens | private Long markCoveredTokens(Map<SNode, Long> markedAndCovered, SNode tok) {
"""
Checks if a token is covered by a matched node but not a match by it self.
@param markedAndCovered A mapping from node to a matched number. The node
must not matched directly, but covered by a matched
node.
@param tok the checked token.
@return Returns null, if token is not covered neither marked.
"""
RelannisNodeFeature f = RelannisNodeFeature.extract(tok);
if (markedAndCovered.containsKey(tok) && f != null && f.getMatchedNode() == null) {
return markedAndCovered.get(tok);
}
return f != null ? f.getMatchedNode() : null;
} | java | private Long markCoveredTokens(Map<SNode, Long> markedAndCovered, SNode tok) {
RelannisNodeFeature f = RelannisNodeFeature.extract(tok);
if (markedAndCovered.containsKey(tok) && f != null && f.getMatchedNode() == null) {
return markedAndCovered.get(tok);
}
return f != null ? f.getMatchedNode() : null;
} | [
"private",
"Long",
"markCoveredTokens",
"(",
"Map",
"<",
"SNode",
",",
"Long",
">",
"markedAndCovered",
",",
"SNode",
"tok",
")",
"{",
"RelannisNodeFeature",
"f",
"=",
"RelannisNodeFeature",
".",
"extract",
"(",
"tok",
")",
";",
"if",
"(",
"markedAndCovered",
".",
"containsKey",
"(",
"tok",
")",
"&&",
"f",
"!=",
"null",
"&&",
"f",
".",
"getMatchedNode",
"(",
")",
"==",
"null",
")",
"{",
"return",
"markedAndCovered",
".",
"get",
"(",
"tok",
")",
";",
"}",
"return",
"f",
"!=",
"null",
"?",
"f",
".",
"getMatchedNode",
"(",
")",
":",
"null",
";",
"}"
] | Checks if a token is covered by a matched node but not a match by it self.
@param markedAndCovered A mapping from node to a matched number. The node
must not matched directly, but covered by a matched
node.
@param tok the checked token.
@return Returns null, if token is not covered neither marked. | [
"Checks",
"if",
"a",
"token",
"is",
"covered",
"by",
"a",
"matched",
"node",
"but",
"not",
"a",
"match",
"by",
"it",
"self",
"."
] | train | https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-visualizers/src/main/java/annis/visualizers/component/grid/GridComponent.java#L424-L430 |
VoltDB/voltdb | src/frontend/org/voltdb/utils/CatalogSizing.java | CatalogSizing.getCatalogSizes | public static DatabaseSizes getCatalogSizes(Database dbCatalog, boolean isXDCR) {
"""
Produce a sizing of all significant database objects.
@param dbCatalog database catalog
@param isXDCR Is XDCR enabled
@return database size result object tree
"""
DatabaseSizes dbSizes = new DatabaseSizes();
for (Table table: dbCatalog.getTables()) {
dbSizes.addTable(getTableSize(table, isXDCR));
}
return dbSizes;
} | java | public static DatabaseSizes getCatalogSizes(Database dbCatalog, boolean isXDCR) {
DatabaseSizes dbSizes = new DatabaseSizes();
for (Table table: dbCatalog.getTables()) {
dbSizes.addTable(getTableSize(table, isXDCR));
}
return dbSizes;
} | [
"public",
"static",
"DatabaseSizes",
"getCatalogSizes",
"(",
"Database",
"dbCatalog",
",",
"boolean",
"isXDCR",
")",
"{",
"DatabaseSizes",
"dbSizes",
"=",
"new",
"DatabaseSizes",
"(",
")",
";",
"for",
"(",
"Table",
"table",
":",
"dbCatalog",
".",
"getTables",
"(",
")",
")",
"{",
"dbSizes",
".",
"addTable",
"(",
"getTableSize",
"(",
"table",
",",
"isXDCR",
")",
")",
";",
"}",
"return",
"dbSizes",
";",
"}"
] | Produce a sizing of all significant database objects.
@param dbCatalog database catalog
@param isXDCR Is XDCR enabled
@return database size result object tree | [
"Produce",
"a",
"sizing",
"of",
"all",
"significant",
"database",
"objects",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/CatalogSizing.java#L394-L400 |
Azure/azure-sdk-for-java | network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java | VirtualNetworkGatewayConnectionsInner.getSharedKey | public ConnectionSharedKeyInner getSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) {
"""
The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayConnectionName The virtual network gateway connection shared key name.
@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 ConnectionSharedKeyInner object if successful.
"""
return getSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().body();
} | java | public ConnectionSharedKeyInner getSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName) {
return getSharedKeyWithServiceResponseAsync(resourceGroupName, virtualNetworkGatewayConnectionName).toBlocking().single().body();
} | [
"public",
"ConnectionSharedKeyInner",
"getSharedKey",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualNetworkGatewayConnectionName",
")",
"{",
"return",
"getSharedKeyWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualNetworkGatewayConnectionName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider.
@param resourceGroupName The name of the resource group.
@param virtualNetworkGatewayConnectionName The virtual network gateway connection shared key name.
@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 ConnectionSharedKeyInner object if successful. | [
"The",
"Get",
"VirtualNetworkGatewayConnectionSharedKey",
"operation",
"retrieves",
"information",
"about",
"the",
"specified",
"virtual",
"network",
"gateway",
"connection",
"shared",
"key",
"through",
"Network",
"resource",
"provider",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2017_10_01/src/main/java/com/microsoft/azure/management/network/v2017_10_01/implementation/VirtualNetworkGatewayConnectionsInner.java#L1025-L1027 |
OpenLiberty/open-liberty | dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java | SelfExtractRun.getExtractDirectory | private static String getExtractDirectory() {
"""
Determine and return directory to extract into.
Three choices:
1) ${WLP_JAR_EXTRACT_DIR}
2) ${WLP_JAR_EXTRACT_ROOT}/<jar file name>_nnnnnnnnnnnnnnnnnnn
3) default - <home>/wlpExtract/<jar file name>_nnnnnnnnnnnnnnnnnnn
@return extraction directory
"""
createExtractor();
String containerPath = extractor.container.getName();
File containerFile = new File(containerPath);
if (containerFile.isDirectory()) {
extractor.allowNonEmptyInstallDirectory(true);
return containerFile.getAbsolutePath();
}
// check if user specified explicit directory
String extractDirVar = System.getenv("WLP_JAR_EXTRACT_DIR");
// if so, return it and done
if (extractDirVar != null && extractDirVar.length() > 0) {
String retVal = createIfNeeded(extractDirVar.trim());
return retVal;
} else {
String extractDirVarRoot = System.getenv("WLP_JAR_EXTRACT_ROOT");
if (extractDirVarRoot == null || extractDirVarRoot.length() == 0) {
extractDirVarRoot = getUserHome() + File.separator + "wlpExtract";
}
createIfNeeded(extractDirVarRoot);
try {
String basedir = (new File(extractDirVarRoot)).getAbsolutePath();
return createTempDirectory(basedir, jarFileName() + "_");
} catch (Exception e) {
throw new RuntimeException("Could not create temp directory under: " + extractDirVarRoot);
}
}
} | java | private static String getExtractDirectory() {
createExtractor();
String containerPath = extractor.container.getName();
File containerFile = new File(containerPath);
if (containerFile.isDirectory()) {
extractor.allowNonEmptyInstallDirectory(true);
return containerFile.getAbsolutePath();
}
// check if user specified explicit directory
String extractDirVar = System.getenv("WLP_JAR_EXTRACT_DIR");
// if so, return it and done
if (extractDirVar != null && extractDirVar.length() > 0) {
String retVal = createIfNeeded(extractDirVar.trim());
return retVal;
} else {
String extractDirVarRoot = System.getenv("WLP_JAR_EXTRACT_ROOT");
if (extractDirVarRoot == null || extractDirVarRoot.length() == 0) {
extractDirVarRoot = getUserHome() + File.separator + "wlpExtract";
}
createIfNeeded(extractDirVarRoot);
try {
String basedir = (new File(extractDirVarRoot)).getAbsolutePath();
return createTempDirectory(basedir, jarFileName() + "_");
} catch (Exception e) {
throw new RuntimeException("Could not create temp directory under: " + extractDirVarRoot);
}
}
} | [
"private",
"static",
"String",
"getExtractDirectory",
"(",
")",
"{",
"createExtractor",
"(",
")",
";",
"String",
"containerPath",
"=",
"extractor",
".",
"container",
".",
"getName",
"(",
")",
";",
"File",
"containerFile",
"=",
"new",
"File",
"(",
"containerPath",
")",
";",
"if",
"(",
"containerFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"extractor",
".",
"allowNonEmptyInstallDirectory",
"(",
"true",
")",
";",
"return",
"containerFile",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"// check if user specified explicit directory",
"String",
"extractDirVar",
"=",
"System",
".",
"getenv",
"(",
"\"WLP_JAR_EXTRACT_DIR\"",
")",
";",
"// if so, return it and done",
"if",
"(",
"extractDirVar",
"!=",
"null",
"&&",
"extractDirVar",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"String",
"retVal",
"=",
"createIfNeeded",
"(",
"extractDirVar",
".",
"trim",
"(",
")",
")",
";",
"return",
"retVal",
";",
"}",
"else",
"{",
"String",
"extractDirVarRoot",
"=",
"System",
".",
"getenv",
"(",
"\"WLP_JAR_EXTRACT_ROOT\"",
")",
";",
"if",
"(",
"extractDirVarRoot",
"==",
"null",
"||",
"extractDirVarRoot",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"extractDirVarRoot",
"=",
"getUserHome",
"(",
")",
"+",
"File",
".",
"separator",
"+",
"\"wlpExtract\"",
";",
"}",
"createIfNeeded",
"(",
"extractDirVarRoot",
")",
";",
"try",
"{",
"String",
"basedir",
"=",
"(",
"new",
"File",
"(",
"extractDirVarRoot",
")",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"return",
"createTempDirectory",
"(",
"basedir",
",",
"jarFileName",
"(",
")",
"+",
"\"_\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not create temp directory under: \"",
"+",
"extractDirVarRoot",
")",
";",
"}",
"}",
"}"
] | Determine and return directory to extract into.
Three choices:
1) ${WLP_JAR_EXTRACT_DIR}
2) ${WLP_JAR_EXTRACT_ROOT}/<jar file name>_nnnnnnnnnnnnnnnnnnn
3) default - <home>/wlpExtract/<jar file name>_nnnnnnnnnnnnnnnnnnn
@return extraction directory | [
"Determine",
"and",
"return",
"directory",
"to",
"extract",
"into",
".",
"Three",
"choices",
":",
"1",
")",
"$",
"{",
"WLP_JAR_EXTRACT_DIR",
"}",
"2",
")",
"$",
"{",
"WLP_JAR_EXTRACT_ROOT",
"}",
"/",
"<jar",
"file",
"name",
">",
"_nnnnnnnnnnnnnnnnnnn",
"3",
")",
"default",
"-",
"<home",
">",
"/",
"wlpExtract",
"/",
"<jar",
"file",
"name",
">",
"_nnnnnnnnnnnnnnnnnnn"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/wlp.lib.extract/src/wlp/lib/extract/SelfExtractRun.java#L134-L164 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.deleteCertificateIssuerAsync | public Observable<IssuerBundle> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) {
"""
Deletes the specified certificate issuer.
The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This operation requires the certificates/manageissuers/deleteissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IssuerBundle object
"""
return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1<ServiceResponse<IssuerBundle>, IssuerBundle>() {
@Override
public IssuerBundle call(ServiceResponse<IssuerBundle> response) {
return response.body();
}
});
} | java | public Observable<IssuerBundle> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) {
return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1<ServiceResponse<IssuerBundle>, IssuerBundle>() {
@Override
public IssuerBundle call(ServiceResponse<IssuerBundle> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"IssuerBundle",
">",
"deleteCertificateIssuerAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"issuerName",
")",
"{",
"return",
"deleteCertificateIssuerWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"issuerName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"IssuerBundle",
">",
",",
"IssuerBundle",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"IssuerBundle",
"call",
"(",
"ServiceResponse",
"<",
"IssuerBundle",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Deletes the specified certificate issuer.
The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This operation requires the certificates/manageissuers/deleteissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IssuerBundle object | [
"Deletes",
"the",
"specified",
"certificate",
"issuer",
".",
"The",
"DeleteCertificateIssuer",
"operation",
"permanently",
"removes",
"the",
"specified",
"certificate",
"issuer",
"from",
"the",
"vault",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"manageissuers",
"/",
"deleteissuers",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L6427-L6434 |
lucee/Lucee | core/src/main/java/lucee/runtime/op/Caster.java | Caster.toDate | public static DateTime toDate(Object o, TimeZone tz) throws PageException {
"""
cast a Object to a DateTime Object
@param o Object to cast
@param tz
@return casted DateTime Object
@throws PageException
"""
return DateCaster.toDateAdvanced(o, tz);
} | java | public static DateTime toDate(Object o, TimeZone tz) throws PageException {
return DateCaster.toDateAdvanced(o, tz);
} | [
"public",
"static",
"DateTime",
"toDate",
"(",
"Object",
"o",
",",
"TimeZone",
"tz",
")",
"throws",
"PageException",
"{",
"return",
"DateCaster",
".",
"toDateAdvanced",
"(",
"o",
",",
"tz",
")",
";",
"}"
] | cast a Object to a DateTime Object
@param o Object to cast
@param tz
@return casted DateTime Object
@throws PageException | [
"cast",
"a",
"Object",
"to",
"a",
"DateTime",
"Object"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/op/Caster.java#L2873-L2875 |
apache/groovy | src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java | StaticTypesCallSiteWriter.setField | private boolean setField(PropertyExpression expression, Expression objectExpression, ClassNode rType, String name) {
"""
this is just a simple set field handling static and non-static, but not Closure and inner classes
"""
if (expression.isSafe()) return false;
FieldNode fn = AsmClassGenerator.getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper(controller.getClassNode(), rType, name, false);
if (fn==null) return false;
OperandStack stack = controller.getOperandStack();
stack.doGroovyCast(fn.getType());
MethodVisitor mv = controller.getMethodVisitor();
String ownerName = BytecodeHelper.getClassInternalName(fn.getOwner());
if (!fn.isStatic()) {
controller.getCompileStack().pushLHS(false);
objectExpression.visit(controller.getAcg());
controller.getCompileStack().popLHS();
if (!rType.equals(stack.getTopOperand())) {
BytecodeHelper.doCast(mv, rType);
stack.replace(rType);
}
stack.swap();
mv.visitFieldInsn(PUTFIELD, ownerName, name, BytecodeHelper.getTypeDescription(fn.getType()));
stack.remove(1);
} else {
mv.visitFieldInsn(PUTSTATIC, ownerName, name, BytecodeHelper.getTypeDescription(fn.getType()));
}
//mv.visitInsn(ACONST_NULL);
//stack.replace(OBJECT_TYPE);
return true;
} | java | private boolean setField(PropertyExpression expression, Expression objectExpression, ClassNode rType, String name) {
if (expression.isSafe()) return false;
FieldNode fn = AsmClassGenerator.getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper(controller.getClassNode(), rType, name, false);
if (fn==null) return false;
OperandStack stack = controller.getOperandStack();
stack.doGroovyCast(fn.getType());
MethodVisitor mv = controller.getMethodVisitor();
String ownerName = BytecodeHelper.getClassInternalName(fn.getOwner());
if (!fn.isStatic()) {
controller.getCompileStack().pushLHS(false);
objectExpression.visit(controller.getAcg());
controller.getCompileStack().popLHS();
if (!rType.equals(stack.getTopOperand())) {
BytecodeHelper.doCast(mv, rType);
stack.replace(rType);
}
stack.swap();
mv.visitFieldInsn(PUTFIELD, ownerName, name, BytecodeHelper.getTypeDescription(fn.getType()));
stack.remove(1);
} else {
mv.visitFieldInsn(PUTSTATIC, ownerName, name, BytecodeHelper.getTypeDescription(fn.getType()));
}
//mv.visitInsn(ACONST_NULL);
//stack.replace(OBJECT_TYPE);
return true;
} | [
"private",
"boolean",
"setField",
"(",
"PropertyExpression",
"expression",
",",
"Expression",
"objectExpression",
",",
"ClassNode",
"rType",
",",
"String",
"name",
")",
"{",
"if",
"(",
"expression",
".",
"isSafe",
"(",
")",
")",
"return",
"false",
";",
"FieldNode",
"fn",
"=",
"AsmClassGenerator",
".",
"getDeclaredFieldOfCurrentClassOrAccessibleFieldOfSuper",
"(",
"controller",
".",
"getClassNode",
"(",
")",
",",
"rType",
",",
"name",
",",
"false",
")",
";",
"if",
"(",
"fn",
"==",
"null",
")",
"return",
"false",
";",
"OperandStack",
"stack",
"=",
"controller",
".",
"getOperandStack",
"(",
")",
";",
"stack",
".",
"doGroovyCast",
"(",
"fn",
".",
"getType",
"(",
")",
")",
";",
"MethodVisitor",
"mv",
"=",
"controller",
".",
"getMethodVisitor",
"(",
")",
";",
"String",
"ownerName",
"=",
"BytecodeHelper",
".",
"getClassInternalName",
"(",
"fn",
".",
"getOwner",
"(",
")",
")",
";",
"if",
"(",
"!",
"fn",
".",
"isStatic",
"(",
")",
")",
"{",
"controller",
".",
"getCompileStack",
"(",
")",
".",
"pushLHS",
"(",
"false",
")",
";",
"objectExpression",
".",
"visit",
"(",
"controller",
".",
"getAcg",
"(",
")",
")",
";",
"controller",
".",
"getCompileStack",
"(",
")",
".",
"popLHS",
"(",
")",
";",
"if",
"(",
"!",
"rType",
".",
"equals",
"(",
"stack",
".",
"getTopOperand",
"(",
")",
")",
")",
"{",
"BytecodeHelper",
".",
"doCast",
"(",
"mv",
",",
"rType",
")",
";",
"stack",
".",
"replace",
"(",
"rType",
")",
";",
"}",
"stack",
".",
"swap",
"(",
")",
";",
"mv",
".",
"visitFieldInsn",
"(",
"PUTFIELD",
",",
"ownerName",
",",
"name",
",",
"BytecodeHelper",
".",
"getTypeDescription",
"(",
"fn",
".",
"getType",
"(",
")",
")",
")",
";",
"stack",
".",
"remove",
"(",
"1",
")",
";",
"}",
"else",
"{",
"mv",
".",
"visitFieldInsn",
"(",
"PUTSTATIC",
",",
"ownerName",
",",
"name",
",",
"BytecodeHelper",
".",
"getTypeDescription",
"(",
"fn",
".",
"getType",
"(",
")",
")",
")",
";",
"}",
"//mv.visitInsn(ACONST_NULL);",
"//stack.replace(OBJECT_TYPE);",
"return",
"true",
";",
"}"
] | this is just a simple set field handling static and non-static, but not Closure and inner classes | [
"this",
"is",
"just",
"a",
"simple",
"set",
"field",
"handling",
"static",
"and",
"non",
"-",
"static",
"but",
"not",
"Closure",
"and",
"inner",
"classes"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesCallSiteWriter.java#L902-L929 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java | FlowPath.markActive | public void markActive(@NonNull String nodeName, boolean active) {
"""
This method allows to set specified node active or inactive.
PLEASE NOTE: All nodes using this node as input, will be considered inactive, if this node is set to be inactive.
@param nodeName
@param active
"""
ensureNodeStateExists(nodeName);
states.get(nodeName).setActive(active);
} | java | public void markActive(@NonNull String nodeName, boolean active) {
ensureNodeStateExists(nodeName);
states.get(nodeName).setActive(active);
} | [
"public",
"void",
"markActive",
"(",
"@",
"NonNull",
"String",
"nodeName",
",",
"boolean",
"active",
")",
"{",
"ensureNodeStateExists",
"(",
"nodeName",
")",
";",
"states",
".",
"get",
"(",
"nodeName",
")",
".",
"setActive",
"(",
"active",
")",
";",
"}"
] | This method allows to set specified node active or inactive.
PLEASE NOTE: All nodes using this node as input, will be considered inactive, if this node is set to be inactive.
@param nodeName
@param active | [
"This",
"method",
"allows",
"to",
"set",
"specified",
"node",
"active",
"or",
"inactive",
".",
"PLEASE",
"NOTE",
":",
"All",
"nodes",
"using",
"this",
"node",
"as",
"input",
"will",
"be",
"considered",
"inactive",
"if",
"this",
"node",
"is",
"set",
"to",
"be",
"inactive",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/flow/FlowPath.java#L62-L66 |
js-lib-com/commons | src/main/java/js/util/Params.java | Params.isKindOf | public static void isKindOf(Type parameter, Type typeToMatch, String name) {
"""
Test if parameter is of requested type and throw exception if not.
@param parameter invocation parameter,
@param typeToMatch type to match,
@param name the name of invocation parameter.
@throws IllegalArgumentException if parameter is not of requested type.
"""
if (!Types.isKindOf(parameter, typeToMatch)) {
throw new IllegalArgumentException(Strings.format("%s is not %s.", name, typeToMatch));
}
} | java | public static void isKindOf(Type parameter, Type typeToMatch, String name) {
if (!Types.isKindOf(parameter, typeToMatch)) {
throw new IllegalArgumentException(Strings.format("%s is not %s.", name, typeToMatch));
}
} | [
"public",
"static",
"void",
"isKindOf",
"(",
"Type",
"parameter",
",",
"Type",
"typeToMatch",
",",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"Types",
".",
"isKindOf",
"(",
"parameter",
",",
"typeToMatch",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"Strings",
".",
"format",
"(",
"\"%s is not %s.\"",
",",
"name",
",",
"typeToMatch",
")",
")",
";",
"}",
"}"
] | Test if parameter is of requested type and throw exception if not.
@param parameter invocation parameter,
@param typeToMatch type to match,
@param name the name of invocation parameter.
@throws IllegalArgumentException if parameter is not of requested type. | [
"Test",
"if",
"parameter",
"is",
"of",
"requested",
"type",
"and",
"throw",
"exception",
"if",
"not",
"."
] | train | https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/util/Params.java#L541-L545 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java | SeaGlassLookAndFeel.defineInternalFrameCloseButtons | private void defineInternalFrameCloseButtons(UIDefaults d) {
"""
Initialize the internal frame close button settings.
@param d the UI defaults map.
"""
String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\"";
String c = PAINTER_PREFIX + "TitlePaneCloseButtonPainter";
// Set the multiplicity of states for the Close button.
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused");
d.put(p + ".WindowNotFocused", new TitlePaneCloseButtonWindowNotFocusedState());
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_DISABLED));
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED));
d.put(p + "[Enabled+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED_WINDOWNOTFOCUSED));
d.put(p + "[MouseOver+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
d.put(p + "[Pressed+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED_WINDOWNOTFOCUSED));
d.put(p + ".icon", new SeaGlassIcon(p, "iconPainter", 43, 18));
} | java | private void defineInternalFrameCloseButtons(UIDefaults d) {
String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\"";
String c = PAINTER_PREFIX + "TitlePaneCloseButtonPainter";
// Set the multiplicity of states for the Close button.
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused");
d.put(p + ".WindowNotFocused", new TitlePaneCloseButtonWindowNotFocusedState());
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_DISABLED));
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED));
d.put(p + "[Enabled+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED_WINDOWNOTFOCUSED));
d.put(p + "[MouseOver+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
d.put(p + "[Pressed+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED_WINDOWNOTFOCUSED));
d.put(p + ".icon", new SeaGlassIcon(p, "iconPainter", 43, 18));
} | [
"private",
"void",
"defineInternalFrameCloseButtons",
"(",
"UIDefaults",
"d",
")",
"{",
"String",
"p",
"=",
"\"InternalFrame:InternalFrameTitlePane:\\\"InternalFrameTitlePane.closeButton\\\"\"",
";",
"String",
"c",
"=",
"PAINTER_PREFIX",
"+",
"\"TitlePaneCloseButtonPainter\"",
";",
"// Set the multiplicity of states for the Close button.",
"d",
".",
"put",
"(",
"p",
"+",
"\".States\"",
",",
"\"Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused\"",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".WindowNotFocused\"",
",",
"new",
"TitlePaneCloseButtonWindowNotFocusedState",
"(",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".contentMargins\"",
",",
"new",
"InsetsUIResource",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Disabled].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_DISABLED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[MouseOver].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_MOUSEOVER",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Pressed].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_PRESSED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled+WindowNotFocused].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED_WINDOWNOTFOCUSED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[MouseOver+WindowNotFocused].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_MOUSEOVER",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Pressed+WindowNotFocused].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"TitlePaneCloseButtonPainter",
".",
"Which",
".",
"BACKGROUND_PRESSED_WINDOWNOTFOCUSED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".icon\"",
",",
"new",
"SeaGlassIcon",
"(",
"p",
",",
"\"iconPainter\"",
",",
"43",
",",
"18",
")",
")",
";",
"}"
] | Initialize the internal frame close button settings.
@param d the UI defaults map. | [
"Initialize",
"the",
"internal",
"frame",
"close",
"button",
"settings",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java#L1234-L1252 |
kaazing/gateway | mina.core/core/src/main/java/org/apache/mina/util/byteaccess/ByteArrayList.java | ByteArrayList.addNode | protected void addNode( Node nodeToInsert, Node insertBeforeNode ) {
"""
Inserts a new node into the list.
@param nodeToInsert new node to insert
@param insertBeforeNode node to insert before
@throws NullPointerException if either node is null
"""
// Insert node.
nodeToInsert.next = insertBeforeNode;
nodeToInsert.previous = insertBeforeNode.previous;
insertBeforeNode.previous.next = nodeToInsert;
insertBeforeNode.previous = nodeToInsert;
} | java | protected void addNode( Node nodeToInsert, Node insertBeforeNode )
{
// Insert node.
nodeToInsert.next = insertBeforeNode;
nodeToInsert.previous = insertBeforeNode.previous;
insertBeforeNode.previous.next = nodeToInsert;
insertBeforeNode.previous = nodeToInsert;
} | [
"protected",
"void",
"addNode",
"(",
"Node",
"nodeToInsert",
",",
"Node",
"insertBeforeNode",
")",
"{",
"// Insert node.",
"nodeToInsert",
".",
"next",
"=",
"insertBeforeNode",
";",
"nodeToInsert",
".",
"previous",
"=",
"insertBeforeNode",
".",
"previous",
";",
"insertBeforeNode",
".",
"previous",
".",
"next",
"=",
"nodeToInsert",
";",
"insertBeforeNode",
".",
"previous",
"=",
"nodeToInsert",
";",
"}"
] | Inserts a new node into the list.
@param nodeToInsert new node to insert
@param insertBeforeNode node to insert before
@throws NullPointerException if either node is null | [
"Inserts",
"a",
"new",
"node",
"into",
"the",
"list",
"."
] | train | https://github.com/kaazing/gateway/blob/06017b19273109b3b992e528e702586446168d57/mina.core/core/src/main/java/org/apache/mina/util/byteaccess/ByteArrayList.java#L177-L184 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/ByteUtils.java | ByteUtils.print_bytes | public static String print_bytes( byte[] data, int offset, int length ) {
"""
Produce a <code>String</code> representation for the specified array of
<code>byte</code>s. Print each <code>byte</code> as two hexadecimal
digits.
@param data The array to print
@param offset the start offset in <code>data</code>
@param length the number of <code>byte</code>s to print
@return DOCUMENT ME!
"""
int size = 2 * length;
size += ((size / 8) + (size / 64));
char[] buf = new char[size];
int low_mask = 0x0f;
int high_mask = 0xf0;
int buf_pos = 0;
byte b;
int j = 0;
for( int i = offset; i < (offset + length); ++i ) {
b = data[i];
buf[buf_pos++] = digits[(high_mask & b) >> 4];
buf[buf_pos++] = digits[(low_mask & b)];
if ((j % 4) == 3) {
buf[buf_pos++] = ' ';
}
if ((j % 32) == 31) {
buf[buf_pos++] = '\n';
}
++j;
}
return new String(buf);
} | java | public static String print_bytes( byte[] data, int offset, int length ) {
int size = 2 * length;
size += ((size / 8) + (size / 64));
char[] buf = new char[size];
int low_mask = 0x0f;
int high_mask = 0xf0;
int buf_pos = 0;
byte b;
int j = 0;
for( int i = offset; i < (offset + length); ++i ) {
b = data[i];
buf[buf_pos++] = digits[(high_mask & b) >> 4];
buf[buf_pos++] = digits[(low_mask & b)];
if ((j % 4) == 3) {
buf[buf_pos++] = ' ';
}
if ((j % 32) == 31) {
buf[buf_pos++] = '\n';
}
++j;
}
return new String(buf);
} | [
"public",
"static",
"String",
"print_bytes",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"int",
"size",
"=",
"2",
"*",
"length",
";",
"size",
"+=",
"(",
"(",
"size",
"/",
"8",
")",
"+",
"(",
"size",
"/",
"64",
")",
")",
";",
"char",
"[",
"]",
"buf",
"=",
"new",
"char",
"[",
"size",
"]",
";",
"int",
"low_mask",
"=",
"0x0f",
";",
"int",
"high_mask",
"=",
"0xf0",
";",
"int",
"buf_pos",
"=",
"0",
";",
"byte",
"b",
";",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"offset",
";",
"i",
"<",
"(",
"offset",
"+",
"length",
")",
";",
"++",
"i",
")",
"{",
"b",
"=",
"data",
"[",
"i",
"]",
";",
"buf",
"[",
"buf_pos",
"++",
"]",
"=",
"digits",
"[",
"(",
"high_mask",
"&",
"b",
")",
">>",
"4",
"]",
";",
"buf",
"[",
"buf_pos",
"++",
"]",
"=",
"digits",
"[",
"(",
"low_mask",
"&",
"b",
")",
"]",
";",
"if",
"(",
"(",
"j",
"%",
"4",
")",
"==",
"3",
")",
"{",
"buf",
"[",
"buf_pos",
"++",
"]",
"=",
"'",
"'",
";",
"}",
"if",
"(",
"(",
"j",
"%",
"32",
")",
"==",
"31",
")",
"{",
"buf",
"[",
"buf_pos",
"++",
"]",
"=",
"'",
"'",
";",
"}",
"++",
"j",
";",
"}",
"return",
"new",
"String",
"(",
"buf",
")",
";",
"}"
] | Produce a <code>String</code> representation for the specified array of
<code>byte</code>s. Print each <code>byte</code> as two hexadecimal
digits.
@param data The array to print
@param offset the start offset in <code>data</code>
@param length the number of <code>byte</code>s to print
@return DOCUMENT ME! | [
"Produce",
"a",
"<code",
">",
"String<",
"/",
"code",
">",
"representation",
"for",
"the",
"specified",
"array",
"of",
"<code",
">",
"byte<",
"/",
"code",
">",
"s",
".",
"Print",
"each",
"<code",
">",
"byte<",
"/",
"code",
">",
"as",
"two",
"hexadecimal",
"digits",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/ByteUtils.java#L621-L650 |
cdk/cdk | tool/charges/src/main/java/org/openscience/cdk/charges/GasteigerPEPEPartialCharges.java | GasteigerPEPEPartialCharges.setAntiFlags | private IAtomContainer setAntiFlags(IAtomContainer container, IAtomContainer ac, int number, boolean b) {
"""
Set the Flags to atoms and bonds which are not contained
in an atomContainer.
@param container Container with the flags
@param ac Container to put the flags
@param b True, if the the flag is true
@return Container with added flags
"""
IBond bond = ac.getBond(number);
if (!container.contains(bond)) {
bond.setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getBegin().setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getEnd().setFlag(CDKConstants.REACTIVE_CENTER, b);
} else
return null;
return ac;
} | java | private IAtomContainer setAntiFlags(IAtomContainer container, IAtomContainer ac, int number, boolean b) {
IBond bond = ac.getBond(number);
if (!container.contains(bond)) {
bond.setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getBegin().setFlag(CDKConstants.REACTIVE_CENTER, b);
bond.getEnd().setFlag(CDKConstants.REACTIVE_CENTER, b);
} else
return null;
return ac;
} | [
"private",
"IAtomContainer",
"setAntiFlags",
"(",
"IAtomContainer",
"container",
",",
"IAtomContainer",
"ac",
",",
"int",
"number",
",",
"boolean",
"b",
")",
"{",
"IBond",
"bond",
"=",
"ac",
".",
"getBond",
"(",
"number",
")",
";",
"if",
"(",
"!",
"container",
".",
"contains",
"(",
"bond",
")",
")",
"{",
"bond",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"bond",
".",
"getBegin",
"(",
")",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"bond",
".",
"getEnd",
"(",
")",
".",
"setFlag",
"(",
"CDKConstants",
".",
"REACTIVE_CENTER",
",",
"b",
")",
";",
"}",
"else",
"return",
"null",
";",
"return",
"ac",
";",
"}"
] | Set the Flags to atoms and bonds which are not contained
in an atomContainer.
@param container Container with the flags
@param ac Container to put the flags
@param b True, if the the flag is true
@return Container with added flags | [
"Set",
"the",
"Flags",
"to",
"atoms",
"and",
"bonds",
"which",
"are",
"not",
"contained",
"in",
"an",
"atomContainer",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/charges/src/main/java/org/openscience/cdk/charges/GasteigerPEPEPartialCharges.java#L497-L506 |
tobato/FastDFS_Client | src/main/java/com/github/tobato/fastdfs/domain/proto/mapper/BytesUtil.java | BytesUtil.buff2int | public static int buff2int(byte[] bs, int offset) {
"""
buff convert to int
@param bs the buffer (big-endian)
@param offset the start position based 0
@return int number
"""
return ((bs[offset] >= 0 ? bs[offset] : 256 + bs[offset]) << 24)
| ((bs[offset + 1] >= 0 ? bs[offset + 1] : 256 + bs[offset + 1]) << 16)
| ((bs[offset + 2] >= 0 ? bs[offset + 2] : 256 + bs[offset + 2]) << 8)
| (bs[offset + 3] >= 0 ? bs[offset + 3] : 256 + bs[offset + 3]);
} | java | public static int buff2int(byte[] bs, int offset) {
return ((bs[offset] >= 0 ? bs[offset] : 256 + bs[offset]) << 24)
| ((bs[offset + 1] >= 0 ? bs[offset + 1] : 256 + bs[offset + 1]) << 16)
| ((bs[offset + 2] >= 0 ? bs[offset + 2] : 256 + bs[offset + 2]) << 8)
| (bs[offset + 3] >= 0 ? bs[offset + 3] : 256 + bs[offset + 3]);
} | [
"public",
"static",
"int",
"buff2int",
"(",
"byte",
"[",
"]",
"bs",
",",
"int",
"offset",
")",
"{",
"return",
"(",
"(",
"bs",
"[",
"offset",
"]",
">=",
"0",
"?",
"bs",
"[",
"offset",
"]",
":",
"256",
"+",
"bs",
"[",
"offset",
"]",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"bs",
"[",
"offset",
"+",
"1",
"]",
">=",
"0",
"?",
"bs",
"[",
"offset",
"+",
"1",
"]",
":",
"256",
"+",
"bs",
"[",
"offset",
"+",
"1",
"]",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"bs",
"[",
"offset",
"+",
"2",
"]",
">=",
"0",
"?",
"bs",
"[",
"offset",
"+",
"2",
"]",
":",
"256",
"+",
"bs",
"[",
"offset",
"+",
"2",
"]",
")",
"<<",
"8",
")",
"|",
"(",
"bs",
"[",
"offset",
"+",
"3",
"]",
">=",
"0",
"?",
"bs",
"[",
"offset",
"+",
"3",
"]",
":",
"256",
"+",
"bs",
"[",
"offset",
"+",
"3",
"]",
")",
";",
"}"
] | buff convert to int
@param bs the buffer (big-endian)
@param offset the start position based 0
@return int number | [
"buff",
"convert",
"to",
"int"
] | train | https://github.com/tobato/FastDFS_Client/blob/8e3bfe712f1739028beed7f3a6b2cc4579a231e4/src/main/java/com/github/tobato/fastdfs/domain/proto/mapper/BytesUtil.java#L60-L65 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java | GregorianCalendar.getFixedDateMonth1 | private long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
"""
Returns the fixed date of the first date of the month (usually
the 1st of the month) before the specified date.
@param date the date for which the first day of the month is
calculated. The date has to be in the cut-over year (Gregorian
or Julian).
@param fixedDate the fixed date representation of the date
"""
assert date.getNormalizedYear() == gregorianCutoverYear ||
date.getNormalizedYear() == gregorianCutoverYearJulian;
BaseCalendar.Date gCutover = getGregorianCutoverDate();
if (gCutover.getMonth() == BaseCalendar.JANUARY
&& gCutover.getDayOfMonth() == 1) {
// The cutover happened on January 1.
return fixedDate - date.getDayOfMonth() + 1;
}
long fixedDateMonth1;
// The cutover happened sometime during the year.
if (date.getMonth() == gCutover.getMonth()) {
// The cutover happened in the month.
BaseCalendar.Date jLastDate = getLastJulianDate();
if (gregorianCutoverYear == gregorianCutoverYearJulian
&& gCutover.getMonth() == jLastDate.getMonth()) {
// The "gap" fits in the same month.
fixedDateMonth1 = jcal.getFixedDate(date.getNormalizedYear(),
date.getMonth(),
1,
null);
} else {
// Use the cutover date as the first day of the month.
fixedDateMonth1 = gregorianCutoverDate;
}
} else {
// The cutover happened before the month.
fixedDateMonth1 = fixedDate - date.getDayOfMonth() + 1;
}
return fixedDateMonth1;
} | java | private long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
assert date.getNormalizedYear() == gregorianCutoverYear ||
date.getNormalizedYear() == gregorianCutoverYearJulian;
BaseCalendar.Date gCutover = getGregorianCutoverDate();
if (gCutover.getMonth() == BaseCalendar.JANUARY
&& gCutover.getDayOfMonth() == 1) {
// The cutover happened on January 1.
return fixedDate - date.getDayOfMonth() + 1;
}
long fixedDateMonth1;
// The cutover happened sometime during the year.
if (date.getMonth() == gCutover.getMonth()) {
// The cutover happened in the month.
BaseCalendar.Date jLastDate = getLastJulianDate();
if (gregorianCutoverYear == gregorianCutoverYearJulian
&& gCutover.getMonth() == jLastDate.getMonth()) {
// The "gap" fits in the same month.
fixedDateMonth1 = jcal.getFixedDate(date.getNormalizedYear(),
date.getMonth(),
1,
null);
} else {
// Use the cutover date as the first day of the month.
fixedDateMonth1 = gregorianCutoverDate;
}
} else {
// The cutover happened before the month.
fixedDateMonth1 = fixedDate - date.getDayOfMonth() + 1;
}
return fixedDateMonth1;
} | [
"private",
"long",
"getFixedDateMonth1",
"(",
"BaseCalendar",
".",
"Date",
"date",
",",
"long",
"fixedDate",
")",
"{",
"assert",
"date",
".",
"getNormalizedYear",
"(",
")",
"==",
"gregorianCutoverYear",
"||",
"date",
".",
"getNormalizedYear",
"(",
")",
"==",
"gregorianCutoverYearJulian",
";",
"BaseCalendar",
".",
"Date",
"gCutover",
"=",
"getGregorianCutoverDate",
"(",
")",
";",
"if",
"(",
"gCutover",
".",
"getMonth",
"(",
")",
"==",
"BaseCalendar",
".",
"JANUARY",
"&&",
"gCutover",
".",
"getDayOfMonth",
"(",
")",
"==",
"1",
")",
"{",
"// The cutover happened on January 1.",
"return",
"fixedDate",
"-",
"date",
".",
"getDayOfMonth",
"(",
")",
"+",
"1",
";",
"}",
"long",
"fixedDateMonth1",
";",
"// The cutover happened sometime during the year.",
"if",
"(",
"date",
".",
"getMonth",
"(",
")",
"==",
"gCutover",
".",
"getMonth",
"(",
")",
")",
"{",
"// The cutover happened in the month.",
"BaseCalendar",
".",
"Date",
"jLastDate",
"=",
"getLastJulianDate",
"(",
")",
";",
"if",
"(",
"gregorianCutoverYear",
"==",
"gregorianCutoverYearJulian",
"&&",
"gCutover",
".",
"getMonth",
"(",
")",
"==",
"jLastDate",
".",
"getMonth",
"(",
")",
")",
"{",
"// The \"gap\" fits in the same month.",
"fixedDateMonth1",
"=",
"jcal",
".",
"getFixedDate",
"(",
"date",
".",
"getNormalizedYear",
"(",
")",
",",
"date",
".",
"getMonth",
"(",
")",
",",
"1",
",",
"null",
")",
";",
"}",
"else",
"{",
"// Use the cutover date as the first day of the month.",
"fixedDateMonth1",
"=",
"gregorianCutoverDate",
";",
"}",
"}",
"else",
"{",
"// The cutover happened before the month.",
"fixedDateMonth1",
"=",
"fixedDate",
"-",
"date",
".",
"getDayOfMonth",
"(",
")",
"+",
"1",
";",
"}",
"return",
"fixedDateMonth1",
";",
"}"
] | Returns the fixed date of the first date of the month (usually
the 1st of the month) before the specified date.
@param date the date for which the first day of the month is
calculated. The date has to be in the cut-over year (Gregorian
or Julian).
@param fixedDate the fixed date representation of the date | [
"Returns",
"the",
"fixed",
"date",
"of",
"the",
"first",
"date",
"of",
"the",
"month",
"(",
"usually",
"the",
"1st",
"of",
"the",
"month",
")",
"before",
"the",
"specified",
"date",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/GregorianCalendar.java#L3192-L3224 |
umeding/fuzzer | src/main/java/com/uwemeding/fuzzer/RuleConditions.java | RuleConditions.createAndCondition | public static Node createAndCondition(Node left, Node right) {
"""
Create an "AND" condition.
<p>
@param left left side of condition
@param right right side of condition
@return the "and" condition
"""
checkNode(left, IN, AND, OR);
checkNode(right, IN, AND, OR);
return new Condition(Node.Type.AND, left, right);
} | java | public static Node createAndCondition(Node left, Node right) {
checkNode(left, IN, AND, OR);
checkNode(right, IN, AND, OR);
return new Condition(Node.Type.AND, left, right);
} | [
"public",
"static",
"Node",
"createAndCondition",
"(",
"Node",
"left",
",",
"Node",
"right",
")",
"{",
"checkNode",
"(",
"left",
",",
"IN",
",",
"AND",
",",
"OR",
")",
";",
"checkNode",
"(",
"right",
",",
"IN",
",",
"AND",
",",
"OR",
")",
";",
"return",
"new",
"Condition",
"(",
"Node",
".",
"Type",
".",
"AND",
",",
"left",
",",
"right",
")",
";",
"}"
] | Create an "AND" condition.
<p>
@param left left side of condition
@param right right side of condition
@return the "and" condition | [
"Create",
"an",
"AND",
"condition",
".",
"<p",
">"
] | train | https://github.com/umeding/fuzzer/blob/e8aa46313bb1d1328865f26f99455124aede828c/src/main/java/com/uwemeding/fuzzer/RuleConditions.java#L52-L56 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/JMProgressiveManager.java | JMProgressiveManager.registerLastResultChangeListener | public JMProgressiveManager<T, R> registerLastResultChangeListener(
Consumer<Optional<R>> resultChangeListener) {
"""
Register last result change listener jm progressive manager.
@param resultChangeListener the result change listener
@return the jm progressive manager
"""
return registerListener(lastResult, resultChangeListener);
} | java | public JMProgressiveManager<T, R> registerLastResultChangeListener(
Consumer<Optional<R>> resultChangeListener) {
return registerListener(lastResult, resultChangeListener);
} | [
"public",
"JMProgressiveManager",
"<",
"T",
",",
"R",
">",
"registerLastResultChangeListener",
"(",
"Consumer",
"<",
"Optional",
"<",
"R",
">",
">",
"resultChangeListener",
")",
"{",
"return",
"registerListener",
"(",
"lastResult",
",",
"resultChangeListener",
")",
";",
"}"
] | Register last result change listener jm progressive manager.
@param resultChangeListener the result change listener
@return the jm progressive manager | [
"Register",
"last",
"result",
"change",
"listener",
"jm",
"progressive",
"manager",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMProgressiveManager.java#L202-L205 |
metamx/extendedset | src/main/java/it/uniroma3/mat/extendedset/wrappers/matrix/PairSet.java | PairSet.removeAll | public boolean removeAll(Collection<T> trans, Collection<I> items) {
"""
Removes the pairs obtained from the Cartesian product of transactions and
items
@param trans
collection of transactions
@param items
collection of items
@return <code>true</code> if the set set has been changed
"""
if (trans == null || trans.isEmpty() || items == null || items.isEmpty())
return false;
return matrix.removeAll(allTransactions.convert(trans).indices(), allItems.convert(items).indices());
} | java | public boolean removeAll(Collection<T> trans, Collection<I> items) {
if (trans == null || trans.isEmpty() || items == null || items.isEmpty())
return false;
return matrix.removeAll(allTransactions.convert(trans).indices(), allItems.convert(items).indices());
} | [
"public",
"boolean",
"removeAll",
"(",
"Collection",
"<",
"T",
">",
"trans",
",",
"Collection",
"<",
"I",
">",
"items",
")",
"{",
"if",
"(",
"trans",
"==",
"null",
"||",
"trans",
".",
"isEmpty",
"(",
")",
"||",
"items",
"==",
"null",
"||",
"items",
".",
"isEmpty",
"(",
")",
")",
"return",
"false",
";",
"return",
"matrix",
".",
"removeAll",
"(",
"allTransactions",
".",
"convert",
"(",
"trans",
")",
".",
"indices",
"(",
")",
",",
"allItems",
".",
"convert",
"(",
"items",
")",
".",
"indices",
"(",
")",
")",
";",
"}"
] | Removes the pairs obtained from the Cartesian product of transactions and
items
@param trans
collection of transactions
@param items
collection of items
@return <code>true</code> if the set set has been changed | [
"Removes",
"the",
"pairs",
"obtained",
"from",
"the",
"Cartesian",
"product",
"of",
"transactions",
"and",
"items"
] | train | https://github.com/metamx/extendedset/blob/0f77c28057fac9c1bd6d79fbe5425b8efe5742a8/src/main/java/it/uniroma3/mat/extendedset/wrappers/matrix/PairSet.java#L554-L558 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/system/systemcpu_stats.java | systemcpu_stats.get | public static systemcpu_stats get(nitro_service service, Long id) throws Exception {
"""
Use this API to fetch statistics of systemcpu_stats resource of given name .
"""
systemcpu_stats obj = new systemcpu_stats();
obj.set_id(id);
systemcpu_stats response = (systemcpu_stats) obj.stat_resource(service);
return response;
} | java | public static systemcpu_stats get(nitro_service service, Long id) throws Exception{
systemcpu_stats obj = new systemcpu_stats();
obj.set_id(id);
systemcpu_stats response = (systemcpu_stats) obj.stat_resource(service);
return response;
} | [
"public",
"static",
"systemcpu_stats",
"get",
"(",
"nitro_service",
"service",
",",
"Long",
"id",
")",
"throws",
"Exception",
"{",
"systemcpu_stats",
"obj",
"=",
"new",
"systemcpu_stats",
"(",
")",
";",
"obj",
".",
"set_id",
"(",
"id",
")",
";",
"systemcpu_stats",
"response",
"=",
"(",
"systemcpu_stats",
")",
"obj",
".",
"stat_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch statistics of systemcpu_stats resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"statistics",
"of",
"systemcpu_stats",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/system/systemcpu_stats.java#L151-L156 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/FieldAnnotation.java | FieldAnnotation.fromReferencedField | public static FieldAnnotation fromReferencedField(DismantleBytecode visitor) {
"""
Factory method. Class name, field name, and field signatures are taken
from the given visitor, which is visiting a reference to the field (i.e.,
a getfield or getstatic instruction).
@param visitor
the visitor which is visiting the field reference
@return the FieldAnnotation object
"""
String className = visitor.getDottedClassConstantOperand();
return new FieldAnnotation(className, visitor.getNameConstantOperand(), visitor.getSigConstantOperand(),
visitor.getRefFieldIsStatic());
} | java | public static FieldAnnotation fromReferencedField(DismantleBytecode visitor) {
String className = visitor.getDottedClassConstantOperand();
return new FieldAnnotation(className, visitor.getNameConstantOperand(), visitor.getSigConstantOperand(),
visitor.getRefFieldIsStatic());
} | [
"public",
"static",
"FieldAnnotation",
"fromReferencedField",
"(",
"DismantleBytecode",
"visitor",
")",
"{",
"String",
"className",
"=",
"visitor",
".",
"getDottedClassConstantOperand",
"(",
")",
";",
"return",
"new",
"FieldAnnotation",
"(",
"className",
",",
"visitor",
".",
"getNameConstantOperand",
"(",
")",
",",
"visitor",
".",
"getSigConstantOperand",
"(",
")",
",",
"visitor",
".",
"getRefFieldIsStatic",
"(",
")",
")",
";",
"}"
] | Factory method. Class name, field name, and field signatures are taken
from the given visitor, which is visiting a reference to the field (i.e.,
a getfield or getstatic instruction).
@param visitor
the visitor which is visiting the field reference
@return the FieldAnnotation object | [
"Factory",
"method",
".",
"Class",
"name",
"field",
"name",
"and",
"field",
"signatures",
"are",
"taken",
"from",
"the",
"given",
"visitor",
"which",
"is",
"visiting",
"a",
"reference",
"to",
"the",
"field",
"(",
"i",
".",
"e",
".",
"a",
"getfield",
"or",
"getstatic",
"instruction",
")",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/FieldAnnotation.java#L144-L148 |
xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmElements.java | XsdAsmElements.generateClassMethods | private static void generateClassMethods(ClassWriter classWriter, String className, String apiName) {
"""
Creates some class specific methods that all implementations of {@link XsdAbstractElement} should have, which are:
Constructor(ElementVisitor visitor) - Assigns the argument to the visitor field;
Constructor(Element parent) - Assigns the argument to the parent field and obtains the visitor of the parent;
Constructor(Element parent, ElementVisitor visitor, boolean performsVisit) -
An alternative constructor to avoid the visit method call;
of({@link Consumer} consumer) - Method used to avoid variable extraction in order to allow cleaner code;
dynamic({@link Consumer} consumer) - Method used to indicate that the changes on the fluent interface performed
inside the Consumer code are a dynamic aspect of the result and are bound to change;
self() - Returns this;
getName() - Returns the name of the element;
getParent() - Returns the parent field;
getVisitor() - Returns the visitor field;
__() - Returns the parent and calls the respective visitParent method.
@param classWriter The {@link ClassWriter} on which the methods should be written.
@param className The class name.
@param apiName The name of the generated fluent interface.
"""
generateClassMethods(classWriter, className, className, apiName, true);
} | java | private static void generateClassMethods(ClassWriter classWriter, String className, String apiName) {
generateClassMethods(classWriter, className, className, apiName, true);
} | [
"private",
"static",
"void",
"generateClassMethods",
"(",
"ClassWriter",
"classWriter",
",",
"String",
"className",
",",
"String",
"apiName",
")",
"{",
"generateClassMethods",
"(",
"classWriter",
",",
"className",
",",
"className",
",",
"apiName",
",",
"true",
")",
";",
"}"
] | Creates some class specific methods that all implementations of {@link XsdAbstractElement} should have, which are:
Constructor(ElementVisitor visitor) - Assigns the argument to the visitor field;
Constructor(Element parent) - Assigns the argument to the parent field and obtains the visitor of the parent;
Constructor(Element parent, ElementVisitor visitor, boolean performsVisit) -
An alternative constructor to avoid the visit method call;
of({@link Consumer} consumer) - Method used to avoid variable extraction in order to allow cleaner code;
dynamic({@link Consumer} consumer) - Method used to indicate that the changes on the fluent interface performed
inside the Consumer code are a dynamic aspect of the result and are bound to change;
self() - Returns this;
getName() - Returns the name of the element;
getParent() - Returns the parent field;
getVisitor() - Returns the visitor field;
__() - Returns the parent and calls the respective visitParent method.
@param classWriter The {@link ClassWriter} on which the methods should be written.
@param className The class name.
@param apiName The name of the generated fluent interface. | [
"Creates",
"some",
"class",
"specific",
"methods",
"that",
"all",
"implementations",
"of",
"{"
] | train | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmElements.java#L66-L68 |
joniles/mpxj | src/main/java/net/sf/mpxj/phoenix/PhoenixReader.java | PhoenixReader.findChildTaskByUUID | private Task findChildTaskByUUID(ChildTaskContainer parent, UUID uuid) {
"""
Locates a task within a child task container which matches the supplied UUID.
@param parent child task container
@param uuid required UUID
@return Task instance or null if the task is not found
"""
Task result = null;
for (Task task : parent.getChildTasks())
{
if (uuid.equals(task.getGUID()))
{
result = task;
break;
}
}
return result;
} | java | private Task findChildTaskByUUID(ChildTaskContainer parent, UUID uuid)
{
Task result = null;
for (Task task : parent.getChildTasks())
{
if (uuid.equals(task.getGUID()))
{
result = task;
break;
}
}
return result;
} | [
"private",
"Task",
"findChildTaskByUUID",
"(",
"ChildTaskContainer",
"parent",
",",
"UUID",
"uuid",
")",
"{",
"Task",
"result",
"=",
"null",
";",
"for",
"(",
"Task",
"task",
":",
"parent",
".",
"getChildTasks",
"(",
")",
")",
"{",
"if",
"(",
"uuid",
".",
"equals",
"(",
"task",
".",
"getGUID",
"(",
")",
")",
")",
"{",
"result",
"=",
"task",
";",
"break",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Locates a task within a child task container which matches the supplied UUID.
@param parent child task container
@param uuid required UUID
@return Task instance or null if the task is not found | [
"Locates",
"a",
"task",
"within",
"a",
"child",
"task",
"container",
"which",
"matches",
"the",
"supplied",
"UUID",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/phoenix/PhoenixReader.java#L609-L623 |
GerdHolz/TOVAL | src/de/invation/code/toval/graphic/renderer/DefaultTableHeaderCellRenderer.java | DefaultTableHeaderCellRenderer.getIcon | @SuppressWarnings("incomplete-switch")
protected Icon getIcon(JTable table, int column) {
"""
Overloaded to return an icon suitable to the primary sorted column, or null if
the column is not the primary sort key.
@param table the <code>JTable</code>.
@param column the column index.
@return the sort icon, or null if the column is unsorted.
"""
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
} | java | @SuppressWarnings("incomplete-switch")
protected Icon getIcon(JTable table, int column) {
SortKey sortKey = getSortKey(table, column);
if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
switch (sortKey.getSortOrder()) {
case ASCENDING:
return UIManager.getIcon("Table.ascendingSortIcon");
case DESCENDING:
return UIManager.getIcon("Table.descendingSortIcon");
}
}
return null;
} | [
"@",
"SuppressWarnings",
"(",
"\"incomplete-switch\"",
")",
"protected",
"Icon",
"getIcon",
"(",
"JTable",
"table",
",",
"int",
"column",
")",
"{",
"SortKey",
"sortKey",
"=",
"getSortKey",
"(",
"table",
",",
"column",
")",
";",
"if",
"(",
"sortKey",
"!=",
"null",
"&&",
"table",
".",
"convertColumnIndexToView",
"(",
"sortKey",
".",
"getColumn",
"(",
")",
")",
"==",
"column",
")",
"{",
"switch",
"(",
"sortKey",
".",
"getSortOrder",
"(",
")",
")",
"{",
"case",
"ASCENDING",
":",
"return",
"UIManager",
".",
"getIcon",
"(",
"\"Table.ascendingSortIcon\"",
")",
";",
"case",
"DESCENDING",
":",
"return",
"UIManager",
".",
"getIcon",
"(",
"\"Table.descendingSortIcon\"",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Overloaded to return an icon suitable to the primary sorted column, or null if
the column is not the primary sort key.
@param table the <code>JTable</code>.
@param column the column index.
@return the sort icon, or null if the column is unsorted. | [
"Overloaded",
"to",
"return",
"an",
"icon",
"suitable",
"to",
"the",
"primary",
"sorted",
"column",
"or",
"null",
"if",
"the",
"column",
"is",
"not",
"the",
"primary",
"sort",
"key",
"."
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/graphic/renderer/DefaultTableHeaderCellRenderer.java#L80-L92 |
RobertStewart/privateer | src/main/java/com/wombatnation/privateer/Privateer.java | Privateer.callMethod | public Object callMethod(Object o, String methodName, Object... args)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
"""
Calls the specified method on the Object o with the specified arguments. Returns the
result as an Object. Only methods declared on the class for Object o can be called.
<p>
The length of the vararg list of arguments to be passed to the method must match
what the method expects. If no arguments are expected, null can be passed. If one
argument is expected, that argument can be passed as an object. If multiple
arguments are expected, they can be passed as an Object array or as a comma-separated
list.
@param o Object to access
@param methodName Name of method to call
@param args Vararg list of arguments to pass to method
@return Object that is the result of calling the named method
@throws NoSuchMethodException if the name or arguments don't match any declared method
@throws IllegalAccessException
@throws InvocationTargetException if some unexpected error occurs when invoking a method that was thought to match
@throws IllegalArgumentException if the argument count doesn't match any method that has the same name
"""
Method method = null;
if (args == null || args.length == 0) {
method = o.getClass().getDeclaredMethod(methodName);
} else {
Class<?>[] types = new Class[args.length];
for (int i = 0; i < args.length; i++) {
types[i] = args[i].getClass();
}
try {
method = o.getClass().getDeclaredMethod(methodName, types);
} catch (NoSuchMethodException e) {
// Try more complex comparison for matching args to supertypes in the params
method = findSupertypeMethod(o, methodName, types);
}
}
if (method == null) {
throw new NoSuchMethodException("Found no method named" + methodName + " with matching params");
}
method.setAccessible(true);
return method.invoke(o, args);
} | java | public Object callMethod(Object o, String methodName, Object... args)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Method method = null;
if (args == null || args.length == 0) {
method = o.getClass().getDeclaredMethod(methodName);
} else {
Class<?>[] types = new Class[args.length];
for (int i = 0; i < args.length; i++) {
types[i] = args[i].getClass();
}
try {
method = o.getClass().getDeclaredMethod(methodName, types);
} catch (NoSuchMethodException e) {
// Try more complex comparison for matching args to supertypes in the params
method = findSupertypeMethod(o, methodName, types);
}
}
if (method == null) {
throw new NoSuchMethodException("Found no method named" + methodName + " with matching params");
}
method.setAccessible(true);
return method.invoke(o, args);
} | [
"public",
"Object",
"callMethod",
"(",
"Object",
"o",
",",
"String",
"methodName",
",",
"Object",
"...",
"args",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"Method",
"method",
"=",
"null",
";",
"if",
"(",
"args",
"==",
"null",
"||",
"args",
".",
"length",
"==",
"0",
")",
"{",
"method",
"=",
"o",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"methodName",
")",
";",
"}",
"else",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"types",
"=",
"new",
"Class",
"[",
"args",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"types",
"[",
"i",
"]",
"=",
"args",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
";",
"}",
"try",
"{",
"method",
"=",
"o",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"methodName",
",",
"types",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"// Try more complex comparison for matching args to supertypes in the params",
"method",
"=",
"findSupertypeMethod",
"(",
"o",
",",
"methodName",
",",
"types",
")",
";",
"}",
"}",
"if",
"(",
"method",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"\"Found no method named\"",
"+",
"methodName",
"+",
"\" with matching params\"",
")",
";",
"}",
"method",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"method",
".",
"invoke",
"(",
"o",
",",
"args",
")",
";",
"}"
] | Calls the specified method on the Object o with the specified arguments. Returns the
result as an Object. Only methods declared on the class for Object o can be called.
<p>
The length of the vararg list of arguments to be passed to the method must match
what the method expects. If no arguments are expected, null can be passed. If one
argument is expected, that argument can be passed as an object. If multiple
arguments are expected, they can be passed as an Object array or as a comma-separated
list.
@param o Object to access
@param methodName Name of method to call
@param args Vararg list of arguments to pass to method
@return Object that is the result of calling the named method
@throws NoSuchMethodException if the name or arguments don't match any declared method
@throws IllegalAccessException
@throws InvocationTargetException if some unexpected error occurs when invoking a method that was thought to match
@throws IllegalArgumentException if the argument count doesn't match any method that has the same name | [
"Calls",
"the",
"specified",
"method",
"on",
"the",
"Object",
"o",
"with",
"the",
"specified",
"arguments",
".",
"Returns",
"the",
"result",
"as",
"an",
"Object",
".",
"Only",
"methods",
"declared",
"on",
"the",
"class",
"for",
"Object",
"o",
"can",
"be",
"called",
".",
"<p",
">",
"The",
"length",
"of",
"the",
"vararg",
"list",
"of",
"arguments",
"to",
"be",
"passed",
"to",
"the",
"method",
"must",
"match",
"what",
"the",
"method",
"expects",
".",
"If",
"no",
"arguments",
"are",
"expected",
"null",
"can",
"be",
"passed",
".",
"If",
"one",
"argument",
"is",
"expected",
"that",
"argument",
"can",
"be",
"passed",
"as",
"an",
"object",
".",
"If",
"multiple",
"arguments",
"are",
"expected",
"they",
"can",
"be",
"passed",
"as",
"an",
"Object",
"array",
"or",
"as",
"a",
"comma",
"-",
"separated",
"list",
"."
] | train | https://github.com/RobertStewart/privateer/blob/766603021ff406c950e798ce3fb259c9f1f460c7/src/main/java/com/wombatnation/privateer/Privateer.java#L123-L150 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java | ReflectUtil.newInstance | public static <T> T newInstance(Class<T> clazz, Object... params) throws UtilException {
"""
实例化对象
@param <T> 对象类型
@param clazz 类
@param params 构造函数参数
@return 对象
@throws UtilException 包装各类异常
"""
if (ArrayUtil.isEmpty(params)) {
final Constructor<T> constructor = getConstructor(clazz);
try {
return constructor.newInstance();
} catch (Exception e) {
throw new UtilException(e, "Instance class [{}] error!", clazz);
}
}
final Class<?>[] paramTypes = ClassUtil.getClasses(params);
final Constructor<T> constructor = getConstructor(clazz, paramTypes);
if (null == constructor) {
throw new UtilException("No Constructor matched for parameter types: [{}]", new Object[] { paramTypes });
}
try {
return constructor.newInstance(params);
} catch (Exception e) {
throw new UtilException(e, "Instance class [{}] error!", clazz);
}
} | java | public static <T> T newInstance(Class<T> clazz, Object... params) throws UtilException {
if (ArrayUtil.isEmpty(params)) {
final Constructor<T> constructor = getConstructor(clazz);
try {
return constructor.newInstance();
} catch (Exception e) {
throw new UtilException(e, "Instance class [{}] error!", clazz);
}
}
final Class<?>[] paramTypes = ClassUtil.getClasses(params);
final Constructor<T> constructor = getConstructor(clazz, paramTypes);
if (null == constructor) {
throw new UtilException("No Constructor matched for parameter types: [{}]", new Object[] { paramTypes });
}
try {
return constructor.newInstance(params);
} catch (Exception e) {
throw new UtilException(e, "Instance class [{}] error!", clazz);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"newInstance",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Object",
"...",
"params",
")",
"throws",
"UtilException",
"{",
"if",
"(",
"ArrayUtil",
".",
"isEmpty",
"(",
"params",
")",
")",
"{",
"final",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"getConstructor",
"(",
"clazz",
")",
";",
"try",
"{",
"return",
"constructor",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"UtilException",
"(",
"e",
",",
"\"Instance class [{}] error!\"",
",",
"clazz",
")",
";",
"}",
"}",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"paramTypes",
"=",
"ClassUtil",
".",
"getClasses",
"(",
"params",
")",
";",
"final",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"getConstructor",
"(",
"clazz",
",",
"paramTypes",
")",
";",
"if",
"(",
"null",
"==",
"constructor",
")",
"{",
"throw",
"new",
"UtilException",
"(",
"\"No Constructor matched for parameter types: [{}]\"",
",",
"new",
"Object",
"[",
"]",
"{",
"paramTypes",
"}",
")",
";",
"}",
"try",
"{",
"return",
"constructor",
".",
"newInstance",
"(",
"params",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"UtilException",
"(",
"e",
",",
"\"Instance class [{}] error!\"",
",",
"clazz",
")",
";",
"}",
"}"
] | 实例化对象
@param <T> 对象类型
@param clazz 类
@param params 构造函数参数
@return 对象
@throws UtilException 包装各类异常 | [
"实例化对象"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ReflectUtil.java#L669-L689 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerAzureADAdministratorsInner.java | ServerAzureADAdministratorsInner.listByServerAsync | public Observable<List<ServerAzureADAdministratorInner>> listByServerAsync(String resourceGroupName, String serverName) {
"""
Returns a list of server Administrators.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ServerAzureADAdministratorInner> object
"""
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<ServerAzureADAdministratorInner>>, List<ServerAzureADAdministratorInner>>() {
@Override
public List<ServerAzureADAdministratorInner> call(ServiceResponse<List<ServerAzureADAdministratorInner>> response) {
return response.body();
}
});
} | java | public Observable<List<ServerAzureADAdministratorInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<ServerAzureADAdministratorInner>>, List<ServerAzureADAdministratorInner>>() {
@Override
public List<ServerAzureADAdministratorInner> call(ServiceResponse<List<ServerAzureADAdministratorInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"ServerAzureADAdministratorInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"ServerAzureADAdministratorInner",
">",
">",
",",
"List",
"<",
"ServerAzureADAdministratorInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"ServerAzureADAdministratorInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"ServerAzureADAdministratorInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Returns a list of server Administrators.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<ServerAzureADAdministratorInner> object | [
"Returns",
"a",
"list",
"of",
"server",
"Administrators",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerAzureADAdministratorsInner.java#L542-L549 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java | ObjectArrayList.beforeInsertDummies | protected void beforeInsertDummies(int index, int length) {
"""
Inserts length dummies before the specified position into the receiver.
Shifts the element currently at that position (if any) and
any subsequent elements to the right.
@param index index before which to insert dummies (must be in [0,size])..
@param length number of dummies to be inserted.
"""
if (index > size || index < 0)
throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size);
if (length > 0) {
ensureCapacity(size + length);
System.arraycopy(elements, index, elements, index + length, size-index);
size += length;
}
} | java | protected void beforeInsertDummies(int index, int length) {
if (index > size || index < 0)
throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size);
if (length > 0) {
ensureCapacity(size + length);
System.arraycopy(elements, index, elements, index + length, size-index);
size += length;
}
} | [
"protected",
"void",
"beforeInsertDummies",
"(",
"int",
"index",
",",
"int",
"length",
")",
"{",
"if",
"(",
"index",
">",
"size",
"||",
"index",
"<",
"0",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Index: \"",
"+",
"index",
"+",
"\", Size: \"",
"+",
"size",
")",
";",
"if",
"(",
"length",
">",
"0",
")",
"{",
"ensureCapacity",
"(",
"size",
"+",
"length",
")",
";",
"System",
".",
"arraycopy",
"(",
"elements",
",",
"index",
",",
"elements",
",",
"index",
"+",
"length",
",",
"size",
"-",
"index",
")",
";",
"size",
"+=",
"length",
";",
"}",
"}"
] | Inserts length dummies before the specified position into the receiver.
Shifts the element currently at that position (if any) and
any subsequent elements to the right.
@param index index before which to insert dummies (must be in [0,size])..
@param length number of dummies to be inserted. | [
"Inserts",
"length",
"dummies",
"before",
"the",
"specified",
"position",
"into",
"the",
"receiver",
".",
"Shifts",
"the",
"element",
"currently",
"at",
"that",
"position",
"(",
"if",
"any",
")",
"and",
"any",
"subsequent",
"elements",
"to",
"the",
"right",
"."
] | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/list/ObjectArrayList.java#L119-L127 |
Jasig/uPortal | uPortal-portlets/src/main/java/org/apereo/portal/portlets/backgroundpreference/ViewBackgroundPreferenceController.java | ViewBackgroundPreferenceController.getView | @RenderMapping
public String getView(RenderRequest req, Model model) {
"""
Display the main user-facing view of the portlet.
@param request
@return
"""
final String[] images = imageSetSelectionStrategy.getImageSet(req);
model.addAttribute("images", images);
final String[] thumbnailImages = imageSetSelectionStrategy.getImageThumbnailSet(req);
model.addAttribute("thumbnailImages", thumbnailImages);
final String[] imageCaptions = imageSetSelectionStrategy.getImageCaptions(req);
model.addAttribute("imageCaptions", imageCaptions);
final String preferredBackgroundImage = imageSetSelectionStrategy.getSelectedImage(req);
model.addAttribute("backgroundImage", preferredBackgroundImage);
final String backgroundContainerSelector =
imageSetSelectionStrategy.getBackgroundContainerSelector(req);
model.addAttribute("backgroundContainerSelector", backgroundContainerSelector);
final PortletPreferences prefs = req.getPreferences();
model.addAttribute("applyOpacityTo", prefs.getValue("applyOpacityTo", null));
model.addAttribute("opacityCssValue", prefs.getValue("opacityCssValue", "1.0"));
return "/jsp/BackgroundPreference/viewBackgroundPreference";
} | java | @RenderMapping
public String getView(RenderRequest req, Model model) {
final String[] images = imageSetSelectionStrategy.getImageSet(req);
model.addAttribute("images", images);
final String[] thumbnailImages = imageSetSelectionStrategy.getImageThumbnailSet(req);
model.addAttribute("thumbnailImages", thumbnailImages);
final String[] imageCaptions = imageSetSelectionStrategy.getImageCaptions(req);
model.addAttribute("imageCaptions", imageCaptions);
final String preferredBackgroundImage = imageSetSelectionStrategy.getSelectedImage(req);
model.addAttribute("backgroundImage", preferredBackgroundImage);
final String backgroundContainerSelector =
imageSetSelectionStrategy.getBackgroundContainerSelector(req);
model.addAttribute("backgroundContainerSelector", backgroundContainerSelector);
final PortletPreferences prefs = req.getPreferences();
model.addAttribute("applyOpacityTo", prefs.getValue("applyOpacityTo", null));
model.addAttribute("opacityCssValue", prefs.getValue("opacityCssValue", "1.0"));
return "/jsp/BackgroundPreference/viewBackgroundPreference";
} | [
"@",
"RenderMapping",
"public",
"String",
"getView",
"(",
"RenderRequest",
"req",
",",
"Model",
"model",
")",
"{",
"final",
"String",
"[",
"]",
"images",
"=",
"imageSetSelectionStrategy",
".",
"getImageSet",
"(",
"req",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"images\"",
",",
"images",
")",
";",
"final",
"String",
"[",
"]",
"thumbnailImages",
"=",
"imageSetSelectionStrategy",
".",
"getImageThumbnailSet",
"(",
"req",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"thumbnailImages\"",
",",
"thumbnailImages",
")",
";",
"final",
"String",
"[",
"]",
"imageCaptions",
"=",
"imageSetSelectionStrategy",
".",
"getImageCaptions",
"(",
"req",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"imageCaptions\"",
",",
"imageCaptions",
")",
";",
"final",
"String",
"preferredBackgroundImage",
"=",
"imageSetSelectionStrategy",
".",
"getSelectedImage",
"(",
"req",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"backgroundImage\"",
",",
"preferredBackgroundImage",
")",
";",
"final",
"String",
"backgroundContainerSelector",
"=",
"imageSetSelectionStrategy",
".",
"getBackgroundContainerSelector",
"(",
"req",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"backgroundContainerSelector\"",
",",
"backgroundContainerSelector",
")",
";",
"final",
"PortletPreferences",
"prefs",
"=",
"req",
".",
"getPreferences",
"(",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"applyOpacityTo\"",
",",
"prefs",
".",
"getValue",
"(",
"\"applyOpacityTo\"",
",",
"null",
")",
")",
";",
"model",
".",
"addAttribute",
"(",
"\"opacityCssValue\"",
",",
"prefs",
".",
"getValue",
"(",
"\"opacityCssValue\"",
",",
"\"1.0\"",
")",
")",
";",
"return",
"\"/jsp/BackgroundPreference/viewBackgroundPreference\"",
";",
"}"
] | Display the main user-facing view of the portlet.
@param request
@return | [
"Display",
"the",
"main",
"user",
"-",
"facing",
"view",
"of",
"the",
"portlet",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-portlets/src/main/java/org/apereo/portal/portlets/backgroundpreference/ViewBackgroundPreferenceController.java#L42-L66 |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.waterfall | @SafeVarargs
public final void waterfall(final C context, final Outcome<C> outcome, final Function<C>... functions) {
"""
Runs an array of functions in series, working on a shared context.
However, if any of the functions pass an error to the callback,
the next function is not executed and the outcome is immediately called with the error.
"""
_series(context, outcome, functions);
} | java | @SafeVarargs
public final void waterfall(final C context, final Outcome<C> outcome, final Function<C>... functions) {
_series(context, outcome, functions);
} | [
"@",
"SafeVarargs",
"public",
"final",
"void",
"waterfall",
"(",
"final",
"C",
"context",
",",
"final",
"Outcome",
"<",
"C",
">",
"outcome",
",",
"final",
"Function",
"<",
"C",
">",
"...",
"functions",
")",
"{",
"_series",
"(",
"context",
",",
"outcome",
",",
"functions",
")",
";",
"}"
] | Runs an array of functions in series, working on a shared context.
However, if any of the functions pass an error to the callback,
the next function is not executed and the outcome is immediately called with the error. | [
"Runs",
"an",
"array",
"of",
"functions",
"in",
"series",
"working",
"on",
"a",
"shared",
"context",
".",
"However",
"if",
"any",
"of",
"the",
"functions",
"pass",
"an",
"error",
"to",
"the",
"callback",
"the",
"next",
"function",
"is",
"not",
"executed",
"and",
"the",
"outcome",
"is",
"immediately",
"called",
"with",
"the",
"error",
"."
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L67-L70 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jbatch.misc_fat/util/src/fat/util/JobWaiter.java | JobWaiter.completeNewJob | public JobExecution completeNewJob(String jobXMLName, Properties jobParameters) throws IllegalStateException {
"""
Wait for {@code JobWaiter#timeout} seconds for BOTH of:
1) BatchStatus to be one of: STOPPED ,FAILED , COMPLETED, ABANDONED
AND
2) exitStatus to be non-null
Returns JobExecution if it ends in <b>COMPLETED</b> status, otherwise throws
<b>IllegalStateException</b>
@param jobXMLName
@param jobParameters
@return JobExecution (for successfully completing job)
@throws IllegalStateException
"""
long executionId = jobOp.start(jobXMLName, jobParameters);
JobExecution jobExec = waitForFinish(executionId);
if (jobExec.getBatchStatus().equals(BatchStatus.COMPLETED)) {
logger.finer("Job " + executionId + " successfully completed.");
return jobExec;
} else {
throw new IllegalStateException("Job " + executionId + " finished with non-completed state: " + jobExec.getBatchStatus());
}
} | java | public JobExecution completeNewJob(String jobXMLName, Properties jobParameters) throws IllegalStateException {
long executionId = jobOp.start(jobXMLName, jobParameters);
JobExecution jobExec = waitForFinish(executionId);
if (jobExec.getBatchStatus().equals(BatchStatus.COMPLETED)) {
logger.finer("Job " + executionId + " successfully completed.");
return jobExec;
} else {
throw new IllegalStateException("Job " + executionId + " finished with non-completed state: " + jobExec.getBatchStatus());
}
} | [
"public",
"JobExecution",
"completeNewJob",
"(",
"String",
"jobXMLName",
",",
"Properties",
"jobParameters",
")",
"throws",
"IllegalStateException",
"{",
"long",
"executionId",
"=",
"jobOp",
".",
"start",
"(",
"jobXMLName",
",",
"jobParameters",
")",
";",
"JobExecution",
"jobExec",
"=",
"waitForFinish",
"(",
"executionId",
")",
";",
"if",
"(",
"jobExec",
".",
"getBatchStatus",
"(",
")",
".",
"equals",
"(",
"BatchStatus",
".",
"COMPLETED",
")",
")",
"{",
"logger",
".",
"finer",
"(",
"\"Job \"",
"+",
"executionId",
"+",
"\" successfully completed.\"",
")",
";",
"return",
"jobExec",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Job \"",
"+",
"executionId",
"+",
"\" finished with non-completed state: \"",
"+",
"jobExec",
".",
"getBatchStatus",
"(",
")",
")",
";",
"}",
"}"
] | Wait for {@code JobWaiter#timeout} seconds for BOTH of:
1) BatchStatus to be one of: STOPPED ,FAILED , COMPLETED, ABANDONED
AND
2) exitStatus to be non-null
Returns JobExecution if it ends in <b>COMPLETED</b> status, otherwise throws
<b>IllegalStateException</b>
@param jobXMLName
@param jobParameters
@return JobExecution (for successfully completing job)
@throws IllegalStateException | [
"Wait",
"for",
"{",
"@code",
"JobWaiter#timeout",
"}",
"seconds",
"for",
"BOTH",
"of",
":"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jbatch.misc_fat/util/src/fat/util/JobWaiter.java#L103-L112 |
dnsjava/dnsjava | org/xbill/DNS/SIG0.java | SIG0.verifyMessage | public static void
verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous)
throws DNSSEC.DNSSECException {
"""
Verify a message using SIG(0).
@param message The message to be signed
@param b An array containing the message in unparsed form. This is
necessary since SIG(0) signs the message in wire format, and we can't
recreate the exact wire format (with the same name compression).
@param key The KEY record to verify the signature with.
@param previous If this message is a response, the SIG(0) from the query
"""
SIGRecord sig = null;
Record [] additional = message.getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++) {
if (additional[i].getType() != Type.SIG)
continue;
if (((SIGRecord) additional[i]).getTypeCovered() != 0)
continue;
sig = (SIGRecord) additional[i];
break;
}
DNSSEC.verifyMessage(message, b, sig, previous, key);
} | java | public static void
verifyMessage(Message message, byte [] b, KEYRecord key, SIGRecord previous)
throws DNSSEC.DNSSECException
{
SIGRecord sig = null;
Record [] additional = message.getSectionArray(Section.ADDITIONAL);
for (int i = 0; i < additional.length; i++) {
if (additional[i].getType() != Type.SIG)
continue;
if (((SIGRecord) additional[i]).getTypeCovered() != 0)
continue;
sig = (SIGRecord) additional[i];
break;
}
DNSSEC.verifyMessage(message, b, sig, previous, key);
} | [
"public",
"static",
"void",
"verifyMessage",
"(",
"Message",
"message",
",",
"byte",
"[",
"]",
"b",
",",
"KEYRecord",
"key",
",",
"SIGRecord",
"previous",
")",
"throws",
"DNSSEC",
".",
"DNSSECException",
"{",
"SIGRecord",
"sig",
"=",
"null",
";",
"Record",
"[",
"]",
"additional",
"=",
"message",
".",
"getSectionArray",
"(",
"Section",
".",
"ADDITIONAL",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"additional",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"additional",
"[",
"i",
"]",
".",
"getType",
"(",
")",
"!=",
"Type",
".",
"SIG",
")",
"continue",
";",
"if",
"(",
"(",
"(",
"SIGRecord",
")",
"additional",
"[",
"i",
"]",
")",
".",
"getTypeCovered",
"(",
")",
"!=",
"0",
")",
"continue",
";",
"sig",
"=",
"(",
"SIGRecord",
")",
"additional",
"[",
"i",
"]",
";",
"break",
";",
"}",
"DNSSEC",
".",
"verifyMessage",
"(",
"message",
",",
"b",
",",
"sig",
",",
"previous",
",",
"key",
")",
";",
"}"
] | Verify a message using SIG(0).
@param message The message to be signed
@param b An array containing the message in unparsed form. This is
necessary since SIG(0) signs the message in wire format, and we can't
recreate the exact wire format (with the same name compression).
@param key The KEY record to verify the signature with.
@param previous If this message is a response, the SIG(0) from the query | [
"Verify",
"a",
"message",
"using",
"SIG",
"(",
"0",
")",
"."
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/SIG0.java#L62-L77 |
apache/groovy | subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java | NioGroovyMethods.withDataInputStream | public static <T> T withDataInputStream(Path self, @ClosureParams(value = SimpleType.class, options = "java.io.DataInputStream") Closure<T> closure) throws IOException {
"""
Create a new DataInputStream for this file and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param self a Path
@param closure a closure
@return the value returned by the closure
@throws java.io.IOException if an IOException occurs.
@see org.codehaus.groovy.runtime.IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure)
@since 2.3.0
"""
return IOGroovyMethods.withStream(newDataInputStream(self), closure);
} | java | public static <T> T withDataInputStream(Path self, @ClosureParams(value = SimpleType.class, options = "java.io.DataInputStream") Closure<T> closure) throws IOException {
return IOGroovyMethods.withStream(newDataInputStream(self), closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"withDataInputStream",
"(",
"Path",
"self",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.io.DataInputStream\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"IOGroovyMethods",
".",
"withStream",
"(",
"newDataInputStream",
"(",
"self",
")",
",",
"closure",
")",
";",
"}"
] | Create a new DataInputStream for this file and passes it into the closure.
This method ensures the stream is closed after the closure returns.
@param self a Path
@param closure a closure
@return the value returned by the closure
@throws java.io.IOException if an IOException occurs.
@see org.codehaus.groovy.runtime.IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure)
@since 2.3.0 | [
"Create",
"a",
"new",
"DataInputStream",
"for",
"this",
"file",
"and",
"passes",
"it",
"into",
"the",
"closure",
".",
"This",
"method",
"ensures",
"the",
"stream",
"is",
"closed",
"after",
"the",
"closure",
"returns",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java#L1530-L1532 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java | LineageInfo.putDestination | public void putDestination(List<Descriptor> descriptors, int branchId, State state) {
"""
Put data {@link Descriptor}s of a destination dataset to a state
@param descriptors It can be a single item list which just has the dataset descriptor or a list
of dataset partition descriptors
"""
if (!hasLineageInfo(state)) {
log.warn("State has no lineage info but branch " + branchId + " puts {} descriptors", descriptors.size());
return;
}
log.info(String.format("Put destination %s for branch %d", Descriptor.toJson(descriptors), branchId));
synchronized (state.getProp(getKey(NAME_KEY))) {
List<Descriptor> resolvedDescriptors = new ArrayList<>();
for (Descriptor descriptor : descriptors) {
Descriptor resolvedDescriptor = resolver.resolve(descriptor, state);
if (resolvedDescriptor == null) {
continue;
}
resolvedDescriptors.add(resolvedDescriptor);
}
String destinationKey = getKey(BRANCH, branchId, LineageEventBuilder.DESTINATION);
String currentDestinations = state.getProp(destinationKey);
List<Descriptor> allDescriptors = Lists.newArrayList();
if (StringUtils.isNotEmpty(currentDestinations)) {
allDescriptors = Descriptor.fromJsonList(currentDestinations);
}
allDescriptors.addAll(resolvedDescriptors);
state.setProp(destinationKey, Descriptor.toJson(allDescriptors));
}
} | java | public void putDestination(List<Descriptor> descriptors, int branchId, State state) {
if (!hasLineageInfo(state)) {
log.warn("State has no lineage info but branch " + branchId + " puts {} descriptors", descriptors.size());
return;
}
log.info(String.format("Put destination %s for branch %d", Descriptor.toJson(descriptors), branchId));
synchronized (state.getProp(getKey(NAME_KEY))) {
List<Descriptor> resolvedDescriptors = new ArrayList<>();
for (Descriptor descriptor : descriptors) {
Descriptor resolvedDescriptor = resolver.resolve(descriptor, state);
if (resolvedDescriptor == null) {
continue;
}
resolvedDescriptors.add(resolvedDescriptor);
}
String destinationKey = getKey(BRANCH, branchId, LineageEventBuilder.DESTINATION);
String currentDestinations = state.getProp(destinationKey);
List<Descriptor> allDescriptors = Lists.newArrayList();
if (StringUtils.isNotEmpty(currentDestinations)) {
allDescriptors = Descriptor.fromJsonList(currentDestinations);
}
allDescriptors.addAll(resolvedDescriptors);
state.setProp(destinationKey, Descriptor.toJson(allDescriptors));
}
} | [
"public",
"void",
"putDestination",
"(",
"List",
"<",
"Descriptor",
">",
"descriptors",
",",
"int",
"branchId",
",",
"State",
"state",
")",
"{",
"if",
"(",
"!",
"hasLineageInfo",
"(",
"state",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"State has no lineage info but branch \"",
"+",
"branchId",
"+",
"\" puts {} descriptors\"",
",",
"descriptors",
".",
"size",
"(",
")",
")",
";",
"return",
";",
"}",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Put destination %s for branch %d\"",
",",
"Descriptor",
".",
"toJson",
"(",
"descriptors",
")",
",",
"branchId",
")",
")",
";",
"synchronized",
"(",
"state",
".",
"getProp",
"(",
"getKey",
"(",
"NAME_KEY",
")",
")",
")",
"{",
"List",
"<",
"Descriptor",
">",
"resolvedDescriptors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Descriptor",
"descriptor",
":",
"descriptors",
")",
"{",
"Descriptor",
"resolvedDescriptor",
"=",
"resolver",
".",
"resolve",
"(",
"descriptor",
",",
"state",
")",
";",
"if",
"(",
"resolvedDescriptor",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"resolvedDescriptors",
".",
"add",
"(",
"resolvedDescriptor",
")",
";",
"}",
"String",
"destinationKey",
"=",
"getKey",
"(",
"BRANCH",
",",
"branchId",
",",
"LineageEventBuilder",
".",
"DESTINATION",
")",
";",
"String",
"currentDestinations",
"=",
"state",
".",
"getProp",
"(",
"destinationKey",
")",
";",
"List",
"<",
"Descriptor",
">",
"allDescriptors",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentDestinations",
")",
")",
"{",
"allDescriptors",
"=",
"Descriptor",
".",
"fromJsonList",
"(",
"currentDestinations",
")",
";",
"}",
"allDescriptors",
".",
"addAll",
"(",
"resolvedDescriptors",
")",
";",
"state",
".",
"setProp",
"(",
"destinationKey",
",",
"Descriptor",
".",
"toJson",
"(",
"allDescriptors",
")",
")",
";",
"}",
"}"
] | Put data {@link Descriptor}s of a destination dataset to a state
@param descriptors It can be a single item list which just has the dataset descriptor or a list
of dataset partition descriptors | [
"Put",
"data",
"{",
"@link",
"Descriptor",
"}",
"s",
"of",
"a",
"destination",
"dataset",
"to",
"a",
"state"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/lineage/LineageInfo.java#L144-L173 |
geomajas/geomajas-project-server | impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java | ThreadScopeContext.setBean | public void setBean(String name, Object object) {
"""
Set a bean in the context.
@param name bean name
@param object bean value
"""
Bean bean = beans.get(name);
if (null == bean) {
bean = new Bean();
beans.put(name, bean);
}
bean.object = object;
} | java | public void setBean(String name, Object object) {
Bean bean = beans.get(name);
if (null == bean) {
bean = new Bean();
beans.put(name, bean);
}
bean.object = object;
} | [
"public",
"void",
"setBean",
"(",
"String",
"name",
",",
"Object",
"object",
")",
"{",
"Bean",
"bean",
"=",
"beans",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"null",
"==",
"bean",
")",
"{",
"bean",
"=",
"new",
"Bean",
"(",
")",
";",
"beans",
".",
"put",
"(",
"name",
",",
"bean",
")",
";",
"}",
"bean",
".",
"object",
"=",
"object",
";",
"}"
] | Set a bean in the context.
@param name bean name
@param object bean value | [
"Set",
"a",
"bean",
"in",
"the",
"context",
"."
] | train | https://github.com/geomajas/geomajas-project-server/blob/904b7d7deed1350d28955589098dd1e0a786d76e/impl/src/main/java/org/geomajas/spring/ThreadScopeContext.java#L47-L54 |
Azure/azure-sdk-for-java | compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java | VirtualMachinesInner.beginCaptureAsync | public Observable<VirtualMachineCaptureResultInner> beginCaptureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParameters parameters) {
"""
Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@param parameters Parameters supplied to the Capture Virtual Machine operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualMachineCaptureResultInner object
"""
return beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualMachineCaptureResultInner> beginCaptureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParameters parameters) {
return beginCaptureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualMachineCaptureResultInner",
">",
"beginCaptureAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
",",
"VirtualMachineCaptureParameters",
"parameters",
")",
"{",
"return",
"beginCaptureWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualMachineCaptureResultInner",
">",
",",
"VirtualMachineCaptureResultInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualMachineCaptureResultInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualMachineCaptureResultInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@param parameters Parameters supplied to the Capture Virtual Machine operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualMachineCaptureResultInner object | [
"Captures",
"the",
"VM",
"by",
"copying",
"virtual",
"hard",
"disks",
"of",
"the",
"VM",
"and",
"outputs",
"a",
"template",
"that",
"can",
"be",
"used",
"to",
"create",
"similar",
"VMs",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java#L482-L489 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/util/NetworkUtil.java | NetworkUtil.findLocalAddressListeningOnPort | private static InetAddress findLocalAddressListeningOnPort(String pHost, int pPort) throws UnknownHostException, SocketException {
"""
Check for an non-loopback, local adress listening on the given port
"""
InetAddress address = InetAddress.getByName(pHost);
if (address.isLoopbackAddress()) {
// First check local address
InetAddress localAddress = getLocalAddress();
if (!localAddress.isLoopbackAddress() && isPortOpen(localAddress, pPort)) {
return localAddress;
}
// Then try all addresses attache to all interfaces
localAddress = getLocalAddressFromNetworkInterfacesListeningOnPort(pPort);
if (localAddress != null) {
return localAddress;
}
}
return address;
} | java | private static InetAddress findLocalAddressListeningOnPort(String pHost, int pPort) throws UnknownHostException, SocketException {
InetAddress address = InetAddress.getByName(pHost);
if (address.isLoopbackAddress()) {
// First check local address
InetAddress localAddress = getLocalAddress();
if (!localAddress.isLoopbackAddress() && isPortOpen(localAddress, pPort)) {
return localAddress;
}
// Then try all addresses attache to all interfaces
localAddress = getLocalAddressFromNetworkInterfacesListeningOnPort(pPort);
if (localAddress != null) {
return localAddress;
}
}
return address;
} | [
"private",
"static",
"InetAddress",
"findLocalAddressListeningOnPort",
"(",
"String",
"pHost",
",",
"int",
"pPort",
")",
"throws",
"UnknownHostException",
",",
"SocketException",
"{",
"InetAddress",
"address",
"=",
"InetAddress",
".",
"getByName",
"(",
"pHost",
")",
";",
"if",
"(",
"address",
".",
"isLoopbackAddress",
"(",
")",
")",
"{",
"// First check local address",
"InetAddress",
"localAddress",
"=",
"getLocalAddress",
"(",
")",
";",
"if",
"(",
"!",
"localAddress",
".",
"isLoopbackAddress",
"(",
")",
"&&",
"isPortOpen",
"(",
"localAddress",
",",
"pPort",
")",
")",
"{",
"return",
"localAddress",
";",
"}",
"// Then try all addresses attache to all interfaces",
"localAddress",
"=",
"getLocalAddressFromNetworkInterfacesListeningOnPort",
"(",
"pPort",
")",
";",
"if",
"(",
"localAddress",
"!=",
"null",
")",
"{",
"return",
"localAddress",
";",
"}",
"}",
"return",
"address",
";",
"}"
] | Check for an non-loopback, local adress listening on the given port | [
"Check",
"for",
"an",
"non",
"-",
"loopback",
"local",
"adress",
"listening",
"on",
"the",
"given",
"port"
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/util/NetworkUtil.java#L236-L252 |
morimekta/providence | providence-generator-java/src/main/java/net/morimekta/providence/generator/format/java/program/extras/HazelcastPortableProgramFormatter.java | HazelcastPortableProgramFormatter.appendCollectionTypeField | private void appendCollectionTypeField(JField field, PDescriptor descriptor) {
"""
Append a specific list type field to the definition.
@param field JField to append.
<pre>
{@code
.addShortArrayField("shortValues")
}
</pre>
"""
switch (descriptor.getType()) {
case BYTE:
case BINARY:
writer.formatln(".addByteArrayField(\"%s\")", field.name());
break;
case BOOL:
writer.formatln(".addBooleanArrayField(\"%s\")", field.name());
break;
case DOUBLE:
writer.formatln(".addDoubleArrayField(\"%s\")", field.name());
break;
case I16:
writer.formatln(".addShortArrayField(\"%s\")", field.name());
break;
case I32:
case ENUM:
writer.formatln(".addIntArrayField(\"%s\")", field.name());
break;
case I64:
writer.formatln(".addLongArrayField(\"%s\")", field.name());
break;
case STRING:
writer.formatln(".addUTFArrayField(\"%s\")", field.name());
break;
case MESSAGE:
writer.formatln(".addPortableArrayField(\"%s\", %s(%s))",
field.name(),
camelCase("get", descriptor.getName() + "Definition"),
PORTABLE_VERSION);
break;
default:
throw new GeneratorException(
"Not implemented appendCollectionTypeField for list with type: " + descriptor.getType() + " in " +
this.getClass()
.getSimpleName());
}
} | java | private void appendCollectionTypeField(JField field, PDescriptor descriptor) {
switch (descriptor.getType()) {
case BYTE:
case BINARY:
writer.formatln(".addByteArrayField(\"%s\")", field.name());
break;
case BOOL:
writer.formatln(".addBooleanArrayField(\"%s\")", field.name());
break;
case DOUBLE:
writer.formatln(".addDoubleArrayField(\"%s\")", field.name());
break;
case I16:
writer.formatln(".addShortArrayField(\"%s\")", field.name());
break;
case I32:
case ENUM:
writer.formatln(".addIntArrayField(\"%s\")", field.name());
break;
case I64:
writer.formatln(".addLongArrayField(\"%s\")", field.name());
break;
case STRING:
writer.formatln(".addUTFArrayField(\"%s\")", field.name());
break;
case MESSAGE:
writer.formatln(".addPortableArrayField(\"%s\", %s(%s))",
field.name(),
camelCase("get", descriptor.getName() + "Definition"),
PORTABLE_VERSION);
break;
default:
throw new GeneratorException(
"Not implemented appendCollectionTypeField for list with type: " + descriptor.getType() + " in " +
this.getClass()
.getSimpleName());
}
} | [
"private",
"void",
"appendCollectionTypeField",
"(",
"JField",
"field",
",",
"PDescriptor",
"descriptor",
")",
"{",
"switch",
"(",
"descriptor",
".",
"getType",
"(",
")",
")",
"{",
"case",
"BYTE",
":",
"case",
"BINARY",
":",
"writer",
".",
"formatln",
"(",
"\".addByteArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"BOOL",
":",
"writer",
".",
"formatln",
"(",
"\".addBooleanArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"DOUBLE",
":",
"writer",
".",
"formatln",
"(",
"\".addDoubleArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"I16",
":",
"writer",
".",
"formatln",
"(",
"\".addShortArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"I32",
":",
"case",
"ENUM",
":",
"writer",
".",
"formatln",
"(",
"\".addIntArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"I64",
":",
"writer",
".",
"formatln",
"(",
"\".addLongArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"STRING",
":",
"writer",
".",
"formatln",
"(",
"\".addUTFArrayField(\\\"%s\\\")\"",
",",
"field",
".",
"name",
"(",
")",
")",
";",
"break",
";",
"case",
"MESSAGE",
":",
"writer",
".",
"formatln",
"(",
"\".addPortableArrayField(\\\"%s\\\", %s(%s))\"",
",",
"field",
".",
"name",
"(",
")",
",",
"camelCase",
"(",
"\"get\"",
",",
"descriptor",
".",
"getName",
"(",
")",
"+",
"\"Definition\"",
")",
",",
"PORTABLE_VERSION",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"GeneratorException",
"(",
"\"Not implemented appendCollectionTypeField for list with type: \"",
"+",
"descriptor",
".",
"getType",
"(",
")",
"+",
"\" in \"",
"+",
"this",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}"
] | Append a specific list type field to the definition.
@param field JField to append.
<pre>
{@code
.addShortArrayField("shortValues")
}
</pre> | [
"Append",
"a",
"specific",
"list",
"type",
"field",
"to",
"the",
"definition",
"."
] | train | https://github.com/morimekta/providence/blob/7c17dc1c96b1a1d4b9ff942c2cfeb725278bd3aa/providence-generator-java/src/main/java/net/morimekta/providence/generator/format/java/program/extras/HazelcastPortableProgramFormatter.java#L333-L370 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.appendImmediate | public void appendImmediate(Object object, String indentation) {
"""
Add the string representation of the given object to this sequence immediately. That is, all the trailing
whitespace of this sequence will be ignored and the string is appended directly after the last segment that
contains something besides whitespace. The given indentation will be prepended to each line except the first one
if the object has a multi-line string representation.
@param object
the to-be-appended object.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>.
"""
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
append(object, indentation, i + 1);
return;
}
}
}
append(object, indentation, 0);
} | java | public void appendImmediate(Object object, String indentation) {
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
append(object, indentation, i + 1);
return;
}
}
}
append(object, indentation, 0);
} | [
"public",
"void",
"appendImmediate",
"(",
"Object",
"object",
",",
"String",
"indentation",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"segments",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"String",
"segment",
"=",
"segments",
".",
"get",
"(",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"segment",
".",
"length",
"(",
")",
";",
"j",
"++",
")",
"{",
"if",
"(",
"!",
"WhitespaceMatcher",
".",
"isWhitespace",
"(",
"segment",
".",
"charAt",
"(",
"j",
")",
")",
")",
"{",
"append",
"(",
"object",
",",
"indentation",
",",
"i",
"+",
"1",
")",
";",
"return",
";",
"}",
"}",
"}",
"append",
"(",
"object",
",",
"indentation",
",",
"0",
")",
";",
"}"
] | Add the string representation of the given object to this sequence immediately. That is, all the trailing
whitespace of this sequence will be ignored and the string is appended directly after the last segment that
contains something besides whitespace. The given indentation will be prepended to each line except the first one
if the object has a multi-line string representation.
@param object
the to-be-appended object.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>. | [
"Add",
"the",
"string",
"representation",
"of",
"the",
"given",
"object",
"to",
"this",
"sequence",
"immediately",
".",
"That",
"is",
"all",
"the",
"trailing",
"whitespace",
"of",
"this",
"sequence",
"will",
"be",
"ignored",
"and",
"the",
"string",
"is",
"appended",
"directly",
"after",
"the",
"last",
"segment",
"that",
"contains",
"something",
"besides",
"whitespace",
".",
"The",
"given",
"indentation",
"will",
"be",
"prepended",
"to",
"each",
"line",
"except",
"the",
"first",
"one",
"if",
"the",
"object",
"has",
"a",
"multi",
"-",
"line",
"string",
"representation",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L350-L361 |
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.deleteImagesAsync | public Observable<Void> deleteImagesAsync(UUID projectId, List<String> imageIds) {
"""
Delete images from the set of training images.
@param projectId The project id
@param imageIds Ids of the images to be deleted. Limted to 256 images per batch
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return deleteImagesWithServiceResponseAsync(projectId, imageIds).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> deleteImagesAsync(UUID projectId, List<String> imageIds) {
return deleteImagesWithServiceResponseAsync(projectId, imageIds).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"deleteImagesAsync",
"(",
"UUID",
"projectId",
",",
"List",
"<",
"String",
">",
"imageIds",
")",
"{",
"return",
"deleteImagesWithServiceResponseAsync",
"(",
"projectId",
",",
"imageIds",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Delete images from the set of training images.
@param projectId The project id
@param imageIds Ids of the images to be deleted. Limted to 256 images per batch
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Delete",
"images",
"from",
"the",
"set",
"of",
"training",
"images",
"."
] | 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#L4039-L4046 |
joniles/mpxj | src/main/java/net/sf/mpxj/ProjectCalendar.java | ProjectCalendar.getTotalTime | private long getTotalTime(ProjectCalendarDateRanges hours, Date startDate, Date endDate) {
"""
This method calculates the total amount of working time in a single
day, which intersects with the supplied time range.
@param hours collection of working hours in a day
@param startDate time range start
@param endDate time range end
@return length of time in milliseconds
"""
long total = 0;
if (startDate.getTime() != endDate.getTime())
{
Date start = DateHelper.getCanonicalTime(startDate);
Date end = DateHelper.getCanonicalTime(endDate);
for (DateRange range : hours)
{
Date rangeStart = range.getStart();
Date rangeEnd = range.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Date canoncialRangeStart = DateHelper.getCanonicalTime(rangeStart);
Date canonicalRangeEnd = DateHelper.getCanonicalTime(rangeEnd);
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeEnd);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
canonicalRangeEnd = DateHelper.addDays(canonicalRangeEnd, 1);
}
if (canoncialRangeStart.getTime() == canonicalRangeEnd.getTime() && rangeEnd.getTime() > rangeStart.getTime())
{
total += (24 * 60 * 60 * 1000);
}
else
{
total += getTime(start, end, canoncialRangeStart, canonicalRangeEnd);
}
}
}
}
return (total);
} | java | private long getTotalTime(ProjectCalendarDateRanges hours, Date startDate, Date endDate)
{
long total = 0;
if (startDate.getTime() != endDate.getTime())
{
Date start = DateHelper.getCanonicalTime(startDate);
Date end = DateHelper.getCanonicalTime(endDate);
for (DateRange range : hours)
{
Date rangeStart = range.getStart();
Date rangeEnd = range.getEnd();
if (rangeStart != null && rangeEnd != null)
{
Date canoncialRangeStart = DateHelper.getCanonicalTime(rangeStart);
Date canonicalRangeEnd = DateHelper.getCanonicalTime(rangeEnd);
Date startDay = DateHelper.getDayStartDate(rangeStart);
Date finishDay = DateHelper.getDayStartDate(rangeEnd);
//
// Handle the case where the end of the range is at midnight -
// this will show up as the start and end days not matching
//
if (startDay.getTime() != finishDay.getTime())
{
canonicalRangeEnd = DateHelper.addDays(canonicalRangeEnd, 1);
}
if (canoncialRangeStart.getTime() == canonicalRangeEnd.getTime() && rangeEnd.getTime() > rangeStart.getTime())
{
total += (24 * 60 * 60 * 1000);
}
else
{
total += getTime(start, end, canoncialRangeStart, canonicalRangeEnd);
}
}
}
}
return (total);
} | [
"private",
"long",
"getTotalTime",
"(",
"ProjectCalendarDateRanges",
"hours",
",",
"Date",
"startDate",
",",
"Date",
"endDate",
")",
"{",
"long",
"total",
"=",
"0",
";",
"if",
"(",
"startDate",
".",
"getTime",
"(",
")",
"!=",
"endDate",
".",
"getTime",
"(",
")",
")",
"{",
"Date",
"start",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"startDate",
")",
";",
"Date",
"end",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"endDate",
")",
";",
"for",
"(",
"DateRange",
"range",
":",
"hours",
")",
"{",
"Date",
"rangeStart",
"=",
"range",
".",
"getStart",
"(",
")",
";",
"Date",
"rangeEnd",
"=",
"range",
".",
"getEnd",
"(",
")",
";",
"if",
"(",
"rangeStart",
"!=",
"null",
"&&",
"rangeEnd",
"!=",
"null",
")",
"{",
"Date",
"canoncialRangeStart",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"rangeStart",
")",
";",
"Date",
"canonicalRangeEnd",
"=",
"DateHelper",
".",
"getCanonicalTime",
"(",
"rangeEnd",
")",
";",
"Date",
"startDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeStart",
")",
";",
"Date",
"finishDay",
"=",
"DateHelper",
".",
"getDayStartDate",
"(",
"rangeEnd",
")",
";",
"//",
"// Handle the case where the end of the range is at midnight -",
"// this will show up as the start and end days not matching",
"//",
"if",
"(",
"startDay",
".",
"getTime",
"(",
")",
"!=",
"finishDay",
".",
"getTime",
"(",
")",
")",
"{",
"canonicalRangeEnd",
"=",
"DateHelper",
".",
"addDays",
"(",
"canonicalRangeEnd",
",",
"1",
")",
";",
"}",
"if",
"(",
"canoncialRangeStart",
".",
"getTime",
"(",
")",
"==",
"canonicalRangeEnd",
".",
"getTime",
"(",
")",
"&&",
"rangeEnd",
".",
"getTime",
"(",
")",
">",
"rangeStart",
".",
"getTime",
"(",
")",
")",
"{",
"total",
"+=",
"(",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
";",
"}",
"else",
"{",
"total",
"+=",
"getTime",
"(",
"start",
",",
"end",
",",
"canoncialRangeStart",
",",
"canonicalRangeEnd",
")",
";",
"}",
"}",
"}",
"}",
"return",
"(",
"total",
")",
";",
"}"
] | This method calculates the total amount of working time in a single
day, which intersects with the supplied time range.
@param hours collection of working hours in a day
@param startDate time range start
@param endDate time range end
@return length of time in milliseconds | [
"This",
"method",
"calculates",
"the",
"total",
"amount",
"of",
"working",
"time",
"in",
"a",
"single",
"day",
"which",
"intersects",
"with",
"the",
"supplied",
"time",
"range",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L1460-L1502 |
looly/hutool | hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelUtil.java | ExcelUtil.readBySax | public static void readBySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
"""
通过Sax方式读取Excel,同时支持03和07格式
@param in Excel流
@param sheetIndex sheet序号
@param rowHandler 行处理器
@since 3.2.0
"""
in = IoUtil.toMarkSupportStream(in);
if (ExcelFileUtil.isXlsx(in)) {
read07BySax(in, sheetIndex, rowHandler);
} else {
read03BySax(in, sheetIndex, rowHandler);
}
} | java | public static void readBySax(InputStream in, int sheetIndex, RowHandler rowHandler) {
in = IoUtil.toMarkSupportStream(in);
if (ExcelFileUtil.isXlsx(in)) {
read07BySax(in, sheetIndex, rowHandler);
} else {
read03BySax(in, sheetIndex, rowHandler);
}
} | [
"public",
"static",
"void",
"readBySax",
"(",
"InputStream",
"in",
",",
"int",
"sheetIndex",
",",
"RowHandler",
"rowHandler",
")",
"{",
"in",
"=",
"IoUtil",
".",
"toMarkSupportStream",
"(",
"in",
")",
";",
"if",
"(",
"ExcelFileUtil",
".",
"isXlsx",
"(",
"in",
")",
")",
"{",
"read07BySax",
"(",
"in",
",",
"sheetIndex",
",",
"rowHandler",
")",
";",
"}",
"else",
"{",
"read03BySax",
"(",
"in",
",",
"sheetIndex",
",",
"rowHandler",
")",
";",
"}",
"}"
] | 通过Sax方式读取Excel,同时支持03和07格式
@param in Excel流
@param sheetIndex sheet序号
@param rowHandler 行处理器
@since 3.2.0 | [
"通过Sax方式读取Excel,同时支持03和07格式"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelUtil.java#L71-L78 |
akberc/ceylon-maven-plugin | src/main/java/com/dgwave/car/common/ModuleXmlReader.java | ModuleXmlReader.getChildElement | protected static Element getChildElement(final Element parent, final String tagName) {
"""
Get a single child element.
@param parent The parent element
@param tagName The child element name
@return Element The first child element by that name
"""
List<Element> elements = getElements(parent, tagName);
if (elements.size() > 0) {
return elements.get(0);
} else {
return null;
}
} | java | protected static Element getChildElement(final Element parent, final String tagName) {
List<Element> elements = getElements(parent, tagName);
if (elements.size() > 0) {
return elements.get(0);
} else {
return null;
}
} | [
"protected",
"static",
"Element",
"getChildElement",
"(",
"final",
"Element",
"parent",
",",
"final",
"String",
"tagName",
")",
"{",
"List",
"<",
"Element",
">",
"elements",
"=",
"getElements",
"(",
"parent",
",",
"tagName",
")",
";",
"if",
"(",
"elements",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"elements",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get a single child element.
@param parent The parent element
@param tagName The child element name
@return Element The first child element by that name | [
"Get",
"a",
"single",
"child",
"element",
"."
] | train | https://github.com/akberc/ceylon-maven-plugin/blob/b7f6c4a2b24f2fa237350c9e715f4193e83415ef/src/main/java/com/dgwave/car/common/ModuleXmlReader.java#L108-L115 |
DataSketches/sketches-core | src/main/java/com/yahoo/sketches/hllmap/CouponHashMap.java | CouponHashMap.findKey | @Override
int findKey(final byte[] key) {
"""
Returns entryIndex if the given key is found. If not found, returns one's complement index
of an empty slot for insertion, which may be over a deleted key.
@param key the given key
@return the entryIndex
"""
final long[] hash = MurmurHash3.hash(key, SEED);
int entryIndex = getIndex(hash[0], tableEntries_);
int firstDeletedIndex = -1;
final int loopIndex = entryIndex;
do {
if (curCountsArr_[entryIndex] == 0) {
return firstDeletedIndex == -1 ? ~entryIndex : ~firstDeletedIndex; // found empty or deleted
}
if (curCountsArr_[entryIndex] == DELETED_KEY_MARKER) {
if (firstDeletedIndex == -1) {
firstDeletedIndex = entryIndex;
}
} else if (Map.arraysEqual(keysArr_, entryIndex * keySizeBytes_, key, 0, keySizeBytes_)) {
return entryIndex; // found key
}
entryIndex = (entryIndex + getStride(hash[1], tableEntries_)) % tableEntries_;
} while (entryIndex != loopIndex);
throw new SketchesArgumentException("Key not found and no empty slots!");
} | java | @Override
int findKey(final byte[] key) {
final long[] hash = MurmurHash3.hash(key, SEED);
int entryIndex = getIndex(hash[0], tableEntries_);
int firstDeletedIndex = -1;
final int loopIndex = entryIndex;
do {
if (curCountsArr_[entryIndex] == 0) {
return firstDeletedIndex == -1 ? ~entryIndex : ~firstDeletedIndex; // found empty or deleted
}
if (curCountsArr_[entryIndex] == DELETED_KEY_MARKER) {
if (firstDeletedIndex == -1) {
firstDeletedIndex = entryIndex;
}
} else if (Map.arraysEqual(keysArr_, entryIndex * keySizeBytes_, key, 0, keySizeBytes_)) {
return entryIndex; // found key
}
entryIndex = (entryIndex + getStride(hash[1], tableEntries_)) % tableEntries_;
} while (entryIndex != loopIndex);
throw new SketchesArgumentException("Key not found and no empty slots!");
} | [
"@",
"Override",
"int",
"findKey",
"(",
"final",
"byte",
"[",
"]",
"key",
")",
"{",
"final",
"long",
"[",
"]",
"hash",
"=",
"MurmurHash3",
".",
"hash",
"(",
"key",
",",
"SEED",
")",
";",
"int",
"entryIndex",
"=",
"getIndex",
"(",
"hash",
"[",
"0",
"]",
",",
"tableEntries_",
")",
";",
"int",
"firstDeletedIndex",
"=",
"-",
"1",
";",
"final",
"int",
"loopIndex",
"=",
"entryIndex",
";",
"do",
"{",
"if",
"(",
"curCountsArr_",
"[",
"entryIndex",
"]",
"==",
"0",
")",
"{",
"return",
"firstDeletedIndex",
"==",
"-",
"1",
"?",
"~",
"entryIndex",
":",
"~",
"firstDeletedIndex",
";",
"// found empty or deleted",
"}",
"if",
"(",
"curCountsArr_",
"[",
"entryIndex",
"]",
"==",
"DELETED_KEY_MARKER",
")",
"{",
"if",
"(",
"firstDeletedIndex",
"==",
"-",
"1",
")",
"{",
"firstDeletedIndex",
"=",
"entryIndex",
";",
"}",
"}",
"else",
"if",
"(",
"Map",
".",
"arraysEqual",
"(",
"keysArr_",
",",
"entryIndex",
"*",
"keySizeBytes_",
",",
"key",
",",
"0",
",",
"keySizeBytes_",
")",
")",
"{",
"return",
"entryIndex",
";",
"// found key",
"}",
"entryIndex",
"=",
"(",
"entryIndex",
"+",
"getStride",
"(",
"hash",
"[",
"1",
"]",
",",
"tableEntries_",
")",
")",
"%",
"tableEntries_",
";",
"}",
"while",
"(",
"entryIndex",
"!=",
"loopIndex",
")",
";",
"throw",
"new",
"SketchesArgumentException",
"(",
"\"Key not found and no empty slots!\"",
")",
";",
"}"
] | Returns entryIndex if the given key is found. If not found, returns one's complement index
of an empty slot for insertion, which may be over a deleted key.
@param key the given key
@return the entryIndex | [
"Returns",
"entryIndex",
"if",
"the",
"given",
"key",
"is",
"found",
".",
"If",
"not",
"found",
"returns",
"one",
"s",
"complement",
"index",
"of",
"an",
"empty",
"slot",
"for",
"insertion",
"which",
"may",
"be",
"over",
"a",
"deleted",
"key",
"."
] | train | https://github.com/DataSketches/sketches-core/blob/900c8c9668a1e2f1d54d453e956caad54702e540/src/main/java/com/yahoo/sketches/hllmap/CouponHashMap.java#L139-L159 |
milaboratory/milib | src/main/java/com/milaboratory/core/io/util/IOUtil.java | IOUtil.writeRawVarint64 | public static void writeRawVarint64(OutputStream os, long value) throws IOException {
"""
Encode and write a varint.
<p>Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.</p>
"""
while (true) {
if ((value & ~0x7FL) == 0) {
os.write((int) value);
return;
} else {
os.write(((int) value & 0x7F) | 0x80);
value >>>= 7;
}
}
} | java | public static void writeRawVarint64(OutputStream os, long value) throws IOException {
while (true) {
if ((value & ~0x7FL) == 0) {
os.write((int) value);
return;
} else {
os.write(((int) value & 0x7F) | 0x80);
value >>>= 7;
}
}
} | [
"public",
"static",
"void",
"writeRawVarint64",
"(",
"OutputStream",
"os",
",",
"long",
"value",
")",
"throws",
"IOException",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"(",
"value",
"&",
"~",
"0x7F",
"L",
")",
"==",
"0",
")",
"{",
"os",
".",
"write",
"(",
"(",
"int",
")",
"value",
")",
";",
"return",
";",
"}",
"else",
"{",
"os",
".",
"write",
"(",
"(",
"(",
"int",
")",
"value",
"&",
"0x7F",
")",
"|",
"0x80",
")",
";",
"value",
">>>=",
"7",
";",
"}",
"}",
"}"
] | Encode and write a varint.
<p>Copied from com.google.protobuf.CodedOutputStream from Google's protobuf library.</p> | [
"Encode",
"and",
"write",
"a",
"varint",
"."
] | train | https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/io/util/IOUtil.java#L115-L125 |
jbossws/jbossws-common | src/main/java/org/jboss/ws/common/injection/InjectionHelper.java | InjectionHelper.injectWebServiceContext | public static void injectWebServiceContext(final Object instance, final WebServiceContext ctx) {
"""
Injects @Resource annotated accessible objects referencing WebServiceContext.
@param instance to operate on
@param ctx current web service context
"""
final Class<?> instanceClass = instance.getClass();
// inject @Resource annotated methods accepting WebServiceContext parameter
Collection<Method> resourceAnnotatedMethods = WEB_SERVICE_CONTEXT_METHOD_FINDER.process(instanceClass);
for(Method method : resourceAnnotatedMethods)
{
try
{
invokeMethod(instance, method, new Object[] {ctx});
}
catch (Exception e)
{
final String message = "Cannot inject @Resource annotated method: " + method;
InjectionException.rethrow(message, e);
}
}
// inject @Resource annotated fields of WebServiceContext type
final Collection<Field> resourceAnnotatedFields = WEB_SERVICE_CONTEXT_FIELD_FINDER.process(instanceClass);
for (Field field : resourceAnnotatedFields)
{
try
{
setField(instance, field, ctx);
}
catch (Exception e)
{
final String message = "Cannot inject @Resource annotated field: " + field;
InjectionException.rethrow(message, e);
}
}
} | java | public static void injectWebServiceContext(final Object instance, final WebServiceContext ctx)
{
final Class<?> instanceClass = instance.getClass();
// inject @Resource annotated methods accepting WebServiceContext parameter
Collection<Method> resourceAnnotatedMethods = WEB_SERVICE_CONTEXT_METHOD_FINDER.process(instanceClass);
for(Method method : resourceAnnotatedMethods)
{
try
{
invokeMethod(instance, method, new Object[] {ctx});
}
catch (Exception e)
{
final String message = "Cannot inject @Resource annotated method: " + method;
InjectionException.rethrow(message, e);
}
}
// inject @Resource annotated fields of WebServiceContext type
final Collection<Field> resourceAnnotatedFields = WEB_SERVICE_CONTEXT_FIELD_FINDER.process(instanceClass);
for (Field field : resourceAnnotatedFields)
{
try
{
setField(instance, field, ctx);
}
catch (Exception e)
{
final String message = "Cannot inject @Resource annotated field: " + field;
InjectionException.rethrow(message, e);
}
}
} | [
"public",
"static",
"void",
"injectWebServiceContext",
"(",
"final",
"Object",
"instance",
",",
"final",
"WebServiceContext",
"ctx",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"instanceClass",
"=",
"instance",
".",
"getClass",
"(",
")",
";",
"// inject @Resource annotated methods accepting WebServiceContext parameter",
"Collection",
"<",
"Method",
">",
"resourceAnnotatedMethods",
"=",
"WEB_SERVICE_CONTEXT_METHOD_FINDER",
".",
"process",
"(",
"instanceClass",
")",
";",
"for",
"(",
"Method",
"method",
":",
"resourceAnnotatedMethods",
")",
"{",
"try",
"{",
"invokeMethod",
"(",
"instance",
",",
"method",
",",
"new",
"Object",
"[",
"]",
"{",
"ctx",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"\"Cannot inject @Resource annotated method: \"",
"+",
"method",
";",
"InjectionException",
".",
"rethrow",
"(",
"message",
",",
"e",
")",
";",
"}",
"}",
"// inject @Resource annotated fields of WebServiceContext type",
"final",
"Collection",
"<",
"Field",
">",
"resourceAnnotatedFields",
"=",
"WEB_SERVICE_CONTEXT_FIELD_FINDER",
".",
"process",
"(",
"instanceClass",
")",
";",
"for",
"(",
"Field",
"field",
":",
"resourceAnnotatedFields",
")",
"{",
"try",
"{",
"setField",
"(",
"instance",
",",
"field",
",",
"ctx",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"message",
"=",
"\"Cannot inject @Resource annotated field: \"",
"+",
"field",
";",
"InjectionException",
".",
"rethrow",
"(",
"message",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Injects @Resource annotated accessible objects referencing WebServiceContext.
@param instance to operate on
@param ctx current web service context | [
"Injects",
"@Resource",
"annotated",
"accessible",
"objects",
"referencing",
"WebServiceContext",
"."
] | train | https://github.com/jbossws/jbossws-common/blob/fcff8a3ef9bfe046d6fa8c855a3fe4f62841add7/src/main/java/org/jboss/ws/common/injection/InjectionHelper.java#L62-L95 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/ProfilesConfigFileWriter.java | ProfilesConfigFileWriter.modifyOrInsertProfiles | public static void modifyOrInsertProfiles(File destination, Profile... profiles) {
"""
Modify or insert new profiles into an existing credentials file by
in-place modification. Only the properties of the affected profiles will
be modified; all the unaffected profiles and comment lines will remain
the same. This method does not support renaming a profile.
@param destination
The destination file to modify
@param profiles
All the credential profiles to be written.
"""
final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>();
for (Profile profile : profiles) {
modifications.put(profile.getProfileName(), profile);
}
modifyProfiles(destination, modifications);
} | java | public static void modifyOrInsertProfiles(File destination, Profile... profiles) {
final Map<String, Profile> modifications = new LinkedHashMap<String, Profile>();
for (Profile profile : profiles) {
modifications.put(profile.getProfileName(), profile);
}
modifyProfiles(destination, modifications);
} | [
"public",
"static",
"void",
"modifyOrInsertProfiles",
"(",
"File",
"destination",
",",
"Profile",
"...",
"profiles",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Profile",
">",
"modifications",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
"Profile",
">",
"(",
")",
";",
"for",
"(",
"Profile",
"profile",
":",
"profiles",
")",
"{",
"modifications",
".",
"put",
"(",
"profile",
".",
"getProfileName",
"(",
")",
",",
"profile",
")",
";",
"}",
"modifyProfiles",
"(",
"destination",
",",
"modifications",
")",
";",
"}"
] | Modify or insert new profiles into an existing credentials file by
in-place modification. Only the properties of the affected profiles will
be modified; all the unaffected profiles and comment lines will remain
the same. This method does not support renaming a profile.
@param destination
The destination file to modify
@param profiles
All the credential profiles to be written. | [
"Modify",
"or",
"insert",
"new",
"profiles",
"into",
"an",
"existing",
"credentials",
"file",
"by",
"in",
"-",
"place",
"modification",
".",
"Only",
"the",
"properties",
"of",
"the",
"affected",
"profiles",
"will",
"be",
"modified",
";",
"all",
"the",
"unaffected",
"profiles",
"and",
"comment",
"lines",
"will",
"remain",
"the",
"same",
".",
"This",
"method",
"does",
"not",
"support",
"renaming",
"a",
"profile",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/auth/profile/ProfilesConfigFileWriter.java#L105-L112 |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpUtil.java | HttpUtil.addParam | private static void addParam(Map<String, List<String>> params, String name, String value, String charset) {
"""
将键值对加入到值为List类型的Map中
@param params 参数
@param name key
@param value value
@param charset 编码
"""
name = URLUtil.decode(name, charset);
value = URLUtil.decode(value, charset);
List<String> values = params.get(name);
if (values == null) {
values = new ArrayList<String>(1); // 一般是一个参数
params.put(name, values);
}
values.add(value);
} | java | private static void addParam(Map<String, List<String>> params, String name, String value, String charset) {
name = URLUtil.decode(name, charset);
value = URLUtil.decode(value, charset);
List<String> values = params.get(name);
if (values == null) {
values = new ArrayList<String>(1); // 一般是一个参数
params.put(name, values);
}
values.add(value);
} | [
"private",
"static",
"void",
"addParam",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"params",
",",
"String",
"name",
",",
"String",
"value",
",",
"String",
"charset",
")",
"{",
"name",
"=",
"URLUtil",
".",
"decode",
"(",
"name",
",",
"charset",
")",
";",
"value",
"=",
"URLUtil",
".",
"decode",
"(",
"value",
",",
"charset",
")",
";",
"List",
"<",
"String",
">",
"values",
"=",
"params",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"1",
")",
";",
"// 一般是一个参数\r",
"params",
".",
"put",
"(",
"name",
",",
"values",
")",
";",
"}",
"values",
".",
"add",
"(",
"value",
")",
";",
"}"
] | 将键值对加入到值为List类型的Map中
@param params 参数
@param name key
@param value value
@param charset 编码 | [
"将键值对加入到值为List类型的Map中"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java#L763-L772 |
Squarespace/cldr | runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java | MessageArgsUnitParser.selectExactUnit | protected static Unit selectExactUnit(String compact, UnitConverter converter) {
"""
Some categories only have a single possible unit depending the locale.
"""
if (compact != null) {
switch (compact) {
case "consumption":
return converter.consumptionUnit();
case "light":
return Unit.LUX;
case "speed":
return converter.speedUnit();
case "temp":
case "temperature":
return converter.temperatureUnit();
default:
break;
}
}
return null;
} | java | protected static Unit selectExactUnit(String compact, UnitConverter converter) {
if (compact != null) {
switch (compact) {
case "consumption":
return converter.consumptionUnit();
case "light":
return Unit.LUX;
case "speed":
return converter.speedUnit();
case "temp":
case "temperature":
return converter.temperatureUnit();
default:
break;
}
}
return null;
} | [
"protected",
"static",
"Unit",
"selectExactUnit",
"(",
"String",
"compact",
",",
"UnitConverter",
"converter",
")",
"{",
"if",
"(",
"compact",
"!=",
"null",
")",
"{",
"switch",
"(",
"compact",
")",
"{",
"case",
"\"consumption\"",
":",
"return",
"converter",
".",
"consumptionUnit",
"(",
")",
";",
"case",
"\"light\"",
":",
"return",
"Unit",
".",
"LUX",
";",
"case",
"\"speed\"",
":",
"return",
"converter",
".",
"speedUnit",
"(",
")",
";",
"case",
"\"temp\"",
":",
"case",
"\"temperature\"",
":",
"return",
"converter",
".",
"temperatureUnit",
"(",
")",
";",
"default",
":",
"break",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Some categories only have a single possible unit depending the locale. | [
"Some",
"categories",
"only",
"have",
"a",
"single",
"possible",
"unit",
"depending",
"the",
"locale",
"."
] | train | https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java#L93-L110 |
alkacon/opencms-core | src/org/opencms/ade/contenteditor/CmsContentService.java | CmsContentService.getFileEncoding | protected String getFileEncoding(CmsObject cms, CmsResource file) {
"""
Helper method to determine the encoding of the given file in the VFS,
which must be set using the "content-encoding" property.<p>
@param cms the CmsObject
@param file the file which is to be checked
@return the encoding for the file
"""
String result;
try {
result = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue(
OpenCms.getSystemInfo().getDefaultEncoding());
} catch (CmsException e) {
result = OpenCms.getSystemInfo().getDefaultEncoding();
}
return CmsEncoder.lookupEncoding(result, OpenCms.getSystemInfo().getDefaultEncoding());
} | java | protected String getFileEncoding(CmsObject cms, CmsResource file) {
String result;
try {
result = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue(
OpenCms.getSystemInfo().getDefaultEncoding());
} catch (CmsException e) {
result = OpenCms.getSystemInfo().getDefaultEncoding();
}
return CmsEncoder.lookupEncoding(result, OpenCms.getSystemInfo().getDefaultEncoding());
} | [
"protected",
"String",
"getFileEncoding",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"file",
")",
"{",
"String",
"result",
";",
"try",
"{",
"result",
"=",
"cms",
".",
"readPropertyObject",
"(",
"file",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_CONTENT_ENCODING",
",",
"true",
")",
".",
"getValue",
"(",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getDefaultEncoding",
"(",
")",
")",
";",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"result",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getDefaultEncoding",
"(",
")",
";",
"}",
"return",
"CmsEncoder",
".",
"lookupEncoding",
"(",
"result",
",",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getDefaultEncoding",
"(",
")",
")",
";",
"}"
] | Helper method to determine the encoding of the given file in the VFS,
which must be set using the "content-encoding" property.<p>
@param cms the CmsObject
@param file the file which is to be checked
@return the encoding for the file | [
"Helper",
"method",
"to",
"determine",
"the",
"encoding",
"of",
"the",
"given",
"file",
"in",
"the",
"VFS",
"which",
"must",
"be",
"set",
"using",
"the",
"content",
"-",
"encoding",
"property",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/contenteditor/CmsContentService.java#L1050-L1060 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/Assert.java | Assert.notEmpty | public static void notEmpty(Collection<?> collection, Supplier<String> message) {
"""
Asserts that the {@link Collection} is not empty.
The assertion holds if and only if the {@link Collection} is not {@literal null} and contains at least 1 element.
@param collection {@link Collection} to evaluate.
@param message {@link Supplier} containing the message using in the {@link IllegalArgumentException} thrown
if the assertion fails.
@throws java.lang.IllegalArgumentException if the {@link Collection} is {@literal null} or empty.
@see java.util.Collection#isEmpty()
"""
if (isEmpty(collection)) {
throw new IllegalArgumentException(message.get());
}
} | java | public static void notEmpty(Collection<?> collection, Supplier<String> message) {
if (isEmpty(collection)) {
throw new IllegalArgumentException(message.get());
}
} | [
"public",
"static",
"void",
"notEmpty",
"(",
"Collection",
"<",
"?",
">",
"collection",
",",
"Supplier",
"<",
"String",
">",
"message",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"collection",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
".",
"get",
"(",
")",
")",
";",
"}",
"}"
] | Asserts that the {@link Collection} is not empty.
The assertion holds if and only if the {@link Collection} is not {@literal null} and contains at least 1 element.
@param collection {@link Collection} to evaluate.
@param message {@link Supplier} containing the message using in the {@link IllegalArgumentException} thrown
if the assertion fails.
@throws java.lang.IllegalArgumentException if the {@link Collection} is {@literal null} or empty.
@see java.util.Collection#isEmpty() | [
"Asserts",
"that",
"the",
"{",
"@link",
"Collection",
"}",
"is",
"not",
"empty",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/Assert.java#L1049-L1053 |