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
|
---|---|---|---|---|---|---|---|---|---|---|
mnlipp/jgrapes | org.jgrapes.io/src/org/jgrapes/io/FileStorage.java | FileStorage.onSaveInput | @Handler
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void onSaveInput(SaveInput event) throws InterruptedException {
"""
Opens a file for writing using the properties of the event. All data from
subsequent {@link Input} events is written to the file.
The end of record flag is ignored.
@param event the event
@throws InterruptedException if the execution was interrupted
"""
if (!Arrays.asList(event.options())
.contains(StandardOpenOption.WRITE)) {
throw new IllegalArgumentException(
"File must be opened for writing.");
}
for (IOSubchannel channel : event.channels(IOSubchannel.class)) {
if (inputWriters.containsKey(channel)) {
channel.respond(new IOError(event,
new IllegalStateException("File is already open.")));
} else {
new Writer(event, channel);
}
}
} | java | @Handler
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void onSaveInput(SaveInput event) throws InterruptedException {
if (!Arrays.asList(event.options())
.contains(StandardOpenOption.WRITE)) {
throw new IllegalArgumentException(
"File must be opened for writing.");
}
for (IOSubchannel channel : event.channels(IOSubchannel.class)) {
if (inputWriters.containsKey(channel)) {
channel.respond(new IOError(event,
new IllegalStateException("File is already open.")));
} else {
new Writer(event, channel);
}
}
} | [
"@",
"Handler",
"@",
"SuppressWarnings",
"(",
"\"PMD.AvoidInstantiatingObjectsInLoops\"",
")",
"public",
"void",
"onSaveInput",
"(",
"SaveInput",
"event",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"!",
"Arrays",
".",
"asList",
"(",
"event",
".",
"options",
"(",
")",
")",
".",
"contains",
"(",
"StandardOpenOption",
".",
"WRITE",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"File must be opened for writing.\"",
")",
";",
"}",
"for",
"(",
"IOSubchannel",
"channel",
":",
"event",
".",
"channels",
"(",
"IOSubchannel",
".",
"class",
")",
")",
"{",
"if",
"(",
"inputWriters",
".",
"containsKey",
"(",
"channel",
")",
")",
"{",
"channel",
".",
"respond",
"(",
"new",
"IOError",
"(",
"event",
",",
"new",
"IllegalStateException",
"(",
"\"File is already open.\"",
")",
")",
")",
";",
"}",
"else",
"{",
"new",
"Writer",
"(",
"event",
",",
"channel",
")",
";",
"}",
"}",
"}"
] | Opens a file for writing using the properties of the event. All data from
subsequent {@link Input} events is written to the file.
The end of record flag is ignored.
@param event the event
@throws InterruptedException if the execution was interrupted | [
"Opens",
"a",
"file",
"for",
"writing",
"using",
"the",
"properties",
"of",
"the",
"event",
".",
"All",
"data",
"from",
"subsequent",
"{",
"@link",
"Input",
"}",
"events",
"is",
"written",
"to",
"the",
"file",
".",
"The",
"end",
"of",
"record",
"flag",
"is",
"ignored",
"."
] | train | https://github.com/mnlipp/jgrapes/blob/8b5d874935d84c34a52d3e3d3745e869b5203fa0/org.jgrapes.io/src/org/jgrapes/io/FileStorage.java#L303-L319 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-scaleout/deeplearning4j-aws/src/main/java/org/deeplearning4j/aws/s3/uploader/S3Uploader.java | S3Uploader.multiPartUpload | public void multiPartUpload(File file, String bucketName) {
"""
Multi part upload for big files
@param file the file to upload
@param bucketName the bucket name to upload
"""
AmazonS3 client = new AmazonS3Client(creds);
bucketName = ensureValidBucketName(bucketName);
List<Bucket> buckets = client.listBuckets();
for (Bucket b : buckets)
if (b.getName().equals(bucketName)) {
doMultiPart(client, bucketName, file);
return;
}
//bucket didn't exist: create it
client.createBucket(bucketName);
doMultiPart(client, bucketName, file);
} | java | public void multiPartUpload(File file, String bucketName) {
AmazonS3 client = new AmazonS3Client(creds);
bucketName = ensureValidBucketName(bucketName);
List<Bucket> buckets = client.listBuckets();
for (Bucket b : buckets)
if (b.getName().equals(bucketName)) {
doMultiPart(client, bucketName, file);
return;
}
//bucket didn't exist: create it
client.createBucket(bucketName);
doMultiPart(client, bucketName, file);
} | [
"public",
"void",
"multiPartUpload",
"(",
"File",
"file",
",",
"String",
"bucketName",
")",
"{",
"AmazonS3",
"client",
"=",
"new",
"AmazonS3Client",
"(",
"creds",
")",
";",
"bucketName",
"=",
"ensureValidBucketName",
"(",
"bucketName",
")",
";",
"List",
"<",
"Bucket",
">",
"buckets",
"=",
"client",
".",
"listBuckets",
"(",
")",
";",
"for",
"(",
"Bucket",
"b",
":",
"buckets",
")",
"if",
"(",
"b",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"bucketName",
")",
")",
"{",
"doMultiPart",
"(",
"client",
",",
"bucketName",
",",
"file",
")",
";",
"return",
";",
"}",
"//bucket didn't exist: create it",
"client",
".",
"createBucket",
"(",
"bucketName",
")",
";",
"doMultiPart",
"(",
"client",
",",
"bucketName",
",",
"file",
")",
";",
"}"
] | Multi part upload for big files
@param file the file to upload
@param bucketName the bucket name to upload | [
"Multi",
"part",
"upload",
"for",
"big",
"files"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-scaleout/deeplearning4j-aws/src/main/java/org/deeplearning4j/aws/s3/uploader/S3Uploader.java#L45-L59 |
jfinal/jfinal | src/main/java/com/jfinal/token/TokenManager.java | TokenManager.validateToken | public static boolean validateToken(Controller controller, String tokenName) {
"""
Check token to prevent resubmit.
@param tokenName the token name used in view's form
@return true if token is correct
"""
String clientTokenId = controller.getPara(tokenName);
if (tokenCache == null) {
String serverTokenId = controller.getSessionAttr(tokenName);
controller.removeSessionAttr(tokenName); // important!
return StrKit.notBlank(clientTokenId) && clientTokenId.equals(serverTokenId);
}
else {
Token token = new Token(clientTokenId);
boolean result = tokenCache.contains(token);
tokenCache.remove(token);
return result;
}
} | java | public static boolean validateToken(Controller controller, String tokenName) {
String clientTokenId = controller.getPara(tokenName);
if (tokenCache == null) {
String serverTokenId = controller.getSessionAttr(tokenName);
controller.removeSessionAttr(tokenName); // important!
return StrKit.notBlank(clientTokenId) && clientTokenId.equals(serverTokenId);
}
else {
Token token = new Token(clientTokenId);
boolean result = tokenCache.contains(token);
tokenCache.remove(token);
return result;
}
} | [
"public",
"static",
"boolean",
"validateToken",
"(",
"Controller",
"controller",
",",
"String",
"tokenName",
")",
"{",
"String",
"clientTokenId",
"=",
"controller",
".",
"getPara",
"(",
"tokenName",
")",
";",
"if",
"(",
"tokenCache",
"==",
"null",
")",
"{",
"String",
"serverTokenId",
"=",
"controller",
".",
"getSessionAttr",
"(",
"tokenName",
")",
";",
"controller",
".",
"removeSessionAttr",
"(",
"tokenName",
")",
";",
"// important!\r",
"return",
"StrKit",
".",
"notBlank",
"(",
"clientTokenId",
")",
"&&",
"clientTokenId",
".",
"equals",
"(",
"serverTokenId",
")",
";",
"}",
"else",
"{",
"Token",
"token",
"=",
"new",
"Token",
"(",
"clientTokenId",
")",
";",
"boolean",
"result",
"=",
"tokenCache",
".",
"contains",
"(",
"token",
")",
";",
"tokenCache",
".",
"remove",
"(",
"token",
")",
";",
"return",
"result",
";",
"}",
"}"
] | Check token to prevent resubmit.
@param tokenName the token name used in view's form
@return true if token is correct | [
"Check",
"token",
"to",
"prevent",
"resubmit",
"."
] | train | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/token/TokenManager.java#L106-L119 |
windup/windup | java-ast/addon/src/main/java/org/jboss/windup/ast/java/ASTProcessor.java | ASTProcessor.analyze | public static List<ClassReference> analyze(WildcardImportResolver importResolver, Set<String> libraryPaths, Set<String> sourcePaths,
Path sourceFile) {
"""
Parses the provided file, using the given libraryPaths and sourcePaths as context. The libraries may be either
jar files or references to directories containing class files.
The sourcePaths must be a reference to the top level directory for sources (eg, for a file
src/main/java/org/example/Foo.java, the source path would be src/main/java).
The wildcard resolver provides a fallback for processing wildcard imports that the underlying parser was unable
to resolve.
"""
ASTParser parser = ASTParser.newParser(AST.JLS11);
parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true);
parser.setBindingsRecovery(false);
parser.setResolveBindings(true);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
String fileName = sourceFile.getFileName().toString();
parser.setUnitName(fileName);
try
{
parser.setSource(FileUtils.readFileToString(sourceFile.toFile()).toCharArray());
}
catch (IOException e)
{
throw new ASTException("Failed to get source for file: " + sourceFile.toString() + " due to: " + e.getMessage(), e);
}
parser.setKind(ASTParser.K_COMPILATION_UNIT);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, cu, sourceFile.toString());
cu.accept(visitor);
return visitor.getJavaClassReferences();
} | java | public static List<ClassReference> analyze(WildcardImportResolver importResolver, Set<String> libraryPaths, Set<String> sourcePaths,
Path sourceFile)
{
ASTParser parser = ASTParser.newParser(AST.JLS11);
parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]), sourcePaths.toArray(new String[sourcePaths.size()]), null, true);
parser.setBindingsRecovery(false);
parser.setResolveBindings(true);
Map options = JavaCore.getOptions();
JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
parser.setCompilerOptions(options);
String fileName = sourceFile.getFileName().toString();
parser.setUnitName(fileName);
try
{
parser.setSource(FileUtils.readFileToString(sourceFile.toFile()).toCharArray());
}
catch (IOException e)
{
throw new ASTException("Failed to get source for file: " + sourceFile.toString() + " due to: " + e.getMessage(), e);
}
parser.setKind(ASTParser.K_COMPILATION_UNIT);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, cu, sourceFile.toString());
cu.accept(visitor);
return visitor.getJavaClassReferences();
} | [
"public",
"static",
"List",
"<",
"ClassReference",
">",
"analyze",
"(",
"WildcardImportResolver",
"importResolver",
",",
"Set",
"<",
"String",
">",
"libraryPaths",
",",
"Set",
"<",
"String",
">",
"sourcePaths",
",",
"Path",
"sourceFile",
")",
"{",
"ASTParser",
"parser",
"=",
"ASTParser",
".",
"newParser",
"(",
"AST",
".",
"JLS11",
")",
";",
"parser",
".",
"setEnvironment",
"(",
"libraryPaths",
".",
"toArray",
"(",
"new",
"String",
"[",
"libraryPaths",
".",
"size",
"(",
")",
"]",
")",
",",
"sourcePaths",
".",
"toArray",
"(",
"new",
"String",
"[",
"sourcePaths",
".",
"size",
"(",
")",
"]",
")",
",",
"null",
",",
"true",
")",
";",
"parser",
".",
"setBindingsRecovery",
"(",
"false",
")",
";",
"parser",
".",
"setResolveBindings",
"(",
"true",
")",
";",
"Map",
"options",
"=",
"JavaCore",
".",
"getOptions",
"(",
")",
";",
"JavaCore",
".",
"setComplianceOptions",
"(",
"JavaCore",
".",
"VERSION_1_8",
",",
"options",
")",
";",
"parser",
".",
"setCompilerOptions",
"(",
"options",
")",
";",
"String",
"fileName",
"=",
"sourceFile",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
";",
"parser",
".",
"setUnitName",
"(",
"fileName",
")",
";",
"try",
"{",
"parser",
".",
"setSource",
"(",
"FileUtils",
".",
"readFileToString",
"(",
"sourceFile",
".",
"toFile",
"(",
")",
")",
".",
"toCharArray",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ASTException",
"(",
"\"Failed to get source for file: \"",
"+",
"sourceFile",
".",
"toString",
"(",
")",
"+",
"\" due to: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"parser",
".",
"setKind",
"(",
"ASTParser",
".",
"K_COMPILATION_UNIT",
")",
";",
"CompilationUnit",
"cu",
"=",
"(",
"CompilationUnit",
")",
"parser",
".",
"createAST",
"(",
"null",
")",
";",
"ReferenceResolvingVisitor",
"visitor",
"=",
"new",
"ReferenceResolvingVisitor",
"(",
"importResolver",
",",
"cu",
",",
"sourceFile",
".",
"toString",
"(",
")",
")",
";",
"cu",
".",
"accept",
"(",
"visitor",
")",
";",
"return",
"visitor",
".",
"getJavaClassReferences",
"(",
")",
";",
"}"
] | Parses the provided file, using the given libraryPaths and sourcePaths as context. The libraries may be either
jar files or references to directories containing class files.
The sourcePaths must be a reference to the top level directory for sources (eg, for a file
src/main/java/org/example/Foo.java, the source path would be src/main/java).
The wildcard resolver provides a fallback for processing wildcard imports that the underlying parser was unable
to resolve. | [
"Parses",
"the",
"provided",
"file",
"using",
"the",
"given",
"libraryPaths",
"and",
"sourcePaths",
"as",
"context",
".",
"The",
"libraries",
"may",
"be",
"either",
"jar",
"files",
"or",
"references",
"to",
"directories",
"containing",
"class",
"files",
"."
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/java-ast/addon/src/main/java/org/jboss/windup/ast/java/ASTProcessor.java#L41-L66 |
ltearno/hexa.tools | hexa.binding/src/main/java/fr/lteconsulting/hexa/databinding/properties/PropertyValues.java | PropertyValues.setValue | boolean setValue( Object object, String propertyName, Object value ) {
"""
Sets a value on an object's property
@param object
the object on which the property is set
@param propertyName
the name of the property value to be set
@param value
the new value of the property
"""
Clazz<?> s = ClassInfo.Clazz( object.getClass() );
if( Property.class == getPropertyType( s, propertyName ) )
{
Property<Object> property = getPropertyImpl( object, propertyName );
if( property != null )
{
property.setValue( value );
return true;
}
return false;
}
return setPropertyImpl( s, object, propertyName, value );
} | java | boolean setValue( Object object, String propertyName, Object value )
{
Clazz<?> s = ClassInfo.Clazz( object.getClass() );
if( Property.class == getPropertyType( s, propertyName ) )
{
Property<Object> property = getPropertyImpl( object, propertyName );
if( property != null )
{
property.setValue( value );
return true;
}
return false;
}
return setPropertyImpl( s, object, propertyName, value );
} | [
"boolean",
"setValue",
"(",
"Object",
"object",
",",
"String",
"propertyName",
",",
"Object",
"value",
")",
"{",
"Clazz",
"<",
"?",
">",
"s",
"=",
"ClassInfo",
".",
"Clazz",
"(",
"object",
".",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"Property",
".",
"class",
"==",
"getPropertyType",
"(",
"s",
",",
"propertyName",
")",
")",
"{",
"Property",
"<",
"Object",
">",
"property",
"=",
"getPropertyImpl",
"(",
"object",
",",
"propertyName",
")",
";",
"if",
"(",
"property",
"!=",
"null",
")",
"{",
"property",
".",
"setValue",
"(",
"value",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"return",
"setPropertyImpl",
"(",
"s",
",",
"object",
",",
"propertyName",
",",
"value",
")",
";",
"}"
] | Sets a value on an object's property
@param object
the object on which the property is set
@param propertyName
the name of the property value to be set
@param value
the new value of the property | [
"Sets",
"a",
"value",
"on",
"an",
"object",
"s",
"property"
] | train | https://github.com/ltearno/hexa.tools/blob/604c804901b1bb13fe10b3823cc4a639f8993363/hexa.binding/src/main/java/fr/lteconsulting/hexa/databinding/properties/PropertyValues.java#L187-L204 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java | ReidSolomonCodes.findErrorLocatorPolynomialBM | void findErrorLocatorPolynomialBM(GrowQueue_I8 syndromes , GrowQueue_I8 errorLocator ) {
"""
Computes the error locator polynomial using Berlekamp-Massey algorithm [1]
<p>[1] Massey, J. L. (1969), "Shift-register synthesis and BCH decoding" (PDF), IEEE Trans.
Information Theory, IT-15 (1): 122–127</p>
@param syndromes (Input) The syndromes
@param errorLocator (Output) Error locator polynomial. Coefficients are large to small.
"""
GrowQueue_I8 C = errorLocator; // error polynomial
GrowQueue_I8 B = new GrowQueue_I8(); // previous error polynomial
// TODO remove new from this function
initToOne(C,syndromes.size+1);
initToOne(B,syndromes.size+1);
GrowQueue_I8 tmp = new GrowQueue_I8(syndromes.size);
// int L = 0;
// int m = 1; // stores how much B is 'shifted' by
int b = 1;
for (int n = 0; n < syndromes.size; n++) {
// Compute discrepancy delta
int delta = syndromes.data[n]&0xFF;
for (int j = 1; j < C.size; j++) {
delta ^= math.multiply(C.data[C.size-j-1]&0xFF, syndromes.data[n-j]&0xFF);
}
// B = D^m * B
B.data[B.size++] = 0;
// Step 3 is implicitly handled
// m = m + 1
if( delta != 0 ) {
int scale = math.multiply(delta, math.inverse(b));
math.polyAddScaleB(C, B, scale, tmp);
if (B.size <= C.size) {
// if 2*L > N ---- Step 4
// m += 1;
} else {
// if 2*L <= N --- Step 5
B.setTo(C);
// L = n+1-L;
b = delta;
// m = 1;
}
C.setTo(tmp);
}
}
removeLeadingZeros(C);
} | java | void findErrorLocatorPolynomialBM(GrowQueue_I8 syndromes , GrowQueue_I8 errorLocator ) {
GrowQueue_I8 C = errorLocator; // error polynomial
GrowQueue_I8 B = new GrowQueue_I8(); // previous error polynomial
// TODO remove new from this function
initToOne(C,syndromes.size+1);
initToOne(B,syndromes.size+1);
GrowQueue_I8 tmp = new GrowQueue_I8(syndromes.size);
// int L = 0;
// int m = 1; // stores how much B is 'shifted' by
int b = 1;
for (int n = 0; n < syndromes.size; n++) {
// Compute discrepancy delta
int delta = syndromes.data[n]&0xFF;
for (int j = 1; j < C.size; j++) {
delta ^= math.multiply(C.data[C.size-j-1]&0xFF, syndromes.data[n-j]&0xFF);
}
// B = D^m * B
B.data[B.size++] = 0;
// Step 3 is implicitly handled
// m = m + 1
if( delta != 0 ) {
int scale = math.multiply(delta, math.inverse(b));
math.polyAddScaleB(C, B, scale, tmp);
if (B.size <= C.size) {
// if 2*L > N ---- Step 4
// m += 1;
} else {
// if 2*L <= N --- Step 5
B.setTo(C);
// L = n+1-L;
b = delta;
// m = 1;
}
C.setTo(tmp);
}
}
removeLeadingZeros(C);
} | [
"void",
"findErrorLocatorPolynomialBM",
"(",
"GrowQueue_I8",
"syndromes",
",",
"GrowQueue_I8",
"errorLocator",
")",
"{",
"GrowQueue_I8",
"C",
"=",
"errorLocator",
";",
"// error polynomial",
"GrowQueue_I8",
"B",
"=",
"new",
"GrowQueue_I8",
"(",
")",
";",
"// previous error polynomial",
"// TODO remove new from this function",
"initToOne",
"(",
"C",
",",
"syndromes",
".",
"size",
"+",
"1",
")",
";",
"initToOne",
"(",
"B",
",",
"syndromes",
".",
"size",
"+",
"1",
")",
";",
"GrowQueue_I8",
"tmp",
"=",
"new",
"GrowQueue_I8",
"(",
"syndromes",
".",
"size",
")",
";",
"//\t\tint L = 0;",
"//\t\tint m = 1; // stores how much B is 'shifted' by",
"int",
"b",
"=",
"1",
";",
"for",
"(",
"int",
"n",
"=",
"0",
";",
"n",
"<",
"syndromes",
".",
"size",
";",
"n",
"++",
")",
"{",
"// Compute discrepancy delta",
"int",
"delta",
"=",
"syndromes",
".",
"data",
"[",
"n",
"]",
"&",
"0xFF",
";",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
"<",
"C",
".",
"size",
";",
"j",
"++",
")",
"{",
"delta",
"^=",
"math",
".",
"multiply",
"(",
"C",
".",
"data",
"[",
"C",
".",
"size",
"-",
"j",
"-",
"1",
"]",
"&",
"0xFF",
",",
"syndromes",
".",
"data",
"[",
"n",
"-",
"j",
"]",
"&",
"0xFF",
")",
";",
"}",
"// B = D^m * B",
"B",
".",
"data",
"[",
"B",
".",
"size",
"++",
"]",
"=",
"0",
";",
"// Step 3 is implicitly handled",
"// m = m + 1",
"if",
"(",
"delta",
"!=",
"0",
")",
"{",
"int",
"scale",
"=",
"math",
".",
"multiply",
"(",
"delta",
",",
"math",
".",
"inverse",
"(",
"b",
")",
")",
";",
"math",
".",
"polyAddScaleB",
"(",
"C",
",",
"B",
",",
"scale",
",",
"tmp",
")",
";",
"if",
"(",
"B",
".",
"size",
"<=",
"C",
".",
"size",
")",
"{",
"// if 2*L > N ---- Step 4",
"//\t\t\t\t\tm += 1;",
"}",
"else",
"{",
"// if 2*L <= N --- Step 5",
"B",
".",
"setTo",
"(",
"C",
")",
";",
"//\t\t\t\t\tL = n+1-L;",
"b",
"=",
"delta",
";",
"//\t\t\t\t\tm = 1;",
"}",
"C",
".",
"setTo",
"(",
"tmp",
")",
";",
"}",
"}",
"removeLeadingZeros",
"(",
"C",
")",
";",
"}"
] | Computes the error locator polynomial using Berlekamp-Massey algorithm [1]
<p>[1] Massey, J. L. (1969), "Shift-register synthesis and BCH decoding" (PDF), IEEE Trans.
Information Theory, IT-15 (1): 122–127</p>
@param syndromes (Input) The syndromes
@param errorLocator (Output) Error locator polynomial. Coefficients are large to small. | [
"Computes",
"the",
"error",
"locator",
"polynomial",
"using",
"Berlekamp",
"-",
"Massey",
"algorithm",
"[",
"1",
"]"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L117-L165 |
Azure/azure-sdk-for-java | datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java | ServicesInner.checkChildrenNameAvailability | public NameAvailabilityResponseInner checkChildrenNameAvailability(String groupName, String serviceName, NameAvailabilityRequest parameters) {
"""
Check nested resource name validity and availability.
This method checks whether a proposed nested resource name is valid and available.
@param groupName Name of the resource group
@param serviceName Name of the service
@param parameters Requested name to validate
@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 NameAvailabilityResponseInner object if successful.
"""
return checkChildrenNameAvailabilityWithServiceResponseAsync(groupName, serviceName, parameters).toBlocking().single().body();
} | java | public NameAvailabilityResponseInner checkChildrenNameAvailability(String groupName, String serviceName, NameAvailabilityRequest parameters) {
return checkChildrenNameAvailabilityWithServiceResponseAsync(groupName, serviceName, parameters).toBlocking().single().body();
} | [
"public",
"NameAvailabilityResponseInner",
"checkChildrenNameAvailability",
"(",
"String",
"groupName",
",",
"String",
"serviceName",
",",
"NameAvailabilityRequest",
"parameters",
")",
"{",
"return",
"checkChildrenNameAvailabilityWithServiceResponseAsync",
"(",
"groupName",
",",
"serviceName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Check nested resource name validity and availability.
This method checks whether a proposed nested resource name is valid and available.
@param groupName Name of the resource group
@param serviceName Name of the service
@param parameters Requested name to validate
@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 NameAvailabilityResponseInner object if successful. | [
"Check",
"nested",
"resource",
"name",
"validity",
"and",
"availability",
".",
"This",
"method",
"checks",
"whether",
"a",
"proposed",
"nested",
"resource",
"name",
"is",
"valid",
"and",
"available",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datamigration/resource-manager/v2017_11_15_preview/src/main/java/com/microsoft/azure/management/datamigration/v2017_11_15_preview/implementation/ServicesInner.java#L1483-L1485 |
f2prateek/rx-preferences | rx-preferences/src/main/java/com/f2prateek/rx/preferences2/RxSharedPreferences.java | RxSharedPreferences.getFloat | @CheckResult @NonNull
public Preference<Float> getFloat(@NonNull String key) {
"""
Create a float preference for {@code key}. Default is {@code 0}.
"""
return getFloat(key, DEFAULT_FLOAT);
} | java | @CheckResult @NonNull
public Preference<Float> getFloat(@NonNull String key) {
return getFloat(key, DEFAULT_FLOAT);
} | [
"@",
"CheckResult",
"@",
"NonNull",
"public",
"Preference",
"<",
"Float",
">",
"getFloat",
"(",
"@",
"NonNull",
"String",
"key",
")",
"{",
"return",
"getFloat",
"(",
"key",
",",
"DEFAULT_FLOAT",
")",
";",
"}"
] | Create a float preference for {@code key}. Default is {@code 0}. | [
"Create",
"a",
"float",
"preference",
"for",
"{"
] | train | https://github.com/f2prateek/rx-preferences/blob/e338b4e6cee9c0c7b850be86ab41ed7b39a3637e/rx-preferences/src/main/java/com/f2prateek/rx/preferences2/RxSharedPreferences.java#L86-L89 |
hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/parser/RegexpParser.java | RegexpParser.classifyIfEmpty | protected String classifyIfEmpty(final String group, final String message) {
"""
Returns a category for the current warning. If the provided category is
not empty, then a capitalized string is returned. Otherwise the category
is obtained from the specified message text.
@param group
the warning category (might be empty)
@param message
the warning message
@return the actual category
"""
String category = StringUtils.capitalize(group);
if (StringUtils.isEmpty(category)) {
category = classifyWarning(message);
}
return category;
} | java | protected String classifyIfEmpty(final String group, final String message) {
String category = StringUtils.capitalize(group);
if (StringUtils.isEmpty(category)) {
category = classifyWarning(message);
}
return category;
} | [
"protected",
"String",
"classifyIfEmpty",
"(",
"final",
"String",
"group",
",",
"final",
"String",
"message",
")",
"{",
"String",
"category",
"=",
"StringUtils",
".",
"capitalize",
"(",
"group",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"category",
")",
")",
"{",
"category",
"=",
"classifyWarning",
"(",
"message",
")",
";",
"}",
"return",
"category",
";",
"}"
] | Returns a category for the current warning. If the provided category is
not empty, then a capitalized string is returned. Otherwise the category
is obtained from the specified message text.
@param group
the warning category (might be empty)
@param message
the warning message
@return the actual category | [
"Returns",
"a",
"category",
"for",
"the",
"current",
"warning",
".",
"If",
"the",
"provided",
"category",
"is",
"not",
"empty",
"then",
"a",
"capitalized",
"string",
"is",
"returned",
".",
"Otherwise",
"the",
"category",
"is",
"obtained",
"from",
"the",
"specified",
"message",
"text",
".",
"@param",
"group",
"the",
"warning",
"category",
"(",
"might",
"be",
"empty",
")",
"@param",
"message",
"the",
"warning",
"message"
] | train | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/RegexpParser.java#L150-L156 |
fcrepo3/fcrepo | fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java | ContextXmlReader.readMultiMapKeys | private void readMultiMapKeys(XMLEventReader reader, MultiValueMap<String> map)
throws XMLStreamException, JournalException {
"""
Read through the keys of the multi-map, adding to the map as we go.
"""
while (true) {
XMLEvent event2 = reader.nextTag();
if (isStartTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
// if we find a key tag, get the name
String key =
getRequiredAttributeValue(event2.asStartElement(),
QNAME_ATTR_NAME);
// read as many values as we find.
String[] values = readMultiMapValuesForKey(reader);
// store in the map
storeInMultiMap(map, key, values);
} else if (isEndTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP)) {
break;
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP,
QNAME_TAG_MULTI_VALUE_MAP_KEY,
event2);
}
}
} | java | private void readMultiMapKeys(XMLEventReader reader, MultiValueMap<String> map)
throws XMLStreamException, JournalException {
while (true) {
XMLEvent event2 = reader.nextTag();
if (isStartTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP_KEY)) {
// if we find a key tag, get the name
String key =
getRequiredAttributeValue(event2.asStartElement(),
QNAME_ATTR_NAME);
// read as many values as we find.
String[] values = readMultiMapValuesForKey(reader);
// store in the map
storeInMultiMap(map, key, values);
} else if (isEndTagEvent(event2, QNAME_TAG_MULTI_VALUE_MAP)) {
break;
} else {
throw getNotNextMemberOrEndOfGroupException(QNAME_TAG_MULTI_VALUE_MAP,
QNAME_TAG_MULTI_VALUE_MAP_KEY,
event2);
}
}
} | [
"private",
"void",
"readMultiMapKeys",
"(",
"XMLEventReader",
"reader",
",",
"MultiValueMap",
"<",
"String",
">",
"map",
")",
"throws",
"XMLStreamException",
",",
"JournalException",
"{",
"while",
"(",
"true",
")",
"{",
"XMLEvent",
"event2",
"=",
"reader",
".",
"nextTag",
"(",
")",
";",
"if",
"(",
"isStartTagEvent",
"(",
"event2",
",",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
")",
")",
"{",
"// if we find a key tag, get the name",
"String",
"key",
"=",
"getRequiredAttributeValue",
"(",
"event2",
".",
"asStartElement",
"(",
")",
",",
"QNAME_ATTR_NAME",
")",
";",
"// read as many values as we find.",
"String",
"[",
"]",
"values",
"=",
"readMultiMapValuesForKey",
"(",
"reader",
")",
";",
"// store in the map",
"storeInMultiMap",
"(",
"map",
",",
"key",
",",
"values",
")",
";",
"}",
"else",
"if",
"(",
"isEndTagEvent",
"(",
"event2",
",",
"QNAME_TAG_MULTI_VALUE_MAP",
")",
")",
"{",
"break",
";",
"}",
"else",
"{",
"throw",
"getNotNextMemberOrEndOfGroupException",
"(",
"QNAME_TAG_MULTI_VALUE_MAP",
",",
"QNAME_TAG_MULTI_VALUE_MAP_KEY",
",",
"event2",
")",
";",
"}",
"}",
"}"
] | Read through the keys of the multi-map, adding to the map as we go. | [
"Read",
"through",
"the",
"keys",
"of",
"the",
"multi",
"-",
"map",
"adding",
"to",
"the",
"map",
"as",
"we",
"go",
"."
] | train | https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/xmlhelpers/ContextXmlReader.java#L148-L169 |
ebean-orm/ebean-querybean | src/main/java/io/ebean/typequery/TQRootBean.java | TQRootBean.multiMatch | public R multiMatch(String query, String... properties) {
"""
Add a Text Multi-match expression (document store only).
<p>
This automatically makes the query a document store query.
</p>
"""
peekExprList().multiMatch(query, properties);
return root;
} | java | public R multiMatch(String query, String... properties) {
peekExprList().multiMatch(query, properties);
return root;
} | [
"public",
"R",
"multiMatch",
"(",
"String",
"query",
",",
"String",
"...",
"properties",
")",
"{",
"peekExprList",
"(",
")",
".",
"multiMatch",
"(",
"query",
",",
"properties",
")",
";",
"return",
"root",
";",
"}"
] | Add a Text Multi-match expression (document store only).
<p>
This automatically makes the query a document store query.
</p> | [
"Add",
"a",
"Text",
"Multi",
"-",
"match",
"expression",
"(",
"document",
"store",
"only",
")",
".",
"<p",
">",
"This",
"automatically",
"makes",
"the",
"query",
"a",
"document",
"store",
"query",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ebean-orm/ebean-querybean/blob/821650cb817c9c0fdcc97f93408dc79170b12423/src/main/java/io/ebean/typequery/TQRootBean.java#L1388-L1391 |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/Symmetry010Date.java | Symmetry010Date.resolvePreviousValid | private static Symmetry010Date resolvePreviousValid(int prolepticYear, int month, int dayOfMonth) {
"""
Consistency check for dates manipulations after calls to
{@link #plus(long, TemporalUnit)},
{@link #minus(long, TemporalUnit)},
{@link #until(AbstractDate, TemporalUnit)} or
{@link #with(TemporalField, long)}.
@param prolepticYear the Symmetry010 proleptic-year
@param month the Symmetry010 month, from 1 to 12
@param dayOfMonth the Symmetry010 day-of-month, from 1 to 30, or 1 to 31 in February, May, August, November,
or 1 to 37 in December in a Leap Year
@return the resolved date
"""
int monthR = Math.min(month, MONTHS_IN_YEAR);
int dayR = Math.min(dayOfMonth,
monthR == 12 && INSTANCE.isLeapYear(prolepticYear) ? DAYS_IN_MONTH + 7 :
monthR % 3 == 2 ? DAYS_IN_MONTH_LONG : DAYS_IN_MONTH);
return create(prolepticYear, monthR, dayR);
} | java | private static Symmetry010Date resolvePreviousValid(int prolepticYear, int month, int dayOfMonth) {
int monthR = Math.min(month, MONTHS_IN_YEAR);
int dayR = Math.min(dayOfMonth,
monthR == 12 && INSTANCE.isLeapYear(prolepticYear) ? DAYS_IN_MONTH + 7 :
monthR % 3 == 2 ? DAYS_IN_MONTH_LONG : DAYS_IN_MONTH);
return create(prolepticYear, monthR, dayR);
} | [
"private",
"static",
"Symmetry010Date",
"resolvePreviousValid",
"(",
"int",
"prolepticYear",
",",
"int",
"month",
",",
"int",
"dayOfMonth",
")",
"{",
"int",
"monthR",
"=",
"Math",
".",
"min",
"(",
"month",
",",
"MONTHS_IN_YEAR",
")",
";",
"int",
"dayR",
"=",
"Math",
".",
"min",
"(",
"dayOfMonth",
",",
"monthR",
"==",
"12",
"&&",
"INSTANCE",
".",
"isLeapYear",
"(",
"prolepticYear",
")",
"?",
"DAYS_IN_MONTH",
"+",
"7",
":",
"monthR",
"%",
"3",
"==",
"2",
"?",
"DAYS_IN_MONTH_LONG",
":",
"DAYS_IN_MONTH",
")",
";",
"return",
"create",
"(",
"prolepticYear",
",",
"monthR",
",",
"dayR",
")",
";",
"}"
] | Consistency check for dates manipulations after calls to
{@link #plus(long, TemporalUnit)},
{@link #minus(long, TemporalUnit)},
{@link #until(AbstractDate, TemporalUnit)} or
{@link #with(TemporalField, long)}.
@param prolepticYear the Symmetry010 proleptic-year
@param month the Symmetry010 month, from 1 to 12
@param dayOfMonth the Symmetry010 day-of-month, from 1 to 30, or 1 to 31 in February, May, August, November,
or 1 to 37 in December in a Leap Year
@return the resolved date | [
"Consistency",
"check",
"for",
"dates",
"manipulations",
"after",
"calls",
"to",
"{",
"@link",
"#plus",
"(",
"long",
"TemporalUnit",
")",
"}",
"{",
"@link",
"#minus",
"(",
"long",
"TemporalUnit",
")",
"}",
"{",
"@link",
"#until",
"(",
"AbstractDate",
"TemporalUnit",
")",
"}",
"or",
"{",
"@link",
"#with",
"(",
"TemporalField",
"long",
")",
"}",
"."
] | train | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/Symmetry010Date.java#L299-L305 |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicDate.java | EthiopicDate.ofEpochDay | static EthiopicDate ofEpochDay(final long epochDay) {
"""
Obtains a {@code EthiopicDate} representing a date in the Ethiopic calendar
system from the epoch-day.
@param epochDay the epoch day to convert based on 1970-01-01 (ISO)
@return the date in Ethiopic calendar system, not null
@throws DateTimeException if the epoch-day is out of range
"""
EPOCH_DAY.range().checkValidValue(epochDay, EPOCH_DAY); // validate outer bounds
long ethiopicED = epochDay + EPOCH_DAY_DIFFERENCE;
int adjustment = 0;
if (ethiopicED < 0) {
ethiopicED = ethiopicED + (1461L * (1_000_000L / 4));
adjustment = -1_000_000;
}
int prolepticYear = (int) (((ethiopicED * 4) + 1463) / 1461);
int startYearEpochDay = (prolepticYear - 1) * 365 + (prolepticYear / 4);
int doy0 = (int) (ethiopicED - startYearEpochDay);
int month = doy0 / 30 + 1;
int dom = doy0 % 30 + 1;
return new EthiopicDate(prolepticYear + adjustment, month, dom);
} | java | static EthiopicDate ofEpochDay(final long epochDay) {
EPOCH_DAY.range().checkValidValue(epochDay, EPOCH_DAY); // validate outer bounds
long ethiopicED = epochDay + EPOCH_DAY_DIFFERENCE;
int adjustment = 0;
if (ethiopicED < 0) {
ethiopicED = ethiopicED + (1461L * (1_000_000L / 4));
adjustment = -1_000_000;
}
int prolepticYear = (int) (((ethiopicED * 4) + 1463) / 1461);
int startYearEpochDay = (prolepticYear - 1) * 365 + (prolepticYear / 4);
int doy0 = (int) (ethiopicED - startYearEpochDay);
int month = doy0 / 30 + 1;
int dom = doy0 % 30 + 1;
return new EthiopicDate(prolepticYear + adjustment, month, dom);
} | [
"static",
"EthiopicDate",
"ofEpochDay",
"(",
"final",
"long",
"epochDay",
")",
"{",
"EPOCH_DAY",
".",
"range",
"(",
")",
".",
"checkValidValue",
"(",
"epochDay",
",",
"EPOCH_DAY",
")",
";",
"// validate outer bounds",
"long",
"ethiopicED",
"=",
"epochDay",
"+",
"EPOCH_DAY_DIFFERENCE",
";",
"int",
"adjustment",
"=",
"0",
";",
"if",
"(",
"ethiopicED",
"<",
"0",
")",
"{",
"ethiopicED",
"=",
"ethiopicED",
"+",
"(",
"1461L",
"*",
"(",
"1_000_000L",
"/",
"4",
")",
")",
";",
"adjustment",
"=",
"-",
"1_000_000",
";",
"}",
"int",
"prolepticYear",
"=",
"(",
"int",
")",
"(",
"(",
"(",
"ethiopicED",
"*",
"4",
")",
"+",
"1463",
")",
"/",
"1461",
")",
";",
"int",
"startYearEpochDay",
"=",
"(",
"prolepticYear",
"-",
"1",
")",
"*",
"365",
"+",
"(",
"prolepticYear",
"/",
"4",
")",
";",
"int",
"doy0",
"=",
"(",
"int",
")",
"(",
"ethiopicED",
"-",
"startYearEpochDay",
")",
";",
"int",
"month",
"=",
"doy0",
"/",
"30",
"+",
"1",
";",
"int",
"dom",
"=",
"doy0",
"%",
"30",
"+",
"1",
";",
"return",
"new",
"EthiopicDate",
"(",
"prolepticYear",
"+",
"adjustment",
",",
"month",
",",
"dom",
")",
";",
"}"
] | Obtains a {@code EthiopicDate} representing a date in the Ethiopic calendar
system from the epoch-day.
@param epochDay the epoch day to convert based on 1970-01-01 (ISO)
@return the date in Ethiopic calendar system, not null
@throws DateTimeException if the epoch-day is out of range | [
"Obtains",
"a",
"{",
"@code",
"EthiopicDate",
"}",
"representing",
"a",
"date",
"in",
"the",
"Ethiopic",
"calendar",
"system",
"from",
"the",
"epoch",
"-",
"day",
"."
] | train | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicDate.java#L220-L234 |
nwillc/almost-functional | src/main/java/almost/functional/utils/Iterables.java | Iterables.forEach | public static <T> void forEach(final Iterable<T> iterable, final Consumer<? super T> consumer) {
"""
Accept a consumer for each element of an iterable.
@param consumer the consumer to accept for each element
@param <T> the type of the iterable and consumer
@param iterable the iterable
"""
checkNotNull(iterable, "forEach must have a valid iterable");
checkNotNull(consumer, "forEach must have a valid consumer");
for (T t : iterable) {
consumer.accept(t);
}
} | java | public static <T> void forEach(final Iterable<T> iterable, final Consumer<? super T> consumer) {
checkNotNull(iterable, "forEach must have a valid iterable");
checkNotNull(consumer, "forEach must have a valid consumer");
for (T t : iterable) {
consumer.accept(t);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"forEach",
"(",
"final",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"final",
"Consumer",
"<",
"?",
"super",
"T",
">",
"consumer",
")",
"{",
"checkNotNull",
"(",
"iterable",
",",
"\"forEach must have a valid iterable\"",
")",
";",
"checkNotNull",
"(",
"consumer",
",",
"\"forEach must have a valid consumer\"",
")",
";",
"for",
"(",
"T",
"t",
":",
"iterable",
")",
"{",
"consumer",
".",
"accept",
"(",
"t",
")",
";",
"}",
"}"
] | Accept a consumer for each element of an iterable.
@param consumer the consumer to accept for each element
@param <T> the type of the iterable and consumer
@param iterable the iterable | [
"Accept",
"a",
"consumer",
"for",
"each",
"element",
"of",
"an",
"iterable",
"."
] | train | https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/utils/Iterables.java#L43-L50 |
Alluxio/alluxio | integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java | AlluxioFuseFileSystem.truncate | @Override
public int truncate(String path, long size) {
"""
Changes the size of a file. This operation would not succeed because of Alluxio's write-once
model.
"""
LOG.error("Truncate is not supported {}", path);
return -ErrorCodes.EOPNOTSUPP();
} | java | @Override
public int truncate(String path, long size) {
LOG.error("Truncate is not supported {}", path);
return -ErrorCodes.EOPNOTSUPP();
} | [
"@",
"Override",
"public",
"int",
"truncate",
"(",
"String",
"path",
",",
"long",
"size",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Truncate is not supported {}\"",
",",
"path",
")",
";",
"return",
"-",
"ErrorCodes",
".",
"EOPNOTSUPP",
"(",
")",
";",
"}"
] | Changes the size of a file. This operation would not succeed because of Alluxio's write-once
model. | [
"Changes",
"the",
"size",
"of",
"a",
"file",
".",
"This",
"operation",
"would",
"not",
"succeed",
"because",
"of",
"Alluxio",
"s",
"write",
"-",
"once",
"model",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java#L639-L643 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.translationRotate | public Matrix4d translationRotate(double tx, double ty, double tz, Quaterniondc quat) {
"""
Set <code>this</code> matrix to <code>T * R</code>, where <code>T</code> is a translation by the given <code>(tx, ty, tz)</code> and
<code>R</code> is a rotation - and possibly scaling - transformation specified by the given quaternion.
<p>
When transforming a vector by the resulting matrix the rotation - and possibly scaling - transformation will be applied first and then the translation.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
This method is equivalent to calling: <code>translation(tx, ty, tz).rotate(quat)</code>
@see #translation(double, double, double)
@see #rotate(Quaterniondc)
@param tx
the number of units by which to translate the x-component
@param ty
the number of units by which to translate the y-component
@param tz
the number of units by which to translate the z-component
@param quat
the quaternion representing a rotation
@return this
"""
return translationRotate(tx, ty, tz, quat.x(), quat.y(), quat.z(), quat.w());
} | java | public Matrix4d translationRotate(double tx, double ty, double tz, Quaterniondc quat) {
return translationRotate(tx, ty, tz, quat.x(), quat.y(), quat.z(), quat.w());
} | [
"public",
"Matrix4d",
"translationRotate",
"(",
"double",
"tx",
",",
"double",
"ty",
",",
"double",
"tz",
",",
"Quaterniondc",
"quat",
")",
"{",
"return",
"translationRotate",
"(",
"tx",
",",
"ty",
",",
"tz",
",",
"quat",
".",
"x",
"(",
")",
",",
"quat",
".",
"y",
"(",
")",
",",
"quat",
".",
"z",
"(",
")",
",",
"quat",
".",
"w",
"(",
")",
")",
";",
"}"
] | Set <code>this</code> matrix to <code>T * R</code>, where <code>T</code> is a translation by the given <code>(tx, ty, tz)</code> and
<code>R</code> is a rotation - and possibly scaling - transformation specified by the given quaternion.
<p>
When transforming a vector by the resulting matrix the rotation - and possibly scaling - transformation will be applied first and then the translation.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
This method is equivalent to calling: <code>translation(tx, ty, tz).rotate(quat)</code>
@see #translation(double, double, double)
@see #rotate(Quaterniondc)
@param tx
the number of units by which to translate the x-component
@param ty
the number of units by which to translate the y-component
@param tz
the number of units by which to translate the z-component
@param quat
the quaternion representing a rotation
@return this | [
"Set",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"to",
"<code",
">",
"T",
"*",
"R<",
"/",
"code",
">",
"where",
"<code",
">",
"T<",
"/",
"code",
">",
"is",
"a",
"translation",
"by",
"the",
"given",
"<code",
">",
"(",
"tx",
"ty",
"tz",
")",
"<",
"/",
"code",
">",
"and",
"<code",
">",
"R<",
"/",
"code",
">",
"is",
"a",
"rotation",
"-",
"and",
"possibly",
"scaling",
"-",
"transformation",
"specified",
"by",
"the",
"given",
"quaternion",
".",
"<p",
">",
"When",
"transforming",
"a",
"vector",
"by",
"the",
"resulting",
"matrix",
"the",
"rotation",
"-",
"and",
"possibly",
"scaling",
"-",
"transformation",
"will",
"be",
"applied",
"first",
"and",
"then",
"the",
"translation",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
":",
"<code",
">",
"translation",
"(",
"tx",
"ty",
"tz",
")",
".",
"rotate",
"(",
"quat",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L7547-L7549 |
pravega/pravega | segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/ContainerReadIndex.java | ContainerReadIndex.getOrCreateIndex | private StreamSegmentReadIndex getOrCreateIndex(long streamSegmentId) throws StreamSegmentNotExistsException {
"""
Gets a reference to the existing StreamSegmentRead index for the given StreamSegment Id. Creates a new one if
necessary.
@param streamSegmentId The Id of the StreamSegment whose ReadIndex to get.
"""
StreamSegmentReadIndex index;
synchronized (this.lock) {
// Try to see if we have the index already in memory.
index = getIndex(streamSegmentId);
if (index == null) {
// We don't have it, create one.
SegmentMetadata segmentMetadata = this.metadata.getStreamSegmentMetadata(streamSegmentId);
Exceptions.checkArgument(segmentMetadata != null, "streamSegmentId",
"StreamSegmentId %s does not exist in the metadata.", streamSegmentId);
if (segmentMetadata.isDeleted()) {
throw new StreamSegmentNotExistsException(segmentMetadata.getName());
}
index = new StreamSegmentReadIndex(this.config, segmentMetadata, this.cache, this.storage, this.executor, isRecoveryMode());
this.cacheManager.register(index);
this.readIndices.put(streamSegmentId, index);
}
}
return index;
} | java | private StreamSegmentReadIndex getOrCreateIndex(long streamSegmentId) throws StreamSegmentNotExistsException {
StreamSegmentReadIndex index;
synchronized (this.lock) {
// Try to see if we have the index already in memory.
index = getIndex(streamSegmentId);
if (index == null) {
// We don't have it, create one.
SegmentMetadata segmentMetadata = this.metadata.getStreamSegmentMetadata(streamSegmentId);
Exceptions.checkArgument(segmentMetadata != null, "streamSegmentId",
"StreamSegmentId %s does not exist in the metadata.", streamSegmentId);
if (segmentMetadata.isDeleted()) {
throw new StreamSegmentNotExistsException(segmentMetadata.getName());
}
index = new StreamSegmentReadIndex(this.config, segmentMetadata, this.cache, this.storage, this.executor, isRecoveryMode());
this.cacheManager.register(index);
this.readIndices.put(streamSegmentId, index);
}
}
return index;
} | [
"private",
"StreamSegmentReadIndex",
"getOrCreateIndex",
"(",
"long",
"streamSegmentId",
")",
"throws",
"StreamSegmentNotExistsException",
"{",
"StreamSegmentReadIndex",
"index",
";",
"synchronized",
"(",
"this",
".",
"lock",
")",
"{",
"// Try to see if we have the index already in memory.",
"index",
"=",
"getIndex",
"(",
"streamSegmentId",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"// We don't have it, create one.",
"SegmentMetadata",
"segmentMetadata",
"=",
"this",
".",
"metadata",
".",
"getStreamSegmentMetadata",
"(",
"streamSegmentId",
")",
";",
"Exceptions",
".",
"checkArgument",
"(",
"segmentMetadata",
"!=",
"null",
",",
"\"streamSegmentId\"",
",",
"\"StreamSegmentId %s does not exist in the metadata.\"",
",",
"streamSegmentId",
")",
";",
"if",
"(",
"segmentMetadata",
".",
"isDeleted",
"(",
")",
")",
"{",
"throw",
"new",
"StreamSegmentNotExistsException",
"(",
"segmentMetadata",
".",
"getName",
"(",
")",
")",
";",
"}",
"index",
"=",
"new",
"StreamSegmentReadIndex",
"(",
"this",
".",
"config",
",",
"segmentMetadata",
",",
"this",
".",
"cache",
",",
"this",
".",
"storage",
",",
"this",
".",
"executor",
",",
"isRecoveryMode",
"(",
")",
")",
";",
"this",
".",
"cacheManager",
".",
"register",
"(",
"index",
")",
";",
"this",
".",
"readIndices",
".",
"put",
"(",
"streamSegmentId",
",",
"index",
")",
";",
"}",
"}",
"return",
"index",
";",
"}"
] | Gets a reference to the existing StreamSegmentRead index for the given StreamSegment Id. Creates a new one if
necessary.
@param streamSegmentId The Id of the StreamSegment whose ReadIndex to get. | [
"Gets",
"a",
"reference",
"to",
"the",
"existing",
"StreamSegmentRead",
"index",
"for",
"the",
"given",
"StreamSegment",
"Id",
".",
"Creates",
"a",
"new",
"one",
"if",
"necessary",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/ContainerReadIndex.java#L356-L377 |
cdk/cdk | base/standard/src/main/java/org/openscience/cdk/tools/manipulator/RingSetManipulator.java | RingSetManipulator.isSameRing | public static boolean isSameRing(IRingSet ringSet, IAtom atom1, IAtom atom2) {
"""
Checks if <code>atom1</code> and <code>atom2</code> share membership in the same ring or ring system.
Membership in the same ring is checked if the RingSet contains the SSSR of a molecule; membership in
the same ring or same ring system is checked if the RingSet contains all rings of a molecule.<BR><BR>
<p><B>Important:</B> This method only returns meaningful results if <code>atom1</code> and
<code>atom2</code> are members of the same molecule for which the RingSet was calculated!
@param ringSet The collection of rings
@param atom1 The first atom
@param atom2 The second atom
@return boolean true if <code>atom1</code> and <code>atom2</code> share membership of at least one ring or ring system, false otherwise
"""
for (IAtomContainer atomContainer : ringSet.atomContainers()) {
IRing ring = (IRing) atomContainer;
if (ring.contains(atom1) && ring.contains(atom2)) return true;
}
return false;
} | java | public static boolean isSameRing(IRingSet ringSet, IAtom atom1, IAtom atom2) {
for (IAtomContainer atomContainer : ringSet.atomContainers()) {
IRing ring = (IRing) atomContainer;
if (ring.contains(atom1) && ring.contains(atom2)) return true;
}
return false;
} | [
"public",
"static",
"boolean",
"isSameRing",
"(",
"IRingSet",
"ringSet",
",",
"IAtom",
"atom1",
",",
"IAtom",
"atom2",
")",
"{",
"for",
"(",
"IAtomContainer",
"atomContainer",
":",
"ringSet",
".",
"atomContainers",
"(",
")",
")",
"{",
"IRing",
"ring",
"=",
"(",
"IRing",
")",
"atomContainer",
";",
"if",
"(",
"ring",
".",
"contains",
"(",
"atom1",
")",
"&&",
"ring",
".",
"contains",
"(",
"atom2",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if <code>atom1</code> and <code>atom2</code> share membership in the same ring or ring system.
Membership in the same ring is checked if the RingSet contains the SSSR of a molecule; membership in
the same ring or same ring system is checked if the RingSet contains all rings of a molecule.<BR><BR>
<p><B>Important:</B> This method only returns meaningful results if <code>atom1</code> and
<code>atom2</code> are members of the same molecule for which the RingSet was calculated!
@param ringSet The collection of rings
@param atom1 The first atom
@param atom2 The second atom
@return boolean true if <code>atom1</code> and <code>atom2</code> share membership of at least one ring or ring system, false otherwise | [
"Checks",
"if",
"<code",
">",
"atom1<",
"/",
"code",
">",
"and",
"<code",
">",
"atom2<",
"/",
"code",
">",
"share",
"membership",
"in",
"the",
"same",
"ring",
"or",
"ring",
"system",
".",
"Membership",
"in",
"the",
"same",
"ring",
"is",
"checked",
"if",
"the",
"RingSet",
"contains",
"the",
"SSSR",
"of",
"a",
"molecule",
";",
"membership",
"in",
"the",
"same",
"ring",
"or",
"same",
"ring",
"system",
"is",
"checked",
"if",
"the",
"RingSet",
"contains",
"all",
"rings",
"of",
"a",
"molecule",
".",
"<BR",
">",
"<BR",
">"
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/standard/src/main/java/org/openscience/cdk/tools/manipulator/RingSetManipulator.java#L217-L223 |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/CaretSelectionBindImpl.java | CaretSelectionBindImpl.doSelect | private void doSelect(int startPosition, int endPosition, boolean anchorIsStart) {
"""
/* ********************************************************************** *
*
Private methods *
*
**********************************************************************
"""
doUpdate(() -> {
delegateSelection.selectRange(startPosition, endPosition);
internalStartedByAnchor.setValue(anchorIsStart);
delegateCaret.moveTo(anchorIsStart ? endPosition : startPosition);
});
} | java | private void doSelect(int startPosition, int endPosition, boolean anchorIsStart) {
doUpdate(() -> {
delegateSelection.selectRange(startPosition, endPosition);
internalStartedByAnchor.setValue(anchorIsStart);
delegateCaret.moveTo(anchorIsStart ? endPosition : startPosition);
});
} | [
"private",
"void",
"doSelect",
"(",
"int",
"startPosition",
",",
"int",
"endPosition",
",",
"boolean",
"anchorIsStart",
")",
"{",
"doUpdate",
"(",
"(",
")",
"->",
"{",
"delegateSelection",
".",
"selectRange",
"(",
"startPosition",
",",
"endPosition",
")",
";",
"internalStartedByAnchor",
".",
"setValue",
"(",
"anchorIsStart",
")",
";",
"delegateCaret",
".",
"moveTo",
"(",
"anchorIsStart",
"?",
"endPosition",
":",
"startPosition",
")",
";",
"}",
")",
";",
"}"
] | /* ********************************************************************** *
*
Private methods *
*
********************************************************************** | [
"/",
"*",
"**********************************************************************",
"*",
"*",
"Private",
"methods",
"*",
"*",
"**********************************************************************"
] | train | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/CaretSelectionBindImpl.java#L449-L456 |
i-net-software/jlessc | src/com/inet/lib/less/CssFormatter.java | CssFormatter.appendProperty | void appendProperty( @Nonnull String name, @Nonnull Expression value ) {
"""
Append a property to the output like: name: value;
@param name
the name
@param value
the value
@throws LessException
if write properties in the root
"""
if( output == null ) {
throw new LessException( "Properties must be inside selector blocks, they cannot be in the root." );
}
insets();
name = SelectorUtils.replacePlaceHolder( this, name, value );
output.append( name ).append( ':' );
space();
value.appendTo( this );
if( state.importantCount > 0 || value.isImportant() ) {
output.append( " !important" );
}
semicolon();
newline();
} | java | void appendProperty( @Nonnull String name, @Nonnull Expression value ) {
if( output == null ) {
throw new LessException( "Properties must be inside selector blocks, they cannot be in the root." );
}
insets();
name = SelectorUtils.replacePlaceHolder( this, name, value );
output.append( name ).append( ':' );
space();
value.appendTo( this );
if( state.importantCount > 0 || value.isImportant() ) {
output.append( " !important" );
}
semicolon();
newline();
} | [
"void",
"appendProperty",
"(",
"@",
"Nonnull",
"String",
"name",
",",
"@",
"Nonnull",
"Expression",
"value",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"throw",
"new",
"LessException",
"(",
"\"Properties must be inside selector blocks, they cannot be in the root.\"",
")",
";",
"}",
"insets",
"(",
")",
";",
"name",
"=",
"SelectorUtils",
".",
"replacePlaceHolder",
"(",
"this",
",",
"name",
",",
"value",
")",
";",
"output",
".",
"append",
"(",
"name",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"space",
"(",
")",
";",
"value",
".",
"appendTo",
"(",
"this",
")",
";",
"if",
"(",
"state",
".",
"importantCount",
">",
"0",
"||",
"value",
".",
"isImportant",
"(",
")",
")",
"{",
"output",
".",
"append",
"(",
"\" !important\"",
")",
";",
"}",
"semicolon",
"(",
")",
";",
"newline",
"(",
")",
";",
"}"
] | Append a property to the output like: name: value;
@param name
the name
@param value
the value
@throws LessException
if write properties in the root | [
"Append",
"a",
"property",
"to",
"the",
"output",
"like",
":",
"name",
":",
"value",
";"
] | train | https://github.com/i-net-software/jlessc/blob/15b13e1637f6cc2e4d72df021e23ee0ca8d5e629/src/com/inet/lib/less/CssFormatter.java#L824-L838 |
Azure/azure-sdk-for-java | postgresql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/postgresql/v2017_12_01/implementation/FirewallRulesInner.java | FirewallRulesInner.beginCreateOrUpdateAsync | public Observable<FirewallRuleInner> beginCreateOrUpdateAsync(String resourceGroupName, String serverName, String firewallRuleName, FirewallRuleInner parameters) {
"""
Creates a new firewall rule or updates an existing firewall rule.
@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 firewallRuleName The name of the server firewall rule.
@param parameters The required parameters for creating or updating a firewall rule.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the FirewallRuleInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, firewallRuleName, parameters).map(new Func1<ServiceResponse<FirewallRuleInner>, FirewallRuleInner>() {
@Override
public FirewallRuleInner call(ServiceResponse<FirewallRuleInner> response) {
return response.body();
}
});
} | java | public Observable<FirewallRuleInner> beginCreateOrUpdateAsync(String resourceGroupName, String serverName, String firewallRuleName, FirewallRuleInner parameters) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, firewallRuleName, parameters).map(new Func1<ServiceResponse<FirewallRuleInner>, FirewallRuleInner>() {
@Override
public FirewallRuleInner call(ServiceResponse<FirewallRuleInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"FirewallRuleInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"firewallRuleName",
",",
"FirewallRuleInner",
"parameters",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"firewallRuleName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"FirewallRuleInner",
">",
",",
"FirewallRuleInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"FirewallRuleInner",
"call",
"(",
"ServiceResponse",
"<",
"FirewallRuleInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates a new firewall rule or updates an existing firewall rule.
@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 firewallRuleName The name of the server firewall rule.
@param parameters The required parameters for creating or updating a firewall rule.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the FirewallRuleInner object | [
"Creates",
"a",
"new",
"firewall",
"rule",
"or",
"updates",
"an",
"existing",
"firewall",
"rule",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/postgresql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/postgresql/v2017_12_01/implementation/FirewallRulesInner.java#L210-L217 |
gallandarakhneorg/afc | advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusNetwork.java | BusNetwork.addBusHub | public BusHub addBusHub(String name, BusStop... stops) {
"""
Add a bus hub in this network.
At least, one bus stop must be given to create a hub if you pass a
<code>null</code> name.
@param name is the name of the hub.
@param stops are the bus stops to put inside the hub.
@return the create bus hub, or <code>null</code> if not created.
"""
// Do not set immediatly the container to
// avoid event firing when adding the stops
final BusHub hub = new BusHub(null, name);
for (final BusStop stop : stops) {
hub.addBusStop(stop, false);
}
if (addBusHub(hub)) {
return hub;
}
return null;
} | java | public BusHub addBusHub(String name, BusStop... stops) {
// Do not set immediatly the container to
// avoid event firing when adding the stops
final BusHub hub = new BusHub(null, name);
for (final BusStop stop : stops) {
hub.addBusStop(stop, false);
}
if (addBusHub(hub)) {
return hub;
}
return null;
} | [
"public",
"BusHub",
"addBusHub",
"(",
"String",
"name",
",",
"BusStop",
"...",
"stops",
")",
"{",
"// Do not set immediatly the container to",
"// avoid event firing when adding the stops",
"final",
"BusHub",
"hub",
"=",
"new",
"BusHub",
"(",
"null",
",",
"name",
")",
";",
"for",
"(",
"final",
"BusStop",
"stop",
":",
"stops",
")",
"{",
"hub",
".",
"addBusStop",
"(",
"stop",
",",
"false",
")",
";",
"}",
"if",
"(",
"addBusHub",
"(",
"hub",
")",
")",
"{",
"return",
"hub",
";",
"}",
"return",
"null",
";",
"}"
] | Add a bus hub in this network.
At least, one bus stop must be given to create a hub if you pass a
<code>null</code> name.
@param name is the name of the hub.
@param stops are the bus stops to put inside the hub.
@return the create bus hub, or <code>null</code> if not created. | [
"Add",
"a",
"bus",
"hub",
"in",
"this",
"network",
".",
"At",
"least",
"one",
"bus",
"stop",
"must",
"be",
"given",
"to",
"create",
"a",
"hub",
"if",
"you",
"pass",
"a",
"<code",
">",
"null<",
"/",
"code",
">",
"name",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/gis/gisbus/src/main/java/org/arakhne/afc/gis/bus/network/BusNetwork.java#L1070-L1081 |
apache/spark | launcher/src/main/java/org/apache/spark/launcher/OutputRedirector.java | OutputRedirector.containsIgnoreCase | private static boolean containsIgnoreCase(String str, String searchStr) {
"""
Copied from Apache Commons Lang {@code StringUtils#containsIgnoreCase(String, String)}
"""
if (str == null || searchStr == null) {
return false;
}
int len = searchStr.length();
int max = str.length() - len;
for (int i = 0; i <= max; i++) {
if (str.regionMatches(true, i, searchStr, 0, len)) {
return true;
}
}
return false;
} | java | private static boolean containsIgnoreCase(String str, String searchStr) {
if (str == null || searchStr == null) {
return false;
}
int len = searchStr.length();
int max = str.length() - len;
for (int i = 0; i <= max; i++) {
if (str.regionMatches(true, i, searchStr, 0, len)) {
return true;
}
}
return false;
} | [
"private",
"static",
"boolean",
"containsIgnoreCase",
"(",
"String",
"str",
",",
"String",
"searchStr",
")",
"{",
"if",
"(",
"str",
"==",
"null",
"||",
"searchStr",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"int",
"len",
"=",
"searchStr",
".",
"length",
"(",
")",
";",
"int",
"max",
"=",
"str",
".",
"length",
"(",
")",
"-",
"len",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"max",
";",
"i",
"++",
")",
"{",
"if",
"(",
"str",
".",
"regionMatches",
"(",
"true",
",",
"i",
",",
"searchStr",
",",
"0",
",",
"len",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Copied from Apache Commons Lang {@code StringUtils#containsIgnoreCase(String, String)} | [
"Copied",
"from",
"Apache",
"Commons",
"Lang",
"{"
] | train | https://github.com/apache/spark/blob/25ee0474f47d9c30d6f553a7892d9549f91071cf/launcher/src/main/java/org/apache/spark/launcher/OutputRedirector.java#L100-L112 |
brunocvcunha/inutils4j | src/main/java/org/brunocvcunha/inutils4j/reflection/MyReflectionUtils.java | MyReflectionUtils.getClosestAnnotation | public static <T extends Annotation> T getClosestAnnotation(Method method, Class<T> typeOfT) {
"""
Get the closest annotation for a method (inherit from class)
@param method method
@param typeOfT type of annotation inspected
@return annotation instance
"""
T annotation = method.getAnnotation(typeOfT);
if (annotation == null) {
Class<?> clazzToIntrospect = method.getDeclaringClass();
while (annotation == null && clazzToIntrospect != null) {
annotation = clazzToIntrospect.getAnnotation(typeOfT);
clazzToIntrospect = clazzToIntrospect.getSuperclass();
}
}
return annotation;
} | java | public static <T extends Annotation> T getClosestAnnotation(Method method, Class<T> typeOfT) {
T annotation = method.getAnnotation(typeOfT);
if (annotation == null) {
Class<?> clazzToIntrospect = method.getDeclaringClass();
while (annotation == null && clazzToIntrospect != null) {
annotation = clazzToIntrospect.getAnnotation(typeOfT);
clazzToIntrospect = clazzToIntrospect.getSuperclass();
}
}
return annotation;
} | [
"public",
"static",
"<",
"T",
"extends",
"Annotation",
">",
"T",
"getClosestAnnotation",
"(",
"Method",
"method",
",",
"Class",
"<",
"T",
">",
"typeOfT",
")",
"{",
"T",
"annotation",
"=",
"method",
".",
"getAnnotation",
"(",
"typeOfT",
")",
";",
"if",
"(",
"annotation",
"==",
"null",
")",
"{",
"Class",
"<",
"?",
">",
"clazzToIntrospect",
"=",
"method",
".",
"getDeclaringClass",
"(",
")",
";",
"while",
"(",
"annotation",
"==",
"null",
"&&",
"clazzToIntrospect",
"!=",
"null",
")",
"{",
"annotation",
"=",
"clazzToIntrospect",
".",
"getAnnotation",
"(",
"typeOfT",
")",
";",
"clazzToIntrospect",
"=",
"clazzToIntrospect",
".",
"getSuperclass",
"(",
")",
";",
"}",
"}",
"return",
"annotation",
";",
"}"
] | Get the closest annotation for a method (inherit from class)
@param method method
@param typeOfT type of annotation inspected
@return annotation instance | [
"Get",
"the",
"closest",
"annotation",
"for",
"a",
"method",
"(",
"inherit",
"from",
"class",
")"
] | train | https://github.com/brunocvcunha/inutils4j/blob/223c4443c2cee662576ce644e552588fa114aa94/src/main/java/org/brunocvcunha/inutils4j/reflection/MyReflectionUtils.java#L116-L128 |
landawn/AbacusUtil | src/com/landawn/abacus/util/Iterables.java | Iterables.orderedPermutations | public static <E extends Comparable<? super E>> Collection<List<E>> orderedPermutations(Collection<E> elements) {
"""
Note: copy from Google Guava under Apache License v2.
<br />
Returns a {@link Collection} of all the permutations of the specified
{@link Iterable}.
<p><i>Notes:</i> This is an implementation of the algorithm for
Lexicographical Permutations Generation, described in Knuth's "The Art of
Computer Programming", Volume 4, Chapter 7, Section 7.2.1.2. The
iteration order follows the lexicographical order. This means that
the first permutation will be in ascending order, and the last will be in
descending order.
<p>Duplicate elements are considered equal. For example, the list [1, 1]
will have only one permutation, instead of two. This is why the elements
have to implement {@link Comparable}.
<p>An empty iterable has only one permutation, which is an empty list.
<p>This method is equivalent to
{@code Collections2.orderedPermutations(list, Ordering.natural())}.
@param elements the original iterable whose elements have to be permuted.
@return an immutable {@link Collection} containing all the different
permutations of the original iterable.
@throws NullPointerException if the specified iterable is null or has any
null elements.
"""
return orderedPermutations(elements, Comparators.naturalOrder());
} | java | public static <E extends Comparable<? super E>> Collection<List<E>> orderedPermutations(Collection<E> elements) {
return orderedPermutations(elements, Comparators.naturalOrder());
} | [
"public",
"static",
"<",
"E",
"extends",
"Comparable",
"<",
"?",
"super",
"E",
">",
">",
"Collection",
"<",
"List",
"<",
"E",
">",
">",
"orderedPermutations",
"(",
"Collection",
"<",
"E",
">",
"elements",
")",
"{",
"return",
"orderedPermutations",
"(",
"elements",
",",
"Comparators",
".",
"naturalOrder",
"(",
")",
")",
";",
"}"
] | Note: copy from Google Guava under Apache License v2.
<br />
Returns a {@link Collection} of all the permutations of the specified
{@link Iterable}.
<p><i>Notes:</i> This is an implementation of the algorithm for
Lexicographical Permutations Generation, described in Knuth's "The Art of
Computer Programming", Volume 4, Chapter 7, Section 7.2.1.2. The
iteration order follows the lexicographical order. This means that
the first permutation will be in ascending order, and the last will be in
descending order.
<p>Duplicate elements are considered equal. For example, the list [1, 1]
will have only one permutation, instead of two. This is why the elements
have to implement {@link Comparable}.
<p>An empty iterable has only one permutation, which is an empty list.
<p>This method is equivalent to
{@code Collections2.orderedPermutations(list, Ordering.natural())}.
@param elements the original iterable whose elements have to be permuted.
@return an immutable {@link Collection} containing all the different
permutations of the original iterable.
@throws NullPointerException if the specified iterable is null or has any
null elements. | [
"Note",
":",
"copy",
"from",
"Google",
"Guava",
"under",
"Apache",
"License",
"v2",
".",
"<br",
"/",
">"
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/Iterables.java#L669-L671 |
rometools/rome-certiorem | src/main/java/com/rometools/certiorem/hub/notify/standard/AbstractNotifier.java | AbstractNotifier.notifySubscribers | @Override
public void notifySubscribers(final List<? extends Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
"""
This method will serialize the synd feed and build Notifications for the implementation class
to handle.
@see enqueueNotification
@param subscribers List of subscribers to notify
@param value The SyndFeed object to send
@param callback A callback that will be invoked each time a subscriber is notified.
"""
String mimeType = null;
if (value.getFeedType().startsWith("rss")) {
mimeType = "application/rss+xml";
} else {
mimeType = "application/atom+xml";
}
final SyndFeedOutput output = new SyndFeedOutput();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
output.output(value, new OutputStreamWriter(baos));
baos.close();
} catch (final IOException ex) {
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
} catch (final FeedException ex) {
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
}
final byte[] payload = baos.toByteArray();
for (final Subscriber s : subscribers) {
final Notification not = new Notification();
not.callback = callback;
not.lastRun = 0;
not.mimeType = mimeType;
not.payload = payload;
not.retryCount = 0;
not.subscriber = s;
enqueueNotification(not);
}
} | java | @Override
public void notifySubscribers(final List<? extends Subscriber> subscribers, final SyndFeed value, final SubscriptionSummaryCallback callback) {
String mimeType = null;
if (value.getFeedType().startsWith("rss")) {
mimeType = "application/rss+xml";
} else {
mimeType = "application/atom+xml";
}
final SyndFeedOutput output = new SyndFeedOutput();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
output.output(value, new OutputStreamWriter(baos));
baos.close();
} catch (final IOException ex) {
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
} catch (final FeedException ex) {
LOG.error("Unable to output the feed", ex);
throw new RuntimeException("Unable to output the feed.", ex);
}
final byte[] payload = baos.toByteArray();
for (final Subscriber s : subscribers) {
final Notification not = new Notification();
not.callback = callback;
not.lastRun = 0;
not.mimeType = mimeType;
not.payload = payload;
not.retryCount = 0;
not.subscriber = s;
enqueueNotification(not);
}
} | [
"@",
"Override",
"public",
"void",
"notifySubscribers",
"(",
"final",
"List",
"<",
"?",
"extends",
"Subscriber",
">",
"subscribers",
",",
"final",
"SyndFeed",
"value",
",",
"final",
"SubscriptionSummaryCallback",
"callback",
")",
"{",
"String",
"mimeType",
"=",
"null",
";",
"if",
"(",
"value",
".",
"getFeedType",
"(",
")",
".",
"startsWith",
"(",
"\"rss\"",
")",
")",
"{",
"mimeType",
"=",
"\"application/rss+xml\"",
";",
"}",
"else",
"{",
"mimeType",
"=",
"\"application/atom+xml\"",
";",
"}",
"final",
"SyndFeedOutput",
"output",
"=",
"new",
"SyndFeedOutput",
"(",
")",
";",
"final",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"output",
".",
"output",
"(",
"value",
",",
"new",
"OutputStreamWriter",
"(",
"baos",
")",
")",
";",
"baos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to output the feed\"",
",",
"ex",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to output the feed.\"",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"final",
"FeedException",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unable to output the feed\"",
",",
"ex",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to output the feed.\"",
",",
"ex",
")",
";",
"}",
"final",
"byte",
"[",
"]",
"payload",
"=",
"baos",
".",
"toByteArray",
"(",
")",
";",
"for",
"(",
"final",
"Subscriber",
"s",
":",
"subscribers",
")",
"{",
"final",
"Notification",
"not",
"=",
"new",
"Notification",
"(",
")",
";",
"not",
".",
"callback",
"=",
"callback",
";",
"not",
".",
"lastRun",
"=",
"0",
";",
"not",
".",
"mimeType",
"=",
"mimeType",
";",
"not",
".",
"payload",
"=",
"payload",
";",
"not",
".",
"retryCount",
"=",
"0",
";",
"not",
".",
"subscriber",
"=",
"s",
";",
"enqueueNotification",
"(",
"not",
")",
";",
"}",
"}"
] | This method will serialize the synd feed and build Notifications for the implementation class
to handle.
@see enqueueNotification
@param subscribers List of subscribers to notify
@param value The SyndFeed object to send
@param callback A callback that will be invoked each time a subscriber is notified. | [
"This",
"method",
"will",
"serialize",
"the",
"synd",
"feed",
"and",
"build",
"Notifications",
"for",
"the",
"implementation",
"class",
"to",
"handle",
"."
] | train | https://github.com/rometools/rome-certiorem/blob/e5a003193dd2abd748e77961c0f216a7f5690712/src/main/java/com/rometools/certiorem/hub/notify/standard/AbstractNotifier.java#L59-L96 |
actframework/actframework | src/main/java/act/util/ClassNode.java | ClassNode.visitAnnotatedClasses | public ClassNode visitAnnotatedClasses($.Visitor<ClassNode> visitor, boolean publicOnly, boolean noAbstract) {
"""
Accept a visitor that visit all class node that has been annotated by the
class represented by this `ClassNode`
@param visitor the function that take `ClassNode` as argument
@param publicOnly specify whether non-public class shall be scanned
@param noAbstract specify whether abstract class shall be scanned
@return this `ClassNode` instance
"""
return visitAnnotatedClasses($.guardedVisitor(classNodeFilter(publicOnly, noAbstract), visitor));
} | java | public ClassNode visitAnnotatedClasses($.Visitor<ClassNode> visitor, boolean publicOnly, boolean noAbstract) {
return visitAnnotatedClasses($.guardedVisitor(classNodeFilter(publicOnly, noAbstract), visitor));
} | [
"public",
"ClassNode",
"visitAnnotatedClasses",
"(",
"$",
".",
"Visitor",
"<",
"ClassNode",
">",
"visitor",
",",
"boolean",
"publicOnly",
",",
"boolean",
"noAbstract",
")",
"{",
"return",
"visitAnnotatedClasses",
"(",
"$",
".",
"guardedVisitor",
"(",
"classNodeFilter",
"(",
"publicOnly",
",",
"noAbstract",
")",
",",
"visitor",
")",
")",
";",
"}"
] | Accept a visitor that visit all class node that has been annotated by the
class represented by this `ClassNode`
@param visitor the function that take `ClassNode` as argument
@param publicOnly specify whether non-public class shall be scanned
@param noAbstract specify whether abstract class shall be scanned
@return this `ClassNode` instance | [
"Accept",
"a",
"visitor",
"that",
"visit",
"all",
"class",
"node",
"that",
"has",
"been",
"annotated",
"by",
"the",
"class",
"represented",
"by",
"this",
"ClassNode"
] | train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/util/ClassNode.java#L335-L337 |
Stratio/stratio-cassandra | src/java/org/apache/cassandra/config/KSMetaData.java | KSMetaData.fromSchema | public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes) {
"""
Deserialize only Keyspace attributes without nested ColumnFamilies
@param row Keyspace attributes in serialized form
@return deserialized keyspace without cf_defs
"""
UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one();
try
{
return new KSMetaData(result.getString("keyspace_name"),
AbstractReplicationStrategy.getClass(result.getString("strategy_class")),
fromJsonMap(result.getString("strategy_options")),
result.getBoolean("durable_writes"),
cfms,
userTypes);
}
catch (ConfigurationException e)
{
throw new RuntimeException(e);
}
} | java | public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes)
{
UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one();
try
{
return new KSMetaData(result.getString("keyspace_name"),
AbstractReplicationStrategy.getClass(result.getString("strategy_class")),
fromJsonMap(result.getString("strategy_options")),
result.getBoolean("durable_writes"),
cfms,
userTypes);
}
catch (ConfigurationException e)
{
throw new RuntimeException(e);
}
} | [
"public",
"static",
"KSMetaData",
"fromSchema",
"(",
"Row",
"row",
",",
"Iterable",
"<",
"CFMetaData",
">",
"cfms",
",",
"UTMetaData",
"userTypes",
")",
"{",
"UntypedResultSet",
".",
"Row",
"result",
"=",
"QueryProcessor",
".",
"resultify",
"(",
"\"SELECT * FROM system.schema_keyspaces\"",
",",
"row",
")",
".",
"one",
"(",
")",
";",
"try",
"{",
"return",
"new",
"KSMetaData",
"(",
"result",
".",
"getString",
"(",
"\"keyspace_name\"",
")",
",",
"AbstractReplicationStrategy",
".",
"getClass",
"(",
"result",
".",
"getString",
"(",
"\"strategy_class\"",
")",
")",
",",
"fromJsonMap",
"(",
"result",
".",
"getString",
"(",
"\"strategy_options\"",
")",
")",
",",
"result",
".",
"getBoolean",
"(",
"\"durable_writes\"",
")",
",",
"cfms",
",",
"userTypes",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Deserialize only Keyspace attributes without nested ColumnFamilies
@param row Keyspace attributes in serialized form
@return deserialized keyspace without cf_defs | [
"Deserialize",
"only",
"Keyspace",
"attributes",
"without",
"nested",
"ColumnFamilies"
] | train | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/config/KSMetaData.java#L274-L290 |
buschmais/jqa-rdbms-plugin | src/main/java/com/buschmais/jqassistant/plugin/rdbms/impl/scanner/AbstractSchemaScannerPlugin.java | AbstractSchemaScannerPlugin.getCatalog | protected Catalog getCatalog(String url, String user, String password, String infoLevelName, String bundledDriverName, Properties properties)
throws IOException {
"""
Retrieves the catalog metadata using schema crawler.
@param url The url.
@param user The user.
@param password The password.
@param properties The properties to pass to schema crawler.
@param infoLevelName The name of the info level to use.
@param bundledDriverName The name of the bundled driver as provided by schema crawler.
@return The catalog.
@throws java.io.IOException If retrieval fails.
"""
// Determine info level
InfoLevel level = InfoLevel.valueOf(infoLevelName.toLowerCase());
SchemaInfoLevel schemaInfoLevel = level.getSchemaInfoLevel();
// Set options
for (InfoLevelOption option : InfoLevelOption.values()) {
String value = properties.getProperty(option.getPropertyName());
if (value != null) {
LOGGER.info("Setting option " + option.name() + "=" + value);
option.set(schemaInfoLevel, Boolean.valueOf(value.toLowerCase()));
}
}
SchemaCrawlerOptions options;
if (bundledDriverName != null) {
options = getOptions(bundledDriverName, level);
} else {
options = new SchemaCrawlerOptions();
}
options.setSchemaInfoLevel(schemaInfoLevel);
LOGGER.debug("Scanning database schemas on '" + url + "' (user='" + user + "', info level='" + level.name() + "')");
Catalog catalog;
try (Connection connection = DriverManager.getConnection(url, user, password)) {
catalog = SchemaCrawlerUtility.getCatalog(connection, options);
} catch (SQLException | SchemaCrawlerException e) {
throw new IOException(String.format("Cannot scan schema (url='%s', user='%s'", url, user), e);
}
return catalog;
} | java | protected Catalog getCatalog(String url, String user, String password, String infoLevelName, String bundledDriverName, Properties properties)
throws IOException {
// Determine info level
InfoLevel level = InfoLevel.valueOf(infoLevelName.toLowerCase());
SchemaInfoLevel schemaInfoLevel = level.getSchemaInfoLevel();
// Set options
for (InfoLevelOption option : InfoLevelOption.values()) {
String value = properties.getProperty(option.getPropertyName());
if (value != null) {
LOGGER.info("Setting option " + option.name() + "=" + value);
option.set(schemaInfoLevel, Boolean.valueOf(value.toLowerCase()));
}
}
SchemaCrawlerOptions options;
if (bundledDriverName != null) {
options = getOptions(bundledDriverName, level);
} else {
options = new SchemaCrawlerOptions();
}
options.setSchemaInfoLevel(schemaInfoLevel);
LOGGER.debug("Scanning database schemas on '" + url + "' (user='" + user + "', info level='" + level.name() + "')");
Catalog catalog;
try (Connection connection = DriverManager.getConnection(url, user, password)) {
catalog = SchemaCrawlerUtility.getCatalog(connection, options);
} catch (SQLException | SchemaCrawlerException e) {
throw new IOException(String.format("Cannot scan schema (url='%s', user='%s'", url, user), e);
}
return catalog;
} | [
"protected",
"Catalog",
"getCatalog",
"(",
"String",
"url",
",",
"String",
"user",
",",
"String",
"password",
",",
"String",
"infoLevelName",
",",
"String",
"bundledDriverName",
",",
"Properties",
"properties",
")",
"throws",
"IOException",
"{",
"// Determine info level",
"InfoLevel",
"level",
"=",
"InfoLevel",
".",
"valueOf",
"(",
"infoLevelName",
".",
"toLowerCase",
"(",
")",
")",
";",
"SchemaInfoLevel",
"schemaInfoLevel",
"=",
"level",
".",
"getSchemaInfoLevel",
"(",
")",
";",
"// Set options",
"for",
"(",
"InfoLevelOption",
"option",
":",
"InfoLevelOption",
".",
"values",
"(",
")",
")",
"{",
"String",
"value",
"=",
"properties",
".",
"getProperty",
"(",
"option",
".",
"getPropertyName",
"(",
")",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Setting option \"",
"+",
"option",
".",
"name",
"(",
")",
"+",
"\"=\"",
"+",
"value",
")",
";",
"option",
".",
"set",
"(",
"schemaInfoLevel",
",",
"Boolean",
".",
"valueOf",
"(",
"value",
".",
"toLowerCase",
"(",
")",
")",
")",
";",
"}",
"}",
"SchemaCrawlerOptions",
"options",
";",
"if",
"(",
"bundledDriverName",
"!=",
"null",
")",
"{",
"options",
"=",
"getOptions",
"(",
"bundledDriverName",
",",
"level",
")",
";",
"}",
"else",
"{",
"options",
"=",
"new",
"SchemaCrawlerOptions",
"(",
")",
";",
"}",
"options",
".",
"setSchemaInfoLevel",
"(",
"schemaInfoLevel",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"Scanning database schemas on '\"",
"+",
"url",
"+",
"\"' (user='\"",
"+",
"user",
"+",
"\"', info level='\"",
"+",
"level",
".",
"name",
"(",
")",
"+",
"\"')\"",
")",
";",
"Catalog",
"catalog",
";",
"try",
"(",
"Connection",
"connection",
"=",
"DriverManager",
".",
"getConnection",
"(",
"url",
",",
"user",
",",
"password",
")",
")",
"{",
"catalog",
"=",
"SchemaCrawlerUtility",
".",
"getCatalog",
"(",
"connection",
",",
"options",
")",
";",
"}",
"catch",
"(",
"SQLException",
"|",
"SchemaCrawlerException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Cannot scan schema (url='%s', user='%s'\"",
",",
"url",
",",
"user",
")",
",",
"e",
")",
";",
"}",
"return",
"catalog",
";",
"}"
] | Retrieves the catalog metadata using schema crawler.
@param url The url.
@param user The user.
@param password The password.
@param properties The properties to pass to schema crawler.
@param infoLevelName The name of the info level to use.
@param bundledDriverName The name of the bundled driver as provided by schema crawler.
@return The catalog.
@throws java.io.IOException If retrieval fails. | [
"Retrieves",
"the",
"catalog",
"metadata",
"using",
"schema",
"crawler",
"."
] | train | https://github.com/buschmais/jqa-rdbms-plugin/blob/96c3919907deee00175cf5ab005867d76e01ba62/src/main/java/com/buschmais/jqassistant/plugin/rdbms/impl/scanner/AbstractSchemaScannerPlugin.java#L72-L100 |
twotoasters/RecyclerViewLib | library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java | RecyclerView.addItemDecoration | public void addItemDecoration(ItemDecoration decor, int index) {
"""
Add an {@link com.twotoasters.android.support.v7.widget.RecyclerView.ItemDecoration} to this RecyclerView. Item decorations can
affect both measurement and drawing of individual item views.
<p>Item decorations are ordered. Decorations placed earlier in the list will
be run/queried/drawn first for their effects on item views. Padding added to views
will be nested; a padding added by an earlier decoration will mean further
item decorations in the list will be asked to draw/pad within the previous decoration's
given area.</p>
@param decor Decoration to add
@param index Position in the decoration chain to insert this decoration at. If this value
is negative the decoration will be added at the end.
"""
if (mItemDecorations.isEmpty()) {
setWillNotDraw(false);
}
if (index < 0) {
mItemDecorations.add(decor);
} else {
mItemDecorations.add(index, decor);
}
markItemDecorInsetsDirty();
requestLayout();
} | java | public void addItemDecoration(ItemDecoration decor, int index) {
if (mItemDecorations.isEmpty()) {
setWillNotDraw(false);
}
if (index < 0) {
mItemDecorations.add(decor);
} else {
mItemDecorations.add(index, decor);
}
markItemDecorInsetsDirty();
requestLayout();
} | [
"public",
"void",
"addItemDecoration",
"(",
"ItemDecoration",
"decor",
",",
"int",
"index",
")",
"{",
"if",
"(",
"mItemDecorations",
".",
"isEmpty",
"(",
")",
")",
"{",
"setWillNotDraw",
"(",
"false",
")",
";",
"}",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"mItemDecorations",
".",
"add",
"(",
"decor",
")",
";",
"}",
"else",
"{",
"mItemDecorations",
".",
"add",
"(",
"index",
",",
"decor",
")",
";",
"}",
"markItemDecorInsetsDirty",
"(",
")",
";",
"requestLayout",
"(",
")",
";",
"}"
] | Add an {@link com.twotoasters.android.support.v7.widget.RecyclerView.ItemDecoration} to this RecyclerView. Item decorations can
affect both measurement and drawing of individual item views.
<p>Item decorations are ordered. Decorations placed earlier in the list will
be run/queried/drawn first for their effects on item views. Padding added to views
will be nested; a padding added by an earlier decoration will mean further
item decorations in the list will be asked to draw/pad within the previous decoration's
given area.</p>
@param decor Decoration to add
@param index Position in the decoration chain to insert this decoration at. If this value
is negative the decoration will be added at the end. | [
"Add",
"an",
"{",
"@link",
"com",
".",
"twotoasters",
".",
"android",
".",
"support",
".",
"v7",
".",
"widget",
".",
"RecyclerView",
".",
"ItemDecoration",
"}",
"to",
"this",
"RecyclerView",
".",
"Item",
"decorations",
"can",
"affect",
"both",
"measurement",
"and",
"drawing",
"of",
"individual",
"item",
"views",
"."
] | train | https://github.com/twotoasters/RecyclerViewLib/blob/2379fd5bbf57d4dfc8b28046b7ace950905c75f0/library/src/main/java/com/twotoasters/android/support/v7/widget/RecyclerView.java#L555-L566 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/ParameterUtil.java | ParameterUtil.getDateParameter | public static Date getDateParameter (
HttpServletRequest req, String name, String invalidDataMessage)
throws DataValidationException {
"""
Fetches the supplied parameter from the request and converts it to a date. The value of the
parameter should be a date formatted like so: 2001-12-25. If the parameter does not exist,
null is returned. If the parameter is not a well-formed date, a data validation exception is
thrown with the supplied message.
"""
String value = getParameter(req, name, false);
if (StringUtil.isBlank(value) ||
DATE_TEMPLATE.equalsIgnoreCase(value)) {
return null;
}
return parseDateParameter(value, invalidDataMessage);
} | java | public static Date getDateParameter (
HttpServletRequest req, String name, String invalidDataMessage)
throws DataValidationException
{
String value = getParameter(req, name, false);
if (StringUtil.isBlank(value) ||
DATE_TEMPLATE.equalsIgnoreCase(value)) {
return null;
}
return parseDateParameter(value, invalidDataMessage);
} | [
"public",
"static",
"Date",
"getDateParameter",
"(",
"HttpServletRequest",
"req",
",",
"String",
"name",
",",
"String",
"invalidDataMessage",
")",
"throws",
"DataValidationException",
"{",
"String",
"value",
"=",
"getParameter",
"(",
"req",
",",
"name",
",",
"false",
")",
";",
"if",
"(",
"StringUtil",
".",
"isBlank",
"(",
"value",
")",
"||",
"DATE_TEMPLATE",
".",
"equalsIgnoreCase",
"(",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"parseDateParameter",
"(",
"value",
",",
"invalidDataMessage",
")",
";",
"}"
] | Fetches the supplied parameter from the request and converts it to a date. The value of the
parameter should be a date formatted like so: 2001-12-25. If the parameter does not exist,
null is returned. If the parameter is not a well-formed date, a data validation exception is
thrown with the supplied message. | [
"Fetches",
"the",
"supplied",
"parameter",
"from",
"the",
"request",
"and",
"converts",
"it",
"to",
"a",
"date",
".",
"The",
"value",
"of",
"the",
"parameter",
"should",
"be",
"a",
"date",
"formatted",
"like",
"so",
":",
"2001",
"-",
"12",
"-",
"25",
".",
"If",
"the",
"parameter",
"does",
"not",
"exist",
"null",
"is",
"returned",
".",
"If",
"the",
"parameter",
"is",
"not",
"a",
"well",
"-",
"formed",
"date",
"a",
"data",
"validation",
"exception",
"is",
"thrown",
"with",
"the",
"supplied",
"message",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/ParameterUtil.java#L260-L270 |
citrusframework/citrus | modules/citrus-kubernetes/src/main/java/com/consol/citrus/kubernetes/command/AbstractCreateCommand.java | AbstractCreateCommand.getTemplateAsStream | protected InputStream getTemplateAsStream(TestContext context) {
"""
Create input stream from template resource and add test variable support.
@param context
@return
"""
Resource resource;
if (templateResource != null) {
resource = templateResource;
} else {
resource = FileUtils.getFileResource(template, context);
}
String templateYml;
try {
templateYml = context.replaceDynamicContentInString(FileUtils.readToString(resource));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read template resource", e);
}
return new ByteArrayInputStream(templateYml.getBytes());
} | java | protected InputStream getTemplateAsStream(TestContext context) {
Resource resource;
if (templateResource != null) {
resource = templateResource;
} else {
resource = FileUtils.getFileResource(template, context);
}
String templateYml;
try {
templateYml = context.replaceDynamicContentInString(FileUtils.readToString(resource));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read template resource", e);
}
return new ByteArrayInputStream(templateYml.getBytes());
} | [
"protected",
"InputStream",
"getTemplateAsStream",
"(",
"TestContext",
"context",
")",
"{",
"Resource",
"resource",
";",
"if",
"(",
"templateResource",
"!=",
"null",
")",
"{",
"resource",
"=",
"templateResource",
";",
"}",
"else",
"{",
"resource",
"=",
"FileUtils",
".",
"getFileResource",
"(",
"template",
",",
"context",
")",
";",
"}",
"String",
"templateYml",
";",
"try",
"{",
"templateYml",
"=",
"context",
".",
"replaceDynamicContentInString",
"(",
"FileUtils",
".",
"readToString",
"(",
"resource",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"CitrusRuntimeException",
"(",
"\"Failed to read template resource\"",
",",
"e",
")",
";",
"}",
"return",
"new",
"ByteArrayInputStream",
"(",
"templateYml",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] | Create input stream from template resource and add test variable support.
@param context
@return | [
"Create",
"input",
"stream",
"from",
"template",
"resource",
"and",
"add",
"test",
"variable",
"support",
"."
] | train | https://github.com/citrusframework/citrus/blob/55c58ef74c01d511615e43646ca25c1b2301c56d/modules/citrus-kubernetes/src/main/java/com/consol/citrus/kubernetes/command/AbstractCreateCommand.java#L81-L96 |
hibernate/hibernate-ogm | core/src/main/java/org/hibernate/ogm/util/impl/TupleContextHelper.java | TupleContextHelper.tupleContext | public static TupleContext tupleContext(SharedSessionContractImplementor session, EntityMetadataInformation metadata) {
"""
Given a {@link SessionImplementor} returns the {@link TupleContext} associated to an entity.
@param session the current session
@param metadata the {@link EntityMetadataInformation} of the entity associated to the TupleContext
@return the TupleContext associated to the current session for the entity specified
"""
if ( metadata != null ) {
OgmEntityPersister persister = (OgmEntityPersister) session.getFactory().getMetamodel().entityPersister( metadata.getTypeName() );
return persister.getTupleContext( session );
}
else if ( session != null ) {
// We are not dealing with a single entity but we might still need the transactionContext
TransactionContext transactionContext = TransactionContextHelper.transactionContext( session );
TupleContext tupleContext = new OnlyWithTransactionContext( transactionContext );
return tupleContext;
}
else {
return null;
}
} | java | public static TupleContext tupleContext(SharedSessionContractImplementor session, EntityMetadataInformation metadata) {
if ( metadata != null ) {
OgmEntityPersister persister = (OgmEntityPersister) session.getFactory().getMetamodel().entityPersister( metadata.getTypeName() );
return persister.getTupleContext( session );
}
else if ( session != null ) {
// We are not dealing with a single entity but we might still need the transactionContext
TransactionContext transactionContext = TransactionContextHelper.transactionContext( session );
TupleContext tupleContext = new OnlyWithTransactionContext( transactionContext );
return tupleContext;
}
else {
return null;
}
} | [
"public",
"static",
"TupleContext",
"tupleContext",
"(",
"SharedSessionContractImplementor",
"session",
",",
"EntityMetadataInformation",
"metadata",
")",
"{",
"if",
"(",
"metadata",
"!=",
"null",
")",
"{",
"OgmEntityPersister",
"persister",
"=",
"(",
"OgmEntityPersister",
")",
"session",
".",
"getFactory",
"(",
")",
".",
"getMetamodel",
"(",
")",
".",
"entityPersister",
"(",
"metadata",
".",
"getTypeName",
"(",
")",
")",
";",
"return",
"persister",
".",
"getTupleContext",
"(",
"session",
")",
";",
"}",
"else",
"if",
"(",
"session",
"!=",
"null",
")",
"{",
"// We are not dealing with a single entity but we might still need the transactionContext",
"TransactionContext",
"transactionContext",
"=",
"TransactionContextHelper",
".",
"transactionContext",
"(",
"session",
")",
";",
"TupleContext",
"tupleContext",
"=",
"new",
"OnlyWithTransactionContext",
"(",
"transactionContext",
")",
";",
"return",
"tupleContext",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Given a {@link SessionImplementor} returns the {@link TupleContext} associated to an entity.
@param session the current session
@param metadata the {@link EntityMetadataInformation} of the entity associated to the TupleContext
@return the TupleContext associated to the current session for the entity specified | [
"Given",
"a",
"{",
"@link",
"SessionImplementor",
"}",
"returns",
"the",
"{",
"@link",
"TupleContext",
"}",
"associated",
"to",
"an",
"entity",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/TupleContextHelper.java#L34-L48 |
voldemort/voldemort | src/java/voldemort/utils/RebalanceUtils.java | RebalanceUtils.validateClusterStores | public static void validateClusterStores(final Cluster cluster,
final List<StoreDefinition> storeDefs) {
"""
Verify store definitions are congruent with cluster definition.
@param cluster
@param storeDefs
"""
// Constructing a StoreRoutingPlan has the (desirable in this
// case) side-effect of verifying that the store definition is congruent
// with the cluster definition. If there are issues, exceptions are
// thrown.
for(StoreDefinition storeDefinition: storeDefs) {
new StoreRoutingPlan(cluster, storeDefinition);
}
return;
} | java | public static void validateClusterStores(final Cluster cluster,
final List<StoreDefinition> storeDefs) {
// Constructing a StoreRoutingPlan has the (desirable in this
// case) side-effect of verifying that the store definition is congruent
// with the cluster definition. If there are issues, exceptions are
// thrown.
for(StoreDefinition storeDefinition: storeDefs) {
new StoreRoutingPlan(cluster, storeDefinition);
}
return;
} | [
"public",
"static",
"void",
"validateClusterStores",
"(",
"final",
"Cluster",
"cluster",
",",
"final",
"List",
"<",
"StoreDefinition",
">",
"storeDefs",
")",
"{",
"// Constructing a StoreRoutingPlan has the (desirable in this",
"// case) side-effect of verifying that the store definition is congruent",
"// with the cluster definition. If there are issues, exceptions are",
"// thrown.",
"for",
"(",
"StoreDefinition",
"storeDefinition",
":",
"storeDefs",
")",
"{",
"new",
"StoreRoutingPlan",
"(",
"cluster",
",",
"storeDefinition",
")",
";",
"}",
"return",
";",
"}"
] | Verify store definitions are congruent with cluster definition.
@param cluster
@param storeDefs | [
"Verify",
"store",
"definitions",
"are",
"congruent",
"with",
"cluster",
"definition",
"."
] | train | https://github.com/voldemort/voldemort/blob/a7dbdea58032021361680faacf2782cf981c5332/src/java/voldemort/utils/RebalanceUtils.java#L76-L86 |
google/error-prone | check_api/src/main/java/com/google/errorprone/matchers/Matchers.java | Matchers.methodNameStartsWith | public static Matcher<MethodTree> methodNameStartsWith(final String prefix) {
"""
Match a method declaration that starts with a given string.
@param prefix The prefix.
"""
return new Matcher<MethodTree>() {
@Override
public boolean matches(MethodTree methodTree, VisitorState state) {
return methodTree.getName().toString().startsWith(prefix);
}
};
} | java | public static Matcher<MethodTree> methodNameStartsWith(final String prefix) {
return new Matcher<MethodTree>() {
@Override
public boolean matches(MethodTree methodTree, VisitorState state) {
return methodTree.getName().toString().startsWith(prefix);
}
};
} | [
"public",
"static",
"Matcher",
"<",
"MethodTree",
">",
"methodNameStartsWith",
"(",
"final",
"String",
"prefix",
")",
"{",
"return",
"new",
"Matcher",
"<",
"MethodTree",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"MethodTree",
"methodTree",
",",
"VisitorState",
"state",
")",
"{",
"return",
"methodTree",
".",
"getName",
"(",
")",
".",
"toString",
"(",
")",
".",
"startsWith",
"(",
"prefix",
")",
";",
"}",
"}",
";",
"}"
] | Match a method declaration that starts with a given string.
@param prefix The prefix. | [
"Match",
"a",
"method",
"declaration",
"that",
"starts",
"with",
"a",
"given",
"string",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/check_api/src/main/java/com/google/errorprone/matchers/Matchers.java#L932-L939 |
logic-ng/LogicNG | src/main/java/org/logicng/solvers/CleaneLing.java | CleaneLing.createAssignment | private Assignment createAssignment(final LNGBooleanVector vec, final Collection<Variable> variables) {
"""
Creates an assignment from a Boolean vector of the solver.
@param vec the vector of the solver
@param variables the variables which should appear in the model or {@code null} if all variables should
appear
@return the assignment
"""
final Assignment model = new Assignment();
for (int i = 1; i < vec.size(); i++) {
final Variable var = this.f.variable(this.idx2name.get(i));
if (vec.get(i)) {
if (variables == null || variables.contains(var)) { model.addLiteral(var); }
} else if (variables == null || variables.contains(var)) { model.addLiteral(var.negate()); }
}
return model;
} | java | private Assignment createAssignment(final LNGBooleanVector vec, final Collection<Variable> variables) {
final Assignment model = new Assignment();
for (int i = 1; i < vec.size(); i++) {
final Variable var = this.f.variable(this.idx2name.get(i));
if (vec.get(i)) {
if (variables == null || variables.contains(var)) { model.addLiteral(var); }
} else if (variables == null || variables.contains(var)) { model.addLiteral(var.negate()); }
}
return model;
} | [
"private",
"Assignment",
"createAssignment",
"(",
"final",
"LNGBooleanVector",
"vec",
",",
"final",
"Collection",
"<",
"Variable",
">",
"variables",
")",
"{",
"final",
"Assignment",
"model",
"=",
"new",
"Assignment",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"vec",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Variable",
"var",
"=",
"this",
".",
"f",
".",
"variable",
"(",
"this",
".",
"idx2name",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"vec",
".",
"get",
"(",
"i",
")",
")",
"{",
"if",
"(",
"variables",
"==",
"null",
"||",
"variables",
".",
"contains",
"(",
"var",
")",
")",
"{",
"model",
".",
"addLiteral",
"(",
"var",
")",
";",
"}",
"}",
"else",
"if",
"(",
"variables",
"==",
"null",
"||",
"variables",
".",
"contains",
"(",
"var",
")",
")",
"{",
"model",
".",
"addLiteral",
"(",
"var",
".",
"negate",
"(",
")",
")",
";",
"}",
"}",
"return",
"model",
";",
"}"
] | Creates an assignment from a Boolean vector of the solver.
@param vec the vector of the solver
@param variables the variables which should appear in the model or {@code null} if all variables should
appear
@return the assignment | [
"Creates",
"an",
"assignment",
"from",
"a",
"Boolean",
"vector",
"of",
"the",
"solver",
"."
] | train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/solvers/CleaneLing.java#L322-L331 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapters.java | IndexChangeAdapters.forNodeDepth | public static IndexChangeAdapter forNodeDepth( ExecutionContext context,
NodeTypePredicate matcher,
String workspaceName,
ProvidedIndex<?> index ) {
"""
Create an {@link IndexChangeAdapter} implementation that handles the "mode:nodeDepth" property.
@param context the execution context; may not be null
@param matcher the node type matcher used to determine which nodes should be included in the index; may not be null
@param workspaceName the name of the workspace; may not be null
@param index the index that should be used; may not be null
@return the new {@link IndexChangeAdapter}; never null
"""
return new NodeDepthChangeAdapter(context, matcher, workspaceName, index);
} | java | public static IndexChangeAdapter forNodeDepth( ExecutionContext context,
NodeTypePredicate matcher,
String workspaceName,
ProvidedIndex<?> index ) {
return new NodeDepthChangeAdapter(context, matcher, workspaceName, index);
} | [
"public",
"static",
"IndexChangeAdapter",
"forNodeDepth",
"(",
"ExecutionContext",
"context",
",",
"NodeTypePredicate",
"matcher",
",",
"String",
"workspaceName",
",",
"ProvidedIndex",
"<",
"?",
">",
"index",
")",
"{",
"return",
"new",
"NodeDepthChangeAdapter",
"(",
"context",
",",
"matcher",
",",
"workspaceName",
",",
"index",
")",
";",
"}"
] | Create an {@link IndexChangeAdapter} implementation that handles the "mode:nodeDepth" property.
@param context the execution context; may not be null
@param matcher the node type matcher used to determine which nodes should be included in the index; may not be null
@param workspaceName the name of the workspace; may not be null
@param index the index that should be used; may not be null
@return the new {@link IndexChangeAdapter}; never null | [
"Create",
"an",
"{",
"@link",
"IndexChangeAdapter",
"}",
"implementation",
"that",
"handles",
"the",
"mode",
":",
"nodeDepth",
"property",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/spi/index/provider/IndexChangeAdapters.java#L80-L85 |
azkaban/azkaban | azkaban-common/src/main/java/azkaban/executor/selector/ExecutorComparator.java | ExecutorComparator.getCpuUsageComparator | private static FactorComparator<Executor> getCpuUsageComparator(final int weight) {
"""
function defines the cpuUsage comparator.
@param weight weight of the comparator.
"""
return FactorComparator.create(CPUUSAGE_COMPARATOR_NAME, weight, new Comparator<Executor>() {
@Override
public int compare(final Executor o1, final Executor o2) {
final ExecutorInfo stat1 = o1.getExecutorInfo();
final ExecutorInfo stat2 = o2.getExecutorInfo();
final int result = 0;
if (statisticsObjectCheck(stat1, stat2, CPUUSAGE_COMPARATOR_NAME)) {
return result;
}
// CPU usage , the lesser the value is, the better.
return ((Double) stat2.getCpuUsage()).compareTo(stat1.getCpuUsage());
}
});
} | java | private static FactorComparator<Executor> getCpuUsageComparator(final int weight) {
return FactorComparator.create(CPUUSAGE_COMPARATOR_NAME, weight, new Comparator<Executor>() {
@Override
public int compare(final Executor o1, final Executor o2) {
final ExecutorInfo stat1 = o1.getExecutorInfo();
final ExecutorInfo stat2 = o2.getExecutorInfo();
final int result = 0;
if (statisticsObjectCheck(stat1, stat2, CPUUSAGE_COMPARATOR_NAME)) {
return result;
}
// CPU usage , the lesser the value is, the better.
return ((Double) stat2.getCpuUsage()).compareTo(stat1.getCpuUsage());
}
});
} | [
"private",
"static",
"FactorComparator",
"<",
"Executor",
">",
"getCpuUsageComparator",
"(",
"final",
"int",
"weight",
")",
"{",
"return",
"FactorComparator",
".",
"create",
"(",
"CPUUSAGE_COMPARATOR_NAME",
",",
"weight",
",",
"new",
"Comparator",
"<",
"Executor",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"final",
"Executor",
"o1",
",",
"final",
"Executor",
"o2",
")",
"{",
"final",
"ExecutorInfo",
"stat1",
"=",
"o1",
".",
"getExecutorInfo",
"(",
")",
";",
"final",
"ExecutorInfo",
"stat2",
"=",
"o2",
".",
"getExecutorInfo",
"(",
")",
";",
"final",
"int",
"result",
"=",
"0",
";",
"if",
"(",
"statisticsObjectCheck",
"(",
"stat1",
",",
"stat2",
",",
"CPUUSAGE_COMPARATOR_NAME",
")",
")",
"{",
"return",
"result",
";",
"}",
"// CPU usage , the lesser the value is, the better.",
"return",
"(",
"(",
"Double",
")",
"stat2",
".",
"getCpuUsage",
"(",
")",
")",
".",
"compareTo",
"(",
"stat1",
".",
"getCpuUsage",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | function defines the cpuUsage comparator.
@param weight weight of the comparator. | [
"function",
"defines",
"the",
"cpuUsage",
"comparator",
"."
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/azkaban-common/src/main/java/azkaban/executor/selector/ExecutorComparator.java#L173-L190 |
lievendoclo/Valkyrie-RCP | valkyrie-rcp-core/src/main/java/org/valkyriercp/component/BigDecimalTextField.java | BigDecimalTextField.setBigDecimalFormat | private static final void setBigDecimalFormat(NumberFormat format, Class numberClass) {
"""
When parsing a number, BigDecimalFormat can return numbers different than
BigDecimal. This method will ensure that when using a {@link BigDecimal}
or a {@link java.math.BigInteger}, the formatter will return a {@link BigDecimal}
in order to prevent loss of precision. Note that you should use the
{@link DecimalFormat} to make this work.
@param format
@param numberClass
@see #getValue()
@see DecimalFormat#setParseBigDecimal(boolean)
"""
if (format instanceof DecimalFormat && ((numberClass == BigDecimal.class) || (numberClass == BigInteger.class))) {
((DecimalFormat) format).setParseBigDecimal(true);
}
} | java | private static final void setBigDecimalFormat(NumberFormat format, Class numberClass) {
if (format instanceof DecimalFormat && ((numberClass == BigDecimal.class) || (numberClass == BigInteger.class))) {
((DecimalFormat) format).setParseBigDecimal(true);
}
} | [
"private",
"static",
"final",
"void",
"setBigDecimalFormat",
"(",
"NumberFormat",
"format",
",",
"Class",
"numberClass",
")",
"{",
"if",
"(",
"format",
"instanceof",
"DecimalFormat",
"&&",
"(",
"(",
"numberClass",
"==",
"BigDecimal",
".",
"class",
")",
"||",
"(",
"numberClass",
"==",
"BigInteger",
".",
"class",
")",
")",
")",
"{",
"(",
"(",
"DecimalFormat",
")",
"format",
")",
".",
"setParseBigDecimal",
"(",
"true",
")",
";",
"}",
"}"
] | When parsing a number, BigDecimalFormat can return numbers different than
BigDecimal. This method will ensure that when using a {@link BigDecimal}
or a {@link java.math.BigInteger}, the formatter will return a {@link BigDecimal}
in order to prevent loss of precision. Note that you should use the
{@link DecimalFormat} to make this work.
@param format
@param numberClass
@see #getValue()
@see DecimalFormat#setParseBigDecimal(boolean) | [
"When",
"parsing",
"a",
"number",
"BigDecimalFormat",
"can",
"return",
"numbers",
"different",
"than",
"BigDecimal",
".",
"This",
"method",
"will",
"ensure",
"that",
"when",
"using",
"a",
"{",
"@link",
"BigDecimal",
"}",
"or",
"a",
"{",
"@link",
"java",
".",
"math",
".",
"BigInteger",
"}",
"the",
"formatter",
"will",
"return",
"a",
"{",
"@link",
"BigDecimal",
"}",
"in",
"order",
"to",
"prevent",
"loss",
"of",
"precision",
".",
"Note",
"that",
"you",
"should",
"use",
"the",
"{",
"@link",
"DecimalFormat",
"}",
"to",
"make",
"this",
"work",
"."
] | train | https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/component/BigDecimalTextField.java#L153-L157 |
infinispan/infinispan | core/src/main/java/org/infinispan/interceptors/impl/BatchingInterceptor.java | BatchingInterceptor.handleDefault | @Override
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable {
"""
Simply check if there is an ongoing tx. <ul> <li>If there is one, this is a no-op and just passes the call up the
chain.</li> <li>If there isn't one and there is a batch in progress, resume the batch's tx, pass up, and finally
suspend the batch's tx.</li> <li>If there is no batch in progress, just pass the call up the chain.</li> </ul>
"""
if (!ctx.isOriginLocal()) {
// Nothing to do for remote calls
return invokeNext(ctx, command);
}
Transaction tx;
if (transactionManager.getTransaction() != null || (tx = batchContainer.getBatchTransaction()) == null) {
// The active transaction means we are in an auto-batch.
// No batch means a read-only auto-batch.
// Either way, we don't need to do anything
return invokeNext(ctx, command);
}
try {
transactionManager.resume(tx);
if (ctx.isInTxScope()) {
return invokeNext(ctx, command);
}
log.tracef("Called with a non-tx invocation context: %s", ctx);
InvocationContext txInvocationContext = invocationContextFactory.createInvocationContext(true, -1);
return invokeNext(txInvocationContext, command);
} finally {
suspendTransaction();
}
} | java | @Override
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable {
if (!ctx.isOriginLocal()) {
// Nothing to do for remote calls
return invokeNext(ctx, command);
}
Transaction tx;
if (transactionManager.getTransaction() != null || (tx = batchContainer.getBatchTransaction()) == null) {
// The active transaction means we are in an auto-batch.
// No batch means a read-only auto-batch.
// Either way, we don't need to do anything
return invokeNext(ctx, command);
}
try {
transactionManager.resume(tx);
if (ctx.isInTxScope()) {
return invokeNext(ctx, command);
}
log.tracef("Called with a non-tx invocation context: %s", ctx);
InvocationContext txInvocationContext = invocationContextFactory.createInvocationContext(true, -1);
return invokeNext(txInvocationContext, command);
} finally {
suspendTransaction();
}
} | [
"@",
"Override",
"public",
"Object",
"handleDefault",
"(",
"InvocationContext",
"ctx",
",",
"VisitableCommand",
"command",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"!",
"ctx",
".",
"isOriginLocal",
"(",
")",
")",
"{",
"// Nothing to do for remote calls",
"return",
"invokeNext",
"(",
"ctx",
",",
"command",
")",
";",
"}",
"Transaction",
"tx",
";",
"if",
"(",
"transactionManager",
".",
"getTransaction",
"(",
")",
"!=",
"null",
"||",
"(",
"tx",
"=",
"batchContainer",
".",
"getBatchTransaction",
"(",
")",
")",
"==",
"null",
")",
"{",
"// The active transaction means we are in an auto-batch.",
"// No batch means a read-only auto-batch.",
"// Either way, we don't need to do anything",
"return",
"invokeNext",
"(",
"ctx",
",",
"command",
")",
";",
"}",
"try",
"{",
"transactionManager",
".",
"resume",
"(",
"tx",
")",
";",
"if",
"(",
"ctx",
".",
"isInTxScope",
"(",
")",
")",
"{",
"return",
"invokeNext",
"(",
"ctx",
",",
"command",
")",
";",
"}",
"log",
".",
"tracef",
"(",
"\"Called with a non-tx invocation context: %s\"",
",",
"ctx",
")",
";",
"InvocationContext",
"txInvocationContext",
"=",
"invocationContextFactory",
".",
"createInvocationContext",
"(",
"true",
",",
"-",
"1",
")",
";",
"return",
"invokeNext",
"(",
"txInvocationContext",
",",
"command",
")",
";",
"}",
"finally",
"{",
"suspendTransaction",
"(",
")",
";",
"}",
"}"
] | Simply check if there is an ongoing tx. <ul> <li>If there is one, this is a no-op and just passes the call up the
chain.</li> <li>If there isn't one and there is a batch in progress, resume the batch's tx, pass up, and finally
suspend the batch's tx.</li> <li>If there is no batch in progress, just pass the call up the chain.</li> </ul> | [
"Simply",
"check",
"if",
"there",
"is",
"an",
"ongoing",
"tx",
".",
"<ul",
">",
"<li",
">",
"If",
"there",
"is",
"one",
"this",
"is",
"a",
"no",
"-",
"op",
"and",
"just",
"passes",
"the",
"call",
"up",
"the",
"chain",
".",
"<",
"/",
"li",
">",
"<li",
">",
"If",
"there",
"isn",
"t",
"one",
"and",
"there",
"is",
"a",
"batch",
"in",
"progress",
"resume",
"the",
"batch",
"s",
"tx",
"pass",
"up",
"and",
"finally",
"suspend",
"the",
"batch",
"s",
"tx",
".",
"<",
"/",
"li",
">",
"<li",
">",
"If",
"there",
"is",
"no",
"batch",
"in",
"progress",
"just",
"pass",
"the",
"call",
"up",
"the",
"chain",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/core/src/main/java/org/infinispan/interceptors/impl/BatchingInterceptor.java#L57-L84 |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/ExceptionMap.java | ExceptionMap.init | public static synchronized void init () {
"""
Searches for the <code>exceptionmap.properties</code> file in the
classpath and loads it. If the file could not be found, an error is
reported and a default set of mappings is used.
"""
// only initialize ourselves once
if (_keys != null) {
return;
} else {
_keys = new ArrayList<Class<?>>();
_values = new ArrayList<String>();
}
// first try loading the properties file without a leading slash
ClassLoader cld = ExceptionMap.class.getClassLoader();
InputStream config = ConfigUtil.getStream(PROPS_NAME, cld);
if (config == null) {
log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH.");
} else {
// otherwise process ye old config file.
try {
// we'll do some serious jiggery pokery to leverage the parsing
// implementation provided by java.util.Properties. god bless
// method overloading
final ArrayList<String> classes = new ArrayList<String>();
Properties loader = new Properties() {
@Override public Object put (Object key, Object value) {
classes.add((String)key);
_values.add((String)value);
return key;
}
};
loader.load(config);
// now cruise through and resolve the exceptions named as
// keys and throw out any that don't appear to exist
for (int i = 0; i < classes.size(); i++) {
String exclass = classes.get(i);
try {
Class<?> cl = Class.forName(exclass);
// replace the string with the class object
_keys.add(cl);
} catch (Throwable t) {
log.warning("Unable to resolve exception class.", "class", exclass,
"error", t);
_values.remove(i);
i--; // back on up a notch
}
}
} catch (IOException ioe) {
log.warning("Error reading exception mapping file: " + ioe);
}
}
} | java | public static synchronized void init ()
{
// only initialize ourselves once
if (_keys != null) {
return;
} else {
_keys = new ArrayList<Class<?>>();
_values = new ArrayList<String>();
}
// first try loading the properties file without a leading slash
ClassLoader cld = ExceptionMap.class.getClassLoader();
InputStream config = ConfigUtil.getStream(PROPS_NAME, cld);
if (config == null) {
log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH.");
} else {
// otherwise process ye old config file.
try {
// we'll do some serious jiggery pokery to leverage the parsing
// implementation provided by java.util.Properties. god bless
// method overloading
final ArrayList<String> classes = new ArrayList<String>();
Properties loader = new Properties() {
@Override public Object put (Object key, Object value) {
classes.add((String)key);
_values.add((String)value);
return key;
}
};
loader.load(config);
// now cruise through and resolve the exceptions named as
// keys and throw out any that don't appear to exist
for (int i = 0; i < classes.size(); i++) {
String exclass = classes.get(i);
try {
Class<?> cl = Class.forName(exclass);
// replace the string with the class object
_keys.add(cl);
} catch (Throwable t) {
log.warning("Unable to resolve exception class.", "class", exclass,
"error", t);
_values.remove(i);
i--; // back on up a notch
}
}
} catch (IOException ioe) {
log.warning("Error reading exception mapping file: " + ioe);
}
}
} | [
"public",
"static",
"synchronized",
"void",
"init",
"(",
")",
"{",
"// only initialize ourselves once",
"if",
"(",
"_keys",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"else",
"{",
"_keys",
"=",
"new",
"ArrayList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"_values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"}",
"// first try loading the properties file without a leading slash",
"ClassLoader",
"cld",
"=",
"ExceptionMap",
".",
"class",
".",
"getClassLoader",
"(",
")",
";",
"InputStream",
"config",
"=",
"ConfigUtil",
".",
"getStream",
"(",
"PROPS_NAME",
",",
"cld",
")",
";",
"if",
"(",
"config",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"\"Unable to load \"",
"+",
"PROPS_NAME",
"+",
"\" from CLASSPATH.\"",
")",
";",
"}",
"else",
"{",
"// otherwise process ye old config file.",
"try",
"{",
"// we'll do some serious jiggery pokery to leverage the parsing",
"// implementation provided by java.util.Properties. god bless",
"// method overloading",
"final",
"ArrayList",
"<",
"String",
">",
"classes",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"Properties",
"loader",
"=",
"new",
"Properties",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"put",
"(",
"Object",
"key",
",",
"Object",
"value",
")",
"{",
"classes",
".",
"add",
"(",
"(",
"String",
")",
"key",
")",
";",
"_values",
".",
"add",
"(",
"(",
"String",
")",
"value",
")",
";",
"return",
"key",
";",
"}",
"}",
";",
"loader",
".",
"load",
"(",
"config",
")",
";",
"// now cruise through and resolve the exceptions named as",
"// keys and throw out any that don't appear to exist",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"classes",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"exclass",
"=",
"classes",
".",
"get",
"(",
"i",
")",
";",
"try",
"{",
"Class",
"<",
"?",
">",
"cl",
"=",
"Class",
".",
"forName",
"(",
"exclass",
")",
";",
"// replace the string with the class object",
"_keys",
".",
"add",
"(",
"cl",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"log",
".",
"warning",
"(",
"\"Unable to resolve exception class.\"",
",",
"\"class\"",
",",
"exclass",
",",
"\"error\"",
",",
"t",
")",
";",
"_values",
".",
"remove",
"(",
"i",
")",
";",
"i",
"--",
";",
"// back on up a notch",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"log",
".",
"warning",
"(",
"\"Error reading exception mapping file: \"",
"+",
"ioe",
")",
";",
"}",
"}",
"}"
] | Searches for the <code>exceptionmap.properties</code> file in the
classpath and loads it. If the file could not be found, an error is
reported and a default set of mappings is used. | [
"Searches",
"for",
"the",
"<code",
">",
"exceptionmap",
".",
"properties<",
"/",
"code",
">",
"file",
"in",
"the",
"classpath",
"and",
"loads",
"it",
".",
"If",
"the",
"file",
"could",
"not",
"be",
"found",
"an",
"error",
"is",
"reported",
"and",
"a",
"default",
"set",
"of",
"mappings",
"is",
"used",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/ExceptionMap.java#L62-L115 |
UrielCh/ovh-java-sdk | ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java | ApiOvhHostingweb.serviceName_email_request_POST | public String serviceName_email_request_POST(String serviceName, OvhActionEnum action) throws IOException {
"""
Request specific operation for your email
REST: POST /hosting/web/{serviceName}/email/request
@param action [required] Action you want to request
@param serviceName [required] The internal name of your hosting
"""
String qPath = "/hosting/web/{serviceName}/email/request";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | java | public String serviceName_email_request_POST(String serviceName, OvhActionEnum action) throws IOException {
String qPath = "/hosting/web/{serviceName}/email/request";
StringBuilder sb = path(qPath, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "action", action);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, String.class);
} | [
"public",
"String",
"serviceName_email_request_POST",
"(",
"String",
"serviceName",
",",
"OvhActionEnum",
"action",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/hosting/web/{serviceName}/email/request\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"action\"",
",",
"action",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"String",
".",
"class",
")",
";",
"}"
] | Request specific operation for your email
REST: POST /hosting/web/{serviceName}/email/request
@param action [required] Action you want to request
@param serviceName [required] The internal name of your hosting | [
"Request",
"specific",
"operation",
"for",
"your",
"email"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-hostingweb/src/main/java/net/minidev/ovh/api/ApiOvhHostingweb.java#L1863-L1870 |
Teddy-Zhu/SilentGo | utils/src/main/java/com/silentgo/utils/log/StaticLog.java | StaticLog.log | public static boolean log(Level level, Throwable t, String format, Object... arguments) {
"""
打印日志<br>
@param level 日志级别
@param t 需在日志中堆栈打印的异常
@param format 格式文本,{} 代表变量
@param arguments 变量对应的参数
"""
return log(LogFactory.indirectGet(), level, t, format, arguments);
} | java | public static boolean log(Level level, Throwable t, String format, Object... arguments) {
return log(LogFactory.indirectGet(), level, t, format, arguments);
} | [
"public",
"static",
"boolean",
"log",
"(",
"Level",
"level",
",",
"Throwable",
"t",
",",
"String",
"format",
",",
"Object",
"...",
"arguments",
")",
"{",
"return",
"log",
"(",
"LogFactory",
".",
"indirectGet",
"(",
")",
",",
"level",
",",
"t",
",",
"format",
",",
"arguments",
")",
";",
"}"
] | 打印日志<br>
@param level 日志级别
@param t 需在日志中堆栈打印的异常
@param format 格式文本,{} 代表变量
@param arguments 变量对应的参数 | [
"打印日志<br",
">"
] | train | https://github.com/Teddy-Zhu/SilentGo/blob/27f58b0cafe56b2eb9fc6993efa9ca2b529661e1/utils/src/main/java/com/silentgo/utils/log/StaticLog.java#L222-L224 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java | CloudTasksClient.cancelLease | public final Task cancelLease(String name, Timestamp scheduleTime) {
"""
Cancel a pull task's lease.
<p>The worker can use this method to cancel a task's lease by setting its
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] to now. This will make the task
available to be leased to the next caller of
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
<p>Sample code:
<pre><code>
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
Timestamp scheduleTime = Timestamp.newBuilder().build();
Task response = cloudTasksClient.cancelLease(name.toString(), scheduleTime);
}
</code></pre>
@param name Required.
<p>The task name. For example:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@param scheduleTime Required.
<p>The task's current schedule time, available in the
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or
[RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction
is to ensure that your worker currently holds the lease.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
CancelLeaseRequest request =
CancelLeaseRequest.newBuilder().setName(name).setScheduleTime(scheduleTime).build();
return cancelLease(request);
} | java | public final Task cancelLease(String name, Timestamp scheduleTime) {
CancelLeaseRequest request =
CancelLeaseRequest.newBuilder().setName(name).setScheduleTime(scheduleTime).build();
return cancelLease(request);
} | [
"public",
"final",
"Task",
"cancelLease",
"(",
"String",
"name",
",",
"Timestamp",
"scheduleTime",
")",
"{",
"CancelLeaseRequest",
"request",
"=",
"CancelLeaseRequest",
".",
"newBuilder",
"(",
")",
".",
"setName",
"(",
"name",
")",
".",
"setScheduleTime",
"(",
"scheduleTime",
")",
".",
"build",
"(",
")",
";",
"return",
"cancelLease",
"(",
"request",
")",
";",
"}"
] | Cancel a pull task's lease.
<p>The worker can use this method to cancel a task's lease by setting its
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] to now. This will make the task
available to be leased to the next caller of
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks].
<p>Sample code:
<pre><code>
try (CloudTasksClient cloudTasksClient = CloudTasksClient.create()) {
TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]");
Timestamp scheduleTime = Timestamp.newBuilder().build();
Task response = cloudTasksClient.cancelLease(name.toString(), scheduleTime);
}
</code></pre>
@param name Required.
<p>The task name. For example:
`projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
@param scheduleTime Required.
<p>The task's current schedule time, available in the
[schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time] returned by
[LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks] response or
[RenewLease][google.cloud.tasks.v2beta2.CloudTasks.RenewLease] response. This restriction
is to ensure that your worker currently holds the lease.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Cancel",
"a",
"pull",
"task",
"s",
"lease",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java#L2544-L2549 |
actframework/actframework | src/main/java/act/app/ActionContext.java | ActionContext.loginAndRedirectBack | public void loginAndRedirectBack(Object userIdentifier, String defaultLandingUrl) {
"""
Login the user and redirect back to original URL. If no
original URL found then redirect to `defaultLandingUrl`.
@param userIdentifier
the user identifier, could be either userId or username
@param defaultLandingUrl
the URL to be redirected if original URL not found
"""
login(userIdentifier);
RedirectToLoginUrl.redirectToOriginalUrl(this, defaultLandingUrl);
} | java | public void loginAndRedirectBack(Object userIdentifier, String defaultLandingUrl) {
login(userIdentifier);
RedirectToLoginUrl.redirectToOriginalUrl(this, defaultLandingUrl);
} | [
"public",
"void",
"loginAndRedirectBack",
"(",
"Object",
"userIdentifier",
",",
"String",
"defaultLandingUrl",
")",
"{",
"login",
"(",
"userIdentifier",
")",
";",
"RedirectToLoginUrl",
".",
"redirectToOriginalUrl",
"(",
"this",
",",
"defaultLandingUrl",
")",
";",
"}"
] | Login the user and redirect back to original URL. If no
original URL found then redirect to `defaultLandingUrl`.
@param userIdentifier
the user identifier, could be either userId or username
@param defaultLandingUrl
the URL to be redirected if original URL not found | [
"Login",
"the",
"user",
"and",
"redirect",
"back",
"to",
"original",
"URL",
".",
"If",
"no",
"original",
"URL",
"found",
"then",
"redirect",
"to",
"defaultLandingUrl",
"."
] | train | https://github.com/actframework/actframework/blob/55a8f8b45e71159a79ec6e157c02f71700f8cd54/src/main/java/act/app/ActionContext.java#L1293-L1296 |
Esri/geometry-api-java | src/main/java/com/esri/core/geometry/GeometryEngine.java | GeometryEngine.geoJsonToGeometry | public static MapGeometry geoJsonToGeometry(String json, int importFlags, Geometry.Type type) {
"""
Imports the MapGeometry from its JSON representation. M and Z values are
not imported from JSON representation.
See OperatorImportFromJson.
@param json
The JSON representation of the geometry (with spatial
reference).
@return The MapGeometry instance containing the imported geometry and its
spatial reference.
"""
MapGeometry geom = OperatorImportFromGeoJson.local().execute(importFlags, type, json, null);
return geom;
} | java | public static MapGeometry geoJsonToGeometry(String json, int importFlags, Geometry.Type type) {
MapGeometry geom = OperatorImportFromGeoJson.local().execute(importFlags, type, json, null);
return geom;
} | [
"public",
"static",
"MapGeometry",
"geoJsonToGeometry",
"(",
"String",
"json",
",",
"int",
"importFlags",
",",
"Geometry",
".",
"Type",
"type",
")",
"{",
"MapGeometry",
"geom",
"=",
"OperatorImportFromGeoJson",
".",
"local",
"(",
")",
".",
"execute",
"(",
"importFlags",
",",
"type",
",",
"json",
",",
"null",
")",
";",
"return",
"geom",
";",
"}"
] | Imports the MapGeometry from its JSON representation. M and Z values are
not imported from JSON representation.
See OperatorImportFromJson.
@param json
The JSON representation of the geometry (with spatial
reference).
@return The MapGeometry instance containing the imported geometry and its
spatial reference. | [
"Imports",
"the",
"MapGeometry",
"from",
"its",
"JSON",
"representation",
".",
"M",
"and",
"Z",
"values",
"are",
"not",
"imported",
"from",
"JSON",
"representation",
"."
] | train | https://github.com/Esri/geometry-api-java/blob/494da8ec953d76e7c6072afbc081abfe48ff07cf/src/main/java/com/esri/core/geometry/GeometryEngine.java#L155-L158 |
minio/minio-java | api/src/main/java/io/minio/MinioClient.java | MinioClient.listObjects | public Iterable<Result<Item>> listObjects(final String bucketName, final String prefix, final boolean recursive,
final boolean useVersion1) {
"""
Lists object information as {@code Iterable<Result><Item>} in given bucket, prefix, recursive flag and S3 API
version to use.
</p><b>Example:</b><br>
<pre>{@code Iterable<Result<Item>> myObjects = minioClient.listObjects("my-bucketname", "my-object-prefix", true,
false);
for (Result<Item> result : myObjects) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
} }</pre>
@param bucketName Bucket name.
@param prefix Prefix string. List objects whose name starts with `prefix`.
@param recursive when false, emulates a directory structure where each listing returned is either a full object
or part of the object's key up to the first '/'. All objects wit the same prefix up to the first
'/' will be merged into one entry.
@param useVersion1 If set, Amazon AWS S3 List Object V1 is used, else List Object V2 is used as default.
@return an iterator of Result Items.
@see #listObjects(String bucketName)
@see #listObjects(String bucketName, String prefix)
@see #listObjects(String bucketName, String prefix, boolean recursive)
"""
if (useVersion1) {
return listObjectsV1(bucketName, prefix, recursive);
}
return listObjectsV2(bucketName, prefix, recursive);
} | java | public Iterable<Result<Item>> listObjects(final String bucketName, final String prefix, final boolean recursive,
final boolean useVersion1) {
if (useVersion1) {
return listObjectsV1(bucketName, prefix, recursive);
}
return listObjectsV2(bucketName, prefix, recursive);
} | [
"public",
"Iterable",
"<",
"Result",
"<",
"Item",
">",
">",
"listObjects",
"(",
"final",
"String",
"bucketName",
",",
"final",
"String",
"prefix",
",",
"final",
"boolean",
"recursive",
",",
"final",
"boolean",
"useVersion1",
")",
"{",
"if",
"(",
"useVersion1",
")",
"{",
"return",
"listObjectsV1",
"(",
"bucketName",
",",
"prefix",
",",
"recursive",
")",
";",
"}",
"return",
"listObjectsV2",
"(",
"bucketName",
",",
"prefix",
",",
"recursive",
")",
";",
"}"
] | Lists object information as {@code Iterable<Result><Item>} in given bucket, prefix, recursive flag and S3 API
version to use.
</p><b>Example:</b><br>
<pre>{@code Iterable<Result<Item>> myObjects = minioClient.listObjects("my-bucketname", "my-object-prefix", true,
false);
for (Result<Item> result : myObjects) {
Item item = result.get();
System.out.println(item.lastModified() + ", " + item.size() + ", " + item.objectName());
} }</pre>
@param bucketName Bucket name.
@param prefix Prefix string. List objects whose name starts with `prefix`.
@param recursive when false, emulates a directory structure where each listing returned is either a full object
or part of the object's key up to the first '/'. All objects wit the same prefix up to the first
'/' will be merged into one entry.
@param useVersion1 If set, Amazon AWS S3 List Object V1 is used, else List Object V2 is used as default.
@return an iterator of Result Items.
@see #listObjects(String bucketName)
@see #listObjects(String bucketName, String prefix)
@see #listObjects(String bucketName, String prefix, boolean recursive) | [
"Lists",
"object",
"information",
"as",
"{",
"@code",
"Iterable<Result",
">",
"<Item",
">",
"}",
"in",
"given",
"bucket",
"prefix",
"recursive",
"flag",
"and",
"S3",
"API",
"version",
"to",
"use",
"."
] | train | https://github.com/minio/minio-java/blob/b2028f56403c89ce2d5900ae813bc1314c87bc7f/api/src/main/java/io/minio/MinioClient.java#L2871-L2878 |
michel-kraemer/bson4jackson | src/main/java/de/undercouch/bson4jackson/BsonParser.java | BsonParser.handleJavascriptWithScope | protected JsonToken handleJavascriptWithScope() throws IOException {
"""
Can be called when embedded javascript code with scope is found. Reads
the code and the embedded document.
@return the json token read
@throws IOException if an I/O error occurs
"""
//skip size
_in.readInt();
String code = readString();
Map<String, Object> doc = readDocument();
getContext().value = new JavaScript(code, doc);
return JsonToken.VALUE_EMBEDDED_OBJECT;
} | java | protected JsonToken handleJavascriptWithScope() throws IOException {
//skip size
_in.readInt();
String code = readString();
Map<String, Object> doc = readDocument();
getContext().value = new JavaScript(code, doc);
return JsonToken.VALUE_EMBEDDED_OBJECT;
} | [
"protected",
"JsonToken",
"handleJavascriptWithScope",
"(",
")",
"throws",
"IOException",
"{",
"//skip size",
"_in",
".",
"readInt",
"(",
")",
";",
"String",
"code",
"=",
"readString",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"doc",
"=",
"readDocument",
"(",
")",
";",
"getContext",
"(",
")",
".",
"value",
"=",
"new",
"JavaScript",
"(",
"code",
",",
"doc",
")",
";",
"return",
"JsonToken",
".",
"VALUE_EMBEDDED_OBJECT",
";",
"}"
] | Can be called when embedded javascript code with scope is found. Reads
the code and the embedded document.
@return the json token read
@throws IOException if an I/O error occurs | [
"Can",
"be",
"called",
"when",
"embedded",
"javascript",
"code",
"with",
"scope",
"is",
"found",
".",
"Reads",
"the",
"code",
"and",
"the",
"embedded",
"document",
"."
] | train | https://github.com/michel-kraemer/bson4jackson/blob/32d2ab3c516b3c07490fdfcf0c5e4ed0a2ee3979/src/main/java/de/undercouch/bson4jackson/BsonParser.java#L545-L552 |
puniverse/capsule | capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java | Jar.setMapAttribute | public Jar setMapAttribute(String name, Map<String, ?> values) {
"""
Sets an attribute in the main section of the manifest to a map.
The map entries will be joined with a single whitespace character, and each key-value pair will be joined with a '='.
@param name the attribute's name
@param values the attribute's value
@return {@code this}
@throws IllegalStateException if entries have been added or the JAR has been written prior to calling this methods.
"""
return setAttribute(name, join(values));
} | java | public Jar setMapAttribute(String name, Map<String, ?> values) {
return setAttribute(name, join(values));
} | [
"public",
"Jar",
"setMapAttribute",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"?",
">",
"values",
")",
"{",
"return",
"setAttribute",
"(",
"name",
",",
"join",
"(",
"values",
")",
")",
";",
"}"
] | Sets an attribute in the main section of the manifest to a map.
The map entries will be joined with a single whitespace character, and each key-value pair will be joined with a '='.
@param name the attribute's name
@param values the attribute's value
@return {@code this}
@throws IllegalStateException if entries have been added or the JAR has been written prior to calling this methods. | [
"Sets",
"an",
"attribute",
"in",
"the",
"main",
"section",
"of",
"the",
"manifest",
"to",
"a",
"map",
".",
"The",
"map",
"entries",
"will",
"be",
"joined",
"with",
"a",
"single",
"whitespace",
"character",
"and",
"each",
"key",
"-",
"value",
"pair",
"will",
"be",
"joined",
"with",
"a",
"=",
"."
] | train | https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java#L201-L203 |
ops4j/org.ops4j.pax.logging | pax-logging-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java | StructuredDataMessage.asString | @Override
public String asString(final String format) {
"""
Formats the structured data as described in RFC 5424.
@param format The format identifier. Ignored in this implementation.
@return The formatted String.
"""
try {
return asString(EnglishEnums.valueOf(Format.class, format), null);
} catch (final IllegalArgumentException ex) {
return asString();
}
} | java | @Override
public String asString(final String format) {
try {
return asString(EnglishEnums.valueOf(Format.class, format), null);
} catch (final IllegalArgumentException ex) {
return asString();
}
} | [
"@",
"Override",
"public",
"String",
"asString",
"(",
"final",
"String",
"format",
")",
"{",
"try",
"{",
"return",
"asString",
"(",
"EnglishEnums",
".",
"valueOf",
"(",
"Format",
".",
"class",
",",
"format",
")",
",",
"null",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"ex",
")",
"{",
"return",
"asString",
"(",
")",
";",
"}",
"}"
] | Formats the structured data as described in RFC 5424.
@param format The format identifier. Ignored in this implementation.
@return The formatted String. | [
"Formats",
"the",
"structured",
"data",
"as",
"described",
"in",
"RFC",
"5424",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.logging/blob/493de4e1db4fe9f981f3dd78b8e40e5bf2b2e59d/pax-logging-api/src/main/java/org/apache/logging/log4j/message/StructuredDataMessage.java#L286-L293 |
Jasig/uPortal | uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/LPAChangeParameter.java | LPAChangeParameter.perform | @Override
public void perform() throws PortalException {
"""
Change the parameter for a channel in both the ILF and PLF using the appropriate mechanisms
for incorporated nodes versus owned nodes.
"""
// push the change into the PLF
if (nodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) {
// we are dealing with an incorporated node, adding will replace
// an existing one for the same target node id and name
ParameterEditManager.addParmEditDirective(nodeId, name, value, person);
} else {
// node owned by user so change existing parameter child directly
Document plf = RDBMDistributedLayoutStore.getPLF(person);
Element plfNode = plf.getElementById(nodeId);
changeParameterChild(plfNode, name, value);
}
// push the change into the ILF
changeParameterChild(ilfNode, name, value);
} | java | @Override
public void perform() throws PortalException {
// push the change into the PLF
if (nodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) {
// we are dealing with an incorporated node, adding will replace
// an existing one for the same target node id and name
ParameterEditManager.addParmEditDirective(nodeId, name, value, person);
} else {
// node owned by user so change existing parameter child directly
Document plf = RDBMDistributedLayoutStore.getPLF(person);
Element plfNode = plf.getElementById(nodeId);
changeParameterChild(plfNode, name, value);
}
// push the change into the ILF
changeParameterChild(ilfNode, name, value);
} | [
"@",
"Override",
"public",
"void",
"perform",
"(",
")",
"throws",
"PortalException",
"{",
"// push the change into the PLF",
"if",
"(",
"nodeId",
".",
"startsWith",
"(",
"Constants",
".",
"FRAGMENT_ID_USER_PREFIX",
")",
")",
"{",
"// we are dealing with an incorporated node, adding will replace",
"// an existing one for the same target node id and name",
"ParameterEditManager",
".",
"addParmEditDirective",
"(",
"nodeId",
",",
"name",
",",
"value",
",",
"person",
")",
";",
"}",
"else",
"{",
"// node owned by user so change existing parameter child directly",
"Document",
"plf",
"=",
"RDBMDistributedLayoutStore",
".",
"getPLF",
"(",
"person",
")",
";",
"Element",
"plfNode",
"=",
"plf",
".",
"getElementById",
"(",
"nodeId",
")",
";",
"changeParameterChild",
"(",
"plfNode",
",",
"name",
",",
"value",
")",
";",
"}",
"// push the change into the ILF",
"changeParameterChild",
"(",
"ilfNode",
",",
"name",
",",
"value",
")",
";",
"}"
] | Change the parameter for a channel in both the ILF and PLF using the appropriate mechanisms
for incorporated nodes versus owned nodes. | [
"Change",
"the",
"parameter",
"for",
"a",
"channel",
"in",
"both",
"the",
"ILF",
"and",
"PLF",
"using",
"the",
"appropriate",
"mechanisms",
"for",
"incorporated",
"nodes",
"versus",
"owned",
"nodes",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-layout/uPortal-layout-impl/src/main/java/org/apereo/portal/layout/dlm/LPAChangeParameter.java#L43-L58 |
asterisk-java/asterisk-java | src/main/java/org/asteriskjava/live/internal/AsteriskChannelImpl.java | AsteriskChannelImpl.channelLinked | synchronized void channelLinked(Date date, AsteriskChannel linkedChannel) {
"""
Sets the channel this channel is bridged with.
@param date the date this channel was linked.
@param linkedChannel the channel this channel is bridged with.
"""
final AsteriskChannel oldLinkedChannel;
synchronized (this.linkedChannels)
{
if (this.linkedChannels.isEmpty())
{
oldLinkedChannel = null;
this.linkedChannels.add(linkedChannel);
}
else
{
oldLinkedChannel = this.linkedChannels.get(0);
this.linkedChannels.set(0, linkedChannel);
}
}
final LinkedChannelHistoryEntry historyEntry;
historyEntry = new LinkedChannelHistoryEntry(date, linkedChannel);
synchronized (linkedChannelHistory)
{
linkedChannelHistory.add(historyEntry);
}
this.wasLinked = true;
firePropertyChange(PROPERTY_LINKED_CHANNEL, oldLinkedChannel, linkedChannel);
} | java | synchronized void channelLinked(Date date, AsteriskChannel linkedChannel)
{
final AsteriskChannel oldLinkedChannel;
synchronized (this.linkedChannels)
{
if (this.linkedChannels.isEmpty())
{
oldLinkedChannel = null;
this.linkedChannels.add(linkedChannel);
}
else
{
oldLinkedChannel = this.linkedChannels.get(0);
this.linkedChannels.set(0, linkedChannel);
}
}
final LinkedChannelHistoryEntry historyEntry;
historyEntry = new LinkedChannelHistoryEntry(date, linkedChannel);
synchronized (linkedChannelHistory)
{
linkedChannelHistory.add(historyEntry);
}
this.wasLinked = true;
firePropertyChange(PROPERTY_LINKED_CHANNEL, oldLinkedChannel, linkedChannel);
} | [
"synchronized",
"void",
"channelLinked",
"(",
"Date",
"date",
",",
"AsteriskChannel",
"linkedChannel",
")",
"{",
"final",
"AsteriskChannel",
"oldLinkedChannel",
";",
"synchronized",
"(",
"this",
".",
"linkedChannels",
")",
"{",
"if",
"(",
"this",
".",
"linkedChannels",
".",
"isEmpty",
"(",
")",
")",
"{",
"oldLinkedChannel",
"=",
"null",
";",
"this",
".",
"linkedChannels",
".",
"add",
"(",
"linkedChannel",
")",
";",
"}",
"else",
"{",
"oldLinkedChannel",
"=",
"this",
".",
"linkedChannels",
".",
"get",
"(",
"0",
")",
";",
"this",
".",
"linkedChannels",
".",
"set",
"(",
"0",
",",
"linkedChannel",
")",
";",
"}",
"}",
"final",
"LinkedChannelHistoryEntry",
"historyEntry",
";",
"historyEntry",
"=",
"new",
"LinkedChannelHistoryEntry",
"(",
"date",
",",
"linkedChannel",
")",
";",
"synchronized",
"(",
"linkedChannelHistory",
")",
"{",
"linkedChannelHistory",
".",
"add",
"(",
"historyEntry",
")",
";",
"}",
"this",
".",
"wasLinked",
"=",
"true",
";",
"firePropertyChange",
"(",
"PROPERTY_LINKED_CHANNEL",
",",
"oldLinkedChannel",
",",
"linkedChannel",
")",
";",
"}"
] | Sets the channel this channel is bridged with.
@param date the date this channel was linked.
@param linkedChannel the channel this channel is bridged with. | [
"Sets",
"the",
"channel",
"this",
"channel",
"is",
"bridged",
"with",
"."
] | train | https://github.com/asterisk-java/asterisk-java/blob/cdc9849270d97ef75afa447a02c5194ed29121eb/src/main/java/org/asteriskjava/live/internal/AsteriskChannelImpl.java#L597-L623 |
pebble/pebble-android-sdk | PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java | PebbleDictionary.addInt32 | public void addInt32(final int key, final int i) {
"""
Associate the specified signed int with the provided key in the dictionary. If another key-value pair with the
same key is already present in the dictionary, it will be replaced.
@param key
key with which the specified value is associated
@param i
value to be associated with the specified key
"""
PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.WORD, i);
addTuple(t);
} | java | public void addInt32(final int key, final int i) {
PebbleTuple t = PebbleTuple.create(key, PebbleTuple.TupleType.INT, PebbleTuple.Width.WORD, i);
addTuple(t);
} | [
"public",
"void",
"addInt32",
"(",
"final",
"int",
"key",
",",
"final",
"int",
"i",
")",
"{",
"PebbleTuple",
"t",
"=",
"PebbleTuple",
".",
"create",
"(",
"key",
",",
"PebbleTuple",
".",
"TupleType",
".",
"INT",
",",
"PebbleTuple",
".",
"Width",
".",
"WORD",
",",
"i",
")",
";",
"addTuple",
"(",
"t",
")",
";",
"}"
] | Associate the specified signed int with the provided key in the dictionary. If another key-value pair with the
same key is already present in the dictionary, it will be replaced.
@param key
key with which the specified value is associated
@param i
value to be associated with the specified key | [
"Associate",
"the",
"specified",
"signed",
"int",
"with",
"the",
"provided",
"key",
"in",
"the",
"dictionary",
".",
"If",
"another",
"key",
"-",
"value",
"pair",
"with",
"the",
"same",
"key",
"is",
"already",
"present",
"in",
"the",
"dictionary",
"it",
"will",
"be",
"replaced",
"."
] | train | https://github.com/pebble/pebble-android-sdk/blob/ddfc53ecf3950deebb62a1f205aa21fbe9bce45d/PebbleKit/PebbleKit/src/main/java/com/getpebble/android/kit/util/PebbleDictionary.java#L163-L166 |
BranchMetrics/android-branch-deep-linking | Branch-SDK/src/io/branch/referral/Branch.java | Branch.userCompletedAction | public void userCompletedAction(@NonNull final String action, JSONObject
metadata, BranchViewHandler.IBranchViewEvents callback) {
"""
<p>A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API, with additional app-defined meta data to go along with that action.</p>
@param action A {@link String} value to be passed as an action that the user has carried
out. For example "registered" or "logged in".
@param metadata A {@link JSONObject} containing app-defined meta-data to be attached to a
user action that has just been completed.
@param callback instance of {@link BranchViewHandler.IBranchViewEvents} to listen Branch view events
"""
ServerRequest req = new ServerRequestActionCompleted(context_, action, metadata, callback);
if (!req.constructError_ && !req.handleErrors(context_)) {
handleNewRequest(req);
}
} | java | public void userCompletedAction(@NonNull final String action, JSONObject
metadata, BranchViewHandler.IBranchViewEvents callback) {
ServerRequest req = new ServerRequestActionCompleted(context_, action, metadata, callback);
if (!req.constructError_ && !req.handleErrors(context_)) {
handleNewRequest(req);
}
} | [
"public",
"void",
"userCompletedAction",
"(",
"@",
"NonNull",
"final",
"String",
"action",
",",
"JSONObject",
"metadata",
",",
"BranchViewHandler",
".",
"IBranchViewEvents",
"callback",
")",
"{",
"ServerRequest",
"req",
"=",
"new",
"ServerRequestActionCompleted",
"(",
"context_",
",",
"action",
",",
"metadata",
",",
"callback",
")",
";",
"if",
"(",
"!",
"req",
".",
"constructError_",
"&&",
"!",
"req",
".",
"handleErrors",
"(",
"context_",
")",
")",
"{",
"handleNewRequest",
"(",
"req",
")",
";",
"}",
"}"
] | <p>A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API, with additional app-defined meta data to go along with that action.</p>
@param action A {@link String} value to be passed as an action that the user has carried
out. For example "registered" or "logged in".
@param metadata A {@link JSONObject} containing app-defined meta-data to be attached to a
user action that has just been completed.
@param callback instance of {@link BranchViewHandler.IBranchViewEvents} to listen Branch view events | [
"<p",
">",
"A",
"void",
"call",
"to",
"indicate",
"that",
"the",
"user",
"has",
"performed",
"a",
"specific",
"action",
"and",
"for",
"that",
"to",
"be",
"reported",
"to",
"the",
"Branch",
"API",
"with",
"additional",
"app",
"-",
"defined",
"meta",
"data",
"to",
"go",
"along",
"with",
"that",
"action",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L2049-L2055 |
Netflix/eureka | eureka-core/src/main/java/com/netflix/eureka/cluster/PeerEurekaNode.java | PeerEurekaNode.statusUpdate | public void statusUpdate(final String asgName, final ASGStatus newStatus) {
"""
Send the status information of of the ASG represented by the instance.
<p>
ASG (Autoscaling group) names are available for instances in AWS and the
ASG information is used for determining if the instance should be
registered as {@link InstanceStatus#DOWN} or {@link InstanceStatus#UP}.
@param asgName
the asg name if any of this instance.
@param newStatus
the new status of the ASG.
"""
long expiryTime = System.currentTimeMillis() + maxProcessingDelayMs;
nonBatchingDispatcher.process(
asgName,
new AsgReplicationTask(targetHost, Action.StatusUpdate, asgName, newStatus) {
public EurekaHttpResponse<?> execute() {
return replicationClient.statusUpdate(asgName, newStatus);
}
},
expiryTime
);
} | java | public void statusUpdate(final String asgName, final ASGStatus newStatus) {
long expiryTime = System.currentTimeMillis() + maxProcessingDelayMs;
nonBatchingDispatcher.process(
asgName,
new AsgReplicationTask(targetHost, Action.StatusUpdate, asgName, newStatus) {
public EurekaHttpResponse<?> execute() {
return replicationClient.statusUpdate(asgName, newStatus);
}
},
expiryTime
);
} | [
"public",
"void",
"statusUpdate",
"(",
"final",
"String",
"asgName",
",",
"final",
"ASGStatus",
"newStatus",
")",
"{",
"long",
"expiryTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"maxProcessingDelayMs",
";",
"nonBatchingDispatcher",
".",
"process",
"(",
"asgName",
",",
"new",
"AsgReplicationTask",
"(",
"targetHost",
",",
"Action",
".",
"StatusUpdate",
",",
"asgName",
",",
"newStatus",
")",
"{",
"public",
"EurekaHttpResponse",
"<",
"?",
">",
"execute",
"(",
")",
"{",
"return",
"replicationClient",
".",
"statusUpdate",
"(",
"asgName",
",",
"newStatus",
")",
";",
"}",
"}",
",",
"expiryTime",
")",
";",
"}"
] | Send the status information of of the ASG represented by the instance.
<p>
ASG (Autoscaling group) names are available for instances in AWS and the
ASG information is used for determining if the instance should be
registered as {@link InstanceStatus#DOWN} or {@link InstanceStatus#UP}.
@param asgName
the asg name if any of this instance.
@param newStatus
the new status of the ASG. | [
"Send",
"the",
"status",
"information",
"of",
"of",
"the",
"ASG",
"represented",
"by",
"the",
"instance",
"."
] | train | https://github.com/Netflix/eureka/blob/48446d956be09df6650a3c00b7ebd7e2d1e1544f/eureka-core/src/main/java/com/netflix/eureka/cluster/PeerEurekaNode.java#L243-L254 |
ManfredTremmel/gwt-commons-lang3 | src/main/java/org/apache/commons/lang3/time/DateUtils.java | DateUtils.isSameDay | public static boolean isSameDay(final Date date1, final Date date2) {
"""
<p>Checks if two date objects are on the same day ignoring time.</p>
<p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.
28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false.
</p>
@param date1 the first date, not altered, not null
@param date2 the second date, not altered, not null
@return true if they represent the same day
@throws IllegalArgumentException if either date is <code>null</code>
@since 2.1
"""
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
final Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
final Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return isSameDay(cal1, cal2);
} | java | public static boolean isSameDay(final Date date1, final Date date2) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
final Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
final Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return isSameDay(cal1, cal2);
} | [
"public",
"static",
"boolean",
"isSameDay",
"(",
"final",
"Date",
"date1",
",",
"final",
"Date",
"date2",
")",
"{",
"if",
"(",
"date1",
"==",
"null",
"||",
"date2",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The date must not be null\"",
")",
";",
"}",
"final",
"Calendar",
"cal1",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal1",
".",
"setTime",
"(",
"date1",
")",
";",
"final",
"Calendar",
"cal2",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal2",
".",
"setTime",
"(",
"date2",
")",
";",
"return",
"isSameDay",
"(",
"cal1",
",",
"cal2",
")",
";",
"}"
] | <p>Checks if two date objects are on the same day ignoring time.</p>
<p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.
28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false.
</p>
@param date1 the first date, not altered, not null
@param date2 the second date, not altered, not null
@return true if they represent the same day
@throws IllegalArgumentException if either date is <code>null</code>
@since 2.1 | [
"<p",
">",
"Checks",
"if",
"two",
"date",
"objects",
"are",
"on",
"the",
"same",
"day",
"ignoring",
"time",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/ManfredTremmel/gwt-commons-lang3/blob/9e2dfbbda3668cfa5d935fe76479d1426c294504/src/main/java/org/apache/commons/lang3/time/DateUtils.java#L168-L177 |
JOML-CI/JOML | src/org/joml/Intersectionf.java | Intersectionf.intersectRayAar | public static int intersectRayAar(Vector2fc origin, Vector2fc dir, Vector2fc min, Vector2fc max, Vector2f result) {
"""
Determine whether the given ray with the given <code>origin</code> and direction <code>dir</code>
intersects the axis-aligned rectangle given as its minimum corner <code>min</code> and maximum corner <code>max</code>,
and return the values of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the near and far point of intersection
as well as the side of the axis-aligned rectangle the ray intersects.
<p>
This method also detects an intersection for a ray whose origin lies inside the axis-aligned rectangle.
<p>
Reference: <a href="https://dl.acm.org/citation.cfm?id=1198748">An Efficient and Robust Ray–Box Intersection</a>
@see #intersectRayAar(float, float, float, float, float, float, float, float, Vector2f)
@param origin
the ray's origin
@param dir
the ray's direction
@param min
the minimum corner of the axis-aligned rectangle
@param max
the maximum corner of the axis-aligned rectangle
@param result
a vector which will hold the values of the parameter <i>t</i> in the ray equation
<i>p(t) = origin + t * dir</i> of the near and far point of intersection
@return the side on which the near intersection occurred as one of
{@link #AAR_SIDE_MINX}, {@link #AAR_SIDE_MINY}, {@link #AAR_SIDE_MAXX} or {@link #AAR_SIDE_MAXY};
or <code>-1</code> if the ray does not intersect the axis-aligned rectangle;
"""
return intersectRayAar(origin.x(), origin.y(), dir.x(), dir.y(), min.x(), min.y(), max.x(), max.y(), result);
} | java | public static int intersectRayAar(Vector2fc origin, Vector2fc dir, Vector2fc min, Vector2fc max, Vector2f result) {
return intersectRayAar(origin.x(), origin.y(), dir.x(), dir.y(), min.x(), min.y(), max.x(), max.y(), result);
} | [
"public",
"static",
"int",
"intersectRayAar",
"(",
"Vector2fc",
"origin",
",",
"Vector2fc",
"dir",
",",
"Vector2fc",
"min",
",",
"Vector2fc",
"max",
",",
"Vector2f",
"result",
")",
"{",
"return",
"intersectRayAar",
"(",
"origin",
".",
"x",
"(",
")",
",",
"origin",
".",
"y",
"(",
")",
",",
"dir",
".",
"x",
"(",
")",
",",
"dir",
".",
"y",
"(",
")",
",",
"min",
".",
"x",
"(",
")",
",",
"min",
".",
"y",
"(",
")",
",",
"max",
".",
"x",
"(",
")",
",",
"max",
".",
"y",
"(",
")",
",",
"result",
")",
";",
"}"
] | Determine whether the given ray with the given <code>origin</code> and direction <code>dir</code>
intersects the axis-aligned rectangle given as its minimum corner <code>min</code> and maximum corner <code>max</code>,
and return the values of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the near and far point of intersection
as well as the side of the axis-aligned rectangle the ray intersects.
<p>
This method also detects an intersection for a ray whose origin lies inside the axis-aligned rectangle.
<p>
Reference: <a href="https://dl.acm.org/citation.cfm?id=1198748">An Efficient and Robust Ray–Box Intersection</a>
@see #intersectRayAar(float, float, float, float, float, float, float, float, Vector2f)
@param origin
the ray's origin
@param dir
the ray's direction
@param min
the minimum corner of the axis-aligned rectangle
@param max
the maximum corner of the axis-aligned rectangle
@param result
a vector which will hold the values of the parameter <i>t</i> in the ray equation
<i>p(t) = origin + t * dir</i> of the near and far point of intersection
@return the side on which the near intersection occurred as one of
{@link #AAR_SIDE_MINX}, {@link #AAR_SIDE_MINY}, {@link #AAR_SIDE_MAXX} or {@link #AAR_SIDE_MAXY};
or <code>-1</code> if the ray does not intersect the axis-aligned rectangle; | [
"Determine",
"whether",
"the",
"given",
"ray",
"with",
"the",
"given",
"<code",
">",
"origin<",
"/",
"code",
">",
"and",
"direction",
"<code",
">",
"dir<",
"/",
"code",
">",
"intersects",
"the",
"axis",
"-",
"aligned",
"rectangle",
"given",
"as",
"its",
"minimum",
"corner",
"<code",
">",
"min<",
"/",
"code",
">",
"and",
"maximum",
"corner",
"<code",
">",
"max<",
"/",
"code",
">",
"and",
"return",
"the",
"values",
"of",
"the",
"parameter",
"<i",
">",
"t<",
"/",
"i",
">",
"in",
"the",
"ray",
"equation",
"<i",
">",
"p",
"(",
"t",
")",
"=",
"origin",
"+",
"t",
"*",
"dir<",
"/",
"i",
">",
"of",
"the",
"near",
"and",
"far",
"point",
"of",
"intersection",
"as",
"well",
"as",
"the",
"side",
"of",
"the",
"axis",
"-",
"aligned",
"rectangle",
"the",
"ray",
"intersects",
".",
"<p",
">",
"This",
"method",
"also",
"detects",
"an",
"intersection",
"for",
"a",
"ray",
"whose",
"origin",
"lies",
"inside",
"the",
"axis",
"-",
"aligned",
"rectangle",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"https",
":",
"//",
"dl",
".",
"acm",
".",
"org",
"/",
"citation",
".",
"cfm?id",
"=",
"1198748",
">",
"An",
"Efficient",
"and",
"Robust",
"Ray–Box",
"Intersection<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Intersectionf.java#L4441-L4443 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/rocksdb/RocksDbWrapper.java | RocksDbWrapper.getProperty | public String getProperty(String cfName, String name) throws RocksDbException {
"""
See {@link RocksDB#getProperty(ColumnFamilyHandle, String)}.
@param cfName
@param name
@return
@throws RocksDbException
"""
ColumnFamilyHandle cfh = getColumnFamilyHandle(cfName);
if (cfh == null) {
throw new RocksDbException.ColumnFamilyNotExists(cfName);
}
try {
return rocksDb.getProperty(cfh, name);
} catch (Exception e) {
throw e instanceof RocksDbException ? (RocksDbException) e : new RocksDbException(e);
}
} | java | public String getProperty(String cfName, String name) throws RocksDbException {
ColumnFamilyHandle cfh = getColumnFamilyHandle(cfName);
if (cfh == null) {
throw new RocksDbException.ColumnFamilyNotExists(cfName);
}
try {
return rocksDb.getProperty(cfh, name);
} catch (Exception e) {
throw e instanceof RocksDbException ? (RocksDbException) e : new RocksDbException(e);
}
} | [
"public",
"String",
"getProperty",
"(",
"String",
"cfName",
",",
"String",
"name",
")",
"throws",
"RocksDbException",
"{",
"ColumnFamilyHandle",
"cfh",
"=",
"getColumnFamilyHandle",
"(",
"cfName",
")",
";",
"if",
"(",
"cfh",
"==",
"null",
")",
"{",
"throw",
"new",
"RocksDbException",
".",
"ColumnFamilyNotExists",
"(",
"cfName",
")",
";",
"}",
"try",
"{",
"return",
"rocksDb",
".",
"getProperty",
"(",
"cfh",
",",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"e",
"instanceof",
"RocksDbException",
"?",
"(",
"RocksDbException",
")",
"e",
":",
"new",
"RocksDbException",
"(",
"e",
")",
";",
"}",
"}"
] | See {@link RocksDB#getProperty(ColumnFamilyHandle, String)}.
@param cfName
@param name
@return
@throws RocksDbException | [
"See",
"{",
"@link",
"RocksDB#getProperty",
"(",
"ColumnFamilyHandle",
"String",
")",
"}",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/rocksdb/RocksDbWrapper.java#L452-L462 |
datumbox/datumbox-framework | datumbox-framework-common/src/main/java/com/datumbox/framework/common/utilities/ReflectionMethods.java | ReflectionMethods.invokeMethod | public static Object invokeMethod(Object obj, String methodName, Object... params) {
"""
Invokes a method on the object using reflection.
@param obj
@param methodName
@param params
@return
"""
Method method = findMethod(obj, methodName, params);
return invokeMethod(obj, method, params);
} | java | public static Object invokeMethod(Object obj, String methodName, Object... params) {
Method method = findMethod(obj, methodName, params);
return invokeMethod(obj, method, params);
} | [
"public",
"static",
"Object",
"invokeMethod",
"(",
"Object",
"obj",
",",
"String",
"methodName",
",",
"Object",
"...",
"params",
")",
"{",
"Method",
"method",
"=",
"findMethod",
"(",
"obj",
",",
"methodName",
",",
"params",
")",
";",
"return",
"invokeMethod",
"(",
"obj",
",",
"method",
",",
"params",
")",
";",
"}"
] | Invokes a method on the object using reflection.
@param obj
@param methodName
@param params
@return | [
"Invokes",
"a",
"method",
"on",
"the",
"object",
"using",
"reflection",
"."
] | train | https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-common/src/main/java/com/datumbox/framework/common/utilities/ReflectionMethods.java#L121-L124 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/geo/EnvelopeConverter.java | EnvelopeConverter.getCoordinates | public double[] getCoordinates(String inputString)
throws TypeConversionException {
"""
Retrieves a list of coordinates from the given string. If the number of numbers in the string is odd,
the last number is ignored.
@param inputString The inputstring
@return A list of coordinates
@throws TypeConversionException If the conversion failed
"""
String[] cstr = inputString.split(",");
int coordLength;
if (cstr.length % 2 == 0) {
coordLength = cstr.length;
} else {
coordLength = cstr.length -1;
}
double[] coordinates = new double[coordLength];
try {
for (int index = 0; index < coordLength; index++) {
coordinates[index] = Double.parseDouble(cstr[index]);
}
return coordinates;
} catch (NumberFormatException e) {
throw new TypeConversionException("String contains non-numeric data. Impossible to create envelope", e);
}
} | java | public double[] getCoordinates(String inputString)
throws TypeConversionException {
String[] cstr = inputString.split(",");
int coordLength;
if (cstr.length % 2 == 0) {
coordLength = cstr.length;
} else {
coordLength = cstr.length -1;
}
double[] coordinates = new double[coordLength];
try {
for (int index = 0; index < coordLength; index++) {
coordinates[index] = Double.parseDouble(cstr[index]);
}
return coordinates;
} catch (NumberFormatException e) {
throw new TypeConversionException("String contains non-numeric data. Impossible to create envelope", e);
}
} | [
"public",
"double",
"[",
"]",
"getCoordinates",
"(",
"String",
"inputString",
")",
"throws",
"TypeConversionException",
"{",
"String",
"[",
"]",
"cstr",
"=",
"inputString",
".",
"split",
"(",
"\",\"",
")",
";",
"int",
"coordLength",
";",
"if",
"(",
"cstr",
".",
"length",
"%",
"2",
"==",
"0",
")",
"{",
"coordLength",
"=",
"cstr",
".",
"length",
";",
"}",
"else",
"{",
"coordLength",
"=",
"cstr",
".",
"length",
"-",
"1",
";",
"}",
"double",
"[",
"]",
"coordinates",
"=",
"new",
"double",
"[",
"coordLength",
"]",
";",
"try",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"coordLength",
";",
"index",
"++",
")",
"{",
"coordinates",
"[",
"index",
"]",
"=",
"Double",
".",
"parseDouble",
"(",
"cstr",
"[",
"index",
"]",
")",
";",
"}",
"return",
"coordinates",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"throw",
"new",
"TypeConversionException",
"(",
"\"String contains non-numeric data. Impossible to create envelope\"",
",",
"e",
")",
";",
"}",
"}"
] | Retrieves a list of coordinates from the given string. If the number of numbers in the string is odd,
the last number is ignored.
@param inputString The inputstring
@return A list of coordinates
@throws TypeConversionException If the conversion failed | [
"Retrieves",
"a",
"list",
"of",
"coordinates",
"from",
"the",
"given",
"string",
".",
"If",
"the",
"number",
"of",
"numbers",
"in",
"the",
"string",
"is",
"odd",
"the",
"last",
"number",
"is",
"ignored",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/geo/EnvelopeConverter.java#L98-L117 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/spatial/Bbox.java | Bbox.createFittingBox | public Bbox createFittingBox(double ratioWidth, double ratioHeight) {
"""
Creates a bbox that fits exactly in this box but has a different width/height ratio.
@param ratioWidth width dor ratio
@param ratioHeight height for ratio
@return bbox
"""
if (ratioWidth > 0 && ratioHeight > 0) {
double newRatio = ratioWidth / ratioHeight;
double oldRatio = width / height;
double newWidth = width;
double newHeight = height;
if (newRatio > oldRatio) {
newHeight = width / newRatio;
} else {
newWidth = height * newRatio;
}
Bbox result = new Bbox(0, 0, newWidth, newHeight);
result.setCenterPoint(getCenterPoint());
return result;
} else {
return new Bbox(this);
}
} | java | public Bbox createFittingBox(double ratioWidth, double ratioHeight) {
if (ratioWidth > 0 && ratioHeight > 0) {
double newRatio = ratioWidth / ratioHeight;
double oldRatio = width / height;
double newWidth = width;
double newHeight = height;
if (newRatio > oldRatio) {
newHeight = width / newRatio;
} else {
newWidth = height * newRatio;
}
Bbox result = new Bbox(0, 0, newWidth, newHeight);
result.setCenterPoint(getCenterPoint());
return result;
} else {
return new Bbox(this);
}
} | [
"public",
"Bbox",
"createFittingBox",
"(",
"double",
"ratioWidth",
",",
"double",
"ratioHeight",
")",
"{",
"if",
"(",
"ratioWidth",
">",
"0",
"&&",
"ratioHeight",
">",
"0",
")",
"{",
"double",
"newRatio",
"=",
"ratioWidth",
"/",
"ratioHeight",
";",
"double",
"oldRatio",
"=",
"width",
"/",
"height",
";",
"double",
"newWidth",
"=",
"width",
";",
"double",
"newHeight",
"=",
"height",
";",
"if",
"(",
"newRatio",
">",
"oldRatio",
")",
"{",
"newHeight",
"=",
"width",
"/",
"newRatio",
";",
"}",
"else",
"{",
"newWidth",
"=",
"height",
"*",
"newRatio",
";",
"}",
"Bbox",
"result",
"=",
"new",
"Bbox",
"(",
"0",
",",
"0",
",",
"newWidth",
",",
"newHeight",
")",
";",
"result",
".",
"setCenterPoint",
"(",
"getCenterPoint",
"(",
")",
")",
";",
"return",
"result",
";",
"}",
"else",
"{",
"return",
"new",
"Bbox",
"(",
"this",
")",
";",
"}",
"}"
] | Creates a bbox that fits exactly in this box but has a different width/height ratio.
@param ratioWidth width dor ratio
@param ratioHeight height for ratio
@return bbox | [
"Creates",
"a",
"bbox",
"that",
"fits",
"exactly",
"in",
"this",
"box",
"but",
"has",
"a",
"different",
"width",
"/",
"height",
"ratio",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/spatial/Bbox.java#L326-L343 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/classify/Dataset.java | Dataset.selectFeatures | public void selectFeatures(int numFeatures, double[] scores) {
"""
Generic method to select features based on the feature scores vector provided as an argument.
@param numFeatures number of features to be selected.
@param scores a vector of size total number of features in the data.
"""
List<ScoredObject<F>> scoredFeatures = new ArrayList<ScoredObject<F>>();
for (int i = 0; i < scores.length; i++) {
scoredFeatures.add(new ScoredObject<F>(featureIndex.get(i), scores[i]));
}
Collections.sort(scoredFeatures, ScoredComparator.DESCENDING_COMPARATOR);
Index<F> newFeatureIndex = new HashIndex<F>();
for (int i = 0; i < scoredFeatures.size() && i < numFeatures; i++) {
newFeatureIndex.add(scoredFeatures.get(i).object());
//System.err.println(scoredFeatures.get(i));
}
for (int i = 0; i < size; i++) {
int[] newData = new int[data[i].length];
int curIndex = 0;
for (int j = 0; j < data[i].length; j++) {
int index;
if ((index = newFeatureIndex.indexOf(featureIndex.get(data[i][j]))) != -1) {
newData[curIndex++] = index;
}
}
int[] newDataTrimmed = new int[curIndex];
System.arraycopy(newData, 0, newDataTrimmed, 0, curIndex);
data[i] = newDataTrimmed;
}
featureIndex = newFeatureIndex;
} | java | public void selectFeatures(int numFeatures, double[] scores) {
List<ScoredObject<F>> scoredFeatures = new ArrayList<ScoredObject<F>>();
for (int i = 0; i < scores.length; i++) {
scoredFeatures.add(new ScoredObject<F>(featureIndex.get(i), scores[i]));
}
Collections.sort(scoredFeatures, ScoredComparator.DESCENDING_COMPARATOR);
Index<F> newFeatureIndex = new HashIndex<F>();
for (int i = 0; i < scoredFeatures.size() && i < numFeatures; i++) {
newFeatureIndex.add(scoredFeatures.get(i).object());
//System.err.println(scoredFeatures.get(i));
}
for (int i = 0; i < size; i++) {
int[] newData = new int[data[i].length];
int curIndex = 0;
for (int j = 0; j < data[i].length; j++) {
int index;
if ((index = newFeatureIndex.indexOf(featureIndex.get(data[i][j]))) != -1) {
newData[curIndex++] = index;
}
}
int[] newDataTrimmed = new int[curIndex];
System.arraycopy(newData, 0, newDataTrimmed, 0, curIndex);
data[i] = newDataTrimmed;
}
featureIndex = newFeatureIndex;
} | [
"public",
"void",
"selectFeatures",
"(",
"int",
"numFeatures",
",",
"double",
"[",
"]",
"scores",
")",
"{",
"List",
"<",
"ScoredObject",
"<",
"F",
">>",
"scoredFeatures",
"=",
"new",
"ArrayList",
"<",
"ScoredObject",
"<",
"F",
">",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scores",
".",
"length",
";",
"i",
"++",
")",
"{",
"scoredFeatures",
".",
"add",
"(",
"new",
"ScoredObject",
"<",
"F",
">",
"(",
"featureIndex",
".",
"get",
"(",
"i",
")",
",",
"scores",
"[",
"i",
"]",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"scoredFeatures",
",",
"ScoredComparator",
".",
"DESCENDING_COMPARATOR",
")",
";",
"Index",
"<",
"F",
">",
"newFeatureIndex",
"=",
"new",
"HashIndex",
"<",
"F",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scoredFeatures",
".",
"size",
"(",
")",
"&&",
"i",
"<",
"numFeatures",
";",
"i",
"++",
")",
"{",
"newFeatureIndex",
".",
"add",
"(",
"scoredFeatures",
".",
"get",
"(",
"i",
")",
".",
"object",
"(",
")",
")",
";",
"//System.err.println(scoredFeatures.get(i));\r",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"int",
"[",
"]",
"newData",
"=",
"new",
"int",
"[",
"data",
"[",
"i",
"]",
".",
"length",
"]",
";",
"int",
"curIndex",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"data",
"[",
"i",
"]",
".",
"length",
";",
"j",
"++",
")",
"{",
"int",
"index",
";",
"if",
"(",
"(",
"index",
"=",
"newFeatureIndex",
".",
"indexOf",
"(",
"featureIndex",
".",
"get",
"(",
"data",
"[",
"i",
"]",
"[",
"j",
"]",
")",
")",
")",
"!=",
"-",
"1",
")",
"{",
"newData",
"[",
"curIndex",
"++",
"]",
"=",
"index",
";",
"}",
"}",
"int",
"[",
"]",
"newDataTrimmed",
"=",
"new",
"int",
"[",
"curIndex",
"]",
";",
"System",
".",
"arraycopy",
"(",
"newData",
",",
"0",
",",
"newDataTrimmed",
",",
"0",
",",
"curIndex",
")",
";",
"data",
"[",
"i",
"]",
"=",
"newDataTrimmed",
";",
"}",
"featureIndex",
"=",
"newFeatureIndex",
";",
"}"
] | Generic method to select features based on the feature scores vector provided as an argument.
@param numFeatures number of features to be selected.
@param scores a vector of size total number of features in the data. | [
"Generic",
"method",
"to",
"select",
"features",
"based",
"on",
"the",
"feature",
"scores",
"vector",
"provided",
"as",
"an",
"argument",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/classify/Dataset.java#L598-L627 |
alibaba/jstorm | jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/JstormYarnUtils.java | JstormYarnUtils.getSupervisorSlotPorts | public static String getSupervisorSlotPorts(int memory, int vcores, String instanceName, String supervisorHost, RegistryOperations registryOperations) {
"""
this is for jstorm configuration's format
@param memory
@param vcores
@param supervisorHost
@return
"""
return join(getSupervisorPorts(memory, vcores, instanceName, supervisorHost, registryOperations), JOYConstants.COMMA, false);
} | java | public static String getSupervisorSlotPorts(int memory, int vcores, String instanceName, String supervisorHost, RegistryOperations registryOperations) {
return join(getSupervisorPorts(memory, vcores, instanceName, supervisorHost, registryOperations), JOYConstants.COMMA, false);
} | [
"public",
"static",
"String",
"getSupervisorSlotPorts",
"(",
"int",
"memory",
",",
"int",
"vcores",
",",
"String",
"instanceName",
",",
"String",
"supervisorHost",
",",
"RegistryOperations",
"registryOperations",
")",
"{",
"return",
"join",
"(",
"getSupervisorPorts",
"(",
"memory",
",",
"vcores",
",",
"instanceName",
",",
"supervisorHost",
",",
"registryOperations",
")",
",",
"JOYConstants",
".",
"COMMA",
",",
"false",
")",
";",
"}"
] | this is for jstorm configuration's format
@param memory
@param vcores
@param supervisorHost
@return | [
"this",
"is",
"for",
"jstorm",
"configuration",
"s",
"format"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/JstormYarnUtils.java#L283-L285 |
graknlabs/grakn | server/src/server/kb/ValidateGlobalRules.java | ValidateGlobalRules.validatePlaysAndRelatesStructure | static Set<String> validatePlaysAndRelatesStructure(Casting casting) {
"""
This method checks if the plays edge has been added between the roleplayer's Type and
the Role being played.
It also checks if the Role of the Casting has been linked to the RelationType of the
Relation which the Casting connects to.
@return Specific errors if any are found
"""
Set<String> errors = new HashSet<>();
//Gets here to make sure we traverse/read only once
Thing thing = casting.getRolePlayer();
Role role = casting.getRole();
Relation relation = casting.getRelation();
//Actual checks
roleNotAllowedToBePlayed(role, thing).ifPresent(errors::add);
roleNotLinkedToRelation(role, relation.type(), relation).ifPresent(errors::add);
return errors;
} | java | static Set<String> validatePlaysAndRelatesStructure(Casting casting) {
Set<String> errors = new HashSet<>();
//Gets here to make sure we traverse/read only once
Thing thing = casting.getRolePlayer();
Role role = casting.getRole();
Relation relation = casting.getRelation();
//Actual checks
roleNotAllowedToBePlayed(role, thing).ifPresent(errors::add);
roleNotLinkedToRelation(role, relation.type(), relation).ifPresent(errors::add);
return errors;
} | [
"static",
"Set",
"<",
"String",
">",
"validatePlaysAndRelatesStructure",
"(",
"Casting",
"casting",
")",
"{",
"Set",
"<",
"String",
">",
"errors",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"//Gets here to make sure we traverse/read only once",
"Thing",
"thing",
"=",
"casting",
".",
"getRolePlayer",
"(",
")",
";",
"Role",
"role",
"=",
"casting",
".",
"getRole",
"(",
")",
";",
"Relation",
"relation",
"=",
"casting",
".",
"getRelation",
"(",
")",
";",
"//Actual checks",
"roleNotAllowedToBePlayed",
"(",
"role",
",",
"thing",
")",
".",
"ifPresent",
"(",
"errors",
"::",
"add",
")",
";",
"roleNotLinkedToRelation",
"(",
"role",
",",
"relation",
".",
"type",
"(",
")",
",",
"relation",
")",
".",
"ifPresent",
"(",
"errors",
"::",
"add",
")",
";",
"return",
"errors",
";",
"}"
] | This method checks if the plays edge has been added between the roleplayer's Type and
the Role being played.
It also checks if the Role of the Casting has been linked to the RelationType of the
Relation which the Casting connects to.
@return Specific errors if any are found | [
"This",
"method",
"checks",
"if",
"the",
"plays",
"edge",
"has",
"been",
"added",
"between",
"the",
"roleplayer",
"s",
"Type",
"and",
"the",
"Role",
"being",
"played",
".",
"It",
"also",
"checks",
"if",
"the",
"Role",
"of",
"the",
"Casting",
"has",
"been",
"linked",
"to",
"the",
"RelationType",
"of",
"the",
"Relation",
"which",
"the",
"Casting",
"connects",
"to",
"."
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/server/kb/ValidateGlobalRules.java#L99-L112 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/io/retry/RetryPolicies.java | RetryPolicies.exponentialBackoffRetry | public static final RetryPolicy exponentialBackoffRetry(
int maxRetries, long sleepTime, TimeUnit timeUnit) {
"""
<p>
Keep trying a limited number of times, waiting a growing amount of time between attempts,
and then fail by re-throwing the exception.
The time between attempts is <code>sleepTime</code> mutliplied by a random
number in the range of [0, 2 to the number of retries)
</p>
"""
return new ExponentialBackoffRetry(maxRetries, sleepTime, timeUnit);
} | java | public static final RetryPolicy exponentialBackoffRetry(
int maxRetries, long sleepTime, TimeUnit timeUnit) {
return new ExponentialBackoffRetry(maxRetries, sleepTime, timeUnit);
} | [
"public",
"static",
"final",
"RetryPolicy",
"exponentialBackoffRetry",
"(",
"int",
"maxRetries",
",",
"long",
"sleepTime",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"new",
"ExponentialBackoffRetry",
"(",
"maxRetries",
",",
"sleepTime",
",",
"timeUnit",
")",
";",
"}"
] | <p>
Keep trying a limited number of times, waiting a growing amount of time between attempts,
and then fail by re-throwing the exception.
The time between attempts is <code>sleepTime</code> mutliplied by a random
number in the range of [0, 2 to the number of retries)
</p> | [
"<p",
">",
"Keep",
"trying",
"a",
"limited",
"number",
"of",
"times",
"waiting",
"a",
"growing",
"amount",
"of",
"time",
"between",
"attempts",
"and",
"then",
"fail",
"by",
"re",
"-",
"throwing",
"the",
"exception",
".",
"The",
"time",
"between",
"attempts",
"is",
"<code",
">",
"sleepTime<",
"/",
"code",
">",
"mutliplied",
"by",
"a",
"random",
"number",
"in",
"the",
"range",
"of",
"[",
"0",
"2",
"to",
"the",
"number",
"of",
"retries",
")",
"<",
"/",
"p",
">"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/io/retry/RetryPolicies.java#L98-L101 |
OpenLiberty/open-liberty | dev/com.ibm.ws.app.manager/src/com/ibm/ws/app/manager/internal/monitor/DropinMonitor.java | DropinMonitor.refresh | public synchronized void refresh(ApplicationMonitorConfig config) {
"""
Initialize the dropins manager based on configured properties
@param properties
@return
"""
if (config != null && config.isDropinsMonitored()) {
//ApplicationMonitorConfig prevConfig = _config.getAndSet(config);
_config.set(config);
// keep track of the old monitored directory to see if we need to uninstall apps
File previousMonitoredDirectory = null;
boolean createdPreviousDirectory = createdMonitoredDir.get();
String newMonitoredFolder = config.getLocation();
//if the user set the monitored folder location to be empty or it is somehow null
if ((newMonitoredFolder != null) && (!newMonitoredFolder.equals(""))) {
previousMonitoredDirectory = updateMonitoredDirectory(newMonitoredFolder);
}
if (!!!_coreMonitor.isRegistered()) {
stopRemovedApplications();
// The service has not been started yet.
// load the pids for applications already setup before starting the service fully
configureCoreMonitor(config);
_coreMonitor.register(_ctx, FileMonitor.class, new FileMonitorImpl());
Tr.audit(_tc, "APPLICATION_MONITOR_STARTED", newMonitoredFolder);
} else if (!!!monitoredDirectory.get().equals(previousMonitoredDirectory)) {
// The directory has changed so stop the old applications
stopAllStartedApplications();
// Need to re-register because file monitor doesn't appear to work from modified events.
_coreMonitor.unregister();
// Update the registration with new config before registering the service again
configureCoreMonitor(config);
_coreMonitor.register(_ctx, FileMonitor.class, new FileMonitorImpl());
// Tidy up old location if we built it
tidyUpMonitoredDirectory(createdPreviousDirectory, previousMonitoredDirectory);
}
} else {
// the monitoring service has been disabled: stop/deregister the service
stopAllStartedApplications();
stop();
}
} | java | public synchronized void refresh(ApplicationMonitorConfig config) {
if (config != null && config.isDropinsMonitored()) {
//ApplicationMonitorConfig prevConfig = _config.getAndSet(config);
_config.set(config);
// keep track of the old monitored directory to see if we need to uninstall apps
File previousMonitoredDirectory = null;
boolean createdPreviousDirectory = createdMonitoredDir.get();
String newMonitoredFolder = config.getLocation();
//if the user set the monitored folder location to be empty or it is somehow null
if ((newMonitoredFolder != null) && (!newMonitoredFolder.equals(""))) {
previousMonitoredDirectory = updateMonitoredDirectory(newMonitoredFolder);
}
if (!!!_coreMonitor.isRegistered()) {
stopRemovedApplications();
// The service has not been started yet.
// load the pids for applications already setup before starting the service fully
configureCoreMonitor(config);
_coreMonitor.register(_ctx, FileMonitor.class, new FileMonitorImpl());
Tr.audit(_tc, "APPLICATION_MONITOR_STARTED", newMonitoredFolder);
} else if (!!!monitoredDirectory.get().equals(previousMonitoredDirectory)) {
// The directory has changed so stop the old applications
stopAllStartedApplications();
// Need to re-register because file monitor doesn't appear to work from modified events.
_coreMonitor.unregister();
// Update the registration with new config before registering the service again
configureCoreMonitor(config);
_coreMonitor.register(_ctx, FileMonitor.class, new FileMonitorImpl());
// Tidy up old location if we built it
tidyUpMonitoredDirectory(createdPreviousDirectory, previousMonitoredDirectory);
}
} else {
// the monitoring service has been disabled: stop/deregister the service
stopAllStartedApplications();
stop();
}
} | [
"public",
"synchronized",
"void",
"refresh",
"(",
"ApplicationMonitorConfig",
"config",
")",
"{",
"if",
"(",
"config",
"!=",
"null",
"&&",
"config",
".",
"isDropinsMonitored",
"(",
")",
")",
"{",
"//ApplicationMonitorConfig prevConfig = _config.getAndSet(config);",
"_config",
".",
"set",
"(",
"config",
")",
";",
"// keep track of the old monitored directory to see if we need to uninstall apps",
"File",
"previousMonitoredDirectory",
"=",
"null",
";",
"boolean",
"createdPreviousDirectory",
"=",
"createdMonitoredDir",
".",
"get",
"(",
")",
";",
"String",
"newMonitoredFolder",
"=",
"config",
".",
"getLocation",
"(",
")",
";",
"//if the user set the monitored folder location to be empty or it is somehow null",
"if",
"(",
"(",
"newMonitoredFolder",
"!=",
"null",
")",
"&&",
"(",
"!",
"newMonitoredFolder",
".",
"equals",
"(",
"\"\"",
")",
")",
")",
"{",
"previousMonitoredDirectory",
"=",
"updateMonitoredDirectory",
"(",
"newMonitoredFolder",
")",
";",
"}",
"if",
"(",
"!",
"!",
"!",
"_coreMonitor",
".",
"isRegistered",
"(",
")",
")",
"{",
"stopRemovedApplications",
"(",
")",
";",
"// The service has not been started yet.",
"// load the pids for applications already setup before starting the service fully",
"configureCoreMonitor",
"(",
"config",
")",
";",
"_coreMonitor",
".",
"register",
"(",
"_ctx",
",",
"FileMonitor",
".",
"class",
",",
"new",
"FileMonitorImpl",
"(",
")",
")",
";",
"Tr",
".",
"audit",
"(",
"_tc",
",",
"\"APPLICATION_MONITOR_STARTED\"",
",",
"newMonitoredFolder",
")",
";",
"}",
"else",
"if",
"(",
"!",
"!",
"!",
"monitoredDirectory",
".",
"get",
"(",
")",
".",
"equals",
"(",
"previousMonitoredDirectory",
")",
")",
"{",
"// The directory has changed so stop the old applications",
"stopAllStartedApplications",
"(",
")",
";",
"// Need to re-register because file monitor doesn't appear to work from modified events.",
"_coreMonitor",
".",
"unregister",
"(",
")",
";",
"// Update the registration with new config before registering the service again",
"configureCoreMonitor",
"(",
"config",
")",
";",
"_coreMonitor",
".",
"register",
"(",
"_ctx",
",",
"FileMonitor",
".",
"class",
",",
"new",
"FileMonitorImpl",
"(",
")",
")",
";",
"// Tidy up old location if we built it",
"tidyUpMonitoredDirectory",
"(",
"createdPreviousDirectory",
",",
"previousMonitoredDirectory",
")",
";",
"}",
"}",
"else",
"{",
"// the monitoring service has been disabled: stop/deregister the service",
"stopAllStartedApplications",
"(",
")",
";",
"stop",
"(",
")",
";",
"}",
"}"
] | Initialize the dropins manager based on configured properties
@param properties
@return | [
"Initialize",
"the",
"dropins",
"manager",
"based",
"on",
"configured",
"properties"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.app.manager/src/com/ibm/ws/app/manager/internal/monitor/DropinMonitor.java#L206-L249 |
Waxolunist/bittwiddling | src/main/java/com/vcollaborate/bitwise/BinaryUtils.java | BinaryUtils.toBitSet | public static final BitSet toBitSet(final int size, final long value) {
"""
Converts {@code value} into a {@link BitSet} of size {@code size}.
"""
BitSet bits = new BitSet(size);
int idx = 0;
long tmp = value;
while (tmp != 0L) {
if (tmp % 2L != 0L) {
bits.set(idx);
}
++idx;
tmp = tmp >>> 1;
}
return bits;
} | java | public static final BitSet toBitSet(final int size, final long value) {
BitSet bits = new BitSet(size);
int idx = 0;
long tmp = value;
while (tmp != 0L) {
if (tmp % 2L != 0L) {
bits.set(idx);
}
++idx;
tmp = tmp >>> 1;
}
return bits;
} | [
"public",
"static",
"final",
"BitSet",
"toBitSet",
"(",
"final",
"int",
"size",
",",
"final",
"long",
"value",
")",
"{",
"BitSet",
"bits",
"=",
"new",
"BitSet",
"(",
"size",
")",
";",
"int",
"idx",
"=",
"0",
";",
"long",
"tmp",
"=",
"value",
";",
"while",
"(",
"tmp",
"!=",
"0L",
")",
"{",
"if",
"(",
"tmp",
"%",
"2L",
"!=",
"0L",
")",
"{",
"bits",
".",
"set",
"(",
"idx",
")",
";",
"}",
"++",
"idx",
";",
"tmp",
"=",
"tmp",
">>>",
"1",
";",
"}",
"return",
"bits",
";",
"}"
] | Converts {@code value} into a {@link BitSet} of size {@code size}. | [
"Converts",
"{"
] | train | https://github.com/Waxolunist/bittwiddling/blob/2c36342add73aab1223292d12fcff453aa3c07cd/src/main/java/com/vcollaborate/bitwise/BinaryUtils.java#L34-L46 |
Red5/red5-io | src/main/java/org/red5/io/matroska/ParserUtils.java | ParserUtils.parseFloat | public static double parseFloat(InputStream inputStream, final int size) throws IOException {
"""
method used to parse float and double
@param inputStream
- stream to get value
@param size
- size of the value in bytes
@return - parsed value as double
@throws IOException
- in case of IO error
"""
byte[] buffer = new byte[size];
int numberOfReadsBytes = inputStream.read(buffer, 0, size);
assert numberOfReadsBytes == size;
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer).order(ByteOrder.BIG_ENDIAN);
if (8 == size) {
return byteBuffer.getDouble();
}
return byteBuffer.getFloat();
} | java | public static double parseFloat(InputStream inputStream, final int size) throws IOException {
byte[] buffer = new byte[size];
int numberOfReadsBytes = inputStream.read(buffer, 0, size);
assert numberOfReadsBytes == size;
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer).order(ByteOrder.BIG_ENDIAN);
if (8 == size) {
return byteBuffer.getDouble();
}
return byteBuffer.getFloat();
} | [
"public",
"static",
"double",
"parseFloat",
"(",
"InputStream",
"inputStream",
",",
"final",
"int",
"size",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"int",
"numberOfReadsBytes",
"=",
"inputStream",
".",
"read",
"(",
"buffer",
",",
"0",
",",
"size",
")",
";",
"assert",
"numberOfReadsBytes",
"==",
"size",
";",
"ByteBuffer",
"byteBuffer",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"buffer",
")",
".",
"order",
"(",
"ByteOrder",
".",
"BIG_ENDIAN",
")",
";",
"if",
"(",
"8",
"==",
"size",
")",
"{",
"return",
"byteBuffer",
".",
"getDouble",
"(",
")",
";",
"}",
"return",
"byteBuffer",
".",
"getFloat",
"(",
")",
";",
"}"
] | method used to parse float and double
@param inputStream
- stream to get value
@param size
- size of the value in bytes
@return - parsed value as double
@throws IOException
- in case of IO error | [
"method",
"used",
"to",
"parse",
"float",
"and",
"double"
] | train | https://github.com/Red5/red5-io/blob/9bbbc506423c5a8f18169d46d400df56c0072a33/src/main/java/org/red5/io/matroska/ParserUtils.java#L100-L111 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java | FutureUtils.toJava | public static <T, U extends T> CompletableFuture<T> toJava(Future<U> scalaFuture) {
"""
Converts a Scala {@link Future} to a {@link CompletableFuture}.
@param scalaFuture to convert to a Java 8 CompletableFuture
@param <T> type of the future value
@param <U> type of the original future
@return Java 8 CompletableFuture
"""
final CompletableFuture<T> result = new CompletableFuture<>();
scalaFuture.onComplete(new OnComplete<U>() {
@Override
public void onComplete(Throwable failure, U success) {
if (failure != null) {
result.completeExceptionally(failure);
} else {
result.complete(success);
}
}
}, Executors.directExecutionContext());
return result;
} | java | public static <T, U extends T> CompletableFuture<T> toJava(Future<U> scalaFuture) {
final CompletableFuture<T> result = new CompletableFuture<>();
scalaFuture.onComplete(new OnComplete<U>() {
@Override
public void onComplete(Throwable failure, U success) {
if (failure != null) {
result.completeExceptionally(failure);
} else {
result.complete(success);
}
}
}, Executors.directExecutionContext());
return result;
} | [
"public",
"static",
"<",
"T",
",",
"U",
"extends",
"T",
">",
"CompletableFuture",
"<",
"T",
">",
"toJava",
"(",
"Future",
"<",
"U",
">",
"scalaFuture",
")",
"{",
"final",
"CompletableFuture",
"<",
"T",
">",
"result",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"scalaFuture",
".",
"onComplete",
"(",
"new",
"OnComplete",
"<",
"U",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onComplete",
"(",
"Throwable",
"failure",
",",
"U",
"success",
")",
"{",
"if",
"(",
"failure",
"!=",
"null",
")",
"{",
"result",
".",
"completeExceptionally",
"(",
"failure",
")",
";",
"}",
"else",
"{",
"result",
".",
"complete",
"(",
"success",
")",
";",
"}",
"}",
"}",
",",
"Executors",
".",
"directExecutionContext",
"(",
")",
")",
";",
"return",
"result",
";",
"}"
] | Converts a Scala {@link Future} to a {@link CompletableFuture}.
@param scalaFuture to convert to a Java 8 CompletableFuture
@param <T> type of the future value
@param <U> type of the original future
@return Java 8 CompletableFuture | [
"Converts",
"a",
"Scala",
"{",
"@link",
"Future",
"}",
"to",
"a",
"{",
"@link",
"CompletableFuture",
"}",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java#L808-L823 |
apache/groovy | subprojects/groovy-swing/src/main/java/org/codehaus/groovy/runtime/SwingGroovyMethods.java | SwingGroovyMethods.leftShift | public static DefaultMutableTreeNode leftShift(DefaultMutableTreeNode self, DefaultMutableTreeNode node) {
"""
Overloads the left shift operator to provide an easy way to add
nodes to a DefaultMutableTreeNode.<p>
@param self a DefaultMutableTreeNode
@param node a node to be added to the treeNode.
@return same treeNode, after the value was added to it.
@since 1.6.4
"""
self.add(node);
return self;
} | java | public static DefaultMutableTreeNode leftShift(DefaultMutableTreeNode self, DefaultMutableTreeNode node) {
self.add(node);
return self;
} | [
"public",
"static",
"DefaultMutableTreeNode",
"leftShift",
"(",
"DefaultMutableTreeNode",
"self",
",",
"DefaultMutableTreeNode",
"node",
")",
"{",
"self",
".",
"add",
"(",
"node",
")",
";",
"return",
"self",
";",
"}"
] | Overloads the left shift operator to provide an easy way to add
nodes to a DefaultMutableTreeNode.<p>
@param self a DefaultMutableTreeNode
@param node a node to be added to the treeNode.
@return same treeNode, after the value was added to it.
@since 1.6.4 | [
"Overloads",
"the",
"left",
"shift",
"operator",
"to",
"provide",
"an",
"easy",
"way",
"to",
"add",
"nodes",
"to",
"a",
"DefaultMutableTreeNode",
".",
"<p",
">"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/runtime/SwingGroovyMethods.java#L719-L722 |
beangle/beangle3 | orm/hibernate/src/main/java/org/beangle/orm/hibernate/RailsNamingStrategy.java | RailsNamingStrategy.logicalCollectionColumnName | public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
"""
Return the column name if explicit or the concatenation of the property
name and the referenced column
"""
return Strings.isNotEmpty(columnName) ? columnName : unqualify(propertyName) + "_" + referencedColumn;
} | java | public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
return Strings.isNotEmpty(columnName) ? columnName : unqualify(propertyName) + "_" + referencedColumn;
} | [
"public",
"String",
"logicalCollectionColumnName",
"(",
"String",
"columnName",
",",
"String",
"propertyName",
",",
"String",
"referencedColumn",
")",
"{",
"return",
"Strings",
".",
"isNotEmpty",
"(",
"columnName",
")",
"?",
"columnName",
":",
"unqualify",
"(",
"propertyName",
")",
"+",
"\"_\"",
"+",
"referencedColumn",
";",
"}"
] | Return the column name if explicit or the concatenation of the property
name and the referenced column | [
"Return",
"the",
"column",
"name",
"if",
"explicit",
"or",
"the",
"concatenation",
"of",
"the",
"property",
"name",
"and",
"the",
"referenced",
"column"
] | train | https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/RailsNamingStrategy.java#L166-L168 |
DDTH/ddth-commons | ddth-commons-core/src/main/java/com/github/ddth/commons/utils/IdGenerator.java | IdGenerator.extractTimestampTinyAscii | public static long extractTimestampTinyAscii(String idTinyAscii) throws NumberFormatException {
"""
Extracts the (UNIX) timestamp from a tiny ascii id (radix
{@link Character#MAX_RADIX}).
@param idTinyAscii
@return the UNIX timestamp (milliseconds)
@throws NumberFormatException
"""
return extractTimestampTiny(Long.parseLong(idTinyAscii, Character.MAX_RADIX));
} | java | public static long extractTimestampTinyAscii(String idTinyAscii) throws NumberFormatException {
return extractTimestampTiny(Long.parseLong(idTinyAscii, Character.MAX_RADIX));
} | [
"public",
"static",
"long",
"extractTimestampTinyAscii",
"(",
"String",
"idTinyAscii",
")",
"throws",
"NumberFormatException",
"{",
"return",
"extractTimestampTiny",
"(",
"Long",
".",
"parseLong",
"(",
"idTinyAscii",
",",
"Character",
".",
"MAX_RADIX",
")",
")",
";",
"}"
] | Extracts the (UNIX) timestamp from a tiny ascii id (radix
{@link Character#MAX_RADIX}).
@param idTinyAscii
@return the UNIX timestamp (milliseconds)
@throws NumberFormatException | [
"Extracts",
"the",
"(",
"UNIX",
")",
"timestamp",
"from",
"a",
"tiny",
"ascii",
"id",
"(",
"radix",
"{",
"@link",
"Character#MAX_RADIX",
"}",
")",
"."
] | train | https://github.com/DDTH/ddth-commons/blob/734f0e77321d41eeca78a557be9884df9874e46e/ddth-commons-core/src/main/java/com/github/ddth/commons/utils/IdGenerator.java#L231-L233 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerCommunicationLinksInner.java | ServerCommunicationLinksInner.beginCreateOrUpdate | public ServerCommunicationLinkInner beginCreateOrUpdate(String resourceGroupName, String serverName, String communicationLinkName, String partnerServer) {
"""
Creates a server communication link.
@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 communicationLinkName The name of the server communication link.
@param partnerServer The name of the partner server.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ServerCommunicationLinkInner object if successful.
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, communicationLinkName, partnerServer).toBlocking().single().body();
} | java | public ServerCommunicationLinkInner beginCreateOrUpdate(String resourceGroupName, String serverName, String communicationLinkName, String partnerServer) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, communicationLinkName, partnerServer).toBlocking().single().body();
} | [
"public",
"ServerCommunicationLinkInner",
"beginCreateOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"communicationLinkName",
",",
"String",
"partnerServer",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"communicationLinkName",
",",
"partnerServer",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates a server communication link.
@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 communicationLinkName The name of the server communication link.
@param partnerServer The name of the partner server.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the ServerCommunicationLinkInner object if successful. | [
"Creates",
"a",
"server",
"communication",
"link",
"."
] | 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/ServerCommunicationLinksInner.java#L362-L364 |
sargue/mailgun | src/main/java/net/sargue/mailgun/content/Builder.java | Builder.rowh | public <T> Builder rowh(String label, T data) {
"""
Adds a new row with two columns, the first one being a header cell.
@param <T> the type parameter
@param label the header cell content
@param data the second cell content
@return this builder
"""
return tag("tr").cellHeader(label, false).cell(data).end();
} | java | public <T> Builder rowh(String label, T data) {
return tag("tr").cellHeader(label, false).cell(data).end();
} | [
"public",
"<",
"T",
">",
"Builder",
"rowh",
"(",
"String",
"label",
",",
"T",
"data",
")",
"{",
"return",
"tag",
"(",
"\"tr\"",
")",
".",
"cellHeader",
"(",
"label",
",",
"false",
")",
".",
"cell",
"(",
"data",
")",
".",
"end",
"(",
")",
";",
"}"
] | Adds a new row with two columns, the first one being a header cell.
@param <T> the type parameter
@param label the header cell content
@param data the second cell content
@return this builder | [
"Adds",
"a",
"new",
"row",
"with",
"two",
"columns",
"the",
"first",
"one",
"being",
"a",
"header",
"cell",
"."
] | train | https://github.com/sargue/mailgun/blob/2ffb0a156f3f3666eb1bb2db661451b9377c3d11/src/main/java/net/sargue/mailgun/content/Builder.java#L452-L454 |
alkacon/opencms-core | src/org/opencms/ui/error/CmsErrorUI.java | CmsErrorUI.setErrorAttributes | private static void setErrorAttributes(CmsObject cms, Throwable throwable, HttpServletRequest request) {
"""
Sets the error attributes to the current session.<p>
@param cms the cms context
@param throwable the throwable
@param request the current request
"""
String errorUri = CmsFlexController.getThrowableResourceUri(request);
if (errorUri == null) {
errorUri = cms.getRequestContext().getUri();
}
// try to get the exception root cause
Throwable cause = CmsFlexController.getThrowable(request);
if (cause == null) {
cause = throwable;
}
request.getSession().setAttribute(THROWABLE, cause);
request.getSession().setAttribute(PATH, errorUri);
} | java | private static void setErrorAttributes(CmsObject cms, Throwable throwable, HttpServletRequest request) {
String errorUri = CmsFlexController.getThrowableResourceUri(request);
if (errorUri == null) {
errorUri = cms.getRequestContext().getUri();
}
// try to get the exception root cause
Throwable cause = CmsFlexController.getThrowable(request);
if (cause == null) {
cause = throwable;
}
request.getSession().setAttribute(THROWABLE, cause);
request.getSession().setAttribute(PATH, errorUri);
} | [
"private",
"static",
"void",
"setErrorAttributes",
"(",
"CmsObject",
"cms",
",",
"Throwable",
"throwable",
",",
"HttpServletRequest",
"request",
")",
"{",
"String",
"errorUri",
"=",
"CmsFlexController",
".",
"getThrowableResourceUri",
"(",
"request",
")",
";",
"if",
"(",
"errorUri",
"==",
"null",
")",
"{",
"errorUri",
"=",
"cms",
".",
"getRequestContext",
"(",
")",
".",
"getUri",
"(",
")",
";",
"}",
"// try to get the exception root cause",
"Throwable",
"cause",
"=",
"CmsFlexController",
".",
"getThrowable",
"(",
"request",
")",
";",
"if",
"(",
"cause",
"==",
"null",
")",
"{",
"cause",
"=",
"throwable",
";",
"}",
"request",
".",
"getSession",
"(",
")",
".",
"setAttribute",
"(",
"THROWABLE",
",",
"cause",
")",
";",
"request",
".",
"getSession",
"(",
")",
".",
"setAttribute",
"(",
"PATH",
",",
"errorUri",
")",
";",
"}"
] | Sets the error attributes to the current session.<p>
@param cms the cms context
@param throwable the throwable
@param request the current request | [
"Sets",
"the",
"error",
"attributes",
"to",
"the",
"current",
"session",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/error/CmsErrorUI.java#L131-L146 |
mgormley/pacaya | src/main/java/edu/jhu/pacaya/gm/model/ForwardOnlyFactorsModule.java | ForwardOnlyFactorsModule.getFactorsModule | public static Module<Factors> getFactorsModule(FactorGraph fg, Algebra s) {
"""
Constructs a factors module and runs the forward computation.
"""
ForwardOnlyFactorsModule fm = new ForwardOnlyFactorsModule(null, fg, s);
fm.forward();
return fm;
} | java | public static Module<Factors> getFactorsModule(FactorGraph fg, Algebra s) {
ForwardOnlyFactorsModule fm = new ForwardOnlyFactorsModule(null, fg, s);
fm.forward();
return fm;
} | [
"public",
"static",
"Module",
"<",
"Factors",
">",
"getFactorsModule",
"(",
"FactorGraph",
"fg",
",",
"Algebra",
"s",
")",
"{",
"ForwardOnlyFactorsModule",
"fm",
"=",
"new",
"ForwardOnlyFactorsModule",
"(",
"null",
",",
"fg",
",",
"s",
")",
";",
"fm",
".",
"forward",
"(",
")",
";",
"return",
"fm",
";",
"}"
] | Constructs a factors module and runs the forward computation. | [
"Constructs",
"a",
"factors",
"module",
"and",
"runs",
"the",
"forward",
"computation",
"."
] | train | https://github.com/mgormley/pacaya/blob/786294cbac7cc65dbc32210c10acc32ed0c69233/src/main/java/edu/jhu/pacaya/gm/model/ForwardOnlyFactorsModule.java#L103-L107 |
softlayer/softlayer-java | gen/src/main/java/com/softlayer/api/gen/Meta.java | Meta.fromUrl | public static Meta fromUrl(URL url) {
"""
Reads a JSON object from the given metadata URL and generates a new Meta object containing all types.
@param url The API metadata URL.
@return Meta
"""
InputStream stream = null;
try {
stream = url.openStream();
Gson gson = new GsonBuilder().registerTypeAdapter(PropertyForm.class, new TypeAdapter<PropertyForm>() {
@Override
public void write(JsonWriter out, PropertyForm value) throws IOException {
out.value(value.name().toLowerCase());
}
@Override
public PropertyForm read(JsonReader in) throws IOException {
return PropertyForm.valueOf(in.nextString().toUpperCase());
}
}).create();
Map<String, Type> types = gson.fromJson(
new InputStreamReader(stream),
new TypeToken<Map<String, Type>>(){ }.getType()
);
return new Meta(types);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (stream != null) {
try { stream.close(); } catch (Exception e) { }
}
}
} | java | public static Meta fromUrl(URL url) {
InputStream stream = null;
try {
stream = url.openStream();
Gson gson = new GsonBuilder().registerTypeAdapter(PropertyForm.class, new TypeAdapter<PropertyForm>() {
@Override
public void write(JsonWriter out, PropertyForm value) throws IOException {
out.value(value.name().toLowerCase());
}
@Override
public PropertyForm read(JsonReader in) throws IOException {
return PropertyForm.valueOf(in.nextString().toUpperCase());
}
}).create();
Map<String, Type> types = gson.fromJson(
new InputStreamReader(stream),
new TypeToken<Map<String, Type>>(){ }.getType()
);
return new Meta(types);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (stream != null) {
try { stream.close(); } catch (Exception e) { }
}
}
} | [
"public",
"static",
"Meta",
"fromUrl",
"(",
"URL",
"url",
")",
"{",
"InputStream",
"stream",
"=",
"null",
";",
"try",
"{",
"stream",
"=",
"url",
".",
"openStream",
"(",
")",
";",
"Gson",
"gson",
"=",
"new",
"GsonBuilder",
"(",
")",
".",
"registerTypeAdapter",
"(",
"PropertyForm",
".",
"class",
",",
"new",
"TypeAdapter",
"<",
"PropertyForm",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"write",
"(",
"JsonWriter",
"out",
",",
"PropertyForm",
"value",
")",
"throws",
"IOException",
"{",
"out",
".",
"value",
"(",
"value",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"PropertyForm",
"read",
"(",
"JsonReader",
"in",
")",
"throws",
"IOException",
"{",
"return",
"PropertyForm",
".",
"valueOf",
"(",
"in",
".",
"nextString",
"(",
")",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"}",
")",
".",
"create",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Type",
">",
"types",
"=",
"gson",
".",
"fromJson",
"(",
"new",
"InputStreamReader",
"(",
"stream",
")",
",",
"new",
"TypeToken",
"<",
"Map",
"<",
"String",
",",
"Type",
">",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
")",
";",
"return",
"new",
"Meta",
"(",
"types",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"stream",
"!=",
"null",
")",
"{",
"try",
"{",
"stream",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}",
"}"
] | Reads a JSON object from the given metadata URL and generates a new Meta object containing all types.
@param url The API metadata URL.
@return Meta | [
"Reads",
"a",
"JSON",
"object",
"from",
"the",
"given",
"metadata",
"URL",
"and",
"generates",
"a",
"new",
"Meta",
"object",
"containing",
"all",
"types",
"."
] | train | https://github.com/softlayer/softlayer-java/blob/0bb17f4b520aae0d0878f3dcaad0d9ee96472363/gen/src/main/java/com/softlayer/api/gen/Meta.java#L30-L57 |
b3dgs/lionengine | lionengine-core/src/main/java/com/b3dgs/lionengine/AnimatorModel.java | AnimatorModel.updatePlaying | private void updatePlaying(double extrp) {
"""
Update play mode routine.
@param extrp The extrapolation value.
"""
current += speed * extrp;
// Last frame reached
if (Double.compare(current, last + FRAME) >= 0)
{
// If not reversed, done, else, reverse
current = last + HALF_FRAME;
checkStatePlaying();
}
} | java | private void updatePlaying(double extrp)
{
current += speed * extrp;
// Last frame reached
if (Double.compare(current, last + FRAME) >= 0)
{
// If not reversed, done, else, reverse
current = last + HALF_FRAME;
checkStatePlaying();
}
} | [
"private",
"void",
"updatePlaying",
"(",
"double",
"extrp",
")",
"{",
"current",
"+=",
"speed",
"*",
"extrp",
";",
"// Last frame reached",
"if",
"(",
"Double",
".",
"compare",
"(",
"current",
",",
"last",
"+",
"FRAME",
")",
">=",
"0",
")",
"{",
"// If not reversed, done, else, reverse",
"current",
"=",
"last",
"+",
"HALF_FRAME",
";",
"checkStatePlaying",
"(",
")",
";",
"}",
"}"
] | Update play mode routine.
@param extrp The extrapolation value. | [
"Update",
"play",
"mode",
"routine",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-core/src/main/java/com/b3dgs/lionengine/AnimatorModel.java#L58-L69 |
GeoLatte/geolatte-common | src/main/java/org/geolatte/common/reflection/EntityClassReader.java | EntityClassReader.getPropertyValue | private Object getPropertyValue(Object objectToGet, StringTokenizer propertyPathParts) {
"""
Recursive method to get the value of a property path.
@param objectToGet The object from which the property value is to be retrieved.
@param propertyPathParts A set of property names, with enumeration pointer pointed at the last handled part.
@return The value of the named property in the given object or null if the property can not be found.
"""
String propertyName = propertyPathParts.nextToken();
Object propertyValue = null;
if (accessorMap.containsKey(propertyName)) {
propertyValue = accessorMap.get(propertyName).getValueFrom(objectToGet);
}
if (!propertyPathParts.hasMoreTokens() || propertyValue == null)
return propertyValue;
else {
EntityClassReader currentPathReader = EntityClassReader.getClassReaderFor(propertyValue.getClass());
return currentPathReader.getPropertyValue(propertyValue, propertyPathParts);
}
} | java | private Object getPropertyValue(Object objectToGet, StringTokenizer propertyPathParts) {
String propertyName = propertyPathParts.nextToken();
Object propertyValue = null;
if (accessorMap.containsKey(propertyName)) {
propertyValue = accessorMap.get(propertyName).getValueFrom(objectToGet);
}
if (!propertyPathParts.hasMoreTokens() || propertyValue == null)
return propertyValue;
else {
EntityClassReader currentPathReader = EntityClassReader.getClassReaderFor(propertyValue.getClass());
return currentPathReader.getPropertyValue(propertyValue, propertyPathParts);
}
} | [
"private",
"Object",
"getPropertyValue",
"(",
"Object",
"objectToGet",
",",
"StringTokenizer",
"propertyPathParts",
")",
"{",
"String",
"propertyName",
"=",
"propertyPathParts",
".",
"nextToken",
"(",
")",
";",
"Object",
"propertyValue",
"=",
"null",
";",
"if",
"(",
"accessorMap",
".",
"containsKey",
"(",
"propertyName",
")",
")",
"{",
"propertyValue",
"=",
"accessorMap",
".",
"get",
"(",
"propertyName",
")",
".",
"getValueFrom",
"(",
"objectToGet",
")",
";",
"}",
"if",
"(",
"!",
"propertyPathParts",
".",
"hasMoreTokens",
"(",
")",
"||",
"propertyValue",
"==",
"null",
")",
"return",
"propertyValue",
";",
"else",
"{",
"EntityClassReader",
"currentPathReader",
"=",
"EntityClassReader",
".",
"getClassReaderFor",
"(",
"propertyValue",
".",
"getClass",
"(",
")",
")",
";",
"return",
"currentPathReader",
".",
"getPropertyValue",
"(",
"propertyValue",
",",
"propertyPathParts",
")",
";",
"}",
"}"
] | Recursive method to get the value of a property path.
@param objectToGet The object from which the property value is to be retrieved.
@param propertyPathParts A set of property names, with enumeration pointer pointed at the last handled part.
@return The value of the named property in the given object or null if the property can not be found. | [
"Recursive",
"method",
"to",
"get",
"the",
"value",
"of",
"a",
"property",
"path",
"."
] | train | https://github.com/GeoLatte/geolatte-common/blob/dc7f92b04d8c6cb706e78cb95e746d8f12089d95/src/main/java/org/geolatte/common/reflection/EntityClassReader.java#L343-L359 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java | Util.propertyNameFromMethodName | public static String propertyNameFromMethodName(Configuration configuration, String name) {
"""
A convenience method to get property name from the name of the
getter or setter method.
@param name name of the getter or setter method.
@return the name of the property of the given setter of getter.
"""
String propertyName = null;
if (name.startsWith("get") || name.startsWith("set")) {
propertyName = name.substring(3);
} else if (name.startsWith("is")) {
propertyName = name.substring(2);
}
if ((propertyName == null) || propertyName.isEmpty()){
return "";
}
return propertyName.substring(0, 1).toLowerCase(configuration.getLocale())
+ propertyName.substring(1);
} | java | public static String propertyNameFromMethodName(Configuration configuration, String name) {
String propertyName = null;
if (name.startsWith("get") || name.startsWith("set")) {
propertyName = name.substring(3);
} else if (name.startsWith("is")) {
propertyName = name.substring(2);
}
if ((propertyName == null) || propertyName.isEmpty()){
return "";
}
return propertyName.substring(0, 1).toLowerCase(configuration.getLocale())
+ propertyName.substring(1);
} | [
"public",
"static",
"String",
"propertyNameFromMethodName",
"(",
"Configuration",
"configuration",
",",
"String",
"name",
")",
"{",
"String",
"propertyName",
"=",
"null",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"get\"",
")",
"||",
"name",
".",
"startsWith",
"(",
"\"set\"",
")",
")",
"{",
"propertyName",
"=",
"name",
".",
"substring",
"(",
"3",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"is\"",
")",
")",
"{",
"propertyName",
"=",
"name",
".",
"substring",
"(",
"2",
")",
";",
"}",
"if",
"(",
"(",
"propertyName",
"==",
"null",
")",
"||",
"propertyName",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"propertyName",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toLowerCase",
"(",
"configuration",
".",
"getLocale",
"(",
")",
")",
"+",
"propertyName",
".",
"substring",
"(",
"1",
")",
";",
"}"
] | A convenience method to get property name from the name of the
getter or setter method.
@param name name of the getter or setter method.
@return the name of the property of the given setter of getter. | [
"A",
"convenience",
"method",
"to",
"get",
"property",
"name",
"from",
"the",
"name",
"of",
"the",
"getter",
"or",
"setter",
"method",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java#L728-L740 |
aerogear/aerogear-android-core | library/src/main/java/org/jboss/aerogear/android/core/reflection/Property.java | Property.getValue | public Object getValue(Object instance) {
"""
Get value
@param instance Instance to get value
@return Value
"""
try {
return getMethod.invoke(instance);
} catch (Exception e) {
throw new PropertyNotFoundException(klass, getType(), fieldName);
}
} | java | public Object getValue(Object instance) {
try {
return getMethod.invoke(instance);
} catch (Exception e) {
throw new PropertyNotFoundException(klass, getType(), fieldName);
}
} | [
"public",
"Object",
"getValue",
"(",
"Object",
"instance",
")",
"{",
"try",
"{",
"return",
"getMethod",
".",
"invoke",
"(",
"instance",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"PropertyNotFoundException",
"(",
"klass",
",",
"getType",
"(",
")",
",",
"fieldName",
")",
";",
"}",
"}"
] | Get value
@param instance Instance to get value
@return Value | [
"Get",
"value"
] | train | https://github.com/aerogear/aerogear-android-core/blob/3be24a79dd3d2792804935572bb672ff8714e6aa/library/src/main/java/org/jboss/aerogear/android/core/reflection/Property.java#L124-L131 |
mgormley/optimize | src/main/java/edu/jhu/hlt/optimize/BottouSchedule.java | BottouSchedule.getLearningRate | @Override
public double getLearningRate(int iterCount, int i) {
"""
Gets the learning rate for the current iteration.
@param iterCount The current iteration.
@param i The index of the current model parameter.
"""
// We use the learning rate suggested in Leon Bottou's (2012) SGD Tricks paper.
//
// \gamma_t = \frac{\gamma_0}{(1 + \gamma_0 \lambda t)^p}
//
// For SGD p = 1.0, for ASGD p = 0.75
if (prm.power == 1.0) {
return prm.initialLr / (1 + prm.initialLr * prm.lambda * iterCount);
} else {
return prm.initialLr / Math.pow(1 + prm.initialLr * prm.lambda * iterCount, prm.power);
}
} | java | @Override
public double getLearningRate(int iterCount, int i) {
// We use the learning rate suggested in Leon Bottou's (2012) SGD Tricks paper.
//
// \gamma_t = \frac{\gamma_0}{(1 + \gamma_0 \lambda t)^p}
//
// For SGD p = 1.0, for ASGD p = 0.75
if (prm.power == 1.0) {
return prm.initialLr / (1 + prm.initialLr * prm.lambda * iterCount);
} else {
return prm.initialLr / Math.pow(1 + prm.initialLr * prm.lambda * iterCount, prm.power);
}
} | [
"@",
"Override",
"public",
"double",
"getLearningRate",
"(",
"int",
"iterCount",
",",
"int",
"i",
")",
"{",
"// We use the learning rate suggested in Leon Bottou's (2012) SGD Tricks paper.",
"// ",
"// \\gamma_t = \\frac{\\gamma_0}{(1 + \\gamma_0 \\lambda t)^p}",
"//",
"// For SGD p = 1.0, for ASGD p = 0.75",
"if",
"(",
"prm",
".",
"power",
"==",
"1.0",
")",
"{",
"return",
"prm",
".",
"initialLr",
"/",
"(",
"1",
"+",
"prm",
".",
"initialLr",
"*",
"prm",
".",
"lambda",
"*",
"iterCount",
")",
";",
"}",
"else",
"{",
"return",
"prm",
".",
"initialLr",
"/",
"Math",
".",
"pow",
"(",
"1",
"+",
"prm",
".",
"initialLr",
"*",
"prm",
".",
"lambda",
"*",
"iterCount",
",",
"prm",
".",
"power",
")",
";",
"}",
"}"
] | Gets the learning rate for the current iteration.
@param iterCount The current iteration.
@param i The index of the current model parameter. | [
"Gets",
"the",
"learning",
"rate",
"for",
"the",
"current",
"iteration",
"."
] | train | https://github.com/mgormley/optimize/blob/3d1b93260b99febb8a5ecd9e8543c223e151a8d3/src/main/java/edu/jhu/hlt/optimize/BottouSchedule.java#L50-L62 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPPrefixesInner.java | PublicIPPrefixesInner.beginUpdateTags | public PublicIPPrefixInner beginUpdateTags(String resourceGroupName, String publicIpPrefixName) {
"""
Updates public IP prefix tags.
@param resourceGroupName The name of the resource group.
@param publicIpPrefixName The name of the public IP prefix.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PublicIPPrefixInner object if successful.
"""
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, publicIpPrefixName).toBlocking().single().body();
} | java | public PublicIPPrefixInner beginUpdateTags(String resourceGroupName, String publicIpPrefixName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, publicIpPrefixName).toBlocking().single().body();
} | [
"public",
"PublicIPPrefixInner",
"beginUpdateTags",
"(",
"String",
"resourceGroupName",
",",
"String",
"publicIpPrefixName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"publicIpPrefixName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Updates public IP prefix tags.
@param resourceGroupName The name of the resource group.
@param publicIpPrefixName The name of the public IP prefix.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the PublicIPPrefixInner object if successful. | [
"Updates",
"public",
"IP",
"prefix",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/PublicIPPrefixesInner.java#L754-L756 |
ansell/csvstream | src/main/java/com/github/ansell/csv/stream/CSVStream.java | CSVStream.buildSchema | public static CsvSchema buildSchema(List<String> headers, boolean useHeader) {
"""
Build a {@link CsvSchema} object using the given headers.
@param headers
The list of strings in the header.
@param useHeader
Set to false to avoid writing the header line, which is necessary
if appending to an existing file.
@return A {@link CsvSchema} object including the given header items.
"""
return CsvSchema.builder().addColumns(headers, ColumnType.STRING).setUseHeader(useHeader).build();
} | java | public static CsvSchema buildSchema(List<String> headers, boolean useHeader) {
return CsvSchema.builder().addColumns(headers, ColumnType.STRING).setUseHeader(useHeader).build();
} | [
"public",
"static",
"CsvSchema",
"buildSchema",
"(",
"List",
"<",
"String",
">",
"headers",
",",
"boolean",
"useHeader",
")",
"{",
"return",
"CsvSchema",
".",
"builder",
"(",
")",
".",
"addColumns",
"(",
"headers",
",",
"ColumnType",
".",
"STRING",
")",
".",
"setUseHeader",
"(",
"useHeader",
")",
".",
"build",
"(",
")",
";",
"}"
] | Build a {@link CsvSchema} object using the given headers.
@param headers
The list of strings in the header.
@param useHeader
Set to false to avoid writing the header line, which is necessary
if appending to an existing file.
@return A {@link CsvSchema} object including the given header items. | [
"Build",
"a",
"{",
"@link",
"CsvSchema",
"}",
"object",
"using",
"the",
"given",
"headers",
"."
] | train | https://github.com/ansell/csvstream/blob/9468bfbd6997fbc4237eafc990ba811cd5905dc1/src/main/java/com/github/ansell/csv/stream/CSVStream.java#L563-L565 |
roboconf/roboconf-platform | core/roboconf-core/src/main/java/net/roboconf/core/model/RuntimeModelIo.java | RuntimeModelIo.writeInstances | public static void writeInstances( File targetFile, Collection<Instance> rootInstances ) throws IOException {
"""
Writes all the instances into a file.
@param targetFile the file to save
@param rootInstances the root instances (not null)
@throws IOException if something went wrong
"""
FileDefinition def = new FromInstances().buildFileDefinition( rootInstances, targetFile, false, true );
ParsingModelIo.saveRelationsFile( def, false, "\n" );
} | java | public static void writeInstances( File targetFile, Collection<Instance> rootInstances ) throws IOException {
FileDefinition def = new FromInstances().buildFileDefinition( rootInstances, targetFile, false, true );
ParsingModelIo.saveRelationsFile( def, false, "\n" );
} | [
"public",
"static",
"void",
"writeInstances",
"(",
"File",
"targetFile",
",",
"Collection",
"<",
"Instance",
">",
"rootInstances",
")",
"throws",
"IOException",
"{",
"FileDefinition",
"def",
"=",
"new",
"FromInstances",
"(",
")",
".",
"buildFileDefinition",
"(",
"rootInstances",
",",
"targetFile",
",",
"false",
",",
"true",
")",
";",
"ParsingModelIo",
".",
"saveRelationsFile",
"(",
"def",
",",
"false",
",",
"\"\\n\"",
")",
";",
"}"
] | Writes all the instances into a file.
@param targetFile the file to save
@param rootInstances the root instances (not null)
@throws IOException if something went wrong | [
"Writes",
"all",
"the",
"instances",
"into",
"a",
"file",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/model/RuntimeModelIo.java#L484-L488 |
selendroid/selendroid | selendroid-server/src/main/java/io/selendroid/server/extension/ExtensionLoader.java | ExtensionLoader.runBeforeApplicationCreateBootstrap | public void runBeforeApplicationCreateBootstrap(
Instrumentation instrumentation, String[] bootstrapClasses) {
"""
Run bootstrap all BootstrapHandler#runBeforeApplicationCreate classes provided in order.
"""
if (!isWithExtension) {
SelendroidLogger.error("Cannot run bootstrap. Must load an extension first.");
return;
}
for (String bootstrapClassName : bootstrapClasses) {
try {
SelendroidLogger.info("Running beforeApplicationCreate bootstrap: " + bootstrapClassName);
loadBootstrap(bootstrapClassName).runBeforeApplicationCreate(instrumentation);
SelendroidLogger.info("\"Running beforeApplicationCreate bootstrap: " + bootstrapClassName);
} catch (Exception e) {
throw new SelendroidException("Cannot run bootstrap " + bootstrapClassName, e);
}
}
} | java | public void runBeforeApplicationCreateBootstrap(
Instrumentation instrumentation, String[] bootstrapClasses) {
if (!isWithExtension) {
SelendroidLogger.error("Cannot run bootstrap. Must load an extension first.");
return;
}
for (String bootstrapClassName : bootstrapClasses) {
try {
SelendroidLogger.info("Running beforeApplicationCreate bootstrap: " + bootstrapClassName);
loadBootstrap(bootstrapClassName).runBeforeApplicationCreate(instrumentation);
SelendroidLogger.info("\"Running beforeApplicationCreate bootstrap: " + bootstrapClassName);
} catch (Exception e) {
throw new SelendroidException("Cannot run bootstrap " + bootstrapClassName, e);
}
}
} | [
"public",
"void",
"runBeforeApplicationCreateBootstrap",
"(",
"Instrumentation",
"instrumentation",
",",
"String",
"[",
"]",
"bootstrapClasses",
")",
"{",
"if",
"(",
"!",
"isWithExtension",
")",
"{",
"SelendroidLogger",
".",
"error",
"(",
"\"Cannot run bootstrap. Must load an extension first.\"",
")",
";",
"return",
";",
"}",
"for",
"(",
"String",
"bootstrapClassName",
":",
"bootstrapClasses",
")",
"{",
"try",
"{",
"SelendroidLogger",
".",
"info",
"(",
"\"Running beforeApplicationCreate bootstrap: \"",
"+",
"bootstrapClassName",
")",
";",
"loadBootstrap",
"(",
"bootstrapClassName",
")",
".",
"runBeforeApplicationCreate",
"(",
"instrumentation",
")",
";",
"SelendroidLogger",
".",
"info",
"(",
"\"\\\"Running beforeApplicationCreate bootstrap: \"",
"+",
"bootstrapClassName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SelendroidException",
"(",
"\"Cannot run bootstrap \"",
"+",
"bootstrapClassName",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Run bootstrap all BootstrapHandler#runBeforeApplicationCreate classes provided in order. | [
"Run",
"bootstrap",
"all",
"BootstrapHandler#runBeforeApplicationCreate",
"classes",
"provided",
"in",
"order",
"."
] | train | https://github.com/selendroid/selendroid/blob/a32c1a96c973b80c14a588b1075f084201f7fe94/selendroid-server/src/main/java/io/selendroid/server/extension/ExtensionLoader.java#L59-L75 |
aws/aws-sdk-java | aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/Table.java | Table.waitForDelete | public void waitForDelete() throws InterruptedException {
"""
A convenient blocking call that can be used, typically during table
deletion, to wait for the table to become deleted. This method uses
{@link com.amazonaws.services.dynamodbv2.waiters.AmazonDynamoDBWaiters}
to poll the status of the table every 5 seconds.
"""
Waiter waiter = client.waiters().tableNotExists();
try {
waiter.run(new WaiterParameters<DescribeTableRequest>(new DescribeTableRequest(tableName))
.withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25), new FixedDelayStrategy(5))));
} catch (Exception exception) {
throw new IllegalArgumentException("Table " + tableName + " is not deleted.", exception);
}
} | java | public void waitForDelete() throws InterruptedException {
Waiter waiter = client.waiters().tableNotExists();
try {
waiter.run(new WaiterParameters<DescribeTableRequest>(new DescribeTableRequest(tableName))
.withPollingStrategy(new PollingStrategy(new MaxAttemptsRetryStrategy(25), new FixedDelayStrategy(5))));
} catch (Exception exception) {
throw new IllegalArgumentException("Table " + tableName + " is not deleted.", exception);
}
} | [
"public",
"void",
"waitForDelete",
"(",
")",
"throws",
"InterruptedException",
"{",
"Waiter",
"waiter",
"=",
"client",
".",
"waiters",
"(",
")",
".",
"tableNotExists",
"(",
")",
";",
"try",
"{",
"waiter",
".",
"run",
"(",
"new",
"WaiterParameters",
"<",
"DescribeTableRequest",
">",
"(",
"new",
"DescribeTableRequest",
"(",
"tableName",
")",
")",
".",
"withPollingStrategy",
"(",
"new",
"PollingStrategy",
"(",
"new",
"MaxAttemptsRetryStrategy",
"(",
"25",
")",
",",
"new",
"FixedDelayStrategy",
"(",
"5",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Table \"",
"+",
"tableName",
"+",
"\" is not deleted.\"",
",",
"exception",
")",
";",
"}",
"}"
] | A convenient blocking call that can be used, typically during table
deletion, to wait for the table to become deleted. This method uses
{@link com.amazonaws.services.dynamodbv2.waiters.AmazonDynamoDBWaiters}
to poll the status of the table every 5 seconds. | [
"A",
"convenient",
"blocking",
"call",
"that",
"can",
"be",
"used",
"typically",
"during",
"table",
"deletion",
"to",
"wait",
"for",
"the",
"table",
"to",
"become",
"deleted",
".",
"This",
"method",
"uses",
"{"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-dynamodb/src/main/java/com/amazonaws/services/dynamodbv2/document/Table.java#L499-L507 |
ravendb/ravendb-jvm-client | src/main/java/net/ravendb/client/primitives/EventHelper.java | EventHelper.invoke | public static <T extends EventArgs> void invoke(List<EventHandler<T>> delegates, Object sender, T event) {
"""
Helper used for invoking event on list of delegates
@param <T> event class
@param delegates Event delegates
@param sender Event sender
@param event Event to send
"""
for (EventHandler<T> delegate : delegates) {
delegate.handle(sender, event);
}
} | java | public static <T extends EventArgs> void invoke(List<EventHandler<T>> delegates, Object sender, T event) {
for (EventHandler<T> delegate : delegates) {
delegate.handle(sender, event);
}
} | [
"public",
"static",
"<",
"T",
"extends",
"EventArgs",
">",
"void",
"invoke",
"(",
"List",
"<",
"EventHandler",
"<",
"T",
">",
">",
"delegates",
",",
"Object",
"sender",
",",
"T",
"event",
")",
"{",
"for",
"(",
"EventHandler",
"<",
"T",
">",
"delegate",
":",
"delegates",
")",
"{",
"delegate",
".",
"handle",
"(",
"sender",
",",
"event",
")",
";",
"}",
"}"
] | Helper used for invoking event on list of delegates
@param <T> event class
@param delegates Event delegates
@param sender Event sender
@param event Event to send | [
"Helper",
"used",
"for",
"invoking",
"event",
"on",
"list",
"of",
"delegates"
] | train | https://github.com/ravendb/ravendb-jvm-client/blob/5a45727de507b541d1571e79ddd97c7d88bee787/src/main/java/net/ravendb/client/primitives/EventHelper.java#L16-L20 |
mikereedell/sunrisesunsetlib-java | src/main/java/com/luckycatlabs/sunrisesunset/calculator/SolarEventCalculator.java | SolarEventCalculator.computeSunriseCalendar | public Calendar computeSunriseCalendar(Zenith solarZenith, Calendar date) {
"""
Computes the sunrise time for the given zenith at the given date.
@param solarZenith
<code>Zenith</code> enum corresponding to the type of sunrise to compute.
@param date
<code>Calendar</code> object representing the date to compute the sunrise for.
@return the sunrise time as a calendar or null for no sunrise
"""
return getLocalTimeAsCalendar(computeSolarEventTime(solarZenith, date, true), date);
} | java | public Calendar computeSunriseCalendar(Zenith solarZenith, Calendar date) {
return getLocalTimeAsCalendar(computeSolarEventTime(solarZenith, date, true), date);
} | [
"public",
"Calendar",
"computeSunriseCalendar",
"(",
"Zenith",
"solarZenith",
",",
"Calendar",
"date",
")",
"{",
"return",
"getLocalTimeAsCalendar",
"(",
"computeSolarEventTime",
"(",
"solarZenith",
",",
"date",
",",
"true",
")",
",",
"date",
")",
";",
"}"
] | Computes the sunrise time for the given zenith at the given date.
@param solarZenith
<code>Zenith</code> enum corresponding to the type of sunrise to compute.
@param date
<code>Calendar</code> object representing the date to compute the sunrise for.
@return the sunrise time as a calendar or null for no sunrise | [
"Computes",
"the",
"sunrise",
"time",
"for",
"the",
"given",
"zenith",
"at",
"the",
"given",
"date",
"."
] | train | https://github.com/mikereedell/sunrisesunsetlib-java/blob/6e6de23f1d11429eef58de2541582cbde9b85b92/src/main/java/com/luckycatlabs/sunrisesunset/calculator/SolarEventCalculator.java#L85-L87 |
j-easy/easy-random | easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java | BigDecimalRangeRandomizer.aNewBigDecimalRangeRandomizer | public static BigDecimalRangeRandomizer aNewBigDecimalRangeRandomizer(final Double min, final Double max, final long seed) {
"""
Create a new {@link BigDecimalRangeRandomizer}.
@param min min value
@param max max value
@param seed initial seed
@return a new {@link BigDecimalRangeRandomizer}.
"""
return new BigDecimalRangeRandomizer(min, max, seed);
} | java | public static BigDecimalRangeRandomizer aNewBigDecimalRangeRandomizer(final Double min, final Double max, final long seed) {
return new BigDecimalRangeRandomizer(min, max, seed);
} | [
"public",
"static",
"BigDecimalRangeRandomizer",
"aNewBigDecimalRangeRandomizer",
"(",
"final",
"Double",
"min",
",",
"final",
"Double",
"max",
",",
"final",
"long",
"seed",
")",
"{",
"return",
"new",
"BigDecimalRangeRandomizer",
"(",
"min",
",",
"max",
",",
"seed",
")",
";",
"}"
] | Create a new {@link BigDecimalRangeRandomizer}.
@param min min value
@param max max value
@param seed initial seed
@return a new {@link BigDecimalRangeRandomizer}. | [
"Create",
"a",
"new",
"{",
"@link",
"BigDecimalRangeRandomizer",
"}",
"."
] | train | https://github.com/j-easy/easy-random/blob/816b0d6a74c7288af111e70ae1b0b57d7fe3b59d/easy-random-core/src/main/java/org/jeasy/random/randomizers/range/BigDecimalRangeRandomizer.java#L93-L95 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jaxws.clientcontainer/src/com/ibm/ws/jaxws/metadata/builder/WebServiceRefInfoBuilder.java | WebServiceRefInfoBuilder.buildPartialInfoFromWebServiceClient | private static WebServiceRefPartialInfo buildPartialInfoFromWebServiceClient(Class<?> serviceInterfaceClass) {
"""
This method will build a ServiceRefPartialInfo object from a class with an
@WebServiceClient annotation.
"""
WebServiceClient webServiceClient = serviceInterfaceClass.getAnnotation(WebServiceClient.class);
if (webServiceClient == null) {
return null;
}
String className = serviceInterfaceClass.getName();
String wsdlLocation = webServiceClient.wsdlLocation();
QName serviceQName = null;
String localPart = webServiceClient.name();
if (localPart != null) {
serviceQName = new QName(webServiceClient.targetNamespace(), localPart);
}
String handlerChainDeclaringClassName = null;
javax.jws.HandlerChain handlerChainAnnotation = serviceInterfaceClass.getAnnotation(javax.jws.HandlerChain.class);
if (handlerChainAnnotation != null)
handlerChainDeclaringClassName = serviceInterfaceClass.getName();
WebServiceRefPartialInfo partialInfo = new WebServiceRefPartialInfo(className, wsdlLocation, serviceQName, null, handlerChainDeclaringClassName, handlerChainAnnotation);
return partialInfo;
} | java | private static WebServiceRefPartialInfo buildPartialInfoFromWebServiceClient(Class<?> serviceInterfaceClass) {
WebServiceClient webServiceClient = serviceInterfaceClass.getAnnotation(WebServiceClient.class);
if (webServiceClient == null) {
return null;
}
String className = serviceInterfaceClass.getName();
String wsdlLocation = webServiceClient.wsdlLocation();
QName serviceQName = null;
String localPart = webServiceClient.name();
if (localPart != null) {
serviceQName = new QName(webServiceClient.targetNamespace(), localPart);
}
String handlerChainDeclaringClassName = null;
javax.jws.HandlerChain handlerChainAnnotation = serviceInterfaceClass.getAnnotation(javax.jws.HandlerChain.class);
if (handlerChainAnnotation != null)
handlerChainDeclaringClassName = serviceInterfaceClass.getName();
WebServiceRefPartialInfo partialInfo = new WebServiceRefPartialInfo(className, wsdlLocation, serviceQName, null, handlerChainDeclaringClassName, handlerChainAnnotation);
return partialInfo;
} | [
"private",
"static",
"WebServiceRefPartialInfo",
"buildPartialInfoFromWebServiceClient",
"(",
"Class",
"<",
"?",
">",
"serviceInterfaceClass",
")",
"{",
"WebServiceClient",
"webServiceClient",
"=",
"serviceInterfaceClass",
".",
"getAnnotation",
"(",
"WebServiceClient",
".",
"class",
")",
";",
"if",
"(",
"webServiceClient",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"className",
"=",
"serviceInterfaceClass",
".",
"getName",
"(",
")",
";",
"String",
"wsdlLocation",
"=",
"webServiceClient",
".",
"wsdlLocation",
"(",
")",
";",
"QName",
"serviceQName",
"=",
"null",
";",
"String",
"localPart",
"=",
"webServiceClient",
".",
"name",
"(",
")",
";",
"if",
"(",
"localPart",
"!=",
"null",
")",
"{",
"serviceQName",
"=",
"new",
"QName",
"(",
"webServiceClient",
".",
"targetNamespace",
"(",
")",
",",
"localPart",
")",
";",
"}",
"String",
"handlerChainDeclaringClassName",
"=",
"null",
";",
"javax",
".",
"jws",
".",
"HandlerChain",
"handlerChainAnnotation",
"=",
"serviceInterfaceClass",
".",
"getAnnotation",
"(",
"javax",
".",
"jws",
".",
"HandlerChain",
".",
"class",
")",
";",
"if",
"(",
"handlerChainAnnotation",
"!=",
"null",
")",
"handlerChainDeclaringClassName",
"=",
"serviceInterfaceClass",
".",
"getName",
"(",
")",
";",
"WebServiceRefPartialInfo",
"partialInfo",
"=",
"new",
"WebServiceRefPartialInfo",
"(",
"className",
",",
"wsdlLocation",
",",
"serviceQName",
",",
"null",
",",
"handlerChainDeclaringClassName",
",",
"handlerChainAnnotation",
")",
";",
"return",
"partialInfo",
";",
"}"
] | This method will build a ServiceRefPartialInfo object from a class with an
@WebServiceClient annotation. | [
"This",
"method",
"will",
"build",
"a",
"ServiceRefPartialInfo",
"object",
"from",
"a",
"class",
"with",
"an"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jaxws.clientcontainer/src/com/ibm/ws/jaxws/metadata/builder/WebServiceRefInfoBuilder.java#L238-L258 |
Appendium/objectlabkit | utils/src/main/java/net/objectlab/kit/util/IntegerUtil.java | IntegerUtil.assign | public static Integer assign(final Integer value, final Integer defaultValueIfNull) {
"""
Return the value unless it is null, in which case it returns the default value.
@param value
@param defaultValueIfNull
@return
"""
return value != null ? value : defaultValueIfNull;
} | java | public static Integer assign(final Integer value, final Integer defaultValueIfNull) {
return value != null ? value : defaultValueIfNull;
} | [
"public",
"static",
"Integer",
"assign",
"(",
"final",
"Integer",
"value",
",",
"final",
"Integer",
"defaultValueIfNull",
")",
"{",
"return",
"value",
"!=",
"null",
"?",
"value",
":",
"defaultValueIfNull",
";",
"}"
] | Return the value unless it is null, in which case it returns the default value.
@param value
@param defaultValueIfNull
@return | [
"Return",
"the",
"value",
"unless",
"it",
"is",
"null",
"in",
"which",
"case",
"it",
"returns",
"the",
"default",
"value",
"."
] | train | https://github.com/Appendium/objectlabkit/blob/cd649bce7a32e4e926520e62cb765f3b1d451594/utils/src/main/java/net/objectlab/kit/util/IntegerUtil.java#L116-L118 |
GoogleCloudPlatform/bigdata-interop | gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystemBase.java | GoogleHadoopFileSystemBase.globStatus | @Override
public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException {
"""
Returns an array of FileStatus objects whose path names match pathPattern and is accepted by
the user-supplied path filter. Results are sorted by their path names.
<p>Return null if pathPattern has no glob and the path does not exist. Return an empty array if
pathPattern has a glob and no path matches it.
@param pathPattern A regular expression specifying the path pattern.
@param filter A user-supplied path filter.
@return An array of FileStatus objects.
@throws IOException if an error occurs.
"""
checkOpen();
logger.atFine().log("GHFS.globStatus: %s", pathPattern);
// URI does not handle glob expressions nicely, for the purpose of
// fully-qualifying a path we can URI-encode them.
// Using toString() to avoid Path(URI) constructor.
Path encodedPath = new Path(pathPattern.toUri().toString());
// We convert pathPattern to GCS path and then to Hadoop path to ensure that it ends up in
// the correct format. See note in getHadoopPath for more information.
Path encodedFixedPath = getHadoopPath(getGcsPath(encodedPath));
// Decode URI-encoded path back into a glob path.
Path fixedPath = new Path(URI.create(encodedFixedPath.toString()));
logger.atFine().log("GHFS.globStatus fixedPath: %s => %s", pathPattern, fixedPath);
if (enableConcurrentGlob && couldUseFlatGlob(fixedPath)) {
return concurrentGlobInternal(fixedPath, filter);
}
if (enableFlatGlob && couldUseFlatGlob(fixedPath)) {
return flatGlobInternal(fixedPath, filter);
}
return super.globStatus(fixedPath, filter);
} | java | @Override
public FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws IOException {
checkOpen();
logger.atFine().log("GHFS.globStatus: %s", pathPattern);
// URI does not handle glob expressions nicely, for the purpose of
// fully-qualifying a path we can URI-encode them.
// Using toString() to avoid Path(URI) constructor.
Path encodedPath = new Path(pathPattern.toUri().toString());
// We convert pathPattern to GCS path and then to Hadoop path to ensure that it ends up in
// the correct format. See note in getHadoopPath for more information.
Path encodedFixedPath = getHadoopPath(getGcsPath(encodedPath));
// Decode URI-encoded path back into a glob path.
Path fixedPath = new Path(URI.create(encodedFixedPath.toString()));
logger.atFine().log("GHFS.globStatus fixedPath: %s => %s", pathPattern, fixedPath);
if (enableConcurrentGlob && couldUseFlatGlob(fixedPath)) {
return concurrentGlobInternal(fixedPath, filter);
}
if (enableFlatGlob && couldUseFlatGlob(fixedPath)) {
return flatGlobInternal(fixedPath, filter);
}
return super.globStatus(fixedPath, filter);
} | [
"@",
"Override",
"public",
"FileStatus",
"[",
"]",
"globStatus",
"(",
"Path",
"pathPattern",
",",
"PathFilter",
"filter",
")",
"throws",
"IOException",
"{",
"checkOpen",
"(",
")",
";",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"GHFS.globStatus: %s\"",
",",
"pathPattern",
")",
";",
"// URI does not handle glob expressions nicely, for the purpose of",
"// fully-qualifying a path we can URI-encode them.",
"// Using toString() to avoid Path(URI) constructor.",
"Path",
"encodedPath",
"=",
"new",
"Path",
"(",
"pathPattern",
".",
"toUri",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"// We convert pathPattern to GCS path and then to Hadoop path to ensure that it ends up in",
"// the correct format. See note in getHadoopPath for more information.",
"Path",
"encodedFixedPath",
"=",
"getHadoopPath",
"(",
"getGcsPath",
"(",
"encodedPath",
")",
")",
";",
"// Decode URI-encoded path back into a glob path.",
"Path",
"fixedPath",
"=",
"new",
"Path",
"(",
"URI",
".",
"create",
"(",
"encodedFixedPath",
".",
"toString",
"(",
")",
")",
")",
";",
"logger",
".",
"atFine",
"(",
")",
".",
"log",
"(",
"\"GHFS.globStatus fixedPath: %s => %s\"",
",",
"pathPattern",
",",
"fixedPath",
")",
";",
"if",
"(",
"enableConcurrentGlob",
"&&",
"couldUseFlatGlob",
"(",
"fixedPath",
")",
")",
"{",
"return",
"concurrentGlobInternal",
"(",
"fixedPath",
",",
"filter",
")",
";",
"}",
"if",
"(",
"enableFlatGlob",
"&&",
"couldUseFlatGlob",
"(",
"fixedPath",
")",
")",
"{",
"return",
"flatGlobInternal",
"(",
"fixedPath",
",",
"filter",
")",
";",
"}",
"return",
"super",
".",
"globStatus",
"(",
"fixedPath",
",",
"filter",
")",
";",
"}"
] | Returns an array of FileStatus objects whose path names match pathPattern and is accepted by
the user-supplied path filter. Results are sorted by their path names.
<p>Return null if pathPattern has no glob and the path does not exist. Return an empty array if
pathPattern has a glob and no path matches it.
@param pathPattern A regular expression specifying the path pattern.
@param filter A user-supplied path filter.
@return An array of FileStatus objects.
@throws IOException if an error occurs. | [
"Returns",
"an",
"array",
"of",
"FileStatus",
"objects",
"whose",
"path",
"names",
"match",
"pathPattern",
"and",
"is",
"accepted",
"by",
"the",
"user",
"-",
"supplied",
"path",
"filter",
".",
"Results",
"are",
"sorted",
"by",
"their",
"path",
"names",
"."
] | train | https://github.com/GoogleCloudPlatform/bigdata-interop/blob/918d91c80a63e36046edb28972a5c65d3326a858/gcs/src/main/java/com/google/cloud/hadoop/fs/gcs/GoogleHadoopFileSystemBase.java#L1222-L1247 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/OperationsApi.java | OperationsApi.postCheckImportStatusWithHttpInfo | public ApiResponse<ApiAsyncSuccessResponse> postCheckImportStatusWithHttpInfo() throws ApiException {
"""
Check import status
Get [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects based on the specified filters.
@return ApiResponse<ApiAsyncSuccessResponse>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
com.squareup.okhttp.Call call = postCheckImportStatusValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken<ApiAsyncSuccessResponse>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | java | public ApiResponse<ApiAsyncSuccessResponse> postCheckImportStatusWithHttpInfo() throws ApiException {
com.squareup.okhttp.Call call = postCheckImportStatusValidateBeforeCall(null, null);
Type localVarReturnType = new TypeToken<ApiAsyncSuccessResponse>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | [
"public",
"ApiResponse",
"<",
"ApiAsyncSuccessResponse",
">",
"postCheckImportStatusWithHttpInfo",
"(",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"postCheckImportStatusValidateBeforeCall",
"(",
"null",
",",
"null",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"ApiAsyncSuccessResponse",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"return",
"apiClient",
".",
"execute",
"(",
"call",
",",
"localVarReturnType",
")",
";",
"}"
] | Check import status
Get [CfgPerson](https://docs.genesys.com/Documentation/PSDK/latest/ConfigLayerRef/CfgPerson) objects based on the specified filters.
@return ApiResponse<ApiAsyncSuccessResponse>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Check",
"import",
"status",
"Get",
"[",
"CfgPerson",
"]",
"(",
"https",
":",
"//",
"docs",
".",
"genesys",
".",
"com",
"/",
"Documentation",
"/",
"PSDK",
"/",
"latest",
"/",
"ConfigLayerRef",
"/",
"CfgPerson",
")",
"objects",
"based",
"on",
"the",
"specified",
"filters",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/OperationsApi.java#L797-L801 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/images/ImageGenerator.java | ImageGenerator.drawImage | public BufferedImage drawImage( ReferencedEnvelope ref, int imageWidth, int imageHeight, double buffer ) {
"""
Draw the map on an image.
@param bounds the area of interest.
@param imageWidth the width of the image to produce.
@param imageHeight the height of the image to produce.
@param buffer the buffer to add around the map bounds in map units.
@return the image.
"""
checkMapContent();
if (buffer > 0.0)
ref.expandBy(buffer, buffer);
Rectangle2D refRect = new Rectangle2D.Double(ref.getMinX(), ref.getMinY(), ref.getWidth(), ref.getHeight());
Rectangle2D imageRect = new Rectangle2D.Double(0, 0, imageWidth, imageHeight);
GeometryUtilities.scaleToRatio(imageRect, refRect, false);
ReferencedEnvelope newRef = new ReferencedEnvelope(refRect, ref.getCoordinateReferenceSystem());
Rectangle imageBounds = new Rectangle(0, 0, imageWidth, imageHeight);
BufferedImage dumpImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = dumpImage.createGraphics();
g2d.fillRect(0, 0, imageWidth, imageHeight);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
synchronized (renderer) {
renderer.paint(g2d, imageBounds, newRef);
}
return dumpImage;
} | java | public BufferedImage drawImage( ReferencedEnvelope ref, int imageWidth, int imageHeight, double buffer ) {
checkMapContent();
if (buffer > 0.0)
ref.expandBy(buffer, buffer);
Rectangle2D refRect = new Rectangle2D.Double(ref.getMinX(), ref.getMinY(), ref.getWidth(), ref.getHeight());
Rectangle2D imageRect = new Rectangle2D.Double(0, 0, imageWidth, imageHeight);
GeometryUtilities.scaleToRatio(imageRect, refRect, false);
ReferencedEnvelope newRef = new ReferencedEnvelope(refRect, ref.getCoordinateReferenceSystem());
Rectangle imageBounds = new Rectangle(0, 0, imageWidth, imageHeight);
BufferedImage dumpImage = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = dumpImage.createGraphics();
g2d.fillRect(0, 0, imageWidth, imageHeight);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
synchronized (renderer) {
renderer.paint(g2d, imageBounds, newRef);
}
return dumpImage;
} | [
"public",
"BufferedImage",
"drawImage",
"(",
"ReferencedEnvelope",
"ref",
",",
"int",
"imageWidth",
",",
"int",
"imageHeight",
",",
"double",
"buffer",
")",
"{",
"checkMapContent",
"(",
")",
";",
"if",
"(",
"buffer",
">",
"0.0",
")",
"ref",
".",
"expandBy",
"(",
"buffer",
",",
"buffer",
")",
";",
"Rectangle2D",
"refRect",
"=",
"new",
"Rectangle2D",
".",
"Double",
"(",
"ref",
".",
"getMinX",
"(",
")",
",",
"ref",
".",
"getMinY",
"(",
")",
",",
"ref",
".",
"getWidth",
"(",
")",
",",
"ref",
".",
"getHeight",
"(",
")",
")",
";",
"Rectangle2D",
"imageRect",
"=",
"new",
"Rectangle2D",
".",
"Double",
"(",
"0",
",",
"0",
",",
"imageWidth",
",",
"imageHeight",
")",
";",
"GeometryUtilities",
".",
"scaleToRatio",
"(",
"imageRect",
",",
"refRect",
",",
"false",
")",
";",
"ReferencedEnvelope",
"newRef",
"=",
"new",
"ReferencedEnvelope",
"(",
"refRect",
",",
"ref",
".",
"getCoordinateReferenceSystem",
"(",
")",
")",
";",
"Rectangle",
"imageBounds",
"=",
"new",
"Rectangle",
"(",
"0",
",",
"0",
",",
"imageWidth",
",",
"imageHeight",
")",
";",
"BufferedImage",
"dumpImage",
"=",
"new",
"BufferedImage",
"(",
"imageWidth",
",",
"imageHeight",
",",
"BufferedImage",
".",
"TYPE_INT_RGB",
")",
";",
"Graphics2D",
"g2d",
"=",
"dumpImage",
".",
"createGraphics",
"(",
")",
";",
"g2d",
".",
"fillRect",
"(",
"0",
",",
"0",
",",
"imageWidth",
",",
"imageHeight",
")",
";",
"g2d",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_ANTIALIASING",
",",
"RenderingHints",
".",
"VALUE_ANTIALIAS_ON",
")",
";",
"synchronized",
"(",
"renderer",
")",
"{",
"renderer",
".",
"paint",
"(",
"g2d",
",",
"imageBounds",
",",
"newRef",
")",
";",
"}",
"return",
"dumpImage",
";",
"}"
] | Draw the map on an image.
@param bounds the area of interest.
@param imageWidth the width of the image to produce.
@param imageHeight the height of the image to produce.
@param buffer the buffer to add around the map bounds in map units.
@return the image. | [
"Draw",
"the",
"map",
"on",
"an",
"image",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/images/ImageGenerator.java#L452-L476 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java | HttpChannelConfig.parseLimitNumberHeaders | private void parseLimitNumberHeaders(Map<Object, Object> props) {
"""
Check the input configuration for a maximum limit on the number of
headers allowed per message.
@param props
"""
Object value = props.get(HttpConfigConstants.PROPNAME_LIMIT_NUMHEADERS);
if (null != value) {
try {
this.limitNumHeaders = rangeLimit(convertInteger(value), HttpConfigConstants.MIN_LIMIT_NUMHEADERS, HttpConfigConstants.MAX_LIMIT_NUMHEADERS);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Num hdrs limit is " + getLimitOnNumberOfHeaders());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitNumberHeaders", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid number of headers limit; " + value);
}
}
}
} | java | private void parseLimitNumberHeaders(Map<Object, Object> props) {
Object value = props.get(HttpConfigConstants.PROPNAME_LIMIT_NUMHEADERS);
if (null != value) {
try {
this.limitNumHeaders = rangeLimit(convertInteger(value), HttpConfigConstants.MIN_LIMIT_NUMHEADERS, HttpConfigConstants.MAX_LIMIT_NUMHEADERS);
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Num hdrs limit is " + getLimitOnNumberOfHeaders());
}
} catch (NumberFormatException nfe) {
FFDCFilter.processException(nfe, getClass().getName() + ".parseLimitNumberHeaders", "1");
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Config: Invalid number of headers limit; " + value);
}
}
}
} | [
"private",
"void",
"parseLimitNumberHeaders",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"props",
")",
"{",
"Object",
"value",
"=",
"props",
".",
"get",
"(",
"HttpConfigConstants",
".",
"PROPNAME_LIMIT_NUMHEADERS",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"try",
"{",
"this",
".",
"limitNumHeaders",
"=",
"rangeLimit",
"(",
"convertInteger",
"(",
"value",
")",
",",
"HttpConfigConstants",
".",
"MIN_LIMIT_NUMHEADERS",
",",
"HttpConfigConstants",
".",
"MAX_LIMIT_NUMHEADERS",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Num hdrs limit is \"",
"+",
"getLimitOnNumberOfHeaders",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"FFDCFilter",
".",
"processException",
"(",
"nfe",
",",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".parseLimitNumberHeaders\"",
",",
"\"1\"",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Config: Invalid number of headers limit; \"",
"+",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Check the input configuration for a maximum limit on the number of
headers allowed per message.
@param props | [
"Check",
"the",
"input",
"configuration",
"for",
"a",
"maximum",
"limit",
"on",
"the",
"number",
"of",
"headers",
"allowed",
"per",
"message",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/HttpChannelConfig.java#L835-L850 |
jmxtrans/jmxtrans | jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/naming/KeyUtils.java | KeyUtils.getKeyString | public static String getKeyString(Query query, Result result, List<String> typeNames) {
"""
Gets the key string, without rootPrefix nor Alias
@param query the query
@param result the result
@param typeNames the type names
@return the key string
"""
StringBuilder sb = new StringBuilder();
addMBeanIdentifier(query, result, sb);
addSeparator(sb);
addTypeName(query, result, typeNames, sb);
addKeyString(query, result, sb);
return sb.toString();
} | java | public static String getKeyString(Query query, Result result, List<String> typeNames) {
StringBuilder sb = new StringBuilder();
addMBeanIdentifier(query, result, sb);
addSeparator(sb);
addTypeName(query, result, typeNames, sb);
addKeyString(query, result, sb);
return sb.toString();
} | [
"public",
"static",
"String",
"getKeyString",
"(",
"Query",
"query",
",",
"Result",
"result",
",",
"List",
"<",
"String",
">",
"typeNames",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"addMBeanIdentifier",
"(",
"query",
",",
"result",
",",
"sb",
")",
";",
"addSeparator",
"(",
"sb",
")",
";",
"addTypeName",
"(",
"query",
",",
"result",
",",
"typeNames",
",",
"sb",
")",
";",
"addKeyString",
"(",
"query",
",",
"result",
",",
"sb",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Gets the key string, without rootPrefix nor Alias
@param query the query
@param result the result
@param typeNames the type names
@return the key string | [
"Gets",
"the",
"key",
"string",
"without",
"rootPrefix",
"nor",
"Alias"
] | train | https://github.com/jmxtrans/jmxtrans/blob/496f342de3bcf2c2226626374b7a16edf8f4ba2a/jmxtrans-core/src/main/java/com/googlecode/jmxtrans/model/naming/KeyUtils.java#L66-L73 |
jbundle/jbundle | thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java | ThinTableModel.setSortedByColumn | public void setSortedByColumn(JTableHeader tableHeader, int iViewColumn, boolean bOrder) {
"""
Change the tableheader to display this sort column and order.
"""
if (!(tableHeader.getDefaultRenderer() instanceof SortableHeaderRenderer))
tableHeader.setDefaultRenderer(new SortableHeaderRenderer(tableHeader.getDefaultRenderer())); // Set up header renderer the first time
((SortableHeaderRenderer)tableHeader.getDefaultRenderer()).setSortedByColumn(tableHeader, iViewColumn, bOrder);
} | java | public void setSortedByColumn(JTableHeader tableHeader, int iViewColumn, boolean bOrder)
{
if (!(tableHeader.getDefaultRenderer() instanceof SortableHeaderRenderer))
tableHeader.setDefaultRenderer(new SortableHeaderRenderer(tableHeader.getDefaultRenderer())); // Set up header renderer the first time
((SortableHeaderRenderer)tableHeader.getDefaultRenderer()).setSortedByColumn(tableHeader, iViewColumn, bOrder);
} | [
"public",
"void",
"setSortedByColumn",
"(",
"JTableHeader",
"tableHeader",
",",
"int",
"iViewColumn",
",",
"boolean",
"bOrder",
")",
"{",
"if",
"(",
"!",
"(",
"tableHeader",
".",
"getDefaultRenderer",
"(",
")",
"instanceof",
"SortableHeaderRenderer",
")",
")",
"tableHeader",
".",
"setDefaultRenderer",
"(",
"new",
"SortableHeaderRenderer",
"(",
"tableHeader",
".",
"getDefaultRenderer",
"(",
")",
")",
")",
";",
"// Set up header renderer the first time",
"(",
"(",
"SortableHeaderRenderer",
")",
"tableHeader",
".",
"getDefaultRenderer",
"(",
")",
")",
".",
"setSortedByColumn",
"(",
"tableHeader",
",",
"iViewColumn",
",",
"bOrder",
")",
";",
"}"
] | Change the tableheader to display this sort column and order. | [
"Change",
"the",
"tableheader",
"to",
"display",
"this",
"sort",
"column",
"and",
"order",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java#L734-L739 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/utils/JacksonJsonEnumHelper.java | JacksonJsonEnumHelper.addEnum | public void addEnum(E e, String name) {
"""
Add an enum that has a specialized name that does not fit the standard naming conventions.
@param e the enum to add
@param name the name for the enum
"""
valuesMap.put(name, e);
namesMap.put(e, name);
} | java | public void addEnum(E e, String name) {
valuesMap.put(name, e);
namesMap.put(e, name);
} | [
"public",
"void",
"addEnum",
"(",
"E",
"e",
",",
"String",
"name",
")",
"{",
"valuesMap",
".",
"put",
"(",
"name",
",",
"e",
")",
";",
"namesMap",
".",
"put",
"(",
"e",
",",
"name",
")",
";",
"}"
] | Add an enum that has a specialized name that does not fit the standard naming conventions.
@param e the enum to add
@param name the name for the enum | [
"Add",
"an",
"enum",
"that",
"has",
"a",
"specialized",
"name",
"that",
"does",
"not",
"fit",
"the",
"standard",
"naming",
"conventions",
"."
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/utils/JacksonJsonEnumHelper.java#L71-L74 |
ggrandes/packer | src/main/java/org/javastack/packer/Packer.java | Packer.getHexStringUpper | public String getHexStringUpper() {
"""
Get Hex String in upper case ("0123456789ABCDEF")
@return
@see #putHexString(String)
@see #getHexStringLower()
"""
int len = getVInt();
byte[] hex = new byte[len];
System.arraycopy(buf, bufPosition, hex, 0, hex.length);
bufPosition += hex.length;
return toHex(hex, true);
} | java | public String getHexStringUpper() {
int len = getVInt();
byte[] hex = new byte[len];
System.arraycopy(buf, bufPosition, hex, 0, hex.length);
bufPosition += hex.length;
return toHex(hex, true);
} | [
"public",
"String",
"getHexStringUpper",
"(",
")",
"{",
"int",
"len",
"=",
"getVInt",
"(",
")",
";",
"byte",
"[",
"]",
"hex",
"=",
"new",
"byte",
"[",
"len",
"]",
";",
"System",
".",
"arraycopy",
"(",
"buf",
",",
"bufPosition",
",",
"hex",
",",
"0",
",",
"hex",
".",
"length",
")",
";",
"bufPosition",
"+=",
"hex",
".",
"length",
";",
"return",
"toHex",
"(",
"hex",
",",
"true",
")",
";",
"}"
] | Get Hex String in upper case ("0123456789ABCDEF")
@return
@see #putHexString(String)
@see #getHexStringLower() | [
"Get",
"Hex",
"String",
"in",
"upper",
"case",
"(",
"0123456789ABCDEF",
")"
] | train | https://github.com/ggrandes/packer/blob/0b37b286a3d0555050eb2e65419dd74f8d8d3e78/src/main/java/org/javastack/packer/Packer.java#L1122-L1128 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.