repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/event/ReComputeFieldHandler.java
|
ReComputeFieldHandler.fieldChanged
|
public int fieldChanged(boolean bDisplayOption, int iMoveMode) {
"""
The Field has Changed.
Get the value of this listener's owner, pass it to the computeValue method and
set the returned value to the target field.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
Field changed, re-compute the value in this field.
"""
double srcValue = ((NumberField)this.getOwner()).getValue();
BaseField fldTarget = this.getFieldTarget();
if (this.getOwner().isNull()) // If null, set the target to null
return fldTarget.moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // zero out the field
boolean[] rgbListeners = null;
if (m_bDisableTarget)
rgbListeners = fldTarget.setEnableListeners(false);
int iErrorCode = fldTarget.setValue(this.computeValue(srcValue), bDisplayOption, iMoveMode);
if (m_bDisableTarget)
fldTarget.setEnableListeners(rgbListeners);
return iErrorCode;
}
|
java
|
public int fieldChanged(boolean bDisplayOption, int iMoveMode)
{
double srcValue = ((NumberField)this.getOwner()).getValue();
BaseField fldTarget = this.getFieldTarget();
if (this.getOwner().isNull()) // If null, set the target to null
return fldTarget.moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // zero out the field
boolean[] rgbListeners = null;
if (m_bDisableTarget)
rgbListeners = fldTarget.setEnableListeners(false);
int iErrorCode = fldTarget.setValue(this.computeValue(srcValue), bDisplayOption, iMoveMode);
if (m_bDisableTarget)
fldTarget.setEnableListeners(rgbListeners);
return iErrorCode;
}
|
[
"public",
"int",
"fieldChanged",
"(",
"boolean",
"bDisplayOption",
",",
"int",
"iMoveMode",
")",
"{",
"double",
"srcValue",
"=",
"(",
"(",
"NumberField",
")",
"this",
".",
"getOwner",
"(",
")",
")",
".",
"getValue",
"(",
")",
";",
"BaseField",
"fldTarget",
"=",
"this",
".",
"getFieldTarget",
"(",
")",
";",
"if",
"(",
"this",
".",
"getOwner",
"(",
")",
".",
"isNull",
"(",
")",
")",
"// If null, set the target to null",
"return",
"fldTarget",
".",
"moveFieldToThis",
"(",
"this",
".",
"getOwner",
"(",
")",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"// zero out the field",
"boolean",
"[",
"]",
"rgbListeners",
"=",
"null",
";",
"if",
"(",
"m_bDisableTarget",
")",
"rgbListeners",
"=",
"fldTarget",
".",
"setEnableListeners",
"(",
"false",
")",
";",
"int",
"iErrorCode",
"=",
"fldTarget",
".",
"setValue",
"(",
"this",
".",
"computeValue",
"(",
"srcValue",
")",
",",
"bDisplayOption",
",",
"iMoveMode",
")",
";",
"if",
"(",
"m_bDisableTarget",
")",
"fldTarget",
".",
"setEnableListeners",
"(",
"rgbListeners",
")",
";",
"return",
"iErrorCode",
";",
"}"
] |
The Field has Changed.
Get the value of this listener's owner, pass it to the computeValue method and
set the returned value to the target field.
@param bDisplayOption If true, display the change.
@param iMoveMode The type of move being done (init/read/screen).
@return The error code (or NORMAL_RETURN if okay).
Field changed, re-compute the value in this field.
|
[
"The",
"Field",
"has",
"Changed",
".",
"Get",
"the",
"value",
"of",
"this",
"listener",
"s",
"owner",
"pass",
"it",
"to",
"the",
"computeValue",
"method",
"and",
"set",
"the",
"returned",
"value",
"to",
"the",
"target",
"field",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/event/ReComputeFieldHandler.java#L129-L142
|
zeroturnaround/zt-zip
|
src/main/java/org/zeroturnaround/zip/ZipUtil.java
|
ZipUtil.replaceEntry
|
public static boolean replaceEntry(final File zip, final String path, final byte[] bytes) {
"""
Changes an existing ZIP file: replaces a given entry in it.
@param zip
an existing ZIP file.
@param path
new ZIP entry path.
@param bytes
new entry bytes (or <code>null</code> if directory).
@return <code>true</code> if the entry was replaced.
"""
return operateInPlace(zip, new InPlaceAction() {
public boolean act(File tmpFile) {
return replaceEntry(zip, new ByteSource(path, bytes), tmpFile);
}
});
}
|
java
|
public static boolean replaceEntry(final File zip, final String path, final byte[] bytes) {
return operateInPlace(zip, new InPlaceAction() {
public boolean act(File tmpFile) {
return replaceEntry(zip, new ByteSource(path, bytes), tmpFile);
}
});
}
|
[
"public",
"static",
"boolean",
"replaceEntry",
"(",
"final",
"File",
"zip",
",",
"final",
"String",
"path",
",",
"final",
"byte",
"[",
"]",
"bytes",
")",
"{",
"return",
"operateInPlace",
"(",
"zip",
",",
"new",
"InPlaceAction",
"(",
")",
"{",
"public",
"boolean",
"act",
"(",
"File",
"tmpFile",
")",
"{",
"return",
"replaceEntry",
"(",
"zip",
",",
"new",
"ByteSource",
"(",
"path",
",",
"bytes",
")",
",",
"tmpFile",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Changes an existing ZIP file: replaces a given entry in it.
@param zip
an existing ZIP file.
@param path
new ZIP entry path.
@param bytes
new entry bytes (or <code>null</code> if directory).
@return <code>true</code> if the entry was replaced.
|
[
"Changes",
"an",
"existing",
"ZIP",
"file",
":",
"replaces",
"a",
"given",
"entry",
"in",
"it",
"."
] |
train
|
https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/ZipUtil.java#L2553-L2559
|
anotheria/moskito
|
moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/CounterAspect.java
|
CounterAspect.countMethod
|
@Around(value = "execution(* *(..)) && (@annotation(annotation))")
public Object countMethod(ProceedingJoinPoint pjp, Count annotation) throws Throwable {
"""
Pointcut definition for @Count annotation at method level.
@param pjp ProceedingJoinPoint.
@param annotation @Count annotation.
@return
@throws Throwable
"""
return count(pjp, annotation.producerId(), annotation.subsystem(), annotation.category());
}
|
java
|
@Around(value = "execution(* *(..)) && (@annotation(annotation))")
public Object countMethod(ProceedingJoinPoint pjp, Count annotation) throws Throwable {
return count(pjp, annotation.producerId(), annotation.subsystem(), annotation.category());
}
|
[
"@",
"Around",
"(",
"value",
"=",
"\"execution(* *(..)) && (@annotation(annotation))\"",
")",
"public",
"Object",
"countMethod",
"(",
"ProceedingJoinPoint",
"pjp",
",",
"Count",
"annotation",
")",
"throws",
"Throwable",
"{",
"return",
"count",
"(",
"pjp",
",",
"annotation",
".",
"producerId",
"(",
")",
",",
"annotation",
".",
"subsystem",
"(",
")",
",",
"annotation",
".",
"category",
"(",
")",
")",
";",
"}"
] |
Pointcut definition for @Count annotation at method level.
@param pjp ProceedingJoinPoint.
@param annotation @Count annotation.
@return
@throws Throwable
|
[
"Pointcut",
"definition",
"for"
] |
train
|
https://github.com/anotheria/moskito/blob/0fdb79053b98a6ece610fa159f59bc3331e4cf05/moskito-aop/src/main/java/net/anotheria/moskito/aop/aspect/CounterAspect.java#L31-L34
|
doanduyhai/Achilles
|
achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/raw/TypedQuery.java
|
TypedQuery.withRowAsyncListener
|
public TypedQuery<ENTITY> withRowAsyncListener(Function<Row, Row> rowAsyncListener) {
"""
Add the given async listener on the {@link com.datastax.driver.core.Row} object.
Example of usage:
<pre class="code"><code class="java">
.withRowAsyncListener(row -> {
//Do something with the row object here
})
</code></pre>
Remark: <strong>You can inspect and read values from the row object</strong>
"""
this.options.setRowAsyncListeners(Optional.of(asList(rowAsyncListener)));
return this;
}
|
java
|
public TypedQuery<ENTITY> withRowAsyncListener(Function<Row, Row> rowAsyncListener) {
this.options.setRowAsyncListeners(Optional.of(asList(rowAsyncListener)));
return this;
}
|
[
"public",
"TypedQuery",
"<",
"ENTITY",
">",
"withRowAsyncListener",
"(",
"Function",
"<",
"Row",
",",
"Row",
">",
"rowAsyncListener",
")",
"{",
"this",
".",
"options",
".",
"setRowAsyncListeners",
"(",
"Optional",
".",
"of",
"(",
"asList",
"(",
"rowAsyncListener",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add the given async listener on the {@link com.datastax.driver.core.Row} object.
Example of usage:
<pre class="code"><code class="java">
.withRowAsyncListener(row -> {
//Do something with the row object here
})
</code></pre>
Remark: <strong>You can inspect and read values from the row object</strong>
|
[
"Add",
"the",
"given",
"async",
"listener",
"on",
"the",
"{",
"@link",
"com",
".",
"datastax",
".",
"driver",
".",
"core",
".",
"Row",
"}",
"object",
".",
"Example",
"of",
"usage",
":",
"<pre",
"class",
"=",
"code",
">",
"<code",
"class",
"=",
"java",
">"
] |
train
|
https://github.com/doanduyhai/Achilles/blob/8281c33100e72c993e570592ae1a5306afac6813/achilles-core/src/main/java/info/archinnov/achilles/internals/dsl/raw/TypedQuery.java#L137-L140
|
ehcache/ehcache3
|
impl/src/main/java/org/ehcache/impl/config/copy/DefaultCopyProviderConfiguration.java
|
DefaultCopyProviderConfiguration.addCopierFor
|
public <T> DefaultCopyProviderConfiguration addCopierFor(Class<T> clazz, Class<? extends Copier<T>> copierClass) {
"""
Adds a new {@code Class} - {@link Copier} pair to this configuration object
@param clazz the {@code Class} for which this copier is
@param copierClass the {@link Copier} type to use
@param <T> the type of objects the copier will deal with
@return this configuration instance
@throws NullPointerException if any argument is null
@throws IllegalArgumentException in a case a mapping for {@code clazz} already exists
"""
return addCopierFor(clazz, copierClass, false);
}
|
java
|
public <T> DefaultCopyProviderConfiguration addCopierFor(Class<T> clazz, Class<? extends Copier<T>> copierClass) {
return addCopierFor(clazz, copierClass, false);
}
|
[
"public",
"<",
"T",
">",
"DefaultCopyProviderConfiguration",
"addCopierFor",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Class",
"<",
"?",
"extends",
"Copier",
"<",
"T",
">",
">",
"copierClass",
")",
"{",
"return",
"addCopierFor",
"(",
"clazz",
",",
"copierClass",
",",
"false",
")",
";",
"}"
] |
Adds a new {@code Class} - {@link Copier} pair to this configuration object
@param clazz the {@code Class} for which this copier is
@param copierClass the {@link Copier} type to use
@param <T> the type of objects the copier will deal with
@return this configuration instance
@throws NullPointerException if any argument is null
@throws IllegalArgumentException in a case a mapping for {@code clazz} already exists
|
[
"Adds",
"a",
"new",
"{",
"@code",
"Class",
"}",
"-",
"{",
"@link",
"Copier",
"}",
"pair",
"to",
"this",
"configuration",
"object"
] |
train
|
https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/config/copy/DefaultCopyProviderConfiguration.java#L68-L70
|
apache/incubator-gobblin
|
gobblin-utility/src/main/java/org/apache/gobblin/util/AvroUtils.java
|
AvroUtils.getDirectorySchema
|
public static Schema getDirectorySchema(Path directory, Configuration conf, boolean latest) throws IOException {
"""
Get the latest avro schema for a directory
@param directory the input dir that contains avro files
@param conf configuration
@param latest true to return latest schema, false to return oldest schema
@return the latest/oldest schema in the directory
@throws IOException
"""
return getDirectorySchema(directory, FileSystem.get(conf), latest);
}
|
java
|
public static Schema getDirectorySchema(Path directory, Configuration conf, boolean latest) throws IOException {
return getDirectorySchema(directory, FileSystem.get(conf), latest);
}
|
[
"public",
"static",
"Schema",
"getDirectorySchema",
"(",
"Path",
"directory",
",",
"Configuration",
"conf",
",",
"boolean",
"latest",
")",
"throws",
"IOException",
"{",
"return",
"getDirectorySchema",
"(",
"directory",
",",
"FileSystem",
".",
"get",
"(",
"conf",
")",
",",
"latest",
")",
";",
"}"
] |
Get the latest avro schema for a directory
@param directory the input dir that contains avro files
@param conf configuration
@param latest true to return latest schema, false to return oldest schema
@return the latest/oldest schema in the directory
@throws IOException
|
[
"Get",
"the",
"latest",
"avro",
"schema",
"for",
"a",
"directory"
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/AvroUtils.java#L519-L521
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/field/ReferenceField.java
|
ReferenceField.setupIconView
|
public ScreenComponent setupIconView(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, boolean bIncludeBlankOption) {
"""
Display a button that shows the icon from the current record in the secondary file.
"""
ScreenComponent screenField = null;
Record record = this.makeReferenceRecord();
// Set up the listener to read the current record on a valid main record
ImageField fldDisplayFieldDesc = this.getIconField(record);
if (fldDisplayFieldDesc.getListener(BlankButtonHandler.class) == null)
fldDisplayFieldDesc.addListener(new BlankButtonHandler(null));
if (fldDisplayFieldDesc != null)
{ // The next two lines are so in GridScreen(s), the converter leads to this field, while it displays the fielddesc.
FieldConverter fldDescConverter = new FieldDescConverter(fldDisplayFieldDesc, (Converter)converter);
Map<String,Object> properties = new HashMap<String,Object>();
properties.put(ScreenModel.IMAGE, ScreenModel.NONE);
properties.put(ScreenModel.NEVER_DISABLE, Constants.TRUE);
screenField = createScreenComponent(ScreenModel.BUTTON_BOX, itsLocation, targetScreen, fldDescConverter, iDisplayFieldDesc, properties);
//?{
//? public void setEnabled(boolean bEnabled)
//? {
//? super.setEnabled(true); // Never disable
//? }
//?};
String strDisplay = converter.getFieldDesc();
if (!(targetScreen instanceof GridScreenParent))
if ((strDisplay != null) && (strDisplay.length() > 0))
{ // Since display string does not come with buttons
ScreenLoc descLocation = targetScreen.getNextLocation(ScreenConstants.FIELD_DESC, ScreenConstants.DONT_SET_ANCHOR);
properties = new HashMap<String,Object>();
properties.put(ScreenModel.DISPLAY_STRING, strDisplay);
createScreenComponent(ScreenModel.STATIC_STRING, descLocation, targetScreen, converter, iDisplayFieldDesc, properties);
}
}
if (((targetScreen instanceof GridScreenParent)) || (iDisplayFieldDesc == ScreenConstants.DONT_DISPLAY_FIELD_DESC))
{ // If there is no popupbox to display the icon, I must explicitly read it.
this.addListener(new ReadSecondaryHandler(fldDisplayFieldDesc.getRecord()));
}
return screenField;
}
|
java
|
public ScreenComponent setupIconView(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, boolean bIncludeBlankOption)
{
ScreenComponent screenField = null;
Record record = this.makeReferenceRecord();
// Set up the listener to read the current record on a valid main record
ImageField fldDisplayFieldDesc = this.getIconField(record);
if (fldDisplayFieldDesc.getListener(BlankButtonHandler.class) == null)
fldDisplayFieldDesc.addListener(new BlankButtonHandler(null));
if (fldDisplayFieldDesc != null)
{ // The next two lines are so in GridScreen(s), the converter leads to this field, while it displays the fielddesc.
FieldConverter fldDescConverter = new FieldDescConverter(fldDisplayFieldDesc, (Converter)converter);
Map<String,Object> properties = new HashMap<String,Object>();
properties.put(ScreenModel.IMAGE, ScreenModel.NONE);
properties.put(ScreenModel.NEVER_DISABLE, Constants.TRUE);
screenField = createScreenComponent(ScreenModel.BUTTON_BOX, itsLocation, targetScreen, fldDescConverter, iDisplayFieldDesc, properties);
//?{
//? public void setEnabled(boolean bEnabled)
//? {
//? super.setEnabled(true); // Never disable
//? }
//?};
String strDisplay = converter.getFieldDesc();
if (!(targetScreen instanceof GridScreenParent))
if ((strDisplay != null) && (strDisplay.length() > 0))
{ // Since display string does not come with buttons
ScreenLoc descLocation = targetScreen.getNextLocation(ScreenConstants.FIELD_DESC, ScreenConstants.DONT_SET_ANCHOR);
properties = new HashMap<String,Object>();
properties.put(ScreenModel.DISPLAY_STRING, strDisplay);
createScreenComponent(ScreenModel.STATIC_STRING, descLocation, targetScreen, converter, iDisplayFieldDesc, properties);
}
}
if (((targetScreen instanceof GridScreenParent)) || (iDisplayFieldDesc == ScreenConstants.DONT_DISPLAY_FIELD_DESC))
{ // If there is no popupbox to display the icon, I must explicitly read it.
this.addListener(new ReadSecondaryHandler(fldDisplayFieldDesc.getRecord()));
}
return screenField;
}
|
[
"public",
"ScreenComponent",
"setupIconView",
"(",
"ScreenLoc",
"itsLocation",
",",
"ComponentParent",
"targetScreen",
",",
"Convert",
"converter",
",",
"int",
"iDisplayFieldDesc",
",",
"boolean",
"bIncludeBlankOption",
")",
"{",
"ScreenComponent",
"screenField",
"=",
"null",
";",
"Record",
"record",
"=",
"this",
".",
"makeReferenceRecord",
"(",
")",
";",
"// Set up the listener to read the current record on a valid main record",
"ImageField",
"fldDisplayFieldDesc",
"=",
"this",
".",
"getIconField",
"(",
"record",
")",
";",
"if",
"(",
"fldDisplayFieldDesc",
".",
"getListener",
"(",
"BlankButtonHandler",
".",
"class",
")",
"==",
"null",
")",
"fldDisplayFieldDesc",
".",
"addListener",
"(",
"new",
"BlankButtonHandler",
"(",
"null",
")",
")",
";",
"if",
"(",
"fldDisplayFieldDesc",
"!=",
"null",
")",
"{",
"// The next two lines are so in GridScreen(s), the converter leads to this field, while it displays the fielddesc.",
"FieldConverter",
"fldDescConverter",
"=",
"new",
"FieldDescConverter",
"(",
"fldDisplayFieldDesc",
",",
"(",
"Converter",
")",
"converter",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"ScreenModel",
".",
"IMAGE",
",",
"ScreenModel",
".",
"NONE",
")",
";",
"properties",
".",
"put",
"(",
"ScreenModel",
".",
"NEVER_DISABLE",
",",
"Constants",
".",
"TRUE",
")",
";",
"screenField",
"=",
"createScreenComponent",
"(",
"ScreenModel",
".",
"BUTTON_BOX",
",",
"itsLocation",
",",
"targetScreen",
",",
"fldDescConverter",
",",
"iDisplayFieldDesc",
",",
"properties",
")",
";",
"//?{",
"//? public void setEnabled(boolean bEnabled)",
"//? {",
"//? super.setEnabled(true); // Never disable",
"//? }",
"//?};",
"String",
"strDisplay",
"=",
"converter",
".",
"getFieldDesc",
"(",
")",
";",
"if",
"(",
"!",
"(",
"targetScreen",
"instanceof",
"GridScreenParent",
")",
")",
"if",
"(",
"(",
"strDisplay",
"!=",
"null",
")",
"&&",
"(",
"strDisplay",
".",
"length",
"(",
")",
">",
"0",
")",
")",
"{",
"// Since display string does not come with buttons",
"ScreenLoc",
"descLocation",
"=",
"targetScreen",
".",
"getNextLocation",
"(",
"ScreenConstants",
".",
"FIELD_DESC",
",",
"ScreenConstants",
".",
"DONT_SET_ANCHOR",
")",
";",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"properties",
".",
"put",
"(",
"ScreenModel",
".",
"DISPLAY_STRING",
",",
"strDisplay",
")",
";",
"createScreenComponent",
"(",
"ScreenModel",
".",
"STATIC_STRING",
",",
"descLocation",
",",
"targetScreen",
",",
"converter",
",",
"iDisplayFieldDesc",
",",
"properties",
")",
";",
"}",
"}",
"if",
"(",
"(",
"(",
"targetScreen",
"instanceof",
"GridScreenParent",
")",
")",
"||",
"(",
"iDisplayFieldDesc",
"==",
"ScreenConstants",
".",
"DONT_DISPLAY_FIELD_DESC",
")",
")",
"{",
"// If there is no popupbox to display the icon, I must explicitly read it.",
"this",
".",
"addListener",
"(",
"new",
"ReadSecondaryHandler",
"(",
"fldDisplayFieldDesc",
".",
"getRecord",
"(",
")",
")",
")",
";",
"}",
"return",
"screenField",
";",
"}"
] |
Display a button that shows the icon from the current record in the secondary file.
|
[
"Display",
"a",
"button",
"that",
"shows",
"the",
"icon",
"from",
"the",
"current",
"record",
"in",
"the",
"secondary",
"file",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/ReferenceField.java#L305-L343
|
katjahahn/PortEx
|
src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java
|
Visualizer.createLegendImage
|
public BufferedImage createLegendImage(boolean withBytePlot,
boolean withEntropy, boolean withPEStructure) {
"""
Creates a buffered image with a basic Legend
@param withBytePlot
show byteplot legend
@param withEntropy
show entropy legend
@param withPEStructure
show PE structure legend
@return buffered image of the generated legend
"""
image = new BufferedImage(legendWidth, height, IMAGE_TYPE);
drawLegend(withBytePlot, withEntropy, withPEStructure);
assert image != null;
assert image.getWidth() == legendWidth;
assert image.getHeight() == height;
return image;
}
|
java
|
public BufferedImage createLegendImage(boolean withBytePlot,
boolean withEntropy, boolean withPEStructure) {
image = new BufferedImage(legendWidth, height, IMAGE_TYPE);
drawLegend(withBytePlot, withEntropy, withPEStructure);
assert image != null;
assert image.getWidth() == legendWidth;
assert image.getHeight() == height;
return image;
}
|
[
"public",
"BufferedImage",
"createLegendImage",
"(",
"boolean",
"withBytePlot",
",",
"boolean",
"withEntropy",
",",
"boolean",
"withPEStructure",
")",
"{",
"image",
"=",
"new",
"BufferedImage",
"(",
"legendWidth",
",",
"height",
",",
"IMAGE_TYPE",
")",
";",
"drawLegend",
"(",
"withBytePlot",
",",
"withEntropy",
",",
"withPEStructure",
")",
";",
"assert",
"image",
"!=",
"null",
";",
"assert",
"image",
".",
"getWidth",
"(",
")",
"==",
"legendWidth",
";",
"assert",
"image",
".",
"getHeight",
"(",
")",
"==",
"height",
";",
"return",
"image",
";",
"}"
] |
Creates a buffered image with a basic Legend
@param withBytePlot
show byteplot legend
@param withEntropy
show entropy legend
@param withPEStructure
show PE structure legend
@return buffered image of the generated legend
|
[
"Creates",
"a",
"buffered",
"image",
"with",
"a",
"basic",
"Legend"
] |
train
|
https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L414-L422
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByHash
|
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash) throws InvalidArgumentException, ProposalException {
"""
Query a peer in this channel for a Block by the block hash.
Each peer is tried until successful response.
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param peers the Peers to query.
@param blockHash the hash of the Block in the chain.
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException if an error occurred processing the query.
"""
return queryBlockByHash(peers, blockHash, client.getUserContext());
}
|
java
|
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash) throws InvalidArgumentException, ProposalException {
return queryBlockByHash(peers, blockHash, client.getUserContext());
}
|
[
"public",
"BlockInfo",
"queryBlockByHash",
"(",
"Collection",
"<",
"Peer",
">",
"peers",
",",
"byte",
"[",
"]",
"blockHash",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByHash",
"(",
"peers",
",",
"blockHash",
",",
"client",
".",
"getUserContext",
"(",
")",
")",
";",
"}"
] |
Query a peer in this channel for a Block by the block hash.
Each peer is tried until successful response.
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param peers the Peers to query.
@param blockHash the hash of the Block in the chain.
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException if an error occurred processing the query.
|
[
"Query",
"a",
"peer",
"in",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"block",
"hash",
".",
"Each",
"peer",
"is",
"tried",
"until",
"successful",
"response",
"."
] |
train
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2699-L2703
|
BioPAX/Paxtools
|
pattern/src/main/java/org/biopax/paxtools/pattern/Pattern.java
|
Pattern.insertPointConstraint
|
public void insertPointConstraint(Constraint con, int ... ind) {
"""
A point constraint deals with only one element in a match, checks its validity. This method
injects the parameter constraint multiple times among the list of mapped constraints, to the
specified indexes.
@param con constraint to add
@param ind indices to add this point constraint
"""
assert con.getVariableSize() == 1;
for (int i : ind)
{
for (int j = 0; j < constraints.size(); j++)
{
int[] index = constraints.get(j).getInds();
if (index[index.length-1] == i)
{
constraints.add(j + 1, new MappedConst(con, i));
break;
}
}
}
}
|
java
|
public void insertPointConstraint(Constraint con, int ... ind)
{
assert con.getVariableSize() == 1;
for (int i : ind)
{
for (int j = 0; j < constraints.size(); j++)
{
int[] index = constraints.get(j).getInds();
if (index[index.length-1] == i)
{
constraints.add(j + 1, new MappedConst(con, i));
break;
}
}
}
}
|
[
"public",
"void",
"insertPointConstraint",
"(",
"Constraint",
"con",
",",
"int",
"...",
"ind",
")",
"{",
"assert",
"con",
".",
"getVariableSize",
"(",
")",
"==",
"1",
";",
"for",
"(",
"int",
"i",
":",
"ind",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"constraints",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"int",
"[",
"]",
"index",
"=",
"constraints",
".",
"get",
"(",
"j",
")",
".",
"getInds",
"(",
")",
";",
"if",
"(",
"index",
"[",
"index",
".",
"length",
"-",
"1",
"]",
"==",
"i",
")",
"{",
"constraints",
".",
"add",
"(",
"j",
"+",
"1",
",",
"new",
"MappedConst",
"(",
"con",
",",
"i",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
A point constraint deals with only one element in a match, checks its validity. This method
injects the parameter constraint multiple times among the list of mapped constraints, to the
specified indexes.
@param con constraint to add
@param ind indices to add this point constraint
|
[
"A",
"point",
"constraint",
"deals",
"with",
"only",
"one",
"element",
"in",
"a",
"match",
"checks",
"its",
"validity",
".",
"This",
"method",
"injects",
"the",
"parameter",
"constraint",
"multiple",
"times",
"among",
"the",
"list",
"of",
"mapped",
"constraints",
"to",
"the",
"specified",
"indexes",
"."
] |
train
|
https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/Pattern.java#L315-L331
|
brianwhu/xillium
|
data/src/main/java/org/xillium/data/persistence/ParametricStatement.java
|
ParametricStatement.executeUpdate
|
public int executeUpdate(Connection conn, DataObject[] objects) throws SQLException {
"""
Executes a batch UPDATE or DELETE statement.
@return the number of rows affected
"""
PreparedStatement statement = conn.prepareStatement(_sql);
try {
for (DataObject object: objects) {
load(statement, object);
statement.addBatch();
}
int count = getAffectedRowCount(statement.executeBatch());
return count;
} finally {
statement.close();
}
}
|
java
|
public int executeUpdate(Connection conn, DataObject[] objects) throws SQLException {
PreparedStatement statement = conn.prepareStatement(_sql);
try {
for (DataObject object: objects) {
load(statement, object);
statement.addBatch();
}
int count = getAffectedRowCount(statement.executeBatch());
return count;
} finally {
statement.close();
}
}
|
[
"public",
"int",
"executeUpdate",
"(",
"Connection",
"conn",
",",
"DataObject",
"[",
"]",
"objects",
")",
"throws",
"SQLException",
"{",
"PreparedStatement",
"statement",
"=",
"conn",
".",
"prepareStatement",
"(",
"_sql",
")",
";",
"try",
"{",
"for",
"(",
"DataObject",
"object",
":",
"objects",
")",
"{",
"load",
"(",
"statement",
",",
"object",
")",
";",
"statement",
".",
"addBatch",
"(",
")",
";",
"}",
"int",
"count",
"=",
"getAffectedRowCount",
"(",
"statement",
".",
"executeBatch",
"(",
")",
")",
";",
"return",
"count",
";",
"}",
"finally",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Executes a batch UPDATE or DELETE statement.
@return the number of rows affected
|
[
"Executes",
"a",
"batch",
"UPDATE",
"or",
"DELETE",
"statement",
"."
] |
train
|
https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/ParametricStatement.java#L286-L298
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java
|
UserAttrs.getFloatAttribute
|
public static final float getFloatAttribute(Path path, String attribute, LinkOption... options) throws IOException {
"""
Returns user-defined-attribute NaN if not found.
@param path
@param attribute
@param options
@return
@throws IOException
@see java.lang.Float#NaN
"""
return getFloatAttribute(path, attribute, Float.NaN, options);
}
|
java
|
public static final float getFloatAttribute(Path path, String attribute, LinkOption... options) throws IOException
{
return getFloatAttribute(path, attribute, Float.NaN, options);
}
|
[
"public",
"static",
"final",
"float",
"getFloatAttribute",
"(",
"Path",
"path",
",",
"String",
"attribute",
",",
"LinkOption",
"...",
"options",
")",
"throws",
"IOException",
"{",
"return",
"getFloatAttribute",
"(",
"path",
",",
"attribute",
",",
"Float",
".",
"NaN",
",",
"options",
")",
";",
"}"
] |
Returns user-defined-attribute NaN if not found.
@param path
@param attribute
@param options
@return
@throws IOException
@see java.lang.Float#NaN
|
[
"Returns",
"user",
"-",
"defined",
"-",
"attribute",
"NaN",
"if",
"not",
"found",
"."
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java#L231-L234
|
Azure/azure-sdk-for-java
|
edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/UsersInner.java
|
UsersInner.createOrUpdateAsync
|
public Observable<UserInner> createOrUpdateAsync(String deviceName, String name, String resourceGroupName, UserInner user) {
"""
Creates a new user or updates an existing user's information on a data box edge/gateway device.
@param deviceName The device name.
@param name The user name.
@param resourceGroupName The resource group name.
@param user The user details.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(deviceName, name, resourceGroupName, user).map(new Func1<ServiceResponse<UserInner>, UserInner>() {
@Override
public UserInner call(ServiceResponse<UserInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<UserInner> createOrUpdateAsync(String deviceName, String name, String resourceGroupName, UserInner user) {
return createOrUpdateWithServiceResponseAsync(deviceName, name, resourceGroupName, user).map(new Func1<ServiceResponse<UserInner>, UserInner>() {
@Override
public UserInner call(ServiceResponse<UserInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"UserInner",
">",
"createOrUpdateAsync",
"(",
"String",
"deviceName",
",",
"String",
"name",
",",
"String",
"resourceGroupName",
",",
"UserInner",
"user",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"deviceName",
",",
"name",
",",
"resourceGroupName",
",",
"user",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"UserInner",
">",
",",
"UserInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"UserInner",
"call",
"(",
"ServiceResponse",
"<",
"UserInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a new user or updates an existing user's information on a data box edge/gateway device.
@param deviceName The device name.
@param name The user name.
@param resourceGroupName The resource group name.
@param user The user details.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Creates",
"a",
"new",
"user",
"or",
"updates",
"an",
"existing",
"user",
"s",
"information",
"on",
"a",
"data",
"box",
"edge",
"/",
"gateway",
"device",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/edgegateway/resource-manager/v2019_03_01/src/main/java/com/microsoft/azure/management/edgegateway/v2019_03_01/implementation/UsersInner.java#L351-L358
|
uber/rides-java-sdk
|
uber-rides/src/main/java/com/uber/sdk/rides/client/error/ErrorParser.java
|
ErrorParser.parseError
|
@Nonnull
public static ApiError parseError(@Nullable String errorBody, int statusCode, @Nullable String message) {
"""
Parses an error body and code into an {@link ApiError}.
@param errorBody the error body from the response.
@param statusCode the status code from the response.
@param message the message from the response.
@return the parsed {@link ApiError}.
"""
if (errorBody == null) {
return new ApiError(null, statusCode, message);
}
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<CompatibilityApiError> oldApiErrorJsonAdapter = moshi.adapter(CompatibilityApiError.class).failOnUnknown();
try {
return new ApiError(oldApiErrorJsonAdapter.fromJson(errorBody), statusCode);
} catch (IOException | JsonDataException exception) {
// Not old type of error, move on
}
JsonAdapter<ApiError> apiErrorJsonAdapter = moshi.adapter(ApiError.class).failOnUnknown();
try {
return apiErrorJsonAdapter.fromJson(errorBody);
} catch (IOException | JsonDataException exception) {
return new ApiError(null, statusCode, "Unknown Error");
}
}
|
java
|
@Nonnull
public static ApiError parseError(@Nullable String errorBody, int statusCode, @Nullable String message) {
if (errorBody == null) {
return new ApiError(null, statusCode, message);
}
Moshi moshi = new Moshi.Builder().build();
JsonAdapter<CompatibilityApiError> oldApiErrorJsonAdapter = moshi.adapter(CompatibilityApiError.class).failOnUnknown();
try {
return new ApiError(oldApiErrorJsonAdapter.fromJson(errorBody), statusCode);
} catch (IOException | JsonDataException exception) {
// Not old type of error, move on
}
JsonAdapter<ApiError> apiErrorJsonAdapter = moshi.adapter(ApiError.class).failOnUnknown();
try {
return apiErrorJsonAdapter.fromJson(errorBody);
} catch (IOException | JsonDataException exception) {
return new ApiError(null, statusCode, "Unknown Error");
}
}
|
[
"@",
"Nonnull",
"public",
"static",
"ApiError",
"parseError",
"(",
"@",
"Nullable",
"String",
"errorBody",
",",
"int",
"statusCode",
",",
"@",
"Nullable",
"String",
"message",
")",
"{",
"if",
"(",
"errorBody",
"==",
"null",
")",
"{",
"return",
"new",
"ApiError",
"(",
"null",
",",
"statusCode",
",",
"message",
")",
";",
"}",
"Moshi",
"moshi",
"=",
"new",
"Moshi",
".",
"Builder",
"(",
")",
".",
"build",
"(",
")",
";",
"JsonAdapter",
"<",
"CompatibilityApiError",
">",
"oldApiErrorJsonAdapter",
"=",
"moshi",
".",
"adapter",
"(",
"CompatibilityApiError",
".",
"class",
")",
".",
"failOnUnknown",
"(",
")",
";",
"try",
"{",
"return",
"new",
"ApiError",
"(",
"oldApiErrorJsonAdapter",
".",
"fromJson",
"(",
"errorBody",
")",
",",
"statusCode",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"JsonDataException",
"exception",
")",
"{",
"// Not old type of error, move on",
"}",
"JsonAdapter",
"<",
"ApiError",
">",
"apiErrorJsonAdapter",
"=",
"moshi",
".",
"adapter",
"(",
"ApiError",
".",
"class",
")",
".",
"failOnUnknown",
"(",
")",
";",
"try",
"{",
"return",
"apiErrorJsonAdapter",
".",
"fromJson",
"(",
"errorBody",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"JsonDataException",
"exception",
")",
"{",
"return",
"new",
"ApiError",
"(",
"null",
",",
"statusCode",
",",
"\"Unknown Error\"",
")",
";",
"}",
"}"
] |
Parses an error body and code into an {@link ApiError}.
@param errorBody the error body from the response.
@param statusCode the status code from the response.
@param message the message from the response.
@return the parsed {@link ApiError}.
|
[
"Parses",
"an",
"error",
"body",
"and",
"code",
"into",
"an",
"{",
"@link",
"ApiError",
"}",
"."
] |
train
|
https://github.com/uber/rides-java-sdk/blob/6c75570ab7884f8ecafaad312ef471dd33f64c42/uber-rides/src/main/java/com/uber/sdk/rides/client/error/ErrorParser.java#L68-L88
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java
|
MappedParametrizedObjectEntry.getParameterInteger
|
public Integer getParameterInteger(String name) throws RepositoryConfigurationException {
"""
Parse named parameter as Integer.
@param name
parameter name
@return Integer value
@throws RepositoryConfigurationException
"""
try
{
return StringNumberParser.parseInt(getParameterValue(name));
}
catch (NumberFormatException e)
{
throw new RepositoryConfigurationException(name + ": unparseable Integer. " + e, e);
}
}
|
java
|
public Integer getParameterInteger(String name) throws RepositoryConfigurationException
{
try
{
return StringNumberParser.parseInt(getParameterValue(name));
}
catch (NumberFormatException e)
{
throw new RepositoryConfigurationException(name + ": unparseable Integer. " + e, e);
}
}
|
[
"public",
"Integer",
"getParameterInteger",
"(",
"String",
"name",
")",
"throws",
"RepositoryConfigurationException",
"{",
"try",
"{",
"return",
"StringNumberParser",
".",
"parseInt",
"(",
"getParameterValue",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"RepositoryConfigurationException",
"(",
"name",
"+",
"\": unparseable Integer. \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}"
] |
Parse named parameter as Integer.
@param name
parameter name
@return Integer value
@throws RepositoryConfigurationException
|
[
"Parse",
"named",
"parameter",
"as",
"Integer",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java#L176-L186
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X509CertImpl.java
|
X509CertImpl.makeAltNames
|
private static Collection<List<?>> makeAltNames(GeneralNames names) {
"""
Converts a GeneralNames structure into an immutable Collection of
alternative names (subject or issuer) in the form required by
{@link #getSubjectAlternativeNames} or
{@link #getIssuerAlternativeNames}.
@param names the GeneralNames to be converted
@return an immutable Collection of alternative names
"""
if (names.isEmpty()) {
return Collections.<List<?>>emptySet();
}
List<List<?>> newNames = new ArrayList<>();
for (GeneralName gname : names.names()) {
GeneralNameInterface name = gname.getName();
List<Object> nameEntry = new ArrayList<>(2);
nameEntry.add(Integer.valueOf(name.getType()));
switch (name.getType()) {
case GeneralNameInterface.NAME_RFC822:
nameEntry.add(((RFC822Name) name).getName());
break;
case GeneralNameInterface.NAME_DNS:
nameEntry.add(((DNSName) name).getName());
break;
case GeneralNameInterface.NAME_DIRECTORY:
nameEntry.add(((X500Name) name).getRFC2253Name());
break;
case GeneralNameInterface.NAME_URI:
nameEntry.add(((URIName) name).getName());
break;
case GeneralNameInterface.NAME_IP:
try {
nameEntry.add(((IPAddressName) name).getName());
} catch (IOException ioe) {
// IPAddressName in cert is bogus
throw new RuntimeException("IPAddress cannot be parsed",
ioe);
}
break;
case GeneralNameInterface.NAME_OID:
nameEntry.add(((OIDName) name).getOID().toString());
break;
default:
// add DER encoded form
DerOutputStream derOut = new DerOutputStream();
try {
name.encode(derOut);
} catch (IOException ioe) {
// should not occur since name has already been decoded
// from cert (this would indicate a bug in our code)
throw new RuntimeException("name cannot be encoded", ioe);
}
nameEntry.add(derOut.toByteArray());
break;
}
newNames.add(Collections.unmodifiableList(nameEntry));
}
return Collections.unmodifiableCollection(newNames);
}
|
java
|
private static Collection<List<?>> makeAltNames(GeneralNames names) {
if (names.isEmpty()) {
return Collections.<List<?>>emptySet();
}
List<List<?>> newNames = new ArrayList<>();
for (GeneralName gname : names.names()) {
GeneralNameInterface name = gname.getName();
List<Object> nameEntry = new ArrayList<>(2);
nameEntry.add(Integer.valueOf(name.getType()));
switch (name.getType()) {
case GeneralNameInterface.NAME_RFC822:
nameEntry.add(((RFC822Name) name).getName());
break;
case GeneralNameInterface.NAME_DNS:
nameEntry.add(((DNSName) name).getName());
break;
case GeneralNameInterface.NAME_DIRECTORY:
nameEntry.add(((X500Name) name).getRFC2253Name());
break;
case GeneralNameInterface.NAME_URI:
nameEntry.add(((URIName) name).getName());
break;
case GeneralNameInterface.NAME_IP:
try {
nameEntry.add(((IPAddressName) name).getName());
} catch (IOException ioe) {
// IPAddressName in cert is bogus
throw new RuntimeException("IPAddress cannot be parsed",
ioe);
}
break;
case GeneralNameInterface.NAME_OID:
nameEntry.add(((OIDName) name).getOID().toString());
break;
default:
// add DER encoded form
DerOutputStream derOut = new DerOutputStream();
try {
name.encode(derOut);
} catch (IOException ioe) {
// should not occur since name has already been decoded
// from cert (this would indicate a bug in our code)
throw new RuntimeException("name cannot be encoded", ioe);
}
nameEntry.add(derOut.toByteArray());
break;
}
newNames.add(Collections.unmodifiableList(nameEntry));
}
return Collections.unmodifiableCollection(newNames);
}
|
[
"private",
"static",
"Collection",
"<",
"List",
"<",
"?",
">",
">",
"makeAltNames",
"(",
"GeneralNames",
"names",
")",
"{",
"if",
"(",
"names",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"<",
"List",
"<",
"?",
">",
">",
"emptySet",
"(",
")",
";",
"}",
"List",
"<",
"List",
"<",
"?",
">",
">",
"newNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"GeneralName",
"gname",
":",
"names",
".",
"names",
"(",
")",
")",
"{",
"GeneralNameInterface",
"name",
"=",
"gname",
".",
"getName",
"(",
")",
";",
"List",
"<",
"Object",
">",
"nameEntry",
"=",
"new",
"ArrayList",
"<>",
"(",
"2",
")",
";",
"nameEntry",
".",
"add",
"(",
"Integer",
".",
"valueOf",
"(",
"name",
".",
"getType",
"(",
")",
")",
")",
";",
"switch",
"(",
"name",
".",
"getType",
"(",
")",
")",
"{",
"case",
"GeneralNameInterface",
".",
"NAME_RFC822",
":",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"RFC822Name",
")",
"name",
")",
".",
"getName",
"(",
")",
")",
";",
"break",
";",
"case",
"GeneralNameInterface",
".",
"NAME_DNS",
":",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"DNSName",
")",
"name",
")",
".",
"getName",
"(",
")",
")",
";",
"break",
";",
"case",
"GeneralNameInterface",
".",
"NAME_DIRECTORY",
":",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"X500Name",
")",
"name",
")",
".",
"getRFC2253Name",
"(",
")",
")",
";",
"break",
";",
"case",
"GeneralNameInterface",
".",
"NAME_URI",
":",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"URIName",
")",
"name",
")",
".",
"getName",
"(",
")",
")",
";",
"break",
";",
"case",
"GeneralNameInterface",
".",
"NAME_IP",
":",
"try",
"{",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"IPAddressName",
")",
"name",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"// IPAddressName in cert is bogus",
"throw",
"new",
"RuntimeException",
"(",
"\"IPAddress cannot be parsed\"",
",",
"ioe",
")",
";",
"}",
"break",
";",
"case",
"GeneralNameInterface",
".",
"NAME_OID",
":",
"nameEntry",
".",
"add",
"(",
"(",
"(",
"OIDName",
")",
"name",
")",
".",
"getOID",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"// add DER encoded form",
"DerOutputStream",
"derOut",
"=",
"new",
"DerOutputStream",
"(",
")",
";",
"try",
"{",
"name",
".",
"encode",
"(",
"derOut",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"// should not occur since name has already been decoded",
"// from cert (this would indicate a bug in our code)",
"throw",
"new",
"RuntimeException",
"(",
"\"name cannot be encoded\"",
",",
"ioe",
")",
";",
"}",
"nameEntry",
".",
"add",
"(",
"derOut",
".",
"toByteArray",
"(",
")",
")",
";",
"break",
";",
"}",
"newNames",
".",
"add",
"(",
"Collections",
".",
"unmodifiableList",
"(",
"nameEntry",
")",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableCollection",
"(",
"newNames",
")",
";",
"}"
] |
Converts a GeneralNames structure into an immutable Collection of
alternative names (subject or issuer) in the form required by
{@link #getSubjectAlternativeNames} or
{@link #getIssuerAlternativeNames}.
@param names the GeneralNames to be converted
@return an immutable Collection of alternative names
|
[
"Converts",
"a",
"GeneralNames",
"structure",
"into",
"an",
"immutable",
"Collection",
"of",
"alternative",
"names",
"(",
"subject",
"or",
"issuer",
")",
"in",
"the",
"form",
"required",
"by",
"{",
"@link",
"#getSubjectAlternativeNames",
"}",
"or",
"{",
"@link",
"#getIssuerAlternativeNames",
"}",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/sun/security/x509/X509CertImpl.java#L1563-L1613
|
rythmengine/rythmengine
|
src/main/java/org/rythmengine/utils/S.java
|
S.ne
|
public static boolean ne(String s1, String s2, int modifier) {
"""
Alias of {@link #isNotEqual(String, String, int)}
@param s1
@param s2
@param modifier
@return true if o1's str not equals o2's str
"""
return !isEqual(s1, s2, modifier);
}
|
java
|
public static boolean ne(String s1, String s2, int modifier) {
return !isEqual(s1, s2, modifier);
}
|
[
"public",
"static",
"boolean",
"ne",
"(",
"String",
"s1",
",",
"String",
"s2",
",",
"int",
"modifier",
")",
"{",
"return",
"!",
"isEqual",
"(",
"s1",
",",
"s2",
",",
"modifier",
")",
";",
"}"
] |
Alias of {@link #isNotEqual(String, String, int)}
@param s1
@param s2
@param modifier
@return true if o1's str not equals o2's str
|
[
"Alias",
"of",
"{",
"@link",
"#isNotEqual",
"(",
"String",
"String",
"int",
")",
"}"
] |
train
|
https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/utils/S.java#L263-L265
|
stripe/stripe-android
|
stripe/src/main/java/com/stripe/android/Stripe.java
|
Stripe.createPiiTokenSynchronous
|
public Token createPiiTokenSynchronous(@NonNull String personalId)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
CardException,
APIException {
"""
Blocking method to create a {@link Token} for PII. Do not call this on the UI thread
or your app will crash. The method uses the currently set {@link #mDefaultPublishableKey}.
@param personalId the personal ID to use for this token
@return a {@link Token} that can be used for this card
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers)
"""
return createPiiTokenSynchronous(personalId, mDefaultPublishableKey);
}
|
java
|
public Token createPiiTokenSynchronous(@NonNull String personalId)
throws AuthenticationException,
InvalidRequestException,
APIConnectionException,
CardException,
APIException {
return createPiiTokenSynchronous(personalId, mDefaultPublishableKey);
}
|
[
"public",
"Token",
"createPiiTokenSynchronous",
"(",
"@",
"NonNull",
"String",
"personalId",
")",
"throws",
"AuthenticationException",
",",
"InvalidRequestException",
",",
"APIConnectionException",
",",
"CardException",
",",
"APIException",
"{",
"return",
"createPiiTokenSynchronous",
"(",
"personalId",
",",
"mDefaultPublishableKey",
")",
";",
"}"
] |
Blocking method to create a {@link Token} for PII. Do not call this on the UI thread
or your app will crash. The method uses the currently set {@link #mDefaultPublishableKey}.
@param personalId the personal ID to use for this token
@return a {@link Token} that can be used for this card
@throws AuthenticationException failure to properly authenticate yourself (check your key)
@throws InvalidRequestException your request has invalid parameters
@throws APIConnectionException failure to connect to Stripe's API
@throws APIException any other type of problem (for instance, a temporary issue with
Stripe's servers)
|
[
"Blocking",
"method",
"to",
"create",
"a",
"{",
"@link",
"Token",
"}",
"for",
"PII",
".",
"Do",
"not",
"call",
"this",
"on",
"the",
"UI",
"thread",
"or",
"your",
"app",
"will",
"crash",
".",
"The",
"method",
"uses",
"the",
"currently",
"set",
"{",
"@link",
"#mDefaultPublishableKey",
"}",
"."
] |
train
|
https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/Stripe.java#L577-L584
|
modelmapper/modelmapper
|
core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java
|
PropertyInfoRegistry.accessorFor
|
static Accessor accessorFor(Class<?> type, String accessorName, InheritingConfiguration configuration) {
"""
Returns an accessor for the {@code accessorName}, else {@code null} if none exists.
"""
PropertyInfoKey key = new PropertyInfoKey(type, accessorName, configuration);
if (!ACCESSOR_CACHE.containsKey(key) || !FIELD_CACHE.containsKey(key)) {
@SuppressWarnings("unchecked")
Class<Object> uncheckedType = (Class<Object>) type;
for (Entry<String, Accessor> entry : TypeInfoRegistry.typeInfoFor(uncheckedType, configuration).getAccessors().entrySet()) {
if (entry.getValue().getMember() instanceof Method)
accessorFor(type, (Method) entry.getValue().getMember(), configuration, entry.getKey());
else if (entry.getValue().getMember() instanceof Field)
fieldPropertyFor(type, (Field) entry.getValue().getMember(), configuration, entry.getKey());
}
}
if (ACCESSOR_CACHE.containsKey(key))
return ACCESSOR_CACHE.get(key);
return FIELD_CACHE.get(key);
}
|
java
|
static Accessor accessorFor(Class<?> type, String accessorName, InheritingConfiguration configuration) {
PropertyInfoKey key = new PropertyInfoKey(type, accessorName, configuration);
if (!ACCESSOR_CACHE.containsKey(key) || !FIELD_CACHE.containsKey(key)) {
@SuppressWarnings("unchecked")
Class<Object> uncheckedType = (Class<Object>) type;
for (Entry<String, Accessor> entry : TypeInfoRegistry.typeInfoFor(uncheckedType, configuration).getAccessors().entrySet()) {
if (entry.getValue().getMember() instanceof Method)
accessorFor(type, (Method) entry.getValue().getMember(), configuration, entry.getKey());
else if (entry.getValue().getMember() instanceof Field)
fieldPropertyFor(type, (Field) entry.getValue().getMember(), configuration, entry.getKey());
}
}
if (ACCESSOR_CACHE.containsKey(key))
return ACCESSOR_CACHE.get(key);
return FIELD_CACHE.get(key);
}
|
[
"static",
"Accessor",
"accessorFor",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"accessorName",
",",
"InheritingConfiguration",
"configuration",
")",
"{",
"PropertyInfoKey",
"key",
"=",
"new",
"PropertyInfoKey",
"(",
"type",
",",
"accessorName",
",",
"configuration",
")",
";",
"if",
"(",
"!",
"ACCESSOR_CACHE",
".",
"containsKey",
"(",
"key",
")",
"||",
"!",
"FIELD_CACHE",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"Object",
">",
"uncheckedType",
"=",
"(",
"Class",
"<",
"Object",
">",
")",
"type",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Accessor",
">",
"entry",
":",
"TypeInfoRegistry",
".",
"typeInfoFor",
"(",
"uncheckedType",
",",
"configuration",
")",
".",
"getAccessors",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getMember",
"(",
")",
"instanceof",
"Method",
")",
"accessorFor",
"(",
"type",
",",
"(",
"Method",
")",
"entry",
".",
"getValue",
"(",
")",
".",
"getMember",
"(",
")",
",",
"configuration",
",",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"else",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getMember",
"(",
")",
"instanceof",
"Field",
")",
"fieldPropertyFor",
"(",
"type",
",",
"(",
"Field",
")",
"entry",
".",
"getValue",
"(",
")",
".",
"getMember",
"(",
")",
",",
"configuration",
",",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"ACCESSOR_CACHE",
".",
"containsKey",
"(",
"key",
")",
")",
"return",
"ACCESSOR_CACHE",
".",
"get",
"(",
"key",
")",
";",
"return",
"FIELD_CACHE",
".",
"get",
"(",
"key",
")",
";",
"}"
] |
Returns an accessor for the {@code accessorName}, else {@code null} if none exists.
|
[
"Returns",
"an",
"accessor",
"for",
"the",
"{"
] |
train
|
https://github.com/modelmapper/modelmapper/blob/491d165ded9dc9aba7ce8b56984249e1a1363204/core/src/main/java/org/modelmapper/internal/PropertyInfoRegistry.java#L76-L92
|
landawn/AbacusUtil
|
src/com/landawn/abacus/util/N.java
|
N.checkArgNotNegative
|
public static int checkArgNotNegative(final int arg, final String argNameOrErrorMsg) {
"""
Checks if the specified {@code arg} is not negative, and throws {@code IllegalArgumentException} if it is.
@param arg
@param argNameOrErrorMsg
@throws IllegalArgumentException if the specified {@code arg} is negative.
"""
if (arg < 0) {
if (argNameOrErrorMsg.indexOf(' ') == N.INDEX_NOT_FOUND) {
throw new IllegalArgumentException("'" + argNameOrErrorMsg + "' can not be negative: " + arg);
} else {
throw new IllegalArgumentException(argNameOrErrorMsg);
}
}
return arg;
}
|
java
|
public static int checkArgNotNegative(final int arg, final String argNameOrErrorMsg) {
if (arg < 0) {
if (argNameOrErrorMsg.indexOf(' ') == N.INDEX_NOT_FOUND) {
throw new IllegalArgumentException("'" + argNameOrErrorMsg + "' can not be negative: " + arg);
} else {
throw new IllegalArgumentException(argNameOrErrorMsg);
}
}
return arg;
}
|
[
"public",
"static",
"int",
"checkArgNotNegative",
"(",
"final",
"int",
"arg",
",",
"final",
"String",
"argNameOrErrorMsg",
")",
"{",
"if",
"(",
"arg",
"<",
"0",
")",
"{",
"if",
"(",
"argNameOrErrorMsg",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"N",
".",
"INDEX_NOT_FOUND",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'\"",
"+",
"argNameOrErrorMsg",
"+",
"\"' can not be negative: \"",
"+",
"arg",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"argNameOrErrorMsg",
")",
";",
"}",
"}",
"return",
"arg",
";",
"}"
] |
Checks if the specified {@code arg} is not negative, and throws {@code IllegalArgumentException} if it is.
@param arg
@param argNameOrErrorMsg
@throws IllegalArgumentException if the specified {@code arg} is negative.
|
[
"Checks",
"if",
"the",
"specified",
"{",
"@code",
"arg",
"}",
"is",
"not",
"negative",
"and",
"throws",
"{",
"@code",
"IllegalArgumentException",
"}",
"if",
"it",
"is",
"."
] |
train
|
https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/N.java#L5827-L5837
|
VoltDB/voltdb
|
src/hsqldb19b3/org/hsqldb_voltpatches/lib/DoubleIntIndex.java
|
DoubleIntIndex.addUnique
|
public synchronized boolean addUnique(int key, int value) {
"""
Adds a pair, ensuring no duplicate key xor value already exists in the
current search target column.
@param key the key
@param value the value
@return true or false depending on success
"""
if (count == capacity) {
if (fixedSize) {
return false;
} else {
doubleCapacity();
}
}
if (!sorted) {
fastQuickSort();
}
targetSearchValue = sortOnValues ? value
: key;
int i = binaryEmptySlotSearch();
if (i == -1) {
return false;
}
hasChanged = true;
if (count != i) {
moveRows(i, i + 1, count - i);
}
keys[i] = key;
values[i] = value;
count++;
return true;
}
|
java
|
public synchronized boolean addUnique(int key, int value) {
if (count == capacity) {
if (fixedSize) {
return false;
} else {
doubleCapacity();
}
}
if (!sorted) {
fastQuickSort();
}
targetSearchValue = sortOnValues ? value
: key;
int i = binaryEmptySlotSearch();
if (i == -1) {
return false;
}
hasChanged = true;
if (count != i) {
moveRows(i, i + 1, count - i);
}
keys[i] = key;
values[i] = value;
count++;
return true;
}
|
[
"public",
"synchronized",
"boolean",
"addUnique",
"(",
"int",
"key",
",",
"int",
"value",
")",
"{",
"if",
"(",
"count",
"==",
"capacity",
")",
"{",
"if",
"(",
"fixedSize",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"doubleCapacity",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"sorted",
")",
"{",
"fastQuickSort",
"(",
")",
";",
"}",
"targetSearchValue",
"=",
"sortOnValues",
"?",
"value",
":",
"key",
";",
"int",
"i",
"=",
"binaryEmptySlotSearch",
"(",
")",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"hasChanged",
"=",
"true",
";",
"if",
"(",
"count",
"!=",
"i",
")",
"{",
"moveRows",
"(",
"i",
",",
"i",
"+",
"1",
",",
"count",
"-",
"i",
")",
";",
"}",
"keys",
"[",
"i",
"]",
"=",
"key",
";",
"values",
"[",
"i",
"]",
"=",
"value",
";",
"count",
"++",
";",
"return",
"true",
";",
"}"
] |
Adds a pair, ensuring no duplicate key xor value already exists in the
current search target column.
@param key the key
@param value the value
@return true or false depending on success
|
[
"Adds",
"a",
"pair",
"ensuring",
"no",
"duplicate",
"key",
"xor",
"value",
"already",
"exists",
"in",
"the",
"current",
"search",
"target",
"column",
"."
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/hsqldb19b3/org/hsqldb_voltpatches/lib/DoubleIntIndex.java#L215-L250
|
jbossws/jbossws-common
|
src/main/java/org/jboss/ws/common/invocation/AbstractInvocationHandler.java
|
AbstractInvocationHandler.getImplMethod
|
protected final Method getImplMethod(final Class<?> implClass, final Method seiMethod) throws NoSuchMethodException {
"""
Returns implementation method that will be used for invocation.
@param implClass implementation endpoint class
@param seiMethod SEI interface method used for method finding algorithm
@return implementation method
@throws NoSuchMethodException if implementation method wasn't found
"""
final String methodName = seiMethod.getName();
final Class<?>[] paramTypes = seiMethod.getParameterTypes();
return implClass.getMethod(methodName, paramTypes);
}
|
java
|
protected final Method getImplMethod(final Class<?> implClass, final Method seiMethod) throws NoSuchMethodException
{
final String methodName = seiMethod.getName();
final Class<?>[] paramTypes = seiMethod.getParameterTypes();
return implClass.getMethod(methodName, paramTypes);
}
|
[
"protected",
"final",
"Method",
"getImplMethod",
"(",
"final",
"Class",
"<",
"?",
">",
"implClass",
",",
"final",
"Method",
"seiMethod",
")",
"throws",
"NoSuchMethodException",
"{",
"final",
"String",
"methodName",
"=",
"seiMethod",
".",
"getName",
"(",
")",
";",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"paramTypes",
"=",
"seiMethod",
".",
"getParameterTypes",
"(",
")",
";",
"return",
"implClass",
".",
"getMethod",
"(",
"methodName",
",",
"paramTypes",
")",
";",
"}"
] |
Returns implementation method that will be used for invocation.
@param implClass implementation endpoint class
@param seiMethod SEI interface method used for method finding algorithm
@return implementation method
@throws NoSuchMethodException if implementation method wasn't found
|
[
"Returns",
"implementation",
"method",
"that",
"will",
"be",
"used",
"for",
"invocation",
"."
] |
train
|
https://github.com/jbossws/jbossws-common/blob/fcff8a3ef9bfe046d6fa8c855a3fe4f62841add7/src/main/java/org/jboss/ws/common/invocation/AbstractInvocationHandler.java#L82-L88
|
rometools/rome
|
rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java
|
Publisher.sendUpdateNotificationAsyncronously
|
public void sendUpdateNotificationAsyncronously(final String hub, final String topic, final AsyncNotificationCallback callback) {
"""
Sends the HUB url a notification of a change in topic asynchronously
@param hub URL of the hub to notify.
@param topic The Topic that has changed
@param callback A callback invoked when the notification completes.
@throws NotificationException Any failure
"""
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendUpdateNotification(hub, topic);
callback.onSuccess();
} catch (final Throwable t) {
callback.onFailure(t);
}
}
};
if (executor != null) {
executor.execute(r);
} else {
new Thread(r).start();
}
}
|
java
|
public void sendUpdateNotificationAsyncronously(final String hub, final String topic, final AsyncNotificationCallback callback) {
final Runnable r = new Runnable() {
@Override
public void run() {
try {
sendUpdateNotification(hub, topic);
callback.onSuccess();
} catch (final Throwable t) {
callback.onFailure(t);
}
}
};
if (executor != null) {
executor.execute(r);
} else {
new Thread(r).start();
}
}
|
[
"public",
"void",
"sendUpdateNotificationAsyncronously",
"(",
"final",
"String",
"hub",
",",
"final",
"String",
"topic",
",",
"final",
"AsyncNotificationCallback",
"callback",
")",
"{",
"final",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"sendUpdateNotification",
"(",
"hub",
",",
"topic",
")",
";",
"callback",
".",
"onSuccess",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"t",
")",
"{",
"callback",
".",
"onFailure",
"(",
"t",
")",
";",
"}",
"}",
"}",
";",
"if",
"(",
"executor",
"!=",
"null",
")",
"{",
"executor",
".",
"execute",
"(",
"r",
")",
";",
"}",
"else",
"{",
"new",
"Thread",
"(",
"r",
")",
".",
"start",
"(",
")",
";",
"}",
"}"
] |
Sends the HUB url a notification of a change in topic asynchronously
@param hub URL of the hub to notify.
@param topic The Topic that has changed
@param callback A callback invoked when the notification completes.
@throws NotificationException Any failure
|
[
"Sends",
"the",
"HUB",
"url",
"a",
"notification",
"of",
"a",
"change",
"in",
"topic",
"asynchronously"
] |
train
|
https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-certiorem/src/main/java/com/rometools/certiorem/pub/Publisher.java#L160-L178
|
datasalt/pangool
|
core/src/main/java/com/datasalt/pangool/tuplemr/serialization/SimpleTupleDeserializer.java
|
SimpleTupleDeserializer.readFields
|
public void readFields(ITuple tuple, Deserializer[] customDeserializers) throws IOException {
"""
Read fields using the specified "readSchema" in the constructor.
"""
readFields(tuple, readSchema, customDeserializers);
}
|
java
|
public void readFields(ITuple tuple, Deserializer[] customDeserializers) throws IOException {
readFields(tuple, readSchema, customDeserializers);
}
|
[
"public",
"void",
"readFields",
"(",
"ITuple",
"tuple",
",",
"Deserializer",
"[",
"]",
"customDeserializers",
")",
"throws",
"IOException",
"{",
"readFields",
"(",
"tuple",
",",
"readSchema",
",",
"customDeserializers",
")",
";",
"}"
] |
Read fields using the specified "readSchema" in the constructor.
|
[
"Read",
"fields",
"using",
"the",
"specified",
"readSchema",
"in",
"the",
"constructor",
"."
] |
train
|
https://github.com/datasalt/pangool/blob/bfd312dd78cba03febaf7988ae96a3d4bc585408/core/src/main/java/com/datasalt/pangool/tuplemr/serialization/SimpleTupleDeserializer.java#L138-L140
|
gosu-lang/gosu-lang
|
gosu-core-api/src/main/java/gw/lang/reflect/TypeSystem.java
|
TypeSystem.getByRelativeName
|
public static IType getByRelativeName( String relativeName, ITypeUsesMap typeUses ) throws ClassNotFoundException {
"""
Gets an intrinsic type based on a relative name. This could either be the name of an entity,
like "User", the name of a typekey, like "SystemPermission", or a class name, like
"java.lang.String" (relative and fully qualified class names are the same as far as this factory
is concerned). Names can have [] appended to them to create arrays, and multi-dimensional arrays
are supported.
@param relativeName the relative name of the type
@param typeUses the map of used types to use when resolving
@return the corresponding IType
@throws ClassNotFoundException if the specified name doesn't correspond to any type
"""
return CommonServices.getTypeSystem().getByRelativeName(relativeName, typeUses);
}
|
java
|
public static IType getByRelativeName( String relativeName, ITypeUsesMap typeUses ) throws ClassNotFoundException
{
return CommonServices.getTypeSystem().getByRelativeName(relativeName, typeUses);
}
|
[
"public",
"static",
"IType",
"getByRelativeName",
"(",
"String",
"relativeName",
",",
"ITypeUsesMap",
"typeUses",
")",
"throws",
"ClassNotFoundException",
"{",
"return",
"CommonServices",
".",
"getTypeSystem",
"(",
")",
".",
"getByRelativeName",
"(",
"relativeName",
",",
"typeUses",
")",
";",
"}"
] |
Gets an intrinsic type based on a relative name. This could either be the name of an entity,
like "User", the name of a typekey, like "SystemPermission", or a class name, like
"java.lang.String" (relative and fully qualified class names are the same as far as this factory
is concerned). Names can have [] appended to them to create arrays, and multi-dimensional arrays
are supported.
@param relativeName the relative name of the type
@param typeUses the map of used types to use when resolving
@return the corresponding IType
@throws ClassNotFoundException if the specified name doesn't correspond to any type
|
[
"Gets",
"an",
"intrinsic",
"type",
"based",
"on",
"a",
"relative",
"name",
".",
"This",
"could",
"either",
"be",
"the",
"name",
"of",
"an",
"entity",
"like",
"User",
"the",
"name",
"of",
"a",
"typekey",
"like",
"SystemPermission",
"or",
"a",
"class",
"name",
"like",
"java",
".",
"lang",
".",
"String",
"(",
"relative",
"and",
"fully",
"qualified",
"class",
"names",
"are",
"the",
"same",
"as",
"far",
"as",
"this",
"factory",
"is",
"concerned",
")",
".",
"Names",
"can",
"have",
"[]",
"appended",
"to",
"them",
"to",
"create",
"arrays",
"and",
"multi",
"-",
"dimensional",
"arrays",
"are",
"supported",
"."
] |
train
|
https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/lang/reflect/TypeSystem.java#L134-L137
|
prestodb/presto
|
presto-main/src/main/java/com/facebook/presto/sql/planner/GroupingOperationRewriter.java
|
GroupingOperationRewriter.calculateGrouping
|
static long calculateGrouping(Set<Integer> groupingSet, List<Integer> columns) {
"""
The grouping function is used in conjunction with GROUPING SETS, ROLLUP and CUBE to
indicate which columns are present in that grouping.
<p>The grouping function must be invoked with arguments that exactly match the columns
referenced in the corresponding GROUPING SET, ROLLUP or CUBE clause at the associated
query level. Those column arguments are not evaluated and instead the function is
re-written with the arguments below.
<p>To compute the resulting bit set for a particular row, bits are assigned to the
argument columns with the rightmost column being the most significant bit. For a
given grouping, a bit is set to 0 if the corresponding column is included in the
grouping and 1 otherwise. For an example, see the SQL documentation for the
function.
@param columns The column arguments with which the function was invoked
converted to ordinals with respect to the base table column ordering.
@param groupingSet A collection containing the ordinals of the
columns present in the grouping.
@return A bit set converted to decimal indicating which columns are present in
the grouping. If a column is NOT present in the grouping its corresponding
bit is set to 1 and to 0 if the column is present in the grouping.
"""
long grouping = (1L << columns.size()) - 1;
for (int index = 0; index < columns.size(); index++) {
int column = columns.get(index);
if (groupingSet.contains(column)) {
// Leftmost argument to grouping() (i.e. when index = 0) corresponds to
// the most significant bit in the result. That is why we shift 1L starting
// from the columns.size() - 1 bit index.
grouping = grouping & ~(1L << (columns.size() - 1 - index));
}
}
return grouping;
}
|
java
|
static long calculateGrouping(Set<Integer> groupingSet, List<Integer> columns)
{
long grouping = (1L << columns.size()) - 1;
for (int index = 0; index < columns.size(); index++) {
int column = columns.get(index);
if (groupingSet.contains(column)) {
// Leftmost argument to grouping() (i.e. when index = 0) corresponds to
// the most significant bit in the result. That is why we shift 1L starting
// from the columns.size() - 1 bit index.
grouping = grouping & ~(1L << (columns.size() - 1 - index));
}
}
return grouping;
}
|
[
"static",
"long",
"calculateGrouping",
"(",
"Set",
"<",
"Integer",
">",
"groupingSet",
",",
"List",
"<",
"Integer",
">",
"columns",
")",
"{",
"long",
"grouping",
"=",
"(",
"1L",
"<<",
"columns",
".",
"size",
"(",
")",
")",
"-",
"1",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"columns",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"int",
"column",
"=",
"columns",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"groupingSet",
".",
"contains",
"(",
"column",
")",
")",
"{",
"// Leftmost argument to grouping() (i.e. when index = 0) corresponds to",
"// the most significant bit in the result. That is why we shift 1L starting",
"// from the columns.size() - 1 bit index.",
"grouping",
"=",
"grouping",
"&",
"~",
"(",
"1L",
"<<",
"(",
"columns",
".",
"size",
"(",
")",
"-",
"1",
"-",
"index",
")",
")",
";",
"}",
"}",
"return",
"grouping",
";",
"}"
] |
The grouping function is used in conjunction with GROUPING SETS, ROLLUP and CUBE to
indicate which columns are present in that grouping.
<p>The grouping function must be invoked with arguments that exactly match the columns
referenced in the corresponding GROUPING SET, ROLLUP or CUBE clause at the associated
query level. Those column arguments are not evaluated and instead the function is
re-written with the arguments below.
<p>To compute the resulting bit set for a particular row, bits are assigned to the
argument columns with the rightmost column being the most significant bit. For a
given grouping, a bit is set to 0 if the corresponding column is included in the
grouping and 1 otherwise. For an example, see the SQL documentation for the
function.
@param columns The column arguments with which the function was invoked
converted to ordinals with respect to the base table column ordering.
@param groupingSet A collection containing the ordinals of the
columns present in the grouping.
@return A bit set converted to decimal indicating which columns are present in
the grouping. If a column is NOT present in the grouping its corresponding
bit is set to 1 and to 0 if the column is present in the grouping.
|
[
"The",
"grouping",
"function",
"is",
"used",
"in",
"conjunction",
"with",
"GROUPING",
"SETS",
"ROLLUP",
"and",
"CUBE",
"to",
"indicate",
"which",
"columns",
"are",
"present",
"in",
"that",
"grouping",
"."
] |
train
|
https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/sql/planner/GroupingOperationRewriter.java#L107-L123
|
tiesebarrell/process-assertions
|
process-assertions-api/src/main/java/org/toxos/processassertions/api/internal/MessageLogger.java
|
MessageLogger.logInfo
|
public final void logInfo(final Logger logger, final String messageKey, final Object... objects) {
"""
Logs a message by the provided key to the provided {@link Logger} at info level after substituting the parameters in the message by the provided objects.
@param logger the logger to log to
@param messageKey the key of the message in the bundle
@param objects the substitution parameters
"""
logger.info(getMessage(messageKey, objects));
}
|
java
|
public final void logInfo(final Logger logger, final String messageKey, final Object... objects) {
logger.info(getMessage(messageKey, objects));
}
|
[
"public",
"final",
"void",
"logInfo",
"(",
"final",
"Logger",
"logger",
",",
"final",
"String",
"messageKey",
",",
"final",
"Object",
"...",
"objects",
")",
"{",
"logger",
".",
"info",
"(",
"getMessage",
"(",
"messageKey",
",",
"objects",
")",
")",
";",
"}"
] |
Logs a message by the provided key to the provided {@link Logger} at info level after substituting the parameters in the message by the provided objects.
@param logger the logger to log to
@param messageKey the key of the message in the bundle
@param objects the substitution parameters
|
[
"Logs",
"a",
"message",
"by",
"the",
"provided",
"key",
"to",
"the",
"provided",
"{"
] |
train
|
https://github.com/tiesebarrell/process-assertions/blob/932a8443982e356cdf5a230165a35c725d9306ab/process-assertions-api/src/main/java/org/toxos/processassertions/api/internal/MessageLogger.java#L48-L50
|
cesarferreira/AndroidQuickUtils
|
library/src/main/java/quickutils/core/animations/Fade.java
|
Fade.hideNaughtily
|
public void hideNaughtily(final View view, final int visibility) {
"""
Fades out the specified view and then sets its visibility to the specified
value (either View.INVISIBLE or View.GONE). This is a naughty method as it allows you
to animate from INVISIBLE - GONE or vice versa (which makes sense in some parallel universe).
@param view The view to be hidden
@param visibility The value to which the view's visibility will be set after it fades out.
"""
if (durationSet) {
view.animate().setDuration(duration);
}
view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setAlpha(1);
view.setVisibility(visibility);
view.animate().setListener(null);
}
});
}
|
java
|
public void hideNaughtily(final View view, final int visibility) {
if (durationSet) {
view.animate().setDuration(duration);
}
view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setAlpha(1);
view.setVisibility(visibility);
view.animate().setListener(null);
}
});
}
|
[
"public",
"void",
"hideNaughtily",
"(",
"final",
"View",
"view",
",",
"final",
"int",
"visibility",
")",
"{",
"if",
"(",
"durationSet",
")",
"{",
"view",
".",
"animate",
"(",
")",
".",
"setDuration",
"(",
"duration",
")",
";",
"}",
"view",
".",
"animate",
"(",
")",
".",
"alpha",
"(",
"0f",
")",
".",
"setListener",
"(",
"new",
"AnimatorListenerAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onAnimationEnd",
"(",
"Animator",
"animation",
")",
"{",
"view",
".",
"setAlpha",
"(",
"1",
")",
";",
"view",
".",
"setVisibility",
"(",
"visibility",
")",
";",
"view",
".",
"animate",
"(",
")",
".",
"setListener",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Fades out the specified view and then sets its visibility to the specified
value (either View.INVISIBLE or View.GONE). This is a naughty method as it allows you
to animate from INVISIBLE - GONE or vice versa (which makes sense in some parallel universe).
@param view The view to be hidden
@param visibility The value to which the view's visibility will be set after it fades out.
|
[
"Fades",
"out",
"the",
"specified",
"view",
"and",
"then",
"sets",
"its",
"visibility",
"to",
"the",
"specified",
"value",
"(",
"either",
"View",
".",
"INVISIBLE",
"or",
"View",
".",
"GONE",
")",
".",
"This",
"is",
"a",
"naughty",
"method",
"as",
"it",
"allows",
"you",
"to",
"animate",
"from",
"INVISIBLE",
"-",
"GONE",
"or",
"vice",
"versa",
"(",
"which",
"makes",
"sense",
"in",
"some",
"parallel",
"universe",
")",
"."
] |
train
|
https://github.com/cesarferreira/AndroidQuickUtils/blob/73a91daedbb9f7be7986ea786fbc441c9e5a881c/library/src/main/java/quickutils/core/animations/Fade.java#L110-L122
|
matthewhorridge/owlapi-gwt
|
owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectMaxCardinalityImpl_CustomFieldSerializer.java
|
OWLObjectMaxCardinalityImpl_CustomFieldSerializer.deserializeInstance
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLObjectMaxCardinalityImpl instance) throws SerializationException {
"""
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
"""
deserialize(streamReader, instance);
}
|
java
|
@Override
public void deserializeInstance(SerializationStreamReader streamReader, OWLObjectMaxCardinalityImpl instance) throws SerializationException {
deserialize(streamReader, instance);
}
|
[
"@",
"Override",
"public",
"void",
"deserializeInstance",
"(",
"SerializationStreamReader",
"streamReader",
",",
"OWLObjectMaxCardinalityImpl",
"instance",
")",
"throws",
"SerializationException",
"{",
"deserialize",
"(",
"streamReader",
",",
"instance",
")",
";",
"}"
] |
Deserializes the content of the object from the
{@link com.google.gwt.user.client.rpc.SerializationStreamReader}.
@param streamReader the {@link com.google.gwt.user.client.rpc.SerializationStreamReader} to read the
object's content from
@param instance the object instance to deserialize
@throws com.google.gwt.user.client.rpc.SerializationException
if the deserialization operation is not
successful
|
[
"Deserializes",
"the",
"content",
"of",
"the",
"object",
"from",
"the",
"{",
"@link",
"com",
".",
"google",
".",
"gwt",
".",
"user",
".",
"client",
".",
"rpc",
".",
"SerializationStreamReader",
"}",
"."
] |
train
|
https://github.com/matthewhorridge/owlapi-gwt/blob/7ab975fb6cef3c8947099983551672a3b5d4e2fd/owlapi-gwt-serialization/src/main/java/uk/ac/manchester/cs/owl/owlapi/OWLObjectMaxCardinalityImpl_CustomFieldSerializer.java#L95-L98
|
lessthanoptimal/BoofCV
|
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/QuadPoseEstimator.java
|
QuadPoseEstimator.pixelToMarker
|
public void pixelToMarker( double pixelX , double pixelY , Point2D_F64 marker ) {
"""
Given the found solution, compute the the observed pixel would appear on the marker's surface.
pixel -> normalized pixel -> rotated -> projected on to plane
@param pixelX (Input) pixel coordinate
@param pixelY (Input) pixel coordinate
@param marker (Output) location on the marker
"""
// find pointing vector in camera reference frame
pixelToNorm.compute(pixelX,pixelY,marker);
cameraP3.set(marker.x,marker.y,1);
// rotate into marker reference frame
GeometryMath_F64.multTran(outputFiducialToCamera.R,cameraP3,ray.slope);
GeometryMath_F64.multTran(outputFiducialToCamera.R,outputFiducialToCamera.T,ray.p);
ray.p.scale(-1);
double t = -ray.p.z/ray.slope.z;
marker.x = ray.p.x + ray.slope.x*t;
marker.y = ray.p.y + ray.slope.y*t;
}
|
java
|
public void pixelToMarker( double pixelX , double pixelY , Point2D_F64 marker ) {
// find pointing vector in camera reference frame
pixelToNorm.compute(pixelX,pixelY,marker);
cameraP3.set(marker.x,marker.y,1);
// rotate into marker reference frame
GeometryMath_F64.multTran(outputFiducialToCamera.R,cameraP3,ray.slope);
GeometryMath_F64.multTran(outputFiducialToCamera.R,outputFiducialToCamera.T,ray.p);
ray.p.scale(-1);
double t = -ray.p.z/ray.slope.z;
marker.x = ray.p.x + ray.slope.x*t;
marker.y = ray.p.y + ray.slope.y*t;
}
|
[
"public",
"void",
"pixelToMarker",
"(",
"double",
"pixelX",
",",
"double",
"pixelY",
",",
"Point2D_F64",
"marker",
")",
"{",
"// find pointing vector in camera reference frame",
"pixelToNorm",
".",
"compute",
"(",
"pixelX",
",",
"pixelY",
",",
"marker",
")",
";",
"cameraP3",
".",
"set",
"(",
"marker",
".",
"x",
",",
"marker",
".",
"y",
",",
"1",
")",
";",
"// rotate into marker reference frame",
"GeometryMath_F64",
".",
"multTran",
"(",
"outputFiducialToCamera",
".",
"R",
",",
"cameraP3",
",",
"ray",
".",
"slope",
")",
";",
"GeometryMath_F64",
".",
"multTran",
"(",
"outputFiducialToCamera",
".",
"R",
",",
"outputFiducialToCamera",
".",
"T",
",",
"ray",
".",
"p",
")",
";",
"ray",
".",
"p",
".",
"scale",
"(",
"-",
"1",
")",
";",
"double",
"t",
"=",
"-",
"ray",
".",
"p",
".",
"z",
"/",
"ray",
".",
"slope",
".",
"z",
";",
"marker",
".",
"x",
"=",
"ray",
".",
"p",
".",
"x",
"+",
"ray",
".",
"slope",
".",
"x",
"*",
"t",
";",
"marker",
".",
"y",
"=",
"ray",
".",
"p",
".",
"y",
"+",
"ray",
".",
"slope",
".",
"y",
"*",
"t",
";",
"}"
] |
Given the found solution, compute the the observed pixel would appear on the marker's surface.
pixel -> normalized pixel -> rotated -> projected on to plane
@param pixelX (Input) pixel coordinate
@param pixelY (Input) pixel coordinate
@param marker (Output) location on the marker
|
[
"Given",
"the",
"found",
"solution",
"compute",
"the",
"the",
"observed",
"pixel",
"would",
"appear",
"on",
"the",
"marker",
"s",
"surface",
".",
"pixel",
"-",
">",
"normalized",
"pixel",
"-",
">",
"rotated",
"-",
">",
"projected",
"on",
"to",
"plane"
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/QuadPoseEstimator.java#L156-L171
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/BugInstance.java
|
BugInstance.addMethod
|
@Nonnull
public BugInstance addMethod(JavaClass javaClass, Method method) {
"""
Add a method annotation. If this is the first method annotation added, it
becomes the primary method annotation. If the method has source line
information, then a SourceLineAnnotation is added to the method.
@param javaClass
the class the method is defined in
@param method
the method
@return this object
"""
MethodAnnotation methodAnnotation = new MethodAnnotation(javaClass.getClassName(), method.getName(),
method.getSignature(), method.isStatic());
SourceLineAnnotation methodSourceLines = SourceLineAnnotation.forEntireMethod(javaClass, method);
methodAnnotation.setSourceLines(methodSourceLines);
addMethod(methodAnnotation);
return this;
}
|
java
|
@Nonnull
public BugInstance addMethod(JavaClass javaClass, Method method) {
MethodAnnotation methodAnnotation = new MethodAnnotation(javaClass.getClassName(), method.getName(),
method.getSignature(), method.isStatic());
SourceLineAnnotation methodSourceLines = SourceLineAnnotation.forEntireMethod(javaClass, method);
methodAnnotation.setSourceLines(methodSourceLines);
addMethod(methodAnnotation);
return this;
}
|
[
"@",
"Nonnull",
"public",
"BugInstance",
"addMethod",
"(",
"JavaClass",
"javaClass",
",",
"Method",
"method",
")",
"{",
"MethodAnnotation",
"methodAnnotation",
"=",
"new",
"MethodAnnotation",
"(",
"javaClass",
".",
"getClassName",
"(",
")",
",",
"method",
".",
"getName",
"(",
")",
",",
"method",
".",
"getSignature",
"(",
")",
",",
"method",
".",
"isStatic",
"(",
")",
")",
";",
"SourceLineAnnotation",
"methodSourceLines",
"=",
"SourceLineAnnotation",
".",
"forEntireMethod",
"(",
"javaClass",
",",
"method",
")",
";",
"methodAnnotation",
".",
"setSourceLines",
"(",
"methodSourceLines",
")",
";",
"addMethod",
"(",
"methodAnnotation",
")",
";",
"return",
"this",
";",
"}"
] |
Add a method annotation. If this is the first method annotation added, it
becomes the primary method annotation. If the method has source line
information, then a SourceLineAnnotation is added to the method.
@param javaClass
the class the method is defined in
@param method
the method
@return this object
|
[
"Add",
"a",
"method",
"annotation",
".",
"If",
"this",
"is",
"the",
"first",
"method",
"annotation",
"added",
"it",
"becomes",
"the",
"primary",
"method",
"annotation",
".",
"If",
"the",
"method",
"has",
"source",
"line",
"information",
"then",
"a",
"SourceLineAnnotation",
"is",
"added",
"to",
"the",
"method",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugInstance.java#L1363-L1371
|
apereo/cas
|
support/cas-server-support-saml/src/main/java/org/apereo/cas/support/saml/authentication/SamlResponseBuilder.java
|
SamlResponseBuilder.createResponse
|
public Response createResponse(final String serviceId, final WebApplicationService service) {
"""
Create response.
@param serviceId the service id
@param service the service
@return the response
"""
return this.samlObjectBuilder.newResponse(
this.samlObjectBuilder.generateSecureRandomId(),
ZonedDateTime.now(ZoneOffset.UTC).minusSeconds(this.skewAllowance), serviceId, service);
}
|
java
|
public Response createResponse(final String serviceId, final WebApplicationService service) {
return this.samlObjectBuilder.newResponse(
this.samlObjectBuilder.generateSecureRandomId(),
ZonedDateTime.now(ZoneOffset.UTC).minusSeconds(this.skewAllowance), serviceId, service);
}
|
[
"public",
"Response",
"createResponse",
"(",
"final",
"String",
"serviceId",
",",
"final",
"WebApplicationService",
"service",
")",
"{",
"return",
"this",
".",
"samlObjectBuilder",
".",
"newResponse",
"(",
"this",
".",
"samlObjectBuilder",
".",
"generateSecureRandomId",
"(",
")",
",",
"ZonedDateTime",
".",
"now",
"(",
"ZoneOffset",
".",
"UTC",
")",
".",
"minusSeconds",
"(",
"this",
".",
"skewAllowance",
")",
",",
"serviceId",
",",
"service",
")",
";",
"}"
] |
Create response.
@param serviceId the service id
@param service the service
@return the response
|
[
"Create",
"response",
"."
] |
train
|
https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/support/cas-server-support-saml/src/main/java/org/apereo/cas/support/saml/authentication/SamlResponseBuilder.java#L52-L56
|
google/error-prone-javac
|
src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
|
MessageRetriever.getText
|
public String getText(String key, Object... args) throws MissingResourceException {
"""
Get and format message string from resource
@param key selects message from resource
@param args arguments to be replaced in the message.
@throws MissingResourceException when the key does not
exist in the properties file.
"""
ResourceBundle bundle = initRB();
String message = bundle.getString(key);
return MessageFormat.format(message, args);
}
|
java
|
public String getText(String key, Object... args) throws MissingResourceException {
ResourceBundle bundle = initRB();
String message = bundle.getString(key);
return MessageFormat.format(message, args);
}
|
[
"public",
"String",
"getText",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"throws",
"MissingResourceException",
"{",
"ResourceBundle",
"bundle",
"=",
"initRB",
"(",
")",
";",
"String",
"message",
"=",
"bundle",
".",
"getString",
"(",
"key",
")",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"message",
",",
"args",
")",
";",
"}"
] |
Get and format message string from resource
@param key selects message from resource
@param args arguments to be replaced in the message.
@throws MissingResourceException when the key does not
exist in the properties file.
|
[
"Get",
"and",
"format",
"message",
"string",
"from",
"resource"
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java#L123-L127
|
cloudinary/cloudinary_java
|
cloudinary-core/src/main/java/com/cloudinary/Api.java
|
Api.getStreamingProfile
|
public ApiResponse getStreamingProfile(String name, Map options) throws Exception {
"""
Get a streaming profile information
@param name the name of the profile to fetch
@param options additional options
@return a streaming profile
@throws Exception an exception
"""
if (options == null)
options = ObjectUtils.emptyMap();
List<String> uri = Arrays.asList("streaming_profiles", name);
return callApi(HttpMethod.GET, uri, ObjectUtils.emptyMap(), options);
}
|
java
|
public ApiResponse getStreamingProfile(String name, Map options) throws Exception {
if (options == null)
options = ObjectUtils.emptyMap();
List<String> uri = Arrays.asList("streaming_profiles", name);
return callApi(HttpMethod.GET, uri, ObjectUtils.emptyMap(), options);
}
|
[
"public",
"ApiResponse",
"getStreamingProfile",
"(",
"String",
"name",
",",
"Map",
"options",
")",
"throws",
"Exception",
"{",
"if",
"(",
"options",
"==",
"null",
")",
"options",
"=",
"ObjectUtils",
".",
"emptyMap",
"(",
")",
";",
"List",
"<",
"String",
">",
"uri",
"=",
"Arrays",
".",
"asList",
"(",
"\"streaming_profiles\"",
",",
"name",
")",
";",
"return",
"callApi",
"(",
"HttpMethod",
".",
"GET",
",",
"uri",
",",
"ObjectUtils",
".",
"emptyMap",
"(",
")",
",",
"options",
")",
";",
"}"
] |
Get a streaming profile information
@param name the name of the profile to fetch
@param options additional options
@return a streaming profile
@throws Exception an exception
|
[
"Get",
"a",
"streaming",
"profile",
"information"
] |
train
|
https://github.com/cloudinary/cloudinary_java/blob/58ee1823180da2dea6a2eb7e5cf00d5a760f8aef/cloudinary-core/src/main/java/com/cloudinary/Api.java#L380-L387
|
citrusframework/citrus
|
modules/citrus-mail/src/main/java/com/consol/citrus/mail/message/MailMessageConverter.java
|
MailMessageConverter.createMailRequest
|
protected MailMessage createMailRequest(Map<String, Object> messageHeaders, BodyPart bodyPart, MailEndpointConfiguration endpointConfiguration) {
"""
Creates a new mail message model object from message headers.
@param messageHeaders
@param bodyPart
@param endpointConfiguration
@return
"""
return MailMessage.request(messageHeaders)
.marshaller(endpointConfiguration.getMarshaller())
.from(messageHeaders.get(CitrusMailMessageHeaders.MAIL_FROM).toString())
.to(messageHeaders.get(CitrusMailMessageHeaders.MAIL_TO).toString())
.cc(messageHeaders.get(CitrusMailMessageHeaders.MAIL_CC).toString())
.bcc(messageHeaders.get(CitrusMailMessageHeaders.MAIL_BCC).toString())
.subject(messageHeaders.get(CitrusMailMessageHeaders.MAIL_SUBJECT).toString())
.body(bodyPart);
}
|
java
|
protected MailMessage createMailRequest(Map<String, Object> messageHeaders, BodyPart bodyPart, MailEndpointConfiguration endpointConfiguration) {
return MailMessage.request(messageHeaders)
.marshaller(endpointConfiguration.getMarshaller())
.from(messageHeaders.get(CitrusMailMessageHeaders.MAIL_FROM).toString())
.to(messageHeaders.get(CitrusMailMessageHeaders.MAIL_TO).toString())
.cc(messageHeaders.get(CitrusMailMessageHeaders.MAIL_CC).toString())
.bcc(messageHeaders.get(CitrusMailMessageHeaders.MAIL_BCC).toString())
.subject(messageHeaders.get(CitrusMailMessageHeaders.MAIL_SUBJECT).toString())
.body(bodyPart);
}
|
[
"protected",
"MailMessage",
"createMailRequest",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"messageHeaders",
",",
"BodyPart",
"bodyPart",
",",
"MailEndpointConfiguration",
"endpointConfiguration",
")",
"{",
"return",
"MailMessage",
".",
"request",
"(",
"messageHeaders",
")",
".",
"marshaller",
"(",
"endpointConfiguration",
".",
"getMarshaller",
"(",
")",
")",
".",
"from",
"(",
"messageHeaders",
".",
"get",
"(",
"CitrusMailMessageHeaders",
".",
"MAIL_FROM",
")",
".",
"toString",
"(",
")",
")",
".",
"to",
"(",
"messageHeaders",
".",
"get",
"(",
"CitrusMailMessageHeaders",
".",
"MAIL_TO",
")",
".",
"toString",
"(",
")",
")",
".",
"cc",
"(",
"messageHeaders",
".",
"get",
"(",
"CitrusMailMessageHeaders",
".",
"MAIL_CC",
")",
".",
"toString",
"(",
")",
")",
".",
"bcc",
"(",
"messageHeaders",
".",
"get",
"(",
"CitrusMailMessageHeaders",
".",
"MAIL_BCC",
")",
".",
"toString",
"(",
")",
")",
".",
"subject",
"(",
"messageHeaders",
".",
"get",
"(",
"CitrusMailMessageHeaders",
".",
"MAIL_SUBJECT",
")",
".",
"toString",
"(",
")",
")",
".",
"body",
"(",
"bodyPart",
")",
";",
"}"
] |
Creates a new mail message model object from message headers.
@param messageHeaders
@param bodyPart
@param endpointConfiguration
@return
|
[
"Creates",
"a",
"new",
"mail",
"message",
"model",
"object",
"from",
"message",
"headers",
"."
] |
train
|
https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-mail/src/main/java/com/consol/citrus/mail/message/MailMessageConverter.java#L126-L135
|
jmeetsma/Iglu-Util
|
src/main/java/org/ijsberg/iglu/util/io/FileSupport.java
|
FileSupport.copyFile
|
public static void copyFile(String fileName, String newFileName, boolean overwriteExisting) throws IOException {
"""
Copies a file.
@param fileName
@param newFileName
@param overwriteExisting
@throws IOException
"""
copyFile(new File(fileName), newFileName, overwriteExisting);
}
|
java
|
public static void copyFile(String fileName, String newFileName, boolean overwriteExisting) throws IOException {
copyFile(new File(fileName), newFileName, overwriteExisting);
}
|
[
"public",
"static",
"void",
"copyFile",
"(",
"String",
"fileName",
",",
"String",
"newFileName",
",",
"boolean",
"overwriteExisting",
")",
"throws",
"IOException",
"{",
"copyFile",
"(",
"new",
"File",
"(",
"fileName",
")",
",",
"newFileName",
",",
"overwriteExisting",
")",
";",
"}"
] |
Copies a file.
@param fileName
@param newFileName
@param overwriteExisting
@throws IOException
|
[
"Copies",
"a",
"file",
"."
] |
train
|
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/io/FileSupport.java#L583-L585
|
3redronin/mu-server
|
src/main/java/io/muserver/Cookie.java
|
Cookie.secureCookie
|
@Deprecated
public static Cookie secureCookie(String name, String value) {
"""
<p>Creates a new cookie with secure settings such as HttpOnly and Secure set to true.</p>
@param name The name of the cookie
@param value The value of the cookie
@return Returns a new cookie that can be sent to the response
@deprecated Please use {@link CookieBuilder#newSecureCookie()} instead
"""
return CookieBuilder.newSecureCookie()
.withName(name)
.withValue(value)
.build();
}
|
java
|
@Deprecated
public static Cookie secureCookie(String name, String value) {
return CookieBuilder.newSecureCookie()
.withName(name)
.withValue(value)
.build();
}
|
[
"@",
"Deprecated",
"public",
"static",
"Cookie",
"secureCookie",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"return",
"CookieBuilder",
".",
"newSecureCookie",
"(",
")",
".",
"withName",
"(",
"name",
")",
".",
"withValue",
"(",
"value",
")",
".",
"build",
"(",
")",
";",
"}"
] |
<p>Creates a new cookie with secure settings such as HttpOnly and Secure set to true.</p>
@param name The name of the cookie
@param value The value of the cookie
@return Returns a new cookie that can be sent to the response
@deprecated Please use {@link CookieBuilder#newSecureCookie()} instead
|
[
"<p",
">",
"Creates",
"a",
"new",
"cookie",
"with",
"secure",
"settings",
"such",
"as",
"HttpOnly",
"and",
"Secure",
"set",
"to",
"true",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/3redronin/mu-server/blob/51598606a3082a121fbd785348ee9770b40308e6/src/main/java/io/muserver/Cookie.java#L23-L29
|
google/error-prone-javac
|
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java
|
PackageSummaryBuilder.getInstance
|
public static PackageSummaryBuilder getInstance(Context context,
PackageElement pkg, PackageSummaryWriter packageWriter) {
"""
Construct a new PackageSummaryBuilder.
@param context the build context.
@param pkg the package being documented.
@param packageWriter the doclet specific writer that will output the
result.
@return an instance of a PackageSummaryBuilder.
"""
return new PackageSummaryBuilder(context, pkg, packageWriter);
}
|
java
|
public static PackageSummaryBuilder getInstance(Context context,
PackageElement pkg, PackageSummaryWriter packageWriter) {
return new PackageSummaryBuilder(context, pkg, packageWriter);
}
|
[
"public",
"static",
"PackageSummaryBuilder",
"getInstance",
"(",
"Context",
"context",
",",
"PackageElement",
"pkg",
",",
"PackageSummaryWriter",
"packageWriter",
")",
"{",
"return",
"new",
"PackageSummaryBuilder",
"(",
"context",
",",
"pkg",
",",
"packageWriter",
")",
";",
"}"
] |
Construct a new PackageSummaryBuilder.
@param context the build context.
@param pkg the package being documented.
@param packageWriter the doclet specific writer that will output the
result.
@return an instance of a PackageSummaryBuilder.
|
[
"Construct",
"a",
"new",
"PackageSummaryBuilder",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java#L99-L102
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.audit.source/src/com/ibm/ws/security/audit/encryption/AuditEncryptionImpl.java
|
AuditEncryptionImpl.getInstance
|
public static AuditEncryptionImpl getInstance(String keyStoreName, String keyStorePath, String keyStoreType, String keyStoreProvider,
String keyStorePassword, String keyAlias) throws AuditEncryptionException {
"""
<p>
The <code>getInstance</code> method returns initializes the AuditEncryption implementation
</p>
@param String representing the non-fully qualified keystore name
@param String representing the path to the keystore
@param String representing the keystore type
@param String representing the keystore provider
@param String representing the password for the keystore
@param String representing the alias for the keystore entry
@return instance of the <code>AuditEncryption</code> object
"""
try {
if (ae == null)
ae = new AuditEncryptionImpl(keyStoreName, keyStorePath, keyStoreType, keyStoreProvider, keyStorePassword, keyAlias);
return ae;
} catch (AuditEncryptionException e) {
throw new AuditEncryptionException(e);
}
}
|
java
|
public static AuditEncryptionImpl getInstance(String keyStoreName, String keyStorePath, String keyStoreType, String keyStoreProvider,
String keyStorePassword, String keyAlias) throws AuditEncryptionException {
try {
if (ae == null)
ae = new AuditEncryptionImpl(keyStoreName, keyStorePath, keyStoreType, keyStoreProvider, keyStorePassword, keyAlias);
return ae;
} catch (AuditEncryptionException e) {
throw new AuditEncryptionException(e);
}
}
|
[
"public",
"static",
"AuditEncryptionImpl",
"getInstance",
"(",
"String",
"keyStoreName",
",",
"String",
"keyStorePath",
",",
"String",
"keyStoreType",
",",
"String",
"keyStoreProvider",
",",
"String",
"keyStorePassword",
",",
"String",
"keyAlias",
")",
"throws",
"AuditEncryptionException",
"{",
"try",
"{",
"if",
"(",
"ae",
"==",
"null",
")",
"ae",
"=",
"new",
"AuditEncryptionImpl",
"(",
"keyStoreName",
",",
"keyStorePath",
",",
"keyStoreType",
",",
"keyStoreProvider",
",",
"keyStorePassword",
",",
"keyAlias",
")",
";",
"return",
"ae",
";",
"}",
"catch",
"(",
"AuditEncryptionException",
"e",
")",
"{",
"throw",
"new",
"AuditEncryptionException",
"(",
"e",
")",
";",
"}",
"}"
] |
<p>
The <code>getInstance</code> method returns initializes the AuditEncryption implementation
</p>
@param String representing the non-fully qualified keystore name
@param String representing the path to the keystore
@param String representing the keystore type
@param String representing the keystore provider
@param String representing the password for the keystore
@param String representing the alias for the keystore entry
@return instance of the <code>AuditEncryption</code> object
|
[
"<p",
">",
"The",
"<code",
">",
"getInstance<",
"/",
"code",
">",
"method",
"returns",
"initializes",
"the",
"AuditEncryption",
"implementation",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.audit.source/src/com/ibm/ws/security/audit/encryption/AuditEncryptionImpl.java#L77-L87
|
wcm-io/wcm-io-handler
|
media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java
|
DefaultRenditionHandler.isSizeMatchingRequest
|
private boolean isSizeMatchingRequest(MediaArgs mediaArgs, String[] requestedFileExtensions) {
"""
Checks if the media args contain any with/height restriction, that means a rendition matching
the given size constraints is requested. Additionally it is checked that at least one image file
extension is requested.
@param mediaArgs Media arguments
@return true if any size restriction was defined.
"""
// check that at least one image file extension is in the list of requested extensions
boolean anyImageFileExtension = false;
for (String fileExtension : requestedFileExtensions) {
if (FileExtension.isImage(fileExtension)) {
anyImageFileExtension = true;
}
}
if (!anyImageFileExtension && mediaArgs.getFixedWidth() == 0 && mediaArgs.getFixedHeight() == 0) {
return false;
}
// check for size restriction
if (mediaArgs.getFixedWidth() > 0 || mediaArgs.getFixedHeight() > 0) {
return true;
}
Boolean isSizeMatchingMediaFormat = visitMediaFormats(mediaArgs, new MediaFormatVisitor<Boolean>() {
@Override
public Boolean visit(MediaFormat mediaFormat) {
if (mediaFormat.getEffectiveMinWidth() > 0
|| mediaFormat.getEffectiveMaxWidth() > 0
|| mediaFormat.getEffectiveMinHeight() > 0
|| mediaFormat.getEffectiveMaxHeight() > 0
|| mediaFormat.getRatio() > 0) {
return true;
}
return null;
}
});
return isSizeMatchingMediaFormat != null && isSizeMatchingMediaFormat.booleanValue();
}
|
java
|
private boolean isSizeMatchingRequest(MediaArgs mediaArgs, String[] requestedFileExtensions) {
// check that at least one image file extension is in the list of requested extensions
boolean anyImageFileExtension = false;
for (String fileExtension : requestedFileExtensions) {
if (FileExtension.isImage(fileExtension)) {
anyImageFileExtension = true;
}
}
if (!anyImageFileExtension && mediaArgs.getFixedWidth() == 0 && mediaArgs.getFixedHeight() == 0) {
return false;
}
// check for size restriction
if (mediaArgs.getFixedWidth() > 0 || mediaArgs.getFixedHeight() > 0) {
return true;
}
Boolean isSizeMatchingMediaFormat = visitMediaFormats(mediaArgs, new MediaFormatVisitor<Boolean>() {
@Override
public Boolean visit(MediaFormat mediaFormat) {
if (mediaFormat.getEffectiveMinWidth() > 0
|| mediaFormat.getEffectiveMaxWidth() > 0
|| mediaFormat.getEffectiveMinHeight() > 0
|| mediaFormat.getEffectiveMaxHeight() > 0
|| mediaFormat.getRatio() > 0) {
return true;
}
return null;
}
});
return isSizeMatchingMediaFormat != null && isSizeMatchingMediaFormat.booleanValue();
}
|
[
"private",
"boolean",
"isSizeMatchingRequest",
"(",
"MediaArgs",
"mediaArgs",
",",
"String",
"[",
"]",
"requestedFileExtensions",
")",
"{",
"// check that at least one image file extension is in the list of requested extensions",
"boolean",
"anyImageFileExtension",
"=",
"false",
";",
"for",
"(",
"String",
"fileExtension",
":",
"requestedFileExtensions",
")",
"{",
"if",
"(",
"FileExtension",
".",
"isImage",
"(",
"fileExtension",
")",
")",
"{",
"anyImageFileExtension",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"anyImageFileExtension",
"&&",
"mediaArgs",
".",
"getFixedWidth",
"(",
")",
"==",
"0",
"&&",
"mediaArgs",
".",
"getFixedHeight",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// check for size restriction",
"if",
"(",
"mediaArgs",
".",
"getFixedWidth",
"(",
")",
">",
"0",
"||",
"mediaArgs",
".",
"getFixedHeight",
"(",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"Boolean",
"isSizeMatchingMediaFormat",
"=",
"visitMediaFormats",
"(",
"mediaArgs",
",",
"new",
"MediaFormatVisitor",
"<",
"Boolean",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Boolean",
"visit",
"(",
"MediaFormat",
"mediaFormat",
")",
"{",
"if",
"(",
"mediaFormat",
".",
"getEffectiveMinWidth",
"(",
")",
">",
"0",
"||",
"mediaFormat",
".",
"getEffectiveMaxWidth",
"(",
")",
">",
"0",
"||",
"mediaFormat",
".",
"getEffectiveMinHeight",
"(",
")",
">",
"0",
"||",
"mediaFormat",
".",
"getEffectiveMaxHeight",
"(",
")",
">",
"0",
"||",
"mediaFormat",
".",
"getRatio",
"(",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"null",
";",
"}",
"}",
")",
";",
"return",
"isSizeMatchingMediaFormat",
"!=",
"null",
"&&",
"isSizeMatchingMediaFormat",
".",
"booleanValue",
"(",
")",
";",
"}"
] |
Checks if the media args contain any with/height restriction, that means a rendition matching
the given size constraints is requested. Additionally it is checked that at least one image file
extension is requested.
@param mediaArgs Media arguments
@return true if any size restriction was defined.
|
[
"Checks",
"if",
"the",
"media",
"args",
"contain",
"any",
"with",
"/",
"height",
"restriction",
"that",
"means",
"a",
"rendition",
"matching",
"the",
"given",
"size",
"constraints",
"is",
"requested",
".",
"Additionally",
"it",
"is",
"checked",
"that",
"at",
"least",
"one",
"image",
"file",
"extension",
"is",
"requested",
"."
] |
train
|
https://github.com/wcm-io/wcm-io-handler/blob/b0fc1c11a3ceb89efb73826dcfd480d6a00c19af/media/src/main/java/io/wcm/handler/mediasource/dam/impl/DefaultRenditionHandler.java#L245-L276
|
Polidea/RxAndroidBle
|
rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java
|
ValueInterpreter.getIntValue
|
public static Integer getIntValue(@NonNull byte[] value, @IntFormatType int formatType, @IntRange(from = 0) int offset) {
"""
Return the integer value interpreted from the passed byte array.
<p>The formatType parameter determines how the value
is to be interpreted. For example, setting formatType to
{@link #FORMAT_UINT16} specifies that the first two bytes of the
characteristic value at the given offset are interpreted to generate the
return value.
@param value The byte array from which to interpret value.
@param formatType The format type used to interpret the value.
@param offset Offset at which the integer value can be found.
@return The value at a given offset or null if offset exceeds value size.
"""
if ((offset + getTypeLen(formatType)) > value.length) {
RxBleLog.w(
"Int formatType (0x%x) is longer than remaining bytes (%d) - returning null", formatType, value.length - offset
);
return null;
}
switch (formatType) {
case FORMAT_UINT8:
return unsignedByteToInt(value[offset]);
case FORMAT_UINT16:
return unsignedBytesToInt(value[offset], value[offset + 1]);
case FORMAT_UINT32:
return unsignedBytesToInt(value[offset], value[offset + 1],
value[offset + 2], value[offset + 3]);
case FORMAT_SINT8:
return unsignedToSigned(unsignedByteToInt(value[offset]), 8);
case FORMAT_SINT16:
return unsignedToSigned(unsignedBytesToInt(value[offset],
value[offset + 1]), 16);
case FORMAT_SINT32:
return unsignedToSigned(unsignedBytesToInt(value[offset],
value[offset + 1], value[offset + 2], value[offset + 3]), 32);
default:
RxBleLog.w("Passed an invalid integer formatType (0x%x) - returning null", formatType);
return null;
}
}
|
java
|
public static Integer getIntValue(@NonNull byte[] value, @IntFormatType int formatType, @IntRange(from = 0) int offset) {
if ((offset + getTypeLen(formatType)) > value.length) {
RxBleLog.w(
"Int formatType (0x%x) is longer than remaining bytes (%d) - returning null", formatType, value.length - offset
);
return null;
}
switch (formatType) {
case FORMAT_UINT8:
return unsignedByteToInt(value[offset]);
case FORMAT_UINT16:
return unsignedBytesToInt(value[offset], value[offset + 1]);
case FORMAT_UINT32:
return unsignedBytesToInt(value[offset], value[offset + 1],
value[offset + 2], value[offset + 3]);
case FORMAT_SINT8:
return unsignedToSigned(unsignedByteToInt(value[offset]), 8);
case FORMAT_SINT16:
return unsignedToSigned(unsignedBytesToInt(value[offset],
value[offset + 1]), 16);
case FORMAT_SINT32:
return unsignedToSigned(unsignedBytesToInt(value[offset],
value[offset + 1], value[offset + 2], value[offset + 3]), 32);
default:
RxBleLog.w("Passed an invalid integer formatType (0x%x) - returning null", formatType);
return null;
}
}
|
[
"public",
"static",
"Integer",
"getIntValue",
"(",
"@",
"NonNull",
"byte",
"[",
"]",
"value",
",",
"@",
"IntFormatType",
"int",
"formatType",
",",
"@",
"IntRange",
"(",
"from",
"=",
"0",
")",
"int",
"offset",
")",
"{",
"if",
"(",
"(",
"offset",
"+",
"getTypeLen",
"(",
"formatType",
")",
")",
">",
"value",
".",
"length",
")",
"{",
"RxBleLog",
".",
"w",
"(",
"\"Int formatType (0x%x) is longer than remaining bytes (%d) - returning null\"",
",",
"formatType",
",",
"value",
".",
"length",
"-",
"offset",
")",
";",
"return",
"null",
";",
"}",
"switch",
"(",
"formatType",
")",
"{",
"case",
"FORMAT_UINT8",
":",
"return",
"unsignedByteToInt",
"(",
"value",
"[",
"offset",
"]",
")",
";",
"case",
"FORMAT_UINT16",
":",
"return",
"unsignedBytesToInt",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
")",
";",
"case",
"FORMAT_UINT32",
":",
"return",
"unsignedBytesToInt",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
",",
"value",
"[",
"offset",
"+",
"2",
"]",
",",
"value",
"[",
"offset",
"+",
"3",
"]",
")",
";",
"case",
"FORMAT_SINT8",
":",
"return",
"unsignedToSigned",
"(",
"unsignedByteToInt",
"(",
"value",
"[",
"offset",
"]",
")",
",",
"8",
")",
";",
"case",
"FORMAT_SINT16",
":",
"return",
"unsignedToSigned",
"(",
"unsignedBytesToInt",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
")",
",",
"16",
")",
";",
"case",
"FORMAT_SINT32",
":",
"return",
"unsignedToSigned",
"(",
"unsignedBytesToInt",
"(",
"value",
"[",
"offset",
"]",
",",
"value",
"[",
"offset",
"+",
"1",
"]",
",",
"value",
"[",
"offset",
"+",
"2",
"]",
",",
"value",
"[",
"offset",
"+",
"3",
"]",
")",
",",
"32",
")",
";",
"default",
":",
"RxBleLog",
".",
"w",
"(",
"\"Passed an invalid integer formatType (0x%x) - returning null\"",
",",
"formatType",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Return the integer value interpreted from the passed byte array.
<p>The formatType parameter determines how the value
is to be interpreted. For example, setting formatType to
{@link #FORMAT_UINT16} specifies that the first two bytes of the
characteristic value at the given offset are interpreted to generate the
return value.
@param value The byte array from which to interpret value.
@param formatType The format type used to interpret the value.
@param offset Offset at which the integer value can be found.
@return The value at a given offset or null if offset exceeds value size.
|
[
"Return",
"the",
"integer",
"value",
"interpreted",
"from",
"the",
"passed",
"byte",
"array",
"."
] |
train
|
https://github.com/Polidea/RxAndroidBle/blob/c6e4a9753c834d710e255306bb290e9244cdbc10/rxandroidble/src/main/java/com/polidea/rxandroidble2/helpers/ValueInterpreter.java#L94-L126
|
cchantep/acolyte
|
jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java
|
Java8CompositeHandler.withQueryHandler2
|
public <T> Java8CompositeHandler withQueryHandler2(ScalarQueryHandler<T> h) {
"""
Returns handler that delegates query execution to |h| function.
Given function will be used only if executed statement is detected
as a query by withQueryDetection.
@param h the new query handler
<pre>
{@code
import acolyte.jdbc.StatementHandler.Parameter;
import static acolyte.jdbc.AcolyteDSL.handleStatement;
handleStatement.withQueryHandler2((String sql, List<Parameter> ps) -> {
if (sql == "SELECT * FROM Test WHERE id = ?") return "Foo";
else return "Bar";
});
}
</pre>
"""
final QueryHandler qh = new QueryHandler() {
public QueryResult apply(String sql, List<Parameter> ps)
throws SQLException {
return RowLists.scalar(h.apply(sql, ps)).asResult();
}
};
return withQueryHandler(qh);
}
|
java
|
public <T> Java8CompositeHandler withQueryHandler2(ScalarQueryHandler<T> h) {
final QueryHandler qh = new QueryHandler() {
public QueryResult apply(String sql, List<Parameter> ps)
throws SQLException {
return RowLists.scalar(h.apply(sql, ps)).asResult();
}
};
return withQueryHandler(qh);
}
|
[
"public",
"<",
"T",
">",
"Java8CompositeHandler",
"withQueryHandler2",
"(",
"ScalarQueryHandler",
"<",
"T",
">",
"h",
")",
"{",
"final",
"QueryHandler",
"qh",
"=",
"new",
"QueryHandler",
"(",
")",
"{",
"public",
"QueryResult",
"apply",
"(",
"String",
"sql",
",",
"List",
"<",
"Parameter",
">",
"ps",
")",
"throws",
"SQLException",
"{",
"return",
"RowLists",
".",
"scalar",
"(",
"h",
".",
"apply",
"(",
"sql",
",",
"ps",
")",
")",
".",
"asResult",
"(",
")",
";",
"}",
"}",
";",
"return",
"withQueryHandler",
"(",
"qh",
")",
";",
"}"
] |
Returns handler that delegates query execution to |h| function.
Given function will be used only if executed statement is detected
as a query by withQueryDetection.
@param h the new query handler
<pre>
{@code
import acolyte.jdbc.StatementHandler.Parameter;
import static acolyte.jdbc.AcolyteDSL.handleStatement;
handleStatement.withQueryHandler2((String sql, List<Parameter> ps) -> {
if (sql == "SELECT * FROM Test WHERE id = ?") return "Foo";
else return "Bar";
});
}
</pre>
|
[
"Returns",
"handler",
"that",
"delegates",
"query",
"execution",
"to",
"|h|",
"function",
".",
"Given",
"function",
"will",
"be",
"used",
"only",
"if",
"executed",
"statement",
"is",
"detected",
"as",
"a",
"query",
"by",
"withQueryDetection",
"."
] |
train
|
https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-java8/src/main/java/acolyte/jdbc/Java8CompositeHandler.java#L135-L144
|
apache/incubator-atlas
|
webapp/src/main/java/org/apache/atlas/web/service/AtlasZookeeperSecurityProperties.java
|
AtlasZookeeperSecurityProperties.parseAuth
|
public static AuthInfo parseAuth(String authString) {
"""
Get an {@link AuthInfo} by parsing input string.
@param authString A string of the form scheme:authString
@return {@link AuthInfo} with the scheme and auth taken from configuration values.
"""
String[] authComponents = getComponents(authString, "authString", "scheme:authString");
return new AuthInfo(authComponents[0], authComponents[1].getBytes(Charsets.UTF_8));
}
|
java
|
public static AuthInfo parseAuth(String authString) {
String[] authComponents = getComponents(authString, "authString", "scheme:authString");
return new AuthInfo(authComponents[0], authComponents[1].getBytes(Charsets.UTF_8));
}
|
[
"public",
"static",
"AuthInfo",
"parseAuth",
"(",
"String",
"authString",
")",
"{",
"String",
"[",
"]",
"authComponents",
"=",
"getComponents",
"(",
"authString",
",",
"\"authString\"",
",",
"\"scheme:authString\"",
")",
";",
"return",
"new",
"AuthInfo",
"(",
"authComponents",
"[",
"0",
"]",
",",
"authComponents",
"[",
"1",
"]",
".",
"getBytes",
"(",
"Charsets",
".",
"UTF_8",
")",
")",
";",
"}"
] |
Get an {@link AuthInfo} by parsing input string.
@param authString A string of the form scheme:authString
@return {@link AuthInfo} with the scheme and auth taken from configuration values.
|
[
"Get",
"an",
"{"
] |
train
|
https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/webapp/src/main/java/org/apache/atlas/web/service/AtlasZookeeperSecurityProperties.java#L70-L73
|
googleads/googleads-java-lib
|
examples/admanager_axis/src/main/java/admanager/axis/v201808/userservice/GetCurrentUser.java
|
GetCurrentUser.runExample
|
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws RemoteException {
"""
Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
"""
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get the current user.
User user = userService.getCurrentUser();
System.out.printf(
"User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n",
user.getId(), user.getName(), user.getEmail(), user.getRoleName());
}
|
java
|
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
throws RemoteException {
// Get the UserService.
UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
// Get the current user.
User user = userService.getCurrentUser();
System.out.printf(
"User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n",
user.getId(), user.getName(), user.getEmail(), user.getRoleName());
}
|
[
"public",
"static",
"void",
"runExample",
"(",
"AdManagerServices",
"adManagerServices",
",",
"AdManagerSession",
"session",
")",
"throws",
"RemoteException",
"{",
"// Get the UserService.",
"UserServiceInterface",
"userService",
"=",
"adManagerServices",
".",
"get",
"(",
"session",
",",
"UserServiceInterface",
".",
"class",
")",
";",
"// Get the current user.",
"User",
"user",
"=",
"userService",
".",
"getCurrentUser",
"(",
")",
";",
"System",
".",
"out",
".",
"printf",
"(",
"\"User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n\"",
",",
"user",
".",
"getId",
"(",
")",
",",
"user",
".",
"getName",
"(",
")",
",",
"user",
".",
"getEmail",
"(",
")",
",",
"user",
".",
"getRoleName",
"(",
")",
")",
";",
"}"
] |
Runs the example.
@param adManagerServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
|
[
"Runs",
"the",
"example",
"."
] |
train
|
https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/examples/admanager_axis/src/main/java/admanager/axis/v201808/userservice/GetCurrentUser.java#L49-L60
|
alkacon/opencms-core
|
src-setup/org/opencms/setup/db/update6to7/CmsUpdateDBCmsUsers.java
|
CmsUpdateDBCmsUsers.removeUnnecessaryColumns
|
protected void removeUnnecessaryColumns(CmsSetupDb dbCon) throws SQLException {
"""
Removes the columns USER_INFO, USER_ADDRESS, USER_DESCRIPTION and USER_TYPE from the CMS_USERS table.<p>
@param dbCon the db connection interface
@throws SQLException if something goes wrong
"""
System.out.println(new Exception().getStackTrace()[0].toString());
// Get the sql queries to drop the columns
String dropUserInfo = readQuery(QUERY_DROP_USER_INFO_COLUMN);
String dropUserAddress = readQuery(QUERY_DROP_USER_ADDRESS_COLUMN);
String dropUserDescription = readQuery(QUERY_DROP_USER_DESCRIPTION_COLUMN);
String dropUserType = readQuery(QUERY_DROP_USER_TYPE_COLUMN);
// execute the queries to drop the columns, if they exist
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_INFO)) {
dbCon.updateSqlStatement(dropUserInfo, null, null);
} else {
System.out.println("no column " + USER_INFO + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_ADDRESS)) {
dbCon.updateSqlStatement(dropUserAddress, null, null);
} else {
System.out.println("no column " + USER_ADDRESS + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_DESCRIPTION)) {
dbCon.updateSqlStatement(dropUserDescription, null, null);
} else {
System.out.println("no column " + USER_DESCRIPTION + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_TYPE)) {
dbCon.updateSqlStatement(dropUserType, null, null);
} else {
System.out.println("no column " + USER_TYPE + " in table " + CMS_USERS_TABLE + " found");
}
}
|
java
|
protected void removeUnnecessaryColumns(CmsSetupDb dbCon) throws SQLException {
System.out.println(new Exception().getStackTrace()[0].toString());
// Get the sql queries to drop the columns
String dropUserInfo = readQuery(QUERY_DROP_USER_INFO_COLUMN);
String dropUserAddress = readQuery(QUERY_DROP_USER_ADDRESS_COLUMN);
String dropUserDescription = readQuery(QUERY_DROP_USER_DESCRIPTION_COLUMN);
String dropUserType = readQuery(QUERY_DROP_USER_TYPE_COLUMN);
// execute the queries to drop the columns, if they exist
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_INFO)) {
dbCon.updateSqlStatement(dropUserInfo, null, null);
} else {
System.out.println("no column " + USER_INFO + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_ADDRESS)) {
dbCon.updateSqlStatement(dropUserAddress, null, null);
} else {
System.out.println("no column " + USER_ADDRESS + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_DESCRIPTION)) {
dbCon.updateSqlStatement(dropUserDescription, null, null);
} else {
System.out.println("no column " + USER_DESCRIPTION + " in table " + CMS_USERS_TABLE + " found");
}
if (dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_TYPE)) {
dbCon.updateSqlStatement(dropUserType, null, null);
} else {
System.out.println("no column " + USER_TYPE + " in table " + CMS_USERS_TABLE + " found");
}
}
|
[
"protected",
"void",
"removeUnnecessaryColumns",
"(",
"CmsSetupDb",
"dbCon",
")",
"throws",
"SQLException",
"{",
"System",
".",
"out",
".",
"println",
"(",
"new",
"Exception",
"(",
")",
".",
"getStackTrace",
"(",
")",
"[",
"0",
"]",
".",
"toString",
"(",
")",
")",
";",
"// Get the sql queries to drop the columns",
"String",
"dropUserInfo",
"=",
"readQuery",
"(",
"QUERY_DROP_USER_INFO_COLUMN",
")",
";",
"String",
"dropUserAddress",
"=",
"readQuery",
"(",
"QUERY_DROP_USER_ADDRESS_COLUMN",
")",
";",
"String",
"dropUserDescription",
"=",
"readQuery",
"(",
"QUERY_DROP_USER_DESCRIPTION_COLUMN",
")",
";",
"String",
"dropUserType",
"=",
"readQuery",
"(",
"QUERY_DROP_USER_TYPE_COLUMN",
")",
";",
"// execute the queries to drop the columns, if they exist",
"if",
"(",
"dbCon",
".",
"hasTableOrColumn",
"(",
"CMS_USERS_TABLE",
",",
"USER_INFO",
")",
")",
"{",
"dbCon",
".",
"updateSqlStatement",
"(",
"dropUserInfo",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"no column \"",
"+",
"USER_INFO",
"+",
"\" in table \"",
"+",
"CMS_USERS_TABLE",
"+",
"\" found\"",
")",
";",
"}",
"if",
"(",
"dbCon",
".",
"hasTableOrColumn",
"(",
"CMS_USERS_TABLE",
",",
"USER_ADDRESS",
")",
")",
"{",
"dbCon",
".",
"updateSqlStatement",
"(",
"dropUserAddress",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"no column \"",
"+",
"USER_ADDRESS",
"+",
"\" in table \"",
"+",
"CMS_USERS_TABLE",
"+",
"\" found\"",
")",
";",
"}",
"if",
"(",
"dbCon",
".",
"hasTableOrColumn",
"(",
"CMS_USERS_TABLE",
",",
"USER_DESCRIPTION",
")",
")",
"{",
"dbCon",
".",
"updateSqlStatement",
"(",
"dropUserDescription",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"no column \"",
"+",
"USER_DESCRIPTION",
"+",
"\" in table \"",
"+",
"CMS_USERS_TABLE",
"+",
"\" found\"",
")",
";",
"}",
"if",
"(",
"dbCon",
".",
"hasTableOrColumn",
"(",
"CMS_USERS_TABLE",
",",
"USER_TYPE",
")",
")",
"{",
"dbCon",
".",
"updateSqlStatement",
"(",
"dropUserType",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"no column \"",
"+",
"USER_TYPE",
"+",
"\" in table \"",
"+",
"CMS_USERS_TABLE",
"+",
"\" found\"",
")",
";",
"}",
"}"
] |
Removes the columns USER_INFO, USER_ADDRESS, USER_DESCRIPTION and USER_TYPE from the CMS_USERS table.<p>
@param dbCon the db connection interface
@throws SQLException if something goes wrong
|
[
"Removes",
"the",
"columns",
"USER_INFO",
"USER_ADDRESS",
"USER_DESCRIPTION",
"and",
"USER_TYPE",
"from",
"the",
"CMS_USERS",
"table",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-setup/org/opencms/setup/db/update6to7/CmsUpdateDBCmsUsers.java#L310-L340
|
Stratio/stratio-cassandra
|
src/java/org/apache/cassandra/config/Schema.java
|
Schema.getCFMetaData
|
public CFMetaData getCFMetaData(String keyspaceName, String cfName) {
"""
Given a keyspace name & column family name, get the column family
meta data. If the keyspace name or column family name is not valid
this function returns null.
@param keyspaceName The keyspace name
@param cfName The ColumnFamily name
@return ColumnFamily Metadata object or null if it wasn't found
"""
assert keyspaceName != null;
KSMetaData ksm = keyspaces.get(keyspaceName);
return (ksm == null) ? null : ksm.cfMetaData().get(cfName);
}
|
java
|
public CFMetaData getCFMetaData(String keyspaceName, String cfName)
{
assert keyspaceName != null;
KSMetaData ksm = keyspaces.get(keyspaceName);
return (ksm == null) ? null : ksm.cfMetaData().get(cfName);
}
|
[
"public",
"CFMetaData",
"getCFMetaData",
"(",
"String",
"keyspaceName",
",",
"String",
"cfName",
")",
"{",
"assert",
"keyspaceName",
"!=",
"null",
";",
"KSMetaData",
"ksm",
"=",
"keyspaces",
".",
"get",
"(",
"keyspaceName",
")",
";",
"return",
"(",
"ksm",
"==",
"null",
")",
"?",
"null",
":",
"ksm",
".",
"cfMetaData",
"(",
")",
".",
"get",
"(",
"cfName",
")",
";",
"}"
] |
Given a keyspace name & column family name, get the column family
meta data. If the keyspace name or column family name is not valid
this function returns null.
@param keyspaceName The keyspace name
@param cfName The ColumnFamily name
@return ColumnFamily Metadata object or null if it wasn't found
|
[
"Given",
"a",
"keyspace",
"name",
"&",
"column",
"family",
"name",
"get",
"the",
"column",
"family",
"meta",
"data",
".",
"If",
"the",
"keyspace",
"name",
"or",
"column",
"family",
"name",
"is",
"not",
"valid",
"this",
"function",
"returns",
"null",
"."
] |
train
|
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/config/Schema.java#L190-L195
|
liyiorg/weixin-popular
|
src/main/java/weixin/popular/util/JsUtil.java
|
JsUtil.generateConfigJson
|
public static String generateConfigJson(String jsapi_ticket,boolean debug,String appId,String url,String... jsApiList) {
"""
生成 config接口注入权限验证 JSON
@param jsapi_ticket jsapi_ticket
@param debug debug
@param appId appId
@param url url
@param jsApiList 可以为空<br>
基础接口<br>
checkJsApi 判断当前客户端版本是否支持指定JS接口<br>
分享接口<br>
updateAppMessageShareData 分享到朋友及QQ<br>
updateTimelineShareData 分享到朋友圈及QQ空间<br>
onMenuShareTimeline 分享到朋友圈<br>
onMenuShareAppMessage 分享给朋友<br>
onMenuShareQQ 分享到QQ<br>
onMenuShareWeibo 分享到腾讯微博<br>
onMenuShareQZone 分享到QQ空间<br>
图像接口<br>
chooseImage 拍照或从手机相册中选图<br>
previewImage 预览图片<br>
uploadImage 上传图片<br>
downloadImage 下载图片<br>
音频接口<br>
startRecord 开始录音<br>
stopRecord 停止录音<br>
onVoiceRecordEnd 监听录音自动停止<br>
playVoice 播放语音<br>
pauseVoice 暂停播放<br>
stopVoice 停止播放<br>
onVoicePlayEnd 监听语音播放完毕<br>
uploadVoice 上传语音<br>
downloadVoice 下载语音<br>
智能接口<br>
translateVoice 识别音频并返回识别结果<br>
设备信息<br>
getNetworkType 获取网络状态<br>
地理位置<br>
openLocation 使用微信内置地图查看位置<br>
getLocation 获取地理位置<br>
摇一摇周边<br>
startSearchBeacons 开启查找周边ibeacon设备<br>
stopSearchBeacons 关闭查找周边ibeacon设备<br>
onSearchBeacons 监听周边ibeacon设备<br>
界面操作<br>
hideOptionMenu 隐藏右上角菜单<br>
showOptionMenu 显示右上角菜单<br>
closeWindow 关闭当前网页窗口<br>
hideMenuItems 批量隐藏功能按钮<br>
showMenuItems 批量显示功能按钮<br>
hideAllNonBaseMenuItem 隐藏所有非基础按钮<br>
showAllNonBaseMenuItem 显示所有功能按钮<br>
微信扫一扫<br>
scanQRCode 调起微信扫一扫<br>
微信小店<br>
openProductSpecificView 跳转微信商品页<br>
微信卡券<br>
chooseCard 拉取适用卡券列表并获取用户选择信息<br>
addCard 批量添加卡券<br>
openCard 查看微信卡包中的卡券<br>
微信支付<br>
chooseWXPay 发起一个微信支付<br>
openAddress 共享收货地址接口<br>
@return 配置JSON数据
"""
long timestamp = System.currentTimeMillis()/1000;
String nonceStr = UUID.randomUUID().toString();
String signature = generateConfigSignature(nonceStr, jsapi_ticket, timestamp + "", url);
Map<String,Object> map = new LinkedHashMap<>();
map.put("debug", debug);
map.put("appId", appId);
map.put("timestamp", timestamp);
map.put("nonceStr", nonceStr);
map.put("signature", signature);
map.put("jsApiList", jsApiList == null ? ALL_JS_API_LIST : jsApiList);
return JsonUtil.toJSONString(map);
}
|
java
|
public static String generateConfigJson(String jsapi_ticket,boolean debug,String appId,String url,String... jsApiList){
long timestamp = System.currentTimeMillis()/1000;
String nonceStr = UUID.randomUUID().toString();
String signature = generateConfigSignature(nonceStr, jsapi_ticket, timestamp + "", url);
Map<String,Object> map = new LinkedHashMap<>();
map.put("debug", debug);
map.put("appId", appId);
map.put("timestamp", timestamp);
map.put("nonceStr", nonceStr);
map.put("signature", signature);
map.put("jsApiList", jsApiList == null ? ALL_JS_API_LIST : jsApiList);
return JsonUtil.toJSONString(map);
}
|
[
"public",
"static",
"String",
"generateConfigJson",
"(",
"String",
"jsapi_ticket",
",",
"boolean",
"debug",
",",
"String",
"appId",
",",
"String",
"url",
",",
"String",
"...",
"jsApiList",
")",
"{",
"long",
"timestamp",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"String",
"nonceStr",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"signature",
"=",
"generateConfigSignature",
"(",
"nonceStr",
",",
"jsapi_ticket",
",",
"timestamp",
"+",
"\"\"",
",",
"url",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"debug\"",
",",
"debug",
")",
";",
"map",
".",
"put",
"(",
"\"appId\"",
",",
"appId",
")",
";",
"map",
".",
"put",
"(",
"\"timestamp\"",
",",
"timestamp",
")",
";",
"map",
".",
"put",
"(",
"\"nonceStr\"",
",",
"nonceStr",
")",
";",
"map",
".",
"put",
"(",
"\"signature\"",
",",
"signature",
")",
";",
"map",
".",
"put",
"(",
"\"jsApiList\"",
",",
"jsApiList",
"==",
"null",
"?",
"ALL_JS_API_LIST",
":",
"jsApiList",
")",
";",
"return",
"JsonUtil",
".",
"toJSONString",
"(",
"map",
")",
";",
"}"
] |
生成 config接口注入权限验证 JSON
@param jsapi_ticket jsapi_ticket
@param debug debug
@param appId appId
@param url url
@param jsApiList 可以为空<br>
基础接口<br>
checkJsApi 判断当前客户端版本是否支持指定JS接口<br>
分享接口<br>
updateAppMessageShareData 分享到朋友及QQ<br>
updateTimelineShareData 分享到朋友圈及QQ空间<br>
onMenuShareTimeline 分享到朋友圈<br>
onMenuShareAppMessage 分享给朋友<br>
onMenuShareQQ 分享到QQ<br>
onMenuShareWeibo 分享到腾讯微博<br>
onMenuShareQZone 分享到QQ空间<br>
图像接口<br>
chooseImage 拍照或从手机相册中选图<br>
previewImage 预览图片<br>
uploadImage 上传图片<br>
downloadImage 下载图片<br>
音频接口<br>
startRecord 开始录音<br>
stopRecord 停止录音<br>
onVoiceRecordEnd 监听录音自动停止<br>
playVoice 播放语音<br>
pauseVoice 暂停播放<br>
stopVoice 停止播放<br>
onVoicePlayEnd 监听语音播放完毕<br>
uploadVoice 上传语音<br>
downloadVoice 下载语音<br>
智能接口<br>
translateVoice 识别音频并返回识别结果<br>
设备信息<br>
getNetworkType 获取网络状态<br>
地理位置<br>
openLocation 使用微信内置地图查看位置<br>
getLocation 获取地理位置<br>
摇一摇周边<br>
startSearchBeacons 开启查找周边ibeacon设备<br>
stopSearchBeacons 关闭查找周边ibeacon设备<br>
onSearchBeacons 监听周边ibeacon设备<br>
界面操作<br>
hideOptionMenu 隐藏右上角菜单<br>
showOptionMenu 显示右上角菜单<br>
closeWindow 关闭当前网页窗口<br>
hideMenuItems 批量隐藏功能按钮<br>
showMenuItems 批量显示功能按钮<br>
hideAllNonBaseMenuItem 隐藏所有非基础按钮<br>
showAllNonBaseMenuItem 显示所有功能按钮<br>
微信扫一扫<br>
scanQRCode 调起微信扫一扫<br>
微信小店<br>
openProductSpecificView 跳转微信商品页<br>
微信卡券<br>
chooseCard 拉取适用卡券列表并获取用户选择信息<br>
addCard 批量添加卡券<br>
openCard 查看微信卡包中的卡券<br>
微信支付<br>
chooseWXPay 发起一个微信支付<br>
openAddress 共享收货地址接口<br>
@return 配置JSON数据
|
[
"生成",
"config接口注入权限验证",
"JSON",
"@param",
"jsapi_ticket",
"jsapi_ticket",
"@param",
"debug",
"debug",
"@param",
"appId",
"appId",
"@param",
"url",
"url",
"@param",
"jsApiList",
"可以为空<br",
">",
"基础接口<br",
">",
"checkJsApi",
"判断当前客户端版本是否支持指定JS接口<br",
">",
"分享接口<br",
">",
"updateAppMessageShareData",
"分享到朋友及QQ<br",
">",
"updateTimelineShareData",
"分享到朋友圈及QQ空间<br",
">"
] |
train
|
https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/util/JsUtil.java#L158-L170
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-licenseoffice/src/main/java/net/minidev/ovh/api/ApiOvhLicenseoffice.java
|
ApiOvhLicenseoffice.serviceName_usageStatistics_GET
|
public ArrayList<OvhStatistics> serviceName_usageStatistics_GET(String serviceName, Date from, Date to) throws IOException {
"""
Shows the subscriptions' usage statistics for the given time period
REST: GET /license/office/{serviceName}/usageStatistics
@param to [required] Period's end point.
@param from [required] Period's start point.
@param serviceName [required] The unique identifier of your Office service
"""
String qPath = "/license/office/{serviceName}/usageStatistics";
StringBuilder sb = path(qPath, serviceName);
query(sb, "from", from);
query(sb, "to", to);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
}
|
java
|
public ArrayList<OvhStatistics> serviceName_usageStatistics_GET(String serviceName, Date from, Date to) throws IOException {
String qPath = "/license/office/{serviceName}/usageStatistics";
StringBuilder sb = path(qPath, serviceName);
query(sb, "from", from);
query(sb, "to", to);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t3);
}
|
[
"public",
"ArrayList",
"<",
"OvhStatistics",
">",
"serviceName_usageStatistics_GET",
"(",
"String",
"serviceName",
",",
"Date",
"from",
",",
"Date",
"to",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/license/office/{serviceName}/usageStatistics\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"from\"",
",",
"from",
")",
";",
"query",
"(",
"sb",
",",
"\"to\"",
",",
"to",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t3",
")",
";",
"}"
] |
Shows the subscriptions' usage statistics for the given time period
REST: GET /license/office/{serviceName}/usageStatistics
@param to [required] Period's end point.
@param from [required] Period's start point.
@param serviceName [required] The unique identifier of your Office service
|
[
"Shows",
"the",
"subscriptions",
"usage",
"statistics",
"for",
"the",
"given",
"time",
"period"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-licenseoffice/src/main/java/net/minidev/ovh/api/ApiOvhLicenseoffice.java#L238-L245
|
robocup-atan/atan
|
src/main/java/com/github/robocup_atan/atan/model/XPMImage.java
|
XPMImage.setTile
|
public void setTile(int x, int y, String tile) {
"""
Updates an 8*8 tile in the XPM Image.
@param x Between 0 and 31.
@param y Between 0 and 7.
@param tile An XPM image string defining an 8*8 image.
"""
if ((x > getArrayWidth()) || (y > getArrayHeight()) || (x < 0) || (y < 0)) {
throw new IllegalArgumentException();
}
image[x][y] = tile;
}
|
java
|
public void setTile(int x, int y, String tile) {
if ((x > getArrayWidth()) || (y > getArrayHeight()) || (x < 0) || (y < 0)) {
throw new IllegalArgumentException();
}
image[x][y] = tile;
}
|
[
"public",
"void",
"setTile",
"(",
"int",
"x",
",",
"int",
"y",
",",
"String",
"tile",
")",
"{",
"if",
"(",
"(",
"x",
">",
"getArrayWidth",
"(",
")",
")",
"||",
"(",
"y",
">",
"getArrayHeight",
"(",
")",
")",
"||",
"(",
"x",
"<",
"0",
")",
"||",
"(",
"y",
"<",
"0",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"image",
"[",
"x",
"]",
"[",
"y",
"]",
"=",
"tile",
";",
"}"
] |
Updates an 8*8 tile in the XPM Image.
@param x Between 0 and 31.
@param y Between 0 and 7.
@param tile An XPM image string defining an 8*8 image.
|
[
"Updates",
"an",
"8",
"*",
"8",
"tile",
"in",
"the",
"XPM",
"Image",
"."
] |
train
|
https://github.com/robocup-atan/atan/blob/52237b468b09ba5b7c52d290984dbe0326c96df7/src/main/java/com/github/robocup_atan/atan/model/XPMImage.java#L100-L105
|
xdcrafts/flower
|
flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java
|
ListApi.getOptionalUnsafe
|
public static <T> Optional<T> getOptionalUnsafe(final List list, final Class<T> clazz, final Integer... path) {
"""
Get optional value by path.
@param <T> optional value type
@param clazz type of value
@param list subject
@param path nodes to walk in map
@return value
"""
return getUnsafe(list, Optional.class, path);
}
|
java
|
public static <T> Optional<T> getOptionalUnsafe(final List list, final Class<T> clazz, final Integer... path) {
return getUnsafe(list, Optional.class, path);
}
|
[
"public",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"getOptionalUnsafe",
"(",
"final",
"List",
"list",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
",",
"final",
"Integer",
"...",
"path",
")",
"{",
"return",
"getUnsafe",
"(",
"list",
",",
"Optional",
".",
"class",
",",
"path",
")",
";",
"}"
] |
Get optional value by path.
@param <T> optional value type
@param clazz type of value
@param list subject
@param path nodes to walk in map
@return value
|
[
"Get",
"optional",
"value",
"by",
"path",
"."
] |
train
|
https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/ListApi.java#L268-L270
|
jbundle/jbundle
|
base/remote/src/main/java/org/jbundle/base/remote/lock/ClientLockManager.java
|
ClientLockManager.getLockSessionInfo
|
public SessionInfo getLockSessionInfo(Task objSession, String strUserName) {
"""
Lookup the information for this session (or create new sessioninfo).
@param objSession The unique object identifying this session (Typically the Task).
@param strUser The (optional) user name.
@return The new or looked up session information.
"""
if (objSession == null)
{
Utility.getLogger().warning("null session");
return new SessionInfo(0, strUserName); //
}
SessionInfo intSession = (SessionInfo)m_hmLockSessions.get(objSession);
if (intSession == null)
m_hmLockSessions.put(objSession, intSession = new SessionInfo(m_iNextLockSession++, strUserName));
return intSession;
}
|
java
|
public SessionInfo getLockSessionInfo(Task objSession, String strUserName)
{
if (objSession == null)
{
Utility.getLogger().warning("null session");
return new SessionInfo(0, strUserName); //
}
SessionInfo intSession = (SessionInfo)m_hmLockSessions.get(objSession);
if (intSession == null)
m_hmLockSessions.put(objSession, intSession = new SessionInfo(m_iNextLockSession++, strUserName));
return intSession;
}
|
[
"public",
"SessionInfo",
"getLockSessionInfo",
"(",
"Task",
"objSession",
",",
"String",
"strUserName",
")",
"{",
"if",
"(",
"objSession",
"==",
"null",
")",
"{",
"Utility",
".",
"getLogger",
"(",
")",
".",
"warning",
"(",
"\"null session\"",
")",
";",
"return",
"new",
"SessionInfo",
"(",
"0",
",",
"strUserName",
")",
";",
"// ",
"}",
"SessionInfo",
"intSession",
"=",
"(",
"SessionInfo",
")",
"m_hmLockSessions",
".",
"get",
"(",
"objSession",
")",
";",
"if",
"(",
"intSession",
"==",
"null",
")",
"m_hmLockSessions",
".",
"put",
"(",
"objSession",
",",
"intSession",
"=",
"new",
"SessionInfo",
"(",
"m_iNextLockSession",
"++",
",",
"strUserName",
")",
")",
";",
"return",
"intSession",
";",
"}"
] |
Lookup the information for this session (or create new sessioninfo).
@param objSession The unique object identifying this session (Typically the Task).
@param strUser The (optional) user name.
@return The new or looked up session information.
|
[
"Lookup",
"the",
"information",
"for",
"this",
"session",
"(",
"or",
"create",
"new",
"sessioninfo",
")",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/lock/ClientLockManager.java#L164-L175
|
alkacon/opencms-core
|
src/org/opencms/rmi/CmsRemoteShellClient.java
|
CmsRemoteShellClient.executeCommand
|
private void executeCommand(String command, List<String> arguments) {
"""
Executes a command remotely, displays the command output and updates the internal state.<p>
@param command the command
@param arguments the arguments
"""
try {
CmsShellCommandResult result = m_remoteShell.executeCommand(command, arguments);
m_out.print(result.getOutput());
updateState(result);
if (m_exitCalled) {
exit(0);
} else if (m_hasError && (m_errorCode != -1)) {
exit(m_errorCode);
}
} catch (RemoteException r) {
r.printStackTrace(System.err);
exit(1);
}
}
|
java
|
private void executeCommand(String command, List<String> arguments) {
try {
CmsShellCommandResult result = m_remoteShell.executeCommand(command, arguments);
m_out.print(result.getOutput());
updateState(result);
if (m_exitCalled) {
exit(0);
} else if (m_hasError && (m_errorCode != -1)) {
exit(m_errorCode);
}
} catch (RemoteException r) {
r.printStackTrace(System.err);
exit(1);
}
}
|
[
"private",
"void",
"executeCommand",
"(",
"String",
"command",
",",
"List",
"<",
"String",
">",
"arguments",
")",
"{",
"try",
"{",
"CmsShellCommandResult",
"result",
"=",
"m_remoteShell",
".",
"executeCommand",
"(",
"command",
",",
"arguments",
")",
";",
"m_out",
".",
"print",
"(",
"result",
".",
"getOutput",
"(",
")",
")",
";",
"updateState",
"(",
"result",
")",
";",
"if",
"(",
"m_exitCalled",
")",
"{",
"exit",
"(",
"0",
")",
";",
"}",
"else",
"if",
"(",
"m_hasError",
"&&",
"(",
"m_errorCode",
"!=",
"-",
"1",
")",
")",
"{",
"exit",
"(",
"m_errorCode",
")",
";",
"}",
"}",
"catch",
"(",
"RemoteException",
"r",
")",
"{",
"r",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] |
Executes a command remotely, displays the command output and updates the internal state.<p>
@param command the command
@param arguments the arguments
|
[
"Executes",
"a",
"command",
"remotely",
"displays",
"the",
"command",
"output",
"and",
"updates",
"the",
"internal",
"state",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/rmi/CmsRemoteShellClient.java#L248-L263
|
ngageoint/geopackage-java
|
src/main/java/mil/nga/geopackage/db/SQLUtils.java
|
SQLUtils.wrapQuery
|
public static ResultSetResult wrapQuery(Connection connection, String sql,
String[] selectionArgs) {
"""
Perform the query and wrap as a result
@param connection
connection
@param sql
sql statement
@param selectionArgs
selection arguments
@return result
@since 3.1.0
"""
return new ResultSetResult(query(connection, sql, selectionArgs));
}
|
java
|
public static ResultSetResult wrapQuery(Connection connection, String sql,
String[] selectionArgs) {
return new ResultSetResult(query(connection, sql, selectionArgs));
}
|
[
"public",
"static",
"ResultSetResult",
"wrapQuery",
"(",
"Connection",
"connection",
",",
"String",
"sql",
",",
"String",
"[",
"]",
"selectionArgs",
")",
"{",
"return",
"new",
"ResultSetResult",
"(",
"query",
"(",
"connection",
",",
"sql",
",",
"selectionArgs",
")",
")",
";",
"}"
] |
Perform the query and wrap as a result
@param connection
connection
@param sql
sql statement
@param selectionArgs
selection arguments
@return result
@since 3.1.0
|
[
"Perform",
"the",
"query",
"and",
"wrap",
"as",
"a",
"result"
] |
train
|
https://github.com/ngageoint/geopackage-java/blob/889bffb5d18330a3f4bd89443acf7959ebe3a376/src/main/java/mil/nga/geopackage/db/SQLUtils.java#L596-L599
|
sarl/sarl
|
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/contextspace/StandardContextSpaceService.java
|
StandardContextSpaceService.fireSpaceCreated
|
protected void fireSpaceCreated(Space space, boolean isLocalCreation) {
"""
Notifies the listeners on the space creation.
@param space reference to the created space.
@param isLocalCreation indicates if the space was initially created on the current kernel.
"""
for (final SpaceRepositoryListener listener : this.listeners.getListeners(SpaceRepositoryListener.class)) {
listener.spaceCreated(space, isLocalCreation);
}
}
|
java
|
protected void fireSpaceCreated(Space space, boolean isLocalCreation) {
for (final SpaceRepositoryListener listener : this.listeners.getListeners(SpaceRepositoryListener.class)) {
listener.spaceCreated(space, isLocalCreation);
}
}
|
[
"protected",
"void",
"fireSpaceCreated",
"(",
"Space",
"space",
",",
"boolean",
"isLocalCreation",
")",
"{",
"for",
"(",
"final",
"SpaceRepositoryListener",
"listener",
":",
"this",
".",
"listeners",
".",
"getListeners",
"(",
"SpaceRepositoryListener",
".",
"class",
")",
")",
"{",
"listener",
".",
"spaceCreated",
"(",
"space",
",",
"isLocalCreation",
")",
";",
"}",
"}"
] |
Notifies the listeners on the space creation.
@param space reference to the created space.
@param isLocalCreation indicates if the space was initially created on the current kernel.
|
[
"Notifies",
"the",
"listeners",
"on",
"the",
"space",
"creation",
"."
] |
train
|
https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/services/jdk/contextspace/StandardContextSpaceService.java#L346-L350
|
DDTH/ddth-commons
|
ddth-commons-core/src/main/java/com/github/ddth/commons/utils/DateTimeUtils.java
|
DateTimeUtils.addWeeks
|
public static Calendar addWeeks(Calendar origin, int value) {
"""
Add/Subtract the specified amount of weeks to the given {@link Calendar}.
<p>
The returned {@link Calendar} has its fields synced.
</p>
@param origin
@param value
@return
@since 0.9.2
"""
Calendar cal = sync((Calendar) origin.clone());
cal.add(Calendar.WEEK_OF_YEAR, value);
return sync(cal);
}
|
java
|
public static Calendar addWeeks(Calendar origin, int value) {
Calendar cal = sync((Calendar) origin.clone());
cal.add(Calendar.WEEK_OF_YEAR, value);
return sync(cal);
}
|
[
"public",
"static",
"Calendar",
"addWeeks",
"(",
"Calendar",
"origin",
",",
"int",
"value",
")",
"{",
"Calendar",
"cal",
"=",
"sync",
"(",
"(",
"Calendar",
")",
"origin",
".",
"clone",
"(",
")",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"WEEK_OF_YEAR",
",",
"value",
")",
";",
"return",
"sync",
"(",
"cal",
")",
";",
"}"
] |
Add/Subtract the specified amount of weeks to the given {@link Calendar}.
<p>
The returned {@link Calendar} has its fields synced.
</p>
@param origin
@param value
@return
@since 0.9.2
|
[
"Add",
"/",
"Subtract",
"the",
"specified",
"amount",
"of",
"weeks",
"to",
"the",
"given",
"{",
"@link",
"Calendar",
"}",
"."
] |
train
|
https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/DateTimeUtils.java#L706-L710
|
Impetus/Kundera
|
src/kundera-neo4j/src/main/java/com/impetus/client/neo4j/GraphEntityMapper.java
|
GraphEntityMapper.deserializeIdAttributeValue
|
private Object deserializeIdAttributeValue(final EntityMetadata m, String idValue) {
"""
Prepares Embedded ID field from value prepared via
serializeIdAttributeValue method.
"""
if (idValue == null)
{
return null;
}
Class<?> embeddableClass = m.getIdAttribute().getBindableJavaType();
Object embeddedObject = embeddedObject = KunderaCoreUtils.createNewInstance(embeddableClass);
List<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer((String) idValue, COMPOSITE_KEY_SEPARATOR);
while (st.hasMoreTokens())
{
tokens.add((String) st.nextElement());
}
int count = 0;
for (Field embeddedField : embeddableClass.getDeclaredFields())
{
if (!ReflectUtils.isTransientOrStatic(embeddedField))
{
if (count < tokens.size())
{
String value = tokens.get(count++);
PropertyAccessorHelper.set(embeddedObject, embeddedField, value);
}
}
}
return embeddedObject;
}
|
java
|
private Object deserializeIdAttributeValue(final EntityMetadata m, String idValue)
{
if (idValue == null)
{
return null;
}
Class<?> embeddableClass = m.getIdAttribute().getBindableJavaType();
Object embeddedObject = embeddedObject = KunderaCoreUtils.createNewInstance(embeddableClass);
List<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer((String) idValue, COMPOSITE_KEY_SEPARATOR);
while (st.hasMoreTokens())
{
tokens.add((String) st.nextElement());
}
int count = 0;
for (Field embeddedField : embeddableClass.getDeclaredFields())
{
if (!ReflectUtils.isTransientOrStatic(embeddedField))
{
if (count < tokens.size())
{
String value = tokens.get(count++);
PropertyAccessorHelper.set(embeddedObject, embeddedField, value);
}
}
}
return embeddedObject;
}
|
[
"private",
"Object",
"deserializeIdAttributeValue",
"(",
"final",
"EntityMetadata",
"m",
",",
"String",
"idValue",
")",
"{",
"if",
"(",
"idValue",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Class",
"<",
"?",
">",
"embeddableClass",
"=",
"m",
".",
"getIdAttribute",
"(",
")",
".",
"getBindableJavaType",
"(",
")",
";",
"Object",
"embeddedObject",
"=",
"embeddedObject",
"=",
"KunderaCoreUtils",
".",
"createNewInstance",
"(",
"embeddableClass",
")",
";",
"List",
"<",
"String",
">",
"tokens",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"(",
"String",
")",
"idValue",
",",
"COMPOSITE_KEY_SEPARATOR",
")",
";",
"while",
"(",
"st",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"tokens",
".",
"add",
"(",
"(",
"String",
")",
"st",
".",
"nextElement",
"(",
")",
")",
";",
"}",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"Field",
"embeddedField",
":",
"embeddableClass",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"if",
"(",
"!",
"ReflectUtils",
".",
"isTransientOrStatic",
"(",
"embeddedField",
")",
")",
"{",
"if",
"(",
"count",
"<",
"tokens",
".",
"size",
"(",
")",
")",
"{",
"String",
"value",
"=",
"tokens",
".",
"get",
"(",
"count",
"++",
")",
";",
"PropertyAccessorHelper",
".",
"set",
"(",
"embeddedObject",
",",
"embeddedField",
",",
"value",
")",
";",
"}",
"}",
"}",
"return",
"embeddedObject",
";",
"}"
] |
Prepares Embedded ID field from value prepared via
serializeIdAttributeValue method.
|
[
"Prepares",
"Embedded",
"ID",
"field",
"from",
"value",
"prepared",
"via",
"serializeIdAttributeValue",
"method",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-neo4j/src/main/java/com/impetus/client/neo4j/GraphEntityMapper.java#L542-L570
|
forge/furnace
|
container-api/src/main/java/org/jboss/forge/furnace/versions/Versions.java
|
Versions.isApiCompatible
|
public static boolean isApiCompatible(Version runtimeVersion, Version addonApiVersion) {
"""
This method only returns true if:
- The major version of addonApiVersion is equal to the major version of runtimeVersion AND
- The minor version of addonApiVersion is less or equal to the minor version of runtimeVersion
- The addonApiVersion is null
@param runtimeVersion a version in the format x.x.x
@param addonApiVersion a version in the format x.x.x
"""
if (addonApiVersion == null || addonApiVersion.toString().length() == 0
|| runtimeVersion == null || runtimeVersion.toString().length() == 0)
return true;
int runtimeMajorVersion = runtimeVersion.getMajorVersion();
int runtimeMinorVersion = runtimeVersion.getMinorVersion();
int addonApiMajorVersion = addonApiVersion.getMajorVersion();
int addonApiMinorVersion = addonApiVersion.getMinorVersion();
return (addonApiMajorVersion == runtimeMajorVersion && addonApiMinorVersion <= runtimeMinorVersion);
}
|
java
|
public static boolean isApiCompatible(Version runtimeVersion, Version addonApiVersion)
{
if (addonApiVersion == null || addonApiVersion.toString().length() == 0
|| runtimeVersion == null || runtimeVersion.toString().length() == 0)
return true;
int runtimeMajorVersion = runtimeVersion.getMajorVersion();
int runtimeMinorVersion = runtimeVersion.getMinorVersion();
int addonApiMajorVersion = addonApiVersion.getMajorVersion();
int addonApiMinorVersion = addonApiVersion.getMinorVersion();
return (addonApiMajorVersion == runtimeMajorVersion && addonApiMinorVersion <= runtimeMinorVersion);
}
|
[
"public",
"static",
"boolean",
"isApiCompatible",
"(",
"Version",
"runtimeVersion",
",",
"Version",
"addonApiVersion",
")",
"{",
"if",
"(",
"addonApiVersion",
"==",
"null",
"||",
"addonApiVersion",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
"||",
"runtimeVersion",
"==",
"null",
"||",
"runtimeVersion",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"true",
";",
"int",
"runtimeMajorVersion",
"=",
"runtimeVersion",
".",
"getMajorVersion",
"(",
")",
";",
"int",
"runtimeMinorVersion",
"=",
"runtimeVersion",
".",
"getMinorVersion",
"(",
")",
";",
"int",
"addonApiMajorVersion",
"=",
"addonApiVersion",
".",
"getMajorVersion",
"(",
")",
";",
"int",
"addonApiMinorVersion",
"=",
"addonApiVersion",
".",
"getMinorVersion",
"(",
")",
";",
"return",
"(",
"addonApiMajorVersion",
"==",
"runtimeMajorVersion",
"&&",
"addonApiMinorVersion",
"<=",
"runtimeMinorVersion",
")",
";",
"}"
] |
This method only returns true if:
- The major version of addonApiVersion is equal to the major version of runtimeVersion AND
- The minor version of addonApiVersion is less or equal to the minor version of runtimeVersion
- The addonApiVersion is null
@param runtimeVersion a version in the format x.x.x
@param addonApiVersion a version in the format x.x.x
|
[
"This",
"method",
"only",
"returns",
"true",
"if",
":"
] |
train
|
https://github.com/forge/furnace/blob/bbe6deaa3c0d85ba43daa3e2f7d486f2dad21e0a/container-api/src/main/java/org/jboss/forge/furnace/versions/Versions.java#L38-L49
|
netty/netty
|
handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java
|
CipherSuiteConverter.toOpenSsl
|
static String toOpenSsl(String javaCipherSuite, boolean boringSSL) {
"""
Converts the specified Java cipher suite to its corresponding OpenSSL cipher suite name.
@return {@code null} if the conversion has failed
"""
String converted = j2o.get(javaCipherSuite);
if (converted != null) {
return converted;
}
return cacheFromJava(javaCipherSuite, boringSSL);
}
|
java
|
static String toOpenSsl(String javaCipherSuite, boolean boringSSL) {
String converted = j2o.get(javaCipherSuite);
if (converted != null) {
return converted;
}
return cacheFromJava(javaCipherSuite, boringSSL);
}
|
[
"static",
"String",
"toOpenSsl",
"(",
"String",
"javaCipherSuite",
",",
"boolean",
"boringSSL",
")",
"{",
"String",
"converted",
"=",
"j2o",
".",
"get",
"(",
"javaCipherSuite",
")",
";",
"if",
"(",
"converted",
"!=",
"null",
")",
"{",
"return",
"converted",
";",
"}",
"return",
"cacheFromJava",
"(",
"javaCipherSuite",
",",
"boringSSL",
")",
";",
"}"
] |
Converts the specified Java cipher suite to its corresponding OpenSSL cipher suite name.
@return {@code null} if the conversion has failed
|
[
"Converts",
"the",
"specified",
"Java",
"cipher",
"suite",
"to",
"its",
"corresponding",
"OpenSSL",
"cipher",
"suite",
"name",
"."
] |
train
|
https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/handler/src/main/java/io/netty/handler/ssl/CipherSuiteConverter.java#L153-L159
|
ngageoint/geopackage-core-java
|
src/main/java/mil/nga/geopackage/extension/related/RelatedTablesCoreExtension.java
|
RelatedTablesCoreExtension.addAttributesRelationship
|
public ExtendedRelation addAttributesRelationship(String baseTableName,
AttributesTable attributesTable, String mappingTableName) {
"""
Adds an attributes relationship between the base table and user
attributes related table. Creates a default user mapping table and the
attributes table if needed.
@param baseTableName
base table name
@param attributesTable
user attributes table
@param mappingTableName
user mapping table name
@return The relationship that was added
@since 3.2.0
"""
return addRelationship(baseTableName, attributesTable, mappingTableName);
}
|
java
|
public ExtendedRelation addAttributesRelationship(String baseTableName,
AttributesTable attributesTable, String mappingTableName) {
return addRelationship(baseTableName, attributesTable, mappingTableName);
}
|
[
"public",
"ExtendedRelation",
"addAttributesRelationship",
"(",
"String",
"baseTableName",
",",
"AttributesTable",
"attributesTable",
",",
"String",
"mappingTableName",
")",
"{",
"return",
"addRelationship",
"(",
"baseTableName",
",",
"attributesTable",
",",
"mappingTableName",
")",
";",
"}"
] |
Adds an attributes relationship between the base table and user
attributes related table. Creates a default user mapping table and the
attributes table if needed.
@param baseTableName
base table name
@param attributesTable
user attributes table
@param mappingTableName
user mapping table name
@return The relationship that was added
@since 3.2.0
|
[
"Adds",
"an",
"attributes",
"relationship",
"between",
"the",
"base",
"table",
"and",
"user",
"attributes",
"related",
"table",
".",
"Creates",
"a",
"default",
"user",
"mapping",
"table",
"and",
"the",
"attributes",
"table",
"if",
"needed",
"."
] |
train
|
https://github.com/ngageoint/geopackage-core-java/blob/6431c3b041a45b7f3802904ea4156b4082a72daa/src/main/java/mil/nga/geopackage/extension/related/RelatedTablesCoreExtension.java#L641-L644
|
alkacon/opencms-core
|
src-gwt/org/opencms/ade/sitemap/client/alias/CmsAliasTableController.java
|
CmsAliasTableController.editNewRewrite
|
public void editNewRewrite(String rewriteRegex, String rewriteReplacement, CmsAliasMode mode) {
"""
This method is called when the user adds a new rewrite alias.<p>
@param rewriteRegex the rewrite pattern
@param rewriteReplacement the rewrite replacement string
@param mode the rewrite mode
"""
CmsRewriteAliasTableRow row = new CmsRewriteAliasTableRow(
new CmsUUID(CmsClientStringUtil.randomUUID()),
rewriteRegex,
rewriteReplacement,
mode);
m_view.clearRewriteNew();
m_view.getRewriteData().add(0, row);
validateRewrite();
}
|
java
|
public void editNewRewrite(String rewriteRegex, String rewriteReplacement, CmsAliasMode mode) {
CmsRewriteAliasTableRow row = new CmsRewriteAliasTableRow(
new CmsUUID(CmsClientStringUtil.randomUUID()),
rewriteRegex,
rewriteReplacement,
mode);
m_view.clearRewriteNew();
m_view.getRewriteData().add(0, row);
validateRewrite();
}
|
[
"public",
"void",
"editNewRewrite",
"(",
"String",
"rewriteRegex",
",",
"String",
"rewriteReplacement",
",",
"CmsAliasMode",
"mode",
")",
"{",
"CmsRewriteAliasTableRow",
"row",
"=",
"new",
"CmsRewriteAliasTableRow",
"(",
"new",
"CmsUUID",
"(",
"CmsClientStringUtil",
".",
"randomUUID",
"(",
")",
")",
",",
"rewriteRegex",
",",
"rewriteReplacement",
",",
"mode",
")",
";",
"m_view",
".",
"clearRewriteNew",
"(",
")",
";",
"m_view",
".",
"getRewriteData",
"(",
")",
".",
"add",
"(",
"0",
",",
"row",
")",
";",
"validateRewrite",
"(",
")",
";",
"}"
] |
This method is called when the user adds a new rewrite alias.<p>
@param rewriteRegex the rewrite pattern
@param rewriteReplacement the rewrite replacement string
@param mode the rewrite mode
|
[
"This",
"method",
"is",
"called",
"when",
"the",
"user",
"adds",
"a",
"new",
"rewrite",
"alias",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/alias/CmsAliasTableController.java#L199-L209
|
couchbase/couchbase-lite-java
|
src/main/java/com/couchbase/lite/AbstractReplicator.java
|
AbstractReplicator.addDocumentReplicationListener
|
@NonNull
public ListenerToken addDocumentReplicationListener(@NonNull DocumentReplicationListener listener) {
"""
Set the given DocumentReplicationListener to the this replicator.
@param listener
@return ListenerToken A token to remove the handler later
"""
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
return addDocumentReplicationListener(null, listener);
}
|
java
|
@NonNull
public ListenerToken addDocumentReplicationListener(@NonNull DocumentReplicationListener listener) {
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
return addDocumentReplicationListener(null, listener);
}
|
[
"@",
"NonNull",
"public",
"ListenerToken",
"addDocumentReplicationListener",
"(",
"@",
"NonNull",
"DocumentReplicationListener",
"listener",
")",
"{",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"listener cannot be null.\"",
")",
";",
"}",
"return",
"addDocumentReplicationListener",
"(",
"null",
",",
"listener",
")",
";",
"}"
] |
Set the given DocumentReplicationListener to the this replicator.
@param listener
@return ListenerToken A token to remove the handler later
|
[
"Set",
"the",
"given",
"DocumentReplicationListener",
"to",
"the",
"this",
"replicator",
"."
] |
train
|
https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/AbstractReplicator.java#L434-L439
|
raydac/java-comment-preprocessor
|
jcp/src/main/java/com/igormaznitsa/jcp/context/PreprocessorContext.java
|
PreprocessorContext.createDestinationFileForPath
|
@Nonnull
public File createDestinationFileForPath(@Nonnull final String path) {
"""
It allows to create a File object for its path subject to the destination directory path
@param path the path to the file, it must not be null
@return a generated File object for the path
"""
assertNotNull("Path is null", path);
if (path.isEmpty()) {
throw makeException("File name is empty", null);
}
return new File(this.getTarget(), path);
}
|
java
|
@Nonnull
public File createDestinationFileForPath(@Nonnull final String path) {
assertNotNull("Path is null", path);
if (path.isEmpty()) {
throw makeException("File name is empty", null);
}
return new File(this.getTarget(), path);
}
|
[
"@",
"Nonnull",
"public",
"File",
"createDestinationFileForPath",
"(",
"@",
"Nonnull",
"final",
"String",
"path",
")",
"{",
"assertNotNull",
"(",
"\"Path is null\"",
",",
"path",
")",
";",
"if",
"(",
"path",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"makeException",
"(",
"\"File name is empty\"",
",",
"null",
")",
";",
"}",
"return",
"new",
"File",
"(",
"this",
".",
"getTarget",
"(",
")",
",",
"path",
")",
";",
"}"
] |
It allows to create a File object for its path subject to the destination directory path
@param path the path to the file, it must not be null
@return a generated File object for the path
|
[
"It",
"allows",
"to",
"create",
"a",
"File",
"object",
"for",
"its",
"path",
"subject",
"to",
"the",
"destination",
"directory",
"path"
] |
train
|
https://github.com/raydac/java-comment-preprocessor/blob/83ac87b575ac084914d77695a8c8673de3b8300c/jcp/src/main/java/com/igormaznitsa/jcp/context/PreprocessorContext.java#L710-L719
|
alkacon/opencms-core
|
src-modules/org/opencms/workplace/tools/searchindex/CmsDocumentTypeAddList.java
|
CmsDocumentTypeAddList.fillDetailMimetypes
|
private void fillDetailMimetypes(CmsListItem item, String detailId) {
"""
Fills details about configured mime types of the document type into the given item. <p>
@param item the list item to fill
@param detailId the id for the detail to fill
"""
CmsSearchManager searchManager = OpenCms.getSearchManager();
StringBuffer html = new StringBuffer();
String doctypeName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);
// output of mime types
Iterator<String> itMimetypes = docType.getMimeTypes().iterator();
html.append("<ul>\n");
while (itMimetypes.hasNext()) {
html.append(" <li>\n").append(" ").append(itMimetypes.next()).append("\n");
html.append(" </li>");
}
html.append("</ul>\n");
item.set(detailId, html.toString());
}
|
java
|
private void fillDetailMimetypes(CmsListItem item, String detailId) {
CmsSearchManager searchManager = OpenCms.getSearchManager();
StringBuffer html = new StringBuffer();
String doctypeName = (String)item.get(LIST_COLUMN_NAME);
CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);
// output of mime types
Iterator<String> itMimetypes = docType.getMimeTypes().iterator();
html.append("<ul>\n");
while (itMimetypes.hasNext()) {
html.append(" <li>\n").append(" ").append(itMimetypes.next()).append("\n");
html.append(" </li>");
}
html.append("</ul>\n");
item.set(detailId, html.toString());
}
|
[
"private",
"void",
"fillDetailMimetypes",
"(",
"CmsListItem",
"item",
",",
"String",
"detailId",
")",
"{",
"CmsSearchManager",
"searchManager",
"=",
"OpenCms",
".",
"getSearchManager",
"(",
")",
";",
"StringBuffer",
"html",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"doctypeName",
"=",
"(",
"String",
")",
"item",
".",
"get",
"(",
"LIST_COLUMN_NAME",
")",
";",
"CmsSearchDocumentType",
"docType",
"=",
"searchManager",
".",
"getDocumentTypeConfig",
"(",
"doctypeName",
")",
";",
"// output of mime types",
"Iterator",
"<",
"String",
">",
"itMimetypes",
"=",
"docType",
".",
"getMimeTypes",
"(",
")",
".",
"iterator",
"(",
")",
";",
"html",
".",
"append",
"(",
"\"<ul>\\n\"",
")",
";",
"while",
"(",
"itMimetypes",
".",
"hasNext",
"(",
")",
")",
"{",
"html",
".",
"append",
"(",
"\" <li>\\n\"",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"itMimetypes",
".",
"next",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"html",
".",
"append",
"(",
"\" </li>\"",
")",
";",
"}",
"html",
".",
"append",
"(",
"\"</ul>\\n\"",
")",
";",
"item",
".",
"set",
"(",
"detailId",
",",
"html",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Fills details about configured mime types of the document type into the given item. <p>
@param item the list item to fill
@param detailId the id for the detail to fill
|
[
"Fills",
"details",
"about",
"configured",
"mime",
"types",
"of",
"the",
"document",
"type",
"into",
"the",
"given",
"item",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/tools/searchindex/CmsDocumentTypeAddList.java#L492-L510
|
Erudika/para
|
para-client/src/main/java/com/erudika/para/client/ParaClient.java
|
ParaClient.resourcePermissions
|
public Map<String, Map<String, List<String>>> resourcePermissions() {
"""
Returns the permissions for all subjects and resources for current app.
@return a map of subject ids to resource names to a list of allowed methods
"""
return getEntity(invokeGet("_permissions", null), Map.class);
}
|
java
|
public Map<String, Map<String, List<String>>> resourcePermissions() {
return getEntity(invokeGet("_permissions", null), Map.class);
}
|
[
"public",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"resourcePermissions",
"(",
")",
"{",
"return",
"getEntity",
"(",
"invokeGet",
"(",
"\"_permissions\"",
",",
"null",
")",
",",
"Map",
".",
"class",
")",
";",
"}"
] |
Returns the permissions for all subjects and resources for current app.
@return a map of subject ids to resource names to a list of allowed methods
|
[
"Returns",
"the",
"permissions",
"for",
"all",
"subjects",
"and",
"resources",
"for",
"current",
"app",
"."
] |
train
|
https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-client/src/main/java/com/erudika/para/client/ParaClient.java#L1411-L1413
|
apache/incubator-zipkin
|
zipkin-storage/cassandra-v1/src/main/java/zipkin2/storage/cassandra/v1/CassandraStorage.java
|
CassandraStorage.spanConsumer
|
@Override
public SpanConsumer spanConsumer() {
"""
{@inheritDoc} Memoized in order to avoid re-preparing statements
"""
if (spanConsumer == null) {
synchronized (this) {
if (spanConsumer == null) {
spanConsumer = new CassandraSpanConsumer(this, indexCacheSpec);
}
}
}
return spanConsumer;
}
|
java
|
@Override
public SpanConsumer spanConsumer() {
if (spanConsumer == null) {
synchronized (this) {
if (spanConsumer == null) {
spanConsumer = new CassandraSpanConsumer(this, indexCacheSpec);
}
}
}
return spanConsumer;
}
|
[
"@",
"Override",
"public",
"SpanConsumer",
"spanConsumer",
"(",
")",
"{",
"if",
"(",
"spanConsumer",
"==",
"null",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"spanConsumer",
"==",
"null",
")",
"{",
"spanConsumer",
"=",
"new",
"CassandraSpanConsumer",
"(",
"this",
",",
"indexCacheSpec",
")",
";",
"}",
"}",
"}",
"return",
"spanConsumer",
";",
"}"
] |
{@inheritDoc} Memoized in order to avoid re-preparing statements
|
[
"{"
] |
train
|
https://github.com/apache/incubator-zipkin/blob/89b2fab983fc626b3be32ce9d7cf64b3f01f1a87/zipkin-storage/cassandra-v1/src/main/java/zipkin2/storage/cassandra/v1/CassandraStorage.java#L365-L375
|
micwin/ticino
|
context/src/main/java/net/micwin/ticino/context/GenericContext.java
|
GenericContext.lookup
|
@Override
public <TargetContextType extends IModifyableContext<ElementType>> TargetContextType lookup(
final Predicate<ElementType> pPredicate, final TargetContextType pTarget) {
"""
Looks up elements that match given predicate and returns them in given
{@link IModifyableContext}.
@param pPredicate
The criteria the elements must match to be found.
@param pTarget
Where the found elements were put into.
"""
return lookup(pPredicate, Integer.MAX_VALUE, pTarget);
}
|
java
|
@Override
public <TargetContextType extends IModifyableContext<ElementType>> TargetContextType lookup(
final Predicate<ElementType> pPredicate, final TargetContextType pTarget) {
return lookup(pPredicate, Integer.MAX_VALUE, pTarget);
}
|
[
"@",
"Override",
"public",
"<",
"TargetContextType",
"extends",
"IModifyableContext",
"<",
"ElementType",
">",
">",
"TargetContextType",
"lookup",
"(",
"final",
"Predicate",
"<",
"ElementType",
">",
"pPredicate",
",",
"final",
"TargetContextType",
"pTarget",
")",
"{",
"return",
"lookup",
"(",
"pPredicate",
",",
"Integer",
".",
"MAX_VALUE",
",",
"pTarget",
")",
";",
"}"
] |
Looks up elements that match given predicate and returns them in given
{@link IModifyableContext}.
@param pPredicate
The criteria the elements must match to be found.
@param pTarget
Where the found elements were put into.
|
[
"Looks",
"up",
"elements",
"that",
"match",
"given",
"predicate",
"and",
"returns",
"them",
"in",
"given",
"{",
"@link",
"IModifyableContext",
"}",
"."
] |
train
|
https://github.com/micwin/ticino/blob/4d143093500cd2fb9767ebe8cd05ddda23e35613/context/src/main/java/net/micwin/ticino/context/GenericContext.java#L80-L85
|
alkacon/opencms-core
|
src/org/opencms/main/CmsShellCommands.java
|
CmsShellCommands.hardTouch
|
private void hardTouch(CmsObject cms, CmsResource resource) throws CmsException {
"""
Rewrites the content of the given file.<p>
@param cms the CmsObject
@param resource the resource to rewrite the content for
@throws CmsException if something goes wrong
"""
CmsFile file = cms.readFile(resource);
cms = OpenCms.initCmsObject(cms);
cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
file.setContents(file.getContents());
cms.writeFile(file);
}
|
java
|
private void hardTouch(CmsObject cms, CmsResource resource) throws CmsException {
CmsFile file = cms.readFile(resource);
cms = OpenCms.initCmsObject(cms);
cms.getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
file.setContents(file.getContents());
cms.writeFile(file);
}
|
[
"private",
"void",
"hardTouch",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"throws",
"CmsException",
"{",
"CmsFile",
"file",
"=",
"cms",
".",
"readFile",
"(",
"resource",
")",
";",
"cms",
"=",
"OpenCms",
".",
"initCmsObject",
"(",
"cms",
")",
";",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"setAttribute",
"(",
"CmsXmlContent",
".",
"AUTO_CORRECTION_ATTRIBUTE",
",",
"Boolean",
".",
"TRUE",
")",
";",
"file",
".",
"setContents",
"(",
"file",
".",
"getContents",
"(",
")",
")",
";",
"cms",
".",
"writeFile",
"(",
"file",
")",
";",
"}"
] |
Rewrites the content of the given file.<p>
@param cms the CmsObject
@param resource the resource to rewrite the content for
@throws CmsException if something goes wrong
|
[
"Rewrites",
"the",
"content",
"of",
"the",
"given",
"file",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/main/CmsShellCommands.java#L1857-L1864
|
jmchilton/galaxy-bootstrap
|
src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java
|
DownloadProperties.forRelease
|
public static DownloadProperties forRelease(final String release, final File destination) {
"""
Builds a new DownloadProperties for downloading a specific Galaxy release.
@param release The release to pull from GitHub (eg. "v17.01")
@param destination The destination directory to store Galaxy, null if a directory
should be chosen by default.
@return A new DownloadProperties for downloading a specific Galaxy release.
"""
return new DownloadProperties(new WgetGithubDownloader(release), destination);
}
|
java
|
public static DownloadProperties forRelease(final String release, final File destination) {
return new DownloadProperties(new WgetGithubDownloader(release), destination);
}
|
[
"public",
"static",
"DownloadProperties",
"forRelease",
"(",
"final",
"String",
"release",
",",
"final",
"File",
"destination",
")",
"{",
"return",
"new",
"DownloadProperties",
"(",
"new",
"WgetGithubDownloader",
"(",
"release",
")",
",",
"destination",
")",
";",
"}"
] |
Builds a new DownloadProperties for downloading a specific Galaxy release.
@param release The release to pull from GitHub (eg. "v17.01")
@param destination The destination directory to store Galaxy, null if a directory
should be chosen by default.
@return A new DownloadProperties for downloading a specific Galaxy release.
|
[
"Builds",
"a",
"new",
"DownloadProperties",
"for",
"downloading",
"a",
"specific",
"Galaxy",
"release",
"."
] |
train
|
https://github.com/jmchilton/galaxy-bootstrap/blob/4a899f5e6ec0c9f6f4b9b21d5a0320e5925ec649/src/main/java/com/github/jmchilton/galaxybootstrap/DownloadProperties.java#L403-L405
|
caspervg/SC4D-LEX4J
|
lex4j/src/main/java/net/caspervg/lex4j/route/LotRoute.java
|
LotRoute.postComment
|
public void postComment(int id, int rating, String comment) {
"""
Adds a comment and/or rating to a lot/file
@param id ID of the lot/file
@param rating rating for the lot/file (can be null)
@param comment comment for the lot/file (can be null)
@custom.require Authentication
"""
ClientResource resource = new ClientResource(Route.ADD_COMMENT.url(id));
resource.setChallengeResponse(this.auth.toChallenge());
Form form = new Form();
if (id > 0)
form.add("rating", String.valueOf(rating));
if (comment != null && comment.length() > 0)
form.add("comment", comment);
resource.post(form);
}
|
java
|
public void postComment(int id, int rating, String comment) {
ClientResource resource = new ClientResource(Route.ADD_COMMENT.url(id));
resource.setChallengeResponse(this.auth.toChallenge());
Form form = new Form();
if (id > 0)
form.add("rating", String.valueOf(rating));
if (comment != null && comment.length() > 0)
form.add("comment", comment);
resource.post(form);
}
|
[
"public",
"void",
"postComment",
"(",
"int",
"id",
",",
"int",
"rating",
",",
"String",
"comment",
")",
"{",
"ClientResource",
"resource",
"=",
"new",
"ClientResource",
"(",
"Route",
".",
"ADD_COMMENT",
".",
"url",
"(",
"id",
")",
")",
";",
"resource",
".",
"setChallengeResponse",
"(",
"this",
".",
"auth",
".",
"toChallenge",
"(",
")",
")",
";",
"Form",
"form",
"=",
"new",
"Form",
"(",
")",
";",
"if",
"(",
"id",
">",
"0",
")",
"form",
".",
"add",
"(",
"\"rating\"",
",",
"String",
".",
"valueOf",
"(",
"rating",
")",
")",
";",
"if",
"(",
"comment",
"!=",
"null",
"&&",
"comment",
".",
"length",
"(",
")",
">",
"0",
")",
"form",
".",
"add",
"(",
"\"comment\"",
",",
"comment",
")",
";",
"resource",
".",
"post",
"(",
"form",
")",
";",
"}"
] |
Adds a comment and/or rating to a lot/file
@param id ID of the lot/file
@param rating rating for the lot/file (can be null)
@param comment comment for the lot/file (can be null)
@custom.require Authentication
|
[
"Adds",
"a",
"comment",
"and",
"/",
"or",
"rating",
"to",
"a",
"lot",
"/",
"file"
] |
train
|
https://github.com/caspervg/SC4D-LEX4J/blob/3d086ec70c817119a88573c2e23af27276cdb1d6/lex4j/src/main/java/net/caspervg/lex4j/route/LotRoute.java#L175-L186
|
alkacon/opencms-core
|
src/org/opencms/lock/CmsLockManager.java
|
CmsLockManager.getLock
|
public CmsLock getLock(CmsDbContext dbc, CmsResource resource, boolean includeSiblings) throws CmsException {
"""
Returns the lock state of the given resource.<p>
In case no lock is set, the <code>null lock</code> which can be obtained
by {@link CmsLock#getNullLock()} is returned.<p>
@param dbc the current database context
@param resource the resource
@param includeSiblings if siblings (shared locks) should be included in the search
@return the lock state of the given resource
@throws CmsException if something goes wrong
"""
// resources are never locked in the online project
// and non-existent resources are never locked
if ((resource == null) || (dbc.currentProject().isOnlineProject())) {
return CmsLock.getNullLock();
}
// check exclusive direct locks first
CmsLock lock = getDirectLock(resource.getRootPath());
if ((lock == null) && includeSiblings) {
// check if siblings are exclusively locked
List<CmsResource> siblings = internalReadSiblings(dbc, resource);
lock = getSiblingsLock(siblings, resource.getRootPath());
}
if (lock == null) {
// if there is no parent lock, this will be the null lock as well
lock = getParentLock(resource.getRootPath());
}
if (!lock.getSystemLock().isUnlocked()) {
lock = lock.getSystemLock();
} else {
lock = lock.getEditionLock();
}
return lock;
}
|
java
|
public CmsLock getLock(CmsDbContext dbc, CmsResource resource, boolean includeSiblings) throws CmsException {
// resources are never locked in the online project
// and non-existent resources are never locked
if ((resource == null) || (dbc.currentProject().isOnlineProject())) {
return CmsLock.getNullLock();
}
// check exclusive direct locks first
CmsLock lock = getDirectLock(resource.getRootPath());
if ((lock == null) && includeSiblings) {
// check if siblings are exclusively locked
List<CmsResource> siblings = internalReadSiblings(dbc, resource);
lock = getSiblingsLock(siblings, resource.getRootPath());
}
if (lock == null) {
// if there is no parent lock, this will be the null lock as well
lock = getParentLock(resource.getRootPath());
}
if (!lock.getSystemLock().isUnlocked()) {
lock = lock.getSystemLock();
} else {
lock = lock.getEditionLock();
}
return lock;
}
|
[
"public",
"CmsLock",
"getLock",
"(",
"CmsDbContext",
"dbc",
",",
"CmsResource",
"resource",
",",
"boolean",
"includeSiblings",
")",
"throws",
"CmsException",
"{",
"// resources are never locked in the online project",
"// and non-existent resources are never locked",
"if",
"(",
"(",
"resource",
"==",
"null",
")",
"||",
"(",
"dbc",
".",
"currentProject",
"(",
")",
".",
"isOnlineProject",
"(",
")",
")",
")",
"{",
"return",
"CmsLock",
".",
"getNullLock",
"(",
")",
";",
"}",
"// check exclusive direct locks first",
"CmsLock",
"lock",
"=",
"getDirectLock",
"(",
"resource",
".",
"getRootPath",
"(",
")",
")",
";",
"if",
"(",
"(",
"lock",
"==",
"null",
")",
"&&",
"includeSiblings",
")",
"{",
"// check if siblings are exclusively locked",
"List",
"<",
"CmsResource",
">",
"siblings",
"=",
"internalReadSiblings",
"(",
"dbc",
",",
"resource",
")",
";",
"lock",
"=",
"getSiblingsLock",
"(",
"siblings",
",",
"resource",
".",
"getRootPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"lock",
"==",
"null",
")",
"{",
"// if there is no parent lock, this will be the null lock as well",
"lock",
"=",
"getParentLock",
"(",
"resource",
".",
"getRootPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"lock",
".",
"getSystemLock",
"(",
")",
".",
"isUnlocked",
"(",
")",
")",
"{",
"lock",
"=",
"lock",
".",
"getSystemLock",
"(",
")",
";",
"}",
"else",
"{",
"lock",
"=",
"lock",
".",
"getEditionLock",
"(",
")",
";",
"}",
"return",
"lock",
";",
"}"
] |
Returns the lock state of the given resource.<p>
In case no lock is set, the <code>null lock</code> which can be obtained
by {@link CmsLock#getNullLock()} is returned.<p>
@param dbc the current database context
@param resource the resource
@param includeSiblings if siblings (shared locks) should be included in the search
@return the lock state of the given resource
@throws CmsException if something goes wrong
|
[
"Returns",
"the",
"lock",
"state",
"of",
"the",
"given",
"resource",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/lock/CmsLockManager.java#L192-L217
|
b3dgs/lionengine
|
lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/TileCollisionModel.java
|
TileCollisionModel.getInputValue
|
public double getInputValue(Axis input, double x, double y) {
"""
Get the input value relative to tile.
@param input The input used.
@param x The horizontal location.
@param y The vertical location.
@return The input value.
"""
final double v;
switch (input)
{
case X:
v = Math.floor(x - tile.getX());
break;
case Y:
v = Math.floor(y - tile.getY());
break;
default:
throw new LionEngineException(input);
}
return v;
}
|
java
|
public double getInputValue(Axis input, double x, double y)
{
final double v;
switch (input)
{
case X:
v = Math.floor(x - tile.getX());
break;
case Y:
v = Math.floor(y - tile.getY());
break;
default:
throw new LionEngineException(input);
}
return v;
}
|
[
"public",
"double",
"getInputValue",
"(",
"Axis",
"input",
",",
"double",
"x",
",",
"double",
"y",
")",
"{",
"final",
"double",
"v",
";",
"switch",
"(",
"input",
")",
"{",
"case",
"X",
":",
"v",
"=",
"Math",
".",
"floor",
"(",
"x",
"-",
"tile",
".",
"getX",
"(",
")",
")",
";",
"break",
";",
"case",
"Y",
":",
"v",
"=",
"Math",
".",
"floor",
"(",
"y",
"-",
"tile",
".",
"getY",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"LionEngineException",
"(",
"input",
")",
";",
"}",
"return",
"v",
";",
"}"
] |
Get the input value relative to tile.
@param input The input used.
@param x The horizontal location.
@param y The vertical location.
@return The input value.
|
[
"Get",
"the",
"input",
"value",
"relative",
"to",
"tile",
"."
] |
train
|
https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/collision/TileCollisionModel.java#L58-L73
|
apptik/JustJson
|
json-core/src/main/java/io/apptik/json/JsonArray.java
|
JsonArray.getBoolean
|
public Boolean getBoolean(int index, boolean strict) throws JsonException {
"""
Returns the value at {@code index} if it exists and is a boolean or can
be coerced to a boolean.
@throws JsonException if the value at {@code index} doesn't exist or
cannot be coerced to a boolean.
"""
JsonElement el = get(index);
Boolean res = null;
if (strict && !el.isBoolean()) {
throw Util.typeMismatch(index, el, "boolean", true);
}
if (el.isBoolean()) {
res = el.asBoolean();
}
if (el.isString()) {
res = Util.toBoolean(el.asString());
}
if (res == null)
throw Util.typeMismatch(index, el, "boolean", strict);
return res;
}
|
java
|
public Boolean getBoolean(int index, boolean strict) throws JsonException {
JsonElement el = get(index);
Boolean res = null;
if (strict && !el.isBoolean()) {
throw Util.typeMismatch(index, el, "boolean", true);
}
if (el.isBoolean()) {
res = el.asBoolean();
}
if (el.isString()) {
res = Util.toBoolean(el.asString());
}
if (res == null)
throw Util.typeMismatch(index, el, "boolean", strict);
return res;
}
|
[
"public",
"Boolean",
"getBoolean",
"(",
"int",
"index",
",",
"boolean",
"strict",
")",
"throws",
"JsonException",
"{",
"JsonElement",
"el",
"=",
"get",
"(",
"index",
")",
";",
"Boolean",
"res",
"=",
"null",
";",
"if",
"(",
"strict",
"&&",
"!",
"el",
".",
"isBoolean",
"(",
")",
")",
"{",
"throw",
"Util",
".",
"typeMismatch",
"(",
"index",
",",
"el",
",",
"\"boolean\"",
",",
"true",
")",
";",
"}",
"if",
"(",
"el",
".",
"isBoolean",
"(",
")",
")",
"{",
"res",
"=",
"el",
".",
"asBoolean",
"(",
")",
";",
"}",
"if",
"(",
"el",
".",
"isString",
"(",
")",
")",
"{",
"res",
"=",
"Util",
".",
"toBoolean",
"(",
"el",
".",
"asString",
"(",
")",
")",
";",
"}",
"if",
"(",
"res",
"==",
"null",
")",
"throw",
"Util",
".",
"typeMismatch",
"(",
"index",
",",
"el",
",",
"\"boolean\"",
",",
"strict",
")",
";",
"return",
"res",
";",
"}"
] |
Returns the value at {@code index} if it exists and is a boolean or can
be coerced to a boolean.
@throws JsonException if the value at {@code index} doesn't exist or
cannot be coerced to a boolean.
|
[
"Returns",
"the",
"value",
"at",
"{",
"@code",
"index",
"}",
"if",
"it",
"exists",
"and",
"is",
"a",
"boolean",
"or",
"can",
"be",
"coerced",
"to",
"a",
"boolean",
"."
] |
train
|
https://github.com/apptik/JustJson/blob/c90f0dd7f84df26da4749be8cd9b026fff499a79/json-core/src/main/java/io/apptik/json/JsonArray.java#L326-L341
|
comapi/comapi-chat-sdk-android
|
COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java
|
MessageProcessor.createTempMessage
|
public ChatMessage createTempMessage() {
"""
Create a temporary message to be displayed while the message is being send. to be replaced later on with a final message constructed with MessageProcessor#createFinalMessage(MessageSentResponse).
@return Temporary message to be saved in persistance store.
"""
return ChatMessage.builder()
.setMessageId(tempId)
.setSentEventId(-1L) // temporary value, will be replaced by persistence controller
.setConversationId(conversationId)
.setSentBy(sender)
.setFromWhom(new Sender(sender, sender))
.setSentOn(System.currentTimeMillis())
.setParts(getAllParts())
.setMetadata(originalMessage.getMetadata())
.build();
}
|
java
|
public ChatMessage createTempMessage() {
return ChatMessage.builder()
.setMessageId(tempId)
.setSentEventId(-1L) // temporary value, will be replaced by persistence controller
.setConversationId(conversationId)
.setSentBy(sender)
.setFromWhom(new Sender(sender, sender))
.setSentOn(System.currentTimeMillis())
.setParts(getAllParts())
.setMetadata(originalMessage.getMetadata())
.build();
}
|
[
"public",
"ChatMessage",
"createTempMessage",
"(",
")",
"{",
"return",
"ChatMessage",
".",
"builder",
"(",
")",
".",
"setMessageId",
"(",
"tempId",
")",
".",
"setSentEventId",
"(",
"-",
"1L",
")",
"// temporary value, will be replaced by persistence controller",
".",
"setConversationId",
"(",
"conversationId",
")",
".",
"setSentBy",
"(",
"sender",
")",
".",
"setFromWhom",
"(",
"new",
"Sender",
"(",
"sender",
",",
"sender",
")",
")",
".",
"setSentOn",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
".",
"setParts",
"(",
"getAllParts",
"(",
")",
")",
".",
"setMetadata",
"(",
"originalMessage",
".",
"getMetadata",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Create a temporary message to be displayed while the message is being send. to be replaced later on with a final message constructed with MessageProcessor#createFinalMessage(MessageSentResponse).
@return Temporary message to be saved in persistance store.
|
[
"Create",
"a",
"temporary",
"message",
"to",
"be",
"displayed",
"while",
"the",
"message",
"is",
"being",
"send",
".",
"to",
"be",
"replaced",
"later",
"on",
"with",
"a",
"final",
"message",
"constructed",
"with",
"MessageProcessor#createFinalMessage",
"(",
"MessageSentResponse",
")",
"."
] |
train
|
https://github.com/comapi/comapi-chat-sdk-android/blob/388f37bfacb7793ce30c92ab70e5f32848bbe460/COMAPI/chat/src/main/java/com/comapi/chat/internal/MessageProcessor.java#L231-L242
|
sshtools/j2ssh-maverick
|
j2ssh-maverick/src/main/java/com/sshtools/publickey/AbstractKnownHostsKeyVerification.java
|
AbstractKnownHostsKeyVerification.allowHost
|
public void allowHost(String host, SshPublicKey pk, boolean always)
throws SshException {
"""
<p>
Allows a host key, optionally recording the key to the known_hosts file.
</p>
@param host
the name of the host
@param pk
the public key to allow
@param always
true if the key should be written to the known_hosts file
@throws InvalidHostFileException
if the host file cannot be written
@since 0.2.0
"""
// Put the host into the allowed hosts list, overiding any previous
// entry
if (hashHosts) {
SshHmac sha1 = (SshHmac) ComponentManager.getInstance()
.supportedHMacsCS().getInstance("hmac-sha1");
byte[] hashSalt = new byte[sha1.getMacLength()];
ComponentManager.getInstance().getRND().nextBytes(hashSalt);
sha1.init(hashSalt);
sha1.update(host.getBytes());
byte[] theHash = sha1.doFinal();
String names = HASH_MAGIC + Base64.encodeBytes(hashSalt, false)
+ HASH_DELIM + Base64.encodeBytes(theHash, false);
putAllowedKey(names, pk, always);
} else {
putAllowedKey(host, pk, always);
}
// allowedHosts.put(host, pk);
// If we always want to allow then save the host file with the
// new details
if (always) {
try {
saveHostFile();
} catch (IOException ex) {
throw new SshException("knownhosts file could not be saved! "
+ ex.getMessage(), SshException.INTERNAL_ERROR);
}
}
}
|
java
|
public void allowHost(String host, SshPublicKey pk, boolean always)
throws SshException {
// Put the host into the allowed hosts list, overiding any previous
// entry
if (hashHosts) {
SshHmac sha1 = (SshHmac) ComponentManager.getInstance()
.supportedHMacsCS().getInstance("hmac-sha1");
byte[] hashSalt = new byte[sha1.getMacLength()];
ComponentManager.getInstance().getRND().nextBytes(hashSalt);
sha1.init(hashSalt);
sha1.update(host.getBytes());
byte[] theHash = sha1.doFinal();
String names = HASH_MAGIC + Base64.encodeBytes(hashSalt, false)
+ HASH_DELIM + Base64.encodeBytes(theHash, false);
putAllowedKey(names, pk, always);
} else {
putAllowedKey(host, pk, always);
}
// allowedHosts.put(host, pk);
// If we always want to allow then save the host file with the
// new details
if (always) {
try {
saveHostFile();
} catch (IOException ex) {
throw new SshException("knownhosts file could not be saved! "
+ ex.getMessage(), SshException.INTERNAL_ERROR);
}
}
}
|
[
"public",
"void",
"allowHost",
"(",
"String",
"host",
",",
"SshPublicKey",
"pk",
",",
"boolean",
"always",
")",
"throws",
"SshException",
"{",
"// Put the host into the allowed hosts list, overiding any previous",
"// entry",
"if",
"(",
"hashHosts",
")",
"{",
"SshHmac",
"sha1",
"=",
"(",
"SshHmac",
")",
"ComponentManager",
".",
"getInstance",
"(",
")",
".",
"supportedHMacsCS",
"(",
")",
".",
"getInstance",
"(",
"\"hmac-sha1\"",
")",
";",
"byte",
"[",
"]",
"hashSalt",
"=",
"new",
"byte",
"[",
"sha1",
".",
"getMacLength",
"(",
")",
"]",
";",
"ComponentManager",
".",
"getInstance",
"(",
")",
".",
"getRND",
"(",
")",
".",
"nextBytes",
"(",
"hashSalt",
")",
";",
"sha1",
".",
"init",
"(",
"hashSalt",
")",
";",
"sha1",
".",
"update",
"(",
"host",
".",
"getBytes",
"(",
")",
")",
";",
"byte",
"[",
"]",
"theHash",
"=",
"sha1",
".",
"doFinal",
"(",
")",
";",
"String",
"names",
"=",
"HASH_MAGIC",
"+",
"Base64",
".",
"encodeBytes",
"(",
"hashSalt",
",",
"false",
")",
"+",
"HASH_DELIM",
"+",
"Base64",
".",
"encodeBytes",
"(",
"theHash",
",",
"false",
")",
";",
"putAllowedKey",
"(",
"names",
",",
"pk",
",",
"always",
")",
";",
"}",
"else",
"{",
"putAllowedKey",
"(",
"host",
",",
"pk",
",",
"always",
")",
";",
"}",
"// allowedHosts.put(host, pk);",
"// If we always want to allow then save the host file with the",
"// new details",
"if",
"(",
"always",
")",
"{",
"try",
"{",
"saveHostFile",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"SshException",
"(",
"\"knownhosts file could not be saved! \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
",",
"SshException",
".",
"INTERNAL_ERROR",
")",
";",
"}",
"}",
"}"
] |
<p>
Allows a host key, optionally recording the key to the known_hosts file.
</p>
@param host
the name of the host
@param pk
the public key to allow
@param always
true if the key should be written to the known_hosts file
@throws InvalidHostFileException
if the host file cannot be written
@since 0.2.0
|
[
"<p",
">",
"Allows",
"a",
"host",
"key",
"optionally",
"recording",
"the",
"key",
"to",
"the",
"known_hosts",
"file",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sshtools/j2ssh-maverick/blob/ce11ceaf0aa0b129b54327a6891973e1e34689f7/j2ssh-maverick/src/main/java/com/sshtools/publickey/AbstractKnownHostsKeyVerification.java#L312-L347
|
zxing/zxing
|
core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java
|
Decoder.readByte
|
private static byte readByte(boolean[] rawbits, int startIndex) {
"""
Reads a code of length 8 in an array of bits, padding with zeros
"""
int n = rawbits.length - startIndex;
if (n >= 8) {
return (byte) readCode(rawbits, startIndex, 8);
}
return (byte) (readCode(rawbits, startIndex, n) << (8 - n));
}
|
java
|
private static byte readByte(boolean[] rawbits, int startIndex) {
int n = rawbits.length - startIndex;
if (n >= 8) {
return (byte) readCode(rawbits, startIndex, 8);
}
return (byte) (readCode(rawbits, startIndex, n) << (8 - n));
}
|
[
"private",
"static",
"byte",
"readByte",
"(",
"boolean",
"[",
"]",
"rawbits",
",",
"int",
"startIndex",
")",
"{",
"int",
"n",
"=",
"rawbits",
".",
"length",
"-",
"startIndex",
";",
"if",
"(",
"n",
">=",
"8",
")",
"{",
"return",
"(",
"byte",
")",
"readCode",
"(",
"rawbits",
",",
"startIndex",
",",
"8",
")",
";",
"}",
"return",
"(",
"byte",
")",
"(",
"readCode",
"(",
"rawbits",
",",
"startIndex",
",",
"n",
")",
"<<",
"(",
"8",
"-",
"n",
")",
")",
";",
"}"
] |
Reads a code of length 8 in an array of bits, padding with zeros
|
[
"Reads",
"a",
"code",
"of",
"length",
"8",
"in",
"an",
"array",
"of",
"bits",
"padding",
"with",
"zeros"
] |
train
|
https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java#L344-L350
|
ehcache/ehcache3
|
impl/src/main/java/org/ehcache/impl/internal/resilience/RobustLoaderWriterResilienceStrategy.java
|
RobustLoaderWriterResilienceStrategy.putFailure
|
@Override
public void putFailure(K key, V value, StoreAccessException e) {
"""
Write the value to the loader-write.
@param key the key being put
@param value the value being put
@param e the triggered failure
"""
try {
loaderWriter.write(key, value);
} catch (Exception e1) {
throw ExceptionFactory.newCacheWritingException(e1, e);
} finally {
cleanup(key, e);
}
}
|
java
|
@Override
public void putFailure(K key, V value, StoreAccessException e) {
try {
loaderWriter.write(key, value);
} catch (Exception e1) {
throw ExceptionFactory.newCacheWritingException(e1, e);
} finally {
cleanup(key, e);
}
}
|
[
"@",
"Override",
"public",
"void",
"putFailure",
"(",
"K",
"key",
",",
"V",
"value",
",",
"StoreAccessException",
"e",
")",
"{",
"try",
"{",
"loaderWriter",
".",
"write",
"(",
"key",
",",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"throw",
"ExceptionFactory",
".",
"newCacheWritingException",
"(",
"e1",
",",
"e",
")",
";",
"}",
"finally",
"{",
"cleanup",
"(",
"key",
",",
"e",
")",
";",
"}",
"}"
] |
Write the value to the loader-write.
@param key the key being put
@param value the value being put
@param e the triggered failure
|
[
"Write",
"the",
"value",
"to",
"the",
"loader",
"-",
"write",
"."
] |
train
|
https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/impl/src/main/java/org/ehcache/impl/internal/resilience/RobustLoaderWriterResilienceStrategy.java#L86-L95
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionValuePersistenceImpl.java
|
CPOptionValuePersistenceImpl.findByCPOptionId
|
@Override
public List<CPOptionValue> findByCPOptionId(long CPOptionId, int start,
int end) {
"""
Returns a range of all the cp option values where CPOptionId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPOptionValueModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPOptionId the cp option ID
@param start the lower bound of the range of cp option values
@param end the upper bound of the range of cp option values (not inclusive)
@return the range of matching cp option values
"""
return findByCPOptionId(CPOptionId, start, end, null);
}
|
java
|
@Override
public List<CPOptionValue> findByCPOptionId(long CPOptionId, int start,
int end) {
return findByCPOptionId(CPOptionId, start, end, null);
}
|
[
"@",
"Override",
"public",
"List",
"<",
"CPOptionValue",
">",
"findByCPOptionId",
"(",
"long",
"CPOptionId",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findByCPOptionId",
"(",
"CPOptionId",
",",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] |
Returns a range of all the cp option values where CPOptionId = ?.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CPOptionValueModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param CPOptionId the cp option ID
@param start the lower bound of the range of cp option values
@param end the upper bound of the range of cp option values (not inclusive)
@return the range of matching cp option values
|
[
"Returns",
"a",
"range",
"of",
"all",
"the",
"cp",
"option",
"values",
"where",
"CPOptionId",
"=",
"?",
";",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionValuePersistenceImpl.java#L2545-L2549
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Handler.java
|
Handler.reportError
|
protected void reportError(String msg, Exception ex, int code) {
"""
Protected convenience method to report an error to this Handler's
ErrorManager. Note that this method retrieves and uses the ErrorManager
without doing a security check. It can therefore be used in
environments where the caller may be non-privileged.
@param msg a descriptive string (may be null)
@param ex an exception (may be null)
@param code an error code defined in ErrorManager
"""
try {
errorManager.error(msg, ex, code);
} catch (Exception ex2) {
System.err.println("Handler.reportError caught:");
ex2.printStackTrace();
}
}
|
java
|
protected void reportError(String msg, Exception ex, int code) {
try {
errorManager.error(msg, ex, code);
} catch (Exception ex2) {
System.err.println("Handler.reportError caught:");
ex2.printStackTrace();
}
}
|
[
"protected",
"void",
"reportError",
"(",
"String",
"msg",
",",
"Exception",
"ex",
",",
"int",
"code",
")",
"{",
"try",
"{",
"errorManager",
".",
"error",
"(",
"msg",
",",
"ex",
",",
"code",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex2",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Handler.reportError caught:\"",
")",
";",
"ex2",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Protected convenience method to report an error to this Handler's
ErrorManager. Note that this method retrieves and uses the ErrorManager
without doing a security check. It can therefore be used in
environments where the caller may be non-privileged.
@param msg a descriptive string (may be null)
@param ex an exception (may be null)
@param code an error code defined in ErrorManager
|
[
"Protected",
"convenience",
"method",
"to",
"report",
"an",
"error",
"to",
"this",
"Handler",
"s",
"ErrorManager",
".",
"Note",
"that",
"this",
"method",
"retrieves",
"and",
"uses",
"the",
"ErrorManager",
"without",
"doing",
"a",
"security",
"check",
".",
"It",
"can",
"therefore",
"be",
"used",
"in",
"environments",
"where",
"the",
"caller",
"may",
"be",
"non",
"-",
"privileged",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/logging/Handler.java#L239-L246
|
gallandarakhneorg/afc
|
core/vmutils/src/main/java/org/arakhne/afc/vmutil/locale/Locale.java
|
Locale.getStringWithDefaultFrom
|
@Pure
@Inline(value = "Locale.getStringWithDefaultFrom(ClassLoaderFinder.findClassLoader(), ($1), ($2), ($3), ($4))",
imported = {
"""
Replies the text that corresponds to the specified resource.
<p>The <code>resourcePath</code> argument should be a fully
qualified class name. However, for compatibility with earlier
versions, Sun's Java SE Runtime Environments do not verify this,
and so it is possible to access <code>PropertyResourceBundle</code>s
by specifying a path name (using "/") instead of a fully
qualified class name (using ".").
@param resourcePath is the name (path) of the resource file, a fully qualified class name
@param key is the name of the resource into the specified file
@param defaultValue is the default value to replies if the resource does not contain the specified key.
@param params is the the list of parameters which will
replaces the <code>#1</code>, <code>#2</code>... into the string.
@return the text that corresponds to the specified resource
"""Locale.class, ClassLoaderFinder.class})
public static String getStringWithDefaultFrom(String resourcePath, String key, String defaultValue, Object... params) {
// This method try to use the plugin manager class loader
// if it exists, otherwhise, it use the default class loader
return getStringWithDefaultFrom(
ClassLoaderFinder.findClassLoader(),
resourcePath, key, defaultValue, params);
}
|
java
|
@Pure
@Inline(value = "Locale.getStringWithDefaultFrom(ClassLoaderFinder.findClassLoader(), ($1), ($2), ($3), ($4))",
imported = {Locale.class, ClassLoaderFinder.class})
public static String getStringWithDefaultFrom(String resourcePath, String key, String defaultValue, Object... params) {
// This method try to use the plugin manager class loader
// if it exists, otherwhise, it use the default class loader
return getStringWithDefaultFrom(
ClassLoaderFinder.findClassLoader(),
resourcePath, key, defaultValue, params);
}
|
[
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"Locale.getStringWithDefaultFrom(ClassLoaderFinder.findClassLoader(), ($1), ($2), ($3), ($4))\"",
",",
"imported",
"=",
"{",
"Locale",
".",
"class",
",",
"ClassLoaderFinder",
".",
"class",
"}",
")",
"public",
"static",
"String",
"getStringWithDefaultFrom",
"(",
"String",
"resourcePath",
",",
"String",
"key",
",",
"String",
"defaultValue",
",",
"Object",
"...",
"params",
")",
"{",
"// This method try to use the plugin manager class loader",
"// if it exists, otherwhise, it use the default class loader",
"return",
"getStringWithDefaultFrom",
"(",
"ClassLoaderFinder",
".",
"findClassLoader",
"(",
")",
",",
"resourcePath",
",",
"key",
",",
"defaultValue",
",",
"params",
")",
";",
"}"
] |
Replies the text that corresponds to the specified resource.
<p>The <code>resourcePath</code> argument should be a fully
qualified class name. However, for compatibility with earlier
versions, Sun's Java SE Runtime Environments do not verify this,
and so it is possible to access <code>PropertyResourceBundle</code>s
by specifying a path name (using "/") instead of a fully
qualified class name (using ".").
@param resourcePath is the name (path) of the resource file, a fully qualified class name
@param key is the name of the resource into the specified file
@param defaultValue is the default value to replies if the resource does not contain the specified key.
@param params is the the list of parameters which will
replaces the <code>#1</code>, <code>#2</code>... into the string.
@return the text that corresponds to the specified resource
|
[
"Replies",
"the",
"text",
"that",
"corresponds",
"to",
"the",
"specified",
"resource",
"."
] |
train
|
https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/locale/Locale.java#L140-L149
|
JOML-CI/JOML
|
src/org/joml/Matrix4f.java
|
Matrix4f.setPerspectiveLH
|
public Matrix4f setPerspectiveLH(float fovy, float aspect, float zNear, float zFar) {
"""
Set this matrix to be a symmetric perspective projection frustum transformation for a left-handed coordinate system
using OpenGL's NDC z range of <code>[-1..+1]</code>.
<p>
In order to apply the perspective projection transformation to an existing transformation,
use {@link #perspectiveLH(float, float, float, float) perspectiveLH()}.
@see #perspectiveLH(float, float, float, float)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Float#POSITIVE_INFINITY}.
@return this
"""
return setPerspectiveLH(fovy, aspect, zNear, zFar, false);
}
|
java
|
public Matrix4f setPerspectiveLH(float fovy, float aspect, float zNear, float zFar) {
return setPerspectiveLH(fovy, aspect, zNear, zFar, false);
}
|
[
"public",
"Matrix4f",
"setPerspectiveLH",
"(",
"float",
"fovy",
",",
"float",
"aspect",
",",
"float",
"zNear",
",",
"float",
"zFar",
")",
"{",
"return",
"setPerspectiveLH",
"(",
"fovy",
",",
"aspect",
",",
"zNear",
",",
"zFar",
",",
"false",
")",
";",
"}"
] |
Set this matrix to be a symmetric perspective projection frustum transformation for a left-handed coordinate system
using OpenGL's NDC z range of <code>[-1..+1]</code>.
<p>
In order to apply the perspective projection transformation to an existing transformation,
use {@link #perspectiveLH(float, float, float, float) perspectiveLH()}.
@see #perspectiveLH(float, float, float, float)
@param fovy
the vertical field of view in radians (must be greater than zero and less than {@link Math#PI PI})
@param aspect
the aspect ratio (i.e. width / height; must be greater than zero)
@param zNear
near clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the near clipping plane will be at positive infinity.
In that case, <code>zFar</code> may not also be {@link Float#POSITIVE_INFINITY}.
@param zFar
far clipping plane distance. If the special value {@link Float#POSITIVE_INFINITY} is used, the far clipping plane will be at positive infinity.
In that case, <code>zNear</code> may not also be {@link Float#POSITIVE_INFINITY}.
@return this
|
[
"Set",
"this",
"matrix",
"to",
"be",
"a",
"symmetric",
"perspective",
"projection",
"frustum",
"transformation",
"for",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"using",
"OpenGL",
"s",
"NDC",
"z",
"range",
"of",
"<code",
">",
"[",
"-",
"1",
"..",
"+",
"1",
"]",
"<",
"/",
"code",
">",
".",
"<p",
">",
"In",
"order",
"to",
"apply",
"the",
"perspective",
"projection",
"transformation",
"to",
"an",
"existing",
"transformation",
"use",
"{",
"@link",
"#perspectiveLH",
"(",
"float",
"float",
"float",
"float",
")",
"perspectiveLH",
"()",
"}",
"."
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4f.java#L10281-L10283
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/contact/AtomContactSet.java
|
AtomContactSet.getContact
|
public AtomContact getContact(Atom atom1, Atom atom2) {
"""
Returns the corresponding AtomContact or null if no contact exists between the 2 given atoms
@param atom1
@param atom2
@return
"""
return contacts.get(new Pair<AtomIdentifier>(
new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()),
new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) ));
}
|
java
|
public AtomContact getContact(Atom atom1, Atom atom2) {
return contacts.get(new Pair<AtomIdentifier>(
new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()),
new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) ));
}
|
[
"public",
"AtomContact",
"getContact",
"(",
"Atom",
"atom1",
",",
"Atom",
"atom2",
")",
"{",
"return",
"contacts",
".",
"get",
"(",
"new",
"Pair",
"<",
"AtomIdentifier",
">",
"(",
"new",
"AtomIdentifier",
"(",
"atom1",
".",
"getPDBserial",
"(",
")",
",",
"atom1",
".",
"getGroup",
"(",
")",
".",
"getChainId",
"(",
")",
")",
",",
"new",
"AtomIdentifier",
"(",
"atom2",
".",
"getPDBserial",
"(",
")",
",",
"atom2",
".",
"getGroup",
"(",
")",
".",
"getChainId",
"(",
")",
")",
")",
")",
";",
"}"
] |
Returns the corresponding AtomContact or null if no contact exists between the 2 given atoms
@param atom1
@param atom2
@return
|
[
"Returns",
"the",
"corresponding",
"AtomContact",
"or",
"null",
"if",
"no",
"contact",
"exists",
"between",
"the",
"2",
"given",
"atoms"
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/AtomContactSet.java#L74-L78
|
carrotsearch/hppc
|
hppc/src/main/templates/com/carrotsearch/hppc/KTypeVTypeHashMap.java
|
KTypeVTypeHashMap.putIfAbsent
|
public boolean putIfAbsent(KType key, VType value) {
"""
<a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent
of the following code:
<pre>
if (!map.containsKey(key)) map.put(value);
</pre>
@param key The key of the value to check.
@param value The value to put if <code>key</code> does not exist.
@return <code>true</code> if <code>key</code> did not exist and <code>value</code>
was placed in the map.
"""
int keyIndex = indexOf(key);
if (!indexExists(keyIndex)) {
indexInsert(keyIndex, key, value);
return true;
} else {
return false;
}
}
|
java
|
public boolean putIfAbsent(KType key, VType value) {
int keyIndex = indexOf(key);
if (!indexExists(keyIndex)) {
indexInsert(keyIndex, key, value);
return true;
} else {
return false;
}
}
|
[
"public",
"boolean",
"putIfAbsent",
"(",
"KType",
"key",
",",
"VType",
"value",
")",
"{",
"int",
"keyIndex",
"=",
"indexOf",
"(",
"key",
")",
";",
"if",
"(",
"!",
"indexExists",
"(",
"keyIndex",
")",
")",
"{",
"indexInsert",
"(",
"keyIndex",
",",
"key",
",",
"value",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
<a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent
of the following code:
<pre>
if (!map.containsKey(key)) map.put(value);
</pre>
@param key The key of the value to check.
@param value The value to put if <code>key</code> does not exist.
@return <code>true</code> if <code>key</code> did not exist and <code>value</code>
was placed in the map.
|
[
"<a",
"href",
"=",
"http",
":",
"//",
"trove4j",
".",
"sourceforge",
".",
"net",
">",
"Trove<",
"/",
"a",
">",
"-",
"inspired",
"API",
"method",
".",
"An",
"equivalent",
"of",
"the",
"following",
"code",
":",
"<pre",
">",
"if",
"(",
"!map",
".",
"containsKey",
"(",
"key",
"))",
"map",
".",
"put",
"(",
"value",
")",
";",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/carrotsearch/hppc/blob/e359e9da358e846fcbffc64a765611df954ba3f6/hppc/src/main/templates/com/carrotsearch/hppc/KTypeVTypeHashMap.java#L227-L235
|
jcuda/jcuda
|
JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java
|
JCudaDriver.cuTexRefGetAddressMode
|
public static int cuTexRefGetAddressMode(int pam[], CUtexref hTexRef, int dim) {
"""
Gets the addressing mode used by a texture reference.
<pre>
CUresult cuTexRefGetAddressMode (
CUaddress_mode* pam,
CUtexref hTexRef,
int dim )
</pre>
<div>
<p>Gets the addressing mode used by a
texture reference. Returns in <tt>*pam</tt> the addressing mode
corresponding to the dimension <tt>dim</tt> of the texture reference
<tt>hTexRef</tt>. Currently, the only valid value for <tt>dim</tt>
are 0 and 1.
</p>
</div>
@param pam Returned addressing mode
@param hTexRef Texture reference
@param dim Dimension
@return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
@see JCudaDriver#cuTexRefSetAddress
@see JCudaDriver#cuTexRefSetAddress2D
@see JCudaDriver#cuTexRefSetAddressMode
@see JCudaDriver#cuTexRefSetArray
@see JCudaDriver#cuTexRefSetFilterMode
@see JCudaDriver#cuTexRefSetFlags
@see JCudaDriver#cuTexRefSetFormat
@see JCudaDriver#cuTexRefGetAddress
@see JCudaDriver#cuTexRefGetArray
@see JCudaDriver#cuTexRefGetFilterMode
@see JCudaDriver#cuTexRefGetFlags
@see JCudaDriver#cuTexRefGetFormat
"""
return checkResult(cuTexRefGetAddressModeNative(pam, hTexRef, dim));
}
|
java
|
public static int cuTexRefGetAddressMode(int pam[], CUtexref hTexRef, int dim)
{
return checkResult(cuTexRefGetAddressModeNative(pam, hTexRef, dim));
}
|
[
"public",
"static",
"int",
"cuTexRefGetAddressMode",
"(",
"int",
"pam",
"[",
"]",
",",
"CUtexref",
"hTexRef",
",",
"int",
"dim",
")",
"{",
"return",
"checkResult",
"(",
"cuTexRefGetAddressModeNative",
"(",
"pam",
",",
"hTexRef",
",",
"dim",
")",
")",
";",
"}"
] |
Gets the addressing mode used by a texture reference.
<pre>
CUresult cuTexRefGetAddressMode (
CUaddress_mode* pam,
CUtexref hTexRef,
int dim )
</pre>
<div>
<p>Gets the addressing mode used by a
texture reference. Returns in <tt>*pam</tt> the addressing mode
corresponding to the dimension <tt>dim</tt> of the texture reference
<tt>hTexRef</tt>. Currently, the only valid value for <tt>dim</tt>
are 0 and 1.
</p>
</div>
@param pam Returned addressing mode
@param hTexRef Texture reference
@param dim Dimension
@return CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED,
CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE
@see JCudaDriver#cuTexRefSetAddress
@see JCudaDriver#cuTexRefSetAddress2D
@see JCudaDriver#cuTexRefSetAddressMode
@see JCudaDriver#cuTexRefSetArray
@see JCudaDriver#cuTexRefSetFilterMode
@see JCudaDriver#cuTexRefSetFlags
@see JCudaDriver#cuTexRefSetFormat
@see JCudaDriver#cuTexRefGetAddress
@see JCudaDriver#cuTexRefGetArray
@see JCudaDriver#cuTexRefGetFilterMode
@see JCudaDriver#cuTexRefGetFlags
@see JCudaDriver#cuTexRefGetFormat
|
[
"Gets",
"the",
"addressing",
"mode",
"used",
"by",
"a",
"texture",
"reference",
"."
] |
train
|
https://github.com/jcuda/jcuda/blob/468528b5b9b37dfceb6ed83fcfd889e9b359f984/JCudaJava/src/main/java/jcuda/driver/JCudaDriver.java#L10519-L10522
|
Alexey1Gavrilov/ExpectIt
|
expectit-core/src/main/java/net/sf/expectit/matcher/SimpleResult.java
|
SimpleResult.failure
|
public static Result failure(String input, boolean canStopMatching) {
"""
Creates an instance of an unsuccessful match.
@param input the input string.
@param canStopMatching indicates whether matching operation can be stopped.
@return the result object.
"""
return new SimpleResult(false, input, null, null, canStopMatching);
}
|
java
|
public static Result failure(String input, boolean canStopMatching) {
return new SimpleResult(false, input, null, null, canStopMatching);
}
|
[
"public",
"static",
"Result",
"failure",
"(",
"String",
"input",
",",
"boolean",
"canStopMatching",
")",
"{",
"return",
"new",
"SimpleResult",
"(",
"false",
",",
"input",
",",
"null",
",",
"null",
",",
"canStopMatching",
")",
";",
"}"
] |
Creates an instance of an unsuccessful match.
@param input the input string.
@param canStopMatching indicates whether matching operation can be stopped.
@return the result object.
|
[
"Creates",
"an",
"instance",
"of",
"an",
"unsuccessful",
"match",
"."
] |
train
|
https://github.com/Alexey1Gavrilov/ExpectIt/blob/5acbe1f8f895fe1dbd63e29bf3ab8e5bbf0873c3/expectit-core/src/main/java/net/sf/expectit/matcher/SimpleResult.java#L146-L148
|
line/armeria
|
core/src/main/java/com/linecorp/armeria/server/docs/DocServiceBuilder.java
|
DocServiceBuilder.exampleRequestForMethod
|
public DocServiceBuilder exampleRequestForMethod(String serviceName, String methodName,
Object... exampleRequests) {
"""
Adds the example requests for the method with the specified service and method name.
"""
requireNonNull(exampleRequests, "exampleRequests");
return exampleRequestForMethod(serviceName, methodName, ImmutableList.copyOf(exampleRequests));
}
|
java
|
public DocServiceBuilder exampleRequestForMethod(String serviceName, String methodName,
Object... exampleRequests) {
requireNonNull(exampleRequests, "exampleRequests");
return exampleRequestForMethod(serviceName, methodName, ImmutableList.copyOf(exampleRequests));
}
|
[
"public",
"DocServiceBuilder",
"exampleRequestForMethod",
"(",
"String",
"serviceName",
",",
"String",
"methodName",
",",
"Object",
"...",
"exampleRequests",
")",
"{",
"requireNonNull",
"(",
"exampleRequests",
",",
"\"exampleRequests\"",
")",
";",
"return",
"exampleRequestForMethod",
"(",
"serviceName",
",",
"methodName",
",",
"ImmutableList",
".",
"copyOf",
"(",
"exampleRequests",
")",
")",
";",
"}"
] |
Adds the example requests for the method with the specified service and method name.
|
[
"Adds",
"the",
"example",
"requests",
"for",
"the",
"method",
"with",
"the",
"specified",
"service",
"and",
"method",
"name",
"."
] |
train
|
https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/server/docs/DocServiceBuilder.java#L208-L212
|
Netflix/eureka
|
eureka-core/src/main/java/com/netflix/eureka/cluster/PeerEurekaNode.java
|
PeerEurekaNode.deleteStatusOverride
|
public void deleteStatusOverride(final String appName, final String id, final InstanceInfo info) {
"""
Delete instance status override.
@param appName
the application name of the instance.
@param id
the unique identifier of the instance.
@param info
the instance information of the instance.
"""
long expiryTime = System.currentTimeMillis() + maxProcessingDelayMs;
batchingDispatcher.process(
taskId("deleteStatusOverride", appName, id),
new InstanceReplicationTask(targetHost, Action.DeleteStatusOverride, info, null, false) {
@Override
public EurekaHttpResponse<Void> execute() {
return replicationClient.deleteStatusOverride(appName, id, info);
}
},
expiryTime);
}
|
java
|
public void deleteStatusOverride(final String appName, final String id, final InstanceInfo info) {
long expiryTime = System.currentTimeMillis() + maxProcessingDelayMs;
batchingDispatcher.process(
taskId("deleteStatusOverride", appName, id),
new InstanceReplicationTask(targetHost, Action.DeleteStatusOverride, info, null, false) {
@Override
public EurekaHttpResponse<Void> execute() {
return replicationClient.deleteStatusOverride(appName, id, info);
}
},
expiryTime);
}
|
[
"public",
"void",
"deleteStatusOverride",
"(",
"final",
"String",
"appName",
",",
"final",
"String",
"id",
",",
"final",
"InstanceInfo",
"info",
")",
"{",
"long",
"expiryTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"maxProcessingDelayMs",
";",
"batchingDispatcher",
".",
"process",
"(",
"taskId",
"(",
"\"deleteStatusOverride\"",
",",
"appName",
",",
"id",
")",
",",
"new",
"InstanceReplicationTask",
"(",
"targetHost",
",",
"Action",
".",
"DeleteStatusOverride",
",",
"info",
",",
"null",
",",
"false",
")",
"{",
"@",
"Override",
"public",
"EurekaHttpResponse",
"<",
"Void",
">",
"execute",
"(",
")",
"{",
"return",
"replicationClient",
".",
"deleteStatusOverride",
"(",
"appName",
",",
"id",
",",
"info",
")",
";",
"}",
"}",
",",
"expiryTime",
")",
";",
"}"
] |
Delete instance status override.
@param appName
the application name of the instance.
@param id
the unique identifier of the instance.
@param info
the instance information of the instance.
|
[
"Delete",
"instance",
"status",
"override",
"."
] |
train
|
https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-core/src/main/java/com/netflix/eureka/cluster/PeerEurekaNode.java#L294-L305
|
code4everything/util
|
src/main/java/com/zhazhapan/util/Checker.java
|
Checker.isLimited
|
public static boolean isLimited(String string, int min, int max) {
"""
判断字符串的长度是否在某个范围
@param string 字符串
@param min 最小长度
@param max 最大长度
@return {@link Boolean}
"""
return isNotEmpty(string) && string.length() >= min && string.length() <= max;
}
|
java
|
public static boolean isLimited(String string, int min, int max) {
return isNotEmpty(string) && string.length() >= min && string.length() <= max;
}
|
[
"public",
"static",
"boolean",
"isLimited",
"(",
"String",
"string",
",",
"int",
"min",
",",
"int",
"max",
")",
"{",
"return",
"isNotEmpty",
"(",
"string",
")",
"&&",
"string",
".",
"length",
"(",
")",
">=",
"min",
"&&",
"string",
".",
"length",
"(",
")",
"<=",
"max",
";",
"}"
] |
判断字符串的长度是否在某个范围
@param string 字符串
@param min 最小长度
@param max 最大长度
@return {@link Boolean}
|
[
"判断字符串的长度是否在某个范围"
] |
train
|
https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/Checker.java#L750-L752
|
JOML-CI/JOML
|
src/org/joml/Matrix4d.java
|
Matrix4d.rotationTowards
|
public Matrix4d rotationTowards(Vector3dc dir, Vector3dc up) {
"""
Set this matrix to a model transformation for a right-handed coordinate system,
that aligns the local <code>-z</code> axis with <code>dir</code>.
<p>
In order to apply the rotation transformation to a previous existing transformation,
use {@link #rotateTowards(double, double, double, double, double, double) rotateTowards}.
<p>
This method is equivalent to calling: <code>setLookAt(new Vector3d(), new Vector3d(dir).negate(), up).invertAffine()</code>
@see #rotationTowards(Vector3dc, Vector3dc)
@see #rotateTowards(double, double, double, double, double, double)
@param dir
the direction to orient the local -z axis towards
@param up
the up vector
@return this
"""
return rotationTowards(dir.x(), dir.y(), dir.z(), up.x(), up.y(), up.z());
}
|
java
|
public Matrix4d rotationTowards(Vector3dc dir, Vector3dc up) {
return rotationTowards(dir.x(), dir.y(), dir.z(), up.x(), up.y(), up.z());
}
|
[
"public",
"Matrix4d",
"rotationTowards",
"(",
"Vector3dc",
"dir",
",",
"Vector3dc",
"up",
")",
"{",
"return",
"rotationTowards",
"(",
"dir",
".",
"x",
"(",
")",
",",
"dir",
".",
"y",
"(",
")",
",",
"dir",
".",
"z",
"(",
")",
",",
"up",
".",
"x",
"(",
")",
",",
"up",
".",
"y",
"(",
")",
",",
"up",
".",
"z",
"(",
")",
")",
";",
"}"
] |
Set this matrix to a model transformation for a right-handed coordinate system,
that aligns the local <code>-z</code> axis with <code>dir</code>.
<p>
In order to apply the rotation transformation to a previous existing transformation,
use {@link #rotateTowards(double, double, double, double, double, double) rotateTowards}.
<p>
This method is equivalent to calling: <code>setLookAt(new Vector3d(), new Vector3d(dir).negate(), up).invertAffine()</code>
@see #rotationTowards(Vector3dc, Vector3dc)
@see #rotateTowards(double, double, double, double, double, double)
@param dir
the direction to orient the local -z axis towards
@param up
the up vector
@return this
|
[
"Set",
"this",
"matrix",
"to",
"a",
"model",
"transformation",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"that",
"aligns",
"the",
"local",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"axis",
"with",
"<code",
">",
"dir<",
"/",
"code",
">",
".",
"<p",
">",
"In",
"order",
"to",
"apply",
"the",
"rotation",
"transformation",
"to",
"a",
"previous",
"existing",
"transformation",
"use",
"{",
"@link",
"#rotateTowards",
"(",
"double",
"double",
"double",
"double",
"double",
"double",
")",
"rotateTowards",
"}",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"setLookAt",
"(",
"new",
"Vector3d",
"()",
"new",
"Vector3d",
"(",
"dir",
")",
".",
"negate",
"()",
"up",
")",
".",
"invertAffine",
"()",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L15294-L15296
|
gmessner/gitlab4j-api
|
src/main/java/org/gitlab4j/api/GitLabApiClient.java
|
GitLabApiClient.putUpload
|
protected Response putUpload(String name, File fileToUpload, URL url) throws IOException {
"""
Perform a file upload using multipart/form-data using the HTTP PUT method, returning
a ClientResponse instance with the data returned from the endpoint.
@param name the name for the form field that contains the file name
@param fileToUpload a File instance pointing to the file to upload
@param url the fully formed path to the GitLab API endpoint
@return a ClientResponse instance with the data returned from the endpoint
@throws IOException if an error occurs while constructing the URL
"""
try (MultiPart multiPart = new FormDataMultiPart()) {
multiPart.bodyPart(new FileDataBodyPart(name, fileToUpload, MediaType.APPLICATION_OCTET_STREAM_TYPE));
final Entity<?> entity = Entity.entity(multiPart, Boundary.addBoundary(multiPart.getMediaType()));
return (invocation(url, null).put(entity));
}
}
|
java
|
protected Response putUpload(String name, File fileToUpload, URL url) throws IOException {
try (MultiPart multiPart = new FormDataMultiPart()) {
multiPart.bodyPart(new FileDataBodyPart(name, fileToUpload, MediaType.APPLICATION_OCTET_STREAM_TYPE));
final Entity<?> entity = Entity.entity(multiPart, Boundary.addBoundary(multiPart.getMediaType()));
return (invocation(url, null).put(entity));
}
}
|
[
"protected",
"Response",
"putUpload",
"(",
"String",
"name",
",",
"File",
"fileToUpload",
",",
"URL",
"url",
")",
"throws",
"IOException",
"{",
"try",
"(",
"MultiPart",
"multiPart",
"=",
"new",
"FormDataMultiPart",
"(",
")",
")",
"{",
"multiPart",
".",
"bodyPart",
"(",
"new",
"FileDataBodyPart",
"(",
"name",
",",
"fileToUpload",
",",
"MediaType",
".",
"APPLICATION_OCTET_STREAM_TYPE",
")",
")",
";",
"final",
"Entity",
"<",
"?",
">",
"entity",
"=",
"Entity",
".",
"entity",
"(",
"multiPart",
",",
"Boundary",
".",
"addBoundary",
"(",
"multiPart",
".",
"getMediaType",
"(",
")",
")",
")",
";",
"return",
"(",
"invocation",
"(",
"url",
",",
"null",
")",
".",
"put",
"(",
"entity",
")",
")",
";",
"}",
"}"
] |
Perform a file upload using multipart/form-data using the HTTP PUT method, returning
a ClientResponse instance with the data returned from the endpoint.
@param name the name for the form field that contains the file name
@param fileToUpload a File instance pointing to the file to upload
@param url the fully formed path to the GitLab API endpoint
@return a ClientResponse instance with the data returned from the endpoint
@throws IOException if an error occurs while constructing the URL
|
[
"Perform",
"a",
"file",
"upload",
"using",
"multipart",
"/",
"form",
"-",
"data",
"using",
"the",
"HTTP",
"PUT",
"method",
"returning",
"a",
"ClientResponse",
"instance",
"with",
"the",
"data",
"returned",
"from",
"the",
"endpoint",
"."
] |
train
|
https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/GitLabApiClient.java#L622-L629
|
SonarSource/sonarqube
|
server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java
|
UserDao.selectByIds
|
public List<UserDto> selectByIds(DbSession session, Collection<Integer> ids) {
"""
Select users by ids, including disabled users. An empty list is returned
if list of ids is empty, without any db round trips.
Used by the Governance plugin
"""
return executeLargeInputs(ids, mapper(session)::selectByIds);
}
|
java
|
public List<UserDto> selectByIds(DbSession session, Collection<Integer> ids) {
return executeLargeInputs(ids, mapper(session)::selectByIds);
}
|
[
"public",
"List",
"<",
"UserDto",
">",
"selectByIds",
"(",
"DbSession",
"session",
",",
"Collection",
"<",
"Integer",
">",
"ids",
")",
"{",
"return",
"executeLargeInputs",
"(",
"ids",
",",
"mapper",
"(",
"session",
")",
"::",
"selectByIds",
")",
";",
"}"
] |
Select users by ids, including disabled users. An empty list is returned
if list of ids is empty, without any db round trips.
Used by the Governance plugin
|
[
"Select",
"users",
"by",
"ids",
"including",
"disabled",
"users",
".",
"An",
"empty",
"list",
"is",
"returned",
"if",
"list",
"of",
"ids",
"is",
"empty",
"without",
"any",
"db",
"round",
"trips",
"."
] |
train
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserDao.java#L71-L73
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/ConcurrentServiceReferenceMap.java
|
ConcurrentServiceReferenceMap.removeReference
|
public boolean removeReference(K key, ServiceReference<V> reference) {
"""
Removes the reference associated with the key.
@param key Key associated with this reference
@param reference ServiceReference associated with service to be unset.
@return true if reference was unset (not previously replaced)
"""
if (key == null || reference == null)
return false;
ConcurrentServiceReferenceElement<V> element = new ConcurrentServiceReferenceElement<V>(referenceName, reference);
return elementMap.remove(key, element);
}
|
java
|
public boolean removeReference(K key, ServiceReference<V> reference) {
if (key == null || reference == null)
return false;
ConcurrentServiceReferenceElement<V> element = new ConcurrentServiceReferenceElement<V>(referenceName, reference);
return elementMap.remove(key, element);
}
|
[
"public",
"boolean",
"removeReference",
"(",
"K",
"key",
",",
"ServiceReference",
"<",
"V",
">",
"reference",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"reference",
"==",
"null",
")",
"return",
"false",
";",
"ConcurrentServiceReferenceElement",
"<",
"V",
">",
"element",
"=",
"new",
"ConcurrentServiceReferenceElement",
"<",
"V",
">",
"(",
"referenceName",
",",
"reference",
")",
";",
"return",
"elementMap",
".",
"remove",
"(",
"key",
",",
"element",
")",
";",
"}"
] |
Removes the reference associated with the key.
@param key Key associated with this reference
@param reference ServiceReference associated with service to be unset.
@return true if reference was unset (not previously replaced)
|
[
"Removes",
"the",
"reference",
"associated",
"with",
"the",
"key",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service/src/com/ibm/wsspi/kernel/service/utils/ConcurrentServiceReferenceMap.java#L161-L166
|
astrapi69/jaulp-wicket
|
jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/beaneditor/BeanEditorPanel.java
|
BeanEditorPanel.newRepeatingView
|
protected RepeatingView newRepeatingView(final String id, final IModel<T> model) {
"""
Factory method for creating the RepeatingView. This method is invoked in the constructor from
the derived classes and can be overridden so users can provide their own version of a
RepeatingView.
@param id
the id
@param model
the model
@return the RepeatingView
"""
final RepeatingView fields = new RepeatingView("fields");
form.add(fields);
final T modelObject = model.getObject();
for (final Field field : modelObject.getClass().getDeclaredFields())
{
// skip serialVersionUID...
if (field.getName().equalsIgnoreCase("serialVersionUID"))
{
continue;
}
final WebMarkupContainer row = new WebMarkupContainer(fields.newChildId());
fields.add(row);
final IModel<String> labelModel = Model.of(field.getName());
row.add(new Label("name", labelModel));
final IModel<?> fieldModel = new PropertyModel<Object>(modelObject, field.getName());
// Create the editor for the field.
row.add(newEditorForBeanField("editor", field, fieldModel));
}
return fields;
}
|
java
|
protected RepeatingView newRepeatingView(final String id, final IModel<T> model)
{
final RepeatingView fields = new RepeatingView("fields");
form.add(fields);
final T modelObject = model.getObject();
for (final Field field : modelObject.getClass().getDeclaredFields())
{
// skip serialVersionUID...
if (field.getName().equalsIgnoreCase("serialVersionUID"))
{
continue;
}
final WebMarkupContainer row = new WebMarkupContainer(fields.newChildId());
fields.add(row);
final IModel<String> labelModel = Model.of(field.getName());
row.add(new Label("name", labelModel));
final IModel<?> fieldModel = new PropertyModel<Object>(modelObject, field.getName());
// Create the editor for the field.
row.add(newEditorForBeanField("editor", field, fieldModel));
}
return fields;
}
|
[
"protected",
"RepeatingView",
"newRepeatingView",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"T",
">",
"model",
")",
"{",
"final",
"RepeatingView",
"fields",
"=",
"new",
"RepeatingView",
"(",
"\"fields\"",
")",
";",
"form",
".",
"add",
"(",
"fields",
")",
";",
"final",
"T",
"modelObject",
"=",
"model",
".",
"getObject",
"(",
")",
";",
"for",
"(",
"final",
"Field",
"field",
":",
"modelObject",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
")",
"{",
"// skip serialVersionUID...\r",
"if",
"(",
"field",
".",
"getName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"serialVersionUID\"",
")",
")",
"{",
"continue",
";",
"}",
"final",
"WebMarkupContainer",
"row",
"=",
"new",
"WebMarkupContainer",
"(",
"fields",
".",
"newChildId",
"(",
")",
")",
";",
"fields",
".",
"add",
"(",
"row",
")",
";",
"final",
"IModel",
"<",
"String",
">",
"labelModel",
"=",
"Model",
".",
"of",
"(",
"field",
".",
"getName",
"(",
")",
")",
";",
"row",
".",
"add",
"(",
"new",
"Label",
"(",
"\"name\"",
",",
"labelModel",
")",
")",
";",
"final",
"IModel",
"<",
"?",
">",
"fieldModel",
"=",
"new",
"PropertyModel",
"<",
"Object",
">",
"(",
"modelObject",
",",
"field",
".",
"getName",
"(",
")",
")",
";",
"// Create the editor for the field.\r",
"row",
".",
"add",
"(",
"newEditorForBeanField",
"(",
"\"editor\"",
",",
"field",
",",
"fieldModel",
")",
")",
";",
"}",
"return",
"fields",
";",
"}"
] |
Factory method for creating the RepeatingView. This method is invoked in the constructor from
the derived classes and can be overridden so users can provide their own version of a
RepeatingView.
@param id
the id
@param model
the model
@return the RepeatingView
|
[
"Factory",
"method",
"for",
"creating",
"the",
"RepeatingView",
".",
"This",
"method",
"is",
"invoked",
"in",
"the",
"constructor",
"from",
"the",
"derived",
"classes",
"and",
"can",
"be",
"overridden",
"so",
"users",
"can",
"provide",
"their",
"own",
"version",
"of",
"a",
"RepeatingView",
"."
] |
train
|
https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/beaneditor/BeanEditorPanel.java#L118-L144
|
protostuff/protostuff
|
protostuff-msgpack/src/main/java/io/protostuff/MsgpackIOUtil.java
|
MsgpackIOUtil.parseListFrom
|
public static <T> List<T> parseListFrom(MessageBufferInput in, Schema<T> schema, boolean numeric) throws IOException {
"""
Parses the {@code messages} from the stream using the given {@code schema}.
"""
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in);
try
{
return parseListFrom(unpacker, schema, numeric);
}
finally
{
unpacker.close();
}
}
|
java
|
public static <T> List<T> parseListFrom(MessageBufferInput in, Schema<T> schema, boolean numeric) throws IOException
{
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(in);
try
{
return parseListFrom(unpacker, schema, numeric);
}
finally
{
unpacker.close();
}
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"parseListFrom",
"(",
"MessageBufferInput",
"in",
",",
"Schema",
"<",
"T",
">",
"schema",
",",
"boolean",
"numeric",
")",
"throws",
"IOException",
"{",
"MessageUnpacker",
"unpacker",
"=",
"MessagePack",
".",
"newDefaultUnpacker",
"(",
"in",
")",
";",
"try",
"{",
"return",
"parseListFrom",
"(",
"unpacker",
",",
"schema",
",",
"numeric",
")",
";",
"}",
"finally",
"{",
"unpacker",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Parses the {@code messages} from the stream using the given {@code schema}.
|
[
"Parses",
"the",
"{"
] |
train
|
https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-msgpack/src/main/java/io/protostuff/MsgpackIOUtil.java#L310-L323
|
DDTH/ddth-commons
|
ddth-commons-core/src/main/java/com/github/ddth/commons/utils/SerializationUtils.java
|
SerializationUtils.fromJson
|
public static <T> T fromJson(JsonNode json, Class<T> clazz) {
"""
Deserialize a {@link JsonNode}.
@param json
@param clazz
@return
@since 0.6.2
"""
return fromJson(json, clazz, null);
}
|
java
|
public static <T> T fromJson(JsonNode json, Class<T> clazz) {
return fromJson(json, clazz, null);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"JsonNode",
"json",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"return",
"fromJson",
"(",
"json",
",",
"clazz",
",",
"null",
")",
";",
"}"
] |
Deserialize a {@link JsonNode}.
@param json
@param clazz
@return
@since 0.6.2
|
[
"Deserialize",
"a",
"{",
"@link",
"JsonNode",
"}",
"."
] |
train
|
https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/SerializationUtils.java#L714-L716
|
dadoonet/fscrawler
|
framework/src/main/java/fr/pilato/elasticsearch/crawler/fs/framework/MetaFileHandler.java
|
MetaFileHandler.writeFile
|
protected void writeFile(String subdir, String filename, String content) throws IOException {
"""
Write a file in ~/.fscrawler/{subdir} dir
@param subdir subdir where we can read the file (null if we read in the root dir)
@param filename filename
@param content The String UTF-8 content to write
@throws IOException in case of error while reading
"""
Path dir = root;
if (subdir != null) {
dir = dir.resolve(subdir);
// If the dir does not exist, we need to create it
if (Files.notExists(dir)) {
Files.createDirectory(dir);
}
}
Files.write(dir.resolve(filename), content.getBytes(StandardCharsets.UTF_8));
}
|
java
|
protected void writeFile(String subdir, String filename, String content) throws IOException {
Path dir = root;
if (subdir != null) {
dir = dir.resolve(subdir);
// If the dir does not exist, we need to create it
if (Files.notExists(dir)) {
Files.createDirectory(dir);
}
}
Files.write(dir.resolve(filename), content.getBytes(StandardCharsets.UTF_8));
}
|
[
"protected",
"void",
"writeFile",
"(",
"String",
"subdir",
",",
"String",
"filename",
",",
"String",
"content",
")",
"throws",
"IOException",
"{",
"Path",
"dir",
"=",
"root",
";",
"if",
"(",
"subdir",
"!=",
"null",
")",
"{",
"dir",
"=",
"dir",
".",
"resolve",
"(",
"subdir",
")",
";",
"// If the dir does not exist, we need to create it",
"if",
"(",
"Files",
".",
"notExists",
"(",
"dir",
")",
")",
"{",
"Files",
".",
"createDirectory",
"(",
"dir",
")",
";",
"}",
"}",
"Files",
".",
"write",
"(",
"dir",
".",
"resolve",
"(",
"filename",
")",
",",
"content",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"}"
] |
Write a file in ~/.fscrawler/{subdir} dir
@param subdir subdir where we can read the file (null if we read in the root dir)
@param filename filename
@param content The String UTF-8 content to write
@throws IOException in case of error while reading
|
[
"Write",
"a",
"file",
"in",
"~",
"/",
".",
"fscrawler",
"/",
"{",
"subdir",
"}",
"dir"
] |
train
|
https://github.com/dadoonet/fscrawler/blob/cca00a14e21ef9986aa30e19b160463aed6bf921/framework/src/main/java/fr/pilato/elasticsearch/crawler/fs/framework/MetaFileHandler.java#L64-L75
|
synchronoss/cpo-api
|
cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java
|
JdbcCpoAdapter.executeObject
|
@Override
public <T> T executeObject(T object) throws CpoException {
"""
Executes an Object whose metadata will call an executable within the datasource. It is assumed that the executable
object exists in the metadatasource. If the executable does not exist, an exception will be thrown.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = new SomeObject();
class CpoAdapter cpo = null;
<p/>
try {
cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
so.setId(1);
so.setName("SomeName");
try{
cpo.executeObject(so);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param object This is an Object that has been defined within the metadata of the datasource. If the class is not
defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown.
This object is used to populate the IN arguments used to executed the datasource object.
<p/>
An object of this type will be created and filled with the returned data from the value_object. This newly created
object will be returned from this method.
@return An object populated with the OUT arguments returned from the executable object
@throws CpoException Thrown if there are errors accessing the datasource
"""
return processExecuteGroup(null, object, object);
}
|
java
|
@Override
public <T> T executeObject(T object) throws CpoException {
return processExecuteGroup(null, object, object);
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"executeObject",
"(",
"T",
"object",
")",
"throws",
"CpoException",
"{",
"return",
"processExecuteGroup",
"(",
"null",
",",
"object",
",",
"object",
")",
";",
"}"
] |
Executes an Object whose metadata will call an executable within the datasource. It is assumed that the executable
object exists in the metadatasource. If the executable does not exist, an exception will be thrown.
<p/>
<pre>Example:
<code>
<p/>
class SomeObject so = new SomeObject();
class CpoAdapter cpo = null;
<p/>
try {
cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
} catch (CpoException ce) {
// Handle the error
cpo = null;
}
<p/>
if (cpo!=null) {
so.setId(1);
so.setName("SomeName");
try{
cpo.executeObject(so);
} catch (CpoException ce) {
// Handle the error
}
}
</code>
</pre>
@param object This is an Object that has been defined within the metadata of the datasource. If the class is not
defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown.
This object is used to populate the IN arguments used to executed the datasource object.
<p/>
An object of this type will be created and filled with the returned data from the value_object. This newly created
object will be returned from this method.
@return An object populated with the OUT arguments returned from the executable object
@throws CpoException Thrown if there are errors accessing the datasource
|
[
"Executes",
"an",
"Object",
"whose",
"metadata",
"will",
"call",
"an",
"executable",
"within",
"the",
"datasource",
".",
"It",
"is",
"assumed",
"that",
"the",
"executable",
"object",
"exists",
"in",
"the",
"metadatasource",
".",
"If",
"the",
"executable",
"does",
"not",
"exist",
"an",
"exception",
"will",
"be",
"thrown",
".",
"<p",
"/",
">",
"<pre",
">",
"Example",
":",
"<code",
">",
"<p",
"/",
">",
"class",
"SomeObject",
"so",
"=",
"new",
"SomeObject",
"()",
";",
"class",
"CpoAdapter",
"cpo",
"=",
"null",
";",
"<p",
"/",
">",
"try",
"{",
"cpo",
"=",
"new",
"JdbcCpoAdapter",
"(",
"new",
"JdbcDataSourceInfo",
"(",
"driver",
"url",
"user",
"password",
"1",
"1",
"false",
"))",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"cpo",
"=",
"null",
";",
"}",
"<p",
"/",
">",
"if",
"(",
"cpo!",
"=",
"null",
")",
"{",
"so",
".",
"setId",
"(",
"1",
")",
";",
"so",
".",
"setName",
"(",
"SomeName",
")",
";",
"try",
"{",
"cpo",
".",
"executeObject",
"(",
"so",
")",
";",
"}",
"catch",
"(",
"CpoException",
"ce",
")",
"{",
"//",
"Handle",
"the",
"error",
"}",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/synchronoss/cpo-api/blob/dc745aca3b3206abf80b85d9689b0132f5baa694/cpo-jdbc/src/main/java/org/synchronoss/cpo/jdbc/JdbcCpoAdapter.java#L780-L783
|
apache/spark
|
core/src/main/java/org/apache/spark/shuffle/sort/PackedRecordPointer.java
|
PackedRecordPointer.packPointer
|
public static long packPointer(long recordPointer, int partitionId) {
"""
Pack a record address and partition id into a single word.
@param recordPointer a record pointer encoded by TaskMemoryManager.
@param partitionId a shuffle partition id (maximum value of 2^24).
@return a packed pointer that can be decoded using the {@link PackedRecordPointer} class.
"""
assert (partitionId <= MAXIMUM_PARTITION_ID);
// Note that without word alignment we can address 2^27 bytes = 128 megabytes per page.
// Also note that this relies on some internals of how TaskMemoryManager encodes its addresses.
final long pageNumber = (recordPointer & MASK_LONG_UPPER_13_BITS) >>> 24;
final long compressedAddress = pageNumber | (recordPointer & MASK_LONG_LOWER_27_BITS);
return (((long) partitionId) << 40) | compressedAddress;
}
|
java
|
public static long packPointer(long recordPointer, int partitionId) {
assert (partitionId <= MAXIMUM_PARTITION_ID);
// Note that without word alignment we can address 2^27 bytes = 128 megabytes per page.
// Also note that this relies on some internals of how TaskMemoryManager encodes its addresses.
final long pageNumber = (recordPointer & MASK_LONG_UPPER_13_BITS) >>> 24;
final long compressedAddress = pageNumber | (recordPointer & MASK_LONG_LOWER_27_BITS);
return (((long) partitionId) << 40) | compressedAddress;
}
|
[
"public",
"static",
"long",
"packPointer",
"(",
"long",
"recordPointer",
",",
"int",
"partitionId",
")",
"{",
"assert",
"(",
"partitionId",
"<=",
"MAXIMUM_PARTITION_ID",
")",
";",
"// Note that without word alignment we can address 2^27 bytes = 128 megabytes per page.",
"// Also note that this relies on some internals of how TaskMemoryManager encodes its addresses.",
"final",
"long",
"pageNumber",
"=",
"(",
"recordPointer",
"&",
"MASK_LONG_UPPER_13_BITS",
")",
">>>",
"24",
";",
"final",
"long",
"compressedAddress",
"=",
"pageNumber",
"|",
"(",
"recordPointer",
"&",
"MASK_LONG_LOWER_27_BITS",
")",
";",
"return",
"(",
"(",
"(",
"long",
")",
"partitionId",
")",
"<<",
"40",
")",
"|",
"compressedAddress",
";",
"}"
] |
Pack a record address and partition id into a single word.
@param recordPointer a record pointer encoded by TaskMemoryManager.
@param partitionId a shuffle partition id (maximum value of 2^24).
@return a packed pointer that can be decoded using the {@link PackedRecordPointer} class.
|
[
"Pack",
"a",
"record",
"address",
"and",
"partition",
"id",
"into",
"a",
"single",
"word",
"."
] |
train
|
https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/core/src/main/java/org/apache/spark/shuffle/sort/PackedRecordPointer.java#L77-L84
|
kuujo/vertigo
|
core/src/main/java/net/kuujo/vertigo/io/logging/PortLoggerFactory.java
|
PortLoggerFactory.getLogger
|
public static PortLogger getLogger(Class<?> clazz, OutputCollector output) {
"""
Creates an output port logger for the given type.
@param clazz The type being logged.
@param output The output to which to log messages.
@return An output port logger.
"""
return getLogger(clazz.getCanonicalName(), output);
}
|
java
|
public static PortLogger getLogger(Class<?> clazz, OutputCollector output) {
return getLogger(clazz.getCanonicalName(), output);
}
|
[
"public",
"static",
"PortLogger",
"getLogger",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"OutputCollector",
"output",
")",
"{",
"return",
"getLogger",
"(",
"clazz",
".",
"getCanonicalName",
"(",
")",
",",
"output",
")",
";",
"}"
] |
Creates an output port logger for the given type.
@param clazz The type being logged.
@param output The output to which to log messages.
@return An output port logger.
|
[
"Creates",
"an",
"output",
"port",
"logger",
"for",
"the",
"given",
"type",
"."
] |
train
|
https://github.com/kuujo/vertigo/blob/c5869dbc5fff89eb5262e83f7a81719b01a5ba6f/core/src/main/java/net/kuujo/vertigo/io/logging/PortLoggerFactory.java#L41-L43
|
wdullaer/MaterialDateTimePicker
|
library/src/main/java/com/wdullaer/materialdatetimepicker/date/DatePickerDialog.java
|
DatePickerDialog.newInstance
|
@SuppressWarnings("unused")
public static DatePickerDialog newInstance(OnDateSetListener callback, Calendar initialSelection) {
"""
Create a new DatePickerDialog instance with a specific initial selection.
@param callback How the parent is notified that the date is set.
@param initialSelection A Calendar object containing the original selection of the picker.
(Time is ignored by trimming the Calendar to midnight in the current
TimeZone of the Calendar object)
@return a new DatePickerDialog instance
"""
DatePickerDialog ret = new DatePickerDialog();
ret.initialize(callback, initialSelection);
return ret;
}
|
java
|
@SuppressWarnings("unused")
public static DatePickerDialog newInstance(OnDateSetListener callback, Calendar initialSelection) {
DatePickerDialog ret = new DatePickerDialog();
ret.initialize(callback, initialSelection);
return ret;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"public",
"static",
"DatePickerDialog",
"newInstance",
"(",
"OnDateSetListener",
"callback",
",",
"Calendar",
"initialSelection",
")",
"{",
"DatePickerDialog",
"ret",
"=",
"new",
"DatePickerDialog",
"(",
")",
";",
"ret",
".",
"initialize",
"(",
"callback",
",",
"initialSelection",
")",
";",
"return",
"ret",
";",
"}"
] |
Create a new DatePickerDialog instance with a specific initial selection.
@param callback How the parent is notified that the date is set.
@param initialSelection A Calendar object containing the original selection of the picker.
(Time is ignored by trimming the Calendar to midnight in the current
TimeZone of the Calendar object)
@return a new DatePickerDialog instance
|
[
"Create",
"a",
"new",
"DatePickerDialog",
"instance",
"with",
"a",
"specific",
"initial",
"selection",
"."
] |
train
|
https://github.com/wdullaer/MaterialDateTimePicker/blob/0a8fe28f19db4f5a5a6cfc525a852416232873a8/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DatePickerDialog.java#L228-L233
|
liferay/com-liferay-commerce
|
commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionCategoryPersistenceImpl.java
|
CPOptionCategoryPersistenceImpl.findByUUID_G
|
@Override
public CPOptionCategory findByUUID_G(String uuid, long groupId)
throws NoSuchCPOptionCategoryException {
"""
Returns the cp option category where uuid = ? and groupId = ? or throws a {@link NoSuchCPOptionCategoryException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option category
@throws NoSuchCPOptionCategoryException if a matching cp option category could not be found
"""
CPOptionCategory cpOptionCategory = fetchByUUID_G(uuid, groupId);
if (cpOptionCategory == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPOptionCategoryException(msg.toString());
}
return cpOptionCategory;
}
|
java
|
@Override
public CPOptionCategory findByUUID_G(String uuid, long groupId)
throws NoSuchCPOptionCategoryException {
CPOptionCategory cpOptionCategory = fetchByUUID_G(uuid, groupId);
if (cpOptionCategory == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCPOptionCategoryException(msg.toString());
}
return cpOptionCategory;
}
|
[
"@",
"Override",
"public",
"CPOptionCategory",
"findByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchCPOptionCategoryException",
"{",
"CPOptionCategory",
"cpOptionCategory",
"=",
"fetchByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"if",
"(",
"cpOptionCategory",
"==",
"null",
")",
"{",
"StringBundler",
"msg",
"=",
"new",
"StringBundler",
"(",
"6",
")",
";",
"msg",
".",
"append",
"(",
"_NO_SUCH_ENTITY_WITH_KEY",
")",
";",
"msg",
".",
"append",
"(",
"\"uuid=\"",
")",
";",
"msg",
".",
"append",
"(",
"uuid",
")",
";",
"msg",
".",
"append",
"(",
"\", groupId=\"",
")",
";",
"msg",
".",
"append",
"(",
"groupId",
")",
";",
"msg",
".",
"append",
"(",
"\"}\"",
")",
";",
"if",
"(",
"_log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"_log",
".",
"debug",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"NoSuchCPOptionCategoryException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"cpOptionCategory",
";",
"}"
] |
Returns the cp option category where uuid = ? and groupId = ? or throws a {@link NoSuchCPOptionCategoryException} if it could not be found.
@param uuid the uuid
@param groupId the group ID
@return the matching cp option category
@throws NoSuchCPOptionCategoryException if a matching cp option category could not be found
|
[
"Returns",
"the",
"cp",
"option",
"category",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCPOptionCategoryException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
] |
train
|
https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CPOptionCategoryPersistenceImpl.java#L667-L693
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.