repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/ade/configuration/CmsADEManager.java | CmsADEManager.getRootPath | protected String getRootPath(CmsUUID structureId, boolean online) throws CmsException {
"""
Gets the root path for a given resource structure id.<p>
@param structureId the structure id
@param online if true, the resource will be looked up in the online project ,else in the offline project
@return the root path for the given structure id
@throws CmsException if something goes wrong
"""
CmsConfigurationCache cache = online ? m_onlineCache : m_offlineCache;
return cache.getPathForStructureId(structureId);
} | java | protected String getRootPath(CmsUUID structureId, boolean online) throws CmsException {
CmsConfigurationCache cache = online ? m_onlineCache : m_offlineCache;
return cache.getPathForStructureId(structureId);
} | [
"protected",
"String",
"getRootPath",
"(",
"CmsUUID",
"structureId",
",",
"boolean",
"online",
")",
"throws",
"CmsException",
"{",
"CmsConfigurationCache",
"cache",
"=",
"online",
"?",
"m_onlineCache",
":",
"m_offlineCache",
";",
"return",
"cache",
".",
"getPathForStructureId",
"(",
"structureId",
")",
";",
"}"
] | Gets the root path for a given resource structure id.<p>
@param structureId the structure id
@param online if true, the resource will be looked up in the online project ,else in the offline project
@return the root path for the given structure id
@throws CmsException if something goes wrong | [
"Gets",
"the",
"root",
"path",
"for",
"a",
"given",
"resource",
"structure",
"id",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L1426-L1430 |
taimos/dvalin | mongodb/src/main/java/de/taimos/dvalin/mongo/ChangelogUtil.java | ChangelogUtil.addIndex | public static void addIndex(DBCollection collection, String field, boolean asc, boolean background) {
"""
Add an index on the given collection and field
@param collection the collection to use for the index
@param field the field to use for the index
@param asc the sorting direction. <code>true</code> to sort ascending; <code>false</code> to sort descending
@param background iff <code>true</code> the index is created in the background
"""
int dir = (asc) ? 1 : -1;
collection.createIndex(new BasicDBObject(field, dir), new BasicDBObject("background", background));
} | java | public static void addIndex(DBCollection collection, String field, boolean asc, boolean background) {
int dir = (asc) ? 1 : -1;
collection.createIndex(new BasicDBObject(field, dir), new BasicDBObject("background", background));
} | [
"public",
"static",
"void",
"addIndex",
"(",
"DBCollection",
"collection",
",",
"String",
"field",
",",
"boolean",
"asc",
",",
"boolean",
"background",
")",
"{",
"int",
"dir",
"=",
"(",
"asc",
")",
"?",
"1",
":",
"-",
"1",
";",
"collection",
".",
"createIndex",
"(",
"new",
"BasicDBObject",
"(",
"field",
",",
"dir",
")",
",",
"new",
"BasicDBObject",
"(",
"\"background\"",
",",
"background",
")",
")",
";",
"}"
] | Add an index on the given collection and field
@param collection the collection to use for the index
@param field the field to use for the index
@param asc the sorting direction. <code>true</code> to sort ascending; <code>false</code> to sort descending
@param background iff <code>true</code> the index is created in the background | [
"Add",
"an",
"index",
"on",
"the",
"given",
"collection",
"and",
"field"
] | train | https://github.com/taimos/dvalin/blob/ff8f1bf594e43d7e8ca8de0b4da9f923b66a1a47/mongodb/src/main/java/de/taimos/dvalin/mongo/ChangelogUtil.java#L62-L65 |
PrashamTrivedi/SharedPreferenceInspector | sharedpreferenceinspector/src/main/java/com/ceelites/sharedpreferenceinspector/Utils/SharedPreferenceUtils.java | SharedPreferenceUtils.initWith | public static SharedPreferenceUtils initWith(Context context, String name) {
"""
Init SharedPreferences with context and a SharedPreferences name
@param context:
Context to init SharedPreferences
@param name:
Name of SharedPreferences file. If you pass <code>null</code> it will create default SharedPrefernces
@return: SharedPreferenceUtils object. It will store given the sharedPreferences value with given SharedPreferences.
"""
if (sharedPreferenceUtils == null) {
sharedPreferenceUtils = new SharedPreferenceUtils();
}
if (isEmptyString(name)) {
sharedPreferenceUtils.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} else {
sharedPreferenceUtils.sharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
return sharedPreferenceUtils;
} | java | public static SharedPreferenceUtils initWith(Context context, String name) {
if (sharedPreferenceUtils == null) {
sharedPreferenceUtils = new SharedPreferenceUtils();
}
if (isEmptyString(name)) {
sharedPreferenceUtils.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
} else {
sharedPreferenceUtils.sharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
return sharedPreferenceUtils;
} | [
"public",
"static",
"SharedPreferenceUtils",
"initWith",
"(",
"Context",
"context",
",",
"String",
"name",
")",
"{",
"if",
"(",
"sharedPreferenceUtils",
"==",
"null",
")",
"{",
"sharedPreferenceUtils",
"=",
"new",
"SharedPreferenceUtils",
"(",
")",
";",
"}",
"if",
"(",
"isEmptyString",
"(",
"name",
")",
")",
"{",
"sharedPreferenceUtils",
".",
"sharedPreferences",
"=",
"PreferenceManager",
".",
"getDefaultSharedPreferences",
"(",
"context",
")",
";",
"}",
"else",
"{",
"sharedPreferenceUtils",
".",
"sharedPreferences",
"=",
"context",
".",
"getSharedPreferences",
"(",
"name",
",",
"Context",
".",
"MODE_PRIVATE",
")",
";",
"}",
"return",
"sharedPreferenceUtils",
";",
"}"
] | Init SharedPreferences with context and a SharedPreferences name
@param context:
Context to init SharedPreferences
@param name:
Name of SharedPreferences file. If you pass <code>null</code> it will create default SharedPrefernces
@return: SharedPreferenceUtils object. It will store given the sharedPreferences value with given SharedPreferences. | [
"Init",
"SharedPreferences",
"with",
"context",
"and",
"a",
"SharedPreferences",
"name"
] | train | https://github.com/PrashamTrivedi/SharedPreferenceInspector/blob/c04d567c4d0fc5e0f8cda308ca85df19c6b3b838/sharedpreferenceinspector/src/main/java/com/ceelites/sharedpreferenceinspector/Utils/SharedPreferenceUtils.java#L63-L73 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/Record.java | Record.setupRecordListener | public BaseMessageFilter setupRecordListener(JMessageListener listener, boolean bTrackMultipleRecords, boolean bAllowEchos) {
"""
Set up a listener to notify when an external change is made to the current record.
@param listener The listener to set to the new filter. If null, use the record's recordowner.
@param bTrackMultipleRecord Use a GridRecordMessageFilter to watch for multiple records.
@param bAllowEchos Allow this record to be notified of changes (usually for remotes hooked to grid tables).
@param bReceiveAllAdds If true, receive all add notifications, otherwise just receive the adds on secondary reads.
@return The new filter.
"""
boolean bReceiveAllAdds = false;
if (((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.TABLE)
|| ((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.LOCAL)
|| ((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.REMOTE_MEMORY))
bReceiveAllAdds = true; // The volume of changes is negligable and there is rarely a secondary, so listen for all changes
return this.setupRecordListener(listener, bTrackMultipleRecords, bAllowEchos, bReceiveAllAdds);
} | java | public BaseMessageFilter setupRecordListener(JMessageListener listener, boolean bTrackMultipleRecords, boolean bAllowEchos)
{
boolean bReceiveAllAdds = false;
if (((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.TABLE)
|| ((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.LOCAL)
|| ((this.getDatabaseType() & DBConstants.TABLE_MASK) == DBConstants.REMOTE_MEMORY))
bReceiveAllAdds = true; // The volume of changes is negligable and there is rarely a secondary, so listen for all changes
return this.setupRecordListener(listener, bTrackMultipleRecords, bAllowEchos, bReceiveAllAdds);
} | [
"public",
"BaseMessageFilter",
"setupRecordListener",
"(",
"JMessageListener",
"listener",
",",
"boolean",
"bTrackMultipleRecords",
",",
"boolean",
"bAllowEchos",
")",
"{",
"boolean",
"bReceiveAllAdds",
"=",
"false",
";",
"if",
"(",
"(",
"(",
"this",
".",
"getDatabaseType",
"(",
")",
"&",
"DBConstants",
".",
"TABLE_MASK",
")",
"==",
"DBConstants",
".",
"TABLE",
")",
"||",
"(",
"(",
"this",
".",
"getDatabaseType",
"(",
")",
"&",
"DBConstants",
".",
"TABLE_MASK",
")",
"==",
"DBConstants",
".",
"LOCAL",
")",
"||",
"(",
"(",
"this",
".",
"getDatabaseType",
"(",
")",
"&",
"DBConstants",
".",
"TABLE_MASK",
")",
"==",
"DBConstants",
".",
"REMOTE_MEMORY",
")",
")",
"bReceiveAllAdds",
"=",
"true",
";",
"// The volume of changes is negligable and there is rarely a secondary, so listen for all changes",
"return",
"this",
".",
"setupRecordListener",
"(",
"listener",
",",
"bTrackMultipleRecords",
",",
"bAllowEchos",
",",
"bReceiveAllAdds",
")",
";",
"}"
] | Set up a listener to notify when an external change is made to the current record.
@param listener The listener to set to the new filter. If null, use the record's recordowner.
@param bTrackMultipleRecord Use a GridRecordMessageFilter to watch for multiple records.
@param bAllowEchos Allow this record to be notified of changes (usually for remotes hooked to grid tables).
@param bReceiveAllAdds If true, receive all add notifications, otherwise just receive the adds on secondary reads.
@return The new filter. | [
"Set",
"up",
"a",
"listener",
"to",
"notify",
"when",
"an",
"external",
"change",
"is",
"made",
"to",
"the",
"current",
"record",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/Record.java#L2782-L2790 |
mpetazzoni/ttorrent | ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java | TrackerRequestProcessor.serveError | private void serveError(Status status, String error, RequestHandler requestHandler) throws IOException {
"""
Write an error message to the response with the given HTTP status code.
@param status The HTTP status code to return.
@param error The error message reported by the tracker.
"""
this.serveError(status, HTTPTrackerErrorMessage.craft(error), requestHandler);
} | java | private void serveError(Status status, String error, RequestHandler requestHandler) throws IOException {
this.serveError(status, HTTPTrackerErrorMessage.craft(error), requestHandler);
} | [
"private",
"void",
"serveError",
"(",
"Status",
"status",
",",
"String",
"error",
",",
"RequestHandler",
"requestHandler",
")",
"throws",
"IOException",
"{",
"this",
".",
"serveError",
"(",
"status",
",",
"HTTPTrackerErrorMessage",
".",
"craft",
"(",
"error",
")",
",",
"requestHandler",
")",
";",
"}"
] | Write an error message to the response with the given HTTP status code.
@param status The HTTP status code to return.
@param error The error message reported by the tracker. | [
"Write",
"an",
"error",
"message",
"to",
"the",
"response",
"with",
"the",
"given",
"HTTP",
"status",
"code",
"."
] | train | https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/ttorrent-tracker/src/main/java/com/turn/ttorrent/tracker/TrackerRequestProcessor.java#L300-L302 |
eclipse/xtext-extras | org.eclipse.xtext.common.types/src/org/eclipse/xtext/common/types/util/TypeReferences.java | TypeReferences.findDeclaredType | public JvmType findDeclaredType(String typeName, Notifier context) {
"""
looks up a JVMType corresponding to the given {@link Class}. This method ignores any Jvm types created in non-
{@link TypeResource} in the given context's resourceSet, but goes straight to the Java-layer, using a
{@link IJvmTypeProvider}.
@return the JvmType with the same qualified name as the given {@link Class} object, or null if no such JvmType
could be found using the context's resourceSet.
"""
if (typeName == null)
throw new NullPointerException("typeName");
if (context == null)
throw new NullPointerException("context");
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null)
return null;
// make sure a type provider is configured in the resource set.
IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
try {
final JvmType result = typeProvider.findTypeByName(typeName);
return result;
} catch (RuntimeException e) {
operationCanceledManager.propagateAsErrorIfCancelException(e);
log.info("Couldn't find JvmType for name '" + typeName + "' in context " + context, e);
return null;
}
} | java | public JvmType findDeclaredType(String typeName, Notifier context) {
if (typeName == null)
throw new NullPointerException("typeName");
if (context == null)
throw new NullPointerException("context");
ResourceSet resourceSet = EcoreUtil2.getResourceSet(context);
if (resourceSet == null)
return null;
// make sure a type provider is configured in the resource set.
IJvmTypeProvider typeProvider = typeProviderFactory.findOrCreateTypeProvider(resourceSet);
try {
final JvmType result = typeProvider.findTypeByName(typeName);
return result;
} catch (RuntimeException e) {
operationCanceledManager.propagateAsErrorIfCancelException(e);
log.info("Couldn't find JvmType for name '" + typeName + "' in context " + context, e);
return null;
}
} | [
"public",
"JvmType",
"findDeclaredType",
"(",
"String",
"typeName",
",",
"Notifier",
"context",
")",
"{",
"if",
"(",
"typeName",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"typeName\"",
")",
";",
"if",
"(",
"context",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"context\"",
")",
";",
"ResourceSet",
"resourceSet",
"=",
"EcoreUtil2",
".",
"getResourceSet",
"(",
"context",
")",
";",
"if",
"(",
"resourceSet",
"==",
"null",
")",
"return",
"null",
";",
"// make sure a type provider is configured in the resource set. ",
"IJvmTypeProvider",
"typeProvider",
"=",
"typeProviderFactory",
".",
"findOrCreateTypeProvider",
"(",
"resourceSet",
")",
";",
"try",
"{",
"final",
"JvmType",
"result",
"=",
"typeProvider",
".",
"findTypeByName",
"(",
"typeName",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"operationCanceledManager",
".",
"propagateAsErrorIfCancelException",
"(",
"e",
")",
";",
"log",
".",
"info",
"(",
"\"Couldn't find JvmType for name '\"",
"+",
"typeName",
"+",
"\"' in context \"",
"+",
"context",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | looks up a JVMType corresponding to the given {@link Class}. This method ignores any Jvm types created in non-
{@link TypeResource} in the given context's resourceSet, but goes straight to the Java-layer, using a
{@link IJvmTypeProvider}.
@return the JvmType with the same qualified name as the given {@link Class} object, or null if no such JvmType
could be found using the context's resourceSet. | [
"looks",
"up",
"a",
"JVMType",
"corresponding",
"to",
"the",
"given",
"{",
"@link",
"Class",
"}",
".",
"This",
"method",
"ignores",
"any",
"Jvm",
"types",
"created",
"in",
"non",
"-",
"{",
"@link",
"TypeResource",
"}",
"in",
"the",
"given",
"context",
"s",
"resourceSet",
"but",
"goes",
"straight",
"to",
"the",
"Java",
"-",
"layer",
"using",
"a",
"{",
"@link",
"IJvmTypeProvider",
"}",
"."
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.common.types/src/org/eclipse/xtext/common/types/util/TypeReferences.java#L244-L262 |
FrodeRanders/java-vopn | src/main/java/org/gautelis/vopn/xml/Serializer.java | Serializer.obj2Xml | public static String obj2Xml(Class clazz, Object o) throws JAXBException, ParserConfigurationException {
"""
Serializes an object into XML
<p>
You need to catch the JAXBException, but beware that the cause is not conveyed correctly through getCause().
Take a peek at the internal 'cause' member and look out for detailed information about the problem.
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
x.y.A does not have a no-arg default constructor.
this problem is related to the following location:
at x.y.A
at public java.util.Collection x.y.A.getEntries()
at x.y.Z
x.y.B does not have a no-arg default constructor.
this problem is related to the following location:
at x.y.B
at public java.util.Collection x.y.A.getEntries()
at x.y.A
at public java.util.Collection x.y.Z.getEntries()
at x.y.Z
You need to take a peek at 'cause' in a debugger when initially developing the application.
"""
Document doc = obj2Doc(clazz, o);
DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
}
lsSerializer.setNewLine("\n");
try {
// Encode as UTF-8
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(baos);
lsSerializer.write(doc, lsOutput);
return baos.toString("UTF-8");
}
catch (UnsupportedEncodingException uee) {
return lsSerializer.writeToString(doc); // Produces UTF-16
}
} | java | public static String obj2Xml(Class clazz, Object o) throws JAXBException, ParserConfigurationException {
Document doc = obj2Doc(clazz, o);
DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
}
lsSerializer.setNewLine("\n");
try {
// Encode as UTF-8
ByteArrayOutputStream baos = new ByteArrayOutputStream();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(baos);
lsSerializer.write(doc, lsOutput);
return baos.toString("UTF-8");
}
catch (UnsupportedEncodingException uee) {
return lsSerializer.writeToString(doc); // Produces UTF-16
}
} | [
"public",
"static",
"String",
"obj2Xml",
"(",
"Class",
"clazz",
",",
"Object",
"o",
")",
"throws",
"JAXBException",
",",
"ParserConfigurationException",
"{",
"Document",
"doc",
"=",
"obj2Doc",
"(",
"clazz",
",",
"o",
")",
";",
"DOMImplementationLS",
"domImplementation",
"=",
"(",
"DOMImplementationLS",
")",
"doc",
".",
"getImplementation",
"(",
")",
";",
"LSSerializer",
"lsSerializer",
"=",
"domImplementation",
".",
"createLSSerializer",
"(",
")",
";",
"DOMConfiguration",
"domConfiguration",
"=",
"lsSerializer",
".",
"getDomConfig",
"(",
")",
";",
"if",
"(",
"domConfiguration",
".",
"canSetParameter",
"(",
"\"format-pretty-print\"",
",",
"Boolean",
".",
"TRUE",
")",
")",
"{",
"lsSerializer",
".",
"getDomConfig",
"(",
")",
".",
"setParameter",
"(",
"\"format-pretty-print\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"}",
"lsSerializer",
".",
"setNewLine",
"(",
"\"\\n\"",
")",
";",
"try",
"{",
"// Encode as UTF-8",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"LSOutput",
"lsOutput",
"=",
"domImplementation",
".",
"createLSOutput",
"(",
")",
";",
"lsOutput",
".",
"setEncoding",
"(",
"\"UTF-8\"",
")",
";",
"lsOutput",
".",
"setByteStream",
"(",
"baos",
")",
";",
"lsSerializer",
".",
"write",
"(",
"doc",
",",
"lsOutput",
")",
";",
"return",
"baos",
".",
"toString",
"(",
"\"UTF-8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"uee",
")",
"{",
"return",
"lsSerializer",
".",
"writeToString",
"(",
"doc",
")",
";",
"// Produces UTF-16",
"}",
"}"
] | Serializes an object into XML
<p>
You need to catch the JAXBException, but beware that the cause is not conveyed correctly through getCause().
Take a peek at the internal 'cause' member and look out for detailed information about the problem.
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
x.y.A does not have a no-arg default constructor.
this problem is related to the following location:
at x.y.A
at public java.util.Collection x.y.A.getEntries()
at x.y.Z
x.y.B does not have a no-arg default constructor.
this problem is related to the following location:
at x.y.B
at public java.util.Collection x.y.A.getEntries()
at x.y.A
at public java.util.Collection x.y.Z.getEntries()
at x.y.Z
You need to take a peek at 'cause' in a debugger when initially developing the application. | [
"Serializes",
"an",
"object",
"into",
"XML",
"<p",
">",
"You",
"need",
"to",
"catch",
"the",
"JAXBException",
"but",
"beware",
"that",
"the",
"cause",
"is",
"not",
"conveyed",
"correctly",
"through",
"getCause",
"()",
".",
"Take",
"a",
"peek",
"at",
"the",
"internal",
"cause",
"member",
"and",
"look",
"out",
"for",
"detailed",
"information",
"about",
"the",
"problem",
"."
] | train | https://github.com/FrodeRanders/java-vopn/blob/4c7b2f90201327af4eaa3cd46b3fee68f864e5cc/src/main/java/org/gautelis/vopn/xml/Serializer.java#L92-L116 |
haifengl/smile | core/src/main/java/smile/feature/MaxAbsScaler.java | MaxAbsScaler.transform | @Override
public double[] transform(double[] x) {
"""
Scales each feature by its maximum absolute value.
@param x a vector to be scaled. The vector will be modified on output.
@return the input vector.
"""
if (x.length != scale.length) {
throw new IllegalArgumentException(String.format("Invalid vector size %d, expected %d", x.length, scale.length));
}
double[] y = copy ? new double[x.length] : x;
for (int i = 0; i < x.length; i++) {
y[i] = x[i] / scale[i];
}
return y;
} | java | @Override
public double[] transform(double[] x) {
if (x.length != scale.length) {
throw new IllegalArgumentException(String.format("Invalid vector size %d, expected %d", x.length, scale.length));
}
double[] y = copy ? new double[x.length] : x;
for (int i = 0; i < x.length; i++) {
y[i] = x[i] / scale[i];
}
return y;
} | [
"@",
"Override",
"public",
"double",
"[",
"]",
"transform",
"(",
"double",
"[",
"]",
"x",
")",
"{",
"if",
"(",
"x",
".",
"length",
"!=",
"scale",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Invalid vector size %d, expected %d\"",
",",
"x",
".",
"length",
",",
"scale",
".",
"length",
")",
")",
";",
"}",
"double",
"[",
"]",
"y",
"=",
"copy",
"?",
"new",
"double",
"[",
"x",
".",
"length",
"]",
":",
"x",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"x",
".",
"length",
";",
"i",
"++",
")",
"{",
"y",
"[",
"i",
"]",
"=",
"x",
"[",
"i",
"]",
"/",
"scale",
"[",
"i",
"]",
";",
"}",
"return",
"y",
";",
"}"
] | Scales each feature by its maximum absolute value.
@param x a vector to be scaled. The vector will be modified on output.
@return the input vector. | [
"Scales",
"each",
"feature",
"by",
"its",
"maximum",
"absolute",
"value",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/feature/MaxAbsScaler.java#L79-L91 |
Azure/azure-sdk-for-java | mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java | LiveEventsInner.beginReset | public void beginReset(String resourceGroupName, String accountName, String liveEventName) {
"""
Reset Live Event.
Resets an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
"""
beginResetWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).toBlocking().single().body();
} | java | public void beginReset(String resourceGroupName, String accountName, String liveEventName) {
beginResetWithServiceResponseAsync(resourceGroupName, accountName, liveEventName).toBlocking().single().body();
} | [
"public",
"void",
"beginReset",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"liveEventName",
")",
"{",
"beginResetWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"liveEventName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Reset Live Event.
Resets an existing Live Event.
@param resourceGroupName The name of the resource group within the Azure subscription.
@param accountName The Media Services account name.
@param liveEventName The name of the Live Event.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ApiErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Reset",
"Live",
"Event",
".",
"Resets",
"an",
"existing",
"Live",
"Event",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/resource-manager/v2018_06_01_preview/src/main/java/com/microsoft/azure/management/mediaservices/v2018_06_01_preview/implementation/LiveEventsInner.java#L1734-L1736 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java | FacesImpl.detectWithUrl | public List<DetectedFace> detectWithUrl(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter) {
"""
Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes.
@param url Publicly reachable URL of an image
@param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws APIErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<DetectedFace> object if successful.
"""
return detectWithUrlWithServiceResponseAsync(url, detectWithUrlOptionalParameter).toBlocking().single().body();
} | java | public List<DetectedFace> detectWithUrl(String url, DetectWithUrlOptionalParameter detectWithUrlOptionalParameter) {
return detectWithUrlWithServiceResponseAsync(url, detectWithUrlOptionalParameter).toBlocking().single().body();
} | [
"public",
"List",
"<",
"DetectedFace",
">",
"detectWithUrl",
"(",
"String",
"url",
",",
"DetectWithUrlOptionalParameter",
"detectWithUrlOptionalParameter",
")",
"{",
"return",
"detectWithUrlWithServiceResponseAsync",
"(",
"url",
",",
"detectWithUrlOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and attributes.
@param url Publicly reachable URL of an image
@param detectWithUrlOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws APIErrorException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<DetectedFace> object if successful. | [
"Detect",
"human",
"faces",
"in",
"an",
"image",
"and",
"returns",
"face",
"locations",
"and",
"optionally",
"with",
"faceIds",
"landmarks",
"and",
"attributes",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/faceapi/src/main/java/com/microsoft/azure/cognitiveservices/vision/faceapi/implementation/FacesImpl.java#L657-L659 |
thombergs/docx-stamper | src/main/java/org/wickedsource/docxstamper/DocxStamperConfiguration.java | DocxStamperConfiguration.addTypeResolver | public <T> DocxStamperConfiguration addTypeResolver(Class<T> resolvedType, ITypeResolver resolver) {
"""
<p>
Registers the given ITypeResolver for the given class. The registered ITypeResolver's resolve() method will only
be called with objects of the specified class.
</p>
<p>
Note that each type can only be resolved by ONE ITypeResolver implementation. Multiple calls to addTypeResolver()
with the same resolvedType parameter will override earlier calls.
</p>
@param resolvedType the class whose objects are to be passed to the given ITypeResolver.
@param resolver the resolver to resolve objects of the given type.
@param <T> the type resolved by the ITypeResolver.
"""
this.typeResolvers.put(resolvedType, resolver);
return this;
} | java | public <T> DocxStamperConfiguration addTypeResolver(Class<T> resolvedType, ITypeResolver resolver) {
this.typeResolvers.put(resolvedType, resolver);
return this;
} | [
"public",
"<",
"T",
">",
"DocxStamperConfiguration",
"addTypeResolver",
"(",
"Class",
"<",
"T",
">",
"resolvedType",
",",
"ITypeResolver",
"resolver",
")",
"{",
"this",
".",
"typeResolvers",
".",
"put",
"(",
"resolvedType",
",",
"resolver",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Registers the given ITypeResolver for the given class. The registered ITypeResolver's resolve() method will only
be called with objects of the specified class.
</p>
<p>
Note that each type can only be resolved by ONE ITypeResolver implementation. Multiple calls to addTypeResolver()
with the same resolvedType parameter will override earlier calls.
</p>
@param resolvedType the class whose objects are to be passed to the given ITypeResolver.
@param resolver the resolver to resolve objects of the given type.
@param <T> the type resolved by the ITypeResolver. | [
"<p",
">",
"Registers",
"the",
"given",
"ITypeResolver",
"for",
"the",
"given",
"class",
".",
"The",
"registered",
"ITypeResolver",
"s",
"resolve",
"()",
"method",
"will",
"only",
"be",
"called",
"with",
"objects",
"of",
"the",
"specified",
"class",
".",
"<",
"/",
"p",
">",
"<p",
">",
"Note",
"that",
"each",
"type",
"can",
"only",
"be",
"resolved",
"by",
"ONE",
"ITypeResolver",
"implementation",
".",
"Multiple",
"calls",
"to",
"addTypeResolver",
"()",
"with",
"the",
"same",
"resolvedType",
"parameter",
"will",
"override",
"earlier",
"calls",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/thombergs/docx-stamper/blob/f1a7e3e92a59abaffac299532fe49450c3b041eb/src/main/java/org/wickedsource/docxstamper/DocxStamperConfiguration.java#L95-L98 |
jillesvangurp/iterables-support | src/main/java/com/jillesvangurp/iterables/Iterables.java | Iterables.castingIterable | public static <I,O> Iterable<O> castingIterable(Iterable<I> it, Class<O> clazz) {
"""
Allows you to iterate over objects and cast them to the appropriate type on the fly.
@param it iterable of I
@param clazz class to cast to
@param <I> input type
@param <O> output type
@return an iterable that casts elements to the specified class.
@throws ClassCastException if the elements are not castable
"""
return map(it, new Processor<I,O>() {
@SuppressWarnings("unchecked")
@Override
public O process(I input) {
return (O)input;
}});
} | java | public static <I,O> Iterable<O> castingIterable(Iterable<I> it, Class<O> clazz) {
return map(it, new Processor<I,O>() {
@SuppressWarnings("unchecked")
@Override
public O process(I input) {
return (O)input;
}});
} | [
"public",
"static",
"<",
"I",
",",
"O",
">",
"Iterable",
"<",
"O",
">",
"castingIterable",
"(",
"Iterable",
"<",
"I",
">",
"it",
",",
"Class",
"<",
"O",
">",
"clazz",
")",
"{",
"return",
"map",
"(",
"it",
",",
"new",
"Processor",
"<",
"I",
",",
"O",
">",
"(",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"O",
"process",
"(",
"I",
"input",
")",
"{",
"return",
"(",
"O",
")",
"input",
";",
"}",
"}",
")",
";",
"}"
] | Allows you to iterate over objects and cast them to the appropriate type on the fly.
@param it iterable of I
@param clazz class to cast to
@param <I> input type
@param <O> output type
@return an iterable that casts elements to the specified class.
@throws ClassCastException if the elements are not castable | [
"Allows",
"you",
"to",
"iterate",
"over",
"objects",
"and",
"cast",
"them",
"to",
"the",
"appropriate",
"type",
"on",
"the",
"fly",
"."
] | train | https://github.com/jillesvangurp/iterables-support/blob/a0a967d82fb7d8d5504a50eb19d5e7f1541b2771/src/main/java/com/jillesvangurp/iterables/Iterables.java#L298-L305 |
Coveros/selenified | src/main/java/com/coveros/selenified/Selenified.java | Selenified.setVersion | protected static void setVersion(Selenified clazz, ITestContext context, String version) {
"""
Sets the version of the current test suite being executed.
@param clazz - the test suite class, used for making threadsafe storage of
application, allowing suites to have independent applications
under test, run at the same time
@param context - the TestNG context associated with the test suite, used for
storing app url information
@param version - the version of the test suite
"""
context.setAttribute(clazz.getClass().getName() + "Version", version);
} | java | protected static void setVersion(Selenified clazz, ITestContext context, String version) {
context.setAttribute(clazz.getClass().getName() + "Version", version);
} | [
"protected",
"static",
"void",
"setVersion",
"(",
"Selenified",
"clazz",
",",
"ITestContext",
"context",
",",
"String",
"version",
")",
"{",
"context",
".",
"setAttribute",
"(",
"clazz",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"Version\"",
",",
"version",
")",
";",
"}"
] | Sets the version of the current test suite being executed.
@param clazz - the test suite class, used for making threadsafe storage of
application, allowing suites to have independent applications
under test, run at the same time
@param context - the TestNG context associated with the test suite, used for
storing app url information
@param version - the version of the test suite | [
"Sets",
"the",
"version",
"of",
"the",
"current",
"test",
"suite",
"being",
"executed",
"."
] | train | https://github.com/Coveros/selenified/blob/396cc1f010dd69eed33cc5061c41253de246a4cd/src/main/java/com/coveros/selenified/Selenified.java#L135-L137 |
landawn/AbacusUtil | src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java | PoolablePreparedStatement.setDate | @Override
public void setDate(int parameterIndex, Date x) throws SQLException {
"""
Method setDate.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setDate(int, Date)
"""
internalStmt.setDate(parameterIndex, x);
} | java | @Override
public void setDate(int parameterIndex, Date x) throws SQLException {
internalStmt.setDate(parameterIndex, x);
} | [
"@",
"Override",
"public",
"void",
"setDate",
"(",
"int",
"parameterIndex",
",",
"Date",
"x",
")",
"throws",
"SQLException",
"{",
"internalStmt",
".",
"setDate",
"(",
"parameterIndex",
",",
"x",
")",
";",
"}"
] | Method setDate.
@param parameterIndex
@param x
@throws SQLException
@see java.sql.PreparedStatement#setDate(int, Date) | [
"Method",
"setDate",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/dataSource/PoolablePreparedStatement.java#L711-L714 |
mozilla/rhino | src/org/mozilla/classfile/ClassFileWriter.java | ClassFileWriter.classNameToSignature | public static String classNameToSignature(String name) {
"""
Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form
suitable for use as JVM type signatures.
"""
int nameLength = name.length();
int colonPos = 1 + nameLength;
char[] buf = new char[colonPos + 1];
buf[0] = 'L';
buf[colonPos] = ';';
name.getChars(0, nameLength, buf, 1);
for (int i = 1; i != colonPos; ++i) {
if (buf[i] == '.') {
buf[i] = '/';
}
}
return new String(buf, 0, colonPos + 1);
} | java | public static String classNameToSignature(String name) {
int nameLength = name.length();
int colonPos = 1 + nameLength;
char[] buf = new char[colonPos + 1];
buf[0] = 'L';
buf[colonPos] = ';';
name.getChars(0, nameLength, buf, 1);
for (int i = 1; i != colonPos; ++i) {
if (buf[i] == '.') {
buf[i] = '/';
}
}
return new String(buf, 0, colonPos + 1);
} | [
"public",
"static",
"String",
"classNameToSignature",
"(",
"String",
"name",
")",
"{",
"int",
"nameLength",
"=",
"name",
".",
"length",
"(",
")",
";",
"int",
"colonPos",
"=",
"1",
"+",
"nameLength",
";",
"char",
"[",
"]",
"buf",
"=",
"new",
"char",
"[",
"colonPos",
"+",
"1",
"]",
";",
"buf",
"[",
"0",
"]",
"=",
"'",
"'",
";",
"buf",
"[",
"colonPos",
"]",
"=",
"'",
"'",
";",
"name",
".",
"getChars",
"(",
"0",
",",
"nameLength",
",",
"buf",
",",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"!=",
"colonPos",
";",
"++",
"i",
")",
"{",
"if",
"(",
"buf",
"[",
"i",
"]",
"==",
"'",
"'",
")",
"{",
"buf",
"[",
"i",
"]",
"=",
"'",
"'",
";",
"}",
"}",
"return",
"new",
"String",
"(",
"buf",
",",
"0",
",",
"colonPos",
"+",
"1",
")",
";",
"}"
] | Convert Java class name in dot notation into "Lname-with-dots-replaced-by-slashes;" form
suitable for use as JVM type signatures. | [
"Convert",
"Java",
"class",
"name",
"in",
"dot",
"notation",
"into",
"Lname",
"-",
"with",
"-",
"dots",
"-",
"replaced",
"-",
"by",
"-",
"slashes",
";",
"form",
"suitable",
"for",
"use",
"as",
"JVM",
"type",
"signatures",
"."
] | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/classfile/ClassFileWriter.java#L113-L126 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java | MapUtil.newHashMap | public static <K, V> HashMap<K, V> newHashMap(boolean isOrder) {
"""
新建一个HashMap
@param <K> Key类型
@param <V> Value类型
@param isOrder Map的Key是否有序,有序返回 {@link LinkedHashMap},否则返回 {@link HashMap}
@return HashMap对象
"""
return newHashMap(DEFAULT_INITIAL_CAPACITY, isOrder);
} | java | public static <K, V> HashMap<K, V> newHashMap(boolean isOrder) {
return newHashMap(DEFAULT_INITIAL_CAPACITY, isOrder);
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"HashMap",
"<",
"K",
",",
"V",
">",
"newHashMap",
"(",
"boolean",
"isOrder",
")",
"{",
"return",
"newHashMap",
"(",
"DEFAULT_INITIAL_CAPACITY",
",",
"isOrder",
")",
";",
"}"
] | 新建一个HashMap
@param <K> Key类型
@param <V> Value类型
@param isOrder Map的Key是否有序,有序返回 {@link LinkedHashMap},否则返回 {@link HashMap}
@return HashMap对象 | [
"新建一个HashMap"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L106-L108 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java | ComputeNodeOperations.getComputeNodeRemoteLoginSettings | public ComputeNodeGetRemoteLoginSettingsResult getComputeNodeRemoteLoginSettings(String poolId, String nodeId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Gets the settings required for remote login to a compute node.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node for which to get a remote login settings.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@return The remote login settings for the specified compute node.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
ComputeNodeGetRemoteLoginSettingsOptions options = new ComputeNodeGetRemoteLoginSettingsOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
return this.parentBatchClient.protocolLayer().computeNodes().getRemoteLoginSettings(poolId, nodeId, options);
} | java | public ComputeNodeGetRemoteLoginSettingsResult getComputeNodeRemoteLoginSettings(String poolId, String nodeId, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
ComputeNodeGetRemoteLoginSettingsOptions options = new ComputeNodeGetRemoteLoginSettingsOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
return this.parentBatchClient.protocolLayer().computeNodes().getRemoteLoginSettings(poolId, nodeId, options);
} | [
"public",
"ComputeNodeGetRemoteLoginSettingsResult",
"getComputeNodeRemoteLoginSettings",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"ComputeNodeGetRemoteLoginSettingsOptions",
"options",
"=",
"new",
"ComputeNodeGetRemoteLoginSettingsOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"return",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"computeNodes",
"(",
")",
".",
"getRemoteLoginSettings",
"(",
"poolId",
",",
"nodeId",
",",
"options",
")",
";",
"}"
] | Gets the settings required for remote login to a compute node.
@param poolId The ID of the pool that contains the compute node.
@param nodeId The ID of the compute node for which to get a remote login settings.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@return The remote login settings for the specified compute node.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Gets",
"the",
"settings",
"required",
"for",
"remote",
"login",
"to",
"a",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java#L490-L496 |
kite-sdk/kite | kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/filesystem/FileSystemDatasetRepository.java | FileSystemDatasetRepository.pathForDataset | @edu.umd.cs.findbugs.annotations.SuppressWarnings(
value="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification="Checked in precondition")
static Path pathForDataset(Path root, @Nullable String namespace, @Nullable String name) {
"""
Returns the correct dataset path for the given name and root directory.
@param root A Path
@param name A String dataset name
@return the correct dataset Path
"""
Preconditions.checkNotNull(namespace, "Namespace cannot be null");
Preconditions.checkNotNull(name, "Dataset name cannot be null");
// Why replace '.' here? Is this a namespacing hack?
return new Path(root, new Path(namespace, name.replace('.', Path.SEPARATOR_CHAR)));
} | java | @edu.umd.cs.findbugs.annotations.SuppressWarnings(
value="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
justification="Checked in precondition")
static Path pathForDataset(Path root, @Nullable String namespace, @Nullable String name) {
Preconditions.checkNotNull(namespace, "Namespace cannot be null");
Preconditions.checkNotNull(name, "Dataset name cannot be null");
// Why replace '.' here? Is this a namespacing hack?
return new Path(root, new Path(namespace, name.replace('.', Path.SEPARATOR_CHAR)));
} | [
"@",
"edu",
".",
"umd",
".",
"cs",
".",
"findbugs",
".",
"annotations",
".",
"SuppressWarnings",
"(",
"value",
"=",
"\"NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE\"",
",",
"justification",
"=",
"\"Checked in precondition\"",
")",
"static",
"Path",
"pathForDataset",
"(",
"Path",
"root",
",",
"@",
"Nullable",
"String",
"namespace",
",",
"@",
"Nullable",
"String",
"name",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"namespace",
",",
"\"Namespace cannot be null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"name",
",",
"\"Dataset name cannot be null\"",
")",
";",
"// Why replace '.' here? Is this a namespacing hack?",
"return",
"new",
"Path",
"(",
"root",
",",
"new",
"Path",
"(",
"namespace",
",",
"name",
".",
"replace",
"(",
"'",
"'",
",",
"Path",
".",
"SEPARATOR_CHAR",
")",
")",
")",
";",
"}"
] | Returns the correct dataset path for the given name and root directory.
@param root A Path
@param name A String dataset name
@return the correct dataset Path | [
"Returns",
"the",
"correct",
"dataset",
"path",
"for",
"the",
"given",
"name",
"and",
"root",
"directory",
"."
] | train | https://github.com/kite-sdk/kite/blob/72bfb4b1a881af85808cd7f14bc3e15160a1e811/kite-data/kite-data-core/src/main/java/org/kitesdk/data/spi/filesystem/FileSystemDatasetRepository.java#L311-L320 |
graphhopper/graphhopper | core/src/main/java/com/graphhopper/geohash/SpatialKeyAlgo.java | SpatialKeyAlgo.decode | @Override
public final void decode(long spatialKey, GHPoint latLon) {
"""
This method returns latitude and longitude via latLon - calculated from specified spatialKey
<p>
@param spatialKey is the input
"""
// Performance: calculating 'midLon' and 'midLat' on the fly is not slower than using
// precalculated values from arrays and for 'bits' a precalculated array is even slightly slower!
// Use the value in the middle => start from "min" use "max" as initial step-size
double midLat = (bbox.maxLat - bbox.minLat) / 2;
double midLon = (bbox.maxLon - bbox.minLon) / 2;
double lat = bbox.minLat;
double lon = bbox.minLon;
long bits = initialBits;
while (true) {
if ((spatialKey & bits) != 0) {
lat += midLat;
}
midLat /= 2;
bits >>>= 1;
if ((spatialKey & bits) != 0) {
lon += midLon;
}
midLon /= 2;
if (bits > 1) {
bits >>>= 1;
} else {
break;
}
}
// stable rounding - see testBijection
lat += midLat;
lon += midLon;
latLon.lat = lat;
latLon.lon = lon;
} | java | @Override
public final void decode(long spatialKey, GHPoint latLon) {
// Performance: calculating 'midLon' and 'midLat' on the fly is not slower than using
// precalculated values from arrays and for 'bits' a precalculated array is even slightly slower!
// Use the value in the middle => start from "min" use "max" as initial step-size
double midLat = (bbox.maxLat - bbox.minLat) / 2;
double midLon = (bbox.maxLon - bbox.minLon) / 2;
double lat = bbox.minLat;
double lon = bbox.minLon;
long bits = initialBits;
while (true) {
if ((spatialKey & bits) != 0) {
lat += midLat;
}
midLat /= 2;
bits >>>= 1;
if ((spatialKey & bits) != 0) {
lon += midLon;
}
midLon /= 2;
if (bits > 1) {
bits >>>= 1;
} else {
break;
}
}
// stable rounding - see testBijection
lat += midLat;
lon += midLon;
latLon.lat = lat;
latLon.lon = lon;
} | [
"@",
"Override",
"public",
"final",
"void",
"decode",
"(",
"long",
"spatialKey",
",",
"GHPoint",
"latLon",
")",
"{",
"// Performance: calculating 'midLon' and 'midLat' on the fly is not slower than using ",
"// precalculated values from arrays and for 'bits' a precalculated array is even slightly slower!",
"// Use the value in the middle => start from \"min\" use \"max\" as initial step-size",
"double",
"midLat",
"=",
"(",
"bbox",
".",
"maxLat",
"-",
"bbox",
".",
"minLat",
")",
"/",
"2",
";",
"double",
"midLon",
"=",
"(",
"bbox",
".",
"maxLon",
"-",
"bbox",
".",
"minLon",
")",
"/",
"2",
";",
"double",
"lat",
"=",
"bbox",
".",
"minLat",
";",
"double",
"lon",
"=",
"bbox",
".",
"minLon",
";",
"long",
"bits",
"=",
"initialBits",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"(",
"spatialKey",
"&",
"bits",
")",
"!=",
"0",
")",
"{",
"lat",
"+=",
"midLat",
";",
"}",
"midLat",
"/=",
"2",
";",
"bits",
">>>=",
"1",
";",
"if",
"(",
"(",
"spatialKey",
"&",
"bits",
")",
"!=",
"0",
")",
"{",
"lon",
"+=",
"midLon",
";",
"}",
"midLon",
"/=",
"2",
";",
"if",
"(",
"bits",
">",
"1",
")",
"{",
"bits",
">>>=",
"1",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"// stable rounding - see testBijection",
"lat",
"+=",
"midLat",
";",
"lon",
"+=",
"midLon",
";",
"latLon",
".",
"lat",
"=",
"lat",
";",
"latLon",
".",
"lon",
"=",
"lon",
";",
"}"
] | This method returns latitude and longitude via latLon - calculated from specified spatialKey
<p>
@param spatialKey is the input | [
"This",
"method",
"returns",
"latitude",
"and",
"longitude",
"via",
"latLon",
"-",
"calculated",
"from",
"specified",
"spatialKey",
"<p",
">"
] | train | https://github.com/graphhopper/graphhopper/blob/c235e306e6e823043cadcc41ead0e685bdebf737/core/src/main/java/com/graphhopper/geohash/SpatialKeyAlgo.java#L194-L229 |
heroku/heroku.jar | heroku-api/src/main/java/com/heroku/api/HerokuAPI.java | HerokuAPI.getBuildInfo | public Build getBuildInfo(String appName, String buildId) {
"""
Gets the info for a running build
@param appName See {@link #listApps} for a list of apps that can be used.
@param buildId the unique identifier of the build
"""
return connection.execute(new BuildInfo(appName, buildId), apiKey);
} | java | public Build getBuildInfo(String appName, String buildId) {
return connection.execute(new BuildInfo(appName, buildId), apiKey);
} | [
"public",
"Build",
"getBuildInfo",
"(",
"String",
"appName",
",",
"String",
"buildId",
")",
"{",
"return",
"connection",
".",
"execute",
"(",
"new",
"BuildInfo",
"(",
"appName",
",",
"buildId",
")",
",",
"apiKey",
")",
";",
"}"
] | Gets the info for a running build
@param appName See {@link #listApps} for a list of apps that can be used.
@param buildId the unique identifier of the build | [
"Gets",
"the",
"info",
"for",
"a",
"running",
"build"
] | train | https://github.com/heroku/heroku.jar/blob/d9e52991293159498c10c498c6f91fcdd637378e/heroku-api/src/main/java/com/heroku/api/HerokuAPI.java#L451-L453 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.updateIntent | public OperationStatus updateIntent(UUID appId, String versionId, UUID intentId, UpdateIntentOptionalParameter updateIntentOptionalParameter) {
"""
Updates the name of an intent classifier.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param updateIntentOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful.
"""
return updateIntentWithServiceResponseAsync(appId, versionId, intentId, updateIntentOptionalParameter).toBlocking().single().body();
} | java | public OperationStatus updateIntent(UUID appId, String versionId, UUID intentId, UpdateIntentOptionalParameter updateIntentOptionalParameter) {
return updateIntentWithServiceResponseAsync(appId, versionId, intentId, updateIntentOptionalParameter).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"updateIntent",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"intentId",
",",
"UpdateIntentOptionalParameter",
"updateIntentOptionalParameter",
")",
"{",
"return",
"updateIntentWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"intentId",
",",
"updateIntentOptionalParameter",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates the name of an intent classifier.
@param appId The application ID.
@param versionId The version ID.
@param intentId The intent classifier ID.
@param updateIntentOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Updates",
"the",
"name",
"of",
"an",
"intent",
"classifier",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L2911-L2913 |
fabric8io/docker-maven-plugin | src/main/java/io/fabric8/maven/docker/service/RunService.java | RunService.findContainerId | private String findContainerId(String imageNameOrAlias, boolean checkAllContainers) throws DockerAccessException {
"""
checkAllContainers: false = only running containers are considered
"""
String id = lookupContainer(imageNameOrAlias);
// check for external container. The image name is interpreted as a *container name* for that case ...
if (id == null) {
Container container = queryService.getContainer(imageNameOrAlias);
if (container != null && (checkAllContainers || container.isRunning())) {
id = container.getId();
}
}
return id;
} | java | private String findContainerId(String imageNameOrAlias, boolean checkAllContainers) throws DockerAccessException {
String id = lookupContainer(imageNameOrAlias);
// check for external container. The image name is interpreted as a *container name* for that case ...
if (id == null) {
Container container = queryService.getContainer(imageNameOrAlias);
if (container != null && (checkAllContainers || container.isRunning())) {
id = container.getId();
}
}
return id;
} | [
"private",
"String",
"findContainerId",
"(",
"String",
"imageNameOrAlias",
",",
"boolean",
"checkAllContainers",
")",
"throws",
"DockerAccessException",
"{",
"String",
"id",
"=",
"lookupContainer",
"(",
"imageNameOrAlias",
")",
";",
"// check for external container. The image name is interpreted as a *container name* for that case ...",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"Container",
"container",
"=",
"queryService",
".",
"getContainer",
"(",
"imageNameOrAlias",
")",
";",
"if",
"(",
"container",
"!=",
"null",
"&&",
"(",
"checkAllContainers",
"||",
"container",
".",
"isRunning",
"(",
")",
")",
")",
"{",
"id",
"=",
"container",
".",
"getId",
"(",
")",
";",
"}",
"}",
"return",
"id",
";",
"}"
] | checkAllContainers: false = only running containers are considered | [
"checkAllContainers",
":",
"false",
"=",
"only",
"running",
"containers",
"are",
"considered"
] | train | https://github.com/fabric8io/docker-maven-plugin/blob/70ce4f56125d8efb8ddcf2ad4dbb5d6e2c7642b3/src/main/java/io/fabric8/maven/docker/service/RunService.java#L423-L434 |
messagebird/java-rest-api | api/src/main/java/com/messagebird/MessageBirdServiceImpl.java | MessageBirdServiceImpl.doRequest | <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException {
"""
Actually sends a HTTP request and returns its body and HTTP status code.
@param method HTTP method.
@param url Absolute URL.
@param payload Payload to JSON encode for the request body. May be null.
@param <P> Type of the payload.
@return APIResponse containing the response's body and status.
"""
HttpURLConnection connection = null;
InputStream inputStream = null;
if (METHOD_PATCH.equalsIgnoreCase(method)) {
// It'd perhaps be cleaner to call this in the constructor, but
// we'd then need to throw GeneralExceptions from there. This means
// it wouldn't be possible to declare AND initialize _instance_
// fields of MessageBirdServiceImpl at the same time. This method
// already throws this exception, so now we don't have to pollute
// our public API further.
allowPatchRequestsIfNeeded();
}
try {
connection = getConnection(url, payload, method);
int status = connection.getResponseCode();
if (APIResponse.isSuccessStatus(status)) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
return new APIResponse(readToEnd(inputStream), status);
} catch (IOException ioe) {
throw new GeneralException(ioe);
} finally {
saveClose(inputStream);
if (connection != null) {
connection.disconnect();
}
}
} | java | <P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException {
HttpURLConnection connection = null;
InputStream inputStream = null;
if (METHOD_PATCH.equalsIgnoreCase(method)) {
// It'd perhaps be cleaner to call this in the constructor, but
// we'd then need to throw GeneralExceptions from there. This means
// it wouldn't be possible to declare AND initialize _instance_
// fields of MessageBirdServiceImpl at the same time. This method
// already throws this exception, so now we don't have to pollute
// our public API further.
allowPatchRequestsIfNeeded();
}
try {
connection = getConnection(url, payload, method);
int status = connection.getResponseCode();
if (APIResponse.isSuccessStatus(status)) {
inputStream = connection.getInputStream();
} else {
inputStream = connection.getErrorStream();
}
return new APIResponse(readToEnd(inputStream), status);
} catch (IOException ioe) {
throw new GeneralException(ioe);
} finally {
saveClose(inputStream);
if (connection != null) {
connection.disconnect();
}
}
} | [
"<",
"P",
">",
"APIResponse",
"doRequest",
"(",
"final",
"String",
"method",
",",
"final",
"String",
"url",
",",
"final",
"P",
"payload",
")",
"throws",
"GeneralException",
"{",
"HttpURLConnection",
"connection",
"=",
"null",
";",
"InputStream",
"inputStream",
"=",
"null",
";",
"if",
"(",
"METHOD_PATCH",
".",
"equalsIgnoreCase",
"(",
"method",
")",
")",
"{",
"// It'd perhaps be cleaner to call this in the constructor, but",
"// we'd then need to throw GeneralExceptions from there. This means",
"// it wouldn't be possible to declare AND initialize _instance_",
"// fields of MessageBirdServiceImpl at the same time. This method",
"// already throws this exception, so now we don't have to pollute",
"// our public API further.",
"allowPatchRequestsIfNeeded",
"(",
")",
";",
"}",
"try",
"{",
"connection",
"=",
"getConnection",
"(",
"url",
",",
"payload",
",",
"method",
")",
";",
"int",
"status",
"=",
"connection",
".",
"getResponseCode",
"(",
")",
";",
"if",
"(",
"APIResponse",
".",
"isSuccessStatus",
"(",
"status",
")",
")",
"{",
"inputStream",
"=",
"connection",
".",
"getInputStream",
"(",
")",
";",
"}",
"else",
"{",
"inputStream",
"=",
"connection",
".",
"getErrorStream",
"(",
")",
";",
"}",
"return",
"new",
"APIResponse",
"(",
"readToEnd",
"(",
"inputStream",
")",
",",
"status",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"GeneralException",
"(",
"ioe",
")",
";",
"}",
"finally",
"{",
"saveClose",
"(",
"inputStream",
")",
";",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"connection",
".",
"disconnect",
"(",
")",
";",
"}",
"}",
"}"
] | Actually sends a HTTP request and returns its body and HTTP status code.
@param method HTTP method.
@param url Absolute URL.
@param payload Payload to JSON encode for the request body. May be null.
@param <P> Type of the payload.
@return APIResponse containing the response's body and status. | [
"Actually",
"sends",
"a",
"HTTP",
"request",
"and",
"returns",
"its",
"body",
"and",
"HTTP",
"status",
"code",
"."
] | train | https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L219-L253 |
prometheus/client_java | simpleclient_common/src/main/java/io/prometheus/client/exporter/common/TextFormat.java | TextFormat.write004 | public static void write004(Writer writer, Enumeration<Collector.MetricFamilySamples> mfs) throws IOException {
"""
Write out the text version 0.0.4 of the given MetricFamilySamples.
"""
/* See http://prometheus.io/docs/instrumenting/exposition_formats/
* for the output format specification. */
while(mfs.hasMoreElements()) {
Collector.MetricFamilySamples metricFamilySamples = mfs.nextElement();
writer.write("# HELP ");
writer.write(metricFamilySamples.name);
writer.write(' ');
writeEscapedHelp(writer, metricFamilySamples.help);
writer.write('\n');
writer.write("# TYPE ");
writer.write(metricFamilySamples.name);
writer.write(' ');
writer.write(typeString(metricFamilySamples.type));
writer.write('\n');
for (Collector.MetricFamilySamples.Sample sample: metricFamilySamples.samples) {
writer.write(sample.name);
if (sample.labelNames.size() > 0) {
writer.write('{');
for (int i = 0; i < sample.labelNames.size(); ++i) {
writer.write(sample.labelNames.get(i));
writer.write("=\"");
writeEscapedLabelValue(writer, sample.labelValues.get(i));
writer.write("\",");
}
writer.write('}');
}
writer.write(' ');
writer.write(Collector.doubleToGoString(sample.value));
if (sample.timestampMs != null){
writer.write(' ');
writer.write(sample.timestampMs.toString());
}
writer.write('\n');
}
}
} | java | public static void write004(Writer writer, Enumeration<Collector.MetricFamilySamples> mfs) throws IOException {
/* See http://prometheus.io/docs/instrumenting/exposition_formats/
* for the output format specification. */
while(mfs.hasMoreElements()) {
Collector.MetricFamilySamples metricFamilySamples = mfs.nextElement();
writer.write("# HELP ");
writer.write(metricFamilySamples.name);
writer.write(' ');
writeEscapedHelp(writer, metricFamilySamples.help);
writer.write('\n');
writer.write("# TYPE ");
writer.write(metricFamilySamples.name);
writer.write(' ');
writer.write(typeString(metricFamilySamples.type));
writer.write('\n');
for (Collector.MetricFamilySamples.Sample sample: metricFamilySamples.samples) {
writer.write(sample.name);
if (sample.labelNames.size() > 0) {
writer.write('{');
for (int i = 0; i < sample.labelNames.size(); ++i) {
writer.write(sample.labelNames.get(i));
writer.write("=\"");
writeEscapedLabelValue(writer, sample.labelValues.get(i));
writer.write("\",");
}
writer.write('}');
}
writer.write(' ');
writer.write(Collector.doubleToGoString(sample.value));
if (sample.timestampMs != null){
writer.write(' ');
writer.write(sample.timestampMs.toString());
}
writer.write('\n');
}
}
} | [
"public",
"static",
"void",
"write004",
"(",
"Writer",
"writer",
",",
"Enumeration",
"<",
"Collector",
".",
"MetricFamilySamples",
">",
"mfs",
")",
"throws",
"IOException",
"{",
"/* See http://prometheus.io/docs/instrumenting/exposition_formats/\n * for the output format specification. */",
"while",
"(",
"mfs",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"Collector",
".",
"MetricFamilySamples",
"metricFamilySamples",
"=",
"mfs",
".",
"nextElement",
"(",
")",
";",
"writer",
".",
"write",
"(",
"\"# HELP \"",
")",
";",
"writer",
".",
"write",
"(",
"metricFamilySamples",
".",
"name",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writeEscapedHelp",
"(",
"writer",
",",
"metricFamilySamples",
".",
"help",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"\"# TYPE \"",
")",
";",
"writer",
".",
"write",
"(",
"metricFamilySamples",
".",
"name",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"typeString",
"(",
"metricFamilySamples",
".",
"type",
")",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"for",
"(",
"Collector",
".",
"MetricFamilySamples",
".",
"Sample",
"sample",
":",
"metricFamilySamples",
".",
"samples",
")",
"{",
"writer",
".",
"write",
"(",
"sample",
".",
"name",
")",
";",
"if",
"(",
"sample",
".",
"labelNames",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sample",
".",
"labelNames",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"writer",
".",
"write",
"(",
"sample",
".",
"labelNames",
".",
"get",
"(",
"i",
")",
")",
";",
"writer",
".",
"write",
"(",
"\"=\\\"\"",
")",
";",
"writeEscapedLabelValue",
"(",
"writer",
",",
"sample",
".",
"labelValues",
".",
"get",
"(",
"i",
")",
")",
";",
"writer",
".",
"write",
"(",
"\"\\\",\"",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"Collector",
".",
"doubleToGoString",
"(",
"sample",
".",
"value",
")",
")",
";",
"if",
"(",
"sample",
".",
"timestampMs",
"!=",
"null",
")",
"{",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"write",
"(",
"sample",
".",
"timestampMs",
".",
"toString",
"(",
")",
")",
";",
"}",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"}",
"}",
"}"
] | Write out the text version 0.0.4 of the given MetricFamilySamples. | [
"Write",
"out",
"the",
"text",
"version",
"0",
".",
"0",
".",
"4",
"of",
"the",
"given",
"MetricFamilySamples",
"."
] | train | https://github.com/prometheus/client_java/blob/4e0e7527b048f1ffd0382dcb74c0b9dab23b4d9f/simpleclient_common/src/main/java/io/prometheus/client/exporter/common/TextFormat.java#L18-L56 |
baratine/baratine | framework/src/main/java/com/caucho/v5/config/types/Period.java | Period.periodEnd | public static long periodEnd(long now, long period) {
"""
Calculates the next period end. The calculation is in local time.
@param now the current time in GMT ms since the epoch
@return the time of the next period in GMT ms since the epoch
"""
QDate localCalendar = QDate.allocateLocalDate();
long endTime = periodEnd(now, period, localCalendar);
QDate.freeLocalDate(localCalendar);
return endTime;
} | java | public static long periodEnd(long now, long period)
{
QDate localCalendar = QDate.allocateLocalDate();
long endTime = periodEnd(now, period, localCalendar);
QDate.freeLocalDate(localCalendar);
return endTime;
} | [
"public",
"static",
"long",
"periodEnd",
"(",
"long",
"now",
",",
"long",
"period",
")",
"{",
"QDate",
"localCalendar",
"=",
"QDate",
".",
"allocateLocalDate",
"(",
")",
";",
"long",
"endTime",
"=",
"periodEnd",
"(",
"now",
",",
"period",
",",
"localCalendar",
")",
";",
"QDate",
".",
"freeLocalDate",
"(",
"localCalendar",
")",
";",
"return",
"endTime",
";",
"}"
] | Calculates the next period end. The calculation is in local time.
@param now the current time in GMT ms since the epoch
@return the time of the next period in GMT ms since the epoch | [
"Calculates",
"the",
"next",
"period",
"end",
".",
"The",
"calculation",
"is",
"in",
"local",
"time",
"."
] | train | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/config/types/Period.java#L217-L226 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java | Hierarchy.findXMethod | @Deprecated
public static XMethod findXMethod(JavaClass[] classList, String methodName, String methodSig) {
"""
Find XMethod for method in given list of classes, searching the classes
in order.
@param classList
list of classes in which to search
@param methodName
the name of the method
@param methodSig
the signature of the method
@return the XMethod, or null if no such method exists in the class
"""
return findXMethod(classList, methodName, methodSig, ANY_METHOD);
} | java | @Deprecated
public static XMethod findXMethod(JavaClass[] classList, String methodName, String methodSig) {
return findXMethod(classList, methodName, methodSig, ANY_METHOD);
} | [
"@",
"Deprecated",
"public",
"static",
"XMethod",
"findXMethod",
"(",
"JavaClass",
"[",
"]",
"classList",
",",
"String",
"methodName",
",",
"String",
"methodSig",
")",
"{",
"return",
"findXMethod",
"(",
"classList",
",",
"methodName",
",",
"methodSig",
",",
"ANY_METHOD",
")",
";",
"}"
] | Find XMethod for method in given list of classes, searching the classes
in order.
@param classList
list of classes in which to search
@param methodName
the name of the method
@param methodSig
the signature of the method
@return the XMethod, or null if no such method exists in the class | [
"Find",
"XMethod",
"for",
"method",
"in",
"given",
"list",
"of",
"classes",
"searching",
"the",
"classes",
"in",
"order",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/Hierarchy.java#L667-L670 |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java | IPAddressString.adjustPrefixLength | public IPAddressString adjustPrefixLength(int adjustment) {
"""
Increases or decreases prefix length by the given increment.
<p>
This acts on address strings with an associated prefix length, whether or not there is also an associated address value.
<p>
If the address string has prefix length 0 and represents all addresses of the same version,
and the prefix length is being decreased, then the address representing all addresses of any version is returned.
<p>
When there is an associated address value and the prefix length is increased, the bits moved within the prefix become zero,
and if prefix lengthis extended beyond the segment series boundary, it is removed.
When there is an associated address value
and the prefix length is decreased, the bits moved outside the prefix become zero.
Also see {@link IPAddress#adjustPrefixLength(int)}
@param adjustment
@return
"""
if(isPrefixOnly()) {
int newBits = adjustment > 0 ? Math.min(IPv6Address.BIT_COUNT, getNetworkPrefixLength() + adjustment) : Math.max(0, getNetworkPrefixLength() + adjustment);
return new IPAddressString(IPAddressNetwork.getPrefixString(newBits), validationOptions);
}
IPAddress address = getAddress();
if(address == null) {
return null;
}
if(adjustment == 0) {
return this;
}
Integer prefix = address.getNetworkPrefixLength();
if(prefix != null && prefix + adjustment < 0 && address.isPrefixBlock()) {
return new IPAddressString(IPAddress.SEGMENT_WILDCARD_STR, validationOptions);
}
return address.adjustPrefixLength(adjustment).toAddressString();
} | java | public IPAddressString adjustPrefixLength(int adjustment) {
if(isPrefixOnly()) {
int newBits = adjustment > 0 ? Math.min(IPv6Address.BIT_COUNT, getNetworkPrefixLength() + adjustment) : Math.max(0, getNetworkPrefixLength() + adjustment);
return new IPAddressString(IPAddressNetwork.getPrefixString(newBits), validationOptions);
}
IPAddress address = getAddress();
if(address == null) {
return null;
}
if(adjustment == 0) {
return this;
}
Integer prefix = address.getNetworkPrefixLength();
if(prefix != null && prefix + adjustment < 0 && address.isPrefixBlock()) {
return new IPAddressString(IPAddress.SEGMENT_WILDCARD_STR, validationOptions);
}
return address.adjustPrefixLength(adjustment).toAddressString();
} | [
"public",
"IPAddressString",
"adjustPrefixLength",
"(",
"int",
"adjustment",
")",
"{",
"if",
"(",
"isPrefixOnly",
"(",
")",
")",
"{",
"int",
"newBits",
"=",
"adjustment",
">",
"0",
"?",
"Math",
".",
"min",
"(",
"IPv6Address",
".",
"BIT_COUNT",
",",
"getNetworkPrefixLength",
"(",
")",
"+",
"adjustment",
")",
":",
"Math",
".",
"max",
"(",
"0",
",",
"getNetworkPrefixLength",
"(",
")",
"+",
"adjustment",
")",
";",
"return",
"new",
"IPAddressString",
"(",
"IPAddressNetwork",
".",
"getPrefixString",
"(",
"newBits",
")",
",",
"validationOptions",
")",
";",
"}",
"IPAddress",
"address",
"=",
"getAddress",
"(",
")",
";",
"if",
"(",
"address",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"adjustment",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"Integer",
"prefix",
"=",
"address",
".",
"getNetworkPrefixLength",
"(",
")",
";",
"if",
"(",
"prefix",
"!=",
"null",
"&&",
"prefix",
"+",
"adjustment",
"<",
"0",
"&&",
"address",
".",
"isPrefixBlock",
"(",
")",
")",
"{",
"return",
"new",
"IPAddressString",
"(",
"IPAddress",
".",
"SEGMENT_WILDCARD_STR",
",",
"validationOptions",
")",
";",
"}",
"return",
"address",
".",
"adjustPrefixLength",
"(",
"adjustment",
")",
".",
"toAddressString",
"(",
")",
";",
"}"
] | Increases or decreases prefix length by the given increment.
<p>
This acts on address strings with an associated prefix length, whether or not there is also an associated address value.
<p>
If the address string has prefix length 0 and represents all addresses of the same version,
and the prefix length is being decreased, then the address representing all addresses of any version is returned.
<p>
When there is an associated address value and the prefix length is increased, the bits moved within the prefix become zero,
and if prefix lengthis extended beyond the segment series boundary, it is removed.
When there is an associated address value
and the prefix length is decreased, the bits moved outside the prefix become zero.
Also see {@link IPAddress#adjustPrefixLength(int)}
@param adjustment
@return | [
"Increases",
"or",
"decreases",
"prefix",
"length",
"by",
"the",
"given",
"increment",
".",
"<p",
">",
"This",
"acts",
"on",
"address",
"strings",
"with",
"an",
"associated",
"prefix",
"length",
"whether",
"or",
"not",
"there",
"is",
"also",
"an",
"associated",
"address",
"value",
".",
"<p",
">",
"If",
"the",
"address",
"string",
"has",
"prefix",
"length",
"0",
"and",
"represents",
"all",
"addresses",
"of",
"the",
"same",
"version",
"and",
"the",
"prefix",
"length",
"is",
"being",
"decreased",
"then",
"the",
"address",
"representing",
"all",
"addresses",
"of",
"any",
"version",
"is",
"returned",
".",
"<p",
">",
"When",
"there",
"is",
"an",
"associated",
"address",
"value",
"and",
"the",
"prefix",
"length",
"is",
"increased",
"the",
"bits",
"moved",
"within",
"the",
"prefix",
"become",
"zero",
"and",
"if",
"prefix",
"lengthis",
"extended",
"beyond",
"the",
"segment",
"series",
"boundary",
"it",
"is",
"removed",
".",
"When",
"there",
"is",
"an",
"associated",
"address",
"value",
"and",
"the",
"prefix",
"length",
"is",
"decreased",
"the",
"bits",
"moved",
"outside",
"the",
"prefix",
"become",
"zero",
"."
] | train | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java#L843-L860 |
googlemaps/google-maps-services-java | src/main/java/com/google/maps/PlacesApi.java | PlacesApi.nearbySearchQuery | public static NearbySearchRequest nearbySearchQuery(GeoApiContext context, LatLng location) {
"""
Performs a search for nearby Places.
@param context The context on which to make Geo API requests.
@param location The latitude/longitude around which to retrieve place information.
@return Returns a NearbySearchRequest that can be configured and executed.
"""
NearbySearchRequest request = new NearbySearchRequest(context);
request.location(location);
return request;
} | java | public static NearbySearchRequest nearbySearchQuery(GeoApiContext context, LatLng location) {
NearbySearchRequest request = new NearbySearchRequest(context);
request.location(location);
return request;
} | [
"public",
"static",
"NearbySearchRequest",
"nearbySearchQuery",
"(",
"GeoApiContext",
"context",
",",
"LatLng",
"location",
")",
"{",
"NearbySearchRequest",
"request",
"=",
"new",
"NearbySearchRequest",
"(",
"context",
")",
";",
"request",
".",
"location",
"(",
"location",
")",
";",
"return",
"request",
";",
"}"
] | Performs a search for nearby Places.
@param context The context on which to make Geo API requests.
@param location The latitude/longitude around which to retrieve place information.
@return Returns a NearbySearchRequest that can be configured and executed. | [
"Performs",
"a",
"search",
"for",
"nearby",
"Places",
"."
] | train | https://github.com/googlemaps/google-maps-services-java/blob/23d20d1930f80e310d856d2da51d72ee0db4476b/src/main/java/com/google/maps/PlacesApi.java#L40-L44 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.hosting_web_serviceName_changeMainDomain_duration_GET | public OvhOrder hosting_web_serviceName_changeMainDomain_duration_GET(String serviceName, String duration, String domain, OvhMxPlanEnum mxplan) throws IOException {
"""
Get prices and contracts information
REST: GET /order/hosting/web/{serviceName}/changeMainDomain/{duration}
@param domain [required] New domain for change the main domain
@param mxplan [required] MX plan linked to the odl main domain
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration
"""
String qPath = "/order/hosting/web/{serviceName}/changeMainDomain/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "domain", domain);
query(sb, "mxplan", mxplan);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder hosting_web_serviceName_changeMainDomain_duration_GET(String serviceName, String duration, String domain, OvhMxPlanEnum mxplan) throws IOException {
String qPath = "/order/hosting/web/{serviceName}/changeMainDomain/{duration}";
StringBuilder sb = path(qPath, serviceName, duration);
query(sb, "domain", domain);
query(sb, "mxplan", mxplan);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"hosting_web_serviceName_changeMainDomain_duration_GET",
"(",
"String",
"serviceName",
",",
"String",
"duration",
",",
"String",
"domain",
",",
"OvhMxPlanEnum",
"mxplan",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/hosting/web/{serviceName}/changeMainDomain/{duration}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"duration",
")",
";",
"query",
"(",
"sb",
",",
"\"domain\"",
",",
"domain",
")",
";",
"query",
"(",
"sb",
",",
"\"mxplan\"",
",",
"mxplan",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOrder",
".",
"class",
")",
";",
"}"
] | Get prices and contracts information
REST: GET /order/hosting/web/{serviceName}/changeMainDomain/{duration}
@param domain [required] New domain for change the main domain
@param mxplan [required] MX plan linked to the odl main domain
@param serviceName [required] The internal name of your hosting
@param duration [required] Duration | [
"Get",
"prices",
"and",
"contracts",
"information"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L4890-L4897 |
rythmengine/rythmengine | src/main/java/org/rythmengine/toString/ToStringStyle.java | ToStringStyle.appendDetail | protected void appendDetail(StringBuilder buffer, String fieldName, Collection<?> coll) {
"""
<p>Append to the <code>toString</code> a <code>Collection</code>.</p>
@param buffer the <code>StringBuilder</code> to populate
@param fieldName the field name, typically not used as already appended
@param coll the <code>Collection</code> to add to the
<code>toString</code>, not <code>null</code>
"""
buffer.append(coll);
} | java | protected void appendDetail(StringBuilder buffer, String fieldName, Collection<?> coll) {
buffer.append(coll);
} | [
"protected",
"void",
"appendDetail",
"(",
"StringBuilder",
"buffer",
",",
"String",
"fieldName",
",",
"Collection",
"<",
"?",
">",
"coll",
")",
"{",
"buffer",
".",
"append",
"(",
"coll",
")",
";",
"}"
] | <p>Append to the <code>toString</code> a <code>Collection</code>.</p>
@param buffer the <code>StringBuilder</code> to populate
@param fieldName the field name, typically not used as already appended
@param coll the <code>Collection</code> to add to the
<code>toString</code>, not <code>null</code> | [
"<p",
">",
"Append",
"to",
"the",
"<code",
">",
"toString<",
"/",
"code",
">",
"a",
"<code",
">",
"Collection<",
"/",
"code",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/rythmengine/rythmengine/blob/064b565f08d9da07378bf77a9dd856ea5831cc92/src/main/java/org/rythmengine/toString/ToStringStyle.java#L603-L605 |
headius/invokebinder | src/main/java/com/headius/invokebinder/Binder.java | Binder.collect | public Binder collect(int index, Class<?> type) {
"""
Box all incoming arguments from the given position onward into the given array type.
@param index the index from which to start boxing args
@param type the array type into which the args will be boxed
@return a new Binder
"""
return new Binder(this, new Collect(type(), index, type));
} | java | public Binder collect(int index, Class<?> type) {
return new Binder(this, new Collect(type(), index, type));
} | [
"public",
"Binder",
"collect",
"(",
"int",
"index",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"return",
"new",
"Binder",
"(",
"this",
",",
"new",
"Collect",
"(",
"type",
"(",
")",
",",
"index",
",",
"type",
")",
")",
";",
"}"
] | Box all incoming arguments from the given position onward into the given array type.
@param index the index from which to start boxing args
@param type the array type into which the args will be boxed
@return a new Binder | [
"Box",
"all",
"incoming",
"arguments",
"from",
"the",
"given",
"position",
"onward",
"into",
"the",
"given",
"array",
"type",
"."
] | train | https://github.com/headius/invokebinder/blob/ce6bfeb8e33265480daa7b797989dd915d51238d/src/main/java/com/headius/invokebinder/Binder.java#L879-L881 |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitNaryExpression | public T visitNaryExpression(NaryExpression elm, C context) {
"""
Visit a NaryExpression. This method will be called for
every node in the tree that is a NaryExpression.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result
"""
if (elm instanceof Coalesce) return visitCoalesce((Coalesce)elm, context);
else if (elm instanceof Concatenate) return visitConcatenate((Concatenate)elm, context);
else if (elm instanceof Except) return visitExcept((Except)elm, context);
else if (elm instanceof Intersect) return visitIntersect((Intersect)elm, context);
else if (elm instanceof Union) return visitUnion((Union)elm, context);
else return null;
} | java | public T visitNaryExpression(NaryExpression elm, C context) {
if (elm instanceof Coalesce) return visitCoalesce((Coalesce)elm, context);
else if (elm instanceof Concatenate) return visitConcatenate((Concatenate)elm, context);
else if (elm instanceof Except) return visitExcept((Except)elm, context);
else if (elm instanceof Intersect) return visitIntersect((Intersect)elm, context);
else if (elm instanceof Union) return visitUnion((Union)elm, context);
else return null;
} | [
"public",
"T",
"visitNaryExpression",
"(",
"NaryExpression",
"elm",
",",
"C",
"context",
")",
"{",
"if",
"(",
"elm",
"instanceof",
"Coalesce",
")",
"return",
"visitCoalesce",
"(",
"(",
"Coalesce",
")",
"elm",
",",
"context",
")",
";",
"else",
"if",
"(",
"elm",
"instanceof",
"Concatenate",
")",
"return",
"visitConcatenate",
"(",
"(",
"Concatenate",
")",
"elm",
",",
"context",
")",
";",
"else",
"if",
"(",
"elm",
"instanceof",
"Except",
")",
"return",
"visitExcept",
"(",
"(",
"Except",
")",
"elm",
",",
"context",
")",
";",
"else",
"if",
"(",
"elm",
"instanceof",
"Intersect",
")",
"return",
"visitIntersect",
"(",
"(",
"Intersect",
")",
"elm",
",",
"context",
")",
";",
"else",
"if",
"(",
"elm",
"instanceof",
"Union",
")",
"return",
"visitUnion",
"(",
"(",
"Union",
")",
"elm",
",",
"context",
")",
";",
"else",
"return",
"null",
";",
"}"
] | Visit a NaryExpression. This method will be called for
every node in the tree that is a NaryExpression.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"NaryExpression",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"NaryExpression",
"."
] | train | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L299-L306 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/CalendarPanel.java | CalendarPanel.labelIndicatorSetColorsToDefaultState | private void labelIndicatorSetColorsToDefaultState(JLabel label) {
"""
labelIndicatorSetColorsToDefaultState, This event is called to set a label indicator to the
state it should have when there is no mouse hovering over it.
"""
if (label == null || settings == null) {
return;
}
if (label == labelMonth || label == labelYear) {
label.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
monthAndYearInnerPanel.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
}
if (label == labelSetDateToToday) {
label.setBackground(settings.getColor(DateArea.BackgroundTodayLabel));
}
if (label == labelClearDate) {
label.setBackground(settings.getColor(DateArea.BackgroundClearLabel));
}
label.setBorder(new CompoundBorder(
new EmptyBorder(1, 1, 1, 1), labelIndicatorEmptyBorder));
} | java | private void labelIndicatorSetColorsToDefaultState(JLabel label) {
if (label == null || settings == null) {
return;
}
if (label == labelMonth || label == labelYear) {
label.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
monthAndYearInnerPanel.setBackground(settings.getColor(DateArea.BackgroundMonthAndYearMenuLabels));
}
if (label == labelSetDateToToday) {
label.setBackground(settings.getColor(DateArea.BackgroundTodayLabel));
}
if (label == labelClearDate) {
label.setBackground(settings.getColor(DateArea.BackgroundClearLabel));
}
label.setBorder(new CompoundBorder(
new EmptyBorder(1, 1, 1, 1), labelIndicatorEmptyBorder));
} | [
"private",
"void",
"labelIndicatorSetColorsToDefaultState",
"(",
"JLabel",
"label",
")",
"{",
"if",
"(",
"label",
"==",
"null",
"||",
"settings",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"label",
"==",
"labelMonth",
"||",
"label",
"==",
"labelYear",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundMonthAndYearMenuLabels",
")",
")",
";",
"monthAndYearInnerPanel",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundMonthAndYearMenuLabels",
")",
")",
";",
"}",
"if",
"(",
"label",
"==",
"labelSetDateToToday",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundTodayLabel",
")",
")",
";",
"}",
"if",
"(",
"label",
"==",
"labelClearDate",
")",
"{",
"label",
".",
"setBackground",
"(",
"settings",
".",
"getColor",
"(",
"DateArea",
".",
"BackgroundClearLabel",
")",
")",
";",
"}",
"label",
".",
"setBorder",
"(",
"new",
"CompoundBorder",
"(",
"new",
"EmptyBorder",
"(",
"1",
",",
"1",
",",
"1",
",",
"1",
")",
",",
"labelIndicatorEmptyBorder",
")",
")",
";",
"}"
] | labelIndicatorSetColorsToDefaultState, This event is called to set a label indicator to the
state it should have when there is no mouse hovering over it. | [
"labelIndicatorSetColorsToDefaultState",
"This",
"event",
"is",
"called",
"to",
"set",
"a",
"label",
"indicator",
"to",
"the",
"state",
"it",
"should",
"have",
"when",
"there",
"is",
"no",
"mouse",
"hovering",
"over",
"it",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/CalendarPanel.java#L961-L977 |
sarl/sarl | sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java | AbstractMapView.fireEntryAdded | @SuppressWarnings("unchecked")
protected void fireEntryAdded(K key, V value) {
"""
Fire the addition event.
@param key the added key.
@param value the added value.
"""
if (this.listeners != null) {
for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) {
listener.entryAdded(key, value);
}
}
} | java | @SuppressWarnings("unchecked")
protected void fireEntryAdded(K key, V value) {
if (this.listeners != null) {
for (final DMapListener<? super K, ? super V> listener : this.listeners.getListeners(DMapListener.class)) {
listener.entryAdded(key, value);
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"fireEntryAdded",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"if",
"(",
"this",
".",
"listeners",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"DMapListener",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"V",
">",
"listener",
":",
"this",
".",
"listeners",
".",
"getListeners",
"(",
"DMapListener",
".",
"class",
")",
")",
"{",
"listener",
".",
"entryAdded",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"}"
] | Fire the addition event.
@param key the added key.
@param value the added value. | [
"Fire",
"the",
"addition",
"event",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/util/AbstractMapView.java#L58-L65 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/internal/partition/impl/InternalPartitionServiceImpl.java | InternalPartitionServiceImpl.createMigrationCommitPartitionState | PartitionRuntimeState createMigrationCommitPartitionState(MigrationInfo migrationInfo) {
"""
Creates a transient PartitionRuntimeState to commit given migration.
Result migration is applied to partition table and migration is added to completed-migrations set.
Version of created partition table is incremented by 1.
"""
lock.lock();
try {
if (!partitionStateManager.isInitialized()) {
return null;
}
List<MigrationInfo> completedMigrations = migrationManager.getCompletedMigrationsCopy();
InternalPartition[] partitions = partitionStateManager.getPartitionsCopy();
int partitionId = migrationInfo.getPartitionId();
InternalPartitionImpl partition = (InternalPartitionImpl) partitions[partitionId];
migrationManager.applyMigration(partition, migrationInfo);
migrationInfo.setStatus(MigrationStatus.SUCCESS);
completedMigrations.add(migrationInfo);
int committedVersion = getPartitionStateVersion() + 1;
return new PartitionRuntimeState(partitions, completedMigrations, committedVersion);
} finally {
lock.unlock();
}
} | java | PartitionRuntimeState createMigrationCommitPartitionState(MigrationInfo migrationInfo) {
lock.lock();
try {
if (!partitionStateManager.isInitialized()) {
return null;
}
List<MigrationInfo> completedMigrations = migrationManager.getCompletedMigrationsCopy();
InternalPartition[] partitions = partitionStateManager.getPartitionsCopy();
int partitionId = migrationInfo.getPartitionId();
InternalPartitionImpl partition = (InternalPartitionImpl) partitions[partitionId];
migrationManager.applyMigration(partition, migrationInfo);
migrationInfo.setStatus(MigrationStatus.SUCCESS);
completedMigrations.add(migrationInfo);
int committedVersion = getPartitionStateVersion() + 1;
return new PartitionRuntimeState(partitions, completedMigrations, committedVersion);
} finally {
lock.unlock();
}
} | [
"PartitionRuntimeState",
"createMigrationCommitPartitionState",
"(",
"MigrationInfo",
"migrationInfo",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"partitionStateManager",
".",
"isInitialized",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"MigrationInfo",
">",
"completedMigrations",
"=",
"migrationManager",
".",
"getCompletedMigrationsCopy",
"(",
")",
";",
"InternalPartition",
"[",
"]",
"partitions",
"=",
"partitionStateManager",
".",
"getPartitionsCopy",
"(",
")",
";",
"int",
"partitionId",
"=",
"migrationInfo",
".",
"getPartitionId",
"(",
")",
";",
"InternalPartitionImpl",
"partition",
"=",
"(",
"InternalPartitionImpl",
")",
"partitions",
"[",
"partitionId",
"]",
";",
"migrationManager",
".",
"applyMigration",
"(",
"partition",
",",
"migrationInfo",
")",
";",
"migrationInfo",
".",
"setStatus",
"(",
"MigrationStatus",
".",
"SUCCESS",
")",
";",
"completedMigrations",
".",
"add",
"(",
"migrationInfo",
")",
";",
"int",
"committedVersion",
"=",
"getPartitionStateVersion",
"(",
")",
"+",
"1",
";",
"return",
"new",
"PartitionRuntimeState",
"(",
"partitions",
",",
"completedMigrations",
",",
"committedVersion",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Creates a transient PartitionRuntimeState to commit given migration.
Result migration is applied to partition table and migration is added to completed-migrations set.
Version of created partition table is incremented by 1. | [
"Creates",
"a",
"transient",
"PartitionRuntimeState",
"to",
"commit",
"given",
"migration",
".",
"Result",
"migration",
"is",
"applied",
"to",
"partition",
"table",
"and",
"migration",
"is",
"added",
"to",
"completed",
"-",
"migrations",
"set",
".",
"Version",
"of",
"created",
"partition",
"table",
"is",
"incremented",
"by",
"1",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/partition/impl/InternalPartitionServiceImpl.java#L444-L466 |
networknt/light-4j | security/src/main/java/com/networknt/security/JwtHelper.java | JwtHelper.verifyJwt | @Deprecated
public static JwtClaims verifyJwt(String jwt, boolean ignoreExpiry) throws InvalidJwtException, ExpiredTokenException {
"""
Verify JWT token format and signature. If ignoreExpiry is true, skip expiry verification, otherwise
verify the expiry before signature verification.
In most cases, we need to verify the expiry of the jwt token. The only time we need to ignore expiry
verification is in SPA middleware handlers which need to verify csrf token in jwt against the csrf
token in the request header to renew the expired token.
@param jwt String of Json web token
@param ignoreExpiry If true, don't verify if the token is expired.
@return JwtClaims object
@throws InvalidJwtException InvalidJwtException
@throws ExpiredTokenException ExpiredTokenException
@deprecated Use verifyToken instead.
"""
return verifyJwt(jwt, ignoreExpiry, true);
} | java | @Deprecated
public static JwtClaims verifyJwt(String jwt, boolean ignoreExpiry) throws InvalidJwtException, ExpiredTokenException {
return verifyJwt(jwt, ignoreExpiry, true);
} | [
"@",
"Deprecated",
"public",
"static",
"JwtClaims",
"verifyJwt",
"(",
"String",
"jwt",
",",
"boolean",
"ignoreExpiry",
")",
"throws",
"InvalidJwtException",
",",
"ExpiredTokenException",
"{",
"return",
"verifyJwt",
"(",
"jwt",
",",
"ignoreExpiry",
",",
"true",
")",
";",
"}"
] | Verify JWT token format and signature. If ignoreExpiry is true, skip expiry verification, otherwise
verify the expiry before signature verification.
In most cases, we need to verify the expiry of the jwt token. The only time we need to ignore expiry
verification is in SPA middleware handlers which need to verify csrf token in jwt against the csrf
token in the request header to renew the expired token.
@param jwt String of Json web token
@param ignoreExpiry If true, don't verify if the token is expired.
@return JwtClaims object
@throws InvalidJwtException InvalidJwtException
@throws ExpiredTokenException ExpiredTokenException
@deprecated Use verifyToken instead. | [
"Verify",
"JWT",
"token",
"format",
"and",
"signature",
".",
"If",
"ignoreExpiry",
"is",
"true",
"skip",
"expiry",
"verification",
"otherwise",
"verify",
"the",
"expiry",
"before",
"signature",
"verification",
"."
] | train | https://github.com/networknt/light-4j/blob/2a60257c60663684c8f6dc8b5ea3cf184e534db6/security/src/main/java/com/networknt/security/JwtHelper.java#L176-L179 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java | Math.floorDiv | public static int floorDiv(int x, int y) {
"""
Returns the largest (closest to positive infinity)
{@code int} value that is less than or equal to the algebraic quotient.
There is one special case, if the dividend is the
{@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
then integer overflow occurs and
the result is equal to the {@code Integer.MIN_VALUE}.
<p>
Normal integer division operates under the round to zero rounding mode
(truncation). This operation instead acts under the round toward
negative infinity (floor) rounding mode.
The floor rounding mode gives different results than truncation
when the exact result is negative.
<ul>
<li>If the signs of the arguments are the same, the results of
{@code floorDiv} and the {@code /} operator are the same. <br>
For example, {@code floorDiv(4, 3) == 1} and {@code (4 / 3) == 1}.</li>
<li>If the signs of the arguments are different, the quotient is negative and
{@code floorDiv} returns the integer less than or equal to the quotient
and the {@code /} operator returns the integer closest to zero.<br>
For example, {@code floorDiv(-4, 3) == -2},
whereas {@code (-4 / 3) == -1}.
</li>
</ul>
<p>
@param x the dividend
@param y the divisor
@return the largest (closest to positive infinity)
{@code int} value that is less than or equal to the algebraic quotient.
@throws ArithmeticException if the divisor {@code y} is zero
@see #floorMod(int, int)
@see #floor(double)
@since 1.8
"""
int r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
} | java | public static int floorDiv(int x, int y) {
int r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
} | [
"public",
"static",
"int",
"floorDiv",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"int",
"r",
"=",
"x",
"/",
"y",
";",
"// if the signs are different and modulo not zero, round down",
"if",
"(",
"(",
"x",
"^",
"y",
")",
"<",
"0",
"&&",
"(",
"r",
"*",
"y",
"!=",
"x",
")",
")",
"{",
"r",
"--",
";",
"}",
"return",
"r",
";",
"}"
] | Returns the largest (closest to positive infinity)
{@code int} value that is less than or equal to the algebraic quotient.
There is one special case, if the dividend is the
{@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
then integer overflow occurs and
the result is equal to the {@code Integer.MIN_VALUE}.
<p>
Normal integer division operates under the round to zero rounding mode
(truncation). This operation instead acts under the round toward
negative infinity (floor) rounding mode.
The floor rounding mode gives different results than truncation
when the exact result is negative.
<ul>
<li>If the signs of the arguments are the same, the results of
{@code floorDiv} and the {@code /} operator are the same. <br>
For example, {@code floorDiv(4, 3) == 1} and {@code (4 / 3) == 1}.</li>
<li>If the signs of the arguments are different, the quotient is negative and
{@code floorDiv} returns the integer less than or equal to the quotient
and the {@code /} operator returns the integer closest to zero.<br>
For example, {@code floorDiv(-4, 3) == -2},
whereas {@code (-4 / 3) == -1}.
</li>
</ul>
<p>
@param x the dividend
@param y the divisor
@return the largest (closest to positive infinity)
{@code int} value that is less than or equal to the algebraic quotient.
@throws ArithmeticException if the divisor {@code y} is zero
@see #floorMod(int, int)
@see #floor(double)
@since 1.8 | [
"Returns",
"the",
"largest",
"(",
"closest",
"to",
"positive",
"infinity",
")",
"{",
"@code",
"int",
"}",
"value",
"that",
"is",
"less",
"than",
"or",
"equal",
"to",
"the",
"algebraic",
"quotient",
".",
"There",
"is",
"one",
"special",
"case",
"if",
"the",
"dividend",
"is",
"the",
"{",
"@linkplain",
"Integer#MIN_VALUE",
"Integer",
".",
"MIN_VALUE",
"}",
"and",
"the",
"divisor",
"is",
"{",
"@code",
"-",
"1",
"}",
"then",
"integer",
"overflow",
"occurs",
"and",
"the",
"result",
"is",
"equal",
"to",
"the",
"{",
"@code",
"Integer",
".",
"MIN_VALUE",
"}",
".",
"<p",
">",
"Normal",
"integer",
"division",
"operates",
"under",
"the",
"round",
"to",
"zero",
"rounding",
"mode",
"(",
"truncation",
")",
".",
"This",
"operation",
"instead",
"acts",
"under",
"the",
"round",
"toward",
"negative",
"infinity",
"(",
"floor",
")",
"rounding",
"mode",
".",
"The",
"floor",
"rounding",
"mode",
"gives",
"different",
"results",
"than",
"truncation",
"when",
"the",
"exact",
"result",
"is",
"negative",
".",
"<ul",
">",
"<li",
">",
"If",
"the",
"signs",
"of",
"the",
"arguments",
"are",
"the",
"same",
"the",
"results",
"of",
"{",
"@code",
"floorDiv",
"}",
"and",
"the",
"{",
"@code",
"/",
"}",
"operator",
"are",
"the",
"same",
".",
"<br",
">",
"For",
"example",
"{",
"@code",
"floorDiv",
"(",
"4",
"3",
")",
"==",
"1",
"}",
"and",
"{",
"@code",
"(",
"4",
"/",
"3",
")",
"==",
"1",
"}",
".",
"<",
"/",
"li",
">",
"<li",
">",
"If",
"the",
"signs",
"of",
"the",
"arguments",
"are",
"different",
"the",
"quotient",
"is",
"negative",
"and",
"{",
"@code",
"floorDiv",
"}",
"returns",
"the",
"integer",
"less",
"than",
"or",
"equal",
"to",
"the",
"quotient",
"and",
"the",
"{",
"@code",
"/",
"}",
"operator",
"returns",
"the",
"integer",
"closest",
"to",
"zero",
".",
"<br",
">",
"For",
"example",
"{",
"@code",
"floorDiv",
"(",
"-",
"4",
"3",
")",
"==",
"-",
"2",
"}",
"whereas",
"{",
"@code",
"(",
"-",
"4",
"/",
"3",
")",
"==",
"-",
"1",
"}",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">",
"<p",
">"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java#L1056-L1063 |
strator-dev/greenpepper | greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java | BOMUtil.newReader | public static Reader newReader(File file)
throws IOException {
"""
<p>newReader.</p>
@param file a {@link java.io.File} object.
@return a {@link java.io.Reader} object.
@throws java.io.IOException if any.
"""
final String fileEncoding = System.getProperty( "file.encoding", "UTF-8" );
final String greenPepperEncoding = System.getProperty( "greenpepper.file.encoding", fileEncoding );
return newReader( file, greenPepperEncoding );
} | java | public static Reader newReader(File file)
throws IOException
{
final String fileEncoding = System.getProperty( "file.encoding", "UTF-8" );
final String greenPepperEncoding = System.getProperty( "greenpepper.file.encoding", fileEncoding );
return newReader( file, greenPepperEncoding );
} | [
"public",
"static",
"Reader",
"newReader",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"final",
"String",
"fileEncoding",
"=",
"System",
".",
"getProperty",
"(",
"\"file.encoding\"",
",",
"\"UTF-8\"",
")",
";",
"final",
"String",
"greenPepperEncoding",
"=",
"System",
".",
"getProperty",
"(",
"\"greenpepper.file.encoding\"",
",",
"fileEncoding",
")",
";",
"return",
"newReader",
"(",
"file",
",",
"greenPepperEncoding",
")",
";",
"}"
] | <p>newReader.</p>
@param file a {@link java.io.File} object.
@return a {@link java.io.Reader} object.
@throws java.io.IOException if any. | [
"<p",
">",
"newReader",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java#L144-L150 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java | StreamHelper.copyInputStreamToOutputStreamAndCloseOS | @Nonnull
public static ESuccess copyInputStreamToOutputStreamAndCloseOS (@WillClose @Nullable final InputStream aIS,
@WillClose @Nullable final OutputStream aOS) {
"""
Pass the content of the given input stream to the given output stream. Both
the input stream and the output stream are automatically closed.
@param aIS
The input stream to read from. May be <code>null</code>. Automatically
closed!
@param aOS
The output stream to write to. May be <code>null</code>. Automatically
closed!
@return <code>{@link ESuccess#SUCCESS}</code> if copying took place, <code>
{@link ESuccess#FAILURE}</code> otherwise
"""
try
{
return copyInputStreamToOutputStream (aIS, aOS, new byte [DEFAULT_BUFSIZE], (MutableLong) null, (Long) null);
}
finally
{
close (aOS);
}
} | java | @Nonnull
public static ESuccess copyInputStreamToOutputStreamAndCloseOS (@WillClose @Nullable final InputStream aIS,
@WillClose @Nullable final OutputStream aOS)
{
try
{
return copyInputStreamToOutputStream (aIS, aOS, new byte [DEFAULT_BUFSIZE], (MutableLong) null, (Long) null);
}
finally
{
close (aOS);
}
} | [
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"copyInputStreamToOutputStreamAndCloseOS",
"(",
"@",
"WillClose",
"@",
"Nullable",
"final",
"InputStream",
"aIS",
",",
"@",
"WillClose",
"@",
"Nullable",
"final",
"OutputStream",
"aOS",
")",
"{",
"try",
"{",
"return",
"copyInputStreamToOutputStream",
"(",
"aIS",
",",
"aOS",
",",
"new",
"byte",
"[",
"DEFAULT_BUFSIZE",
"]",
",",
"(",
"MutableLong",
")",
"null",
",",
"(",
"Long",
")",
"null",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"aOS",
")",
";",
"}",
"}"
] | Pass the content of the given input stream to the given output stream. Both
the input stream and the output stream are automatically closed.
@param aIS
The input stream to read from. May be <code>null</code>. Automatically
closed!
@param aOS
The output stream to write to. May be <code>null</code>. Automatically
closed!
@return <code>{@link ESuccess#SUCCESS}</code> if copying took place, <code>
{@link ESuccess#FAILURE}</code> otherwise | [
"Pass",
"the",
"content",
"of",
"the",
"given",
"input",
"stream",
"to",
"the",
"given",
"output",
"stream",
".",
"Both",
"the",
"input",
"stream",
"and",
"the",
"output",
"stream",
"are",
"automatically",
"closed",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java#L239-L251 |
zaproxy/zaproxy | src/org/zaproxy/zap/extension/script/ExtensionScript.java | ExtensionScript.getInterfaceWithOutAddOnLoader | public <T> T getInterfaceWithOutAddOnLoader(ScriptWrapper script, Class<T> clasz) throws ScriptException, IOException {
"""
Gets the interface {@code clasz} from the given {@code script}. Might return {@code null} if the {@code script} does not
implement the interface.
<p>
First tries to get the interface directly from the {@code script} by calling the method
{@code ScriptWrapper.getInterface(Class)}, if it returns {@code null} the interface will be extracted from the script
after invoking it, using the method {@code Invocable.getInterface(Class)}.
@param script the script that will be invoked
@param clasz the interface that will be obtained from the script
@return the interface implemented by the script, or {@code null} if the {@code script} does not implement the interface.
@throws ScriptException if the engine of the given {@code script} was not found.
@throws IOException if an error occurred while obtaining the interface directly from the script (
{@code ScriptWrapper.getInterface(Class)})
@see #getInterface(ScriptWrapper, Class)
@see ScriptWrapper#getInterface(Class)
@see Invocable#getInterface(Class)
"""
T iface = script.getInterface(clasz);
if (iface != null) {
// the script wrapper has overriden the usual scripting mechanism
return iface;
}
return invokeScriptWithOutAddOnLoader(script).getInterface(clasz);
} | java | public <T> T getInterfaceWithOutAddOnLoader(ScriptWrapper script, Class<T> clasz) throws ScriptException, IOException {
T iface = script.getInterface(clasz);
if (iface != null) {
// the script wrapper has overriden the usual scripting mechanism
return iface;
}
return invokeScriptWithOutAddOnLoader(script).getInterface(clasz);
} | [
"public",
"<",
"T",
">",
"T",
"getInterfaceWithOutAddOnLoader",
"(",
"ScriptWrapper",
"script",
",",
"Class",
"<",
"T",
">",
"clasz",
")",
"throws",
"ScriptException",
",",
"IOException",
"{",
"T",
"iface",
"=",
"script",
".",
"getInterface",
"(",
"clasz",
")",
";",
"if",
"(",
"iface",
"!=",
"null",
")",
"{",
"// the script wrapper has overriden the usual scripting mechanism\r",
"return",
"iface",
";",
"}",
"return",
"invokeScriptWithOutAddOnLoader",
"(",
"script",
")",
".",
"getInterface",
"(",
"clasz",
")",
";",
"}"
] | Gets the interface {@code clasz} from the given {@code script}. Might return {@code null} if the {@code script} does not
implement the interface.
<p>
First tries to get the interface directly from the {@code script} by calling the method
{@code ScriptWrapper.getInterface(Class)}, if it returns {@code null} the interface will be extracted from the script
after invoking it, using the method {@code Invocable.getInterface(Class)}.
@param script the script that will be invoked
@param clasz the interface that will be obtained from the script
@return the interface implemented by the script, or {@code null} if the {@code script} does not implement the interface.
@throws ScriptException if the engine of the given {@code script} was not found.
@throws IOException if an error occurred while obtaining the interface directly from the script (
{@code ScriptWrapper.getInterface(Class)})
@see #getInterface(ScriptWrapper, Class)
@see ScriptWrapper#getInterface(Class)
@see Invocable#getInterface(Class) | [
"Gets",
"the",
"interface",
"{",
"@code",
"clasz",
"}",
"from",
"the",
"given",
"{",
"@code",
"script",
"}",
".",
"Might",
"return",
"{",
"@code",
"null",
"}",
"if",
"the",
"{",
"@code",
"script",
"}",
"does",
"not",
"implement",
"the",
"interface",
".",
"<p",
">",
"First",
"tries",
"to",
"get",
"the",
"interface",
"directly",
"from",
"the",
"{",
"@code",
"script",
"}",
"by",
"calling",
"the",
"method",
"{",
"@code",
"ScriptWrapper",
".",
"getInterface",
"(",
"Class",
")",
"}",
"if",
"it",
"returns",
"{",
"@code",
"null",
"}",
"the",
"interface",
"will",
"be",
"extracted",
"from",
"the",
"script",
"after",
"invoking",
"it",
"using",
"the",
"method",
"{",
"@code",
"Invocable",
".",
"getInterface",
"(",
"Class",
")",
"}",
"."
] | train | https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/extension/script/ExtensionScript.java#L1751-L1758 |
dropbox/dropbox-sdk-java | src/main/java/com/dropbox/core/v1/DbxClientV1.java | DbxClientV1.getMetadataWithChildrenIfChangedC | public <C> Maybe<DbxEntry./*@Nullable*/WithChildrenC<C>> getMetadataWithChildrenIfChangedC(
String path, boolean includeMediaInfo, /*@Nullable*/String previousFolderHash, Collector<DbxEntry,? extends C> collector)
throws DbxException {
"""
Same as {@link #getMetadataWithChildrenIfChanged} except instead of always returning a list of
{@link DbxEntry} objects, you specify a {@link Collector} that processes the {@link DbxEntry}
objects one by one and aggregates them however you want.
<p>
This allows your to process the {@link DbxEntry} values as they arrive, instead of having to
wait for the entire API call to finish before processing the first one. Be careful, though,
because the API call may fail in the middle (after you've already processed some entries).
Make sure your code can handle that situation. For example, if you're inserting stuff into a
database as they arrive, you might want do everything in a transaction and commit only if
the entire call succeeds.
</p>
"""
return getMetadataWithChildrenIfChangedBase(path, includeMediaInfo, previousFolderHash, new DbxEntry.WithChildrenC.ReaderMaybeDeleted<C>(collector));
} | java | public <C> Maybe<DbxEntry./*@Nullable*/WithChildrenC<C>> getMetadataWithChildrenIfChangedC(
String path, boolean includeMediaInfo, /*@Nullable*/String previousFolderHash, Collector<DbxEntry,? extends C> collector)
throws DbxException
{
return getMetadataWithChildrenIfChangedBase(path, includeMediaInfo, previousFolderHash, new DbxEntry.WithChildrenC.ReaderMaybeDeleted<C>(collector));
} | [
"public",
"<",
"C",
">",
"Maybe",
"<",
"DbxEntry",
".",
"/*@Nullable*/",
"WithChildrenC",
"<",
"C",
">",
">",
"getMetadataWithChildrenIfChangedC",
"(",
"String",
"path",
",",
"boolean",
"includeMediaInfo",
",",
"/*@Nullable*/",
"String",
"previousFolderHash",
",",
"Collector",
"<",
"DbxEntry",
",",
"?",
"extends",
"C",
">",
"collector",
")",
"throws",
"DbxException",
"{",
"return",
"getMetadataWithChildrenIfChangedBase",
"(",
"path",
",",
"includeMediaInfo",
",",
"previousFolderHash",
",",
"new",
"DbxEntry",
".",
"WithChildrenC",
".",
"ReaderMaybeDeleted",
"<",
"C",
">",
"(",
"collector",
")",
")",
";",
"}"
] | Same as {@link #getMetadataWithChildrenIfChanged} except instead of always returning a list of
{@link DbxEntry} objects, you specify a {@link Collector} that processes the {@link DbxEntry}
objects one by one and aggregates them however you want.
<p>
This allows your to process the {@link DbxEntry} values as they arrive, instead of having to
wait for the entire API call to finish before processing the first one. Be careful, though,
because the API call may fail in the middle (after you've already processed some entries).
Make sure your code can handle that situation. For example, if you're inserting stuff into a
database as they arrive, you might want do everything in a transaction and commit only if
the entire call succeeds.
</p> | [
"Same",
"as",
"{",
"@link",
"#getMetadataWithChildrenIfChanged",
"}",
"except",
"instead",
"of",
"always",
"returning",
"a",
"list",
"of",
"{",
"@link",
"DbxEntry",
"}",
"objects",
"you",
"specify",
"a",
"{",
"@link",
"Collector",
"}",
"that",
"processes",
"the",
"{",
"@link",
"DbxEntry",
"}",
"objects",
"one",
"by",
"one",
"and",
"aggregates",
"them",
"however",
"you",
"want",
"."
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/src/main/java/com/dropbox/core/v1/DbxClientV1.java#L294-L299 |
jMetal/jMetal | jmetal-core/src/main/java/org/uma/jmetal/util/AbstractAlgorithmRunner.java | AbstractAlgorithmRunner.printQualityIndicators | public static <S extends Solution<?>> void printQualityIndicators(List<S> population, String paretoFrontFile)
throws FileNotFoundException {
"""
Print all the available quality indicators
@param population
@param paretoFrontFile
@throws FileNotFoundException
"""
Front referenceFront = new ArrayFront(paretoFrontFile);
FrontNormalizer frontNormalizer = new FrontNormalizer(referenceFront) ;
Front normalizedReferenceFront = frontNormalizer.normalize(referenceFront) ;
Front normalizedFront = frontNormalizer.normalize(new ArrayFront(population)) ;
List<PointSolution> normalizedPopulation = FrontUtils
.convertFrontToSolutionList(normalizedFront) ;
String outputString = "\n" ;
outputString += "Hypervolume (N) : " +
new PISAHypervolume<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "Hypervolume : " +
new PISAHypervolume<S>(referenceFront).evaluate(population) + "\n";
outputString += "Epsilon (N) : " +
new Epsilon<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) +
"\n" ;
outputString += "Epsilon : " +
new Epsilon<S>(referenceFront).evaluate(population) + "\n" ;
outputString += "GD (N) : " +
new GenerationalDistance<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "GD : " +
new GenerationalDistance<S>(referenceFront).evaluate(population) + "\n";
outputString += "IGD (N) : " +
new InvertedGenerationalDistance<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString +="IGD : " +
new InvertedGenerationalDistance<S>(referenceFront).evaluate(population) + "\n";
outputString += "IGD+ (N) : " +
new InvertedGenerationalDistancePlus<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "IGD+ : " +
new InvertedGenerationalDistancePlus<S>(referenceFront).evaluate(population) + "\n";
outputString += "Spread (N) : " +
new Spread<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "Spread : " +
new Spread<S>(referenceFront).evaluate(population) + "\n";
// outputString += "R2 (N) : " +
// new R2<List<DoubleSolution>>(normalizedReferenceFront).runAlgorithm(normalizedPopulation) + "\n";
// outputString += "R2 : " +
// new R2<List<? extends Solution<?>>>(referenceFront).runAlgorithm(population) + "\n";
outputString += "Error ratio : " +
new ErrorRatio<List<? extends Solution<?>>>(referenceFront).evaluate(population) + "\n";
JMetalLogger.logger.info(outputString);
} | java | public static <S extends Solution<?>> void printQualityIndicators(List<S> population, String paretoFrontFile)
throws FileNotFoundException {
Front referenceFront = new ArrayFront(paretoFrontFile);
FrontNormalizer frontNormalizer = new FrontNormalizer(referenceFront) ;
Front normalizedReferenceFront = frontNormalizer.normalize(referenceFront) ;
Front normalizedFront = frontNormalizer.normalize(new ArrayFront(population)) ;
List<PointSolution> normalizedPopulation = FrontUtils
.convertFrontToSolutionList(normalizedFront) ;
String outputString = "\n" ;
outputString += "Hypervolume (N) : " +
new PISAHypervolume<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "Hypervolume : " +
new PISAHypervolume<S>(referenceFront).evaluate(population) + "\n";
outputString += "Epsilon (N) : " +
new Epsilon<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) +
"\n" ;
outputString += "Epsilon : " +
new Epsilon<S>(referenceFront).evaluate(population) + "\n" ;
outputString += "GD (N) : " +
new GenerationalDistance<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "GD : " +
new GenerationalDistance<S>(referenceFront).evaluate(population) + "\n";
outputString += "IGD (N) : " +
new InvertedGenerationalDistance<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString +="IGD : " +
new InvertedGenerationalDistance<S>(referenceFront).evaluate(population) + "\n";
outputString += "IGD+ (N) : " +
new InvertedGenerationalDistancePlus<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "IGD+ : " +
new InvertedGenerationalDistancePlus<S>(referenceFront).evaluate(population) + "\n";
outputString += "Spread (N) : " +
new Spread<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
outputString += "Spread : " +
new Spread<S>(referenceFront).evaluate(population) + "\n";
// outputString += "R2 (N) : " +
// new R2<List<DoubleSolution>>(normalizedReferenceFront).runAlgorithm(normalizedPopulation) + "\n";
// outputString += "R2 : " +
// new R2<List<? extends Solution<?>>>(referenceFront).runAlgorithm(population) + "\n";
outputString += "Error ratio : " +
new ErrorRatio<List<? extends Solution<?>>>(referenceFront).evaluate(population) + "\n";
JMetalLogger.logger.info(outputString);
} | [
"public",
"static",
"<",
"S",
"extends",
"Solution",
"<",
"?",
">",
">",
"void",
"printQualityIndicators",
"(",
"List",
"<",
"S",
">",
"population",
",",
"String",
"paretoFrontFile",
")",
"throws",
"FileNotFoundException",
"{",
"Front",
"referenceFront",
"=",
"new",
"ArrayFront",
"(",
"paretoFrontFile",
")",
";",
"FrontNormalizer",
"frontNormalizer",
"=",
"new",
"FrontNormalizer",
"(",
"referenceFront",
")",
";",
"Front",
"normalizedReferenceFront",
"=",
"frontNormalizer",
".",
"normalize",
"(",
"referenceFront",
")",
";",
"Front",
"normalizedFront",
"=",
"frontNormalizer",
".",
"normalize",
"(",
"new",
"ArrayFront",
"(",
"population",
")",
")",
";",
"List",
"<",
"PointSolution",
">",
"normalizedPopulation",
"=",
"FrontUtils",
".",
"convertFrontToSolutionList",
"(",
"normalizedFront",
")",
";",
"String",
"outputString",
"=",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Hypervolume (N) : \"",
"+",
"new",
"PISAHypervolume",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Hypervolume : \"",
"+",
"new",
"PISAHypervolume",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Epsilon (N) : \"",
"+",
"new",
"Epsilon",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Epsilon : \"",
"+",
"new",
"Epsilon",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"GD (N) : \"",
"+",
"new",
"GenerationalDistance",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"GD : \"",
"+",
"new",
"GenerationalDistance",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"IGD (N) : \"",
"+",
"new",
"InvertedGenerationalDistance",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"IGD : \"",
"+",
"new",
"InvertedGenerationalDistance",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"IGD+ (N) : \"",
"+",
"new",
"InvertedGenerationalDistancePlus",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"IGD+ : \"",
"+",
"new",
"InvertedGenerationalDistancePlus",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Spread (N) : \"",
"+",
"new",
"Spread",
"<",
"PointSolution",
">",
"(",
"normalizedReferenceFront",
")",
".",
"evaluate",
"(",
"normalizedPopulation",
")",
"+",
"\"\\n\"",
";",
"outputString",
"+=",
"\"Spread : \"",
"+",
"new",
"Spread",
"<",
"S",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"// outputString += \"R2 (N) : \" +",
"// new R2<List<DoubleSolution>>(normalizedReferenceFront).runAlgorithm(normalizedPopulation) + \"\\n\";",
"// outputString += \"R2 : \" +",
"// new R2<List<? extends Solution<?>>>(referenceFront).runAlgorithm(population) + \"\\n\";",
"outputString",
"+=",
"\"Error ratio : \"",
"+",
"new",
"ErrorRatio",
"<",
"List",
"<",
"?",
"extends",
"Solution",
"<",
"?",
">",
">",
">",
"(",
"referenceFront",
")",
".",
"evaluate",
"(",
"population",
")",
"+",
"\"\\n\"",
";",
"JMetalLogger",
".",
"logger",
".",
"info",
"(",
"outputString",
")",
";",
"}"
] | Print all the available quality indicators
@param population
@param paretoFrontFile
@throws FileNotFoundException | [
"Print",
"all",
"the",
"available",
"quality",
"indicators"
] | train | https://github.com/jMetal/jMetal/blob/bc981e6aede275d26c5216c9a01227d9675b0cf7/jmetal-core/src/main/java/org/uma/jmetal/util/AbstractAlgorithmRunner.java#L47-L91 |
darrachequesne/spring-data-jpa-datatables | src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java | DataTablesInput.addColumn | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
"""
Add a new column
@param columnName the name of the column
@param searchable whether the column is searchable or not
@param orderable whether the column is orderable or not
@param searchValue if any, the search value to apply
"""
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | java | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | [
"public",
"void",
"addColumn",
"(",
"String",
"columnName",
",",
"boolean",
"searchable",
",",
"boolean",
"orderable",
",",
"String",
"searchValue",
")",
"{",
"this",
".",
"columns",
".",
"add",
"(",
"new",
"Column",
"(",
"columnName",
",",
"\"\"",
",",
"searchable",
",",
"orderable",
",",
"new",
"Search",
"(",
"searchValue",
",",
"false",
")",
")",
")",
";",
"}"
] | Add a new column
@param columnName the name of the column
@param searchable whether the column is searchable or not
@param orderable whether the column is orderable or not
@param searchValue if any, the search value to apply | [
"Add",
"a",
"new",
"column"
] | train | https://github.com/darrachequesne/spring-data-jpa-datatables/blob/0174dec8f52595a8e4b79f32c79922d64b02b732/src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java#L100-L104 |
meertensinstituut/mtas | src/main/java/mtas/codec/util/CodecInfo.java | CodecInfo.getDoc | public IndexDoc getDoc(String field, int docId) {
"""
Gets the doc.
@param field
the field
@param docId
the doc id
@return the doc
"""
if (fieldReferences.containsKey(field)) {
FieldReferences fr = fieldReferences.get(field);
try {
IndexInput inIndexDocId = indexInputList.get("indexDocId");
ArrayList<MtasTreeHit<?>> list = CodecSearchTree.searchMtasTree(docId,
inIndexDocId, fr.refIndexDocId, fr.refIndexDoc);
if (list.size() == 1) {
return new IndexDoc(list.get(0).ref);
}
} catch (IOException e) {
log.debug(e);
return null;
}
}
return null;
} | java | public IndexDoc getDoc(String field, int docId) {
if (fieldReferences.containsKey(field)) {
FieldReferences fr = fieldReferences.get(field);
try {
IndexInput inIndexDocId = indexInputList.get("indexDocId");
ArrayList<MtasTreeHit<?>> list = CodecSearchTree.searchMtasTree(docId,
inIndexDocId, fr.refIndexDocId, fr.refIndexDoc);
if (list.size() == 1) {
return new IndexDoc(list.get(0).ref);
}
} catch (IOException e) {
log.debug(e);
return null;
}
}
return null;
} | [
"public",
"IndexDoc",
"getDoc",
"(",
"String",
"field",
",",
"int",
"docId",
")",
"{",
"if",
"(",
"fieldReferences",
".",
"containsKey",
"(",
"field",
")",
")",
"{",
"FieldReferences",
"fr",
"=",
"fieldReferences",
".",
"get",
"(",
"field",
")",
";",
"try",
"{",
"IndexInput",
"inIndexDocId",
"=",
"indexInputList",
".",
"get",
"(",
"\"indexDocId\"",
")",
";",
"ArrayList",
"<",
"MtasTreeHit",
"<",
"?",
">",
">",
"list",
"=",
"CodecSearchTree",
".",
"searchMtasTree",
"(",
"docId",
",",
"inIndexDocId",
",",
"fr",
".",
"refIndexDocId",
",",
"fr",
".",
"refIndexDoc",
")",
";",
"if",
"(",
"list",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"new",
"IndexDoc",
"(",
"list",
".",
"get",
"(",
"0",
")",
".",
"ref",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"e",
")",
";",
"return",
"null",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Gets the doc.
@param field
the field
@param docId
the doc id
@return the doc | [
"Gets",
"the",
"doc",
"."
] | train | https://github.com/meertensinstituut/mtas/blob/f02ae730848616bd88b553efa7f9eddc32818e64/src/main/java/mtas/codec/util/CodecInfo.java#L566-L582 |
johnkil/Android-ProgressFragment | progressfragment-native/src/com/devspark/progressfragment/ProgressGridFragment.java | ProgressGridFragment.setGridShown | private void setGridShown(boolean shown, boolean animate) {
"""
Control whether the grid is being displayed. You can make it not
displayed if you are waiting for the initial data to show in it. During
this time an indeterminant progress indicator will be shown instead.
@param shown If true, the grid view is shown; if false, the progress
indicator. The initial value is true.
@param animate If true, an animation will be used to transition to the
new state.
"""
ensureList();
if (mProgressContainer == null) {
throw new IllegalStateException("Can't be used with a custom content view");
}
if (mGridShown == shown) {
return;
}
mGridShown = shown;
if (shown) {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_out));
mGridContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_in));
} else {
mProgressContainer.clearAnimation();
mGridContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.GONE);
mGridContainer.setVisibility(View.VISIBLE);
} else {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_in));
mGridContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_out));
} else {
mProgressContainer.clearAnimation();
mGridContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.VISIBLE);
mGridContainer.setVisibility(View.GONE);
}
} | java | private void setGridShown(boolean shown, boolean animate) {
ensureList();
if (mProgressContainer == null) {
throw new IllegalStateException("Can't be used with a custom content view");
}
if (mGridShown == shown) {
return;
}
mGridShown = shown;
if (shown) {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_out));
mGridContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_in));
} else {
mProgressContainer.clearAnimation();
mGridContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.GONE);
mGridContainer.setVisibility(View.VISIBLE);
} else {
if (animate) {
mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_in));
mGridContainer.startAnimation(AnimationUtils.loadAnimation(
getActivity(), android.R.anim.fade_out));
} else {
mProgressContainer.clearAnimation();
mGridContainer.clearAnimation();
}
mProgressContainer.setVisibility(View.VISIBLE);
mGridContainer.setVisibility(View.GONE);
}
} | [
"private",
"void",
"setGridShown",
"(",
"boolean",
"shown",
",",
"boolean",
"animate",
")",
"{",
"ensureList",
"(",
")",
";",
"if",
"(",
"mProgressContainer",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Can't be used with a custom content view\"",
")",
";",
"}",
"if",
"(",
"mGridShown",
"==",
"shown",
")",
"{",
"return",
";",
"}",
"mGridShown",
"=",
"shown",
";",
"if",
"(",
"shown",
")",
"{",
"if",
"(",
"animate",
")",
"{",
"mProgressContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_out",
")",
")",
";",
"mGridContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_in",
")",
")",
";",
"}",
"else",
"{",
"mProgressContainer",
".",
"clearAnimation",
"(",
")",
";",
"mGridContainer",
".",
"clearAnimation",
"(",
")",
";",
"}",
"mProgressContainer",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"mGridContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"}",
"else",
"{",
"if",
"(",
"animate",
")",
"{",
"mProgressContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_in",
")",
")",
";",
"mGridContainer",
".",
"startAnimation",
"(",
"AnimationUtils",
".",
"loadAnimation",
"(",
"getActivity",
"(",
")",
",",
"android",
".",
"R",
".",
"anim",
".",
"fade_out",
")",
")",
";",
"}",
"else",
"{",
"mProgressContainer",
".",
"clearAnimation",
"(",
")",
";",
"mGridContainer",
".",
"clearAnimation",
"(",
")",
";",
"}",
"mProgressContainer",
".",
"setVisibility",
"(",
"View",
".",
"VISIBLE",
")",
";",
"mGridContainer",
".",
"setVisibility",
"(",
"View",
".",
"GONE",
")",
";",
"}",
"}"
] | Control whether the grid is being displayed. You can make it not
displayed if you are waiting for the initial data to show in it. During
this time an indeterminant progress indicator will be shown instead.
@param shown If true, the grid view is shown; if false, the progress
indicator. The initial value is true.
@param animate If true, an animation will be used to transition to the
new state. | [
"Control",
"whether",
"the",
"grid",
"is",
"being",
"displayed",
".",
"You",
"can",
"make",
"it",
"not",
"displayed",
"if",
"you",
"are",
"waiting",
"for",
"the",
"initial",
"data",
"to",
"show",
"in",
"it",
".",
"During",
"this",
"time",
"an",
"indeterminant",
"progress",
"indicator",
"will",
"be",
"shown",
"instead",
"."
] | train | https://github.com/johnkil/Android-ProgressFragment/blob/f4b3b969f36f3ac9598c662722630f9ffb151bd6/progressfragment-native/src/com/devspark/progressfragment/ProgressGridFragment.java#L221-L255 |
rometools/rome | rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java | MediaModuleGenerator.generatePeerLinks | private void generatePeerLinks(final Metadata m, final Element e) {
"""
Generation of peerLink tags.
@param m source
@param e element to attach new element to
"""
for (final PeerLink peerLink : m.getPeerLinks()) {
final Element peerLinkElement = new Element("peerLink", NS);
addNotNullAttribute(peerLinkElement, "type", peerLink.getType());
addNotNullAttribute(peerLinkElement, "href", peerLink.getHref());
if (peerLinkElement.hasAttributes()) {
e.addContent(peerLinkElement);
}
}
} | java | private void generatePeerLinks(final Metadata m, final Element e) {
for (final PeerLink peerLink : m.getPeerLinks()) {
final Element peerLinkElement = new Element("peerLink", NS);
addNotNullAttribute(peerLinkElement, "type", peerLink.getType());
addNotNullAttribute(peerLinkElement, "href", peerLink.getHref());
if (peerLinkElement.hasAttributes()) {
e.addContent(peerLinkElement);
}
}
} | [
"private",
"void",
"generatePeerLinks",
"(",
"final",
"Metadata",
"m",
",",
"final",
"Element",
"e",
")",
"{",
"for",
"(",
"final",
"PeerLink",
"peerLink",
":",
"m",
".",
"getPeerLinks",
"(",
")",
")",
"{",
"final",
"Element",
"peerLinkElement",
"=",
"new",
"Element",
"(",
"\"peerLink\"",
",",
"NS",
")",
";",
"addNotNullAttribute",
"(",
"peerLinkElement",
",",
"\"type\"",
",",
"peerLink",
".",
"getType",
"(",
")",
")",
";",
"addNotNullAttribute",
"(",
"peerLinkElement",
",",
"\"href\"",
",",
"peerLink",
".",
"getHref",
"(",
")",
")",
";",
"if",
"(",
"peerLinkElement",
".",
"hasAttributes",
"(",
")",
")",
"{",
"e",
".",
"addContent",
"(",
"peerLinkElement",
")",
";",
"}",
"}",
"}"
] | Generation of peerLink tags.
@param m source
@param e element to attach new element to | [
"Generation",
"of",
"peerLink",
"tags",
"."
] | train | https://github.com/rometools/rome/blob/5fcf0b1a9a6cdedbe253a45ad9468c54a0f97010/rome-modules/src/main/java/com/rometools/modules/mediarss/io/MediaModuleGenerator.java#L414-L423 |
graphql-java/graphql-java | src/main/java/graphql/language/NodeTraverser.java | NodeTraverser.preOrder | public Object preOrder(NodeVisitor nodeVisitor, Node root) {
"""
Version of {@link #preOrder(NodeVisitor, Collection)} with one root.
@param nodeVisitor the visitor of the nodes
@param root the root node
@return the accumulation result of this traversal
"""
return preOrder(nodeVisitor, Collections.singleton(root));
} | java | public Object preOrder(NodeVisitor nodeVisitor, Node root) {
return preOrder(nodeVisitor, Collections.singleton(root));
} | [
"public",
"Object",
"preOrder",
"(",
"NodeVisitor",
"nodeVisitor",
",",
"Node",
"root",
")",
"{",
"return",
"preOrder",
"(",
"nodeVisitor",
",",
"Collections",
".",
"singleton",
"(",
"root",
")",
")",
";",
"}"
] | Version of {@link #preOrder(NodeVisitor, Collection)} with one root.
@param nodeVisitor the visitor of the nodes
@param root the root node
@return the accumulation result of this traversal | [
"Version",
"of",
"{",
"@link",
"#preOrder",
"(",
"NodeVisitor",
"Collection",
")",
"}",
"with",
"one",
"root",
"."
] | train | https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/language/NodeTraverser.java#L90-L92 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.updateCertificateAsync | public Observable<CertificateBundle> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) {
"""
Updates the specified attributes associated with the given certificate.
The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated are the certificate's attributes. This operation requires the certificates/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate in the given key vault.
@param certificateVersion The version of the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateBundle object
"""
return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1<ServiceResponse<CertificateBundle>, CertificateBundle>() {
@Override
public CertificateBundle call(ServiceResponse<CertificateBundle> response) {
return response.body();
}
});
} | java | public Observable<CertificateBundle> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) {
return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1<ServiceResponse<CertificateBundle>, CertificateBundle>() {
@Override
public CertificateBundle call(ServiceResponse<CertificateBundle> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"CertificateBundle",
">",
"updateCertificateAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"certificateName",
",",
"String",
"certificateVersion",
")",
"{",
"return",
"updateCertificateWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"certificateName",
",",
"certificateVersion",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"CertificateBundle",
">",
",",
"CertificateBundle",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CertificateBundle",
"call",
"(",
"ServiceResponse",
"<",
"CertificateBundle",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates the specified attributes associated with the given certificate.
The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated are the certificate's attributes. This operation requires the certificates/update permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param certificateName The name of the certificate in the given key vault.
@param certificateVersion The version of the certificate.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CertificateBundle object | [
"Updates",
"the",
"specified",
"attributes",
"associated",
"with",
"the",
"given",
"certificate",
".",
"The",
"UpdateCertificate",
"operation",
"applies",
"the",
"specified",
"update",
"on",
"the",
"given",
"certificate",
";",
"the",
"only",
"elements",
"updated",
"are",
"the",
"certificate",
"s",
"attributes",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"update",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L7366-L7373 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java | StreamHelper.copyReaderToWriter | @Nonnull
public static ESuccess copyReaderToWriter (@WillClose @Nullable final Reader aReader,
@WillNotClose @Nullable final Writer aWriter) {
"""
Pass the content of the given reader to the given writer. The reader is
automatically closed, whereas the writer stays open!
@param aReader
The reader to read from. May be <code>null</code>. Automatically
closed!
@param aWriter
The writer to write to. May be <code>null</code>. Not automatically
closed!
@return <code>{@link ESuccess#SUCCESS}</code> if copying took place, <code>
{@link ESuccess#FAILURE}</code> otherwise
"""
return copyReaderToWriter (aReader, aWriter, new char [DEFAULT_BUFSIZE], (MutableLong) null, (Long) null);
} | java | @Nonnull
public static ESuccess copyReaderToWriter (@WillClose @Nullable final Reader aReader,
@WillNotClose @Nullable final Writer aWriter)
{
return copyReaderToWriter (aReader, aWriter, new char [DEFAULT_BUFSIZE], (MutableLong) null, (Long) null);
} | [
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"copyReaderToWriter",
"(",
"@",
"WillClose",
"@",
"Nullable",
"final",
"Reader",
"aReader",
",",
"@",
"WillNotClose",
"@",
"Nullable",
"final",
"Writer",
"aWriter",
")",
"{",
"return",
"copyReaderToWriter",
"(",
"aReader",
",",
"aWriter",
",",
"new",
"char",
"[",
"DEFAULT_BUFSIZE",
"]",
",",
"(",
"MutableLong",
")",
"null",
",",
"(",
"Long",
")",
"null",
")",
";",
"}"
] | Pass the content of the given reader to the given writer. The reader is
automatically closed, whereas the writer stays open!
@param aReader
The reader to read from. May be <code>null</code>. Automatically
closed!
@param aWriter
The writer to write to. May be <code>null</code>. Not automatically
closed!
@return <code>{@link ESuccess#SUCCESS}</code> if copying took place, <code>
{@link ESuccess#FAILURE}</code> otherwise | [
"Pass",
"the",
"content",
"of",
"the",
"given",
"reader",
"to",
"the",
"given",
"writer",
".",
"The",
"reader",
"is",
"automatically",
"closed",
"whereas",
"the",
"writer",
"stays",
"open!"
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/stream/StreamHelper.java#L738-L743 |
Whiley/WhileyCompiler | src/main/java/wyc/io/WhileyFileParser.java | WhileyFileParser.parseWhileStatement | private Stmt parseWhileStatement(EnclosingScope scope) {
"""
Parse a while statement, which has the form:
<pre>
WhileStmt ::= "while" Expr ("where" Expr)* ':' NewLine Block
</pre>
@see wyc.lang.Stmt.While
@param scope
The enclosing scope for this statement, which determines the
set of visible (i.e. declared) variables and also the current
indentation level.
@return
@author David J. Pearce
"""
int start = index;
match(While);
// NOTE: expression terminated by ':'
Expr condition = parseLogicalExpression(scope, true);
// Parse the loop invariants
Tuple<Expr> invariants = parseInvariant(scope,Where);
match(Colon);
int end = index;
matchEndLine();
Stmt.Block blk = parseBlock(scope, true);
return annotateSourceLocation(new Stmt.While(condition, invariants, new Tuple<>(), blk), start, end-1);
} | java | private Stmt parseWhileStatement(EnclosingScope scope) {
int start = index;
match(While);
// NOTE: expression terminated by ':'
Expr condition = parseLogicalExpression(scope, true);
// Parse the loop invariants
Tuple<Expr> invariants = parseInvariant(scope,Where);
match(Colon);
int end = index;
matchEndLine();
Stmt.Block blk = parseBlock(scope, true);
return annotateSourceLocation(new Stmt.While(condition, invariants, new Tuple<>(), blk), start, end-1);
} | [
"private",
"Stmt",
"parseWhileStatement",
"(",
"EnclosingScope",
"scope",
")",
"{",
"int",
"start",
"=",
"index",
";",
"match",
"(",
"While",
")",
";",
"// NOTE: expression terminated by ':'",
"Expr",
"condition",
"=",
"parseLogicalExpression",
"(",
"scope",
",",
"true",
")",
";",
"// Parse the loop invariants",
"Tuple",
"<",
"Expr",
">",
"invariants",
"=",
"parseInvariant",
"(",
"scope",
",",
"Where",
")",
";",
"match",
"(",
"Colon",
")",
";",
"int",
"end",
"=",
"index",
";",
"matchEndLine",
"(",
")",
";",
"Stmt",
".",
"Block",
"blk",
"=",
"parseBlock",
"(",
"scope",
",",
"true",
")",
";",
"return",
"annotateSourceLocation",
"(",
"new",
"Stmt",
".",
"While",
"(",
"condition",
",",
"invariants",
",",
"new",
"Tuple",
"<>",
"(",
")",
",",
"blk",
")",
",",
"start",
",",
"end",
"-",
"1",
")",
";",
"}"
] | Parse a while statement, which has the form:
<pre>
WhileStmt ::= "while" Expr ("where" Expr)* ':' NewLine Block
</pre>
@see wyc.lang.Stmt.While
@param scope
The enclosing scope for this statement, which determines the
set of visible (i.e. declared) variables and also the current
indentation level.
@return
@author David J. Pearce | [
"Parse",
"a",
"while",
"statement",
"which",
"has",
"the",
"form",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L1181-L1193 |
UrielCh/ovh-java-sdk | ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java | ApiOvhXdsl.spare_spare_GET | public OvhXdslSpare spare_spare_GET(String spare) throws IOException {
"""
Get this object properties
REST: GET /xdsl/spare/{spare}
@param spare [required] The internal name of your spare
"""
String qPath = "/xdsl/spare/{spare}";
StringBuilder sb = path(qPath, spare);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhXdslSpare.class);
} | java | public OvhXdslSpare spare_spare_GET(String spare) throws IOException {
String qPath = "/xdsl/spare/{spare}";
StringBuilder sb = path(qPath, spare);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhXdslSpare.class);
} | [
"public",
"OvhXdslSpare",
"spare_spare_GET",
"(",
"String",
"spare",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/xdsl/spare/{spare}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"spare",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhXdslSpare",
".",
"class",
")",
";",
"}"
] | Get this object properties
REST: GET /xdsl/spare/{spare}
@param spare [required] The internal name of your spare | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-xdsl/src/main/java/net/minidev/ovh/api/ApiOvhXdsl.java#L2083-L2088 |
antopen/alipay-sdk-java | src/main/java/com/alipay/api/internal/util/AtsUtils.java | AtsUtils.ungzip | public static File ungzip(File gzip, File toDir) throws IOException {
"""
解压gzip文件到指定的目录,目前只能解压gzip包里面只包含一个文件的压缩包。
@param gzip 需要解压的gzip文件
@param toDir 需要解压到的目录
@return 解压后的文件
@throws IOException
"""
toDir.mkdirs();
File out = new File(toDir, gzip.getName());
GZIPInputStream gin = null;
FileOutputStream fout = null;
try {
FileInputStream fin = new FileInputStream(gzip);
gin = new GZIPInputStream(fin);
fout = new FileOutputStream(out);
copy(gin, fout);
gin.close();
fout.close();
} finally {
closeQuietly(gin);
closeQuietly(fout);
}
return out;
} | java | public static File ungzip(File gzip, File toDir) throws IOException {
toDir.mkdirs();
File out = new File(toDir, gzip.getName());
GZIPInputStream gin = null;
FileOutputStream fout = null;
try {
FileInputStream fin = new FileInputStream(gzip);
gin = new GZIPInputStream(fin);
fout = new FileOutputStream(out);
copy(gin, fout);
gin.close();
fout.close();
} finally {
closeQuietly(gin);
closeQuietly(fout);
}
return out;
} | [
"public",
"static",
"File",
"ungzip",
"(",
"File",
"gzip",
",",
"File",
"toDir",
")",
"throws",
"IOException",
"{",
"toDir",
".",
"mkdirs",
"(",
")",
";",
"File",
"out",
"=",
"new",
"File",
"(",
"toDir",
",",
"gzip",
".",
"getName",
"(",
")",
")",
";",
"GZIPInputStream",
"gin",
"=",
"null",
";",
"FileOutputStream",
"fout",
"=",
"null",
";",
"try",
"{",
"FileInputStream",
"fin",
"=",
"new",
"FileInputStream",
"(",
"gzip",
")",
";",
"gin",
"=",
"new",
"GZIPInputStream",
"(",
"fin",
")",
";",
"fout",
"=",
"new",
"FileOutputStream",
"(",
"out",
")",
";",
"copy",
"(",
"gin",
",",
"fout",
")",
";",
"gin",
".",
"close",
"(",
")",
";",
"fout",
".",
"close",
"(",
")",
";",
"}",
"finally",
"{",
"closeQuietly",
"(",
"gin",
")",
";",
"closeQuietly",
"(",
"fout",
")",
";",
"}",
"return",
"out",
";",
"}"
] | 解压gzip文件到指定的目录,目前只能解压gzip包里面只包含一个文件的压缩包。
@param gzip 需要解压的gzip文件
@param toDir 需要解压到的目录
@return 解压后的文件
@throws IOException | [
"解压gzip文件到指定的目录,目前只能解压gzip包里面只包含一个文件的压缩包。"
] | train | https://github.com/antopen/alipay-sdk-java/blob/e82aeac7d0239330ee173c7e393596e51e41c1cd/src/main/java/com/alipay/api/internal/util/AtsUtils.java#L46-L63 |
stephanrauh/AngularFaces | AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/components/puiupdateModelAfterAJAXRequest/PuiUpdateModelAfterAJAXRequestRenderer.java | PuiUpdateModelAfterAJAXRequestRenderer.encodeBegin | @Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
"""
private static final Logger LOGGER = Logger.getLogger("de.beyondjava.angularFaces.components.puiupdateModelAfterAJAXRequest.puiUpdateModelAfterAJAXRequestRenderer");
"""
if (FacesContext.getCurrentInstance().isPostback()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeText("\n", null);
writer.startElement("script", component);
writer.write("if (window.jsfScope) {\n");
List<String> beansAsJSon = PuiModelSync.getFacesModel();
for (String bean : beansAsJSon) {
writer.write("puiUpdateModel(" + bean + ");");
}
writer.writeText("\n}", null);
writer.endElement("script");
}
} | java | @Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (FacesContext.getCurrentInstance().isPostback()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeText("\n", null);
writer.startElement("script", component);
writer.write("if (window.jsfScope) {\n");
List<String> beansAsJSon = PuiModelSync.getFacesModel();
for (String bean : beansAsJSon) {
writer.write("puiUpdateModel(" + bean + ");");
}
writer.writeText("\n}", null);
writer.endElement("script");
}
} | [
"@",
"Override",
"public",
"void",
"encodeBegin",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
".",
"isPostback",
"(",
")",
")",
"{",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"writeText",
"(",
"\"\\n\"",
",",
"null",
")",
";",
"writer",
".",
"startElement",
"(",
"\"script\"",
",",
"component",
")",
";",
"writer",
".",
"write",
"(",
"\"if (window.jsfScope) {\\n\"",
")",
";",
"List",
"<",
"String",
">",
"beansAsJSon",
"=",
"PuiModelSync",
".",
"getFacesModel",
"(",
")",
";",
"for",
"(",
"String",
"bean",
":",
"beansAsJSon",
")",
"{",
"writer",
".",
"write",
"(",
"\"puiUpdateModel(\"",
"+",
"bean",
"+",
"\");\"",
")",
";",
"}",
"writer",
".",
"writeText",
"(",
"\"\\n}\"",
",",
"null",
")",
";",
"writer",
".",
"endElement",
"(",
"\"script\"",
")",
";",
"}",
"}"
] | private static final Logger LOGGER = Logger.getLogger("de.beyondjava.angularFaces.components.puiupdateModelAfterAJAXRequest.puiUpdateModelAfterAJAXRequestRenderer"); | [
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"Logger",
".",
"getLogger",
"(",
"de",
".",
"beyondjava",
".",
"angularFaces",
".",
"components",
".",
"puiupdateModelAfterAJAXRequest",
".",
"puiUpdateModelAfterAJAXRequestRenderer",
")",
";"
] | train | https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/components/puiupdateModelAfterAJAXRequest/PuiUpdateModelAfterAJAXRequestRenderer.java#L37-L51 |
lotaris/jee-validation | src/main/java/com/lotaris/jee/validation/AbstractPatchTransferObject.java | AbstractPatchTransferObject.markPropertyAsSet | public <T> T markPropertyAsSet(String property, T value) {
"""
Marks the specified property as set and returns the value given as the second argument. This
is meant to be used as a one-liner.
<p><pre>
public void setFirstName(String firstName) {
this.firstName = markPropertyAsSet(FIRST_NAME, firstName);
}
</pre></p>
@param <T> the type of value
@param property the property to mark as set
@param value the value to return
@return the value
"""
setProperties.add(property);
return value;
} | java | public <T> T markPropertyAsSet(String property, T value) {
setProperties.add(property);
return value;
} | [
"public",
"<",
"T",
">",
"T",
"markPropertyAsSet",
"(",
"String",
"property",
",",
"T",
"value",
")",
"{",
"setProperties",
".",
"add",
"(",
"property",
")",
";",
"return",
"value",
";",
"}"
] | Marks the specified property as set and returns the value given as the second argument. This
is meant to be used as a one-liner.
<p><pre>
public void setFirstName(String firstName) {
this.firstName = markPropertyAsSet(FIRST_NAME, firstName);
}
</pre></p>
@param <T> the type of value
@param property the property to mark as set
@param value the value to return
@return the value | [
"Marks",
"the",
"specified",
"property",
"as",
"set",
"and",
"returns",
"the",
"value",
"given",
"as",
"the",
"second",
"argument",
".",
"This",
"is",
"meant",
"to",
"be",
"used",
"as",
"a",
"one",
"-",
"liner",
"."
] | train | https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/AbstractPatchTransferObject.java#L71-L74 |
apache/spark | common/network-shuffle/src/main/java/org/apache/spark/network/sasl/ShuffleSecretManager.java | ShuffleSecretManager.registerApp | public void registerApp(String appId, String shuffleSecret) {
"""
Register an application with its secret.
Executors need to first authenticate themselves with the same secret before
fetching shuffle files written by other executors in this application.
"""
// Always put the new secret information to make sure it's the most up to date.
// Otherwise we have to specifically look at the application attempt in addition
// to the applicationId since the secrets change between application attempts on yarn.
shuffleSecretMap.put(appId, shuffleSecret);
logger.info("Registered shuffle secret for application {}", appId);
} | java | public void registerApp(String appId, String shuffleSecret) {
// Always put the new secret information to make sure it's the most up to date.
// Otherwise we have to specifically look at the application attempt in addition
// to the applicationId since the secrets change between application attempts on yarn.
shuffleSecretMap.put(appId, shuffleSecret);
logger.info("Registered shuffle secret for application {}", appId);
} | [
"public",
"void",
"registerApp",
"(",
"String",
"appId",
",",
"String",
"shuffleSecret",
")",
"{",
"// Always put the new secret information to make sure it's the most up to date.",
"// Otherwise we have to specifically look at the application attempt in addition",
"// to the applicationId since the secrets change between application attempts on yarn.",
"shuffleSecretMap",
".",
"put",
"(",
"appId",
",",
"shuffleSecret",
")",
";",
"logger",
".",
"info",
"(",
"\"Registered shuffle secret for application {}\"",
",",
"appId",
")",
";",
"}"
] | Register an application with its secret.
Executors need to first authenticate themselves with the same secret before
fetching shuffle files written by other executors in this application. | [
"Register",
"an",
"application",
"with",
"its",
"secret",
".",
"Executors",
"need",
"to",
"first",
"authenticate",
"themselves",
"with",
"the",
"same",
"secret",
"before",
"fetching",
"shuffle",
"files",
"written",
"by",
"other",
"executors",
"in",
"this",
"application",
"."
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/common/network-shuffle/src/main/java/org/apache/spark/network/sasl/ShuffleSecretManager.java#L49-L55 |
pushtorefresh/storio | storio-common/src/main/java/com/pushtorefresh/storio3/internal/Checks.java | Checks.checkNotNull | public static void checkNotNull(@Nullable Object object, @NonNull String message) {
"""
Checks that passed reference is not null,
throws {@link NullPointerException} with passed message if reference is null
@param object to check
@param message exception message if object is null
"""
if (object == null) {
throw new NullPointerException(message);
}
} | java | public static void checkNotNull(@Nullable Object object, @NonNull String message) {
if (object == null) {
throw new NullPointerException(message);
}
} | [
"public",
"static",
"void",
"checkNotNull",
"(",
"@",
"Nullable",
"Object",
"object",
",",
"@",
"NonNull",
"String",
"message",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"message",
")",
";",
"}",
"}"
] | Checks that passed reference is not null,
throws {@link NullPointerException} with passed message if reference is null
@param object to check
@param message exception message if object is null | [
"Checks",
"that",
"passed",
"reference",
"is",
"not",
"null",
"throws",
"{",
"@link",
"NullPointerException",
"}",
"with",
"passed",
"message",
"if",
"reference",
"is",
"null"
] | train | https://github.com/pushtorefresh/storio/blob/58f53d81bcc7b069c8bb271c46a90e37775abe8d/storio-common/src/main/java/com/pushtorefresh/storio3/internal/Checks.java#L24-L28 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DisasterRecoveryConfigurationsInner.java | DisasterRecoveryConfigurationsInner.listAsync | public Observable<List<DisasterRecoveryConfigurationInner>> listAsync(String resourceGroupName, String serverName) {
"""
Lists a server's disaster recovery configuration.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DisasterRecoveryConfigurationInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DisasterRecoveryConfigurationInner>>, List<DisasterRecoveryConfigurationInner>>() {
@Override
public List<DisasterRecoveryConfigurationInner> call(ServiceResponse<List<DisasterRecoveryConfigurationInner>> response) {
return response.body();
}
});
} | java | public Observable<List<DisasterRecoveryConfigurationInner>> listAsync(String resourceGroupName, String serverName) {
return listWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<DisasterRecoveryConfigurationInner>>, List<DisasterRecoveryConfigurationInner>>() {
@Override
public List<DisasterRecoveryConfigurationInner> call(ServiceResponse<List<DisasterRecoveryConfigurationInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"DisasterRecoveryConfigurationInner",
">",
">",
"listAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"DisasterRecoveryConfigurationInner",
">",
">",
",",
"List",
"<",
"DisasterRecoveryConfigurationInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"DisasterRecoveryConfigurationInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"DisasterRecoveryConfigurationInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists a server's disaster recovery configuration.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<DisasterRecoveryConfigurationInner> object | [
"Lists",
"a",
"server",
"s",
"disaster",
"recovery",
"configuration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DisasterRecoveryConfigurationsInner.java#L135-L142 |
kiswanij/jk-util | src/main/java/com/jk/util/JKConversionUtil.java | JKConversionUtil.toBoolean | public static boolean toBoolean(Object value, boolean defaultValue) {
"""
To boolean.
@param value the value
@param defaultValue the default value
@return true, if successful
"""
boolean result;// = defaultValue;
if (value != null) {
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue();
}
if (value.toString().trim().equals("1") || value.toString().trim().toLowerCase().equals("true")) {
result = true;
} else {
result = false;
}
} else {
result = defaultValue;
}
return result;
} | java | public static boolean toBoolean(Object value, boolean defaultValue) {
boolean result;// = defaultValue;
if (value != null) {
if (value instanceof Boolean) {
return ((Boolean) value).booleanValue();
}
if (value.toString().trim().equals("1") || value.toString().trim().toLowerCase().equals("true")) {
result = true;
} else {
result = false;
}
} else {
result = defaultValue;
}
return result;
} | [
"public",
"static",
"boolean",
"toBoolean",
"(",
"Object",
"value",
",",
"boolean",
"defaultValue",
")",
"{",
"boolean",
"result",
";",
"// = defaultValue;\r",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"return",
"(",
"(",
"Boolean",
")",
"value",
")",
".",
"booleanValue",
"(",
")",
";",
"}",
"if",
"(",
"value",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"\"1\"",
")",
"||",
"value",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"true\"",
")",
")",
"{",
"result",
"=",
"true",
";",
"}",
"else",
"{",
"result",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"defaultValue",
";",
"}",
"return",
"result",
";",
"}"
] | To boolean.
@param value the value
@param defaultValue the default value
@return true, if successful | [
"To",
"boolean",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKConversionUtil.java#L132-L149 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/util/ImageUtil.java | ImageUtil.createRectangleImage | public static Image createRectangleImage(String id, String url,
double horMargin, double verMargin, double width, double height) {
"""
Creates an {@link Image} with full opacity (new PictureStyle(1)).
horMargin, verMargin, width and height are used to create the {@link Bbox}
@param id is used to create the actual {@link Image} (new Image(id)).
@param url
@param horMargin
@param verMargin
@param width
@param height
@return
"""
Image i = new Image(id);
i.setHref(url);
i.setStyle(new PictureStyle(1));
i.setBounds(new Bbox(horMargin, verMargin, width, height));
return i;
} | java | public static Image createRectangleImage(String id, String url,
double horMargin, double verMargin, double width, double height) {
Image i = new Image(id);
i.setHref(url);
i.setStyle(new PictureStyle(1));
i.setBounds(new Bbox(horMargin, verMargin, width, height));
return i;
} | [
"public",
"static",
"Image",
"createRectangleImage",
"(",
"String",
"id",
",",
"String",
"url",
",",
"double",
"horMargin",
",",
"double",
"verMargin",
",",
"double",
"width",
",",
"double",
"height",
")",
"{",
"Image",
"i",
"=",
"new",
"Image",
"(",
"id",
")",
";",
"i",
".",
"setHref",
"(",
"url",
")",
";",
"i",
".",
"setStyle",
"(",
"new",
"PictureStyle",
"(",
"1",
")",
")",
";",
"i",
".",
"setBounds",
"(",
"new",
"Bbox",
"(",
"horMargin",
",",
"verMargin",
",",
"width",
",",
"height",
")",
")",
";",
"return",
"i",
";",
"}"
] | Creates an {@link Image} with full opacity (new PictureStyle(1)).
horMargin, verMargin, width and height are used to create the {@link Bbox}
@param id is used to create the actual {@link Image} (new Image(id)).
@param url
@param horMargin
@param verMargin
@param width
@param height
@return | [
"Creates",
"an",
"{"
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/util/ImageUtil.java#L41-L48 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/RandomUtils.java | RandomUtils.nextDouble | public static double nextDouble(final double startInclusive, final double endInclusive) {
"""
<p>
Returns a random double within the specified range.
</p>
@param startInclusive
the smallest value that can be returned, must be non-negative
@param endInclusive
the upper bound (included)
@throws IllegalArgumentException
if {@code startInclusive > endInclusive} or if
{@code startInclusive} is negative
@return the random double
"""
Validate.isTrue(endInclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endInclusive) {
return startInclusive;
}
return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble());
} | java | public static double nextDouble(final double startInclusive, final double endInclusive) {
Validate.isTrue(endInclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endInclusive) {
return startInclusive;
}
return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble());
} | [
"public",
"static",
"double",
"nextDouble",
"(",
"final",
"double",
"startInclusive",
",",
"final",
"double",
"endInclusive",
")",
"{",
"Validate",
".",
"isTrue",
"(",
"endInclusive",
">=",
"startInclusive",
",",
"\"Start value must be smaller or equal to end value.\"",
")",
";",
"Validate",
".",
"isTrue",
"(",
"startInclusive",
">=",
"0",
",",
"\"Both range values must be non-negative.\"",
")",
";",
"if",
"(",
"startInclusive",
"==",
"endInclusive",
")",
"{",
"return",
"startInclusive",
";",
"}",
"return",
"startInclusive",
"+",
"(",
"(",
"endInclusive",
"-",
"startInclusive",
")",
"*",
"RANDOM",
".",
"nextDouble",
"(",
")",
")",
";",
"}"
] | <p>
Returns a random double within the specified range.
</p>
@param startInclusive
the smallest value that can be returned, must be non-negative
@param endInclusive
the upper bound (included)
@throws IllegalArgumentException
if {@code startInclusive > endInclusive} or if
{@code startInclusive} is negative
@return the random double | [
"<p",
">",
"Returns",
"a",
"random",
"double",
"within",
"the",
"specified",
"range",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/RandomUtils.java#L168-L178 |
protostuff/protostuff | protostuff-core/src/main/java/io/protostuff/CodedInput.java | CodedInput.readRawVarint32 | static int readRawVarint32(final InputStream input) throws IOException {
"""
Reads a varint from the input one byte at a time, so that it does not read any bytes after the end of the varint.
If you simply wrapped the stream in a CodedInput and used {@link #readRawVarint32(InputStream)} then you would
probably end up reading past the end of the varint since CodedInput buffers its input.
"""
final int firstByte = input.read();
if (firstByte == -1)
{
throw ProtobufException.truncatedMessage();
}
if ((firstByte & 0x80) == 0)
{
return firstByte;
}
return readRawVarint32(input, firstByte);
} | java | static int readRawVarint32(final InputStream input) throws IOException
{
final int firstByte = input.read();
if (firstByte == -1)
{
throw ProtobufException.truncatedMessage();
}
if ((firstByte & 0x80) == 0)
{
return firstByte;
}
return readRawVarint32(input, firstByte);
} | [
"static",
"int",
"readRawVarint32",
"(",
"final",
"InputStream",
"input",
")",
"throws",
"IOException",
"{",
"final",
"int",
"firstByte",
"=",
"input",
".",
"read",
"(",
")",
";",
"if",
"(",
"firstByte",
"==",
"-",
"1",
")",
"{",
"throw",
"ProtobufException",
".",
"truncatedMessage",
"(",
")",
";",
"}",
"if",
"(",
"(",
"firstByte",
"&",
"0x80",
")",
"==",
"0",
")",
"{",
"return",
"firstByte",
";",
"}",
"return",
"readRawVarint32",
"(",
"input",
",",
"firstByte",
")",
";",
"}"
] | Reads a varint from the input one byte at a time, so that it does not read any bytes after the end of the varint.
If you simply wrapped the stream in a CodedInput and used {@link #readRawVarint32(InputStream)} then you would
probably end up reading past the end of the varint since CodedInput buffers its input. | [
"Reads",
"a",
"varint",
"from",
"the",
"input",
"one",
"byte",
"at",
"a",
"time",
"so",
"that",
"it",
"does",
"not",
"read",
"any",
"bytes",
"after",
"the",
"end",
"of",
"the",
"varint",
".",
"If",
"you",
"simply",
"wrapped",
"the",
"stream",
"in",
"a",
"CodedInput",
"and",
"used",
"{"
] | train | https://github.com/protostuff/protostuff/blob/af669cf089057d0ec83220266131ce411854af7b/protostuff-core/src/main/java/io/protostuff/CodedInput.java#L529-L542 |
apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getExecutionState | public ExecutionEnvironment.ExecutionState getExecutionState(String topologyName) {
"""
Get the execution state for the given topology
@return ExecutionState
"""
return awaitResult(delegate.getExecutionState(null, topologyName));
} | java | public ExecutionEnvironment.ExecutionState getExecutionState(String topologyName) {
return awaitResult(delegate.getExecutionState(null, topologyName));
} | [
"public",
"ExecutionEnvironment",
".",
"ExecutionState",
"getExecutionState",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getExecutionState",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the execution state for the given topology
@return ExecutionState | [
"Get",
"the",
"execution",
"state",
"for",
"the",
"given",
"topology"
] | train | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L284-L286 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/DatabaseAutomaticTuningsInner.java | DatabaseAutomaticTuningsInner.updateAsync | public Observable<DatabaseAutomaticTuningInner> updateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseAutomaticTuningInner parameters) {
"""
Update automatic tuning properties for target database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param parameters The requested automatic tuning resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseAutomaticTuningInner object
"""
return updateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseAutomaticTuningInner>, DatabaseAutomaticTuningInner>() {
@Override
public DatabaseAutomaticTuningInner call(ServiceResponse<DatabaseAutomaticTuningInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseAutomaticTuningInner> updateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseAutomaticTuningInner parameters) {
return updateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseAutomaticTuningInner>, DatabaseAutomaticTuningInner>() {
@Override
public DatabaseAutomaticTuningInner call(ServiceResponse<DatabaseAutomaticTuningInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseAutomaticTuningInner",
">",
"updateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"DatabaseAutomaticTuningInner",
"parameters",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DatabaseAutomaticTuningInner",
">",
",",
"DatabaseAutomaticTuningInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DatabaseAutomaticTuningInner",
"call",
"(",
"ServiceResponse",
"<",
"DatabaseAutomaticTuningInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Update automatic tuning properties for target database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@param parameters The requested automatic tuning resource state.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseAutomaticTuningInner object | [
"Update",
"automatic",
"tuning",
"properties",
"for",
"target",
"database",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/DatabaseAutomaticTuningsInner.java#L201-L208 |
vakinge/jeesuite-libs | jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/cache/EntityCacheHelper.java | EntityCacheHelper.queryTryCache | public static <T> T queryTryCache(Class<? extends BaseEntity> entityClass,String key,long expireSeconds,Callable<T> dataCaller) {
"""
查询并缓存结果
@param entityClass 实体类class (用户组装实际的缓存key)
@param key 缓存的key(和entityClass一起组成真实的缓存key。<br>如entityClass=UserEntity.class,key=findlist,实际的key为:UserEntity.findlist)
@param expireSeconds 过期时间,单位:秒
@param dataCaller 缓存不存在数据加载源
@return
"""
if(CacheHandler.cacheProvider == null){
try {
return dataCaller.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
String entityClassName = entityClass.getSimpleName();
key = entityClassName + CacheHandler.SPLIT_PONIT + key;
T result = CacheHandler.cacheProvider.get(key);
if(result == null){
try {
result = dataCaller.call();
if(result != null){
CacheHandler.cacheProvider.set(key, result, expireSeconds);
String cacheGroupKey = entityClassName + CacheHandler.GROUPKEY_SUFFIX;
CacheHandler.cacheProvider.putGroup(cacheGroupKey, key, expireSeconds);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
} | java | public static <T> T queryTryCache(Class<? extends BaseEntity> entityClass,String key,long expireSeconds,Callable<T> dataCaller){
if(CacheHandler.cacheProvider == null){
try {
return dataCaller.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
String entityClassName = entityClass.getSimpleName();
key = entityClassName + CacheHandler.SPLIT_PONIT + key;
T result = CacheHandler.cacheProvider.get(key);
if(result == null){
try {
result = dataCaller.call();
if(result != null){
CacheHandler.cacheProvider.set(key, result, expireSeconds);
String cacheGroupKey = entityClassName + CacheHandler.GROUPKEY_SUFFIX;
CacheHandler.cacheProvider.putGroup(cacheGroupKey, key, expireSeconds);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
} | [
"public",
"static",
"<",
"T",
">",
"T",
"queryTryCache",
"(",
"Class",
"<",
"?",
"extends",
"BaseEntity",
">",
"entityClass",
",",
"String",
"key",
",",
"long",
"expireSeconds",
",",
"Callable",
"<",
"T",
">",
"dataCaller",
")",
"{",
"if",
"(",
"CacheHandler",
".",
"cacheProvider",
"==",
"null",
")",
"{",
"try",
"{",
"return",
"dataCaller",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"String",
"entityClassName",
"=",
"entityClass",
".",
"getSimpleName",
"(",
")",
";",
"key",
"=",
"entityClassName",
"+",
"CacheHandler",
".",
"SPLIT_PONIT",
"+",
"key",
";",
"T",
"result",
"=",
"CacheHandler",
".",
"cacheProvider",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"try",
"{",
"result",
"=",
"dataCaller",
".",
"call",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"CacheHandler",
".",
"cacheProvider",
".",
"set",
"(",
"key",
",",
"result",
",",
"expireSeconds",
")",
";",
"String",
"cacheGroupKey",
"=",
"entityClassName",
"+",
"CacheHandler",
".",
"GROUPKEY_SUFFIX",
";",
"CacheHandler",
".",
"cacheProvider",
".",
"putGroup",
"(",
"cacheGroupKey",
",",
"key",
",",
"expireSeconds",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | 查询并缓存结果
@param entityClass 实体类class (用户组装实际的缓存key)
@param key 缓存的key(和entityClass一起组成真实的缓存key。<br>如entityClass=UserEntity.class,key=findlist,实际的key为:UserEntity.findlist)
@param expireSeconds 过期时间,单位:秒
@param dataCaller 缓存不存在数据加载源
@return | [
"查询并缓存结果"
] | train | https://github.com/vakinge/jeesuite-libs/blob/c48fe2c7fbd294892cf4030dbec96e744dd3e386/jeesuite-mybatis/src/main/java/com/jeesuite/mybatis/plugin/cache/EntityCacheHelper.java#L45-L71 |
Hygieia/Hygieia | api/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java | CodeQualityServiceImpl.getReportURL | private String getReportURL(String projectUrl,String path,String projectId) {
"""
get projectUrl and projectId from collectorItem and form reportUrl
"""
StringBuilder sb = new StringBuilder(projectUrl);
if(!projectUrl.endsWith("/")) {
sb.append("/");
}
sb.append(path)
.append(projectId);
return sb.toString();
} | java | private String getReportURL(String projectUrl,String path,String projectId) {
StringBuilder sb = new StringBuilder(projectUrl);
if(!projectUrl.endsWith("/")) {
sb.append("/");
}
sb.append(path)
.append(projectId);
return sb.toString();
} | [
"private",
"String",
"getReportURL",
"(",
"String",
"projectUrl",
",",
"String",
"path",
",",
"String",
"projectId",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"projectUrl",
")",
";",
"if",
"(",
"!",
"projectUrl",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"/\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"path",
")",
".",
"append",
"(",
"projectId",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | get projectUrl and projectId from collectorItem and form reportUrl | [
"get",
"projectUrl",
"and",
"projectId",
"from",
"collectorItem",
"and",
"form",
"reportUrl"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/api/src/main/java/com/capitalone/dashboard/service/CodeQualityServiceImpl.java#L220-L228 |
tvesalainen/util | util/src/main/java/org/vesalainen/math/BezierCurve.java | BezierCurve.secondDerivative | private ParameterizedOperator secondDerivative(double... controlPoints) {
"""
Create second derivative function for fixed control points.
@param controlPoints
@return
"""
if (controlPoints.length != 2*length)
{
throw new IllegalArgumentException("control-points length not "+length);
}
return secondDerivative(controlPoints, 0);
} | java | private ParameterizedOperator secondDerivative(double... controlPoints)
{
if (controlPoints.length != 2*length)
{
throw new IllegalArgumentException("control-points length not "+length);
}
return secondDerivative(controlPoints, 0);
} | [
"private",
"ParameterizedOperator",
"secondDerivative",
"(",
"double",
"...",
"controlPoints",
")",
"{",
"if",
"(",
"controlPoints",
".",
"length",
"!=",
"2",
"*",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"control-points length not \"",
"+",
"length",
")",
";",
"}",
"return",
"secondDerivative",
"(",
"controlPoints",
",",
"0",
")",
";",
"}"
] | Create second derivative function for fixed control points.
@param controlPoints
@return | [
"Create",
"second",
"derivative",
"function",
"for",
"fixed",
"control",
"points",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/BezierCurve.java#L143-L150 |
apache/groovy | subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java | Groovyc.scanDir | protected void scanDir(File srcDir, File destDir, String[] files) {
"""
Scans the directory looking for source files to be compiled.
The results are returned in the class variable compileList
@param srcDir The source directory
@param destDir The destination directory
@param files An array of filenames
"""
GlobPatternMapper m = new GlobPatternMapper();
SourceFileScanner sfs = new SourceFileScanner(this);
File[] newFiles;
for (String extension : getScriptExtensions()) {
m.setFrom("*." + extension);
m.setTo("*.class");
newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
addToCompileList(newFiles);
}
if (jointCompilation) {
m.setFrom("*.java");
m.setTo("*.class");
newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
addToCompileList(newFiles);
}
} | java | protected void scanDir(File srcDir, File destDir, String[] files) {
GlobPatternMapper m = new GlobPatternMapper();
SourceFileScanner sfs = new SourceFileScanner(this);
File[] newFiles;
for (String extension : getScriptExtensions()) {
m.setFrom("*." + extension);
m.setTo("*.class");
newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
addToCompileList(newFiles);
}
if (jointCompilation) {
m.setFrom("*.java");
m.setTo("*.class");
newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
addToCompileList(newFiles);
}
} | [
"protected",
"void",
"scanDir",
"(",
"File",
"srcDir",
",",
"File",
"destDir",
",",
"String",
"[",
"]",
"files",
")",
"{",
"GlobPatternMapper",
"m",
"=",
"new",
"GlobPatternMapper",
"(",
")",
";",
"SourceFileScanner",
"sfs",
"=",
"new",
"SourceFileScanner",
"(",
"this",
")",
";",
"File",
"[",
"]",
"newFiles",
";",
"for",
"(",
"String",
"extension",
":",
"getScriptExtensions",
"(",
")",
")",
"{",
"m",
".",
"setFrom",
"(",
"\"*.\"",
"+",
"extension",
")",
";",
"m",
".",
"setTo",
"(",
"\"*.class\"",
")",
";",
"newFiles",
"=",
"sfs",
".",
"restrictAsFiles",
"(",
"files",
",",
"srcDir",
",",
"destDir",
",",
"m",
")",
";",
"addToCompileList",
"(",
"newFiles",
")",
";",
"}",
"if",
"(",
"jointCompilation",
")",
"{",
"m",
".",
"setFrom",
"(",
"\"*.java\"",
")",
";",
"m",
".",
"setTo",
"(",
"\"*.class\"",
")",
";",
"newFiles",
"=",
"sfs",
".",
"restrictAsFiles",
"(",
"files",
",",
"srcDir",
",",
"destDir",
",",
"m",
")",
";",
"addToCompileList",
"(",
"newFiles",
")",
";",
"}",
"}"
] | Scans the directory looking for source files to be compiled.
The results are returned in the class variable compileList
@param srcDir The source directory
@param destDir The destination directory
@param files An array of filenames | [
"Scans",
"the",
"directory",
"looking",
"for",
"source",
"files",
"to",
"be",
"compiled",
".",
"The",
"results",
"are",
"returned",
"in",
"the",
"class",
"variable",
"compileList"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java#L898-L915 |
j256/ormlite-core | src/main/java/com/j256/ormlite/field/FieldType.java | FieldType.convertStringToJavaField | public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
"""
Convert a string value into the appropriate Java field value.
"""
if (value == null) {
return null;
} else {
return fieldConverter.resultStringToJava(this, value, columnPos);
}
} | java | public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
if (value == null) {
return null;
} else {
return fieldConverter.resultStringToJava(this, value, columnPos);
}
} | [
"public",
"Object",
"convertStringToJavaField",
"(",
"String",
"value",
",",
"int",
"columnPos",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"fieldConverter",
".",
"resultStringToJava",
"(",
"this",
",",
"value",
",",
"columnPos",
")",
";",
"}",
"}"
] | Convert a string value into the appropriate Java field value. | [
"Convert",
"a",
"string",
"value",
"into",
"the",
"appropriate",
"Java",
"field",
"value",
"."
] | train | https://github.com/j256/ormlite-core/blob/154d85bbb9614a0ea65a012251257831fb4fba21/src/main/java/com/j256/ormlite/field/FieldType.java#L664-L670 |
HanSolo/Medusa | src/main/java/eu/hansolo/medusa/tools/ConicalGradient.java | ConicalGradient.normalizeStops | private List<Stop> normalizeStops(final double OFFSET, final List<Stop> STOPS) {
"""
/*
private List<Stop> normalizeStops(final Stop... STOPS) { return normalizeStops(0, Arrays.asList(STOPS)); }
private List<Stop> normalizeStops(final double OFFSET, final Stop... STOPS) { return normalizeStops(OFFSET, Arrays.asList(STOPS)); }
private List<Stop> normalizeStops(final List<Stop> STOPS) { return normalizeStops(0, STOPS); }
"""
double offset = Helper.clamp(0.0, 1.0, OFFSET);
List<Stop> stops;
if (null == STOPS || STOPS.isEmpty()) {
stops = new ArrayList<>();
stops.add(new Stop(0.0, Color.TRANSPARENT));
stops.add(new Stop(1.0, Color.TRANSPARENT));
} else {
stops = STOPS;
}
List<Stop> sortedStops = calculate(stops, offset);
// Reverse the Stops for CCW direction
if (ScaleDirection.COUNTER_CLOCKWISE == scaleDirection) {
List<Stop> sortedStops3 = new ArrayList<>();
Collections.reverse(sortedStops);
for (Stop stop : sortedStops) { sortedStops3.add(new Stop(1.0 - stop.getOffset(), stop.getColor())); }
sortedStops = sortedStops3;
}
return sortedStops;
} | java | private List<Stop> normalizeStops(final double OFFSET, final List<Stop> STOPS) {
double offset = Helper.clamp(0.0, 1.0, OFFSET);
List<Stop> stops;
if (null == STOPS || STOPS.isEmpty()) {
stops = new ArrayList<>();
stops.add(new Stop(0.0, Color.TRANSPARENT));
stops.add(new Stop(1.0, Color.TRANSPARENT));
} else {
stops = STOPS;
}
List<Stop> sortedStops = calculate(stops, offset);
// Reverse the Stops for CCW direction
if (ScaleDirection.COUNTER_CLOCKWISE == scaleDirection) {
List<Stop> sortedStops3 = new ArrayList<>();
Collections.reverse(sortedStops);
for (Stop stop : sortedStops) { sortedStops3.add(new Stop(1.0 - stop.getOffset(), stop.getColor())); }
sortedStops = sortedStops3;
}
return sortedStops;
} | [
"private",
"List",
"<",
"Stop",
">",
"normalizeStops",
"(",
"final",
"double",
"OFFSET",
",",
"final",
"List",
"<",
"Stop",
">",
"STOPS",
")",
"{",
"double",
"offset",
"=",
"Helper",
".",
"clamp",
"(",
"0.0",
",",
"1.0",
",",
"OFFSET",
")",
";",
"List",
"<",
"Stop",
">",
"stops",
";",
"if",
"(",
"null",
"==",
"STOPS",
"||",
"STOPS",
".",
"isEmpty",
"(",
")",
")",
"{",
"stops",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"stops",
".",
"add",
"(",
"new",
"Stop",
"(",
"0.0",
",",
"Color",
".",
"TRANSPARENT",
")",
")",
";",
"stops",
".",
"add",
"(",
"new",
"Stop",
"(",
"1.0",
",",
"Color",
".",
"TRANSPARENT",
")",
")",
";",
"}",
"else",
"{",
"stops",
"=",
"STOPS",
";",
"}",
"List",
"<",
"Stop",
">",
"sortedStops",
"=",
"calculate",
"(",
"stops",
",",
"offset",
")",
";",
"// Reverse the Stops for CCW direction",
"if",
"(",
"ScaleDirection",
".",
"COUNTER_CLOCKWISE",
"==",
"scaleDirection",
")",
"{",
"List",
"<",
"Stop",
">",
"sortedStops3",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Collections",
".",
"reverse",
"(",
"sortedStops",
")",
";",
"for",
"(",
"Stop",
"stop",
":",
"sortedStops",
")",
"{",
"sortedStops3",
".",
"add",
"(",
"new",
"Stop",
"(",
"1.0",
"-",
"stop",
".",
"getOffset",
"(",
")",
",",
"stop",
".",
"getColor",
"(",
")",
")",
")",
";",
"}",
"sortedStops",
"=",
"sortedStops3",
";",
"}",
"return",
"sortedStops",
";",
"}"
] | /*
private List<Stop> normalizeStops(final Stop... STOPS) { return normalizeStops(0, Arrays.asList(STOPS)); }
private List<Stop> normalizeStops(final double OFFSET, final Stop... STOPS) { return normalizeStops(OFFSET, Arrays.asList(STOPS)); }
private List<Stop> normalizeStops(final List<Stop> STOPS) { return normalizeStops(0, STOPS); } | [
"/",
"*",
"private",
"List<Stop",
">",
"normalizeStops",
"(",
"final",
"Stop",
"...",
"STOPS",
")",
"{",
"return",
"normalizeStops",
"(",
"0",
"Arrays",
".",
"asList",
"(",
"STOPS",
"))",
";",
"}",
"private",
"List<Stop",
">",
"normalizeStops",
"(",
"final",
"double",
"OFFSET",
"final",
"Stop",
"...",
"STOPS",
")",
"{",
"return",
"normalizeStops",
"(",
"OFFSET",
"Arrays",
".",
"asList",
"(",
"STOPS",
"))",
";",
"}",
"private",
"List<Stop",
">",
"normalizeStops",
"(",
"final",
"List<Stop",
">",
"STOPS",
")",
"{",
"return",
"normalizeStops",
"(",
"0",
"STOPS",
")",
";",
"}"
] | train | https://github.com/HanSolo/Medusa/blob/1321e4925dcde659028d4b296e49e316494c114c/src/main/java/eu/hansolo/medusa/tools/ConicalGradient.java#L285-L305 |
apache/incubator-gobblin | gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanJobHelper.java | AzkabanJobHelper.createAzkabanJob | public static String createAzkabanJob(String sessionId, AzkabanProjectConfig azkabanProjectConfig)
throws IOException {
"""
*
Create project on Azkaban based on Azkaban config. This includes preparing the zip file and uploading it to
Azkaban, setting permissions and schedule.
@param sessionId Session Id.
@param azkabanProjectConfig Azkaban Project Config.
@return Project Id.
@throws IOException
"""
log.info("Creating Azkaban project for: " + azkabanProjectConfig.getAzkabanProjectName());
// Create zip file
String zipFilePath = createAzkabanJobZip(azkabanProjectConfig);
log.info("Zip file path: " + zipFilePath);
// Upload zip file to Azkaban
String projectId = AzkabanAjaxAPIClient.createAzkabanProject(sessionId, zipFilePath, azkabanProjectConfig);
log.info("Project Id: " + projectId);
return projectId;
} | java | public static String createAzkabanJob(String sessionId, AzkabanProjectConfig azkabanProjectConfig)
throws IOException {
log.info("Creating Azkaban project for: " + azkabanProjectConfig.getAzkabanProjectName());
// Create zip file
String zipFilePath = createAzkabanJobZip(azkabanProjectConfig);
log.info("Zip file path: " + zipFilePath);
// Upload zip file to Azkaban
String projectId = AzkabanAjaxAPIClient.createAzkabanProject(sessionId, zipFilePath, azkabanProjectConfig);
log.info("Project Id: " + projectId);
return projectId;
} | [
"public",
"static",
"String",
"createAzkabanJob",
"(",
"String",
"sessionId",
",",
"AzkabanProjectConfig",
"azkabanProjectConfig",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Creating Azkaban project for: \"",
"+",
"azkabanProjectConfig",
".",
"getAzkabanProjectName",
"(",
")",
")",
";",
"// Create zip file",
"String",
"zipFilePath",
"=",
"createAzkabanJobZip",
"(",
"azkabanProjectConfig",
")",
";",
"log",
".",
"info",
"(",
"\"Zip file path: \"",
"+",
"zipFilePath",
")",
";",
"// Upload zip file to Azkaban",
"String",
"projectId",
"=",
"AzkabanAjaxAPIClient",
".",
"createAzkabanProject",
"(",
"sessionId",
",",
"zipFilePath",
",",
"azkabanProjectConfig",
")",
";",
"log",
".",
"info",
"(",
"\"Project Id: \"",
"+",
"projectId",
")",
";",
"return",
"projectId",
";",
"}"
] | *
Create project on Azkaban based on Azkaban config. This includes preparing the zip file and uploading it to
Azkaban, setting permissions and schedule.
@param sessionId Session Id.
@param azkabanProjectConfig Azkaban Project Config.
@return Project Id.
@throws IOException | [
"*",
"Create",
"project",
"on",
"Azkaban",
"based",
"on",
"Azkaban",
"config",
".",
"This",
"includes",
"preparing",
"the",
"zip",
"file",
"and",
"uploading",
"it",
"to",
"Azkaban",
"setting",
"permissions",
"and",
"schedule",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanJobHelper.java#L108-L121 |
VoltDB/voltdb | src/frontend/org/voltdb/compiler/ClassMatcher.java | ClassMatcher.processPathPart | private static void processPathPart(String path, Set<String> classes) {
"""
For a given classpath root, scan it for packages and classes,
adding all found classnames to the given "classes" param.
"""
File rootFile = new File(path);
if (rootFile.isDirectory() == false) {
return;
}
File[] files = rootFile.listFiles();
for (File f : files) {
// classes in the anonymous package
if (f.getName().endsWith(".class")) {
String className = f.getName();
// trim the trailing .class from the end
className = className.substring(0, className.length() - ".class".length());
classes.add(className);
}
if (f.isDirectory()) {
Package p = new Package(null, f);
p.process(classes);
}
}
} | java | private static void processPathPart(String path, Set<String> classes) {
File rootFile = new File(path);
if (rootFile.isDirectory() == false) {
return;
}
File[] files = rootFile.listFiles();
for (File f : files) {
// classes in the anonymous package
if (f.getName().endsWith(".class")) {
String className = f.getName();
// trim the trailing .class from the end
className = className.substring(0, className.length() - ".class".length());
classes.add(className);
}
if (f.isDirectory()) {
Package p = new Package(null, f);
p.process(classes);
}
}
} | [
"private",
"static",
"void",
"processPathPart",
"(",
"String",
"path",
",",
"Set",
"<",
"String",
">",
"classes",
")",
"{",
"File",
"rootFile",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"rootFile",
".",
"isDirectory",
"(",
")",
"==",
"false",
")",
"{",
"return",
";",
"}",
"File",
"[",
"]",
"files",
"=",
"rootFile",
".",
"listFiles",
"(",
")",
";",
"for",
"(",
"File",
"f",
":",
"files",
")",
"{",
"// classes in the anonymous package",
"if",
"(",
"f",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"{",
"String",
"className",
"=",
"f",
".",
"getName",
"(",
")",
";",
"// trim the trailing .class from the end",
"className",
"=",
"className",
".",
"substring",
"(",
"0",
",",
"className",
".",
"length",
"(",
")",
"-",
"\".class\"",
".",
"length",
"(",
")",
")",
";",
"classes",
".",
"add",
"(",
"className",
")",
";",
"}",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"Package",
"p",
"=",
"new",
"Package",
"(",
"null",
",",
"f",
")",
";",
"p",
".",
"process",
"(",
"classes",
")",
";",
"}",
"}",
"}"
] | For a given classpath root, scan it for packages and classes,
adding all found classnames to the given "classes" param. | [
"For",
"a",
"given",
"classpath",
"root",
"scan",
"it",
"for",
"packages",
"and",
"classes",
"adding",
"all",
"found",
"classnames",
"to",
"the",
"given",
"classes",
"param",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/ClassMatcher.java#L177-L197 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/webhook/WebhookCluster.java | WebhookCluster.broadcast | public List<RequestFuture<?>> broadcast(File file) {
"""
Sends the provided {@link java.io.File File}
to all registered {@link net.dv8tion.jda.webhook.WebhookClient WebhookClients}.
<br>Use {@link WebhookMessage#files(String, Object, Object...)} to send up to 10 files!
<p><b>The provided data should not exceed 8MB in size!</b>
@param file
The file that should be sent to the clients
@throws java.lang.IllegalArgumentException
If the provided file is {@code null}, does not exist or ist not readable
@throws java.util.concurrent.RejectedExecutionException
If any of the receivers has been shutdown
@return A list of {@link java.util.concurrent.Future Future} instances
representing all message tasks.
"""
Checks.notNull(file, "File");
return broadcast(file, file.getName());
} | java | public List<RequestFuture<?>> broadcast(File file)
{
Checks.notNull(file, "File");
return broadcast(file, file.getName());
} | [
"public",
"List",
"<",
"RequestFuture",
"<",
"?",
">",
">",
"broadcast",
"(",
"File",
"file",
")",
"{",
"Checks",
".",
"notNull",
"(",
"file",
",",
"\"File\"",
")",
";",
"return",
"broadcast",
"(",
"file",
",",
"file",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Sends the provided {@link java.io.File File}
to all registered {@link net.dv8tion.jda.webhook.WebhookClient WebhookClients}.
<br>Use {@link WebhookMessage#files(String, Object, Object...)} to send up to 10 files!
<p><b>The provided data should not exceed 8MB in size!</b>
@param file
The file that should be sent to the clients
@throws java.lang.IllegalArgumentException
If the provided file is {@code null}, does not exist or ist not readable
@throws java.util.concurrent.RejectedExecutionException
If any of the receivers has been shutdown
@return A list of {@link java.util.concurrent.Future Future} instances
representing all message tasks. | [
"Sends",
"the",
"provided",
"{",
"@link",
"java",
".",
"io",
".",
"File",
"File",
"}",
"to",
"all",
"registered",
"{",
"@link",
"net",
".",
"dv8tion",
".",
"jda",
".",
"webhook",
".",
"WebhookClient",
"WebhookClients",
"}",
".",
"<br",
">",
"Use",
"{",
"@link",
"WebhookMessage#files",
"(",
"String",
"Object",
"Object",
"...",
")",
"}",
"to",
"send",
"up",
"to",
"10",
"files!"
] | train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/webhook/WebhookCluster.java#L736-L740 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/BaseField.java | BaseField.setupTableLookup | public ScreenComponent setupTableLookup(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, Rec record, int iQueryKeySeq, Converter fldDisplayFieldDesc, boolean bIncludeBlankOption, boolean bIncludeFormButton) {
"""
Same as setupTablePopup for larger files (that don't fit in a popup).
Displays a [Key to record (opt)] [Record Description] [Lookup button] [Form button (opt)]
@param record Record to display in a popup
@param iQueryKeySeq Key to use for code-lookup operation (-1 = None)
@param iDisplayFieldSeq Description field for the display field (-1 = third field)
@param bIncludeFormButton Include a form button (in addition to the lookup button)?
@return Return the component or ScreenField that is created for this field.
"""
String keyAreaName = null;
if (iQueryKeySeq != -1)
keyAreaName = this.getRecord().getKeyArea(iQueryKeySeq).getKeyName();
return this.setupTableLookup(itsLocation, targetScreen, converter, iDisplayFieldDesc, record, keyAreaName, fldDisplayFieldDesc, bIncludeBlankOption, bIncludeFormButton);
} | java | public ScreenComponent setupTableLookup(ScreenLoc itsLocation, ComponentParent targetScreen, Convert converter, int iDisplayFieldDesc, Rec record, int iQueryKeySeq, Converter fldDisplayFieldDesc, boolean bIncludeBlankOption, boolean bIncludeFormButton)
{
String keyAreaName = null;
if (iQueryKeySeq != -1)
keyAreaName = this.getRecord().getKeyArea(iQueryKeySeq).getKeyName();
return this.setupTableLookup(itsLocation, targetScreen, converter, iDisplayFieldDesc, record, keyAreaName, fldDisplayFieldDesc, bIncludeBlankOption, bIncludeFormButton);
} | [
"public",
"ScreenComponent",
"setupTableLookup",
"(",
"ScreenLoc",
"itsLocation",
",",
"ComponentParent",
"targetScreen",
",",
"Convert",
"converter",
",",
"int",
"iDisplayFieldDesc",
",",
"Rec",
"record",
",",
"int",
"iQueryKeySeq",
",",
"Converter",
"fldDisplayFieldDesc",
",",
"boolean",
"bIncludeBlankOption",
",",
"boolean",
"bIncludeFormButton",
")",
"{",
"String",
"keyAreaName",
"=",
"null",
";",
"if",
"(",
"iQueryKeySeq",
"!=",
"-",
"1",
")",
"keyAreaName",
"=",
"this",
".",
"getRecord",
"(",
")",
".",
"getKeyArea",
"(",
"iQueryKeySeq",
")",
".",
"getKeyName",
"(",
")",
";",
"return",
"this",
".",
"setupTableLookup",
"(",
"itsLocation",
",",
"targetScreen",
",",
"converter",
",",
"iDisplayFieldDesc",
",",
"record",
",",
"keyAreaName",
",",
"fldDisplayFieldDesc",
",",
"bIncludeBlankOption",
",",
"bIncludeFormButton",
")",
";",
"}"
] | Same as setupTablePopup for larger files (that don't fit in a popup).
Displays a [Key to record (opt)] [Record Description] [Lookup button] [Form button (opt)]
@param record Record to display in a popup
@param iQueryKeySeq Key to use for code-lookup operation (-1 = None)
@param iDisplayFieldSeq Description field for the display field (-1 = third field)
@param bIncludeFormButton Include a form button (in addition to the lookup button)?
@return Return the component or ScreenField that is created for this field. | [
"Same",
"as",
"setupTablePopup",
"for",
"larger",
"files",
"(",
"that",
"don",
"t",
"fit",
"in",
"a",
"popup",
")",
".",
"Displays",
"a",
"[",
"Key",
"to",
"record",
"(",
"opt",
")",
"]",
"[",
"Record",
"Description",
"]",
"[",
"Lookup",
"button",
"]",
"[",
"Form",
"button",
"(",
"opt",
")",
"]"
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BaseField.java#L1304-L1310 |
CleverTap/clevertap-android-sdk | clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java | CleverTapAPI.addMultiValuesForKey | @SuppressWarnings( {
"""
Add a collection of unique values to a multi-value user profile property
If the property does not exist it will be created
<p/>
Max 100 values, on reaching 100 cap, oldest value(s) will be removed.
Values must be Strings and are limited to 512 characters.
<p/>
If the key currently contains a scalar value, the key will be promoted to a multi-value property
with the current value cast to a string and the new value(s) added
@param key String
@param values {@link ArrayList} with String values
""""unused", "WeakerAccess"})
public void addMultiValuesForKey(final String key, final ArrayList<String> values) {
postAsyncSafely("addMultiValuesForKey", new Runnable() {
@Override
public void run() {
final String command = (getLocalDataStore().getProfileValueForKey(key) != null) ? Constants.COMMAND_ADD : Constants.COMMAND_SET;
_handleMultiValues(values, key, command);
}
});
} | java | @SuppressWarnings({"unused", "WeakerAccess"})
public void addMultiValuesForKey(final String key, final ArrayList<String> values) {
postAsyncSafely("addMultiValuesForKey", new Runnable() {
@Override
public void run() {
final String command = (getLocalDataStore().getProfileValueForKey(key) != null) ? Constants.COMMAND_ADD : Constants.COMMAND_SET;
_handleMultiValues(values, key, command);
}
});
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unused\"",
",",
"\"WeakerAccess\"",
"}",
")",
"public",
"void",
"addMultiValuesForKey",
"(",
"final",
"String",
"key",
",",
"final",
"ArrayList",
"<",
"String",
">",
"values",
")",
"{",
"postAsyncSafely",
"(",
"\"addMultiValuesForKey\"",
",",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"final",
"String",
"command",
"=",
"(",
"getLocalDataStore",
"(",
")",
".",
"getProfileValueForKey",
"(",
"key",
")",
"!=",
"null",
")",
"?",
"Constants",
".",
"COMMAND_ADD",
":",
"Constants",
".",
"COMMAND_SET",
";",
"_handleMultiValues",
"(",
"values",
",",
"key",
",",
"command",
")",
";",
"}",
"}",
")",
";",
"}"
] | Add a collection of unique values to a multi-value user profile property
If the property does not exist it will be created
<p/>
Max 100 values, on reaching 100 cap, oldest value(s) will be removed.
Values must be Strings and are limited to 512 characters.
<p/>
If the key currently contains a scalar value, the key will be promoted to a multi-value property
with the current value cast to a string and the new value(s) added
@param key String
@param values {@link ArrayList} with String values | [
"Add",
"a",
"collection",
"of",
"unique",
"values",
"to",
"a",
"multi",
"-",
"value",
"user",
"profile",
"property",
"If",
"the",
"property",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"<p",
"/",
">",
"Max",
"100",
"values",
"on",
"reaching",
"100",
"cap",
"oldest",
"value",
"(",
"s",
")",
"will",
"be",
"removed",
".",
"Values",
"must",
"be",
"Strings",
"and",
"are",
"limited",
"to",
"512",
"characters",
".",
"<p",
"/",
">",
"If",
"the",
"key",
"currently",
"contains",
"a",
"scalar",
"value",
"the",
"key",
"will",
"be",
"promoted",
"to",
"a",
"multi",
"-",
"value",
"property",
"with",
"the",
"current",
"value",
"cast",
"to",
"a",
"string",
"and",
"the",
"new",
"value",
"(",
"s",
")",
"added"
] | train | https://github.com/CleverTap/clevertap-android-sdk/blob/be134c06a4f07494c398335ad9ff4976633743e1/clevertap-android-sdk/src/main/java/com/clevertap/android/sdk/CleverTapAPI.java#L3419-L3428 |
cdk/cdk | app/depict/src/main/java/org/openscience/cdk/depict/DepictionGenerator.java | DepictionGenerator.withAtomMapNumbers | public DepictionGenerator withAtomMapNumbers() {
"""
Display atom-atom mapping numbers on a reaction. Each atom map index
is loaded from the property {@link CDKConstants#ATOM_ATOM_MAPPING}.
Note: A depiction can not have both atom numbers and atom
maps visible (but this can be achieved by manually setting
the annotation).
@return new generator for method chaining
@see #withAtomNumbers()
@see CDKConstants#ATOM_ATOM_MAPPING
@see StandardGenerator#ANNOTATION_LABEL
"""
if (annotateAtomNum)
throw new IllegalArgumentException("Can not annotated atom maps, atom numbers or values are already annotated");
DepictionGenerator copy = new DepictionGenerator(this);
copy.annotateAtomMap = true;
return copy;
} | java | public DepictionGenerator withAtomMapNumbers() {
if (annotateAtomNum)
throw new IllegalArgumentException("Can not annotated atom maps, atom numbers or values are already annotated");
DepictionGenerator copy = new DepictionGenerator(this);
copy.annotateAtomMap = true;
return copy;
} | [
"public",
"DepictionGenerator",
"withAtomMapNumbers",
"(",
")",
"{",
"if",
"(",
"annotateAtomNum",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can not annotated atom maps, atom numbers or values are already annotated\"",
")",
";",
"DepictionGenerator",
"copy",
"=",
"new",
"DepictionGenerator",
"(",
"this",
")",
";",
"copy",
".",
"annotateAtomMap",
"=",
"true",
";",
"return",
"copy",
";",
"}"
] | Display atom-atom mapping numbers on a reaction. Each atom map index
is loaded from the property {@link CDKConstants#ATOM_ATOM_MAPPING}.
Note: A depiction can not have both atom numbers and atom
maps visible (but this can be achieved by manually setting
the annotation).
@return new generator for method chaining
@see #withAtomNumbers()
@see CDKConstants#ATOM_ATOM_MAPPING
@see StandardGenerator#ANNOTATION_LABEL | [
"Display",
"atom",
"-",
"atom",
"mapping",
"numbers",
"on",
"a",
"reaction",
".",
"Each",
"atom",
"map",
"index",
"is",
"loaded",
"from",
"the",
"property",
"{",
"@link",
"CDKConstants#ATOM_ATOM_MAPPING",
"}",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/app/depict/src/main/java/org/openscience/cdk/depict/DepictionGenerator.java#L814-L820 |
google/closure-compiler | src/com/google/javascript/jscomp/TypeCheck.java | TypeCheck.visitGetProp | private void visitGetProp(NodeTraversal t, Node n) {
"""
Visits a GETPROP node.
@param t The node traversal object that supplies context, such as the scope chain to use in
name lookups as well as error reporting.
@param n The node being visited.
"""
// obj.prop or obj.method()
// Lots of types can appear on the left, a call to a void function can
// never be on the left. getPropertyType will decide what is acceptable
// and what isn't.
Node property = n.getLastChild();
Node objNode = n.getFirstChild();
JSType childType = getJSType(objNode);
if (childType.isDict()) {
report(property, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "'.'", "dict");
} else if (validator.expectNotNullOrUndefined(t, n, childType,
"No properties on this expression", getNativeType(OBJECT_TYPE))) {
checkPropertyAccessForGetProp(n);
}
ensureTyped(n);
} | java | private void visitGetProp(NodeTraversal t, Node n) {
// obj.prop or obj.method()
// Lots of types can appear on the left, a call to a void function can
// never be on the left. getPropertyType will decide what is acceptable
// and what isn't.
Node property = n.getLastChild();
Node objNode = n.getFirstChild();
JSType childType = getJSType(objNode);
if (childType.isDict()) {
report(property, TypeValidator.ILLEGAL_PROPERTY_ACCESS, "'.'", "dict");
} else if (validator.expectNotNullOrUndefined(t, n, childType,
"No properties on this expression", getNativeType(OBJECT_TYPE))) {
checkPropertyAccessForGetProp(n);
}
ensureTyped(n);
} | [
"private",
"void",
"visitGetProp",
"(",
"NodeTraversal",
"t",
",",
"Node",
"n",
")",
"{",
"// obj.prop or obj.method()",
"// Lots of types can appear on the left, a call to a void function can",
"// never be on the left. getPropertyType will decide what is acceptable",
"// and what isn't.",
"Node",
"property",
"=",
"n",
".",
"getLastChild",
"(",
")",
";",
"Node",
"objNode",
"=",
"n",
".",
"getFirstChild",
"(",
")",
";",
"JSType",
"childType",
"=",
"getJSType",
"(",
"objNode",
")",
";",
"if",
"(",
"childType",
".",
"isDict",
"(",
")",
")",
"{",
"report",
"(",
"property",
",",
"TypeValidator",
".",
"ILLEGAL_PROPERTY_ACCESS",
",",
"\"'.'\"",
",",
"\"dict\"",
")",
";",
"}",
"else",
"if",
"(",
"validator",
".",
"expectNotNullOrUndefined",
"(",
"t",
",",
"n",
",",
"childType",
",",
"\"No properties on this expression\"",
",",
"getNativeType",
"(",
"OBJECT_TYPE",
")",
")",
")",
"{",
"checkPropertyAccessForGetProp",
"(",
"n",
")",
";",
"}",
"ensureTyped",
"(",
"n",
")",
";",
"}"
] | Visits a GETPROP node.
@param t The node traversal object that supplies context, such as the scope chain to use in
name lookups as well as error reporting.
@param n The node being visited. | [
"Visits",
"a",
"GETPROP",
"node",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/TypeCheck.java#L1943-L1959 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java | StereoDisparityWtoNaiveFive.process | public void process( I left , I right , GrayF32 imageDisparity ) {
"""
Computes the disparity for two stereo images along the image's right axis. Both
image must be rectified.
@param left Left camera image.
@param right Right camera image.
"""
// check inputs and initialize data structures
InputSanityCheck.checkSameShape(left,right,imageDisparity);
this.imageLeft = left;
this.imageRight = right;
w = left.width; h = left.height;
// Compute disparity for each pixel
for( int y = radiusY*2; y < h-radiusY*2; y++ ) {
for( int x = radiusX*2+minDisparity; x < w-radiusX*2; x++ ) {
// take in account image border when computing max disparity
int max = x-Math.max(radiusX*2-1,x-score.length);
// compute match score across all candidates
processPixel(x, y, max);
// select the best disparity
imageDisparity.set(x,y,(float)selectBest(max));
}
}
} | java | public void process( I left , I right , GrayF32 imageDisparity ) {
// check inputs and initialize data structures
InputSanityCheck.checkSameShape(left,right,imageDisparity);
this.imageLeft = left;
this.imageRight = right;
w = left.width; h = left.height;
// Compute disparity for each pixel
for( int y = radiusY*2; y < h-radiusY*2; y++ ) {
for( int x = radiusX*2+minDisparity; x < w-radiusX*2; x++ ) {
// take in account image border when computing max disparity
int max = x-Math.max(radiusX*2-1,x-score.length);
// compute match score across all candidates
processPixel(x, y, max);
// select the best disparity
imageDisparity.set(x,y,(float)selectBest(max));
}
}
} | [
"public",
"void",
"process",
"(",
"I",
"left",
",",
"I",
"right",
",",
"GrayF32",
"imageDisparity",
")",
"{",
"// check inputs and initialize data structures",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"left",
",",
"right",
",",
"imageDisparity",
")",
";",
"this",
".",
"imageLeft",
"=",
"left",
";",
"this",
".",
"imageRight",
"=",
"right",
";",
"w",
"=",
"left",
".",
"width",
";",
"h",
"=",
"left",
".",
"height",
";",
"// Compute disparity for each pixel",
"for",
"(",
"int",
"y",
"=",
"radiusY",
"*",
"2",
";",
"y",
"<",
"h",
"-",
"radiusY",
"*",
"2",
";",
"y",
"++",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"radiusX",
"*",
"2",
"+",
"minDisparity",
";",
"x",
"<",
"w",
"-",
"radiusX",
"*",
"2",
";",
"x",
"++",
")",
"{",
"// take in account image border when computing max disparity",
"int",
"max",
"=",
"x",
"-",
"Math",
".",
"max",
"(",
"radiusX",
"*",
"2",
"-",
"1",
",",
"x",
"-",
"score",
".",
"length",
")",
";",
"// compute match score across all candidates",
"processPixel",
"(",
"x",
",",
"y",
",",
"max",
")",
";",
"// select the best disparity",
"imageDisparity",
".",
"set",
"(",
"x",
",",
"y",
",",
"(",
"float",
")",
"selectBest",
"(",
"max",
")",
")",
";",
"}",
"}",
"}"
] | Computes the disparity for two stereo images along the image's right axis. Both
image must be rectified.
@param left Left camera image.
@param right Right camera image. | [
"Computes",
"the",
"disparity",
"for",
"two",
"stereo",
"images",
"along",
"the",
"image",
"s",
"right",
"axis",
".",
"Both",
"image",
"must",
"be",
"rectified",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java#L75-L96 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java | PatternsImpl.updatePatternsAsync | public Observable<List<PatternRuleInfo>> updatePatternsAsync(UUID appId, String versionId, List<PatternRuleUpdateObject> patterns) {
"""
Updates patterns.
@param appId The application ID.
@param versionId The version ID.
@param patterns An array represents the patterns.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<PatternRuleInfo> object
"""
return updatePatternsWithServiceResponseAsync(appId, versionId, patterns).map(new Func1<ServiceResponse<List<PatternRuleInfo>>, List<PatternRuleInfo>>() {
@Override
public List<PatternRuleInfo> call(ServiceResponse<List<PatternRuleInfo>> response) {
return response.body();
}
});
} | java | public Observable<List<PatternRuleInfo>> updatePatternsAsync(UUID appId, String versionId, List<PatternRuleUpdateObject> patterns) {
return updatePatternsWithServiceResponseAsync(appId, versionId, patterns).map(new Func1<ServiceResponse<List<PatternRuleInfo>>, List<PatternRuleInfo>>() {
@Override
public List<PatternRuleInfo> call(ServiceResponse<List<PatternRuleInfo>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"PatternRuleInfo",
">",
">",
"updatePatternsAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"List",
"<",
"PatternRuleUpdateObject",
">",
"patterns",
")",
"{",
"return",
"updatePatternsWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"patterns",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"List",
"<",
"PatternRuleInfo",
">",
">",
",",
"List",
"<",
"PatternRuleInfo",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"PatternRuleInfo",
">",
"call",
"(",
"ServiceResponse",
"<",
"List",
"<",
"PatternRuleInfo",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Updates patterns.
@param appId The application ID.
@param versionId The version ID.
@param patterns An array represents the patterns.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<PatternRuleInfo> object | [
"Updates",
"patterns",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/PatternsImpl.java#L411-L418 |
aws/aws-sdk-java | aws-java-sdk-greengrass/src/main/java/com/amazonaws/services/greengrass/model/GetCoreDefinitionResult.java | GetCoreDefinitionResult.withTags | public GetCoreDefinitionResult withTags(java.util.Map<String, String> tags) {
"""
The tags for the definition.
@param tags
The tags for the definition.
@return Returns a reference to this object so that method calls can be chained together.
"""
setTags(tags);
return this;
} | java | public GetCoreDefinitionResult withTags(java.util.Map<String, String> tags) {
setTags(tags);
return this;
} | [
"public",
"GetCoreDefinitionResult",
"withTags",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"setTags",
"(",
"tags",
")",
";",
"return",
"this",
";",
"}"
] | The tags for the definition.
@param tags
The tags for the definition.
@return Returns a reference to this object so that method calls can be chained together. | [
"The",
"tags",
"for",
"the",
"definition",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-greengrass/src/main/java/com/amazonaws/services/greengrass/model/GetCoreDefinitionResult.java#L310-L313 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/component/selectOneMenu/SelectOneMenuRenderer.java | SelectOneMenuRenderer.renderOptions | protected void renderOptions(FacesContext context, ResponseWriter rw, SelectOneMenu menu) throws IOException {
"""
Parts of this class are an adapted version of InputRenderer#getSelectItems()
of PrimeFaces 5.1.
@param rw
@throws IOException
"""
Converter converter = menu.getConverter();
List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);
SelectItemAndComponent selection = determineSelectedItem(context, menu, items, converter);
for (int index = 0; index < items.size(); index++) {
SelectItemAndComponent option = items.get(index);
if (option.getSelectItem().isNoSelectionOption() &&
menu.isHideNoSelectionOption() && selection != null)
continue;
renderOption(context, menu, rw, (option.getSelectItem()), index, option.getComponent(),
option == selection || (selection == null && option.getSelectItem().isNoSelectionOption()));
}
} | java | protected void renderOptions(FacesContext context, ResponseWriter rw, SelectOneMenu menu) throws IOException {
Converter converter = menu.getConverter();
List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);
SelectItemAndComponent selection = determineSelectedItem(context, menu, items, converter);
for (int index = 0; index < items.size(); index++) {
SelectItemAndComponent option = items.get(index);
if (option.getSelectItem().isNoSelectionOption() &&
menu.isHideNoSelectionOption() && selection != null)
continue;
renderOption(context, menu, rw, (option.getSelectItem()), index, option.getComponent(),
option == selection || (selection == null && option.getSelectItem().isNoSelectionOption()));
}
} | [
"protected",
"void",
"renderOptions",
"(",
"FacesContext",
"context",
",",
"ResponseWriter",
"rw",
",",
"SelectOneMenu",
"menu",
")",
"throws",
"IOException",
"{",
"Converter",
"converter",
"=",
"menu",
".",
"getConverter",
"(",
")",
";",
"List",
"<",
"SelectItemAndComponent",
">",
"items",
"=",
"SelectItemUtils",
".",
"collectOptions",
"(",
"context",
",",
"menu",
",",
"converter",
")",
";",
"SelectItemAndComponent",
"selection",
"=",
"determineSelectedItem",
"(",
"context",
",",
"menu",
",",
"items",
",",
"converter",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"items",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"SelectItemAndComponent",
"option",
"=",
"items",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"option",
".",
"getSelectItem",
"(",
")",
".",
"isNoSelectionOption",
"(",
")",
"&&",
"menu",
".",
"isHideNoSelectionOption",
"(",
")",
"&&",
"selection",
"!=",
"null",
")",
"continue",
";",
"renderOption",
"(",
"context",
",",
"menu",
",",
"rw",
",",
"(",
"option",
".",
"getSelectItem",
"(",
")",
")",
",",
"index",
",",
"option",
".",
"getComponent",
"(",
")",
",",
"option",
"==",
"selection",
"||",
"(",
"selection",
"==",
"null",
"&&",
"option",
".",
"getSelectItem",
"(",
")",
".",
"isNoSelectionOption",
"(",
")",
")",
")",
";",
"}",
"}"
] | Parts of this class are an adapted version of InputRenderer#getSelectItems()
of PrimeFaces 5.1.
@param rw
@throws IOException | [
"Parts",
"of",
"this",
"class",
"are",
"an",
"adapted",
"version",
"of",
"InputRenderer#getSelectItems",
"()",
"of",
"PrimeFaces",
"5",
".",
"1",
"."
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/selectOneMenu/SelectOneMenuRenderer.java#L357-L373 |
alkacon/opencms-core | src/org/opencms/ui/apps/searchindex/CmsSearchIndexTable.java | CmsSearchIndexTable.onItemClick | void onItemClick(MouseEvents.ClickEvent event, Object itemId, Object propertyId) {
"""
Handles the table item clicks, including clicks on images inside of a table item.<p>
@param event the click event
@param itemId of the clicked row
@param propertyId column id
"""
if (!event.isCtrlKey() && !event.isShiftKey()) {
changeValueIfNotMultiSelect(itemId);
// don't interfere with multi-selection using control key
if (event.getButton().equals(MouseButton.RIGHT) || (propertyId == null)) {
m_menu.setEntries(getMenuEntries(), getSearchIndexNames());
m_menu.openForTable(event, itemId, propertyId, this);
} else if (event.getButton().equals(MouseButton.LEFT) && TableProperty.Name.equals(propertyId)) {
showSourcesWindow(((I_CmsSearchIndex)((Set<?>)getValue()).iterator().next()).getName());
}
}
} | java | void onItemClick(MouseEvents.ClickEvent event, Object itemId, Object propertyId) {
if (!event.isCtrlKey() && !event.isShiftKey()) {
changeValueIfNotMultiSelect(itemId);
// don't interfere with multi-selection using control key
if (event.getButton().equals(MouseButton.RIGHT) || (propertyId == null)) {
m_menu.setEntries(getMenuEntries(), getSearchIndexNames());
m_menu.openForTable(event, itemId, propertyId, this);
} else if (event.getButton().equals(MouseButton.LEFT) && TableProperty.Name.equals(propertyId)) {
showSourcesWindow(((I_CmsSearchIndex)((Set<?>)getValue()).iterator().next()).getName());
}
}
} | [
"void",
"onItemClick",
"(",
"MouseEvents",
".",
"ClickEvent",
"event",
",",
"Object",
"itemId",
",",
"Object",
"propertyId",
")",
"{",
"if",
"(",
"!",
"event",
".",
"isCtrlKey",
"(",
")",
"&&",
"!",
"event",
".",
"isShiftKey",
"(",
")",
")",
"{",
"changeValueIfNotMultiSelect",
"(",
"itemId",
")",
";",
"// don't interfere with multi-selection using control key",
"if",
"(",
"event",
".",
"getButton",
"(",
")",
".",
"equals",
"(",
"MouseButton",
".",
"RIGHT",
")",
"||",
"(",
"propertyId",
"==",
"null",
")",
")",
"{",
"m_menu",
".",
"setEntries",
"(",
"getMenuEntries",
"(",
")",
",",
"getSearchIndexNames",
"(",
")",
")",
";",
"m_menu",
".",
"openForTable",
"(",
"event",
",",
"itemId",
",",
"propertyId",
",",
"this",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"getButton",
"(",
")",
".",
"equals",
"(",
"MouseButton",
".",
"LEFT",
")",
"&&",
"TableProperty",
".",
"Name",
".",
"equals",
"(",
"propertyId",
")",
")",
"{",
"showSourcesWindow",
"(",
"(",
"(",
"I_CmsSearchIndex",
")",
"(",
"(",
"Set",
"<",
"?",
">",
")",
"getValue",
"(",
")",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Handles the table item clicks, including clicks on images inside of a table item.<p>
@param event the click event
@param itemId of the clicked row
@param propertyId column id | [
"Handles",
"the",
"table",
"item",
"clicks",
"including",
"clicks",
"on",
"images",
"inside",
"of",
"a",
"table",
"item",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/searchindex/CmsSearchIndexTable.java#L387-L401 |
JOML-CI/JOML | src/org/joml/Vector3i.java | Vector3i.setComponent | public Vector3i setComponent(int component, int value) throws IllegalArgumentException {
"""
Set the value of the specified component of this vector.
@param component
the component whose value to set, within <code>[0..2]</code>
@param value
the value to set
@return this
@throws IllegalArgumentException if <code>component</code> is not within <code>[0..2]</code>
"""
switch (component) {
case 0:
x = value;
break;
case 1:
y = value;
break;
case 2:
z = value;
break;
default:
throw new IllegalArgumentException();
}
return this;
} | java | public Vector3i setComponent(int component, int value) throws IllegalArgumentException {
switch (component) {
case 0:
x = value;
break;
case 1:
y = value;
break;
case 2:
z = value;
break;
default:
throw new IllegalArgumentException();
}
return this;
} | [
"public",
"Vector3i",
"setComponent",
"(",
"int",
"component",
",",
"int",
"value",
")",
"throws",
"IllegalArgumentException",
"{",
"switch",
"(",
"component",
")",
"{",
"case",
"0",
":",
"x",
"=",
"value",
";",
"break",
";",
"case",
"1",
":",
"y",
"=",
"value",
";",
"break",
";",
"case",
"2",
":",
"z",
"=",
"value",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Set the value of the specified component of this vector.
@param component
the component whose value to set, within <code>[0..2]</code>
@param value
the value to set
@return this
@throws IllegalArgumentException if <code>component</code> is not within <code>[0..2]</code> | [
"Set",
"the",
"value",
"of",
"the",
"specified",
"component",
"of",
"this",
"vector",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Vector3i.java#L417-L432 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java | BaseXmlParser.addProperties | protected void addProperties(Element element, BeanDefinitionBuilder builder) {
"""
Adds all attributes of the specified elements as properties in the current builder.
@param element Element whose attributes are to be added.
@param builder Target builder.
"""
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node node = attributes.item(i);
String attrName = getNodeName(node);
attrName = "class".equals(attrName) ? "clazz" : attrName;
builder.addPropertyValue(attrName, node.getNodeValue());
}
} | java | protected void addProperties(Element element, BeanDefinitionBuilder builder) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node node = attributes.item(i);
String attrName = getNodeName(node);
attrName = "class".equals(attrName) ? "clazz" : attrName;
builder.addPropertyValue(attrName, node.getNodeValue());
}
} | [
"protected",
"void",
"addProperties",
"(",
"Element",
"element",
",",
"BeanDefinitionBuilder",
"builder",
")",
"{",
"NamedNodeMap",
"attributes",
"=",
"element",
".",
"getAttributes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attributes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"node",
"=",
"attributes",
".",
"item",
"(",
"i",
")",
";",
"String",
"attrName",
"=",
"getNodeName",
"(",
"node",
")",
";",
"attrName",
"=",
"\"class\"",
".",
"equals",
"(",
"attrName",
")",
"?",
"\"clazz\"",
":",
"attrName",
";",
"builder",
".",
"addPropertyValue",
"(",
"attrName",
",",
"node",
".",
"getNodeValue",
"(",
")",
")",
";",
"}",
"}"
] | Adds all attributes of the specified elements as properties in the current builder.
@param element Element whose attributes are to be added.
@param builder Target builder. | [
"Adds",
"all",
"attributes",
"of",
"the",
"specified",
"elements",
"as",
"properties",
"in",
"the",
"current",
"builder",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/spring/BaseXmlParser.java#L93-L102 |
apptik/jus | android/jus-android/src/main/java/io/apptik/comm/jus/ui/NetworkImageView.java | NetworkImageView.setImageUrl | public void setImageUrl(String url, ImageLoader imageLoader) {
"""
Sets URL of the image that should be loaded into this view. Note that calling this will
immediately either set the cached image (if available) or the default image specified by
{@link NetworkImageView#setDefaultImageResId(int)} on the view.
<p/>
NOTE: If applicable, {@link NetworkImageView#setDefaultImageResId(int)} and
{@link NetworkImageView#setErrorImageResId(int)} should be called prior to calling
this function.
@param url The URL that should be loaded into this ImageView.
@param imageLoader ImageLoader that will be used to make the request.
"""
this.url = url;
this.imageLoader = imageLoader;
if (this.imageLoader.getDefaultImageId() != 0) {
defaultImageId = this.imageLoader.getDefaultImageId();
}
if (this.imageLoader.getErrorImageId() != 0) {
errorImageId = this.imageLoader.getErrorImageId();
}
// The URL has potentially changed. See if we need to load it.
loadImageIfNecessary(false);
} | java | public void setImageUrl(String url, ImageLoader imageLoader) {
this.url = url;
this.imageLoader = imageLoader;
if (this.imageLoader.getDefaultImageId() != 0) {
defaultImageId = this.imageLoader.getDefaultImageId();
}
if (this.imageLoader.getErrorImageId() != 0) {
errorImageId = this.imageLoader.getErrorImageId();
}
// The URL has potentially changed. See if we need to load it.
loadImageIfNecessary(false);
} | [
"public",
"void",
"setImageUrl",
"(",
"String",
"url",
",",
"ImageLoader",
"imageLoader",
")",
"{",
"this",
".",
"url",
"=",
"url",
";",
"this",
".",
"imageLoader",
"=",
"imageLoader",
";",
"if",
"(",
"this",
".",
"imageLoader",
".",
"getDefaultImageId",
"(",
")",
"!=",
"0",
")",
"{",
"defaultImageId",
"=",
"this",
".",
"imageLoader",
".",
"getDefaultImageId",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"imageLoader",
".",
"getErrorImageId",
"(",
")",
"!=",
"0",
")",
"{",
"errorImageId",
"=",
"this",
".",
"imageLoader",
".",
"getErrorImageId",
"(",
")",
";",
"}",
"// The URL has potentially changed. See if we need to load it.",
"loadImageIfNecessary",
"(",
"false",
")",
";",
"}"
] | Sets URL of the image that should be loaded into this view. Note that calling this will
immediately either set the cached image (if available) or the default image specified by
{@link NetworkImageView#setDefaultImageResId(int)} on the view.
<p/>
NOTE: If applicable, {@link NetworkImageView#setDefaultImageResId(int)} and
{@link NetworkImageView#setErrorImageResId(int)} should be called prior to calling
this function.
@param url The URL that should be loaded into this ImageView.
@param imageLoader ImageLoader that will be used to make the request. | [
"Sets",
"URL",
"of",
"the",
"image",
"that",
"should",
"be",
"loaded",
"into",
"this",
"view",
".",
"Note",
"that",
"calling",
"this",
"will",
"immediately",
"either",
"set",
"the",
"cached",
"image",
"(",
"if",
"available",
")",
"or",
"the",
"default",
"image",
"specified",
"by",
"{",
"@link",
"NetworkImageView#setDefaultImageResId",
"(",
"int",
")",
"}",
"on",
"the",
"view",
".",
"<p",
"/",
">",
"NOTE",
":",
"If",
"applicable",
"{",
"@link",
"NetworkImageView#setDefaultImageResId",
"(",
"int",
")",
"}",
"and",
"{",
"@link",
"NetworkImageView#setErrorImageResId",
"(",
"int",
")",
"}",
"should",
"be",
"called",
"prior",
"to",
"calling",
"this",
"function",
"."
] | train | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/android/jus-android/src/main/java/io/apptik/comm/jus/ui/NetworkImageView.java#L111-L122 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java | PathNormalizer.addGetParameter | public static String addGetParameter(String path, String parameterKey, String parameter) {
"""
Adds a key and value to the request path & or ? will be used as needed
path + ? or & + parameterKey=parameter
@param path
the url to add the parameterKey and parameter too
@param parameterKey
the key in the get request (parameterKey=parameter)
@param parameter
the parameter to add to the end of the url
@return a String with the url parameter added: path + ? or & +
parameterKey=parameter
"""
StringBuilder sb = new StringBuilder(path);
if (path.indexOf("?") > 0) {
sb.append("&");
} else {
sb.append("?");
}
sb.append(parameterKey).append("=").append(parameter);
return sb.toString();
} | java | public static String addGetParameter(String path, String parameterKey, String parameter) {
StringBuilder sb = new StringBuilder(path);
if (path.indexOf("?") > 0) {
sb.append("&");
} else {
sb.append("?");
}
sb.append(parameterKey).append("=").append(parameter);
return sb.toString();
} | [
"public",
"static",
"String",
"addGetParameter",
"(",
"String",
"path",
",",
"String",
"parameterKey",
",",
"String",
"parameter",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"path",
")",
";",
"if",
"(",
"path",
".",
"indexOf",
"(",
"\"?\"",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\"&\"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"?\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"parameterKey",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"parameter",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Adds a key and value to the request path & or ? will be used as needed
path + ? or & + parameterKey=parameter
@param path
the url to add the parameterKey and parameter too
@param parameterKey
the key in the get request (parameterKey=parameter)
@param parameter
the parameter to add to the end of the url
@return a String with the url parameter added: path + ? or & +
parameterKey=parameter | [
"Adds",
"a",
"key",
"and",
"value",
"to",
"the",
"request",
"path",
"&",
"or",
"?",
"will",
"be",
"used",
"as",
"needed"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L437-L446 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/CmsErrorDialog.java | CmsErrorDialog.handleException | public static void handleException(Throwable t) {
"""
Handles the exception by logging the exception to the server log and displaying an error dialog on the client.<p>
@param t the throwable
"""
String message;
StackTraceElement[] trace;
String cause = null;
String className;
if (t instanceof CmsRpcException) {
CmsRpcException ex = (CmsRpcException)t;
message = ex.getOriginalMessage();
trace = ex.getOriginalStackTrace();
cause = ex.getOriginalCauseMessage();
className = ex.getOriginalClassName();
} else {
message = CmsClientStringUtil.getMessage(t);
trace = t.getStackTrace();
if (t.getCause() != null) {
cause = CmsClientStringUtil.getMessage(t.getCause());
}
className = t.getClass().getName();
}
// send the ticket to the server
String ticket = CmsLog.log(message + LINE_BREAK + CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK));
String errorMessage = message == null
? className + ": " + Messages.get().key(Messages.GUI_NO_DESCIPTION_0)
: message;
if (cause != null) {
errorMessage += LINE_BREAK + Messages.get().key(Messages.GUI_REASON_0) + ":" + cause;
}
String details = Messages.get().key(Messages.GUI_TICKET_MESSAGE_3, ticket, className, message)
+ CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK);
new CmsErrorDialog(errorMessage, details).center();
} | java | public static void handleException(Throwable t) {
String message;
StackTraceElement[] trace;
String cause = null;
String className;
if (t instanceof CmsRpcException) {
CmsRpcException ex = (CmsRpcException)t;
message = ex.getOriginalMessage();
trace = ex.getOriginalStackTrace();
cause = ex.getOriginalCauseMessage();
className = ex.getOriginalClassName();
} else {
message = CmsClientStringUtil.getMessage(t);
trace = t.getStackTrace();
if (t.getCause() != null) {
cause = CmsClientStringUtil.getMessage(t.getCause());
}
className = t.getClass().getName();
}
// send the ticket to the server
String ticket = CmsLog.log(message + LINE_BREAK + CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK));
String errorMessage = message == null
? className + ": " + Messages.get().key(Messages.GUI_NO_DESCIPTION_0)
: message;
if (cause != null) {
errorMessage += LINE_BREAK + Messages.get().key(Messages.GUI_REASON_0) + ":" + cause;
}
String details = Messages.get().key(Messages.GUI_TICKET_MESSAGE_3, ticket, className, message)
+ CmsClientStringUtil.getStackTraceAsString(trace, LINE_BREAK);
new CmsErrorDialog(errorMessage, details).center();
} | [
"public",
"static",
"void",
"handleException",
"(",
"Throwable",
"t",
")",
"{",
"String",
"message",
";",
"StackTraceElement",
"[",
"]",
"trace",
";",
"String",
"cause",
"=",
"null",
";",
"String",
"className",
";",
"if",
"(",
"t",
"instanceof",
"CmsRpcException",
")",
"{",
"CmsRpcException",
"ex",
"=",
"(",
"CmsRpcException",
")",
"t",
";",
"message",
"=",
"ex",
".",
"getOriginalMessage",
"(",
")",
";",
"trace",
"=",
"ex",
".",
"getOriginalStackTrace",
"(",
")",
";",
"cause",
"=",
"ex",
".",
"getOriginalCauseMessage",
"(",
")",
";",
"className",
"=",
"ex",
".",
"getOriginalClassName",
"(",
")",
";",
"}",
"else",
"{",
"message",
"=",
"CmsClientStringUtil",
".",
"getMessage",
"(",
"t",
")",
";",
"trace",
"=",
"t",
".",
"getStackTrace",
"(",
")",
";",
"if",
"(",
"t",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"cause",
"=",
"CmsClientStringUtil",
".",
"getMessage",
"(",
"t",
".",
"getCause",
"(",
")",
")",
";",
"}",
"className",
"=",
"t",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"}",
"// send the ticket to the server",
"String",
"ticket",
"=",
"CmsLog",
".",
"log",
"(",
"message",
"+",
"LINE_BREAK",
"+",
"CmsClientStringUtil",
".",
"getStackTraceAsString",
"(",
"trace",
",",
"LINE_BREAK",
")",
")",
";",
"String",
"errorMessage",
"=",
"message",
"==",
"null",
"?",
"className",
"+",
"\": \"",
"+",
"Messages",
".",
"get",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_NO_DESCIPTION_0",
")",
":",
"message",
";",
"if",
"(",
"cause",
"!=",
"null",
")",
"{",
"errorMessage",
"+=",
"LINE_BREAK",
"+",
"Messages",
".",
"get",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_REASON_0",
")",
"+",
"\":\"",
"+",
"cause",
";",
"}",
"String",
"details",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"GUI_TICKET_MESSAGE_3",
",",
"ticket",
",",
"className",
",",
"message",
")",
"+",
"CmsClientStringUtil",
".",
"getStackTraceAsString",
"(",
"trace",
",",
"LINE_BREAK",
")",
";",
"new",
"CmsErrorDialog",
"(",
"errorMessage",
",",
"details",
")",
".",
"center",
"(",
")",
";",
"}"
] | Handles the exception by logging the exception to the server log and displaying an error dialog on the client.<p>
@param t the throwable | [
"Handles",
"the",
"exception",
"by",
"logging",
"the",
"exception",
"to",
"the",
"server",
"log",
"and",
"displaying",
"an",
"error",
"dialog",
"on",
"the",
"client",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/CmsErrorDialog.java#L196-L229 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java | AbstractIndexWriter.addDescription | protected void addDescription(MemberDoc member, Content dlTree, SearchIndexItem si) {
"""
Add description for Class, Field, Method or Constructor.
@param member MemberDoc for the member of the Class Kind
@param dlTree the content tree to which the description will be added
"""
String name = (member instanceof ExecutableMemberDoc)?
member.name() + ((ExecutableMemberDoc)member).flatSignature() :
member.name();
si.setContainingPackage(utils.getPackageName((member.containingClass()).containingPackage()));
si.setContainingClass((member.containingClass()).typeName());
if (member instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
si.setLabel(member.name() + emd.flatSignature());
if (!((emd.signature()).equals(emd.flatSignature()))) {
si.setUrl(getName(getAnchor((ExecutableMemberDoc) member)));
}
} else {
si.setLabel(member.name());
}
si.setCategory(getResource("doclet.Members").toString());
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
Content dt = HtmlTree.DT(span);
dt.addContent(" - ");
addMemberDesc(member, dt);
dlTree.addContent(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(member, dd);
dlTree.addContent(dd);
} | java | protected void addDescription(MemberDoc member, Content dlTree, SearchIndexItem si) {
String name = (member instanceof ExecutableMemberDoc)?
member.name() + ((ExecutableMemberDoc)member).flatSignature() :
member.name();
si.setContainingPackage(utils.getPackageName((member.containingClass()).containingPackage()));
si.setContainingClass((member.containingClass()).typeName());
if (member instanceof ExecutableMemberDoc) {
ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
si.setLabel(member.name() + emd.flatSignature());
if (!((emd.signature()).equals(emd.flatSignature()))) {
si.setUrl(getName(getAnchor((ExecutableMemberDoc) member)));
}
} else {
si.setLabel(member.name());
}
si.setCategory(getResource("doclet.Members").toString());
Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
Content dt = HtmlTree.DT(span);
dt.addContent(" - ");
addMemberDesc(member, dt);
dlTree.addContent(dt);
Content dd = new HtmlTree(HtmlTag.DD);
addComment(member, dd);
dlTree.addContent(dd);
} | [
"protected",
"void",
"addDescription",
"(",
"MemberDoc",
"member",
",",
"Content",
"dlTree",
",",
"SearchIndexItem",
"si",
")",
"{",
"String",
"name",
"=",
"(",
"member",
"instanceof",
"ExecutableMemberDoc",
")",
"?",
"member",
".",
"name",
"(",
")",
"+",
"(",
"(",
"ExecutableMemberDoc",
")",
"member",
")",
".",
"flatSignature",
"(",
")",
":",
"member",
".",
"name",
"(",
")",
";",
"si",
".",
"setContainingPackage",
"(",
"utils",
".",
"getPackageName",
"(",
"(",
"member",
".",
"containingClass",
"(",
")",
")",
".",
"containingPackage",
"(",
")",
")",
")",
";",
"si",
".",
"setContainingClass",
"(",
"(",
"member",
".",
"containingClass",
"(",
")",
")",
".",
"typeName",
"(",
")",
")",
";",
"if",
"(",
"member",
"instanceof",
"ExecutableMemberDoc",
")",
"{",
"ExecutableMemberDoc",
"emd",
"=",
"(",
"ExecutableMemberDoc",
")",
"member",
";",
"si",
".",
"setLabel",
"(",
"member",
".",
"name",
"(",
")",
"+",
"emd",
".",
"flatSignature",
"(",
")",
")",
";",
"if",
"(",
"!",
"(",
"(",
"emd",
".",
"signature",
"(",
")",
")",
".",
"equals",
"(",
"emd",
".",
"flatSignature",
"(",
")",
")",
")",
")",
"{",
"si",
".",
"setUrl",
"(",
"getName",
"(",
"getAnchor",
"(",
"(",
"ExecutableMemberDoc",
")",
"member",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"si",
".",
"setLabel",
"(",
"member",
".",
"name",
"(",
")",
")",
";",
"}",
"si",
".",
"setCategory",
"(",
"getResource",
"(",
"\"doclet.Members\"",
")",
".",
"toString",
"(",
")",
")",
";",
"Content",
"span",
"=",
"HtmlTree",
".",
"SPAN",
"(",
"HtmlStyle",
".",
"memberNameLink",
",",
"getDocLink",
"(",
"LinkInfoImpl",
".",
"Kind",
".",
"INDEX",
",",
"member",
",",
"name",
")",
")",
";",
"Content",
"dt",
"=",
"HtmlTree",
".",
"DT",
"(",
"span",
")",
";",
"dt",
".",
"addContent",
"(",
"\" - \"",
")",
";",
"addMemberDesc",
"(",
"member",
",",
"dt",
")",
";",
"dlTree",
".",
"addContent",
"(",
"dt",
")",
";",
"Content",
"dd",
"=",
"new",
"HtmlTree",
"(",
"HtmlTag",
".",
"DD",
")",
";",
"addComment",
"(",
"member",
",",
"dd",
")",
";",
"dlTree",
".",
"addContent",
"(",
"dd",
")",
";",
"}"
] | Add description for Class, Field, Method or Constructor.
@param member MemberDoc for the member of the Class Kind
@param dlTree the content tree to which the description will be added | [
"Add",
"description",
"for",
"Class",
"Field",
"Method",
"or",
"Constructor",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java#L243-L268 |
cloudant/java-cloudant | cloudant-client/src/main/java/com/cloudant/client/org/lightcouch/CouchDatabaseBase.java | CouchDatabaseBase.invokeUpdateHandler | public String invokeUpdateHandler(String updateHandlerUri, String docId, Params params) {
"""
Invokes an Update Handler.
<pre>
Params params = new Params()
.addParam("field", "foo")
.addParam("value", "bar");
String output = dbClient.invokeUpdateHandler("designDoc/update1", "docId", params);
</pre>
@param updateHandlerUri The Update Handler URI, in the format: <code>designDoc/update1</code>
@param docId The document id to update.
@param params The query parameters as {@link Params}.
@return The output of the request.
"""
assertNotEmpty(updateHandlerUri, "uri");
final String[] v = updateHandlerUri.split("/");
final InputStream response;
final URI uri;
DatabaseURIHelper uriHelper = new DatabaseURIHelper(dbUri).path("_design").path(v[0])
.path("_update").path(v[1]).query(params);
if (docId != null && !docId.isEmpty()) {
//Create PUT request using doc Id
uri = uriHelper.path(docId).build();
response = couchDbClient.put(uri);
} else {
//If no doc Id, create POST request
uri = uriHelper.build();
response = couchDbClient.post(uri, null);
}
return streamToString(response);
} | java | public String invokeUpdateHandler(String updateHandlerUri, String docId, Params params) {
assertNotEmpty(updateHandlerUri, "uri");
final String[] v = updateHandlerUri.split("/");
final InputStream response;
final URI uri;
DatabaseURIHelper uriHelper = new DatabaseURIHelper(dbUri).path("_design").path(v[0])
.path("_update").path(v[1]).query(params);
if (docId != null && !docId.isEmpty()) {
//Create PUT request using doc Id
uri = uriHelper.path(docId).build();
response = couchDbClient.put(uri);
} else {
//If no doc Id, create POST request
uri = uriHelper.build();
response = couchDbClient.post(uri, null);
}
return streamToString(response);
} | [
"public",
"String",
"invokeUpdateHandler",
"(",
"String",
"updateHandlerUri",
",",
"String",
"docId",
",",
"Params",
"params",
")",
"{",
"assertNotEmpty",
"(",
"updateHandlerUri",
",",
"\"uri\"",
")",
";",
"final",
"String",
"[",
"]",
"v",
"=",
"updateHandlerUri",
".",
"split",
"(",
"\"/\"",
")",
";",
"final",
"InputStream",
"response",
";",
"final",
"URI",
"uri",
";",
"DatabaseURIHelper",
"uriHelper",
"=",
"new",
"DatabaseURIHelper",
"(",
"dbUri",
")",
".",
"path",
"(",
"\"_design\"",
")",
".",
"path",
"(",
"v",
"[",
"0",
"]",
")",
".",
"path",
"(",
"\"_update\"",
")",
".",
"path",
"(",
"v",
"[",
"1",
"]",
")",
".",
"query",
"(",
"params",
")",
";",
"if",
"(",
"docId",
"!=",
"null",
"&&",
"!",
"docId",
".",
"isEmpty",
"(",
")",
")",
"{",
"//Create PUT request using doc Id",
"uri",
"=",
"uriHelper",
".",
"path",
"(",
"docId",
")",
".",
"build",
"(",
")",
";",
"response",
"=",
"couchDbClient",
".",
"put",
"(",
"uri",
")",
";",
"}",
"else",
"{",
"//If no doc Id, create POST request",
"uri",
"=",
"uriHelper",
".",
"build",
"(",
")",
";",
"response",
"=",
"couchDbClient",
".",
"post",
"(",
"uri",
",",
"null",
")",
";",
"}",
"return",
"streamToString",
"(",
"response",
")",
";",
"}"
] | Invokes an Update Handler.
<pre>
Params params = new Params()
.addParam("field", "foo")
.addParam("value", "bar");
String output = dbClient.invokeUpdateHandler("designDoc/update1", "docId", params);
</pre>
@param updateHandlerUri The Update Handler URI, in the format: <code>designDoc/update1</code>
@param docId The document id to update.
@param params The query parameters as {@link Params}.
@return The output of the request. | [
"Invokes",
"an",
"Update",
"Handler",
".",
"<pre",
">",
"Params",
"params",
"=",
"new",
"Params",
"()",
".",
"addParam",
"(",
"field",
"foo",
")",
".",
"addParam",
"(",
"value",
"bar",
")",
";",
"String",
"output",
"=",
"dbClient",
".",
"invokeUpdateHandler",
"(",
"designDoc",
"/",
"update1",
"docId",
"params",
")",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/cloudant/java-cloudant/blob/42c438654945361bded2cc0827afc046d535b31b/cloudant-client/src/main/java/com/cloudant/client/org/lightcouch/CouchDatabaseBase.java#L433-L450 |
pravega/pravega | client/src/main/java/io/pravega/client/netty/impl/FlowHandler.java | FlowHandler.createFlow | public ClientConnection createFlow(final Flow flow, final ReplyProcessor rp) {
"""
Create a flow on existing connection.
@param flow Flow.
@param rp ReplyProcessor for the specified flow.
@return Client Connection object.
"""
Exceptions.checkNotClosed(closed.get(), this);
Preconditions.checkState(!disableFlow.get(), "Ensure flows are enabled.");
log.info("Creating Flow {} for endpoint {}. The current Channel is {}.", flow.getFlowId(), connectionName, channel.get());
if (flowIdReplyProcessorMap.put(flow.getFlowId(), rp) != null) {
throw new IllegalArgumentException("Multiple flows cannot be created with the same Flow id " + flow.getFlowId());
}
return new ClientConnectionImpl(connectionName, flow.getFlowId(), batchSizeTracker, this);
} | java | public ClientConnection createFlow(final Flow flow, final ReplyProcessor rp) {
Exceptions.checkNotClosed(closed.get(), this);
Preconditions.checkState(!disableFlow.get(), "Ensure flows are enabled.");
log.info("Creating Flow {} for endpoint {}. The current Channel is {}.", flow.getFlowId(), connectionName, channel.get());
if (flowIdReplyProcessorMap.put(flow.getFlowId(), rp) != null) {
throw new IllegalArgumentException("Multiple flows cannot be created with the same Flow id " + flow.getFlowId());
}
return new ClientConnectionImpl(connectionName, flow.getFlowId(), batchSizeTracker, this);
} | [
"public",
"ClientConnection",
"createFlow",
"(",
"final",
"Flow",
"flow",
",",
"final",
"ReplyProcessor",
"rp",
")",
"{",
"Exceptions",
".",
"checkNotClosed",
"(",
"closed",
".",
"get",
"(",
")",
",",
"this",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"disableFlow",
".",
"get",
"(",
")",
",",
"\"Ensure flows are enabled.\"",
")",
";",
"log",
".",
"info",
"(",
"\"Creating Flow {} for endpoint {}. The current Channel is {}.\"",
",",
"flow",
".",
"getFlowId",
"(",
")",
",",
"connectionName",
",",
"channel",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"flowIdReplyProcessorMap",
".",
"put",
"(",
"flow",
".",
"getFlowId",
"(",
")",
",",
"rp",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Multiple flows cannot be created with the same Flow id \"",
"+",
"flow",
".",
"getFlowId",
"(",
")",
")",
";",
"}",
"return",
"new",
"ClientConnectionImpl",
"(",
"connectionName",
",",
"flow",
".",
"getFlowId",
"(",
")",
",",
"batchSizeTracker",
",",
"this",
")",
";",
"}"
] | Create a flow on existing connection.
@param flow Flow.
@param rp ReplyProcessor for the specified flow.
@return Client Connection object. | [
"Create",
"a",
"flow",
"on",
"existing",
"connection",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/client/src/main/java/io/pravega/client/netty/impl/FlowHandler.java#L64-L72 |
google/closure-compiler | src/com/google/javascript/jscomp/DotFormatter.java | DotFormatter.appendDot | static void appendDot(Node n, ControlFlowGraph<Node> inCFG,
Appendable builder) throws IOException {
"""
Converts an AST to dot representation and appends it to the given buffer.
@param n the root of the AST described in the dot formatted string
@param inCFG Control Flow Graph.
@param builder A place to dump the graph.
"""
new DotFormatter(n, inCFG, builder, false);
} | java | static void appendDot(Node n, ControlFlowGraph<Node> inCFG,
Appendable builder) throws IOException {
new DotFormatter(n, inCFG, builder, false);
} | [
"static",
"void",
"appendDot",
"(",
"Node",
"n",
",",
"ControlFlowGraph",
"<",
"Node",
">",
"inCFG",
",",
"Appendable",
"builder",
")",
"throws",
"IOException",
"{",
"new",
"DotFormatter",
"(",
"n",
",",
"inCFG",
",",
"builder",
",",
"false",
")",
";",
"}"
] | Converts an AST to dot representation and appends it to the given buffer.
@param n the root of the AST described in the dot formatted string
@param inCFG Control Flow Graph.
@param builder A place to dump the graph. | [
"Converts",
"an",
"AST",
"to",
"dot",
"representation",
"and",
"appends",
"it",
"to",
"the",
"given",
"buffer",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DotFormatter.java#L170-L173 |
VoltDB/voltdb | src/frontend/org/voltdb/compiler/VoltDDLElementTracker.java | VoltDDLElementTracker.removeProcedure | public void removeProcedure(String procName, boolean ifExists) throws VoltCompilerException {
"""
Searches for and removes the Procedure provided in prior DDL statements
@param Name of procedure being removed
@throws VoltCompilerException if the procedure does not exist
"""
assert procName != null && ! procName.trim().isEmpty();
String shortName = deriveShortProcedureName(procName);
if( m_procedureMap.containsKey(shortName)) {
m_procedureMap.remove(shortName);
}
else if (!ifExists) {
throw m_compiler.new VoltCompilerException(String.format(
"Dropped Procedure \"%s\" is not defined", procName));
}
} | java | public void removeProcedure(String procName, boolean ifExists) throws VoltCompilerException
{
assert procName != null && ! procName.trim().isEmpty();
String shortName = deriveShortProcedureName(procName);
if( m_procedureMap.containsKey(shortName)) {
m_procedureMap.remove(shortName);
}
else if (!ifExists) {
throw m_compiler.new VoltCompilerException(String.format(
"Dropped Procedure \"%s\" is not defined", procName));
}
} | [
"public",
"void",
"removeProcedure",
"(",
"String",
"procName",
",",
"boolean",
"ifExists",
")",
"throws",
"VoltCompilerException",
"{",
"assert",
"procName",
"!=",
"null",
"&&",
"!",
"procName",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
";",
"String",
"shortName",
"=",
"deriveShortProcedureName",
"(",
"procName",
")",
";",
"if",
"(",
"m_procedureMap",
".",
"containsKey",
"(",
"shortName",
")",
")",
"{",
"m_procedureMap",
".",
"remove",
"(",
"shortName",
")",
";",
"}",
"else",
"if",
"(",
"!",
"ifExists",
")",
"{",
"throw",
"m_compiler",
".",
"new",
"VoltCompilerException",
"(",
"String",
".",
"format",
"(",
"\"Dropped Procedure \\\"%s\\\" is not defined\"",
",",
"procName",
")",
")",
";",
"}",
"}"
] | Searches for and removes the Procedure provided in prior DDL statements
@param Name of procedure being removed
@throws VoltCompilerException if the procedure does not exist | [
"Searches",
"for",
"and",
"removes",
"the",
"Procedure",
"provided",
"in",
"prior",
"DDL",
"statements"
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/compiler/VoltDDLElementTracker.java#L129-L142 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/cache/cachepolicy_binding.java | cachepolicy_binding.get | public static cachepolicy_binding get(nitro_service service, String policyname) throws Exception {
"""
Use this API to fetch cachepolicy_binding resource of given name .
"""
cachepolicy_binding obj = new cachepolicy_binding();
obj.set_policyname(policyname);
cachepolicy_binding response = (cachepolicy_binding) obj.get_resource(service);
return response;
} | java | public static cachepolicy_binding get(nitro_service service, String policyname) throws Exception{
cachepolicy_binding obj = new cachepolicy_binding();
obj.set_policyname(policyname);
cachepolicy_binding response = (cachepolicy_binding) obj.get_resource(service);
return response;
} | [
"public",
"static",
"cachepolicy_binding",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"policyname",
")",
"throws",
"Exception",
"{",
"cachepolicy_binding",
"obj",
"=",
"new",
"cachepolicy_binding",
"(",
")",
";",
"obj",
".",
"set_policyname",
"(",
"policyname",
")",
";",
"cachepolicy_binding",
"response",
"=",
"(",
"cachepolicy_binding",
")",
"obj",
".",
"get_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch cachepolicy_binding resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"cachepolicy_binding",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/cache/cachepolicy_binding.java#L136-L141 |
square/android-times-square | library/src/main/java/com/squareup/timessquare/CalendarPickerView.java | CalendarPickerView.getMonthCellWithIndexByDate | private MonthCellWithMonthIndex getMonthCellWithIndexByDate(Date date) {
"""
Return cell and month-index (for scrolling) for a given Date.
"""
Calendar searchCal = Calendar.getInstance(timeZone, locale);
searchCal.setTime(date);
String monthKey = monthKey(searchCal);
Calendar actCal = Calendar.getInstance(timeZone, locale);
int index = cells.getIndexOfKey(monthKey);
List<List<MonthCellDescriptor>> monthCells = cells.get(monthKey);
for (List<MonthCellDescriptor> weekCells : monthCells) {
for (MonthCellDescriptor actCell : weekCells) {
actCal.setTime(actCell.getDate());
if (sameDate(actCal, searchCal) && actCell.isSelectable()) {
return new MonthCellWithMonthIndex(actCell, index);
}
}
}
return null;
} | java | private MonthCellWithMonthIndex getMonthCellWithIndexByDate(Date date) {
Calendar searchCal = Calendar.getInstance(timeZone, locale);
searchCal.setTime(date);
String monthKey = monthKey(searchCal);
Calendar actCal = Calendar.getInstance(timeZone, locale);
int index = cells.getIndexOfKey(monthKey);
List<List<MonthCellDescriptor>> monthCells = cells.get(monthKey);
for (List<MonthCellDescriptor> weekCells : monthCells) {
for (MonthCellDescriptor actCell : weekCells) {
actCal.setTime(actCell.getDate());
if (sameDate(actCal, searchCal) && actCell.isSelectable()) {
return new MonthCellWithMonthIndex(actCell, index);
}
}
}
return null;
} | [
"private",
"MonthCellWithMonthIndex",
"getMonthCellWithIndexByDate",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"searchCal",
"=",
"Calendar",
".",
"getInstance",
"(",
"timeZone",
",",
"locale",
")",
";",
"searchCal",
".",
"setTime",
"(",
"date",
")",
";",
"String",
"monthKey",
"=",
"monthKey",
"(",
"searchCal",
")",
";",
"Calendar",
"actCal",
"=",
"Calendar",
".",
"getInstance",
"(",
"timeZone",
",",
"locale",
")",
";",
"int",
"index",
"=",
"cells",
".",
"getIndexOfKey",
"(",
"monthKey",
")",
";",
"List",
"<",
"List",
"<",
"MonthCellDescriptor",
">",
">",
"monthCells",
"=",
"cells",
".",
"get",
"(",
"monthKey",
")",
";",
"for",
"(",
"List",
"<",
"MonthCellDescriptor",
">",
"weekCells",
":",
"monthCells",
")",
"{",
"for",
"(",
"MonthCellDescriptor",
"actCell",
":",
"weekCells",
")",
"{",
"actCal",
".",
"setTime",
"(",
"actCell",
".",
"getDate",
"(",
")",
")",
";",
"if",
"(",
"sameDate",
"(",
"actCal",
",",
"searchCal",
")",
"&&",
"actCell",
".",
"isSelectable",
"(",
")",
")",
"{",
"return",
"new",
"MonthCellWithMonthIndex",
"(",
"actCell",
",",
"index",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Return cell and month-index (for scrolling) for a given Date. | [
"Return",
"cell",
"and",
"month",
"-",
"index",
"(",
"for",
"scrolling",
")",
"for",
"a",
"given",
"Date",
"."
] | train | https://github.com/square/android-times-square/blob/83b08e7cc220d587845054cd1471a604d17721f6/library/src/main/java/com/squareup/timessquare/CalendarPickerView.java#L861-L878 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/util/logging/ExceptionLogger.java | ExceptionLogger.getConsumer | @SafeVarargs
public static Consumer<Throwable> getConsumer(Class<? extends Throwable>... ignoredThrowableTypes) {
"""
Returns a consumer that can for example be used in the {@link TextChannel#typeContinuously(Consumer)} method.
It unwraps {@link CompletionException CompletionExceptions},
{@link InvocationTargetException InvocationTargetExceptions} and {@link ExecutionException ExecutionExceptions}
first, and then adds a fresh {@code CompletionException} as wrapper with the stacktrace of the caller of this
method and logs it afterwards.
The rewrapped exception is only logged if it is not in the {@code ignoredThrowableTypes}.
@param ignoredThrowableTypes The throwable types that should never be logged.
@return A consumer which logs the given throwable.
"""
return getConsumer(null, ignoredThrowableTypes);
} | java | @SafeVarargs
public static Consumer<Throwable> getConsumer(Class<? extends Throwable>... ignoredThrowableTypes) {
return getConsumer(null, ignoredThrowableTypes);
} | [
"@",
"SafeVarargs",
"public",
"static",
"Consumer",
"<",
"Throwable",
">",
"getConsumer",
"(",
"Class",
"<",
"?",
"extends",
"Throwable",
">",
"...",
"ignoredThrowableTypes",
")",
"{",
"return",
"getConsumer",
"(",
"null",
",",
"ignoredThrowableTypes",
")",
";",
"}"
] | Returns a consumer that can for example be used in the {@link TextChannel#typeContinuously(Consumer)} method.
It unwraps {@link CompletionException CompletionExceptions},
{@link InvocationTargetException InvocationTargetExceptions} and {@link ExecutionException ExecutionExceptions}
first, and then adds a fresh {@code CompletionException} as wrapper with the stacktrace of the caller of this
method and logs it afterwards.
The rewrapped exception is only logged if it is not in the {@code ignoredThrowableTypes}.
@param ignoredThrowableTypes The throwable types that should never be logged.
@return A consumer which logs the given throwable. | [
"Returns",
"a",
"consumer",
"that",
"can",
"for",
"example",
"be",
"used",
"in",
"the",
"{",
"@link",
"TextChannel#typeContinuously",
"(",
"Consumer",
")",
"}",
"method",
".",
"It",
"unwraps",
"{",
"@link",
"CompletionException",
"CompletionExceptions",
"}",
"{",
"@link",
"InvocationTargetException",
"InvocationTargetExceptions",
"}",
"and",
"{",
"@link",
"ExecutionException",
"ExecutionExceptions",
"}",
"first",
"and",
"then",
"adds",
"a",
"fresh",
"{",
"@code",
"CompletionException",
"}",
"as",
"wrapper",
"with",
"the",
"stacktrace",
"of",
"the",
"caller",
"of",
"this",
"method",
"and",
"logs",
"it",
"afterwards",
".",
"The",
"rewrapped",
"exception",
"is",
"only",
"logged",
"if",
"it",
"is",
"not",
"in",
"the",
"{",
"@code",
"ignoredThrowableTypes",
"}",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/util/logging/ExceptionLogger.java#L62-L65 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/NodeStack.java | NodeStack.innerProcessSubTree | private void innerProcessSubTree(
GBSNode p,
int initialState,
int topIndex) {
"""
Walk through an entire sub-tree, invoking processNode on each node.
<p>Walk through a sub-tree, invoking processNode on each node.
processNode is an abstract megthod that is implemented by
subclasses.</p>
@param p The node at which to start.
@param initialState The initial state of the walk, which is one of
VISIT_LEFT or VISIT_RIGHT. VISIT_LEFT is the
initial state for visiting a whole sub-tree.
VISIT_RIGHT is the initial state for visiting a
sub-fringe.
@param topIndex The index within the NodeStack that is considered
to be the top of the tree.
"""
boolean done = false;
_topIndex = topIndex;
_endp = p;
_endIndex = _idx;
GBSNode q; /* Used for tree walking */
int s = initialState;
while ( !done )
{
switch(s)
{
case NodeStack.VISIT_LEFT:
s = NodeStack.PROCESS_CURRENT;
q = p.leftChild();
while (q != null)
{
push(s, p);
p = q;
q = p.leftChild();
}
break;
case NodeStack.PROCESS_CURRENT:
s = NodeStack.VISIT_RIGHT;
done = processNode(p);
_endp = p; /* Last node processed */
_endIndex = _idx; /* Index to parent of last node processed*/
break;
case NodeStack.VISIT_RIGHT:
s = NodeStack.DONE_VISITS;
q = p.rightChild();
if (q != null)
{
push(s, p);
s = NodeStack.VISIT_LEFT;
p = p.rightChild();
}
break;
case NodeStack.DONE_VISITS:
if (_idx == topIndex) /* Have finally hit end of sub-tree */
done = true;
else
{
s = _state[_cidx];
p = _node[_cidx];
pop();
}
break;
default:
throw new RuntimeException("Help!, s = " + s + ".");
// break;
} /* switch(s) */
} /* while ( !done ) */
} | java | private void innerProcessSubTree(
GBSNode p,
int initialState,
int topIndex)
{
boolean done = false;
_topIndex = topIndex;
_endp = p;
_endIndex = _idx;
GBSNode q; /* Used for tree walking */
int s = initialState;
while ( !done )
{
switch(s)
{
case NodeStack.VISIT_LEFT:
s = NodeStack.PROCESS_CURRENT;
q = p.leftChild();
while (q != null)
{
push(s, p);
p = q;
q = p.leftChild();
}
break;
case NodeStack.PROCESS_CURRENT:
s = NodeStack.VISIT_RIGHT;
done = processNode(p);
_endp = p; /* Last node processed */
_endIndex = _idx; /* Index to parent of last node processed*/
break;
case NodeStack.VISIT_RIGHT:
s = NodeStack.DONE_VISITS;
q = p.rightChild();
if (q != null)
{
push(s, p);
s = NodeStack.VISIT_LEFT;
p = p.rightChild();
}
break;
case NodeStack.DONE_VISITS:
if (_idx == topIndex) /* Have finally hit end of sub-tree */
done = true;
else
{
s = _state[_cidx];
p = _node[_cidx];
pop();
}
break;
default:
throw new RuntimeException("Help!, s = " + s + ".");
// break;
} /* switch(s) */
} /* while ( !done ) */
} | [
"private",
"void",
"innerProcessSubTree",
"(",
"GBSNode",
"p",
",",
"int",
"initialState",
",",
"int",
"topIndex",
")",
"{",
"boolean",
"done",
"=",
"false",
";",
"_topIndex",
"=",
"topIndex",
";",
"_endp",
"=",
"p",
";",
"_endIndex",
"=",
"_idx",
";",
"GBSNode",
"q",
";",
"/* Used for tree walking */",
"int",
"s",
"=",
"initialState",
";",
"while",
"(",
"!",
"done",
")",
"{",
"switch",
"(",
"s",
")",
"{",
"case",
"NodeStack",
".",
"VISIT_LEFT",
":",
"s",
"=",
"NodeStack",
".",
"PROCESS_CURRENT",
";",
"q",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"while",
"(",
"q",
"!=",
"null",
")",
"{",
"push",
"(",
"s",
",",
"p",
")",
";",
"p",
"=",
"q",
";",
"q",
"=",
"p",
".",
"leftChild",
"(",
")",
";",
"}",
"break",
";",
"case",
"NodeStack",
".",
"PROCESS_CURRENT",
":",
"s",
"=",
"NodeStack",
".",
"VISIT_RIGHT",
";",
"done",
"=",
"processNode",
"(",
"p",
")",
";",
"_endp",
"=",
"p",
";",
"/* Last node processed */",
"_endIndex",
"=",
"_idx",
";",
"/* Index to parent of last node processed*/",
"break",
";",
"case",
"NodeStack",
".",
"VISIT_RIGHT",
":",
"s",
"=",
"NodeStack",
".",
"DONE_VISITS",
";",
"q",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"if",
"(",
"q",
"!=",
"null",
")",
"{",
"push",
"(",
"s",
",",
"p",
")",
";",
"s",
"=",
"NodeStack",
".",
"VISIT_LEFT",
";",
"p",
"=",
"p",
".",
"rightChild",
"(",
")",
";",
"}",
"break",
";",
"case",
"NodeStack",
".",
"DONE_VISITS",
":",
"if",
"(",
"_idx",
"==",
"topIndex",
")",
"/* Have finally hit end of sub-tree */",
"done",
"=",
"true",
";",
"else",
"{",
"s",
"=",
"_state",
"[",
"_cidx",
"]",
";",
"p",
"=",
"_node",
"[",
"_cidx",
"]",
";",
"pop",
"(",
")",
";",
"}",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Help!, s = \"",
"+",
"s",
"+",
"\".\"",
")",
";",
"// break;",
"}",
"/* switch(s) */",
"}",
"/* while ( !done ) */",
"}"
] | Walk through an entire sub-tree, invoking processNode on each node.
<p>Walk through a sub-tree, invoking processNode on each node.
processNode is an abstract megthod that is implemented by
subclasses.</p>
@param p The node at which to start.
@param initialState The initial state of the walk, which is one of
VISIT_LEFT or VISIT_RIGHT. VISIT_LEFT is the
initial state for visiting a whole sub-tree.
VISIT_RIGHT is the initial state for visiting a
sub-fringe.
@param topIndex The index within the NodeStack that is considered
to be the top of the tree. | [
"Walk",
"through",
"an",
"entire",
"sub",
"-",
"tree",
"invoking",
"processNode",
"on",
"each",
"node",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/msgstore/gbs/NodeStack.java#L309-L367 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/android/Facebook.java | Facebook.validateServiceIntent | private boolean validateServiceIntent(Context context, Intent intent) {
"""
Helper to validate a service intent by resolving and checking the
provider's package signature.
@param context
@param intent
@return true if the service intent resolution happens successfully and
the signatures match.
"""
ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0);
if (resolveInfo == null) {
return false;
}
return validateAppSignatureForPackage(context, resolveInfo.serviceInfo.packageName);
} | java | private boolean validateServiceIntent(Context context, Intent intent) {
ResolveInfo resolveInfo = context.getPackageManager().resolveService(intent, 0);
if (resolveInfo == null) {
return false;
}
return validateAppSignatureForPackage(context, resolveInfo.serviceInfo.packageName);
} | [
"private",
"boolean",
"validateServiceIntent",
"(",
"Context",
"context",
",",
"Intent",
"intent",
")",
"{",
"ResolveInfo",
"resolveInfo",
"=",
"context",
".",
"getPackageManager",
"(",
")",
".",
"resolveService",
"(",
"intent",
",",
"0",
")",
";",
"if",
"(",
"resolveInfo",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"validateAppSignatureForPackage",
"(",
"context",
",",
"resolveInfo",
".",
"serviceInfo",
".",
"packageName",
")",
";",
"}"
] | Helper to validate a service intent by resolving and checking the
provider's package signature.
@param context
@param intent
@return true if the service intent resolution happens successfully and
the signatures match. | [
"Helper",
"to",
"validate",
"a",
"service",
"intent",
"by",
"resolving",
"and",
"checking",
"the",
"provider",
"s",
"package",
"signature",
"."
] | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/android/Facebook.java#L372-L379 |
Alluxio/alluxio | core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java | BlockMetadataManager.moveBlockMeta | public BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta)
throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException {
"""
Moves an existing block to another location currently hold by a temp block.
@param blockMeta the metadata of the block to move
@param tempBlockMeta a placeholder in the destination directory
@return the new block metadata if success, absent otherwise
@throws BlockDoesNotExistException when the block to move is not found
@throws BlockAlreadyExistsException when the block to move already exists in the destination
@throws WorkerOutOfSpaceException when destination have no extra space to hold the block to
move
"""
StorageDir srcDir = blockMeta.getParentDir();
StorageDir dstDir = tempBlockMeta.getParentDir();
srcDir.removeBlockMeta(blockMeta);
BlockMeta newBlockMeta =
new BlockMeta(blockMeta.getBlockId(), blockMeta.getBlockSize(), dstDir);
dstDir.removeTempBlockMeta(tempBlockMeta);
dstDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
} | java | public BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta)
throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir srcDir = blockMeta.getParentDir();
StorageDir dstDir = tempBlockMeta.getParentDir();
srcDir.removeBlockMeta(blockMeta);
BlockMeta newBlockMeta =
new BlockMeta(blockMeta.getBlockId(), blockMeta.getBlockSize(), dstDir);
dstDir.removeTempBlockMeta(tempBlockMeta);
dstDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
} | [
"public",
"BlockMeta",
"moveBlockMeta",
"(",
"BlockMeta",
"blockMeta",
",",
"TempBlockMeta",
"tempBlockMeta",
")",
"throws",
"BlockDoesNotExistException",
",",
"WorkerOutOfSpaceException",
",",
"BlockAlreadyExistsException",
"{",
"StorageDir",
"srcDir",
"=",
"blockMeta",
".",
"getParentDir",
"(",
")",
";",
"StorageDir",
"dstDir",
"=",
"tempBlockMeta",
".",
"getParentDir",
"(",
")",
";",
"srcDir",
".",
"removeBlockMeta",
"(",
"blockMeta",
")",
";",
"BlockMeta",
"newBlockMeta",
"=",
"new",
"BlockMeta",
"(",
"blockMeta",
".",
"getBlockId",
"(",
")",
",",
"blockMeta",
".",
"getBlockSize",
"(",
")",
",",
"dstDir",
")",
";",
"dstDir",
".",
"removeTempBlockMeta",
"(",
"tempBlockMeta",
")",
";",
"dstDir",
".",
"addBlockMeta",
"(",
"newBlockMeta",
")",
";",
"return",
"newBlockMeta",
";",
"}"
] | Moves an existing block to another location currently hold by a temp block.
@param blockMeta the metadata of the block to move
@param tempBlockMeta a placeholder in the destination directory
@return the new block metadata if success, absent otherwise
@throws BlockDoesNotExistException when the block to move is not found
@throws BlockAlreadyExistsException when the block to move already exists in the destination
@throws WorkerOutOfSpaceException when destination have no extra space to hold the block to
move | [
"Moves",
"an",
"existing",
"block",
"to",
"another",
"location",
"currently",
"hold",
"by",
"a",
"temp",
"block",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L376-L386 |
andygibson/datafactory | src/main/java/org/fluttercode/datafactory/impl/DataFactory.java | DataFactory.getRandomChars | public String getRandomChars(final int minLength, final int maxLength) {
"""
Return a string containing between <code>length</code> random characters
@param minLength minimum number of characters to use in the string
@param maxLength maximum number of characters to use in the string
@return A string containing <code>length</code> random characters
"""
validateMinMaxParams(minLength, maxLength);
StringBuilder sb = new StringBuilder(maxLength);
int length = minLength;
if (maxLength != minLength) {
length = length + random.nextInt(maxLength - minLength);
}
while (length > 0) {
sb.append(getRandomChar());
length--;
}
return sb.toString();
} | java | public String getRandomChars(final int minLength, final int maxLength) {
validateMinMaxParams(minLength, maxLength);
StringBuilder sb = new StringBuilder(maxLength);
int length = minLength;
if (maxLength != minLength) {
length = length + random.nextInt(maxLength - minLength);
}
while (length > 0) {
sb.append(getRandomChar());
length--;
}
return sb.toString();
} | [
"public",
"String",
"getRandomChars",
"(",
"final",
"int",
"minLength",
",",
"final",
"int",
"maxLength",
")",
"{",
"validateMinMaxParams",
"(",
"minLength",
",",
"maxLength",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"maxLength",
")",
";",
"int",
"length",
"=",
"minLength",
";",
"if",
"(",
"maxLength",
"!=",
"minLength",
")",
"{",
"length",
"=",
"length",
"+",
"random",
".",
"nextInt",
"(",
"maxLength",
"-",
"minLength",
")",
";",
"}",
"while",
"(",
"length",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"getRandomChar",
"(",
")",
")",
";",
"length",
"--",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Return a string containing between <code>length</code> random characters
@param minLength minimum number of characters to use in the string
@param maxLength maximum number of characters to use in the string
@return A string containing <code>length</code> random characters | [
"Return",
"a",
"string",
"containing",
"between",
"<code",
">",
"length<",
"/",
"code",
">",
"random",
"characters"
] | train | https://github.com/andygibson/datafactory/blob/f748beb93844dea2ad6174715be3b70df0448a9c/src/main/java/org/fluttercode/datafactory/impl/DataFactory.java#L464-L477 |
teatrove/teatrove | teaservlet/src/main/java/org/teatrove/teaservlet/util/TemplateServerServlet.java | TemplateServerServlet.doGet | public void doGet(HttpServletRequest req,HttpServletResponse res) {
"""
Retrieves all the templates that are newer that the timestamp specified
by the client. The pathInfo from the request specifies which templates
are desired. QueryString parameters "timeStamp" and ??? provide
"""
getTemplateData(req, res,req.getPathInfo());
} | java | public void doGet(HttpServletRequest req,HttpServletResponse res) {
getTemplateData(req, res,req.getPathInfo());
} | [
"public",
"void",
"doGet",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
")",
"{",
"getTemplateData",
"(",
"req",
",",
"res",
",",
"req",
".",
"getPathInfo",
"(",
")",
")",
";",
"}"
] | Retrieves all the templates that are newer that the timestamp specified
by the client. The pathInfo from the request specifies which templates
are desired. QueryString parameters "timeStamp" and ??? provide | [
"Retrieves",
"all",
"the",
"templates",
"that",
"are",
"newer",
"that",
"the",
"timestamp",
"specified",
"by",
"the",
"client",
".",
"The",
"pathInfo",
"from",
"the",
"request",
"specifies",
"which",
"templates",
"are",
"desired",
".",
"QueryString",
"parameters",
"timeStamp",
"and",
"???",
"provide"
] | train | https://github.com/teatrove/teatrove/blob/7039bdd4da6817ff8c737f7e4e07bac7e3ad8bea/teaservlet/src/main/java/org/teatrove/teaservlet/util/TemplateServerServlet.java#L79-L81 |
openengsb/openengsb | components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java | EDBConverter.getEntryNameForMap | private static String getEntryNameForMap(String property, Boolean key, Integer index) {
"""
Returns the entry name for a map element in the EDB format. The key parameter defines if the entry name should be
generated for the key or the value of the map. E.g. the map key for the property "map" with the index 0 would be
"map.0.key".
"""
return String.format("%s.%d.%s", property, index, key ? "key" : "value");
} | java | private static String getEntryNameForMap(String property, Boolean key, Integer index) {
return String.format("%s.%d.%s", property, index, key ? "key" : "value");
} | [
"private",
"static",
"String",
"getEntryNameForMap",
"(",
"String",
"property",
",",
"Boolean",
"key",
",",
"Integer",
"index",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s.%d.%s\"",
",",
"property",
",",
"index",
",",
"key",
"?",
"\"key\"",
":",
"\"value\"",
")",
";",
"}"
] | Returns the entry name for a map element in the EDB format. The key parameter defines if the entry name should be
generated for the key or the value of the map. E.g. the map key for the property "map" with the index 0 would be
"map.0.key". | [
"Returns",
"the",
"entry",
"name",
"for",
"a",
"map",
"element",
"in",
"the",
"EDB",
"format",
".",
"The",
"key",
"parameter",
"defines",
"if",
"the",
"entry",
"name",
"should",
"be",
"generated",
"for",
"the",
"key",
"or",
"the",
"value",
"of",
"the",
"map",
".",
"E",
".",
"g",
".",
"the",
"map",
"key",
"for",
"the",
"property",
"map",
"with",
"the",
"index",
"0",
"would",
"be",
"map",
".",
"0",
".",
"key",
"."
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/common/src/main/java/org/openengsb/core/ekb/common/EDBConverter.java#L521-L523 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.