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
|
---|---|---|---|---|---|---|---|---|---|---|
weld/core | impl/src/main/java/org/jboss/weld/util/Types.java | Types.getCanonicalType | public static Type getCanonicalType(Class<?> clazz) {
"""
Returns a canonical type for a given class.
If the class is a raw type of a parameterized class, the matching {@link ParameterizedType} (with unresolved type
variables) is resolved.
If the class is an array then the component type of the array is canonicalized
Otherwise, the class is returned.
@return
"""
if (clazz.isArray()) {
Class<?> componentType = clazz.getComponentType();
Type resolvedComponentType = getCanonicalType(componentType);
if (componentType != resolvedComponentType) {
// identity check intentional
// a different identity means that we actually replaced the component Class with a ParameterizedType
return new GenericArrayTypeImpl(resolvedComponentType);
}
}
if (clazz.getTypeParameters().length > 0) {
Type[] actualTypeParameters = clazz.getTypeParameters();
return new ParameterizedTypeImpl(clazz, actualTypeParameters, clazz.getDeclaringClass());
}
return clazz;
} | java | public static Type getCanonicalType(Class<?> clazz) {
if (clazz.isArray()) {
Class<?> componentType = clazz.getComponentType();
Type resolvedComponentType = getCanonicalType(componentType);
if (componentType != resolvedComponentType) {
// identity check intentional
// a different identity means that we actually replaced the component Class with a ParameterizedType
return new GenericArrayTypeImpl(resolvedComponentType);
}
}
if (clazz.getTypeParameters().length > 0) {
Type[] actualTypeParameters = clazz.getTypeParameters();
return new ParameterizedTypeImpl(clazz, actualTypeParameters, clazz.getDeclaringClass());
}
return clazz;
} | [
"public",
"static",
"Type",
"getCanonicalType",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
".",
"isArray",
"(",
")",
")",
"{",
"Class",
"<",
"?",
">",
"componentType",
"=",
"clazz",
".",
"getComponentType",
"(",
")",
";",
"Type",
"resolvedComponentType",
"=",
"getCanonicalType",
"(",
"componentType",
")",
";",
"if",
"(",
"componentType",
"!=",
"resolvedComponentType",
")",
"{",
"// identity check intentional",
"// a different identity means that we actually replaced the component Class with a ParameterizedType",
"return",
"new",
"GenericArrayTypeImpl",
"(",
"resolvedComponentType",
")",
";",
"}",
"}",
"if",
"(",
"clazz",
".",
"getTypeParameters",
"(",
")",
".",
"length",
">",
"0",
")",
"{",
"Type",
"[",
"]",
"actualTypeParameters",
"=",
"clazz",
".",
"getTypeParameters",
"(",
")",
";",
"return",
"new",
"ParameterizedTypeImpl",
"(",
"clazz",
",",
"actualTypeParameters",
",",
"clazz",
".",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"return",
"clazz",
";",
"}"
] | Returns a canonical type for a given class.
If the class is a raw type of a parameterized class, the matching {@link ParameterizedType} (with unresolved type
variables) is resolved.
If the class is an array then the component type of the array is canonicalized
Otherwise, the class is returned.
@return | [
"Returns",
"a",
"canonical",
"type",
"for",
"a",
"given",
"class",
"."
] | train | https://github.com/weld/core/blob/567a2eaf95b168597d23a56be89bf05a7834b2aa/impl/src/main/java/org/jboss/weld/util/Types.java#L127-L142 |
pac4j/pac4j | pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java | CommonHelper.asURI | public static URI asURI(final String s) {
"""
Convert a string into an URI.
@param s the string
@return the URI
"""
try {
return new URI(s);
} catch (final URISyntaxException e) {
throw new TechnicalException("Cannot make an URI from: " + s, e);
}
} | java | public static URI asURI(final String s) {
try {
return new URI(s);
} catch (final URISyntaxException e) {
throw new TechnicalException("Cannot make an URI from: " + s, e);
}
} | [
"public",
"static",
"URI",
"asURI",
"(",
"final",
"String",
"s",
")",
"{",
"try",
"{",
"return",
"new",
"URI",
"(",
"s",
")",
";",
"}",
"catch",
"(",
"final",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"TechnicalException",
"(",
"\"Cannot make an URI from: \"",
"+",
"s",
",",
"e",
")",
";",
"}",
"}"
] | Convert a string into an URI.
@param s the string
@return the URI | [
"Convert",
"a",
"string",
"into",
"an",
"URI",
"."
] | train | https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java#L260-L266 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java | CciConnCodeGen.writeMetaData | private void writeMetaData(Definition def, Writer out, int indent) throws IOException {
"""
Output MetaData method
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException
"""
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent,
" * Gets the information on the underlying EIS instance represented through an active connection.\n");
writeWithIndent(out, indent, " *\n");
writeWithIndent(out, indent,
" * @return ConnectionMetaData instance representing information about the EIS instance\n");
writeWithIndent(out, indent,
" * @throws ResourceException Failed to get information about the connected EIS instance. \n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "@Override\n");
writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | java | private void writeMetaData(Definition def, Writer out, int indent) throws IOException
{
writeWithIndent(out, indent, "/**\n");
writeWithIndent(out, indent,
" * Gets the information on the underlying EIS instance represented through an active connection.\n");
writeWithIndent(out, indent, " *\n");
writeWithIndent(out, indent,
" * @return ConnectionMetaData instance representing information about the EIS instance\n");
writeWithIndent(out, indent,
" * @throws ResourceException Failed to get information about the connected EIS instance. \n");
writeWithIndent(out, indent, " */\n");
writeWithIndent(out, indent, "@Override\n");
writeWithIndent(out, indent, "public ConnectionMetaData getMetaData() throws ResourceException");
writeLeftCurlyBracket(out, indent);
writeWithIndent(out, indent + 1, "return new " + def.getMcfDefs().get(getNumOfMcf()).getConnMetaClass() + "();");
writeRightCurlyBracket(out, indent);
writeEol(out);
} | [
"private",
"void",
"writeMetaData",
"(",
"Definition",
"def",
",",
"Writer",
"out",
",",
"int",
"indent",
")",
"throws",
"IOException",
"{",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"/**\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * Gets the information on the underlying EIS instance represented through an active connection.\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" *\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @return ConnectionMetaData instance representing information about the EIS instance\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" * @throws ResourceException Failed to get information about the connected EIS instance. \\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\" */\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"@Override\\n\"",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
",",
"\"public ConnectionMetaData getMetaData() throws ResourceException\"",
")",
";",
"writeLeftCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeWithIndent",
"(",
"out",
",",
"indent",
"+",
"1",
",",
"\"return new \"",
"+",
"def",
".",
"getMcfDefs",
"(",
")",
".",
"get",
"(",
"getNumOfMcf",
"(",
")",
")",
".",
"getConnMetaClass",
"(",
")",
"+",
"\"();\"",
")",
";",
"writeRightCurlyBracket",
"(",
"out",
",",
"indent",
")",
";",
"writeEol",
"(",
"out",
")",
";",
"}"
] | Output MetaData method
@param def definition
@param out Writer
@param indent space number
@throws IOException ioException | [
"Output",
"MetaData",
"method"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/code/CciConnCodeGen.java#L202-L221 |
structr/structr | structr-core/src/main/java/org/structr/schema/parser/DatePropertyParser.java | DatePropertyParser.parseISO8601DateString | public static Date parseISO8601DateString(String source) {
"""
Try to parse source string as a ISO8601 date.
@param source
@return null if unable to parse
"""
final String[] supportedFormats = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ssXXX", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ" };
// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000
if (StringUtils.contains(source, "Z")) {
source = StringUtils.replace(source, "Z", "+0000");
}
Date parsedDate = null;
for (final String format : supportedFormats) {
try {
parsedDate = new SimpleDateFormat(format).parse(source);
} catch (ParseException pe) {
}
if (parsedDate != null) {
return parsedDate;
}
}
return null;
} | java | public static Date parseISO8601DateString(String source) {
final String[] supportedFormats = new String[] { "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ssXXX", "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.SSSZ" };
// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000
if (StringUtils.contains(source, "Z")) {
source = StringUtils.replace(source, "Z", "+0000");
}
Date parsedDate = null;
for (final String format : supportedFormats) {
try {
parsedDate = new SimpleDateFormat(format).parse(source);
} catch (ParseException pe) {
}
if (parsedDate != null) {
return parsedDate;
}
}
return null;
} | [
"public",
"static",
"Date",
"parseISO8601DateString",
"(",
"String",
"source",
")",
"{",
"final",
"String",
"[",
"]",
"supportedFormats",
"=",
"new",
"String",
"[",
"]",
"{",
"\"yyyy-MM-dd'T'HH:mm:ss.SSSXXX\"",
",",
"\"yyyy-MM-dd'T'HH:mm:ssXXX\"",
",",
"\"yyyy-MM-dd'T'HH:mm:ssZ\"",
",",
"\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\"",
"}",
";",
"// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000",
"if",
"(",
"StringUtils",
".",
"contains",
"(",
"source",
",",
"\"Z\"",
")",
")",
"{",
"source",
"=",
"StringUtils",
".",
"replace",
"(",
"source",
",",
"\"Z\"",
",",
"\"+0000\"",
")",
";",
"}",
"Date",
"parsedDate",
"=",
"null",
";",
"for",
"(",
"final",
"String",
"format",
":",
"supportedFormats",
")",
"{",
"try",
"{",
"parsedDate",
"=",
"new",
"SimpleDateFormat",
"(",
"format",
")",
".",
"parse",
"(",
"source",
")",
";",
"}",
"catch",
"(",
"ParseException",
"pe",
")",
"{",
"}",
"if",
"(",
"parsedDate",
"!=",
"null",
")",
"{",
"return",
"parsedDate",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Try to parse source string as a ISO8601 date.
@param source
@return null if unable to parse | [
"Try",
"to",
"parse",
"source",
"string",
"as",
"a",
"ISO8601",
"date",
"."
] | train | https://github.com/structr/structr/blob/c111a1d0c0201c7fea5574ed69aa5a5053185a97/structr-core/src/main/java/org/structr/schema/parser/DatePropertyParser.java#L123-L151 |
languagetool-org/languagetool | languagetool-core/src/main/java/org/languagetool/Languages.java | Languages.getLanguageForShortCode | public static Language getLanguageForShortCode(String langCode, List<String> noopLanguageCodes) {
"""
Get the Language object for the given language code.
@param langCode e.g. <code>en</code> or <code>en-US</code>
@param noopLanguageCodes list of languages that can be detected but that will not actually find any errors
(can be used so non-supported languages are not detected as some other language)
@throws IllegalArgumentException if the language is not supported or if the language code is invalid
@since 4.4
"""
Language language = getLanguageForShortCodeOrNull(langCode);
if (language == null) {
if (noopLanguageCodes.contains(langCode)) {
return NOOP_LANGUAGE;
} else {
List<String> codes = new ArrayList<>();
for (Language realLanguage : getStaticAndDynamicLanguages()) {
codes.add(realLanguage.getShortCodeWithCountryAndVariant());
}
Collections.sort(codes);
throw new IllegalArgumentException("'" + langCode + "' is not a language code known to LanguageTool." +
" Supported language codes are: " + String.join(", ", codes) + ". The list of languages is read from " + PROPERTIES_PATH +
" in the Java classpath. See http://wiki.languagetool.org/java-api for details.");
}
}
return language;
} | java | public static Language getLanguageForShortCode(String langCode, List<String> noopLanguageCodes) {
Language language = getLanguageForShortCodeOrNull(langCode);
if (language == null) {
if (noopLanguageCodes.contains(langCode)) {
return NOOP_LANGUAGE;
} else {
List<String> codes = new ArrayList<>();
for (Language realLanguage : getStaticAndDynamicLanguages()) {
codes.add(realLanguage.getShortCodeWithCountryAndVariant());
}
Collections.sort(codes);
throw new IllegalArgumentException("'" + langCode + "' is not a language code known to LanguageTool." +
" Supported language codes are: " + String.join(", ", codes) + ". The list of languages is read from " + PROPERTIES_PATH +
" in the Java classpath. See http://wiki.languagetool.org/java-api for details.");
}
}
return language;
} | [
"public",
"static",
"Language",
"getLanguageForShortCode",
"(",
"String",
"langCode",
",",
"List",
"<",
"String",
">",
"noopLanguageCodes",
")",
"{",
"Language",
"language",
"=",
"getLanguageForShortCodeOrNull",
"(",
"langCode",
")",
";",
"if",
"(",
"language",
"==",
"null",
")",
"{",
"if",
"(",
"noopLanguageCodes",
".",
"contains",
"(",
"langCode",
")",
")",
"{",
"return",
"NOOP_LANGUAGE",
";",
"}",
"else",
"{",
"List",
"<",
"String",
">",
"codes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Language",
"realLanguage",
":",
"getStaticAndDynamicLanguages",
"(",
")",
")",
"{",
"codes",
".",
"add",
"(",
"realLanguage",
".",
"getShortCodeWithCountryAndVariant",
"(",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"codes",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'\"",
"+",
"langCode",
"+",
"\"' is not a language code known to LanguageTool.\"",
"+",
"\" Supported language codes are: \"",
"+",
"String",
".",
"join",
"(",
"\", \"",
",",
"codes",
")",
"+",
"\". The list of languages is read from \"",
"+",
"PROPERTIES_PATH",
"+",
"\" in the Java classpath. See http://wiki.languagetool.org/java-api for details.\"",
")",
";",
"}",
"}",
"return",
"language",
";",
"}"
] | Get the Language object for the given language code.
@param langCode e.g. <code>en</code> or <code>en-US</code>
@param noopLanguageCodes list of languages that can be detected but that will not actually find any errors
(can be used so non-supported languages are not detected as some other language)
@throws IllegalArgumentException if the language is not supported or if the language code is invalid
@since 4.4 | [
"Get",
"the",
"Language",
"object",
"for",
"the",
"given",
"language",
"code",
"."
] | train | https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/Languages.java#L225-L242 |
sahasbhop/formatted-log | formatted-log/src/main/java/com/github/sahasbhop/flog/FLog.java | FLog.setEnableFileLog | public static void setEnableFileLog(boolean enable, String path, String fileName) {
"""
Enable writing debugging log to a target file
@param enable enabling a file log
@param path directory path to create and save a log file
@param fileName target log file name
"""
sEnableFileLog = enable;
if (enable && path != null && fileName != null) {
sLogFilePath = path.trim();
sLogFileName = fileName.trim();
if (!sLogFilePath.endsWith("/")) {
sLogFilePath = sLogFilePath + "/";
}
}
} | java | public static void setEnableFileLog(boolean enable, String path, String fileName) {
sEnableFileLog = enable;
if (enable && path != null && fileName != null) {
sLogFilePath = path.trim();
sLogFileName = fileName.trim();
if (!sLogFilePath.endsWith("/")) {
sLogFilePath = sLogFilePath + "/";
}
}
} | [
"public",
"static",
"void",
"setEnableFileLog",
"(",
"boolean",
"enable",
",",
"String",
"path",
",",
"String",
"fileName",
")",
"{",
"sEnableFileLog",
"=",
"enable",
";",
"if",
"(",
"enable",
"&&",
"path",
"!=",
"null",
"&&",
"fileName",
"!=",
"null",
")",
"{",
"sLogFilePath",
"=",
"path",
".",
"trim",
"(",
")",
";",
"sLogFileName",
"=",
"fileName",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"sLogFilePath",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"sLogFilePath",
"=",
"sLogFilePath",
"+",
"\"/\"",
";",
"}",
"}",
"}"
] | Enable writing debugging log to a target file
@param enable enabling a file log
@param path directory path to create and save a log file
@param fileName target log file name | [
"Enable",
"writing",
"debugging",
"log",
"to",
"a",
"target",
"file"
] | train | https://github.com/sahasbhop/formatted-log/blob/0a3952df6b68fbfa0bbb2c0ea0a8bf9ea26ea6e3/formatted-log/src/main/java/com/github/sahasbhop/flog/FLog.java#L75-L86 |
BioPAX/Paxtools | sbgn-converter/src/main/java/org/biopax/paxtools/io/sbgn/L3ToSBGNPDConverter.java | L3ToSBGNPDConverter.createProcessAndConnections | private void createProcessAndConnections(TemplateReaction tr) {
"""
/*
Creates a representation for TemplateReaction.
@param tr template reaction
"""
// create the process for the reaction
Glyph process = factory.createGlyph();
process.setClazz(GlyphClazz.PROCESS.getClazz());
process.setId(convertID(tr.getUri()));
glyphMap.put(process.getId(), process);
final Set<PhysicalEntity> products = tr.getProduct();
final Set<PhysicalEntity> participants = new HashSet<PhysicalEntity>( //new modifiable set
new ClassFilterSet<Entity,PhysicalEntity>(tr.getParticipant(), PhysicalEntity.class));
// link products, if any
// ('participant' property is there defined sometimes instead of or in addition to 'product' or 'template')
for (PhysicalEntity pe : products) {
Glyph g = getGlyphToLink(pe, process.getId());
createArc(process, g, ArcClazz.PRODUCTION.getClazz(), null);
participants.remove(pe);
}
// link template, if present
PhysicalEntity template = tr.getTemplate();
if(template != null) {
Glyph g = getGlyphToLink(template, process.getId());
createArc(g, process, ArcClazz.CONSUMPTION.getClazz(), null);
participants.remove(template);
} else if(participants.isEmpty()) {
//when no template is defined and cannot be inferred, create a source-and-sink as the input
Glyph sas = factory.createGlyph();
sas.setClazz(GlyphClazz.SOURCE_AND_SINK.getClazz());
sas.setId("unknown-template_" + ModelUtils.md5hex(process.getId()));
glyphMap.put(sas.getId(), sas);
createArc(sas, process, ArcClazz.CONSUMPTION.getClazz(), null);
}
//infer input or output type arc for the rest of participants
for (PhysicalEntity pe : participants) {
Glyph g = getGlyphToLink(pe, process.getId());
if(template==null)
createArc(g, process, ArcClazz.CONSUMPTION.getClazz(), null);
else
createArc(process, g, ArcClazz.PRODUCTION.getClazz(), null);
}
// Associate controllers
processControllers(tr.getControlledOf(), process);
// Record mapping
sbgn2BPMap.put(process.getId(), new HashSet<String>(Collections.singleton(tr.getUri())));
} | java | private void createProcessAndConnections(TemplateReaction tr) {
// create the process for the reaction
Glyph process = factory.createGlyph();
process.setClazz(GlyphClazz.PROCESS.getClazz());
process.setId(convertID(tr.getUri()));
glyphMap.put(process.getId(), process);
final Set<PhysicalEntity> products = tr.getProduct();
final Set<PhysicalEntity> participants = new HashSet<PhysicalEntity>( //new modifiable set
new ClassFilterSet<Entity,PhysicalEntity>(tr.getParticipant(), PhysicalEntity.class));
// link products, if any
// ('participant' property is there defined sometimes instead of or in addition to 'product' or 'template')
for (PhysicalEntity pe : products) {
Glyph g = getGlyphToLink(pe, process.getId());
createArc(process, g, ArcClazz.PRODUCTION.getClazz(), null);
participants.remove(pe);
}
// link template, if present
PhysicalEntity template = tr.getTemplate();
if(template != null) {
Glyph g = getGlyphToLink(template, process.getId());
createArc(g, process, ArcClazz.CONSUMPTION.getClazz(), null);
participants.remove(template);
} else if(participants.isEmpty()) {
//when no template is defined and cannot be inferred, create a source-and-sink as the input
Glyph sas = factory.createGlyph();
sas.setClazz(GlyphClazz.SOURCE_AND_SINK.getClazz());
sas.setId("unknown-template_" + ModelUtils.md5hex(process.getId()));
glyphMap.put(sas.getId(), sas);
createArc(sas, process, ArcClazz.CONSUMPTION.getClazz(), null);
}
//infer input or output type arc for the rest of participants
for (PhysicalEntity pe : participants) {
Glyph g = getGlyphToLink(pe, process.getId());
if(template==null)
createArc(g, process, ArcClazz.CONSUMPTION.getClazz(), null);
else
createArc(process, g, ArcClazz.PRODUCTION.getClazz(), null);
}
// Associate controllers
processControllers(tr.getControlledOf(), process);
// Record mapping
sbgn2BPMap.put(process.getId(), new HashSet<String>(Collections.singleton(tr.getUri())));
} | [
"private",
"void",
"createProcessAndConnections",
"(",
"TemplateReaction",
"tr",
")",
"{",
"// create the process for the reaction",
"Glyph",
"process",
"=",
"factory",
".",
"createGlyph",
"(",
")",
";",
"process",
".",
"setClazz",
"(",
"GlyphClazz",
".",
"PROCESS",
".",
"getClazz",
"(",
")",
")",
";",
"process",
".",
"setId",
"(",
"convertID",
"(",
"tr",
".",
"getUri",
"(",
")",
")",
")",
";",
"glyphMap",
".",
"put",
"(",
"process",
".",
"getId",
"(",
")",
",",
"process",
")",
";",
"final",
"Set",
"<",
"PhysicalEntity",
">",
"products",
"=",
"tr",
".",
"getProduct",
"(",
")",
";",
"final",
"Set",
"<",
"PhysicalEntity",
">",
"participants",
"=",
"new",
"HashSet",
"<",
"PhysicalEntity",
">",
"(",
"//new modifiable set",
"new",
"ClassFilterSet",
"<",
"Entity",
",",
"PhysicalEntity",
">",
"(",
"tr",
".",
"getParticipant",
"(",
")",
",",
"PhysicalEntity",
".",
"class",
")",
")",
";",
"// link products, if any",
"// ('participant' property is there defined sometimes instead of or in addition to 'product' or 'template')",
"for",
"(",
"PhysicalEntity",
"pe",
":",
"products",
")",
"{",
"Glyph",
"g",
"=",
"getGlyphToLink",
"(",
"pe",
",",
"process",
".",
"getId",
"(",
")",
")",
";",
"createArc",
"(",
"process",
",",
"g",
",",
"ArcClazz",
".",
"PRODUCTION",
".",
"getClazz",
"(",
")",
",",
"null",
")",
";",
"participants",
".",
"remove",
"(",
"pe",
")",
";",
"}",
"// link template, if present",
"PhysicalEntity",
"template",
"=",
"tr",
".",
"getTemplate",
"(",
")",
";",
"if",
"(",
"template",
"!=",
"null",
")",
"{",
"Glyph",
"g",
"=",
"getGlyphToLink",
"(",
"template",
",",
"process",
".",
"getId",
"(",
")",
")",
";",
"createArc",
"(",
"g",
",",
"process",
",",
"ArcClazz",
".",
"CONSUMPTION",
".",
"getClazz",
"(",
")",
",",
"null",
")",
";",
"participants",
".",
"remove",
"(",
"template",
")",
";",
"}",
"else",
"if",
"(",
"participants",
".",
"isEmpty",
"(",
")",
")",
"{",
"//when no template is defined and cannot be inferred, create a source-and-sink as the input",
"Glyph",
"sas",
"=",
"factory",
".",
"createGlyph",
"(",
")",
";",
"sas",
".",
"setClazz",
"(",
"GlyphClazz",
".",
"SOURCE_AND_SINK",
".",
"getClazz",
"(",
")",
")",
";",
"sas",
".",
"setId",
"(",
"\"unknown-template_\"",
"+",
"ModelUtils",
".",
"md5hex",
"(",
"process",
".",
"getId",
"(",
")",
")",
")",
";",
"glyphMap",
".",
"put",
"(",
"sas",
".",
"getId",
"(",
")",
",",
"sas",
")",
";",
"createArc",
"(",
"sas",
",",
"process",
",",
"ArcClazz",
".",
"CONSUMPTION",
".",
"getClazz",
"(",
")",
",",
"null",
")",
";",
"}",
"//infer input or output type arc for the rest of participants",
"for",
"(",
"PhysicalEntity",
"pe",
":",
"participants",
")",
"{",
"Glyph",
"g",
"=",
"getGlyphToLink",
"(",
"pe",
",",
"process",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"template",
"==",
"null",
")",
"createArc",
"(",
"g",
",",
"process",
",",
"ArcClazz",
".",
"CONSUMPTION",
".",
"getClazz",
"(",
")",
",",
"null",
")",
";",
"else",
"createArc",
"(",
"process",
",",
"g",
",",
"ArcClazz",
".",
"PRODUCTION",
".",
"getClazz",
"(",
")",
",",
"null",
")",
";",
"}",
"// Associate controllers",
"processControllers",
"(",
"tr",
".",
"getControlledOf",
"(",
")",
",",
"process",
")",
";",
"// Record mapping",
"sbgn2BPMap",
".",
"put",
"(",
"process",
".",
"getId",
"(",
")",
",",
"new",
"HashSet",
"<",
"String",
">",
"(",
"Collections",
".",
"singleton",
"(",
"tr",
".",
"getUri",
"(",
")",
")",
")",
")",
";",
"}"
] | /*
Creates a representation for TemplateReaction.
@param tr template reaction | [
"/",
"*",
"Creates",
"a",
"representation",
"for",
"TemplateReaction",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/sbgn-converter/src/main/java/org/biopax/paxtools/io/sbgn/L3ToSBGNPDConverter.java#L986-L1032 |
b3dgs/lionengine | lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/pathfinding/PathfindableModel.java | PathfindableModel.avoidObstacle | private void avoidObstacle(int nextStep, int max) {
"""
Update to avoid obstacle because next step is not free.
@param nextStep The next step.
@param max The maximum steps.
"""
if (nextStep >= max - 1)
{
pathStoppedRequested = true;
}
final Collection<Integer> cid = mapPath.getObjectsId(path.getX(nextStep), path.getY(nextStep));
if (sharedPathIds.containsAll(cid))
{
setDestination(destX, destY);
}
else
{
if (!ignoredIds.containsAll(cid))
{
setDestination(destX, destY);
}
}
} | java | private void avoidObstacle(int nextStep, int max)
{
if (nextStep >= max - 1)
{
pathStoppedRequested = true;
}
final Collection<Integer> cid = mapPath.getObjectsId(path.getX(nextStep), path.getY(nextStep));
if (sharedPathIds.containsAll(cid))
{
setDestination(destX, destY);
}
else
{
if (!ignoredIds.containsAll(cid))
{
setDestination(destX, destY);
}
}
} | [
"private",
"void",
"avoidObstacle",
"(",
"int",
"nextStep",
",",
"int",
"max",
")",
"{",
"if",
"(",
"nextStep",
">=",
"max",
"-",
"1",
")",
"{",
"pathStoppedRequested",
"=",
"true",
";",
"}",
"final",
"Collection",
"<",
"Integer",
">",
"cid",
"=",
"mapPath",
".",
"getObjectsId",
"(",
"path",
".",
"getX",
"(",
"nextStep",
")",
",",
"path",
".",
"getY",
"(",
"nextStep",
")",
")",
";",
"if",
"(",
"sharedPathIds",
".",
"containsAll",
"(",
"cid",
")",
")",
"{",
"setDestination",
"(",
"destX",
",",
"destY",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"ignoredIds",
".",
"containsAll",
"(",
"cid",
")",
")",
"{",
"setDestination",
"(",
"destX",
",",
"destY",
")",
";",
"}",
"}",
"}"
] | Update to avoid obstacle because next step is not free.
@param nextStep The next step.
@param max The maximum steps. | [
"Update",
"to",
"avoid",
"obstacle",
"because",
"next",
"step",
"is",
"not",
"free",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-game/src/main/java/com/b3dgs/lionengine/game/feature/tile/map/pathfinding/PathfindableModel.java#L247-L265 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java | NumericsUtilities.isBetween | public static boolean isBetween( double value, double... ranges ) {
"""
Check if value is inside a ND interval (bounds included).
@param value the value to check.
@param ranges the bounds (low1, high1, low2, high2, ...)
@return <code>true</code> if value lies inside the interval.
"""
boolean even = true;
for( int i = 0; i < ranges.length; i++ ) {
if (even) {
// lower bound
if (value < ranges[i]) {
return false;
}
} else {
// higher bound
if (value > ranges[i]) {
return false;
}
}
even = !even;
}
return true;
} | java | public static boolean isBetween( double value, double... ranges ) {
boolean even = true;
for( int i = 0; i < ranges.length; i++ ) {
if (even) {
// lower bound
if (value < ranges[i]) {
return false;
}
} else {
// higher bound
if (value > ranges[i]) {
return false;
}
}
even = !even;
}
return true;
} | [
"public",
"static",
"boolean",
"isBetween",
"(",
"double",
"value",
",",
"double",
"...",
"ranges",
")",
"{",
"boolean",
"even",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ranges",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"even",
")",
"{",
"// lower bound",
"if",
"(",
"value",
"<",
"ranges",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"// higher bound",
"if",
"(",
"value",
">",
"ranges",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"even",
"=",
"!",
"even",
";",
"}",
"return",
"true",
";",
"}"
] | Check if value is inside a ND interval (bounds included).
@param value the value to check.
@param ranges the bounds (low1, high1, low2, high2, ...)
@return <code>true</code> if value lies inside the interval. | [
"Check",
"if",
"value",
"is",
"inside",
"a",
"ND",
"interval",
"(",
"bounds",
"included",
")",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/math/NumericsUtilities.java#L244-L261 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/bos/BosClient.java | BosClient.appendObject | public AppendObjectResponse appendObject(String bucketName, String key, File file) {
"""
Uploads the specified appendable file to Bos under the specified bucket and key name.
@param bucketName The name of an existing bucket, to which you have Write permission.
@param key The key under which to store the specified file.
@param file The appendable file containing the data to be uploaded to Bos.
@return An AppendObjectResponse object containing the information returned by Bos for the newly created object.
"""
return this.appendObject(new AppendObjectRequest(bucketName, key, file));
} | java | public AppendObjectResponse appendObject(String bucketName, String key, File file) {
return this.appendObject(new AppendObjectRequest(bucketName, key, file));
} | [
"public",
"AppendObjectResponse",
"appendObject",
"(",
"String",
"bucketName",
",",
"String",
"key",
",",
"File",
"file",
")",
"{",
"return",
"this",
".",
"appendObject",
"(",
"new",
"AppendObjectRequest",
"(",
"bucketName",
",",
"key",
",",
"file",
")",
")",
";",
"}"
] | Uploads the specified appendable file to Bos under the specified bucket and key name.
@param bucketName The name of an existing bucket, to which you have Write permission.
@param key The key under which to store the specified file.
@param file The appendable file containing the data to be uploaded to Bos.
@return An AppendObjectResponse object containing the information returned by Bos for the newly created object. | [
"Uploads",
"the",
"specified",
"appendable",
"file",
"to",
"Bos",
"under",
"the",
"specified",
"bucket",
"and",
"key",
"name",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/bos/BosClient.java#L1673-L1675 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/WalkerFactory.java | WalkerFactory.analyzePredicate | static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
throws javax.xml.transform.TransformerException {
"""
Analyze a step and give information about it's predicates. Right now this
just returns true or false if the step has a predicate.
@param compiler non-null reference to compiler object that has processed
the XPath operations into an opcode map.
@param opPos The opcode position for the step.
@param stepType The type of step, one of OP_GROUP, etc.
@return true if step has a predicate.
@throws javax.xml.transform.TransformerException
"""
int argLen;
switch (stepType)
{
case OpCodes.OP_VARIABLE :
case OpCodes.OP_EXTFUNCTION :
case OpCodes.OP_FUNCTION :
case OpCodes.OP_GROUP :
argLen = compiler.getArgLength(opPos);
break;
default :
argLen = compiler.getArgLengthOfStep(opPos);
}
int pos = compiler.getFirstPredicateOpPos(opPos);
int nPredicates = compiler.countPredicates(pos);
return (nPredicates > 0) ? true : false;
} | java | static boolean analyzePredicate(Compiler compiler, int opPos, int stepType)
throws javax.xml.transform.TransformerException
{
int argLen;
switch (stepType)
{
case OpCodes.OP_VARIABLE :
case OpCodes.OP_EXTFUNCTION :
case OpCodes.OP_FUNCTION :
case OpCodes.OP_GROUP :
argLen = compiler.getArgLength(opPos);
break;
default :
argLen = compiler.getArgLengthOfStep(opPos);
}
int pos = compiler.getFirstPredicateOpPos(opPos);
int nPredicates = compiler.countPredicates(pos);
return (nPredicates > 0) ? true : false;
} | [
"static",
"boolean",
"analyzePredicate",
"(",
"Compiler",
"compiler",
",",
"int",
"opPos",
",",
"int",
"stepType",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"int",
"argLen",
";",
"switch",
"(",
"stepType",
")",
"{",
"case",
"OpCodes",
".",
"OP_VARIABLE",
":",
"case",
"OpCodes",
".",
"OP_EXTFUNCTION",
":",
"case",
"OpCodes",
".",
"OP_FUNCTION",
":",
"case",
"OpCodes",
".",
"OP_GROUP",
":",
"argLen",
"=",
"compiler",
".",
"getArgLength",
"(",
"opPos",
")",
";",
"break",
";",
"default",
":",
"argLen",
"=",
"compiler",
".",
"getArgLengthOfStep",
"(",
"opPos",
")",
";",
"}",
"int",
"pos",
"=",
"compiler",
".",
"getFirstPredicateOpPos",
"(",
"opPos",
")",
";",
"int",
"nPredicates",
"=",
"compiler",
".",
"countPredicates",
"(",
"pos",
")",
";",
"return",
"(",
"nPredicates",
">",
"0",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Analyze a step and give information about it's predicates. Right now this
just returns true or false if the step has a predicate.
@param compiler non-null reference to compiler object that has processed
the XPath operations into an opcode map.
@param opPos The opcode position for the step.
@param stepType The type of step, one of OP_GROUP, etc.
@return true if step has a predicate.
@throws javax.xml.transform.TransformerException | [
"Analyze",
"a",
"step",
"and",
"give",
"information",
"about",
"it",
"s",
"predicates",
".",
"Right",
"now",
"this",
"just",
"returns",
"true",
"or",
"false",
"if",
"the",
"step",
"has",
"a",
"predicate",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/axes/WalkerFactory.java#L1127-L1149 |
visallo/vertexium | accumulo-iterators/src/main/java/org/vertexium/accumulo/iterator/model/EdgeInfo.java | EdgeInfo.getVertexId | public static String getVertexId(Value value) {
"""
fast access method to avoid creating a new instance of an EdgeInfo
"""
byte[] buffer = value.get();
int offset = 0;
// skip label
int strLen = readInt(buffer, offset);
offset += 4;
if (strLen > 0) {
offset += strLen;
}
strLen = readInt(buffer, offset);
return readString(buffer, offset, strLen);
} | java | public static String getVertexId(Value value) {
byte[] buffer = value.get();
int offset = 0;
// skip label
int strLen = readInt(buffer, offset);
offset += 4;
if (strLen > 0) {
offset += strLen;
}
strLen = readInt(buffer, offset);
return readString(buffer, offset, strLen);
} | [
"public",
"static",
"String",
"getVertexId",
"(",
"Value",
"value",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"value",
".",
"get",
"(",
")",
";",
"int",
"offset",
"=",
"0",
";",
"// skip label",
"int",
"strLen",
"=",
"readInt",
"(",
"buffer",
",",
"offset",
")",
";",
"offset",
"+=",
"4",
";",
"if",
"(",
"strLen",
">",
"0",
")",
"{",
"offset",
"+=",
"strLen",
";",
"}",
"strLen",
"=",
"readInt",
"(",
"buffer",
",",
"offset",
")",
";",
"return",
"readString",
"(",
"buffer",
",",
"offset",
",",
"strLen",
")",
";",
"}"
] | fast access method to avoid creating a new instance of an EdgeInfo | [
"fast",
"access",
"method",
"to",
"avoid",
"creating",
"a",
"new",
"instance",
"of",
"an",
"EdgeInfo"
] | train | https://github.com/visallo/vertexium/blob/bb132b5425ac168957667164e1409b78adbea769/accumulo-iterators/src/main/java/org/vertexium/accumulo/iterator/model/EdgeInfo.java#L56-L69 |
jirkapinkas/jsitemapgenerator | src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java | AbstractGenerator.addPages | public <T> I addPages(Collection<T> webPages, Function<T, WebPage> mapper) {
"""
Add collection of pages to sitemap
@param <T> This is the type parameter
@param webPages Collection of pages
@param mapper Mapper function which transforms some object to WebPage
@return this
"""
for (T element : webPages) {
addPage(mapper.apply(element));
}
return getThis();
} | java | public <T> I addPages(Collection<T> webPages, Function<T, WebPage> mapper) {
for (T element : webPages) {
addPage(mapper.apply(element));
}
return getThis();
} | [
"public",
"<",
"T",
">",
"I",
"addPages",
"(",
"Collection",
"<",
"T",
">",
"webPages",
",",
"Function",
"<",
"T",
",",
"WebPage",
">",
"mapper",
")",
"{",
"for",
"(",
"T",
"element",
":",
"webPages",
")",
"{",
"addPage",
"(",
"mapper",
".",
"apply",
"(",
"element",
")",
")",
";",
"}",
"return",
"getThis",
"(",
")",
";",
"}"
] | Add collection of pages to sitemap
@param <T> This is the type parameter
@param webPages Collection of pages
@param mapper Mapper function which transforms some object to WebPage
@return this | [
"Add",
"collection",
"of",
"pages",
"to",
"sitemap"
] | train | https://github.com/jirkapinkas/jsitemapgenerator/blob/42e1f57bd936e21fe9df642e722726e71f667442/src/main/java/cz/jiripinkas/jsitemapgenerator/AbstractGenerator.java#L136-L141 |
grails/grails-core | grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java | WebUtils.exposeRequestAttributeIfNotPresent | private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) {
"""
Expose the specified request attribute if not already present.
@param request current servlet request
@param name the name of the attribute
@param value the suggested value of the attribute
"""
if (request.getAttribute(name) == null) {
request.setAttribute(name, value);
}
} | java | private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) {
if (request.getAttribute(name) == null) {
request.setAttribute(name, value);
}
} | [
"private",
"static",
"void",
"exposeRequestAttributeIfNotPresent",
"(",
"ServletRequest",
"request",
",",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"name",
")",
"==",
"null",
")",
"{",
"request",
".",
"setAttribute",
"(",
"name",
",",
"value",
")",
";",
"}",
"}"
] | Expose the specified request attribute if not already present.
@param request current servlet request
@param name the name of the attribute
@param value the suggested value of the attribute | [
"Expose",
"the",
"specified",
"request",
"attribute",
"if",
"not",
"already",
"present",
"."
] | train | https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-web-common/src/main/groovy/org/grails/web/util/WebUtils.java#L277-L281 |
kmi/iserve | iserve-discovery-api/src/main/java/uk/ac/open/kmi/iserve/discovery/api/impl/AbstractMatcher.java | AbstractMatcher.listMatchesAtMostOfType | @Override
public Map<URI, MatchResult> listMatchesAtMostOfType(URI origin, MatchType maxType) {
"""
Obtain all the matching resources that have a MatchTyoe with the URI of {@code origin} of the type provided (inclusive) or less.
@param origin URI to match
@param maxType the maximum MatchType we want to obtain
@return a Map containing indexed by the URI of the matching resource and containing the particular {@code MatchResult}. If no
result is found the Map should be empty not null.
"""
return listMatchesWithinRange(origin, this.matchTypesSupported.getLowest(), maxType);
} | java | @Override
public Map<URI, MatchResult> listMatchesAtMostOfType(URI origin, MatchType maxType) {
return listMatchesWithinRange(origin, this.matchTypesSupported.getLowest(), maxType);
} | [
"@",
"Override",
"public",
"Map",
"<",
"URI",
",",
"MatchResult",
">",
"listMatchesAtMostOfType",
"(",
"URI",
"origin",
",",
"MatchType",
"maxType",
")",
"{",
"return",
"listMatchesWithinRange",
"(",
"origin",
",",
"this",
".",
"matchTypesSupported",
".",
"getLowest",
"(",
")",
",",
"maxType",
")",
";",
"}"
] | Obtain all the matching resources that have a MatchTyoe with the URI of {@code origin} of the type provided (inclusive) or less.
@param origin URI to match
@param maxType the maximum MatchType we want to obtain
@return a Map containing indexed by the URI of the matching resource and containing the particular {@code MatchResult}. If no
result is found the Map should be empty not null. | [
"Obtain",
"all",
"the",
"matching",
"resources",
"that",
"have",
"a",
"MatchTyoe",
"with",
"the",
"URI",
"of",
"{",
"@code",
"origin",
"}",
"of",
"the",
"type",
"provided",
"(",
"inclusive",
")",
"or",
"less",
"."
] | train | https://github.com/kmi/iserve/blob/13e7016e64c1d5a539b838c6debf1a5cc4aefcb7/iserve-discovery-api/src/main/java/uk/ac/open/kmi/iserve/discovery/api/impl/AbstractMatcher.java#L111-L114 |
selenide/selenide | src/main/java/com/codeborne/selenide/Condition.java | Condition.matchText | public static Condition matchText(final String regex) {
"""
Assert that given element's text matches given regular expression
<p>Sample: <code>$("h1").should(matchText("Hello\s*John"))</code></p>
@param regex e.g. Kicked.*Chuck Norris - in this case ".*" can contain any characters including spaces, tabs, CR etc.
"""
return new Condition("match text") {
@Override
public boolean apply(Driver driver, WebElement element) {
return Html.text.matches(element.getText(), regex);
}
@Override
public String toString() {
return name + " '" + regex + '\'';
}
};
} | java | public static Condition matchText(final String regex) {
return new Condition("match text") {
@Override
public boolean apply(Driver driver, WebElement element) {
return Html.text.matches(element.getText(), regex);
}
@Override
public String toString() {
return name + " '" + regex + '\'';
}
};
} | [
"public",
"static",
"Condition",
"matchText",
"(",
"final",
"String",
"regex",
")",
"{",
"return",
"new",
"Condition",
"(",
"\"match text\"",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"Driver",
"driver",
",",
"WebElement",
"element",
")",
"{",
"return",
"Html",
".",
"text",
".",
"matches",
"(",
"element",
".",
"getText",
"(",
")",
",",
"regex",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"name",
"+",
"\" '\"",
"+",
"regex",
"+",
"'",
"'",
";",
"}",
"}",
";",
"}"
] | Assert that given element's text matches given regular expression
<p>Sample: <code>$("h1").should(matchText("Hello\s*John"))</code></p>
@param regex e.g. Kicked.*Chuck Norris - in this case ".*" can contain any characters including spaces, tabs, CR etc. | [
"Assert",
"that",
"given",
"element",
"s",
"text",
"matches",
"given",
"regular",
"expression"
] | train | https://github.com/selenide/selenide/blob/b867baf171942cf07725d83a985237428569883f/src/main/java/com/codeborne/selenide/Condition.java#L231-L243 |
overturetool/overture | core/codegen/platform/src/main/java/org/overture/codegen/ir/CodeGenBase.java | CodeGenBase.emitCode | public static void emitCode(File outputFolder, String fileName, String code,
String encoding) {
"""
Emits generated code to a file.
@param outputFolder
outputFolder The output folder that will store the generated code.
@param fileName
The name of the file that will store the generated code.
@param code
The generated code.
@param encoding
The encoding to use for the generated code.
"""
try
{
File javaFile = new File(outputFolder, File.separator + fileName);
javaFile.getParentFile().mkdirs();
javaFile.createNewFile();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(javaFile, false), encoding));
BufferedWriter out = new BufferedWriter(writer);
out.write(code);
out.close();
} catch (IOException e)
{
log.error("Error when saving class file: " + fileName);
e.printStackTrace();
}
} | java | public static void emitCode(File outputFolder, String fileName, String code,
String encoding)
{
try
{
File javaFile = new File(outputFolder, File.separator + fileName);
javaFile.getParentFile().mkdirs();
javaFile.createNewFile();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(javaFile, false), encoding));
BufferedWriter out = new BufferedWriter(writer);
out.write(code);
out.close();
} catch (IOException e)
{
log.error("Error when saving class file: " + fileName);
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"emitCode",
"(",
"File",
"outputFolder",
",",
"String",
"fileName",
",",
"String",
"code",
",",
"String",
"encoding",
")",
"{",
"try",
"{",
"File",
"javaFile",
"=",
"new",
"File",
"(",
"outputFolder",
",",
"File",
".",
"separator",
"+",
"fileName",
")",
";",
"javaFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"javaFile",
".",
"createNewFile",
"(",
")",
";",
"PrintWriter",
"writer",
"=",
"new",
"PrintWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"javaFile",
",",
"false",
")",
",",
"encoding",
")",
")",
";",
"BufferedWriter",
"out",
"=",
"new",
"BufferedWriter",
"(",
"writer",
")",
";",
"out",
".",
"write",
"(",
"code",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error when saving class file: \"",
"+",
"fileName",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Emits generated code to a file.
@param outputFolder
outputFolder The output folder that will store the generated code.
@param fileName
The name of the file that will store the generated code.
@param code
The generated code.
@param encoding
The encoding to use for the generated code. | [
"Emits",
"generated",
"code",
"to",
"a",
"file",
"."
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/codegen/platform/src/main/java/org/overture/codegen/ir/CodeGenBase.java#L611-L629 |
att/openstacksdk | openstack-java-sdk/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java | JerseyConnector.getHostnameVerifier | private HostnameVerifier getHostnameVerifier() {
"""
This host name verifier is used if the protocol is HTTPS AND a trusted hosts list has been provided. Otherwise,
the default behavior is used (requiring valid, unexpired certificates).
@return A host-name verifier that verifies the hosts based on the trusted hosts list. Note, the trusted hosts
list can include wild-card characters * and +.
"""
return new HostnameVerifier() {
@Override
public boolean verify(String hostName, SSLSession arg1) {
for (Pattern trustedHostPattern : trustedHostPatterns) {
if (trustedHostPattern.matcher(hostName).matches()) {
return true;
}
}
return false;
}
};
} | java | private HostnameVerifier getHostnameVerifier() {
return new HostnameVerifier() {
@Override
public boolean verify(String hostName, SSLSession arg1) {
for (Pattern trustedHostPattern : trustedHostPatterns) {
if (trustedHostPattern.matcher(hostName).matches()) {
return true;
}
}
return false;
}
};
} | [
"private",
"HostnameVerifier",
"getHostnameVerifier",
"(",
")",
"{",
"return",
"new",
"HostnameVerifier",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"verify",
"(",
"String",
"hostName",
",",
"SSLSession",
"arg1",
")",
"{",
"for",
"(",
"Pattern",
"trustedHostPattern",
":",
"trustedHostPatterns",
")",
"{",
"if",
"(",
"trustedHostPattern",
".",
"matcher",
"(",
"hostName",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}",
";",
"}"
] | This host name verifier is used if the protocol is HTTPS AND a trusted hosts list has been provided. Otherwise,
the default behavior is used (requiring valid, unexpired certificates).
@return A host-name verifier that verifies the hosts based on the trusted hosts list. Note, the trusted hosts
list can include wild-card characters * and +. | [
"This",
"host",
"name",
"verifier",
"is",
"used",
"if",
"the",
"protocol",
"is",
"HTTPS",
"AND",
"a",
"trusted",
"hosts",
"list",
"has",
"been",
"provided",
".",
"Otherwise",
"the",
"default",
"behavior",
"is",
"used",
"(",
"requiring",
"valid",
"unexpired",
"certificates",
")",
"."
] | train | https://github.com/att/openstacksdk/blob/16a81c460a7186ebe1ea63b7682486ba147208b9/openstack-java-sdk/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java#L311-L324 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/execution/impl/common/BaseFileCopier.java | BaseFileCopier.appendRemoteFileExtension | public static String appendRemoteFileExtension(final String filepath, final String fileext) {
"""
@return a string with a file extension appended if it is not already on the file path
provided.
@param filepath the file path string
@param fileext the file extension, if it does not start with a "." one will be prepended
first. If null, the unmodified filepath will be returned.
"""
return util.appendRemoteFileExtension(filepath, fileext);
} | java | public static String appendRemoteFileExtension(final String filepath, final String fileext) {
return util.appendRemoteFileExtension(filepath, fileext);
} | [
"public",
"static",
"String",
"appendRemoteFileExtension",
"(",
"final",
"String",
"filepath",
",",
"final",
"String",
"fileext",
")",
"{",
"return",
"util",
".",
"appendRemoteFileExtension",
"(",
"filepath",
",",
"fileext",
")",
";",
"}"
] | @return a string with a file extension appended if it is not already on the file path
provided.
@param filepath the file path string
@param fileext the file extension, if it does not start with a "." one will be prepended
first. If null, the unmodified filepath will be returned. | [
"@return",
"a",
"string",
"with",
"a",
"file",
"extension",
"appended",
"if",
"it",
"is",
"not",
"already",
"on",
"the",
"file",
"path",
"provided",
"."
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/impl/common/BaseFileCopier.java#L80-L82 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java | TreeInfo.diagnosticPositionFor | public static DiagnosticPosition diagnosticPositionFor(final Symbol sym, final JCTree tree) {
"""
Find the position for reporting an error about a symbol, where
that symbol is defined somewhere in the given tree.
"""
JCTree decl = declarationFor(sym, tree);
return ((decl != null) ? decl : tree).pos();
} | java | public static DiagnosticPosition diagnosticPositionFor(final Symbol sym, final JCTree tree) {
JCTree decl = declarationFor(sym, tree);
return ((decl != null) ? decl : tree).pos();
} | [
"public",
"static",
"DiagnosticPosition",
"diagnosticPositionFor",
"(",
"final",
"Symbol",
"sym",
",",
"final",
"JCTree",
"tree",
")",
"{",
"JCTree",
"decl",
"=",
"declarationFor",
"(",
"sym",
",",
"tree",
")",
";",
"return",
"(",
"(",
"decl",
"!=",
"null",
")",
"?",
"decl",
":",
"tree",
")",
".",
"pos",
"(",
")",
";",
"}"
] | Find the position for reporting an error about a symbol, where
that symbol is defined somewhere in the given tree. | [
"Find",
"the",
"position",
"for",
"reporting",
"an",
"error",
"about",
"a",
"symbol",
"where",
"that",
"symbol",
"is",
"defined",
"somewhere",
"in",
"the",
"given",
"tree",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java#L606-L609 |
shamanland/xdroid | lib-core/src/main/java/xdroid/core/ThreadUtils.java | ThreadUtils.newThread | public static Handler newThread(String name, int priority, Handler.Callback callback) {
"""
Creates new {@link HandlerThread} and returns new {@link Handler} associated with this thread.
@param name name of thread, in case of null - the default name will be generated
@param priority one of constants from {@link android.os.Process}
@param callback message handling callback, may be null
@return new instance
"""
HandlerThread thread = new HandlerThread(name != null ? name : newName(), priority);
thread.start();
return new Handler(thread.getLooper(), callback);
} | java | public static Handler newThread(String name, int priority, Handler.Callback callback) {
HandlerThread thread = new HandlerThread(name != null ? name : newName(), priority);
thread.start();
return new Handler(thread.getLooper(), callback);
} | [
"public",
"static",
"Handler",
"newThread",
"(",
"String",
"name",
",",
"int",
"priority",
",",
"Handler",
".",
"Callback",
"callback",
")",
"{",
"HandlerThread",
"thread",
"=",
"new",
"HandlerThread",
"(",
"name",
"!=",
"null",
"?",
"name",
":",
"newName",
"(",
")",
",",
"priority",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"return",
"new",
"Handler",
"(",
"thread",
".",
"getLooper",
"(",
")",
",",
"callback",
")",
";",
"}"
] | Creates new {@link HandlerThread} and returns new {@link Handler} associated with this thread.
@param name name of thread, in case of null - the default name will be generated
@param priority one of constants from {@link android.os.Process}
@param callback message handling callback, may be null
@return new instance | [
"Creates",
"new",
"{",
"@link",
"HandlerThread",
"}",
"and",
"returns",
"new",
"{",
"@link",
"Handler",
"}",
"associated",
"with",
"this",
"thread",
"."
] | train | https://github.com/shamanland/xdroid/blob/5330811114afaf6a7b8f9a10f3bbe19d37995d89/lib-core/src/main/java/xdroid/core/ThreadUtils.java#L54-L58 |
JavaMoney/jsr354-api | src/main/java/javax/money/Monetary.java | Monetary.isCurrencyAvailable | public static boolean isCurrencyAvailable(String code, String... providers) {
"""
Allows to check if a {@link CurrencyUnit} instance is defined, i.e.
accessible from {@link Monetary#getCurrency(String, String...)}.
@param code the currency code, not {@code null}.
@param providers the (optional) specification of providers to consider.
@return {@code true} if {@link Monetary#getCurrency(String, java.lang.String...)}
would return a result for the given code.
"""
return Objects.nonNull(MONETARY_CURRENCIES_SINGLETON_SPI()) && MONETARY_CURRENCIES_SINGLETON_SPI().isCurrencyAvailable(code, providers);
} | java | public static boolean isCurrencyAvailable(String code, String... providers) {
return Objects.nonNull(MONETARY_CURRENCIES_SINGLETON_SPI()) && MONETARY_CURRENCIES_SINGLETON_SPI().isCurrencyAvailable(code, providers);
} | [
"public",
"static",
"boolean",
"isCurrencyAvailable",
"(",
"String",
"code",
",",
"String",
"...",
"providers",
")",
"{",
"return",
"Objects",
".",
"nonNull",
"(",
"MONETARY_CURRENCIES_SINGLETON_SPI",
"(",
")",
")",
"&&",
"MONETARY_CURRENCIES_SINGLETON_SPI",
"(",
")",
".",
"isCurrencyAvailable",
"(",
"code",
",",
"providers",
")",
";",
"}"
] | Allows to check if a {@link CurrencyUnit} instance is defined, i.e.
accessible from {@link Monetary#getCurrency(String, String...)}.
@param code the currency code, not {@code null}.
@param providers the (optional) specification of providers to consider.
@return {@code true} if {@link Monetary#getCurrency(String, java.lang.String...)}
would return a result for the given code. | [
"Allows",
"to",
"check",
"if",
"a",
"{",
"@link",
"CurrencyUnit",
"}",
"instance",
"is",
"defined",
"i",
".",
"e",
".",
"accessible",
"from",
"{",
"@link",
"Monetary#getCurrency",
"(",
"String",
"String",
"...",
")",
"}",
"."
] | train | https://github.com/JavaMoney/jsr354-api/blob/49a7ae436eaf45cac1040879185531ef22de5525/src/main/java/javax/money/Monetary.java#L435-L437 |
YahooArchive/samoa | samoa-api/src/main/java/com/yahoo/labs/samoa/learners/classifiers/rules/distributed/AMRulesAggregatorProcessor.java | AMRulesAggregatorProcessor.newResultContentEvent | private ResultContentEvent newResultContentEvent(double[] prediction, InstanceContentEvent inEvent) {
"""
Helper method to generate new ResultContentEvent based on an instance and
its prediction result.
@param prediction The predicted class label from the decision tree model.
@param inEvent The associated instance content event
@return ResultContentEvent to be sent into Evaluator PI or other destination PI.
"""
ResultContentEvent rce = new ResultContentEvent(inEvent.getInstanceIndex(), inEvent.getInstance(), inEvent.getClassId(), prediction, inEvent.isLastEvent());
rce.setClassifierIndex(this.processorId);
rce.setEvaluationIndex(inEvent.getEvaluationIndex());
return rce;
} | java | private ResultContentEvent newResultContentEvent(double[] prediction, InstanceContentEvent inEvent){
ResultContentEvent rce = new ResultContentEvent(inEvent.getInstanceIndex(), inEvent.getInstance(), inEvent.getClassId(), prediction, inEvent.isLastEvent());
rce.setClassifierIndex(this.processorId);
rce.setEvaluationIndex(inEvent.getEvaluationIndex());
return rce;
} | [
"private",
"ResultContentEvent",
"newResultContentEvent",
"(",
"double",
"[",
"]",
"prediction",
",",
"InstanceContentEvent",
"inEvent",
")",
"{",
"ResultContentEvent",
"rce",
"=",
"new",
"ResultContentEvent",
"(",
"inEvent",
".",
"getInstanceIndex",
"(",
")",
",",
"inEvent",
".",
"getInstance",
"(",
")",
",",
"inEvent",
".",
"getClassId",
"(",
")",
",",
"prediction",
",",
"inEvent",
".",
"isLastEvent",
"(",
")",
")",
";",
"rce",
".",
"setClassifierIndex",
"(",
"this",
".",
"processorId",
")",
";",
"rce",
".",
"setEvaluationIndex",
"(",
"inEvent",
".",
"getEvaluationIndex",
"(",
")",
")",
";",
"return",
"rce",
";",
"}"
] | Helper method to generate new ResultContentEvent based on an instance and
its prediction result.
@param prediction The predicted class label from the decision tree model.
@param inEvent The associated instance content event
@return ResultContentEvent to be sent into Evaluator PI or other destination PI. | [
"Helper",
"method",
"to",
"generate",
"new",
"ResultContentEvent",
"based",
"on",
"an",
"instance",
"and",
"its",
"prediction",
"result",
"."
] | train | https://github.com/YahooArchive/samoa/blob/540a2c30167ac85c432b593baabd5ca97e7e8a0f/samoa-api/src/main/java/com/yahoo/labs/samoa/learners/classifiers/rules/distributed/AMRulesAggregatorProcessor.java#L219-L224 |
trustathsh/ironcommon | src/main/java/de/hshannover/f4/trust/ironcommon/yaml/YamlReader.java | YamlReader.loadAs | @SuppressWarnings("unchecked")
public static synchronized <T> T loadAs(String fileName, Class<T> clazz)
throws IOException {
"""
Tries to load the content of a yml-file as instances of a given
{@link Class}. If the file exists but is empty, the file is newly created
and null is returned.
@param fileName
The file name of the yml-file.
@param clazz
The data-type that the content of the yml-file shall be cast
into.
@param <T>
blubb
@return The content of the yml-file as instances of {@link Class} of type
T.
@throws IOException
If the file could not be opened, created (when it doesn't
exist) or the given filename is a directory.
"""
ObjectChecks.checkForNullReference(fileName, "fileName is null");
ObjectChecks.checkForNullReference(clazz, "clazz is null");
FileReader fileReader = null;
File f = null;
try {
fileReader = new FileReader(fileName);
} catch (FileNotFoundException e) {
f = new File(fileName);
if (f.isDirectory()) {
throw new IOException(fileName + " is a directory");
} else if (f.isFile()) {
throw new IOException("Could not open " + fileName + ": "
+ e.getMessage());
} else {
mLogger.debug("File: "
+ fileName
+ " doesn't exist and it's not a directory, try to create it.");
// If it doens't exist and it's not a directory, try to create
// it.
try {
new FileWriter(fileName).close();
} catch (IOException ee) {
throw new IOException("Could not create " + fileName + ": "
+ ee.getMessage());
}
try {
fileReader = new FileReader(fileName);
} catch (IOException ee) {
throw new IOException("Could not open " + fileName + ": "
+ ee.getMessage());
}
}
}
Yaml yaml = new Yaml();
Object data = yaml.loadAs(fileReader, clazz);
fileReader.close();
return (T) data;
} | java | @SuppressWarnings("unchecked")
public static synchronized <T> T loadAs(String fileName, Class<T> clazz)
throws IOException {
ObjectChecks.checkForNullReference(fileName, "fileName is null");
ObjectChecks.checkForNullReference(clazz, "clazz is null");
FileReader fileReader = null;
File f = null;
try {
fileReader = new FileReader(fileName);
} catch (FileNotFoundException e) {
f = new File(fileName);
if (f.isDirectory()) {
throw new IOException(fileName + " is a directory");
} else if (f.isFile()) {
throw new IOException("Could not open " + fileName + ": "
+ e.getMessage());
} else {
mLogger.debug("File: "
+ fileName
+ " doesn't exist and it's not a directory, try to create it.");
// If it doens't exist and it's not a directory, try to create
// it.
try {
new FileWriter(fileName).close();
} catch (IOException ee) {
throw new IOException("Could not create " + fileName + ": "
+ ee.getMessage());
}
try {
fileReader = new FileReader(fileName);
} catch (IOException ee) {
throw new IOException("Could not open " + fileName + ": "
+ ee.getMessage());
}
}
}
Yaml yaml = new Yaml();
Object data = yaml.loadAs(fileReader, clazz);
fileReader.close();
return (T) data;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"synchronized",
"<",
"T",
">",
"T",
"loadAs",
"(",
"String",
"fileName",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"IOException",
"{",
"ObjectChecks",
".",
"checkForNullReference",
"(",
"fileName",
",",
"\"fileName is null\"",
")",
";",
"ObjectChecks",
".",
"checkForNullReference",
"(",
"clazz",
",",
"\"clazz is null\"",
")",
";",
"FileReader",
"fileReader",
"=",
"null",
";",
"File",
"f",
"=",
"null",
";",
"try",
"{",
"fileReader",
"=",
"new",
"FileReader",
"(",
"fileName",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"f",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"fileName",
"+",
"\" is a directory\"",
")",
";",
"}",
"else",
"if",
"(",
"f",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not open \"",
"+",
"fileName",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"else",
"{",
"mLogger",
".",
"debug",
"(",
"\"File: \"",
"+",
"fileName",
"+",
"\" doesn't exist and it's not a directory, try to create it.\"",
")",
";",
"// If it doens't exist and it's not a directory, try to create",
"// it.",
"try",
"{",
"new",
"FileWriter",
"(",
"fileName",
")",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ee",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not create \"",
"+",
"fileName",
"+",
"\": \"",
"+",
"ee",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"try",
"{",
"fileReader",
"=",
"new",
"FileReader",
"(",
"fileName",
")",
";",
"}",
"catch",
"(",
"IOException",
"ee",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Could not open \"",
"+",
"fileName",
"+",
"\": \"",
"+",
"ee",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"Object",
"data",
"=",
"yaml",
".",
"loadAs",
"(",
"fileReader",
",",
"clazz",
")",
";",
"fileReader",
".",
"close",
"(",
")",
";",
"return",
"(",
"T",
")",
"data",
";",
"}"
] | Tries to load the content of a yml-file as instances of a given
{@link Class}. If the file exists but is empty, the file is newly created
and null is returned.
@param fileName
The file name of the yml-file.
@param clazz
The data-type that the content of the yml-file shall be cast
into.
@param <T>
blubb
@return The content of the yml-file as instances of {@link Class} of type
T.
@throws IOException
If the file could not be opened, created (when it doesn't
exist) or the given filename is a directory. | [
"Tries",
"to",
"load",
"the",
"content",
"of",
"a",
"yml",
"-",
"file",
"as",
"instances",
"of",
"a",
"given",
"{",
"@link",
"Class",
"}",
".",
"If",
"the",
"file",
"exists",
"but",
"is",
"empty",
"the",
"file",
"is",
"newly",
"created",
"and",
"null",
"is",
"returned",
"."
] | train | https://github.com/trustathsh/ironcommon/blob/fee589a9300ab16744ca12fafae4357dd18c9fcb/src/main/java/de/hshannover/f4/trust/ironcommon/yaml/YamlReader.java#L87-L131 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/InheritanceHelper.java | InheritanceHelper.isProxyOrSubTypeOf | public boolean isProxyOrSubTypeOf(LightweightTypeReference candidate, Class<?> jvmSuperType,
Class<? extends XtendTypeDeclaration> sarlSuperType) {
"""
Replies if the type candidate is a proxy (unresolved type) or a subtype of the given super type.
@param candidate the type to test.
@param jvmSuperType the expected JVM super-type.
@param sarlSuperType the expected SARL super-type.
@return <code>true</code> if the candidate is a sub-type of the super-type.
"""
if (!candidate.isResolved()) {
return true;
}
return isSubTypeOf(candidate, jvmSuperType, sarlSuperType);
} | java | public boolean isProxyOrSubTypeOf(LightweightTypeReference candidate, Class<?> jvmSuperType,
Class<? extends XtendTypeDeclaration> sarlSuperType) {
if (!candidate.isResolved()) {
return true;
}
return isSubTypeOf(candidate, jvmSuperType, sarlSuperType);
} | [
"public",
"boolean",
"isProxyOrSubTypeOf",
"(",
"LightweightTypeReference",
"candidate",
",",
"Class",
"<",
"?",
">",
"jvmSuperType",
",",
"Class",
"<",
"?",
"extends",
"XtendTypeDeclaration",
">",
"sarlSuperType",
")",
"{",
"if",
"(",
"!",
"candidate",
".",
"isResolved",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"isSubTypeOf",
"(",
"candidate",
",",
"jvmSuperType",
",",
"sarlSuperType",
")",
";",
"}"
] | Replies if the type candidate is a proxy (unresolved type) or a subtype of the given super type.
@param candidate the type to test.
@param jvmSuperType the expected JVM super-type.
@param sarlSuperType the expected SARL super-type.
@return <code>true</code> if the candidate is a sub-type of the super-type. | [
"Replies",
"if",
"the",
"type",
"candidate",
"is",
"a",
"proxy",
"(",
"unresolved",
"type",
")",
"or",
"a",
"subtype",
"of",
"the",
"given",
"super",
"type",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/typesystem/InheritanceHelper.java#L198-L204 |
google/flogger | api/src/main/java/com/google/common/flogger/parser/DefaultPrintfMessageParser.java | DefaultPrintfMessageParser.wrapHexParameter | private static Parameter wrapHexParameter(final FormatOptions options, int index) {
"""
Static method so the anonymous synthetic parameter is static, rather than an inner class.
"""
// %h / %H is really just %x / %X on the hashcode.
return new Parameter(options, index) {
@Override
protected void accept(ParameterVisitor visitor, Object value) {
visitor.visit(value.hashCode(), FormatChar.HEX, getFormatOptions());
}
@Override
public String getFormat() {
return options.shouldUpperCase() ? "%H" : "%h";
}
};
} | java | private static Parameter wrapHexParameter(final FormatOptions options, int index) {
// %h / %H is really just %x / %X on the hashcode.
return new Parameter(options, index) {
@Override
protected void accept(ParameterVisitor visitor, Object value) {
visitor.visit(value.hashCode(), FormatChar.HEX, getFormatOptions());
}
@Override
public String getFormat() {
return options.shouldUpperCase() ? "%H" : "%h";
}
};
} | [
"private",
"static",
"Parameter",
"wrapHexParameter",
"(",
"final",
"FormatOptions",
"options",
",",
"int",
"index",
")",
"{",
"// %h / %H is really just %x / %X on the hashcode.",
"return",
"new",
"Parameter",
"(",
"options",
",",
"index",
")",
"{",
"@",
"Override",
"protected",
"void",
"accept",
"(",
"ParameterVisitor",
"visitor",
",",
"Object",
"value",
")",
"{",
"visitor",
".",
"visit",
"(",
"value",
".",
"hashCode",
"(",
")",
",",
"FormatChar",
".",
"HEX",
",",
"getFormatOptions",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getFormat",
"(",
")",
"{",
"return",
"options",
".",
"shouldUpperCase",
"(",
")",
"?",
"\"%H\"",
":",
"\"%h\"",
";",
"}",
"}",
";",
"}"
] | Static method so the anonymous synthetic parameter is static, rather than an inner class. | [
"Static",
"method",
"so",
"the",
"anonymous",
"synthetic",
"parameter",
"is",
"static",
"rather",
"than",
"an",
"inner",
"class",
"."
] | train | https://github.com/google/flogger/blob/a164967a93a9f4ce92f34319fc0cc7c91a57321c/api/src/main/java/com/google/common/flogger/parser/DefaultPrintfMessageParser.java#L103-L116 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderPersistenceImpl.java | CommerceOrderPersistenceImpl.removeByUuid_C | @Override
public void removeByUuid_C(String uuid, long companyId) {
"""
Removes all the commerce orders where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID
"""
for (CommerceOrder commerceOrder : findByUuid_C(uuid, companyId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
} | java | @Override
public void removeByUuid_C(String uuid, long companyId) {
for (CommerceOrder commerceOrder : findByUuid_C(uuid, companyId,
QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceOrder);
}
} | [
"@",
"Override",
"public",
"void",
"removeByUuid_C",
"(",
"String",
"uuid",
",",
"long",
"companyId",
")",
"{",
"for",
"(",
"CommerceOrder",
"commerceOrder",
":",
"findByUuid_C",
"(",
"uuid",
",",
"companyId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"commerceOrder",
")",
";",
"}",
"}"
] | Removes all the commerce orders where uuid = ? and companyId = ? from the database.
@param uuid the uuid
@param companyId the company ID | [
"Removes",
"all",
"the",
"commerce",
"orders",
"where",
"uuid",
"=",
"?",
";",
"and",
"companyId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceOrderPersistenceImpl.java#L1400-L1406 |
apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/spec_store/FSSpecStore.java | FSSpecStore.getSpecs | private void getSpecs(Path directory, Collection<Spec> specs) throws Exception {
"""
For multiple {@link FlowSpec}s to be loaded, catch Exceptions when one of them failed to be loaded and
continue with the rest.
The {@link IOException} thrown from standard FileSystem call will be propagated, while the file-specific
exception will be caught to ensure other files being able to deserialized.
@param directory The directory that contains specs to be deserialized
@param specs Container of specs.
"""
FileStatus[] fileStatuses = fs.listStatus(directory);
for (FileStatus fileStatus : fileStatuses) {
if (fileStatus.isDirectory()) {
getSpecs(fileStatus.getPath(), specs);
} else {
try {
specs.add(readSpecFromFile(fileStatus.getPath()));
} catch (Exception e) {
log.warn(String.format("Path[%s] cannot be correctly deserialized as Spec", fileStatus.getPath()), e);
}
}
}
} | java | private void getSpecs(Path directory, Collection<Spec> specs) throws Exception {
FileStatus[] fileStatuses = fs.listStatus(directory);
for (FileStatus fileStatus : fileStatuses) {
if (fileStatus.isDirectory()) {
getSpecs(fileStatus.getPath(), specs);
} else {
try {
specs.add(readSpecFromFile(fileStatus.getPath()));
} catch (Exception e) {
log.warn(String.format("Path[%s] cannot be correctly deserialized as Spec", fileStatus.getPath()), e);
}
}
}
} | [
"private",
"void",
"getSpecs",
"(",
"Path",
"directory",
",",
"Collection",
"<",
"Spec",
">",
"specs",
")",
"throws",
"Exception",
"{",
"FileStatus",
"[",
"]",
"fileStatuses",
"=",
"fs",
".",
"listStatus",
"(",
"directory",
")",
";",
"for",
"(",
"FileStatus",
"fileStatus",
":",
"fileStatuses",
")",
"{",
"if",
"(",
"fileStatus",
".",
"isDirectory",
"(",
")",
")",
"{",
"getSpecs",
"(",
"fileStatus",
".",
"getPath",
"(",
")",
",",
"specs",
")",
";",
"}",
"else",
"{",
"try",
"{",
"specs",
".",
"add",
"(",
"readSpecFromFile",
"(",
"fileStatus",
".",
"getPath",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"Path[%s] cannot be correctly deserialized as Spec\"",
",",
"fileStatus",
".",
"getPath",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"}"
] | For multiple {@link FlowSpec}s to be loaded, catch Exceptions when one of them failed to be loaded and
continue with the rest.
The {@link IOException} thrown from standard FileSystem call will be propagated, while the file-specific
exception will be caught to ensure other files being able to deserialized.
@param directory The directory that contains specs to be deserialized
@param specs Container of specs. | [
"For",
"multiple",
"{",
"@link",
"FlowSpec",
"}",
"s",
"to",
"be",
"loaded",
"catch",
"Exceptions",
"when",
"one",
"of",
"them",
"failed",
"to",
"be",
"loaded",
"and",
"continue",
"with",
"the",
"rest",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/spec_store/FSSpecStore.java#L281-L294 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/subdoc/AsyncMutateInBuilder.java | AsyncMutateInBuilder.arrayAppendAll | public <T> AsyncMutateInBuilder arrayAppendAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder) {
"""
Append multiple values at once in an existing array, pushing all values in the collection's iteration order to
the back/end of the array.
Each item in the collection is inserted as an individual element of the array, but a bit of overhead
is saved compared to individual {@link #arrayAppend(String, Object, boolean)} by grouping mutations in
a single packet.
For example given an array [ A, B, C ], appending the values X and Y yields [ A, B, C, X, Y ]
and not [ A, B, C, [ X, Y ] ].
@param path the path of the array.
@param values the collection of values to individually insert at the back of the array.
@param optionsBuilder {@link SubdocOptionsBuilder}
@param <T> the type of data in the collection (must be JSON serializable).
"""
this.mutationSpecs.add(new MutationSpec(Mutation.ARRAY_PUSH_LAST, path, new MultiValue<T>(values), optionsBuilder));
return this;
} | java | public <T> AsyncMutateInBuilder arrayAppendAll(String path, Collection<T> values, SubdocOptionsBuilder optionsBuilder) {
this.mutationSpecs.add(new MutationSpec(Mutation.ARRAY_PUSH_LAST, path, new MultiValue<T>(values), optionsBuilder));
return this;
} | [
"public",
"<",
"T",
">",
"AsyncMutateInBuilder",
"arrayAppendAll",
"(",
"String",
"path",
",",
"Collection",
"<",
"T",
">",
"values",
",",
"SubdocOptionsBuilder",
"optionsBuilder",
")",
"{",
"this",
".",
"mutationSpecs",
".",
"add",
"(",
"new",
"MutationSpec",
"(",
"Mutation",
".",
"ARRAY_PUSH_LAST",
",",
"path",
",",
"new",
"MultiValue",
"<",
"T",
">",
"(",
"values",
")",
",",
"optionsBuilder",
")",
")",
";",
"return",
"this",
";",
"}"
] | Append multiple values at once in an existing array, pushing all values in the collection's iteration order to
the back/end of the array.
Each item in the collection is inserted as an individual element of the array, but a bit of overhead
is saved compared to individual {@link #arrayAppend(String, Object, boolean)} by grouping mutations in
a single packet.
For example given an array [ A, B, C ], appending the values X and Y yields [ A, B, C, X, Y ]
and not [ A, B, C, [ X, Y ] ].
@param path the path of the array.
@param values the collection of values to individually insert at the back of the array.
@param optionsBuilder {@link SubdocOptionsBuilder}
@param <T> the type of data in the collection (must be JSON serializable). | [
"Append",
"multiple",
"values",
"at",
"once",
"in",
"an",
"existing",
"array",
"pushing",
"all",
"values",
"in",
"the",
"collection",
"s",
"iteration",
"order",
"to",
"the",
"back",
"/",
"end",
"of",
"the",
"array",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/subdoc/AsyncMutateInBuilder.java#L1041-L1044 |
JOML-CI/JOML | src/org/joml/Matrix4d.java | Matrix4d.rotateLocal | public Matrix4d rotateLocal(Quaterniondc quat, Matrix4d dest) {
"""
Pre-multiply the rotation - and possibly scaling - transformation of the given {@link Quaterniondc} to this matrix and store
the result in <code>dest</code>.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>Q</code> the rotation matrix obtained from the given quaternion,
then the new matrix will be <code>Q * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>Q * M * v</code>,
the quaternion rotation will be applied last!
<p>
In order to set the matrix to a rotation transformation without pre-multiplying,
use {@link #rotation(Quaterniondc)}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion">http://en.wikipedia.org</a>
@see #rotation(Quaterniondc)
@param quat
the {@link Quaterniondc}
@param dest
will hold the result
@return dest
"""
double w2 = quat.w() * quat.w(), x2 = quat.x() * quat.x();
double y2 = quat.y() * quat.y(), z2 = quat.z() * quat.z();
double zw = quat.z() * quat.w(), dzw = zw + zw, xy = quat.x() * quat.y(), dxy = xy + xy;
double xz = quat.x() * quat.z(), dxz = xz + xz, yw = quat.y() * quat.w(), dyw = yw + yw;
double yz = quat.y() * quat.z(), dyz = yz + yz, xw = quat.x() * quat.w(), dxw = xw + xw;
double lm00 = w2 + x2 - z2 - y2;
double lm01 = dxy + dzw;
double lm02 = dxz - dyw;
double lm10 = -dzw + dxy;
double lm11 = y2 - z2 + w2 - x2;
double lm12 = dyz + dxw;
double lm20 = dyw + dxz;
double lm21 = dyz - dxw;
double lm22 = z2 - y2 - x2 + w2;
double nm00 = lm00 * m00 + lm10 * m01 + lm20 * m02;
double nm01 = lm01 * m00 + lm11 * m01 + lm21 * m02;
double nm02 = lm02 * m00 + lm12 * m01 + lm22 * m02;
double nm03 = m03;
double nm10 = lm00 * m10 + lm10 * m11 + lm20 * m12;
double nm11 = lm01 * m10 + lm11 * m11 + lm21 * m12;
double nm12 = lm02 * m10 + lm12 * m11 + lm22 * m12;
double nm13 = m13;
double nm20 = lm00 * m20 + lm10 * m21 + lm20 * m22;
double nm21 = lm01 * m20 + lm11 * m21 + lm21 * m22;
double nm22 = lm02 * m20 + lm12 * m21 + lm22 * m22;
double nm23 = m23;
double nm30 = lm00 * m30 + lm10 * m31 + lm20 * m32;
double nm31 = lm01 * m30 + lm11 * m31 + lm21 * m32;
double nm32 = lm02 * m30 + lm12 * m31 + lm22 * m32;
double nm33 = m33;
dest.m00 = nm00;
dest.m01 = nm01;
dest.m02 = nm02;
dest.m03 = nm03;
dest.m10 = nm10;
dest.m11 = nm11;
dest.m12 = nm12;
dest.m13 = nm13;
dest.m20 = nm20;
dest.m21 = nm21;
dest.m22 = nm22;
dest.m23 = nm23;
dest.m30 = nm30;
dest.m31 = nm31;
dest.m32 = nm32;
dest.m33 = nm33;
dest.properties = properties & ~(PROPERTY_PERSPECTIVE | PROPERTY_IDENTITY | PROPERTY_TRANSLATION);
return dest;
} | java | public Matrix4d rotateLocal(Quaterniondc quat, Matrix4d dest) {
double w2 = quat.w() * quat.w(), x2 = quat.x() * quat.x();
double y2 = quat.y() * quat.y(), z2 = quat.z() * quat.z();
double zw = quat.z() * quat.w(), dzw = zw + zw, xy = quat.x() * quat.y(), dxy = xy + xy;
double xz = quat.x() * quat.z(), dxz = xz + xz, yw = quat.y() * quat.w(), dyw = yw + yw;
double yz = quat.y() * quat.z(), dyz = yz + yz, xw = quat.x() * quat.w(), dxw = xw + xw;
double lm00 = w2 + x2 - z2 - y2;
double lm01 = dxy + dzw;
double lm02 = dxz - dyw;
double lm10 = -dzw + dxy;
double lm11 = y2 - z2 + w2 - x2;
double lm12 = dyz + dxw;
double lm20 = dyw + dxz;
double lm21 = dyz - dxw;
double lm22 = z2 - y2 - x2 + w2;
double nm00 = lm00 * m00 + lm10 * m01 + lm20 * m02;
double nm01 = lm01 * m00 + lm11 * m01 + lm21 * m02;
double nm02 = lm02 * m00 + lm12 * m01 + lm22 * m02;
double nm03 = m03;
double nm10 = lm00 * m10 + lm10 * m11 + lm20 * m12;
double nm11 = lm01 * m10 + lm11 * m11 + lm21 * m12;
double nm12 = lm02 * m10 + lm12 * m11 + lm22 * m12;
double nm13 = m13;
double nm20 = lm00 * m20 + lm10 * m21 + lm20 * m22;
double nm21 = lm01 * m20 + lm11 * m21 + lm21 * m22;
double nm22 = lm02 * m20 + lm12 * m21 + lm22 * m22;
double nm23 = m23;
double nm30 = lm00 * m30 + lm10 * m31 + lm20 * m32;
double nm31 = lm01 * m30 + lm11 * m31 + lm21 * m32;
double nm32 = lm02 * m30 + lm12 * m31 + lm22 * m32;
double nm33 = m33;
dest.m00 = nm00;
dest.m01 = nm01;
dest.m02 = nm02;
dest.m03 = nm03;
dest.m10 = nm10;
dest.m11 = nm11;
dest.m12 = nm12;
dest.m13 = nm13;
dest.m20 = nm20;
dest.m21 = nm21;
dest.m22 = nm22;
dest.m23 = nm23;
dest.m30 = nm30;
dest.m31 = nm31;
dest.m32 = nm32;
dest.m33 = nm33;
dest.properties = properties & ~(PROPERTY_PERSPECTIVE | PROPERTY_IDENTITY | PROPERTY_TRANSLATION);
return dest;
} | [
"public",
"Matrix4d",
"rotateLocal",
"(",
"Quaterniondc",
"quat",
",",
"Matrix4d",
"dest",
")",
"{",
"double",
"w2",
"=",
"quat",
".",
"w",
"(",
")",
"*",
"quat",
".",
"w",
"(",
")",
",",
"x2",
"=",
"quat",
".",
"x",
"(",
")",
"*",
"quat",
".",
"x",
"(",
")",
";",
"double",
"y2",
"=",
"quat",
".",
"y",
"(",
")",
"*",
"quat",
".",
"y",
"(",
")",
",",
"z2",
"=",
"quat",
".",
"z",
"(",
")",
"*",
"quat",
".",
"z",
"(",
")",
";",
"double",
"zw",
"=",
"quat",
".",
"z",
"(",
")",
"*",
"quat",
".",
"w",
"(",
")",
",",
"dzw",
"=",
"zw",
"+",
"zw",
",",
"xy",
"=",
"quat",
".",
"x",
"(",
")",
"*",
"quat",
".",
"y",
"(",
")",
",",
"dxy",
"=",
"xy",
"+",
"xy",
";",
"double",
"xz",
"=",
"quat",
".",
"x",
"(",
")",
"*",
"quat",
".",
"z",
"(",
")",
",",
"dxz",
"=",
"xz",
"+",
"xz",
",",
"yw",
"=",
"quat",
".",
"y",
"(",
")",
"*",
"quat",
".",
"w",
"(",
")",
",",
"dyw",
"=",
"yw",
"+",
"yw",
";",
"double",
"yz",
"=",
"quat",
".",
"y",
"(",
")",
"*",
"quat",
".",
"z",
"(",
")",
",",
"dyz",
"=",
"yz",
"+",
"yz",
",",
"xw",
"=",
"quat",
".",
"x",
"(",
")",
"*",
"quat",
".",
"w",
"(",
")",
",",
"dxw",
"=",
"xw",
"+",
"xw",
";",
"double",
"lm00",
"=",
"w2",
"+",
"x2",
"-",
"z2",
"-",
"y2",
";",
"double",
"lm01",
"=",
"dxy",
"+",
"dzw",
";",
"double",
"lm02",
"=",
"dxz",
"-",
"dyw",
";",
"double",
"lm10",
"=",
"-",
"dzw",
"+",
"dxy",
";",
"double",
"lm11",
"=",
"y2",
"-",
"z2",
"+",
"w2",
"-",
"x2",
";",
"double",
"lm12",
"=",
"dyz",
"+",
"dxw",
";",
"double",
"lm20",
"=",
"dyw",
"+",
"dxz",
";",
"double",
"lm21",
"=",
"dyz",
"-",
"dxw",
";",
"double",
"lm22",
"=",
"z2",
"-",
"y2",
"-",
"x2",
"+",
"w2",
";",
"double",
"nm00",
"=",
"lm00",
"*",
"m00",
"+",
"lm10",
"*",
"m01",
"+",
"lm20",
"*",
"m02",
";",
"double",
"nm01",
"=",
"lm01",
"*",
"m00",
"+",
"lm11",
"*",
"m01",
"+",
"lm21",
"*",
"m02",
";",
"double",
"nm02",
"=",
"lm02",
"*",
"m00",
"+",
"lm12",
"*",
"m01",
"+",
"lm22",
"*",
"m02",
";",
"double",
"nm03",
"=",
"m03",
";",
"double",
"nm10",
"=",
"lm00",
"*",
"m10",
"+",
"lm10",
"*",
"m11",
"+",
"lm20",
"*",
"m12",
";",
"double",
"nm11",
"=",
"lm01",
"*",
"m10",
"+",
"lm11",
"*",
"m11",
"+",
"lm21",
"*",
"m12",
";",
"double",
"nm12",
"=",
"lm02",
"*",
"m10",
"+",
"lm12",
"*",
"m11",
"+",
"lm22",
"*",
"m12",
";",
"double",
"nm13",
"=",
"m13",
";",
"double",
"nm20",
"=",
"lm00",
"*",
"m20",
"+",
"lm10",
"*",
"m21",
"+",
"lm20",
"*",
"m22",
";",
"double",
"nm21",
"=",
"lm01",
"*",
"m20",
"+",
"lm11",
"*",
"m21",
"+",
"lm21",
"*",
"m22",
";",
"double",
"nm22",
"=",
"lm02",
"*",
"m20",
"+",
"lm12",
"*",
"m21",
"+",
"lm22",
"*",
"m22",
";",
"double",
"nm23",
"=",
"m23",
";",
"double",
"nm30",
"=",
"lm00",
"*",
"m30",
"+",
"lm10",
"*",
"m31",
"+",
"lm20",
"*",
"m32",
";",
"double",
"nm31",
"=",
"lm01",
"*",
"m30",
"+",
"lm11",
"*",
"m31",
"+",
"lm21",
"*",
"m32",
";",
"double",
"nm32",
"=",
"lm02",
"*",
"m30",
"+",
"lm12",
"*",
"m31",
"+",
"lm22",
"*",
"m32",
";",
"double",
"nm33",
"=",
"m33",
";",
"dest",
".",
"m00",
"=",
"nm00",
";",
"dest",
".",
"m01",
"=",
"nm01",
";",
"dest",
".",
"m02",
"=",
"nm02",
";",
"dest",
".",
"m03",
"=",
"nm03",
";",
"dest",
".",
"m10",
"=",
"nm10",
";",
"dest",
".",
"m11",
"=",
"nm11",
";",
"dest",
".",
"m12",
"=",
"nm12",
";",
"dest",
".",
"m13",
"=",
"nm13",
";",
"dest",
".",
"m20",
"=",
"nm20",
";",
"dest",
".",
"m21",
"=",
"nm21",
";",
"dest",
".",
"m22",
"=",
"nm22",
";",
"dest",
".",
"m23",
"=",
"nm23",
";",
"dest",
".",
"m30",
"=",
"nm30",
";",
"dest",
".",
"m31",
"=",
"nm31",
";",
"dest",
".",
"m32",
"=",
"nm32",
";",
"dest",
".",
"m33",
"=",
"nm33",
";",
"dest",
".",
"properties",
"=",
"properties",
"&",
"~",
"(",
"PROPERTY_PERSPECTIVE",
"|",
"PROPERTY_IDENTITY",
"|",
"PROPERTY_TRANSLATION",
")",
";",
"return",
"dest",
";",
"}"
] | Pre-multiply the rotation - and possibly scaling - transformation of the given {@link Quaterniondc} to this matrix and store
the result in <code>dest</code>.
<p>
When used with a right-handed coordinate system, the produced rotation will rotate a vector
counter-clockwise around the rotation axis, when viewing along the negative axis direction towards the origin.
When used with a left-handed coordinate system, the rotation is clockwise.
<p>
If <code>M</code> is <code>this</code> matrix and <code>Q</code> the rotation matrix obtained from the given quaternion,
then the new matrix will be <code>Q * M</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>Q * M * v</code>,
the quaternion rotation will be applied last!
<p>
In order to set the matrix to a rotation transformation without pre-multiplying,
use {@link #rotation(Quaterniondc)}.
<p>
Reference: <a href="http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion">http://en.wikipedia.org</a>
@see #rotation(Quaterniondc)
@param quat
the {@link Quaterniondc}
@param dest
will hold the result
@return dest | [
"Pre",
"-",
"multiply",
"the",
"rotation",
"-",
"and",
"possibly",
"scaling",
"-",
"transformation",
"of",
"the",
"given",
"{",
"@link",
"Quaterniondc",
"}",
"to",
"this",
"matrix",
"and",
"store",
"the",
"result",
"in",
"<code",
">",
"dest<",
"/",
"code",
">",
".",
"<p",
">",
"When",
"used",
"with",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"the",
"produced",
"rotation",
"will",
"rotate",
"a",
"vector",
"counter",
"-",
"clockwise",
"around",
"the",
"rotation",
"axis",
"when",
"viewing",
"along",
"the",
"negative",
"axis",
"direction",
"towards",
"the",
"origin",
".",
"When",
"used",
"with",
"a",
"left",
"-",
"handed",
"coordinate",
"system",
"the",
"rotation",
"is",
"clockwise",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"Q<",
"/",
"code",
">",
"the",
"rotation",
"matrix",
"obtained",
"from",
"the",
"given",
"quaternion",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"Q",
"*",
"M<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"Q",
"*",
"M",
"*",
"v<",
"/",
"code",
">",
"the",
"quaternion",
"rotation",
"will",
"be",
"applied",
"last!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"rotation",
"transformation",
"without",
"pre",
"-",
"multiplying",
"use",
"{",
"@link",
"#rotation",
"(",
"Quaterniondc",
")",
"}",
".",
"<p",
">",
"Reference",
":",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Rotation_matrix#Quaternion",
">",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org<",
"/",
"a",
">"
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4d.java#L8027-L8076 |
jbossws/jbossws-common | src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java | ReflectionUtils.assertVoidReturnType | public static void assertVoidReturnType(final Method method, Class<? extends Annotation> annotation) {
"""
Asserts method return void.
@param method to validate
@param annotation annotation to propagate in exception message
"""
if ((!method.getReturnType().equals(Void.class)) && (!method.getReturnType().equals(Void.TYPE)))
{
throw annotation == null ? MESSAGES.methodHasToReturnVoid(method) : MESSAGES.methodHasToReturnVoid2(method, annotation);
}
} | java | public static void assertVoidReturnType(final Method method, Class<? extends Annotation> annotation)
{
if ((!method.getReturnType().equals(Void.class)) && (!method.getReturnType().equals(Void.TYPE)))
{
throw annotation == null ? MESSAGES.methodHasToReturnVoid(method) : MESSAGES.methodHasToReturnVoid2(method, annotation);
}
} | [
"public",
"static",
"void",
"assertVoidReturnType",
"(",
"final",
"Method",
"method",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotation",
")",
"{",
"if",
"(",
"(",
"!",
"method",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"Void",
".",
"class",
")",
")",
"&&",
"(",
"!",
"method",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"Void",
".",
"TYPE",
")",
")",
")",
"{",
"throw",
"annotation",
"==",
"null",
"?",
"MESSAGES",
".",
"methodHasToReturnVoid",
"(",
"method",
")",
":",
"MESSAGES",
".",
"methodHasToReturnVoid2",
"(",
"method",
",",
"annotation",
")",
";",
"}",
"}"
] | Asserts method return void.
@param method to validate
@param annotation annotation to propagate in exception message | [
"Asserts",
"method",
"return",
"void",
"."
] | train | https://github.com/jbossws/jbossws-common/blob/fcff8a3ef9bfe046d6fa8c855a3fe4f62841add7/src/main/java/org/jboss/ws/common/injection/finders/ReflectionUtils.java#L128-L134 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java | ImgUtil.scale | public static Image scale(Image srcImg, int width, int height) {
"""
缩放图像(按长宽缩放)<br>
注意:目标长宽与原图不成比例会变形
@param srcImg 源图像来源流
@param width 目标宽度
@param height 目标高度
@return {@link Image}
@since 3.1.0
"""
return Img.from(srcImg).scale(width, height).getImg();
} | java | public static Image scale(Image srcImg, int width, int height) {
return Img.from(srcImg).scale(width, height).getImg();
} | [
"public",
"static",
"Image",
"scale",
"(",
"Image",
"srcImg",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"Img",
".",
"from",
"(",
"srcImg",
")",
".",
"scale",
"(",
"width",
",",
"height",
")",
".",
"getImg",
"(",
")",
";",
"}"
] | 缩放图像(按长宽缩放)<br>
注意:目标长宽与原图不成比例会变形
@param srcImg 源图像来源流
@param width 目标宽度
@param height 目标高度
@return {@link Image}
@since 3.1.0 | [
"缩放图像(按长宽缩放)<br",
">",
"注意:目标长宽与原图不成比例会变形"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java#L169-L171 |
stevespringett/Alpine | alpine/src/main/java/alpine/persistence/AbstractAlpineQueryManager.java | AbstractAlpineQueryManager.getObjectById | public <T> T getObjectById(Class<T> clazz, Object id) {
"""
Retrieves an object by its ID.
@param <T> A type parameter. This type will be returned
@param clazz the persistence class to retrive the ID for
@param id the object id to retrieve
@return an object of the specified type
@since 1.0.0
"""
return pm.getObjectById(clazz, id);
} | java | public <T> T getObjectById(Class<T> clazz, Object id) {
return pm.getObjectById(clazz, id);
} | [
"public",
"<",
"T",
">",
"T",
"getObjectById",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Object",
"id",
")",
"{",
"return",
"pm",
".",
"getObjectById",
"(",
"clazz",
",",
"id",
")",
";",
"}"
] | Retrieves an object by its ID.
@param <T> A type parameter. This type will be returned
@param clazz the persistence class to retrive the ID for
@param id the object id to retrieve
@return an object of the specified type
@since 1.0.0 | [
"Retrieves",
"an",
"object",
"by",
"its",
"ID",
"."
] | train | https://github.com/stevespringett/Alpine/blob/6c5ef5e1ba4f38922096f1307d3950c09edb3093/alpine/src/main/java/alpine/persistence/AbstractAlpineQueryManager.java#L503-L505 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/workspace/VoiceApi.java | VoiceApi.singleStepConference | public void singleStepConference(
String connId,
String destination,
String location,
KeyValueCollection userData,
KeyValueCollection reasons,
KeyValueCollection extensions
) throws WorkspaceApiException {
"""
Perform a single-step conference to the specified destination. This adds the destination to the
existing call, creating a conference if necessary.
@param connId The connection ID of the call to conference.
@param destination The number to add to the call.
@param location Name of the remote location in the form of <SwitchName> or <T-ServerApplicationName>@<SwitchName>. This value is used by Workspace to set the location attribute for the corresponding T-Server requests. (optional)
@param userData Key/value data to include with the call. (optional)
@param reasons Information on causes for, and results of, actions taken by the user of the current DN. For details about reasons, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Reasons). (optional)
@param extensions Media device/hardware reason codes and similar information. For details about extensions, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Extensions). (optional)
"""
try {
VoicecallsidsinglestepconferenceData confData =
new VoicecallsidsinglestepconferenceData();
confData.setDestination(destination);
confData.setLocation(location);
confData.setUserData(Util.toKVList(userData));
confData.setReasons(Util.toKVList(reasons));
confData.setExtensions(Util.toKVList(extensions));
SingleStepConferenceData data = new SingleStepConferenceData();
data.data(confData);
ApiSuccessResponse response = this.voiceApi.singleStepConference(connId, data);
throwIfNotOk("singleStepConference", response);
} catch (ApiException e) {
throw new WorkspaceApiException("singleStepConference failed", e);
}
} | java | public void singleStepConference(
String connId,
String destination,
String location,
KeyValueCollection userData,
KeyValueCollection reasons,
KeyValueCollection extensions
) throws WorkspaceApiException {
try {
VoicecallsidsinglestepconferenceData confData =
new VoicecallsidsinglestepconferenceData();
confData.setDestination(destination);
confData.setLocation(location);
confData.setUserData(Util.toKVList(userData));
confData.setReasons(Util.toKVList(reasons));
confData.setExtensions(Util.toKVList(extensions));
SingleStepConferenceData data = new SingleStepConferenceData();
data.data(confData);
ApiSuccessResponse response = this.voiceApi.singleStepConference(connId, data);
throwIfNotOk("singleStepConference", response);
} catch (ApiException e) {
throw new WorkspaceApiException("singleStepConference failed", e);
}
} | [
"public",
"void",
"singleStepConference",
"(",
"String",
"connId",
",",
"String",
"destination",
",",
"String",
"location",
",",
"KeyValueCollection",
"userData",
",",
"KeyValueCollection",
"reasons",
",",
"KeyValueCollection",
"extensions",
")",
"throws",
"WorkspaceApiException",
"{",
"try",
"{",
"VoicecallsidsinglestepconferenceData",
"confData",
"=",
"new",
"VoicecallsidsinglestepconferenceData",
"(",
")",
";",
"confData",
".",
"setDestination",
"(",
"destination",
")",
";",
"confData",
".",
"setLocation",
"(",
"location",
")",
";",
"confData",
".",
"setUserData",
"(",
"Util",
".",
"toKVList",
"(",
"userData",
")",
")",
";",
"confData",
".",
"setReasons",
"(",
"Util",
".",
"toKVList",
"(",
"reasons",
")",
")",
";",
"confData",
".",
"setExtensions",
"(",
"Util",
".",
"toKVList",
"(",
"extensions",
")",
")",
";",
"SingleStepConferenceData",
"data",
"=",
"new",
"SingleStepConferenceData",
"(",
")",
";",
"data",
".",
"data",
"(",
"confData",
")",
";",
"ApiSuccessResponse",
"response",
"=",
"this",
".",
"voiceApi",
".",
"singleStepConference",
"(",
"connId",
",",
"data",
")",
";",
"throwIfNotOk",
"(",
"\"singleStepConference\"",
",",
"response",
")",
";",
"}",
"catch",
"(",
"ApiException",
"e",
")",
"{",
"throw",
"new",
"WorkspaceApiException",
"(",
"\"singleStepConference failed\"",
",",
"e",
")",
";",
"}",
"}"
] | Perform a single-step conference to the specified destination. This adds the destination to the
existing call, creating a conference if necessary.
@param connId The connection ID of the call to conference.
@param destination The number to add to the call.
@param location Name of the remote location in the form of <SwitchName> or <T-ServerApplicationName>@<SwitchName>. This value is used by Workspace to set the location attribute for the corresponding T-Server requests. (optional)
@param userData Key/value data to include with the call. (optional)
@param reasons Information on causes for, and results of, actions taken by the user of the current DN. For details about reasons, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Reasons). (optional)
@param extensions Media device/hardware reason codes and similar information. For details about extensions, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Extensions). (optional) | [
"Perform",
"a",
"single",
"-",
"step",
"conference",
"to",
"the",
"specified",
"destination",
".",
"This",
"adds",
"the",
"destination",
"to",
"the",
"existing",
"call",
"creating",
"a",
"conference",
"if",
"necessary",
"."
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/workspace/VoiceApi.java#L1034-L1058 |
jayantk/jklol | src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java | HeadedSyntacticCategory.getSubcategories | public Set<HeadedSyntacticCategory> getSubcategories(Set<String> featureValues) {
"""
Gets all syntactic categories which can be formed by assigning values to the
feature variables of this category. Returned categories may not be in canonical
form.
@param featureValues
@return
"""
Set<HeadedSyntacticCategory> subcategories = Sets.newHashSet();
for (SyntacticCategory newSyntax : syntacticCategory.getSubcategories(featureValues)) {
subcategories.add(new HeadedSyntacticCategory(newSyntax, semanticVariables, rootIndex));
}
return subcategories;
} | java | public Set<HeadedSyntacticCategory> getSubcategories(Set<String> featureValues) {
Set<HeadedSyntacticCategory> subcategories = Sets.newHashSet();
for (SyntacticCategory newSyntax : syntacticCategory.getSubcategories(featureValues)) {
subcategories.add(new HeadedSyntacticCategory(newSyntax, semanticVariables, rootIndex));
}
return subcategories;
} | [
"public",
"Set",
"<",
"HeadedSyntacticCategory",
">",
"getSubcategories",
"(",
"Set",
"<",
"String",
">",
"featureValues",
")",
"{",
"Set",
"<",
"HeadedSyntacticCategory",
">",
"subcategories",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"SyntacticCategory",
"newSyntax",
":",
"syntacticCategory",
".",
"getSubcategories",
"(",
"featureValues",
")",
")",
"{",
"subcategories",
".",
"add",
"(",
"new",
"HeadedSyntacticCategory",
"(",
"newSyntax",
",",
"semanticVariables",
",",
"rootIndex",
")",
")",
";",
"}",
"return",
"subcategories",
";",
"}"
] | Gets all syntactic categories which can be formed by assigning values to the
feature variables of this category. Returned categories may not be in canonical
form.
@param featureValues
@return | [
"Gets",
"all",
"syntactic",
"categories",
"which",
"can",
"be",
"formed",
"by",
"assigning",
"values",
"to",
"the",
"feature",
"variables",
"of",
"this",
"category",
".",
"Returned",
"categories",
"may",
"not",
"be",
"in",
"canonical",
"form",
"."
] | train | https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/ccg/HeadedSyntacticCategory.java#L451-L457 |
JodaOrg/joda-time | src/main/java/org/joda/time/convert/CalendarConverter.java | CalendarConverter.getChronology | public Chronology getChronology(Object object, DateTimeZone zone) {
"""
Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
The time zone specified is used in preference to that on the calendar.
@param object the Calendar to convert, must not be null
@param zone the specified zone to use, null means default zone
@return the chronology, never null
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type
"""
if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
return BuddhistChronology.getInstance(zone);
} else if (object instanceof GregorianCalendar) {
GregorianCalendar gc = (GregorianCalendar) object;
long cutover = gc.getGregorianChange().getTime();
if (cutover == Long.MIN_VALUE) {
return GregorianChronology.getInstance(zone);
} else if (cutover == Long.MAX_VALUE) {
return JulianChronology.getInstance(zone);
} else {
return GJChronology.getInstance(zone, cutover, 4);
}
} else {
return ISOChronology.getInstance(zone);
}
} | java | public Chronology getChronology(Object object, DateTimeZone zone) {
if (object.getClass().getName().endsWith(".BuddhistCalendar")) {
return BuddhistChronology.getInstance(zone);
} else if (object instanceof GregorianCalendar) {
GregorianCalendar gc = (GregorianCalendar) object;
long cutover = gc.getGregorianChange().getTime();
if (cutover == Long.MIN_VALUE) {
return GregorianChronology.getInstance(zone);
} else if (cutover == Long.MAX_VALUE) {
return JulianChronology.getInstance(zone);
} else {
return GJChronology.getInstance(zone, cutover, 4);
}
} else {
return ISOChronology.getInstance(zone);
}
} | [
"public",
"Chronology",
"getChronology",
"(",
"Object",
"object",
",",
"DateTimeZone",
"zone",
")",
"{",
"if",
"(",
"object",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
".",
"endsWith",
"(",
"\".BuddhistCalendar\"",
")",
")",
"{",
"return",
"BuddhistChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"else",
"if",
"(",
"object",
"instanceof",
"GregorianCalendar",
")",
"{",
"GregorianCalendar",
"gc",
"=",
"(",
"GregorianCalendar",
")",
"object",
";",
"long",
"cutover",
"=",
"gc",
".",
"getGregorianChange",
"(",
")",
".",
"getTime",
"(",
")",
";",
"if",
"(",
"cutover",
"==",
"Long",
".",
"MIN_VALUE",
")",
"{",
"return",
"GregorianChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"else",
"if",
"(",
"cutover",
"==",
"Long",
".",
"MAX_VALUE",
")",
"{",
"return",
"JulianChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"else",
"{",
"return",
"GJChronology",
".",
"getInstance",
"(",
"zone",
",",
"cutover",
",",
"4",
")",
";",
"}",
"}",
"else",
"{",
"return",
"ISOChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"}"
] | Gets the chronology, which is the GJChronology if a GregorianCalendar is used,
BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise.
The time zone specified is used in preference to that on the calendar.
@param object the Calendar to convert, must not be null
@param zone the specified zone to use, null means default zone
@return the chronology, never null
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type | [
"Gets",
"the",
"chronology",
"which",
"is",
"the",
"GJChronology",
"if",
"a",
"GregorianCalendar",
"is",
"used",
"BuddhistChronology",
"if",
"a",
"BuddhistCalendar",
"is",
"used",
"or",
"ISOChronology",
"otherwise",
".",
"The",
"time",
"zone",
"specified",
"is",
"used",
"in",
"preference",
"to",
"that",
"on",
"the",
"calendar",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/CalendarConverter.java#L93-L109 |
timols/java-gitlab-api | src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java | GitlabHTTPRequestor.withAttachment | public GitlabHTTPRequestor withAttachment(String key, File file) {
"""
Sets the HTTP Form Post parameters for the request
Has a fluent api for method chaining
@param key Form parameter Key
@param file File data
@return this
"""
if (file != null && key != null) {
attachments.put(key, file);
}
return this;
} | java | public GitlabHTTPRequestor withAttachment(String key, File file) {
if (file != null && key != null) {
attachments.put(key, file);
}
return this;
} | [
"public",
"GitlabHTTPRequestor",
"withAttachment",
"(",
"String",
"key",
",",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"!=",
"null",
"&&",
"key",
"!=",
"null",
")",
"{",
"attachments",
".",
"put",
"(",
"key",
",",
"file",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets the HTTP Form Post parameters for the request
Has a fluent api for method chaining
@param key Form parameter Key
@param file File data
@return this | [
"Sets",
"the",
"HTTP",
"Form",
"Post",
"parameters",
"for",
"the",
"request",
"Has",
"a",
"fluent",
"api",
"for",
"method",
"chaining"
] | train | https://github.com/timols/java-gitlab-api/blob/f03eedf952cfbb40306be3bf9234dcf78fab029e/src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java#L108-L113 |
Azure/azure-sdk-for-java | eventgrid/resource-manager/v2018_05_01_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_05_01_preview/implementation/EventSubscriptionsInner.java | EventSubscriptionsInner.beginDelete | public void beginDelete(String scope, String eventSubscriptionName) {
"""
Delete an event subscription.
Delete an existing event subscription.
@param scope The scope of the event subscription. The scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' for an EventGrid topic.
@param eventSubscriptionName Name of the event subscription
@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
"""
beginDeleteWithServiceResponseAsync(scope, eventSubscriptionName).toBlocking().single().body();
} | java | public void beginDelete(String scope, String eventSubscriptionName) {
beginDeleteWithServiceResponseAsync(scope, eventSubscriptionName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"scope",
",",
"String",
"eventSubscriptionName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"scope",
",",
"eventSubscriptionName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Delete an event subscription.
Delete an existing event subscription.
@param scope The scope of the event subscription. The scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' for an EventGrid topic.
@param eventSubscriptionName Name of the event subscription
@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 | [
"Delete",
"an",
"event",
"subscription",
".",
"Delete",
"an",
"existing",
"event",
"subscription",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2018_05_01_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_05_01_preview/implementation/EventSubscriptionsInner.java#L475-L477 |
brianwhu/xillium | data/src/main/java/org/xillium/data/persistence/Persistence.java | Persistence.doReadWrite | public <T, F> T doReadWrite(F facility, Task<T, F> task) {
"""
Executes a task within a read-write transaction. Any exception rolls back the transaction and gets rethrown as a RuntimeException.
"""
return doTransaction(facility, task, null);
} | java | public <T, F> T doReadWrite(F facility, Task<T, F> task) {
return doTransaction(facility, task, null);
} | [
"public",
"<",
"T",
",",
"F",
">",
"T",
"doReadWrite",
"(",
"F",
"facility",
",",
"Task",
"<",
"T",
",",
"F",
">",
"task",
")",
"{",
"return",
"doTransaction",
"(",
"facility",
",",
"task",
",",
"null",
")",
";",
"}"
] | Executes a task within a read-write transaction. Any exception rolls back the transaction and gets rethrown as a RuntimeException. | [
"Executes",
"a",
"task",
"within",
"a",
"read",
"-",
"write",
"transaction",
".",
"Any",
"exception",
"rolls",
"back",
"the",
"transaction",
"and",
"gets",
"rethrown",
"as",
"a",
"RuntimeException",
"."
] | train | https://github.com/brianwhu/xillium/blob/e8dbf8cb6589fa1031a0bfcdcb58cb03d2ba7799/data/src/main/java/org/xillium/data/persistence/Persistence.java#L43-L45 |
TestFX/Monocle | src/main/java/com/sun/glass/ui/monocle/MonocleDnDClipboard.java | MonocleDnDClipboard.pushToSystem | @Override
protected void pushToSystem(HashMap<String, Object> cacheData, int supportedActions) {
"""
Here the magic happens.
When this method is called all input events should be grabbed and
appropriate drag notifications should be sent instead of regular input
events
"""
MouseInput.getInstance().notifyDragStart();
((MonocleApplication) Application.GetApplication()).enterDnDEventLoop();
actionPerformed(Clipboard.ACTION_COPY_OR_MOVE);
} | java | @Override
protected void pushToSystem(HashMap<String, Object> cacheData, int supportedActions) {
MouseInput.getInstance().notifyDragStart();
((MonocleApplication) Application.GetApplication()).enterDnDEventLoop();
actionPerformed(Clipboard.ACTION_COPY_OR_MOVE);
} | [
"@",
"Override",
"protected",
"void",
"pushToSystem",
"(",
"HashMap",
"<",
"String",
",",
"Object",
">",
"cacheData",
",",
"int",
"supportedActions",
")",
"{",
"MouseInput",
".",
"getInstance",
"(",
")",
".",
"notifyDragStart",
"(",
")",
";",
"(",
"(",
"MonocleApplication",
")",
"Application",
".",
"GetApplication",
"(",
")",
")",
".",
"enterDnDEventLoop",
"(",
")",
";",
"actionPerformed",
"(",
"Clipboard",
".",
"ACTION_COPY_OR_MOVE",
")",
";",
"}"
] | Here the magic happens.
When this method is called all input events should be grabbed and
appropriate drag notifications should be sent instead of regular input
events | [
"Here",
"the",
"magic",
"happens",
".",
"When",
"this",
"method",
"is",
"called",
"all",
"input",
"events",
"should",
"be",
"grabbed",
"and",
"appropriate",
"drag",
"notifications",
"should",
"be",
"sent",
"instead",
"of",
"regular",
"input",
"events"
] | train | https://github.com/TestFX/Monocle/blob/267ccba8889cab244bf8c562dbaa0345a612874c/src/main/java/com/sun/glass/ui/monocle/MonocleDnDClipboard.java#L51-L56 |
groovy/groovy-core | src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.splitEachLine | public static <T> T splitEachLine(Reader self, String regex, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException {
"""
Iterates through the given reader line by line, splitting each line using
the given regex separator. For each line, the given closure is called with
a single parameter being the list of strings computed by splitting the line
around matches of the given regular expression. The Reader is closed afterwards.
<p>
Here is an example:
<pre>
def s = 'The 3 quick\nbrown 4 fox'
def result = ''
new StringReader(s).splitEachLine(/\d/){ parts ->
result += "${parts[0]}_${parts[1]}|"
}
assert result == 'The _ quick|brown _ fox|'
</pre>
@param self a Reader, closed after the method returns
@param regex the delimiting regular expression
@param closure a closure
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see java.lang.String#split(java.lang.String)
@since 1.5.5
"""
return splitEachLine(self, Pattern.compile(regex), closure);
} | java | public static <T> T splitEachLine(Reader self, String regex, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException {
return splitEachLine(self, Pattern.compile(regex), closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"splitEachLine",
"(",
"Reader",
"self",
",",
"String",
"regex",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FromString",
".",
"class",
",",
"options",
"=",
"\"List<String>\"",
")",
"Closure",
"<",
"T",
">",
"closure",
")",
"throws",
"IOException",
"{",
"return",
"splitEachLine",
"(",
"self",
",",
"Pattern",
".",
"compile",
"(",
"regex",
")",
",",
"closure",
")",
";",
"}"
] | Iterates through the given reader line by line, splitting each line using
the given regex separator. For each line, the given closure is called with
a single parameter being the list of strings computed by splitting the line
around matches of the given regular expression. The Reader is closed afterwards.
<p>
Here is an example:
<pre>
def s = 'The 3 quick\nbrown 4 fox'
def result = ''
new StringReader(s).splitEachLine(/\d/){ parts ->
result += "${parts[0]}_${parts[1]}|"
}
assert result == 'The _ quick|brown _ fox|'
</pre>
@param self a Reader, closed after the method returns
@param regex the delimiting regular expression
@param closure a closure
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see java.lang.String#split(java.lang.String)
@since 1.5.5 | [
"Iterates",
"through",
"the",
"given",
"reader",
"line",
"by",
"line",
"splitting",
"each",
"line",
"using",
"the",
"given",
"regex",
"separator",
".",
"For",
"each",
"line",
"the",
"given",
"closure",
"is",
"called",
"with",
"a",
"single",
"parameter",
"being",
"the",
"list",
"of",
"strings",
"computed",
"by",
"splitting",
"the",
"line",
"around",
"matches",
"of",
"the",
"given",
"regular",
"expression",
".",
"The",
"Reader",
"is",
"closed",
"afterwards",
".",
"<p",
">",
"Here",
"is",
"an",
"example",
":",
"<pre",
">",
"def",
"s",
"=",
"The",
"3",
"quick",
"\\",
"nbrown",
"4",
"fox",
"def",
"result",
"=",
"new",
"StringReader",
"(",
"s",
")",
".",
"splitEachLine",
"(",
"/",
"\\",
"d",
"/",
")",
"{",
"parts",
"-",
">",
"result",
"+",
"=",
"$",
"{",
"parts",
"[",
"0",
"]",
"}",
"_$",
"{",
"parts",
"[",
"1",
"]",
"}",
"|",
"}",
"assert",
"result",
"==",
"The",
"_",
"quick|brown",
"_",
"fox|",
"<",
"/",
"pre",
">"
] | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java#L527-L529 |
bwkimmel/java-util | src/main/java/ca/eandb/util/io/FileUtil.java | FileUtil.setFileContents | public static void setFileContents(File file, ByteBuffer contents, boolean createDirectory) throws IOException {
"""
Writes the specified byte array to a file.
@param file The <code>File</code> to write.
@param contents The byte array to write to the file.
@param createDirectory A value indicating whether the directory
containing the file to be written should be created if it does
not exist.
@throws IOException If the file could not be written.
"""
if (createDirectory) {
File directory = file.getParentFile();
if (!directory.exists()) {
directory.mkdirs();
}
}
FileOutputStream stream = new FileOutputStream(file);
StreamUtil.writeBytes(contents, stream);
stream.close();
} | java | public static void setFileContents(File file, ByteBuffer contents, boolean createDirectory) throws IOException {
if (createDirectory) {
File directory = file.getParentFile();
if (!directory.exists()) {
directory.mkdirs();
}
}
FileOutputStream stream = new FileOutputStream(file);
StreamUtil.writeBytes(contents, stream);
stream.close();
} | [
"public",
"static",
"void",
"setFileContents",
"(",
"File",
"file",
",",
"ByteBuffer",
"contents",
",",
"boolean",
"createDirectory",
")",
"throws",
"IOException",
"{",
"if",
"(",
"createDirectory",
")",
"{",
"File",
"directory",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"directory",
".",
"mkdirs",
"(",
")",
";",
"}",
"}",
"FileOutputStream",
"stream",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"StreamUtil",
".",
"writeBytes",
"(",
"contents",
",",
"stream",
")",
";",
"stream",
".",
"close",
"(",
")",
";",
"}"
] | Writes the specified byte array to a file.
@param file The <code>File</code> to write.
@param contents The byte array to write to the file.
@param createDirectory A value indicating whether the directory
containing the file to be written should be created if it does
not exist.
@throws IOException If the file could not be written. | [
"Writes",
"the",
"specified",
"byte",
"array",
"to",
"a",
"file",
"."
] | train | https://github.com/bwkimmel/java-util/blob/0c03664d42f0e6b111f64447f222aa73c2819e5c/src/main/java/ca/eandb/util/io/FileUtil.java#L142-L153 |
AltBeacon/android-beacon-library | lib/src/main/java/org/altbeacon/beacon/Beacon.java | Beacon.writeToParcel | @Deprecated
public void writeToParcel(Parcel out, int flags) {
"""
Required for making object Parcelable. If you override this class, you must override this
method if you add any additional fields.
"""
out.writeInt(mIdentifiers.size());
for (Identifier identifier: mIdentifiers) {
out.writeString(identifier == null ? null : identifier.toString());
}
out.writeDouble(getDistance());
out.writeInt(mRssi);
out.writeInt(mTxPower);
out.writeString(mBluetoothAddress);
out.writeInt(mBeaconTypeCode);
out.writeInt(mServiceUuid);
out.writeInt(mDataFields.size());
for (Long dataField: mDataFields) {
out.writeLong(dataField);
}
out.writeInt(mExtraDataFields.size());
for (Long dataField: mExtraDataFields) {
out.writeLong(dataField);
}
out.writeInt(mManufacturer);
out.writeString(mBluetoothName);
out.writeString(mParserIdentifier);
out.writeByte((byte) (mMultiFrameBeacon ? 1: 0));
out.writeValue(mRunningAverageRssi);
out.writeInt(mRssiMeasurementCount);
out.writeInt(mPacketCount);
} | java | @Deprecated
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mIdentifiers.size());
for (Identifier identifier: mIdentifiers) {
out.writeString(identifier == null ? null : identifier.toString());
}
out.writeDouble(getDistance());
out.writeInt(mRssi);
out.writeInt(mTxPower);
out.writeString(mBluetoothAddress);
out.writeInt(mBeaconTypeCode);
out.writeInt(mServiceUuid);
out.writeInt(mDataFields.size());
for (Long dataField: mDataFields) {
out.writeLong(dataField);
}
out.writeInt(mExtraDataFields.size());
for (Long dataField: mExtraDataFields) {
out.writeLong(dataField);
}
out.writeInt(mManufacturer);
out.writeString(mBluetoothName);
out.writeString(mParserIdentifier);
out.writeByte((byte) (mMultiFrameBeacon ? 1: 0));
out.writeValue(mRunningAverageRssi);
out.writeInt(mRssiMeasurementCount);
out.writeInt(mPacketCount);
} | [
"@",
"Deprecated",
"public",
"void",
"writeToParcel",
"(",
"Parcel",
"out",
",",
"int",
"flags",
")",
"{",
"out",
".",
"writeInt",
"(",
"mIdentifiers",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Identifier",
"identifier",
":",
"mIdentifiers",
")",
"{",
"out",
".",
"writeString",
"(",
"identifier",
"==",
"null",
"?",
"null",
":",
"identifier",
".",
"toString",
"(",
")",
")",
";",
"}",
"out",
".",
"writeDouble",
"(",
"getDistance",
"(",
")",
")",
";",
"out",
".",
"writeInt",
"(",
"mRssi",
")",
";",
"out",
".",
"writeInt",
"(",
"mTxPower",
")",
";",
"out",
".",
"writeString",
"(",
"mBluetoothAddress",
")",
";",
"out",
".",
"writeInt",
"(",
"mBeaconTypeCode",
")",
";",
"out",
".",
"writeInt",
"(",
"mServiceUuid",
")",
";",
"out",
".",
"writeInt",
"(",
"mDataFields",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Long",
"dataField",
":",
"mDataFields",
")",
"{",
"out",
".",
"writeLong",
"(",
"dataField",
")",
";",
"}",
"out",
".",
"writeInt",
"(",
"mExtraDataFields",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Long",
"dataField",
":",
"mExtraDataFields",
")",
"{",
"out",
".",
"writeLong",
"(",
"dataField",
")",
";",
"}",
"out",
".",
"writeInt",
"(",
"mManufacturer",
")",
";",
"out",
".",
"writeString",
"(",
"mBluetoothName",
")",
";",
"out",
".",
"writeString",
"(",
"mParserIdentifier",
")",
";",
"out",
".",
"writeByte",
"(",
"(",
"byte",
")",
"(",
"mMultiFrameBeacon",
"?",
"1",
":",
"0",
")",
")",
";",
"out",
".",
"writeValue",
"(",
"mRunningAverageRssi",
")",
";",
"out",
".",
"writeInt",
"(",
"mRssiMeasurementCount",
")",
";",
"out",
".",
"writeInt",
"(",
"mPacketCount",
")",
";",
"}"
] | Required for making object Parcelable. If you override this class, you must override this
method if you add any additional fields. | [
"Required",
"for",
"making",
"object",
"Parcelable",
".",
"If",
"you",
"override",
"this",
"class",
"you",
"must",
"override",
"this",
"method",
"if",
"you",
"add",
"any",
"additional",
"fields",
"."
] | train | https://github.com/AltBeacon/android-beacon-library/blob/f7f3a323ea7415d53e7bd695ff6a01f1501d5dc3/lib/src/main/java/org/altbeacon/beacon/Beacon.java#L612-L639 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/AbstractAttributeDefinitionBuilder.java | AbstractAttributeDefinitionBuilder.setDeprecated | public BUILDER setDeprecated(ModelVersion since, boolean notificationUseful) {
"""
Marks the attribute as deprecated since the given API version, with the ability to configure that
notifications to the user (e.g. via a log message) about deprecation of the attribute should not be emitted.
Notifying the user should only be done if the user can take some action in response. Advising that
something will be removed in a later release is not useful if there is no alternative in the
current release. If the {@code notificationUseful} param is {@code true} the text
description of the attribute deprecation available from the {@code read-resource-description}
management operation should provide useful information about how the user can avoid using
the attribute.
@param since the API version, with the API being the one (core or a subsystem) in which the attribute is used
@param notificationUseful whether actively advising the user about the deprecation is useful
@return a builder that can be used to continue building the attribute definition
"""
//noinspection deprecation
this.deprecated = new DeprecationData(since, notificationUseful);
return (BUILDER) this;
} | java | public BUILDER setDeprecated(ModelVersion since, boolean notificationUseful) {
//noinspection deprecation
this.deprecated = new DeprecationData(since, notificationUseful);
return (BUILDER) this;
} | [
"public",
"BUILDER",
"setDeprecated",
"(",
"ModelVersion",
"since",
",",
"boolean",
"notificationUseful",
")",
"{",
"//noinspection deprecation",
"this",
".",
"deprecated",
"=",
"new",
"DeprecationData",
"(",
"since",
",",
"notificationUseful",
")",
";",
"return",
"(",
"BUILDER",
")",
"this",
";",
"}"
] | Marks the attribute as deprecated since the given API version, with the ability to configure that
notifications to the user (e.g. via a log message) about deprecation of the attribute should not be emitted.
Notifying the user should only be done if the user can take some action in response. Advising that
something will be removed in a later release is not useful if there is no alternative in the
current release. If the {@code notificationUseful} param is {@code true} the text
description of the attribute deprecation available from the {@code read-resource-description}
management operation should provide useful information about how the user can avoid using
the attribute.
@param since the API version, with the API being the one (core or a subsystem) in which the attribute is used
@param notificationUseful whether actively advising the user about the deprecation is useful
@return a builder that can be used to continue building the attribute definition | [
"Marks",
"the",
"attribute",
"as",
"deprecated",
"since",
"the",
"given",
"API",
"version",
"with",
"the",
"ability",
"to",
"configure",
"that",
"notifications",
"to",
"the",
"user",
"(",
"e",
".",
"g",
".",
"via",
"a",
"log",
"message",
")",
"about",
"deprecation",
"of",
"the",
"attribute",
"should",
"not",
"be",
"emitted",
".",
"Notifying",
"the",
"user",
"should",
"only",
"be",
"done",
"if",
"the",
"user",
"can",
"take",
"some",
"action",
"in",
"response",
".",
"Advising",
"that",
"something",
"will",
"be",
"removed",
"in",
"a",
"later",
"release",
"is",
"not",
"useful",
"if",
"there",
"is",
"no",
"alternative",
"in",
"the",
"current",
"release",
".",
"If",
"the",
"{",
"@code",
"notificationUseful",
"}",
"param",
"is",
"{",
"@code",
"true",
"}",
"the",
"text",
"description",
"of",
"the",
"attribute",
"deprecation",
"available",
"from",
"the",
"{",
"@code",
"read",
"-",
"resource",
"-",
"description",
"}",
"management",
"operation",
"should",
"provide",
"useful",
"information",
"about",
"how",
"the",
"user",
"can",
"avoid",
"using",
"the",
"attribute",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/AbstractAttributeDefinitionBuilder.java#L713-L717 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/PlanNode.java | PlanNode.findAtOrBelow | public PlanNode findAtOrBelow( Type firstTypeToFind,
Type... additionalTypesToFind ) {
"""
Find the first node with one of the specified types that are at or below this node.
@param firstTypeToFind the first type of node to find; may not be null
@param additionalTypesToFind the additional types of node to find; may not be null
@return the first node that is at or below this node that has one of the supplied types; or null if there is no such node
"""
return findAtOrBelow(EnumSet.of(firstTypeToFind, additionalTypesToFind));
} | java | public PlanNode findAtOrBelow( Type firstTypeToFind,
Type... additionalTypesToFind ) {
return findAtOrBelow(EnumSet.of(firstTypeToFind, additionalTypesToFind));
} | [
"public",
"PlanNode",
"findAtOrBelow",
"(",
"Type",
"firstTypeToFind",
",",
"Type",
"...",
"additionalTypesToFind",
")",
"{",
"return",
"findAtOrBelow",
"(",
"EnumSet",
".",
"of",
"(",
"firstTypeToFind",
",",
"additionalTypesToFind",
")",
")",
";",
"}"
] | Find the first node with one of the specified types that are at or below this node.
@param firstTypeToFind the first type of node to find; may not be null
@param additionalTypesToFind the additional types of node to find; may not be null
@return the first node that is at or below this node that has one of the supplied types; or null if there is no such node | [
"Find",
"the",
"first",
"node",
"with",
"one",
"of",
"the",
"specified",
"types",
"that",
"are",
"at",
"or",
"below",
"this",
"node",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/plan/PlanNode.java#L1462-L1465 |
devnied/EMV-NFC-Paycard-Enrollment | library/src/main/java/com/github/devnied/emvnfccard/parser/impl/EmvParser.java | EmvParser.getGetProcessingOptions | protected byte[] getGetProcessingOptions(final byte[] pPdol) throws CommunicationException {
"""
Method used to create GPO command and execute it
@param pPdol
PDOL raw data
@return return data
@throws CommunicationException communication error
"""
// List Tag and length from PDOL
List<TagAndLength> list = TlvUtil.parseTagAndLength(pPdol);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
out.write(EmvTags.COMMAND_TEMPLATE.getTagBytes()); // COMMAND
// TEMPLATE
out.write(TlvUtil.getLength(list)); // ADD total length
if (list != null) {
for (TagAndLength tl : list) {
out.write(template.get().getTerminal().constructValue(tl));
}
}
} catch (IOException ioe) {
LOGGER.error("Construct GPO Command:" + ioe.getMessage(), ioe);
}
return template.get().getProvider().transceive(new CommandApdu(CommandEnum.GPO, out.toByteArray(), 0).toBytes());
} | java | protected byte[] getGetProcessingOptions(final byte[] pPdol) throws CommunicationException {
// List Tag and length from PDOL
List<TagAndLength> list = TlvUtil.parseTagAndLength(pPdol);
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
out.write(EmvTags.COMMAND_TEMPLATE.getTagBytes()); // COMMAND
// TEMPLATE
out.write(TlvUtil.getLength(list)); // ADD total length
if (list != null) {
for (TagAndLength tl : list) {
out.write(template.get().getTerminal().constructValue(tl));
}
}
} catch (IOException ioe) {
LOGGER.error("Construct GPO Command:" + ioe.getMessage(), ioe);
}
return template.get().getProvider().transceive(new CommandApdu(CommandEnum.GPO, out.toByteArray(), 0).toBytes());
} | [
"protected",
"byte",
"[",
"]",
"getGetProcessingOptions",
"(",
"final",
"byte",
"[",
"]",
"pPdol",
")",
"throws",
"CommunicationException",
"{",
"// List Tag and length from PDOL",
"List",
"<",
"TagAndLength",
">",
"list",
"=",
"TlvUtil",
".",
"parseTagAndLength",
"(",
"pPdol",
")",
";",
"ByteArrayOutputStream",
"out",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"try",
"{",
"out",
".",
"write",
"(",
"EmvTags",
".",
"COMMAND_TEMPLATE",
".",
"getTagBytes",
"(",
")",
")",
";",
"// COMMAND",
"// TEMPLATE",
"out",
".",
"write",
"(",
"TlvUtil",
".",
"getLength",
"(",
"list",
")",
")",
";",
"// ADD total length",
"if",
"(",
"list",
"!=",
"null",
")",
"{",
"for",
"(",
"TagAndLength",
"tl",
":",
"list",
")",
"{",
"out",
".",
"write",
"(",
"template",
".",
"get",
"(",
")",
".",
"getTerminal",
"(",
")",
".",
"constructValue",
"(",
"tl",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"Construct GPO Command:\"",
"+",
"ioe",
".",
"getMessage",
"(",
")",
",",
"ioe",
")",
";",
"}",
"return",
"template",
".",
"get",
"(",
")",
".",
"getProvider",
"(",
")",
".",
"transceive",
"(",
"new",
"CommandApdu",
"(",
"CommandEnum",
".",
"GPO",
",",
"out",
".",
"toByteArray",
"(",
")",
",",
"0",
")",
".",
"toBytes",
"(",
")",
")",
";",
"}"
] | Method used to create GPO command and execute it
@param pPdol
PDOL raw data
@return return data
@throws CommunicationException communication error | [
"Method",
"used",
"to",
"create",
"GPO",
"command",
"and",
"execute",
"it"
] | train | https://github.com/devnied/EMV-NFC-Paycard-Enrollment/blob/bfbd3960708689154a7a75c8a9a934197d738a5b/library/src/main/java/com/github/devnied/emvnfccard/parser/impl/EmvParser.java#L275-L292 |
haifengl/smile | core/src/main/java/smile/feature/GAFeatureSelection.java | GAFeatureSelection.learn | public BitString[] learn(int size, int generation, ClassifierTrainer<double[]> trainer, ClassificationMeasure measure, double[][] x, int[] y, int k) {
"""
Genetic algorithm based feature selection for classification.
@param size the population size of Genetic Algorithm.
@param generation the maximum number of iterations.
@param trainer classifier trainer.
@param measure classification measure as the chromosome fitness measure.
@param x training instances.
@param y training labels.
@param k k-fold cross validation for the evaluation.
@return bit strings of last generation.
"""
if (size <= 0) {
throw new IllegalArgumentException("Invalid population size: " + size);
}
if (k < 2) {
throw new IllegalArgumentException("Invalid k-fold cross validation: " + k);
}
if (x.length != y.length) {
throw new IllegalArgumentException(String.format("The sizes of X and Y don't match: %d != %d", x.length, y.length));
}
int p = x[0].length;
ClassificationFitness fitness = new ClassificationFitness(trainer, measure, x, y, k);
BitString[] seeds = new BitString[size];
for (int i = 0; i < size; i++) {
seeds[i] = new BitString(p, fitness, crossover, crossoverRate, mutationRate);
}
GeneticAlgorithm<BitString> ga = new GeneticAlgorithm<>(seeds, selection);
ga.evolve(generation);
return seeds;
} | java | public BitString[] learn(int size, int generation, ClassifierTrainer<double[]> trainer, ClassificationMeasure measure, double[][] x, int[] y, int k) {
if (size <= 0) {
throw new IllegalArgumentException("Invalid population size: " + size);
}
if (k < 2) {
throw new IllegalArgumentException("Invalid k-fold cross validation: " + k);
}
if (x.length != y.length) {
throw new IllegalArgumentException(String.format("The sizes of X and Y don't match: %d != %d", x.length, y.length));
}
int p = x[0].length;
ClassificationFitness fitness = new ClassificationFitness(trainer, measure, x, y, k);
BitString[] seeds = new BitString[size];
for (int i = 0; i < size; i++) {
seeds[i] = new BitString(p, fitness, crossover, crossoverRate, mutationRate);
}
GeneticAlgorithm<BitString> ga = new GeneticAlgorithm<>(seeds, selection);
ga.evolve(generation);
return seeds;
} | [
"public",
"BitString",
"[",
"]",
"learn",
"(",
"int",
"size",
",",
"int",
"generation",
",",
"ClassifierTrainer",
"<",
"double",
"[",
"]",
">",
"trainer",
",",
"ClassificationMeasure",
"measure",
",",
"double",
"[",
"]",
"[",
"]",
"x",
",",
"int",
"[",
"]",
"y",
",",
"int",
"k",
")",
"{",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid population size: \"",
"+",
"size",
")",
";",
"}",
"if",
"(",
"k",
"<",
"2",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid k-fold cross validation: \"",
"+",
"k",
")",
";",
"}",
"if",
"(",
"x",
".",
"length",
"!=",
"y",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"The sizes of X and Y don't match: %d != %d\"",
",",
"x",
".",
"length",
",",
"y",
".",
"length",
")",
")",
";",
"}",
"int",
"p",
"=",
"x",
"[",
"0",
"]",
".",
"length",
";",
"ClassificationFitness",
"fitness",
"=",
"new",
"ClassificationFitness",
"(",
"trainer",
",",
"measure",
",",
"x",
",",
"y",
",",
"k",
")",
";",
"BitString",
"[",
"]",
"seeds",
"=",
"new",
"BitString",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"seeds",
"[",
"i",
"]",
"=",
"new",
"BitString",
"(",
"p",
",",
"fitness",
",",
"crossover",
",",
"crossoverRate",
",",
"mutationRate",
")",
";",
"}",
"GeneticAlgorithm",
"<",
"BitString",
">",
"ga",
"=",
"new",
"GeneticAlgorithm",
"<>",
"(",
"seeds",
",",
"selection",
")",
";",
"ga",
".",
"evolve",
"(",
"generation",
")",
";",
"return",
"seeds",
";",
"}"
] | Genetic algorithm based feature selection for classification.
@param size the population size of Genetic Algorithm.
@param generation the maximum number of iterations.
@param trainer classifier trainer.
@param measure classification measure as the chromosome fitness measure.
@param x training instances.
@param y training labels.
@param k k-fold cross validation for the evaluation.
@return bit strings of last generation. | [
"Genetic",
"algorithm",
"based",
"feature",
"selection",
"for",
"classification",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/feature/GAFeatureSelection.java#L107-L132 |
kazocsaba/matrix | src/main/java/hu/kazocsaba/math/matrix/MatrixFactory.java | MatrixFactory.createVector | public static Vector4 createVector(double x, double y, double z, double h) {
"""
Creates and initializes a new 4D column vector.
@param x the x coordinate of the new vector
@param y the y coordinate of the new vector
@param z the z coordinate of the new vector
@param h the h coordinate of the new vector
@return the new vector
"""
Vector4 v=new Vector4Impl();
v.setX(x);
v.setY(y);
v.setZ(z);
v.setH(h);
return v;
} | java | public static Vector4 createVector(double x, double y, double z, double h) {
Vector4 v=new Vector4Impl();
v.setX(x);
v.setY(y);
v.setZ(z);
v.setH(h);
return v;
} | [
"public",
"static",
"Vector4",
"createVector",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
",",
"double",
"h",
")",
"{",
"Vector4",
"v",
"=",
"new",
"Vector4Impl",
"(",
")",
";",
"v",
".",
"setX",
"(",
"x",
")",
";",
"v",
".",
"setY",
"(",
"y",
")",
";",
"v",
".",
"setZ",
"(",
"z",
")",
";",
"v",
".",
"setH",
"(",
"h",
")",
";",
"return",
"v",
";",
"}"
] | Creates and initializes a new 4D column vector.
@param x the x coordinate of the new vector
@param y the y coordinate of the new vector
@param z the z coordinate of the new vector
@param h the h coordinate of the new vector
@return the new vector | [
"Creates",
"and",
"initializes",
"a",
"new",
"4D",
"column",
"vector",
"."
] | train | https://github.com/kazocsaba/matrix/blob/018570db945fe616b25606fe605fa6e0c180ab5b/src/main/java/hu/kazocsaba/math/matrix/MatrixFactory.java#L58-L65 |
JakeWharton/ActionBarSherlock | actionbarsherlock/src/com/actionbarsherlock/widget/SearchView.java | SearchView.launchSuggestion | private boolean launchSuggestion(int position, int actionKey, String actionMsg) {
"""
Launches an intent based on a suggestion.
@param position The index of the suggestion to create the intent from.
@param actionKey The key code of the action key that was pressed,
or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
@param actionMsg The message for the action key that was pressed,
or <code>null</code> if none.
@return true if a successful launch, false if could not (e.g. bad position).
"""
Cursor c = mSuggestionsAdapter.getCursor();
if ((c != null) && c.moveToPosition(position)) {
Intent intent = createIntentFromSuggestion(c, actionKey, actionMsg);
// launch the intent
launchIntent(intent);
return true;
}
return false;
} | java | private boolean launchSuggestion(int position, int actionKey, String actionMsg) {
Cursor c = mSuggestionsAdapter.getCursor();
if ((c != null) && c.moveToPosition(position)) {
Intent intent = createIntentFromSuggestion(c, actionKey, actionMsg);
// launch the intent
launchIntent(intent);
return true;
}
return false;
} | [
"private",
"boolean",
"launchSuggestion",
"(",
"int",
"position",
",",
"int",
"actionKey",
",",
"String",
"actionMsg",
")",
"{",
"Cursor",
"c",
"=",
"mSuggestionsAdapter",
".",
"getCursor",
"(",
")",
";",
"if",
"(",
"(",
"c",
"!=",
"null",
")",
"&&",
"c",
".",
"moveToPosition",
"(",
"position",
")",
")",
"{",
"Intent",
"intent",
"=",
"createIntentFromSuggestion",
"(",
"c",
",",
"actionKey",
",",
"actionMsg",
")",
";",
"// launch the intent",
"launchIntent",
"(",
"intent",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Launches an intent based on a suggestion.
@param position The index of the suggestion to create the intent from.
@param actionKey The key code of the action key that was pressed,
or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
@param actionMsg The message for the action key that was pressed,
or <code>null</code> if none.
@return true if a successful launch, false if could not (e.g. bad position). | [
"Launches",
"an",
"intent",
"based",
"on",
"a",
"suggestion",
"."
] | train | https://github.com/JakeWharton/ActionBarSherlock/blob/2c71339e756bcc0b1424c4525680549ba3a2dc97/actionbarsherlock/src/com/actionbarsherlock/widget/SearchView.java#L1408-L1420 |
liyiorg/weixin-popular | src/main/java/weixin/popular/api/MessageAPI.java | MessageAPI.mediaUploadnews | public static Media mediaUploadnews(String access_token, List<Article> articles) {
"""
高级群发 构成 MassMPnewsMessage 对象的前置请求接口
@param access_token access_token
@param articles 图文信息 1-10 个
@return Media
"""
return MediaAPI.mediaUploadnews(access_token, articles);
} | java | public static Media mediaUploadnews(String access_token, List<Article> articles) {
return MediaAPI.mediaUploadnews(access_token, articles);
} | [
"public",
"static",
"Media",
"mediaUploadnews",
"(",
"String",
"access_token",
",",
"List",
"<",
"Article",
">",
"articles",
")",
"{",
"return",
"MediaAPI",
".",
"mediaUploadnews",
"(",
"access_token",
",",
"articles",
")",
";",
"}"
] | 高级群发 构成 MassMPnewsMessage 对象的前置请求接口
@param access_token access_token
@param articles 图文信息 1-10 个
@return Media | [
"高级群发",
"构成",
"MassMPnewsMessage",
"对象的前置请求接口"
] | train | https://github.com/liyiorg/weixin-popular/blob/c64255292d41463bdb671938feaabf42a335d82c/src/main/java/weixin/popular/api/MessageAPI.java#L101-L103 |
OpenTSDB/opentsdb | src/tsd/client/RemoteOracle.java | RemoteOracle.newSuggestBox | public static SuggestBox newSuggestBox(final String suggest_type,
final TextBoxBase textbox) {
"""
Factory method to use in order to get a {@link RemoteOracle} instance.
@param suggest_type The type of suggestion wanted.
@param textbox The text box to wrap to provide suggestions to.
"""
final RemoteOracle oracle = new RemoteOracle(suggest_type);
final SuggestBox box = new SuggestBox(oracle, textbox);
oracle.requester = box;
return box;
} | java | public static SuggestBox newSuggestBox(final String suggest_type,
final TextBoxBase textbox) {
final RemoteOracle oracle = new RemoteOracle(suggest_type);
final SuggestBox box = new SuggestBox(oracle, textbox);
oracle.requester = box;
return box;
} | [
"public",
"static",
"SuggestBox",
"newSuggestBox",
"(",
"final",
"String",
"suggest_type",
",",
"final",
"TextBoxBase",
"textbox",
")",
"{",
"final",
"RemoteOracle",
"oracle",
"=",
"new",
"RemoteOracle",
"(",
"suggest_type",
")",
";",
"final",
"SuggestBox",
"box",
"=",
"new",
"SuggestBox",
"(",
"oracle",
",",
"textbox",
")",
";",
"oracle",
".",
"requester",
"=",
"box",
";",
"return",
"box",
";",
"}"
] | Factory method to use in order to get a {@link RemoteOracle} instance.
@param suggest_type The type of suggestion wanted.
@param textbox The text box to wrap to provide suggestions to. | [
"Factory",
"method",
"to",
"use",
"in",
"order",
"to",
"get",
"a",
"{"
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/client/RemoteOracle.java#L83-L89 |
westnordost/osmapi | src/main/java/de/westnordost/osmapi/changesets/ChangesetsDao.java | ChangesetsDao.find | public void find(Handler<ChangesetInfo> handler, QueryChangesetsFilters filters) {
"""
Get a number of changesets that match the given filters.
@param handler The handler which is fed the incoming changeset infos
@param filters what to search for. I.e.
new QueryChangesetsFilters().byUser(123).onlyClosed()
@throws OsmAuthorizationException if not logged in
"""
String query = filters != null ? "?" + filters.toParamString() : "";
try
{
osm.makeAuthenticatedRequest(CHANGESET + "s" + query, null, new ChangesetParser(handler));
}
catch(OsmNotFoundException e)
{
// ok, we are done (ignore the exception)
}
} | java | public void find(Handler<ChangesetInfo> handler, QueryChangesetsFilters filters)
{
String query = filters != null ? "?" + filters.toParamString() : "";
try
{
osm.makeAuthenticatedRequest(CHANGESET + "s" + query, null, new ChangesetParser(handler));
}
catch(OsmNotFoundException e)
{
// ok, we are done (ignore the exception)
}
} | [
"public",
"void",
"find",
"(",
"Handler",
"<",
"ChangesetInfo",
">",
"handler",
",",
"QueryChangesetsFilters",
"filters",
")",
"{",
"String",
"query",
"=",
"filters",
"!=",
"null",
"?",
"\"?\"",
"+",
"filters",
".",
"toParamString",
"(",
")",
":",
"\"\"",
";",
"try",
"{",
"osm",
".",
"makeAuthenticatedRequest",
"(",
"CHANGESET",
"+",
"\"s\"",
"+",
"query",
",",
"null",
",",
"new",
"ChangesetParser",
"(",
"handler",
")",
")",
";",
"}",
"catch",
"(",
"OsmNotFoundException",
"e",
")",
"{",
"// ok, we are done (ignore the exception)\r",
"}",
"}"
] | Get a number of changesets that match the given filters.
@param handler The handler which is fed the incoming changeset infos
@param filters what to search for. I.e.
new QueryChangesetsFilters().byUser(123).onlyClosed()
@throws OsmAuthorizationException if not logged in | [
"Get",
"a",
"number",
"of",
"changesets",
"that",
"match",
"the",
"given",
"filters",
"."
] | train | https://github.com/westnordost/osmapi/blob/dda6978fd12e117d0cf17812bc22037f61e22c4b/src/main/java/de/westnordost/osmapi/changesets/ChangesetsDao.java#L57-L68 |
danidemi/jlubricant | jlubricant-embeddable-hsql/src/main/java/com/danidemi/jlubricant/embeddable/database/utils/DatasourceTemplate.java | DatasourceTemplate.queryForObject | public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws SQLException {
"""
Execute a query that return a single result obtained allowing the current row to be mapped through
the provided {@link RowMapper}.
@throws SQLException
"""
return (T) query(sql, rowMapper);
} | java | public <T> T queryForObject(String sql, RowMapper<T> rowMapper) throws SQLException {
return (T) query(sql, rowMapper);
} | [
"public",
"<",
"T",
">",
"T",
"queryForObject",
"(",
"String",
"sql",
",",
"RowMapper",
"<",
"T",
">",
"rowMapper",
")",
"throws",
"SQLException",
"{",
"return",
"(",
"T",
")",
"query",
"(",
"sql",
",",
"rowMapper",
")",
";",
"}"
] | Execute a query that return a single result obtained allowing the current row to be mapped through
the provided {@link RowMapper}.
@throws SQLException | [
"Execute",
"a",
"query",
"that",
"return",
"a",
"single",
"result",
"obtained",
"allowing",
"the",
"current",
"row",
"to",
"be",
"mapped",
"through",
"the",
"provided",
"{"
] | train | https://github.com/danidemi/jlubricant/blob/a9937c141c69ec34b768bd603b8093e496329b3a/jlubricant-embeddable-hsql/src/main/java/com/danidemi/jlubricant/embeddable/database/utils/DatasourceTemplate.java#L80-L82 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getLastToken | @Nullable
public static String getLastToken (@Nullable final String sStr, final char cSearch) {
"""
Get the last token from (and excluding) the separating character.
@param sStr
The string to search. May be <code>null</code>.
@param cSearch
The search character.
@return The passed string if no such separator token was found.
"""
final int nIndex = getLastIndexOf (sStr, cSearch);
return nIndex == StringHelper.STRING_NOT_FOUND ? sStr : sStr.substring (nIndex + 1);
} | java | @Nullable
public static String getLastToken (@Nullable final String sStr, final char cSearch)
{
final int nIndex = getLastIndexOf (sStr, cSearch);
return nIndex == StringHelper.STRING_NOT_FOUND ? sStr : sStr.substring (nIndex + 1);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getLastToken",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"final",
"char",
"cSearch",
")",
"{",
"final",
"int",
"nIndex",
"=",
"getLastIndexOf",
"(",
"sStr",
",",
"cSearch",
")",
";",
"return",
"nIndex",
"==",
"StringHelper",
".",
"STRING_NOT_FOUND",
"?",
"sStr",
":",
"sStr",
".",
"substring",
"(",
"nIndex",
"+",
"1",
")",
";",
"}"
] | Get the last token from (and excluding) the separating character.
@param sStr
The string to search. May be <code>null</code>.
@param cSearch
The search character.
@return The passed string if no such separator token was found. | [
"Get",
"the",
"last",
"token",
"from",
"(",
"and",
"excluding",
")",
"the",
"separating",
"character",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L5138-L5143 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/core/SessionUtil.java | SessionUtil.isPrefixEqual | static boolean isPrefixEqual(String aUrlStr, String bUrlStr)
throws MalformedURLException {
"""
Verify if two input urls have the same protocol, host, and port.
@param aUrlStr a source URL string
@param bUrlStr a target URL string
@return true if matched otherwise false
@throws MalformedURLException raises if a URL string is not valid.
"""
URL aUrl = new URL(aUrlStr);
URL bUrl = new URL(bUrlStr);
int aPort = aUrl.getPort();
int bPort = bUrl.getPort();
if (aPort == -1 && "https".equals(aUrl.getProtocol()))
{
// default port number for HTTPS
aPort = 443;
}
if (bPort == -1 && "https".equals(bUrl.getProtocol()))
{
// default port number for HTTPS
bPort = 443;
}
// no default port number for HTTP is supported.
return aUrl.getHost().equalsIgnoreCase(bUrl.getHost()) &&
aUrl.getProtocol().equalsIgnoreCase(bUrl.getProtocol()) &&
aPort == bPort;
} | java | static boolean isPrefixEqual(String aUrlStr, String bUrlStr)
throws MalformedURLException
{
URL aUrl = new URL(aUrlStr);
URL bUrl = new URL(bUrlStr);
int aPort = aUrl.getPort();
int bPort = bUrl.getPort();
if (aPort == -1 && "https".equals(aUrl.getProtocol()))
{
// default port number for HTTPS
aPort = 443;
}
if (bPort == -1 && "https".equals(bUrl.getProtocol()))
{
// default port number for HTTPS
bPort = 443;
}
// no default port number for HTTP is supported.
return aUrl.getHost().equalsIgnoreCase(bUrl.getHost()) &&
aUrl.getProtocol().equalsIgnoreCase(bUrl.getProtocol()) &&
aPort == bPort;
} | [
"static",
"boolean",
"isPrefixEqual",
"(",
"String",
"aUrlStr",
",",
"String",
"bUrlStr",
")",
"throws",
"MalformedURLException",
"{",
"URL",
"aUrl",
"=",
"new",
"URL",
"(",
"aUrlStr",
")",
";",
"URL",
"bUrl",
"=",
"new",
"URL",
"(",
"bUrlStr",
")",
";",
"int",
"aPort",
"=",
"aUrl",
".",
"getPort",
"(",
")",
";",
"int",
"bPort",
"=",
"bUrl",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"aPort",
"==",
"-",
"1",
"&&",
"\"https\"",
".",
"equals",
"(",
"aUrl",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"// default port number for HTTPS",
"aPort",
"=",
"443",
";",
"}",
"if",
"(",
"bPort",
"==",
"-",
"1",
"&&",
"\"https\"",
".",
"equals",
"(",
"bUrl",
".",
"getProtocol",
"(",
")",
")",
")",
"{",
"// default port number for HTTPS",
"bPort",
"=",
"443",
";",
"}",
"// no default port number for HTTP is supported.",
"return",
"aUrl",
".",
"getHost",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"bUrl",
".",
"getHost",
"(",
")",
")",
"&&",
"aUrl",
".",
"getProtocol",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"bUrl",
".",
"getProtocol",
"(",
")",
")",
"&&",
"aPort",
"==",
"bPort",
";",
"}"
] | Verify if two input urls have the same protocol, host, and port.
@param aUrlStr a source URL string
@param bUrlStr a target URL string
@return true if matched otherwise false
@throws MalformedURLException raises if a URL string is not valid. | [
"Verify",
"if",
"two",
"input",
"urls",
"have",
"the",
"same",
"protocol",
"host",
"and",
"port",
"."
] | train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/SessionUtil.java#L1401-L1422 |
sd4324530/fastweixin | src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java | OauthAPI.validToken | public boolean validToken(String token, String openid) {
"""
校验token是否合法有效
@param token token
@param openid 用户openid
@return 是否合法有效
"""
BeanUtil.requireNonNull(token, "token is null");
BeanUtil.requireNonNull(openid, "openid is null");
String url = BASE_API_URL + "sns/auth?access_token=" + token + "&openid=" + openid;
BaseResponse r = executeGet(url);
return isSuccess(r.getErrcode());
} | java | public boolean validToken(String token, String openid) {
BeanUtil.requireNonNull(token, "token is null");
BeanUtil.requireNonNull(openid, "openid is null");
String url = BASE_API_URL + "sns/auth?access_token=" + token + "&openid=" + openid;
BaseResponse r = executeGet(url);
return isSuccess(r.getErrcode());
} | [
"public",
"boolean",
"validToken",
"(",
"String",
"token",
",",
"String",
"openid",
")",
"{",
"BeanUtil",
".",
"requireNonNull",
"(",
"token",
",",
"\"token is null\"",
")",
";",
"BeanUtil",
".",
"requireNonNull",
"(",
"openid",
",",
"\"openid is null\"",
")",
";",
"String",
"url",
"=",
"BASE_API_URL",
"+",
"\"sns/auth?access_token=\"",
"+",
"token",
"+",
"\"&openid=\"",
"+",
"openid",
";",
"BaseResponse",
"r",
"=",
"executeGet",
"(",
"url",
")",
";",
"return",
"isSuccess",
"(",
"r",
".",
"getErrcode",
"(",
")",
")",
";",
"}"
] | 校验token是否合法有效
@param token token
@param openid 用户openid
@return 是否合法有效 | [
"校验token是否合法有效"
] | train | https://github.com/sd4324530/fastweixin/blob/6bc0a7abfa23aad0dbad4c3123a47a7fb53f3447/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java#L115-L121 |
OpenLiberty/open-liberty | dev/com.ibm.ws.mongo/src/com/ibm/ws/mongo/internal/MongoDBService.java | MongoDBService.modified | @Modified
protected void modified(ComponentContext context, Map<String, Object> props) throws Exception {
"""
Modify the DeclarativeService instance that corresponds to an <mongoDB>
configuration element. <p>
This method is only called if the <mogoDB> configuration element changes
and not the <mongo> configuration element. MongoDBService is deactivated
if <mongo> is changed, since the MongoService to deactivated.
@param context DeclarativeService defined/populated component context
@param props the Component Properties from ComponentContext.getProperties.
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Dictionary<String, Object> oldProps = cctx.get().getProperties();
Tr.debug(this, tc, "MongoDBService modified: jndiName: " + oldProps.get(JNDI_NAME) + " -> " + props.get(JNDI_NAME)
+ ", database: " + oldProps.get(DATABASE_NAME) + " -> " + props.get(DATABASE_NAME));
}
cctx.set(context);
// Assuming for now that all changes require an App recycle
if (!applications.isEmpty()) {
Set<String> members = new HashSet<String>(applications);
applications.removeAll(members);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(this, tc, "recycling applications: " + members);
appRecycleSvcRef.recycleApplications(members);
}
} | java | @Modified
protected void modified(ComponentContext context, Map<String, Object> props) throws Exception {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Dictionary<String, Object> oldProps = cctx.get().getProperties();
Tr.debug(this, tc, "MongoDBService modified: jndiName: " + oldProps.get(JNDI_NAME) + " -> " + props.get(JNDI_NAME)
+ ", database: " + oldProps.get(DATABASE_NAME) + " -> " + props.get(DATABASE_NAME));
}
cctx.set(context);
// Assuming for now that all changes require an App recycle
if (!applications.isEmpty()) {
Set<String> members = new HashSet<String>(applications);
applications.removeAll(members);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(this, tc, "recycling applications: " + members);
appRecycleSvcRef.recycleApplications(members);
}
} | [
"@",
"Modified",
"protected",
"void",
"modified",
"(",
"ComponentContext",
"context",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
")",
"throws",
"Exception",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Dictionary",
"<",
"String",
",",
"Object",
">",
"oldProps",
"=",
"cctx",
".",
"get",
"(",
")",
".",
"getProperties",
"(",
")",
";",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"MongoDBService modified: jndiName: \"",
"+",
"oldProps",
".",
"get",
"(",
"JNDI_NAME",
")",
"+",
"\" -> \"",
"+",
"props",
".",
"get",
"(",
"JNDI_NAME",
")",
"+",
"\", database: \"",
"+",
"oldProps",
".",
"get",
"(",
"DATABASE_NAME",
")",
"+",
"\" -> \"",
"+",
"props",
".",
"get",
"(",
"DATABASE_NAME",
")",
")",
";",
"}",
"cctx",
".",
"set",
"(",
"context",
")",
";",
"// Assuming for now that all changes require an App recycle",
"if",
"(",
"!",
"applications",
".",
"isEmpty",
"(",
")",
")",
"{",
"Set",
"<",
"String",
">",
"members",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"applications",
")",
";",
"applications",
".",
"removeAll",
"(",
"members",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"recycling applications: \"",
"+",
"members",
")",
";",
"appRecycleSvcRef",
".",
"recycleApplications",
"(",
"members",
")",
";",
"}",
"}"
] | Modify the DeclarativeService instance that corresponds to an <mongoDB>
configuration element. <p>
This method is only called if the <mogoDB> configuration element changes
and not the <mongo> configuration element. MongoDBService is deactivated
if <mongo> is changed, since the MongoService to deactivated.
@param context DeclarativeService defined/populated component context
@param props the Component Properties from ComponentContext.getProperties. | [
"Modify",
"the",
"DeclarativeService",
"instance",
"that",
"corresponds",
"to",
"an",
"<mongoDB",
">",
"configuration",
"element",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.mongo/src/com/ibm/ws/mongo/internal/MongoDBService.java#L184-L202 |
FINRAOS/JTAF-ExtWebDriver | src/main/java/org/finra/jtaf/ewd/properties/GUIHierarchyConcatenationProperties.java | GUIHierarchyConcatenationProperties.getPropertyValueAsList | public List<String> getPropertyValueAsList(String key, Object[] parameters) {
"""
Searches over the group of {@code GUIProperties} for a property list
corresponding to the given key.
@param key
key to be found
@param parameters
instances of the {@code String} literal <code>"{n}"</code> in
the retrieved value will be replaced by the {@code String}
representation of {@code params[n]}
@return the first property list found associated with a concatenation of
the given names
@throws MissingGUIPropertyException
"""
if (parameters != null && parameters.length > 0) {
String parameters2[] = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
if (parameter != null) {
parameters2[i] = String.valueOf(parameter);
}
}
return getPropertyValueAsList(new String[] { key }, parameters2);
} else {
return getPropertyValueAsList(key);
}
} | java | public List<String> getPropertyValueAsList(String key, Object[] parameters) {
if (parameters != null && parameters.length > 0) {
String parameters2[] = new String[parameters.length];
for (int i = 0; i < parameters.length; i++) {
Object parameter = parameters[i];
if (parameter != null) {
parameters2[i] = String.valueOf(parameter);
}
}
return getPropertyValueAsList(new String[] { key }, parameters2);
} else {
return getPropertyValueAsList(key);
}
} | [
"public",
"List",
"<",
"String",
">",
"getPropertyValueAsList",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"parameters",
")",
"{",
"if",
"(",
"parameters",
"!=",
"null",
"&&",
"parameters",
".",
"length",
">",
"0",
")",
"{",
"String",
"parameters2",
"[",
"]",
"=",
"new",
"String",
"[",
"parameters",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"Object",
"parameter",
"=",
"parameters",
"[",
"i",
"]",
";",
"if",
"(",
"parameter",
"!=",
"null",
")",
"{",
"parameters2",
"[",
"i",
"]",
"=",
"String",
".",
"valueOf",
"(",
"parameter",
")",
";",
"}",
"}",
"return",
"getPropertyValueAsList",
"(",
"new",
"String",
"[",
"]",
"{",
"key",
"}",
",",
"parameters2",
")",
";",
"}",
"else",
"{",
"return",
"getPropertyValueAsList",
"(",
"key",
")",
";",
"}",
"}"
] | Searches over the group of {@code GUIProperties} for a property list
corresponding to the given key.
@param key
key to be found
@param parameters
instances of the {@code String} literal <code>"{n}"</code> in
the retrieved value will be replaced by the {@code String}
representation of {@code params[n]}
@return the first property list found associated with a concatenation of
the given names
@throws MissingGUIPropertyException | [
"Searches",
"over",
"the",
"group",
"of",
"{",
"@code",
"GUIProperties",
"}",
"for",
"a",
"property",
"list",
"corresponding",
"to",
"the",
"given",
"key",
"."
] | train | https://github.com/FINRAOS/JTAF-ExtWebDriver/blob/78d646def1bf0904f79b19a81df0241e07f2c73a/src/main/java/org/finra/jtaf/ewd/properties/GUIHierarchyConcatenationProperties.java#L301-L314 |
sothawo/mapjfx | src/main/java/com/sothawo/mapjfx/MapView.java | JavaConnector.pointerMovedTo | public void pointerMovedTo(double lat, double lon) {
"""
called when the user has moved the pointer (mouse).
@param lat
new latitude value
@param lon
new longitude value
"""
final Coordinate coordinate = new Coordinate(lat, lon);
if (logger.isTraceEnabled()) {
logger.trace("JS reports pointer move {}", coordinate);
}
fireEvent(new MapViewEvent(MapViewEvent.MAP_POINTER_MOVED, coordinate));
} | java | public void pointerMovedTo(double lat, double lon) {
final Coordinate coordinate = new Coordinate(lat, lon);
if (logger.isTraceEnabled()) {
logger.trace("JS reports pointer move {}", coordinate);
}
fireEvent(new MapViewEvent(MapViewEvent.MAP_POINTER_MOVED, coordinate));
} | [
"public",
"void",
"pointerMovedTo",
"(",
"double",
"lat",
",",
"double",
"lon",
")",
"{",
"final",
"Coordinate",
"coordinate",
"=",
"new",
"Coordinate",
"(",
"lat",
",",
"lon",
")",
";",
"if",
"(",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"JS reports pointer move {}\"",
",",
"coordinate",
")",
";",
"}",
"fireEvent",
"(",
"new",
"MapViewEvent",
"(",
"MapViewEvent",
".",
"MAP_POINTER_MOVED",
",",
"coordinate",
")",
")",
";",
"}"
] | called when the user has moved the pointer (mouse).
@param lat
new latitude value
@param lon
new longitude value | [
"called",
"when",
"the",
"user",
"has",
"moved",
"the",
"pointer",
"(",
"mouse",
")",
"."
] | train | https://github.com/sothawo/mapjfx/blob/202091de492ab7a8b000c77efd833029f7f0ef92/src/main/java/com/sothawo/mapjfx/MapView.java#L1317-L1323 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/report/HHeadingScreen.java | HHeadingScreen.printDataStartForm | public void printDataStartForm(PrintWriter out, int iPrintOptions) {
"""
Output this screen using HTML.
@exception DBException File exception.
"""
if ((iPrintOptions & HtmlConstants.DETAIL_SCREEN) != 0)
out.println("<tr>\n<td colspan=\"20\">");
out.println("<table border=\"0\" cellspacing=\"10\">\n<tr>");
} | java | public void printDataStartForm(PrintWriter out, int iPrintOptions)
{
if ((iPrintOptions & HtmlConstants.DETAIL_SCREEN) != 0)
out.println("<tr>\n<td colspan=\"20\">");
out.println("<table border=\"0\" cellspacing=\"10\">\n<tr>");
} | [
"public",
"void",
"printDataStartForm",
"(",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"if",
"(",
"(",
"iPrintOptions",
"&",
"HtmlConstants",
".",
"DETAIL_SCREEN",
")",
"!=",
"0",
")",
"out",
".",
"println",
"(",
"\"<tr>\\n<td colspan=\\\"20\\\">\"",
")",
";",
"out",
".",
"println",
"(",
"\"<table border=\\\"0\\\" cellspacing=\\\"10\\\">\\n<tr>\"",
")",
";",
"}"
] | Output this screen using HTML.
@exception DBException File exception. | [
"Output",
"this",
"screen",
"using",
"HTML",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/report/HHeadingScreen.java#L69-L74 |
albfernandez/itext2 | src/main/java/com/lowagie/text/pdf/PdfContentByte.java | PdfContentByte.moveTo | public void moveTo(float x, float y) {
"""
Move the current point <I>(x, y)</I>, omitting any connecting line segment.
@param x new x-coordinate
@param y new y-coordinate
"""
content.append(x).append(' ').append(y).append(" m").append_i(separator);
} | java | public void moveTo(float x, float y) {
content.append(x).append(' ').append(y).append(" m").append_i(separator);
} | [
"public",
"void",
"moveTo",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"content",
".",
"append",
"(",
"x",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"y",
")",
".",
"append",
"(",
"\" m\"",
")",
".",
"append_i",
"(",
"separator",
")",
";",
"}"
] | Move the current point <I>(x, y)</I>, omitting any connecting line segment.
@param x new x-coordinate
@param y new y-coordinate | [
"Move",
"the",
"current",
"point",
"<I",
">",
"(",
"x",
"y",
")",
"<",
"/",
"I",
">",
"omitting",
"any",
"connecting",
"line",
"segment",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/pdf/PdfContentByte.java#L702-L704 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbManagedConnectionImpl.java | WSRdbManagedConnectionImpl.afterCompletionRRS | @Override
public void afterCompletionRRS() {
"""
Invoked after completion of a z/OS RRS (Resource Recovery Services) global transaction.
"""
stateMgr.setStateNoValidate(WSStateManager.NO_TRANSACTION_ACTIVE);
// now reset the RRA internal flag as its the only place we can set it in the cases of unsharable connections.
// in the cases of shareable conections, the flag will be set to false twice (one here and another in cleanup, but that is ok)
setRrsGlobalTransactionReallyActive(false);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(this, tc, "Setting transaction state to NO_TRANSACTION_ACTIVE");
} | java | @Override
public void afterCompletionRRS() {
stateMgr.setStateNoValidate(WSStateManager.NO_TRANSACTION_ACTIVE);
// now reset the RRA internal flag as its the only place we can set it in the cases of unsharable connections.
// in the cases of shareable conections, the flag will be set to false twice (one here and another in cleanup, but that is ok)
setRrsGlobalTransactionReallyActive(false);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
Tr.debug(this, tc, "Setting transaction state to NO_TRANSACTION_ACTIVE");
} | [
"@",
"Override",
"public",
"void",
"afterCompletionRRS",
"(",
")",
"{",
"stateMgr",
".",
"setStateNoValidate",
"(",
"WSStateManager",
".",
"NO_TRANSACTION_ACTIVE",
")",
";",
"// now reset the RRA internal flag as its the only place we can set it in the cases of unsharable connections.",
"// in the cases of shareable conections, the flag will be set to false twice (one here and another in cleanup, but that is ok)",
"setRrsGlobalTransactionReallyActive",
"(",
"false",
")",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"Tr",
".",
"debug",
"(",
"this",
",",
"tc",
",",
"\"Setting transaction state to NO_TRANSACTION_ACTIVE\"",
")",
";",
"}"
] | Invoked after completion of a z/OS RRS (Resource Recovery Services) global transaction. | [
"Invoked",
"after",
"completion",
"of",
"a",
"z",
"/",
"OS",
"RRS",
"(",
"Resource",
"Recovery",
"Services",
")",
"global",
"transaction",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jdbc/src/com/ibm/ws/rsadapter/impl/WSRdbManagedConnectionImpl.java#L562-L570 |
liferay/com-liferay-commerce | commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationTemplatePersistenceImpl.java | CommerceNotificationTemplatePersistenceImpl.findAll | @Override
public List<CommerceNotificationTemplate> findAll() {
"""
Returns all the commerce notification templates.
@return the commerce notification templates
"""
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | java | @Override
public List<CommerceNotificationTemplate> findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceNotificationTemplate",
">",
"findAll",
"(",
")",
"{",
"return",
"findAll",
"(",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] | Returns all the commerce notification templates.
@return the commerce notification templates | [
"Returns",
"all",
"the",
"commerce",
"notification",
"templates",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-notification-service/src/main/java/com/liferay/commerce/notification/service/persistence/impl/CommerceNotificationTemplatePersistenceImpl.java#L5161-L5164 |
nguyenq/tess4j | src/main/java/net/sourceforge/tess4j/util/ImageHelper.java | ImageHelper.getSubImage | public static BufferedImage getSubImage(BufferedImage image, int x, int y, int width, int height) {
"""
A replacement for the standard <code>BufferedImage.getSubimage</code>
method.
@param image
@param x the X coordinate of the upper-left corner of the specified
rectangular region
@param y the Y coordinate of the upper-left corner of the specified
rectangular region
@param width the width of the specified rectangular region
@param height the height of the specified rectangular region
@return a BufferedImage that is the subimage of <code>image</code>.
"""
int type = (image.getTransparency() == Transparency.OPAQUE)
? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
BufferedImage tmp = new BufferedImage(width, height, type);
Graphics2D g2 = tmp.createGraphics();
g2.drawImage(image.getSubimage(x, y, width, height), 0, 0, null);
g2.dispose();
return tmp;
} | java | public static BufferedImage getSubImage(BufferedImage image, int x, int y, int width, int height) {
int type = (image.getTransparency() == Transparency.OPAQUE)
? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
BufferedImage tmp = new BufferedImage(width, height, type);
Graphics2D g2 = tmp.createGraphics();
g2.drawImage(image.getSubimage(x, y, width, height), 0, 0, null);
g2.dispose();
return tmp;
} | [
"public",
"static",
"BufferedImage",
"getSubImage",
"(",
"BufferedImage",
"image",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"int",
"type",
"=",
"(",
"image",
".",
"getTransparency",
"(",
")",
"==",
"Transparency",
".",
"OPAQUE",
")",
"?",
"BufferedImage",
".",
"TYPE_INT_RGB",
":",
"BufferedImage",
".",
"TYPE_INT_ARGB",
";",
"BufferedImage",
"tmp",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"type",
")",
";",
"Graphics2D",
"g2",
"=",
"tmp",
".",
"createGraphics",
"(",
")",
";",
"g2",
".",
"drawImage",
"(",
"image",
".",
"getSubimage",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
",",
"0",
",",
"0",
",",
"null",
")",
";",
"g2",
".",
"dispose",
"(",
")",
";",
"return",
"tmp",
";",
"}"
] | A replacement for the standard <code>BufferedImage.getSubimage</code>
method.
@param image
@param x the X coordinate of the upper-left corner of the specified
rectangular region
@param y the Y coordinate of the upper-left corner of the specified
rectangular region
@param width the width of the specified rectangular region
@param height the height of the specified rectangular region
@return a BufferedImage that is the subimage of <code>image</code>. | [
"A",
"replacement",
"for",
"the",
"standard",
"<code",
">",
"BufferedImage",
".",
"getSubimage<",
"/",
"code",
">",
"method",
"."
] | train | https://github.com/nguyenq/tess4j/blob/cfcd4a8a44042f150b4aaf7bdf5ffc485a2236e1/src/main/java/net/sourceforge/tess4j/util/ImageHelper.java#L85-L93 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java | ClusterControllerClient.listClusters | public final ListClustersPagedResponse listClusters(String projectId, String region) {
"""
Lists all regions/{region}/clusters in a project.
<p>Sample code:
<pre><code>
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
for (Cluster element : clusterControllerClient.listClusters(projectId, region).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
to.
@param region Required. The Cloud Dataproc region in which to handle the request.
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
ListClustersRequest request =
ListClustersRequest.newBuilder().setProjectId(projectId).setRegion(region).build();
return listClusters(request);
} | java | public final ListClustersPagedResponse listClusters(String projectId, String region) {
ListClustersRequest request =
ListClustersRequest.newBuilder().setProjectId(projectId).setRegion(region).build();
return listClusters(request);
} | [
"public",
"final",
"ListClustersPagedResponse",
"listClusters",
"(",
"String",
"projectId",
",",
"String",
"region",
")",
"{",
"ListClustersRequest",
"request",
"=",
"ListClustersRequest",
".",
"newBuilder",
"(",
")",
".",
"setProjectId",
"(",
"projectId",
")",
".",
"setRegion",
"(",
"region",
")",
".",
"build",
"(",
")",
";",
"return",
"listClusters",
"(",
"request",
")",
";",
"}"
] | Lists all regions/{region}/clusters in a project.
<p>Sample code:
<pre><code>
try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create()) {
String projectId = "";
String region = "";
for (Cluster element : clusterControllerClient.listClusters(projectId, region).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param projectId Required. The ID of the Google Cloud Platform project that the cluster belongs
to.
@param region Required. The Cloud Dataproc region in which to handle the request.
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Lists",
"all",
"regions",
"/",
"{",
"region",
"}",
"/",
"clusters",
"in",
"a",
"project",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/ClusterControllerClient.java#L678-L682 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRecordBrowser.java | LogRecordBrowser.restartRecordsInProcess | private OnePidRecordListImpl restartRecordsInProcess(final RepositoryLogRecord after, long max, final IInternalRecordFilter recFilter) {
"""
continue the list of the records after a record from another repository filtered with <code>recFilter</code>
"""
if (!(after instanceof RepositoryLogRecordImpl)) {
throw new IllegalArgumentException("Specified location does not belong to this repository.");
}
RepositoryLogRecordImpl real = (RepositoryLogRecordImpl)after;
File file = fileBrowser.findByMillis(real.getMillis());
// If record's time is not in our repository, take the first file
if (file == null) {
file = fileBrowser.findNext((File)null, max);
}
return new OnePidRecordListRecordImpl(file, real, max, recFilter);
} | java | private OnePidRecordListImpl restartRecordsInProcess(final RepositoryLogRecord after, long max, final IInternalRecordFilter recFilter) {
if (!(after instanceof RepositoryLogRecordImpl)) {
throw new IllegalArgumentException("Specified location does not belong to this repository.");
}
RepositoryLogRecordImpl real = (RepositoryLogRecordImpl)after;
File file = fileBrowser.findByMillis(real.getMillis());
// If record's time is not in our repository, take the first file
if (file == null) {
file = fileBrowser.findNext((File)null, max);
}
return new OnePidRecordListRecordImpl(file, real, max, recFilter);
} | [
"private",
"OnePidRecordListImpl",
"restartRecordsInProcess",
"(",
"final",
"RepositoryLogRecord",
"after",
",",
"long",
"max",
",",
"final",
"IInternalRecordFilter",
"recFilter",
")",
"{",
"if",
"(",
"!",
"(",
"after",
"instanceof",
"RepositoryLogRecordImpl",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Specified location does not belong to this repository.\"",
")",
";",
"}",
"RepositoryLogRecordImpl",
"real",
"=",
"(",
"RepositoryLogRecordImpl",
")",
"after",
";",
"File",
"file",
"=",
"fileBrowser",
".",
"findByMillis",
"(",
"real",
".",
"getMillis",
"(",
")",
")",
";",
"// If record's time is not in our repository, take the first file",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"file",
"=",
"fileBrowser",
".",
"findNext",
"(",
"(",
"File",
")",
"null",
",",
"max",
")",
";",
"}",
"return",
"new",
"OnePidRecordListRecordImpl",
"(",
"file",
",",
"real",
",",
"max",
",",
"recFilter",
")",
";",
"}"
] | continue the list of the records after a record from another repository filtered with <code>recFilter</code> | [
"continue",
"the",
"list",
"of",
"the",
"records",
"after",
"a",
"record",
"from",
"another",
"repository",
"filtered",
"with",
"<code",
">",
"recFilter<",
"/",
"code",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/impl/LogRecordBrowser.java#L180-L191 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/outbound/HttpOutboundServiceContextImpl.java | HttpOutboundServiceContextImpl.reConnect | protected void reConnect(VirtualConnection inVC, IOException ioe) {
"""
If an error occurs during an attempted write of an outgoing request
message, this method will either reconnect for another try or pass the
error up the channel chain.
@param inVC
@param ioe
"""
if (getLink().isReconnectAllowed()) {
// start the reconnect
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Attempting reconnect: " + getLink().getVirtualConnection());
}
// 359362 - null out the JIT read buffers
getTSC().getReadInterface().setBuffer(null);
getLink().reConnectAsync(ioe);
} else {
callErrorCallback(inVC, ioe);
}
} | java | protected void reConnect(VirtualConnection inVC, IOException ioe) {
if (getLink().isReconnectAllowed()) {
// start the reconnect
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Attempting reconnect: " + getLink().getVirtualConnection());
}
// 359362 - null out the JIT read buffers
getTSC().getReadInterface().setBuffer(null);
getLink().reConnectAsync(ioe);
} else {
callErrorCallback(inVC, ioe);
}
} | [
"protected",
"void",
"reConnect",
"(",
"VirtualConnection",
"inVC",
",",
"IOException",
"ioe",
")",
"{",
"if",
"(",
"getLink",
"(",
")",
".",
"isReconnectAllowed",
"(",
")",
")",
"{",
"// start the reconnect",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"debug",
"(",
"tc",
",",
"\"Attempting reconnect: \"",
"+",
"getLink",
"(",
")",
".",
"getVirtualConnection",
"(",
")",
")",
";",
"}",
"// 359362 - null out the JIT read buffers",
"getTSC",
"(",
")",
".",
"getReadInterface",
"(",
")",
".",
"setBuffer",
"(",
"null",
")",
";",
"getLink",
"(",
")",
".",
"reConnectAsync",
"(",
"ioe",
")",
";",
"}",
"else",
"{",
"callErrorCallback",
"(",
"inVC",
",",
"ioe",
")",
";",
"}",
"}"
] | If an error occurs during an attempted write of an outgoing request
message, this method will either reconnect for another try or pass the
error up the channel chain.
@param inVC
@param ioe | [
"If",
"an",
"error",
"occurs",
"during",
"an",
"attempted",
"write",
"of",
"an",
"outgoing",
"request",
"message",
"this",
"method",
"will",
"either",
"reconnect",
"for",
"another",
"try",
"or",
"pass",
"the",
"error",
"up",
"the",
"channel",
"chain",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/internal/outbound/HttpOutboundServiceContextImpl.java#L213-L226 |
nobuoka/android-lib-ZXingCaptureActivity | src/main/java/info/vividcode/android/zxing/CaptureActivityIntents.java | CaptureActivityIntents.setDecodeMode | public static void setDecodeMode(Intent intent, String scanMode) {
"""
Set barcode formats to scan for onto {@code Intent}.
@param intent Target intent.
@param scanMode Mode which specify set of barcode formats to scan for. Use one of
{@link Intents.Scan#PRODUCT_MODE}, {@link Intents.Scan#ONE_D_MODE},
{@link Intents.Scan#QR_CODE_MODE}, {@link Intents.Scan#DATA_MATRIX_MODE}.
"""
intent.putExtra(Intents.Scan.MODE, scanMode);
} | java | public static void setDecodeMode(Intent intent, String scanMode) {
intent.putExtra(Intents.Scan.MODE, scanMode);
} | [
"public",
"static",
"void",
"setDecodeMode",
"(",
"Intent",
"intent",
",",
"String",
"scanMode",
")",
"{",
"intent",
".",
"putExtra",
"(",
"Intents",
".",
"Scan",
".",
"MODE",
",",
"scanMode",
")",
";",
"}"
] | Set barcode formats to scan for onto {@code Intent}.
@param intent Target intent.
@param scanMode Mode which specify set of barcode formats to scan for. Use one of
{@link Intents.Scan#PRODUCT_MODE}, {@link Intents.Scan#ONE_D_MODE},
{@link Intents.Scan#QR_CODE_MODE}, {@link Intents.Scan#DATA_MATRIX_MODE}. | [
"Set",
"barcode",
"formats",
"to",
"scan",
"for",
"onto",
"{"
] | train | https://github.com/nobuoka/android-lib-ZXingCaptureActivity/blob/17aaa7cf75520d3f2e03db9796b7e8c1d1f1b1e6/src/main/java/info/vividcode/android/zxing/CaptureActivityIntents.java#L55-L57 |
beanshell/beanshell | src/main/java/bsh/org/objectweb/asm/MethodWriter.java | MethodWriter.visitFrameStart | int visitFrameStart(final int offset, final int nLocal, final int nStack) {
"""
Starts the visit of a new stack map frame, stored in {@link #currentFrame}.
@param offset the bytecode offset of the instruction to which the frame corresponds.
@param nLocal the number of local variables in the frame.
@param nStack the number of stack elements in the frame.
@return the index of the next element to be written in this frame.
"""
int frameLength = 3 + nLocal + nStack;
if (currentFrame == null || currentFrame.length < frameLength) {
currentFrame = new int[frameLength];
}
currentFrame[0] = offset;
currentFrame[1] = nLocal;
currentFrame[2] = nStack;
return 3;
} | java | int visitFrameStart(final int offset, final int nLocal, final int nStack) {
int frameLength = 3 + nLocal + nStack;
if (currentFrame == null || currentFrame.length < frameLength) {
currentFrame = new int[frameLength];
}
currentFrame[0] = offset;
currentFrame[1] = nLocal;
currentFrame[2] = nStack;
return 3;
} | [
"int",
"visitFrameStart",
"(",
"final",
"int",
"offset",
",",
"final",
"int",
"nLocal",
",",
"final",
"int",
"nStack",
")",
"{",
"int",
"frameLength",
"=",
"3",
"+",
"nLocal",
"+",
"nStack",
";",
"if",
"(",
"currentFrame",
"==",
"null",
"||",
"currentFrame",
".",
"length",
"<",
"frameLength",
")",
"{",
"currentFrame",
"=",
"new",
"int",
"[",
"frameLength",
"]",
";",
"}",
"currentFrame",
"[",
"0",
"]",
"=",
"offset",
";",
"currentFrame",
"[",
"1",
"]",
"=",
"nLocal",
";",
"currentFrame",
"[",
"2",
"]",
"=",
"nStack",
";",
"return",
"3",
";",
"}"
] | Starts the visit of a new stack map frame, stored in {@link #currentFrame}.
@param offset the bytecode offset of the instruction to which the frame corresponds.
@param nLocal the number of local variables in the frame.
@param nStack the number of stack elements in the frame.
@return the index of the next element to be written in this frame. | [
"Starts",
"the",
"visit",
"of",
"a",
"new",
"stack",
"map",
"frame",
"stored",
"in",
"{",
"@link",
"#currentFrame",
"}",
"."
] | train | https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/org/objectweb/asm/MethodWriter.java#L1607-L1616 |
jenkinsci/jenkins | core/src/main/java/hudson/init/InitStrategy.java | InitStrategy.listPluginArchives | public List<File> listPluginArchives(PluginManager pm) throws IOException {
"""
Returns the list of *.jpi, *.hpi and *.hpl to expand and load.
<p>
Normally we look at {@code $JENKINS_HOME/plugins/*.jpi} and *.hpi and *.hpl.
@return
never null but can be empty. The list can contain different versions of the same plugin,
and when that happens, Jenkins will ignore all but the first one in the list.
"""
List<File> r = new ArrayList<>();
// the ordering makes sure that during the debugging we get proper precedence among duplicates.
// for example, while doing "mvn jpi:run" or "mvn hpi:run" on a plugin that's bundled with Jenkins, we want to the
// *.jpl file to override the bundled jpi/hpi file.
getBundledPluginsFromProperty(r);
// similarly, we prefer *.jpi over *.hpi
listPluginFiles(pm, ".jpl", r); // linked plugin. for debugging.
listPluginFiles(pm, ".hpl", r); // linked plugin. for debugging. (for backward compatibility)
listPluginFiles(pm, ".jpi", r); // plugin jar file
listPluginFiles(pm, ".hpi", r); // plugin jar file (for backward compatibility)
return r;
} | java | public List<File> listPluginArchives(PluginManager pm) throws IOException {
List<File> r = new ArrayList<>();
// the ordering makes sure that during the debugging we get proper precedence among duplicates.
// for example, while doing "mvn jpi:run" or "mvn hpi:run" on a plugin that's bundled with Jenkins, we want to the
// *.jpl file to override the bundled jpi/hpi file.
getBundledPluginsFromProperty(r);
// similarly, we prefer *.jpi over *.hpi
listPluginFiles(pm, ".jpl", r); // linked plugin. for debugging.
listPluginFiles(pm, ".hpl", r); // linked plugin. for debugging. (for backward compatibility)
listPluginFiles(pm, ".jpi", r); // plugin jar file
listPluginFiles(pm, ".hpi", r); // plugin jar file (for backward compatibility)
return r;
} | [
"public",
"List",
"<",
"File",
">",
"listPluginArchives",
"(",
"PluginManager",
"pm",
")",
"throws",
"IOException",
"{",
"List",
"<",
"File",
">",
"r",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// the ordering makes sure that during the debugging we get proper precedence among duplicates.",
"// for example, while doing \"mvn jpi:run\" or \"mvn hpi:run\" on a plugin that's bundled with Jenkins, we want to the",
"// *.jpl file to override the bundled jpi/hpi file.",
"getBundledPluginsFromProperty",
"(",
"r",
")",
";",
"// similarly, we prefer *.jpi over *.hpi",
"listPluginFiles",
"(",
"pm",
",",
"\".jpl\"",
",",
"r",
")",
";",
"// linked plugin. for debugging.",
"listPluginFiles",
"(",
"pm",
",",
"\".hpl\"",
",",
"r",
")",
";",
"// linked plugin. for debugging. (for backward compatibility)",
"listPluginFiles",
"(",
"pm",
",",
"\".jpi\"",
",",
"r",
")",
";",
"// plugin jar file",
"listPluginFiles",
"(",
"pm",
",",
"\".hpi\"",
",",
"r",
")",
";",
"// plugin jar file (for backward compatibility)",
"return",
"r",
";",
"}"
] | Returns the list of *.jpi, *.hpi and *.hpl to expand and load.
<p>
Normally we look at {@code $JENKINS_HOME/plugins/*.jpi} and *.hpi and *.hpl.
@return
never null but can be empty. The list can contain different versions of the same plugin,
and when that happens, Jenkins will ignore all but the first one in the list. | [
"Returns",
"the",
"list",
"of",
"*",
".",
"jpi",
"*",
".",
"hpi",
"and",
"*",
".",
"hpl",
"to",
"expand",
"and",
"load",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/init/InitStrategy.java#L47-L62 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPreferences.java | CmsPreferences.buildSelectUpload | public String buildSelectUpload(String htmlAttributes) {
"""
Builds the html for the workplace start site select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the workplace start site select box
"""
List<String> options = new ArrayList<String>();
List<String> values = new ArrayList<String>();
int selectedIndex = 0;
int pos = 0;
UploadVariant currentVariant = getParamTabWpUploadVariant();
for (UploadVariant variant : UploadVariant.values()) {
values.add(variant.toString());
options.add(getUploadVariantMessage(variant));
if (variant.equals(currentVariant)) {
selectedIndex = pos;
}
pos++;
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
} | java | public String buildSelectUpload(String htmlAttributes) {
List<String> options = new ArrayList<String>();
List<String> values = new ArrayList<String>();
int selectedIndex = 0;
int pos = 0;
UploadVariant currentVariant = getParamTabWpUploadVariant();
for (UploadVariant variant : UploadVariant.values()) {
values.add(variant.toString());
options.add(getUploadVariantMessage(variant));
if (variant.equals(currentVariant)) {
selectedIndex = pos;
}
pos++;
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
} | [
"public",
"String",
"buildSelectUpload",
"(",
"String",
"htmlAttributes",
")",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"int",
"selectedIndex",
"=",
"0",
";",
"int",
"pos",
"=",
"0",
";",
"UploadVariant",
"currentVariant",
"=",
"getParamTabWpUploadVariant",
"(",
")",
";",
"for",
"(",
"UploadVariant",
"variant",
":",
"UploadVariant",
".",
"values",
"(",
")",
")",
"{",
"values",
".",
"add",
"(",
"variant",
".",
"toString",
"(",
")",
")",
";",
"options",
".",
"add",
"(",
"getUploadVariantMessage",
"(",
"variant",
")",
")",
";",
"if",
"(",
"variant",
".",
"equals",
"(",
"currentVariant",
")",
")",
"{",
"selectedIndex",
"=",
"pos",
";",
"}",
"pos",
"++",
";",
"}",
"return",
"buildSelect",
"(",
"htmlAttributes",
",",
"options",
",",
"values",
",",
"selectedIndex",
")",
";",
"}"
] | Builds the html for the workplace start site select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the workplace start site select box | [
"Builds",
"the",
"html",
"for",
"the",
"workplace",
"start",
"site",
"select",
"box",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPreferences.java#L962-L981 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java | SpdySessionHandler.issueStreamError | private void issueStreamError(ChannelHandlerContext ctx, int streamId, SpdyStreamStatus status) {
"""
/*
SPDY Stream Error Handling:
Upon a stream error, the endpoint must send a RST_STREAM frame which contains
the Stream-ID for the stream where the error occurred and the error getStatus which
caused the error.
After sending the RST_STREAM, the stream is closed to the sending endpoint.
Note: this is only called by the worker thread
"""
boolean fireChannelRead = !spdySession.isRemoteSideClosed(streamId);
ChannelPromise promise = ctx.newPromise();
removeStream(streamId, promise);
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status);
ctx.writeAndFlush(spdyRstStreamFrame, promise);
if (fireChannelRead) {
ctx.fireChannelRead(spdyRstStreamFrame);
}
} | java | private void issueStreamError(ChannelHandlerContext ctx, int streamId, SpdyStreamStatus status) {
boolean fireChannelRead = !spdySession.isRemoteSideClosed(streamId);
ChannelPromise promise = ctx.newPromise();
removeStream(streamId, promise);
SpdyRstStreamFrame spdyRstStreamFrame = new DefaultSpdyRstStreamFrame(streamId, status);
ctx.writeAndFlush(spdyRstStreamFrame, promise);
if (fireChannelRead) {
ctx.fireChannelRead(spdyRstStreamFrame);
}
} | [
"private",
"void",
"issueStreamError",
"(",
"ChannelHandlerContext",
"ctx",
",",
"int",
"streamId",
",",
"SpdyStreamStatus",
"status",
")",
"{",
"boolean",
"fireChannelRead",
"=",
"!",
"spdySession",
".",
"isRemoteSideClosed",
"(",
"streamId",
")",
";",
"ChannelPromise",
"promise",
"=",
"ctx",
".",
"newPromise",
"(",
")",
";",
"removeStream",
"(",
"streamId",
",",
"promise",
")",
";",
"SpdyRstStreamFrame",
"spdyRstStreamFrame",
"=",
"new",
"DefaultSpdyRstStreamFrame",
"(",
"streamId",
",",
"status",
")",
";",
"ctx",
".",
"writeAndFlush",
"(",
"spdyRstStreamFrame",
",",
"promise",
")",
";",
"if",
"(",
"fireChannelRead",
")",
"{",
"ctx",
".",
"fireChannelRead",
"(",
"spdyRstStreamFrame",
")",
";",
"}",
"}"
] | /*
SPDY Stream Error Handling:
Upon a stream error, the endpoint must send a RST_STREAM frame which contains
the Stream-ID for the stream where the error occurred and the error getStatus which
caused the error.
After sending the RST_STREAM, the stream is closed to the sending endpoint.
Note: this is only called by the worker thread | [
"/",
"*",
"SPDY",
"Stream",
"Error",
"Handling",
":"
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java#L677-L687 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/context/rule/ItemRule.java | ItemRule.addValue | public void addValue(Token[] tokens) {
"""
Adds the specified value to this List type item.
@param tokens an array of tokens
"""
if (type == null) {
type = ItemType.LIST;
}
if (!isListableType()) {
throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
}
if (tokensList == null) {
tokensList = new ArrayList<>();
}
tokensList.add(tokens);
} | java | public void addValue(Token[] tokens) {
if (type == null) {
type = ItemType.LIST;
}
if (!isListableType()) {
throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
}
if (tokensList == null) {
tokensList = new ArrayList<>();
}
tokensList.add(tokens);
} | [
"public",
"void",
"addValue",
"(",
"Token",
"[",
"]",
"tokens",
")",
"{",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"ItemType",
".",
"LIST",
";",
"}",
"if",
"(",
"!",
"isListableType",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The type of this item must be 'array', 'list' or 'set'\"",
")",
";",
"}",
"if",
"(",
"tokensList",
"==",
"null",
")",
"{",
"tokensList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"tokensList",
".",
"add",
"(",
"tokens",
")",
";",
"}"
] | Adds the specified value to this List type item.
@param tokens an array of tokens | [
"Adds",
"the",
"specified",
"value",
"to",
"this",
"List",
"type",
"item",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L324-L335 |
Azure/azure-sdk-for-java | batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/ExperimentsInner.java | ExperimentsInner.createAsync | public Observable<ExperimentInner> createAsync(String resourceGroupName, String workspaceName, String experimentName) {
"""
Creates an Experiment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param experimentName The name of the experiment. Experiment names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createWithServiceResponseAsync(resourceGroupName, workspaceName, experimentName).map(new Func1<ServiceResponse<ExperimentInner>, ExperimentInner>() {
@Override
public ExperimentInner call(ServiceResponse<ExperimentInner> response) {
return response.body();
}
});
} | java | public Observable<ExperimentInner> createAsync(String resourceGroupName, String workspaceName, String experimentName) {
return createWithServiceResponseAsync(resourceGroupName, workspaceName, experimentName).map(new Func1<ServiceResponse<ExperimentInner>, ExperimentInner>() {
@Override
public ExperimentInner call(ServiceResponse<ExperimentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExperimentInner",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"workspaceName",
",",
"String",
"experimentName",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"workspaceName",
",",
"experimentName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ExperimentInner",
">",
",",
"ExperimentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ExperimentInner",
"call",
"(",
"ServiceResponse",
"<",
"ExperimentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates an Experiment.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param workspaceName The name of the workspace. Workspace names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@param experimentName The name of the experiment. Experiment names can only contain a combination of alphanumeric characters along with dash (-) and underscore (_). The name must be from 1 through 64 characters long.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"an",
"Experiment",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batchai/resource-manager/v2018_05_01/src/main/java/com/microsoft/azure/management/batchai/v2018_05_01/implementation/ExperimentsInner.java#L383-L390 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/KunderaMetadataManager.java | KunderaMetadataManager.getMetamodel | public static MetamodelImpl getMetamodel(final KunderaMetadata kunderaMetadata, String... persistenceUnits) {
"""
Gets the metamodel.
@param persistenceUnits
the persistence units
@return the metamodel
"""
MetamodelImpl metamodel = null;
for (String pu : persistenceUnits)
{
metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(pu);
if (metamodel != null)
{
return metamodel;
}
}
// FIXME: I need to verify this why we need common entity metadata now!
// if (metamodel == null)
// {
// metamodel = (MetamodelImpl)
// kunderaMetadata.getApplicationMetadata().getMetamodel(
// Constants.COMMON_ENTITY_METADATAS);
// }
return metamodel;
} | java | public static MetamodelImpl getMetamodel(final KunderaMetadata kunderaMetadata, String... persistenceUnits)
{
MetamodelImpl metamodel = null;
for (String pu : persistenceUnits)
{
metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(pu);
if (metamodel != null)
{
return metamodel;
}
}
// FIXME: I need to verify this why we need common entity metadata now!
// if (metamodel == null)
// {
// metamodel = (MetamodelImpl)
// kunderaMetadata.getApplicationMetadata().getMetamodel(
// Constants.COMMON_ENTITY_METADATAS);
// }
return metamodel;
} | [
"public",
"static",
"MetamodelImpl",
"getMetamodel",
"(",
"final",
"KunderaMetadata",
"kunderaMetadata",
",",
"String",
"...",
"persistenceUnits",
")",
"{",
"MetamodelImpl",
"metamodel",
"=",
"null",
";",
"for",
"(",
"String",
"pu",
":",
"persistenceUnits",
")",
"{",
"metamodel",
"=",
"(",
"MetamodelImpl",
")",
"kunderaMetadata",
".",
"getApplicationMetadata",
"(",
")",
".",
"getMetamodel",
"(",
"pu",
")",
";",
"if",
"(",
"metamodel",
"!=",
"null",
")",
"{",
"return",
"metamodel",
";",
"}",
"}",
"// FIXME: I need to verify this why we need common entity metadata now!\r",
"// if (metamodel == null)\r",
"// {\r",
"// metamodel = (MetamodelImpl)\r",
"// kunderaMetadata.getApplicationMetadata().getMetamodel(\r",
"// Constants.COMMON_ENTITY_METADATAS);\r",
"// }\r",
"return",
"metamodel",
";",
"}"
] | Gets the metamodel.
@param persistenceUnits
the persistence units
@return the metamodel | [
"Gets",
"the",
"metamodel",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/metadata/KunderaMetadataManager.java#L79-L100 |
dita-ot/dita-ot | src/main/java/org/dita/dost/util/FileUtils.java | FileUtils.getRelativeUnixPath | @Deprecated
public static String getRelativeUnixPath(final String basePath, final String refPath) {
"""
Resolves a path reference against a base path.
@param basePath base path
@param refPath reference path
@return relative path using {@link Constants#UNIX_SEPARATOR} path separator
"""
return getRelativePath(basePath, refPath, UNIX_SEPARATOR);
} | java | @Deprecated
public static String getRelativeUnixPath(final String basePath, final String refPath) {
return getRelativePath(basePath, refPath, UNIX_SEPARATOR);
} | [
"@",
"Deprecated",
"public",
"static",
"String",
"getRelativeUnixPath",
"(",
"final",
"String",
"basePath",
",",
"final",
"String",
"refPath",
")",
"{",
"return",
"getRelativePath",
"(",
"basePath",
",",
"refPath",
",",
"UNIX_SEPARATOR",
")",
";",
"}"
] | Resolves a path reference against a base path.
@param basePath base path
@param refPath reference path
@return relative path using {@link Constants#UNIX_SEPARATOR} path separator | [
"Resolves",
"a",
"path",
"reference",
"against",
"a",
"base",
"path",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/util/FileUtils.java#L182-L185 |
Abnaxos/markdown-doclet | doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/argval/PredefinedArgumentValidators.java | PredefinedArgumentValidators.atLeast | public static ArgumentValidator atLeast(final int expectedMin) {
"""
Creates a {@link ArgumentValidator} which checks for _#arguments >= expectedMin_
@param expectedMin the minimum number of expected arguments
@return the MissingArgumentsValidator
"""
switch (expectedMin) {
case 0:
return ZERO_OR_MORE;
case 1:
return ONE_OR_MORE;
case 2:
return TWO_OR_MORE;
}
return atLeast(expectedMin, MessageFormat.format("{0}..*", expectedMin));
} | java | public static ArgumentValidator atLeast(final int expectedMin) {
switch (expectedMin) {
case 0:
return ZERO_OR_MORE;
case 1:
return ONE_OR_MORE;
case 2:
return TWO_OR_MORE;
}
return atLeast(expectedMin, MessageFormat.format("{0}..*", expectedMin));
} | [
"public",
"static",
"ArgumentValidator",
"atLeast",
"(",
"final",
"int",
"expectedMin",
")",
"{",
"switch",
"(",
"expectedMin",
")",
"{",
"case",
"0",
":",
"return",
"ZERO_OR_MORE",
";",
"case",
"1",
":",
"return",
"ONE_OR_MORE",
";",
"case",
"2",
":",
"return",
"TWO_OR_MORE",
";",
"}",
"return",
"atLeast",
"(",
"expectedMin",
",",
"MessageFormat",
".",
"format",
"(",
"\"{0}..*\"",
",",
"expectedMin",
")",
")",
";",
"}"
] | Creates a {@link ArgumentValidator} which checks for _#arguments >= expectedMin_
@param expectedMin the minimum number of expected arguments
@return the MissingArgumentsValidator | [
"Creates",
"a",
"{",
"@link",
"ArgumentValidator",
"}",
"which",
"checks",
"for",
"_#arguments",
">",
"=",
"expectedMin_"
] | train | https://github.com/Abnaxos/markdown-doclet/blob/e98a9630206fc9c8d813cf2349ff594be8630054/doclet/jdk8/src/main/java/ch/raffael/mddoclet/mdtaglet/argval/PredefinedArgumentValidators.java#L135-L145 |
EsotericSoftware/kryo | src/com/esotericsoftware/kryo/Kryo.java | Kryo.writeClass | public Registration writeClass (Output output, Class type) {
"""
Writes a class and returns its registration.
@param type May be null.
@return Will be null if type is null.
@see ClassResolver#writeClass(Output, Class)
"""
if (output == null) throw new IllegalArgumentException("output cannot be null.");
try {
return classResolver.writeClass(output, type);
} finally {
if (depth == 0 && autoReset) reset();
}
} | java | public Registration writeClass (Output output, Class type) {
if (output == null) throw new IllegalArgumentException("output cannot be null.");
try {
return classResolver.writeClass(output, type);
} finally {
if (depth == 0 && autoReset) reset();
}
} | [
"public",
"Registration",
"writeClass",
"(",
"Output",
"output",
",",
"Class",
"type",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"output cannot be null.\"",
")",
";",
"try",
"{",
"return",
"classResolver",
".",
"writeClass",
"(",
"output",
",",
"type",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"depth",
"==",
"0",
"&&",
"autoReset",
")",
"reset",
"(",
")",
";",
"}",
"}"
] | Writes a class and returns its registration.
@param type May be null.
@return Will be null if type is null.
@see ClassResolver#writeClass(Output, Class) | [
"Writes",
"a",
"class",
"and",
"returns",
"its",
"registration",
"."
] | train | https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/src/com/esotericsoftware/kryo/Kryo.java#L529-L536 |
alkacon/opencms-core | src/org/opencms/xml/containerpage/CmsXmlGroupContainerFactory.java | CmsXmlGroupContainerFactory.createDocument | public static CmsXmlGroupContainer createDocument(CmsObject cms, Locale locale, String modelUri)
throws CmsException {
"""
Create a new instance of an group container based on the given default content,
that will have all language nodes of the default content and ensures the presence of the given locale.<p>
The given encoding is used when marshalling the XML again later.<p>
@param cms the current users OpenCms content
@param locale the locale to generate the default content for
@param modelUri the absolute path to the group container file acting as model
@throws CmsException in case the model file is not found or not valid
@return the created group container
"""
// create the XML content
CmsXmlGroupContainer content = new CmsXmlGroupContainer(cms, locale, modelUri);
// call prepare for use content handler and return the result
return (CmsXmlGroupContainer)content.getHandler().prepareForUse(cms, content);
} | java | public static CmsXmlGroupContainer createDocument(CmsObject cms, Locale locale, String modelUri)
throws CmsException {
// create the XML content
CmsXmlGroupContainer content = new CmsXmlGroupContainer(cms, locale, modelUri);
// call prepare for use content handler and return the result
return (CmsXmlGroupContainer)content.getHandler().prepareForUse(cms, content);
} | [
"public",
"static",
"CmsXmlGroupContainer",
"createDocument",
"(",
"CmsObject",
"cms",
",",
"Locale",
"locale",
",",
"String",
"modelUri",
")",
"throws",
"CmsException",
"{",
"// create the XML content",
"CmsXmlGroupContainer",
"content",
"=",
"new",
"CmsXmlGroupContainer",
"(",
"cms",
",",
"locale",
",",
"modelUri",
")",
";",
"// call prepare for use content handler and return the result",
"return",
"(",
"CmsXmlGroupContainer",
")",
"content",
".",
"getHandler",
"(",
")",
".",
"prepareForUse",
"(",
"cms",
",",
"content",
")",
";",
"}"
] | Create a new instance of an group container based on the given default content,
that will have all language nodes of the default content and ensures the presence of the given locale.<p>
The given encoding is used when marshalling the XML again later.<p>
@param cms the current users OpenCms content
@param locale the locale to generate the default content for
@param modelUri the absolute path to the group container file acting as model
@throws CmsException in case the model file is not found or not valid
@return the created group container | [
"Create",
"a",
"new",
"instance",
"of",
"an",
"group",
"container",
"based",
"on",
"the",
"given",
"default",
"content",
"that",
"will",
"have",
"all",
"language",
"nodes",
"of",
"the",
"default",
"content",
"and",
"ensures",
"the",
"presence",
"of",
"the",
"given",
"locale",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/containerpage/CmsXmlGroupContainerFactory.java#L83-L90 |
rototor/pdfbox-graphics2d | src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java | PdfBoxGraphics2DFontTextDrawer.registerFont | @SuppressWarnings("WeakerAccess")
public void registerFont(String fontName, InputStream fontStream) throws IOException {
"""
Register a font. If possible, try to use a font file, i.e.
{@link #registerFont(String,File)}. This method will lead to the creation of
a temporary file which stores the font data.
@param fontName
the name of the font to use. If null, the name is taken from the
font.
@param fontStream
the input stream of the font. This file must be a ttf/otf file!
You have to close the stream outside, this method will not close
the stream.
"""
File fontFile = File.createTempFile("pdfboxgfx2dfont", ".ttf");
FileOutputStream out = new FileOutputStream(fontFile);
try {
IOUtils.copy(fontStream, out);
} finally {
out.close();
}
fontFile.deleteOnExit();
tempFiles.add(fontFile);
registerFont(fontName, fontFile);
} | java | @SuppressWarnings("WeakerAccess")
public void registerFont(String fontName, InputStream fontStream) throws IOException {
File fontFile = File.createTempFile("pdfboxgfx2dfont", ".ttf");
FileOutputStream out = new FileOutputStream(fontFile);
try {
IOUtils.copy(fontStream, out);
} finally {
out.close();
}
fontFile.deleteOnExit();
tempFiles.add(fontFile);
registerFont(fontName, fontFile);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"public",
"void",
"registerFont",
"(",
"String",
"fontName",
",",
"InputStream",
"fontStream",
")",
"throws",
"IOException",
"{",
"File",
"fontFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"pdfboxgfx2dfont\"",
",",
"\".ttf\"",
")",
";",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"fontFile",
")",
";",
"try",
"{",
"IOUtils",
".",
"copy",
"(",
"fontStream",
",",
"out",
")",
";",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"fontFile",
".",
"deleteOnExit",
"(",
")",
";",
"tempFiles",
".",
"add",
"(",
"fontFile",
")",
";",
"registerFont",
"(",
"fontName",
",",
"fontFile",
")",
";",
"}"
] | Register a font. If possible, try to use a font file, i.e.
{@link #registerFont(String,File)}. This method will lead to the creation of
a temporary file which stores the font data.
@param fontName
the name of the font to use. If null, the name is taken from the
font.
@param fontStream
the input stream of the font. This file must be a ttf/otf file!
You have to close the stream outside, this method will not close
the stream. | [
"Register",
"a",
"font",
".",
"If",
"possible",
"try",
"to",
"use",
"a",
"font",
"file",
"i",
".",
"e",
".",
"{",
"@link",
"#registerFont",
"(",
"String",
"File",
")",
"}",
".",
"This",
"method",
"will",
"lead",
"to",
"the",
"creation",
"of",
"a",
"temporary",
"file",
"which",
"stores",
"the",
"font",
"data",
"."
] | train | https://github.com/rototor/pdfbox-graphics2d/blob/86d53942cf2c137edca59d45766927c077f49230/src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2DFontTextDrawer.java#L82-L94 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java | CircularIndex.minusPOffset | public static int minusPOffset(int index, int offset, int size) {
"""
Subtracts a positive offset to index in a circular buffer.
@param index element in circular buffer
@param offset integer which is positive and less than size
@param size size of the circular buffer
@return new index
"""
index -= offset;
if( index < 0 ) {
return size + index;
} else {
return index;
}
} | java | public static int minusPOffset(int index, int offset, int size) {
index -= offset;
if( index < 0 ) {
return size + index;
} else {
return index;
}
} | [
"public",
"static",
"int",
"minusPOffset",
"(",
"int",
"index",
",",
"int",
"offset",
",",
"int",
"size",
")",
"{",
"index",
"-=",
"offset",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"size",
"+",
"index",
";",
"}",
"else",
"{",
"return",
"index",
";",
"}",
"}"
] | Subtracts a positive offset to index in a circular buffer.
@param index element in circular buffer
@param offset integer which is positive and less than size
@param size size of the circular buffer
@return new index | [
"Subtracts",
"a",
"positive",
"offset",
"to",
"index",
"in",
"a",
"circular",
"buffer",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java#L47-L54 |
nightcode/yaranga | core/src/org/nightcode/common/base/Splitter.java | Splitter.trim | public Splitter trim(char c) {
"""
Returns a splitter that removes all leading or trailing characters
matching the given character from each returned key and value.
@param c character
@return a splitter with the desired configuration
"""
Matcher matcher = new CharMatcher(c);
return new Splitter(pairSeparator, keyValueSeparator, matcher, matcher);
} | java | public Splitter trim(char c) {
Matcher matcher = new CharMatcher(c);
return new Splitter(pairSeparator, keyValueSeparator, matcher, matcher);
} | [
"public",
"Splitter",
"trim",
"(",
"char",
"c",
")",
"{",
"Matcher",
"matcher",
"=",
"new",
"CharMatcher",
"(",
"c",
")",
";",
"return",
"new",
"Splitter",
"(",
"pairSeparator",
",",
"keyValueSeparator",
",",
"matcher",
",",
"matcher",
")",
";",
"}"
] | Returns a splitter that removes all leading or trailing characters
matching the given character from each returned key and value.
@param c character
@return a splitter with the desired configuration | [
"Returns",
"a",
"splitter",
"that",
"removes",
"all",
"leading",
"or",
"trailing",
"characters",
"matching",
"the",
"given",
"character",
"from",
"each",
"returned",
"key",
"and",
"value",
"."
] | train | https://github.com/nightcode/yaranga/blob/f02cf8d8bcd365b6b1d55638938631a00e9ee808/core/src/org/nightcode/common/base/Splitter.java#L140-L143 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/base64/Base64.java | Base64.decodeFileToFile | public static void decodeFileToFile (@Nonnull final String aInFile, @Nonnull final File aOutFile) throws IOException {
"""
Reads <code>infile</code> and decodes it to <code>outfile</code>.
@param aInFile
Input file
@param aOutFile
Output file
@throws IOException
if there is an error
@since 2.2
"""
final byte [] decoded = decodeFromFile (aInFile);
try (final OutputStream out = FileHelper.getBufferedOutputStream (aOutFile))
{
out.write (decoded);
}
} | java | public static void decodeFileToFile (@Nonnull final String aInFile, @Nonnull final File aOutFile) throws IOException
{
final byte [] decoded = decodeFromFile (aInFile);
try (final OutputStream out = FileHelper.getBufferedOutputStream (aOutFile))
{
out.write (decoded);
}
} | [
"public",
"static",
"void",
"decodeFileToFile",
"(",
"@",
"Nonnull",
"final",
"String",
"aInFile",
",",
"@",
"Nonnull",
"final",
"File",
"aOutFile",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"[",
"]",
"decoded",
"=",
"decodeFromFile",
"(",
"aInFile",
")",
";",
"try",
"(",
"final",
"OutputStream",
"out",
"=",
"FileHelper",
".",
"getBufferedOutputStream",
"(",
"aOutFile",
")",
")",
"{",
"out",
".",
"write",
"(",
"decoded",
")",
";",
"}",
"}"
] | Reads <code>infile</code> and decodes it to <code>outfile</code>.
@param aInFile
Input file
@param aOutFile
Output file
@throws IOException
if there is an error
@since 2.2 | [
"Reads",
"<code",
">",
"infile<",
"/",
"code",
">",
"and",
"decodes",
"it",
"to",
"<code",
">",
"outfile<",
"/",
"code",
">",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/base64/Base64.java#L2519-L2526 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/component/slider2/Slider2Renderer.java | Slider2Renderer.decode | @Override
public void decode(FacesContext context, UIComponent component) {
"""
This methods receives and processes input made by the user. More specifically, it ckecks whether the
user has interacted with the current b:slider2. The default implementation simply stores
the input value in the list of submitted values. If the validation checks are passed,
the values in the <code>submittedValues</code> list are store in the backend bean.
@param context the FacesContext.
@param component the current b:slider2.
"""
Slider2 slider = (Slider2) component;
if (slider.isDisabled() || slider.isReadonly()) {
return;
}
decodeBehaviors(context, slider);
String clientId = slider.getClientId(context);
Number submittedValue = convert(component, Float.valueOf(getRequestParameter(context, clientId)));
if (submittedValue != null) {
slider.setSubmittedValue(submittedValue);
}
new AJAXRenderer().decode(context, component, clientId);
} | java | @Override
public void decode(FacesContext context, UIComponent component) {
Slider2 slider = (Slider2) component;
if (slider.isDisabled() || slider.isReadonly()) {
return;
}
decodeBehaviors(context, slider);
String clientId = slider.getClientId(context);
Number submittedValue = convert(component, Float.valueOf(getRequestParameter(context, clientId)));
if (submittedValue != null) {
slider.setSubmittedValue(submittedValue);
}
new AJAXRenderer().decode(context, component, clientId);
} | [
"@",
"Override",
"public",
"void",
"decode",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"{",
"Slider2",
"slider",
"=",
"(",
"Slider2",
")",
"component",
";",
"if",
"(",
"slider",
".",
"isDisabled",
"(",
")",
"||",
"slider",
".",
"isReadonly",
"(",
")",
")",
"{",
"return",
";",
"}",
"decodeBehaviors",
"(",
"context",
",",
"slider",
")",
";",
"String",
"clientId",
"=",
"slider",
".",
"getClientId",
"(",
"context",
")",
";",
"Number",
"submittedValue",
"=",
"convert",
"(",
"component",
",",
"Float",
".",
"valueOf",
"(",
"getRequestParameter",
"(",
"context",
",",
"clientId",
")",
")",
")",
";",
"if",
"(",
"submittedValue",
"!=",
"null",
")",
"{",
"slider",
".",
"setSubmittedValue",
"(",
"submittedValue",
")",
";",
"}",
"new",
"AJAXRenderer",
"(",
")",
".",
"decode",
"(",
"context",
",",
"component",
",",
"clientId",
")",
";",
"}"
] | This methods receives and processes input made by the user. More specifically, it ckecks whether the
user has interacted with the current b:slider2. The default implementation simply stores
the input value in the list of submitted values. If the validation checks are passed,
the values in the <code>submittedValues</code> list are store in the backend bean.
@param context the FacesContext.
@param component the current b:slider2. | [
"This",
"methods",
"receives",
"and",
"processes",
"input",
"made",
"by",
"the",
"user",
".",
"More",
"specifically",
"it",
"ckecks",
"whether",
"the",
"user",
"has",
"interacted",
"with",
"the",
"current",
"b",
":",
"slider2",
".",
"The",
"default",
"implementation",
"simply",
"stores",
"the",
"input",
"value",
"in",
"the",
"list",
"of",
"submitted",
"values",
".",
"If",
"the",
"validation",
"checks",
"are",
"passed",
"the",
"values",
"in",
"the",
"<code",
">",
"submittedValues<",
"/",
"code",
">",
"list",
"are",
"store",
"in",
"the",
"backend",
"bean",
"."
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/slider2/Slider2Renderer.java#L48-L65 |
Impetus/Kundera | src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/datahandler/CassandraDataHandlerBase.java | CassandraDataHandlerBase.prepareCounterColumn | private CounterColumn prepareCounterColumn(String value, byte[] name) {
"""
Prepare counter column.
@param value
the value
@param name
the name
@return the counter column
"""
CounterColumn counterColumn = new CounterColumn();
counterColumn.setName(name);
LongAccessor accessor = new LongAccessor();
counterColumn.setValue(accessor.fromString(LongAccessor.class, value));
return counterColumn;
} | java | private CounterColumn prepareCounterColumn(String value, byte[] name)
{
CounterColumn counterColumn = new CounterColumn();
counterColumn.setName(name);
LongAccessor accessor = new LongAccessor();
counterColumn.setValue(accessor.fromString(LongAccessor.class, value));
return counterColumn;
} | [
"private",
"CounterColumn",
"prepareCounterColumn",
"(",
"String",
"value",
",",
"byte",
"[",
"]",
"name",
")",
"{",
"CounterColumn",
"counterColumn",
"=",
"new",
"CounterColumn",
"(",
")",
";",
"counterColumn",
".",
"setName",
"(",
"name",
")",
";",
"LongAccessor",
"accessor",
"=",
"new",
"LongAccessor",
"(",
")",
";",
"counterColumn",
".",
"setValue",
"(",
"accessor",
".",
"fromString",
"(",
"LongAccessor",
".",
"class",
",",
"value",
")",
")",
";",
"return",
"counterColumn",
";",
"}"
] | Prepare counter column.
@param value
the value
@param name
the name
@return the counter column | [
"Prepare",
"counter",
"column",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/kundera-cassandra/cassandra-core/src/main/java/com/impetus/client/cassandra/datahandler/CassandraDataHandlerBase.java#L2167-L2174 |
Mozu/mozu-java | mozu-java-core/src/main/java/com/mozu/api/urls/platform/entitylists/ListViewUrl.java | ListViewUrl.getEntityListViewUrl | public static MozuUrl getEntityListViewUrl(String entityListFullName, String responseFields, String viewName) {
"""
Get Resource Url for GetEntityListView
@param entityListFullName The full name of the EntityList including namespace in name@nameSpace format
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param viewName The name for a view. Views are used to render data in , such as document and entity lists. Each view includes a schema, format, name, ID, and associated data types to render.
@return String Resource Url
"""
UrlFormatter formatter = new UrlFormatter("/api/platform/entitylists/{entityListFullName}/views/{viewName}?responseFields={responseFields}");
formatter.formatUrl("entityListFullName", entityListFullName);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("viewName", viewName);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | java | public static MozuUrl getEntityListViewUrl(String entityListFullName, String responseFields, String viewName)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/entitylists/{entityListFullName}/views/{viewName}?responseFields={responseFields}");
formatter.formatUrl("entityListFullName", entityListFullName);
formatter.formatUrl("responseFields", responseFields);
formatter.formatUrl("viewName", viewName);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
} | [
"public",
"static",
"MozuUrl",
"getEntityListViewUrl",
"(",
"String",
"entityListFullName",
",",
"String",
"responseFields",
",",
"String",
"viewName",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/platform/entitylists/{entityListFullName}/views/{viewName}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"entityListFullName\"",
",",
"entityListFullName",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"viewName\"",
",",
"viewName",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] | Get Resource Url for GetEntityListView
@param entityListFullName The full name of the EntityList including namespace in name@nameSpace format
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@param viewName The name for a view. Views are used to render data in , such as document and entity lists. Each view includes a schema, format, name, ID, and associated data types to render.
@return String Resource Url | [
"Get",
"Resource",
"Url",
"for",
"GetEntityListView"
] | train | https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-java-core/src/main/java/com/mozu/api/urls/platform/entitylists/ListViewUrl.java#L103-L110 |
shrinkwrap/shrinkwrap | impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/nio2/file/ShrinkWrapPath.java | ShrinkWrapPath.fromString | private Path fromString(final String path) {
"""
Creates a new {@link ShrinkWrapPath} instance from the specified input {@link String}
@param path
@return
"""
if (path == null) {
throw new IllegalArgumentException("path must be specified");
}
// Delegate
return new ShrinkWrapPath(path, fileSystem);
} | java | private Path fromString(final String path) {
if (path == null) {
throw new IllegalArgumentException("path must be specified");
}
// Delegate
return new ShrinkWrapPath(path, fileSystem);
} | [
"private",
"Path",
"fromString",
"(",
"final",
"String",
"path",
")",
"{",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"path must be specified\"",
")",
";",
"}",
"// Delegate",
"return",
"new",
"ShrinkWrapPath",
"(",
"path",
",",
"fileSystem",
")",
";",
"}"
] | Creates a new {@link ShrinkWrapPath} instance from the specified input {@link String}
@param path
@return | [
"Creates",
"a",
"new",
"{",
"@link",
"ShrinkWrapPath",
"}",
"instance",
"from",
"the",
"specified",
"input",
"{",
"@link",
"String",
"}"
] | train | https://github.com/shrinkwrap/shrinkwrap/blob/3f8a1a6d344651428c709a63ebb52d35343c5387/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/nio2/file/ShrinkWrapPath.java#L620-L626 |
ops4j/org.ops4j.base | ops4j-base-util/src/main/java/org/ops4j/util/i18n/Resources.java | Resources.getByte | public byte getByte( String key, byte defaultValue )
throws MissingResourceException {
"""
Retrieve a byte from bundle.
@param key the key of resource
@param defaultValue the default value if key is missing
@return the resource byte
@throws MissingResourceException if the requested key is unknown
"""
try
{
return getByte( key );
}
catch( MissingResourceException mre )
{
return defaultValue;
}
} | java | public byte getByte( String key, byte defaultValue )
throws MissingResourceException
{
try
{
return getByte( key );
}
catch( MissingResourceException mre )
{
return defaultValue;
}
} | [
"public",
"byte",
"getByte",
"(",
"String",
"key",
",",
"byte",
"defaultValue",
")",
"throws",
"MissingResourceException",
"{",
"try",
"{",
"return",
"getByte",
"(",
"key",
")",
";",
"}",
"catch",
"(",
"MissingResourceException",
"mre",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Retrieve a byte from bundle.
@param key the key of resource
@param defaultValue the default value if key is missing
@return the resource byte
@throws MissingResourceException if the requested key is unknown | [
"Retrieve",
"a",
"byte",
"from",
"bundle",
"."
] | train | https://github.com/ops4j/org.ops4j.base/blob/b0e742c0d9511f6b19ca64da2ebaf30b7a47256a/ops4j-base-util/src/main/java/org/ops4j/util/i18n/Resources.java#L176-L187 |
dwdyer/watchmaker | examples/src/java/main/org/uncommons/watchmaker/examples/monalisa/ProbabilitiesPanel.java | ProbabilitiesPanel.createEvolutionPipeline | public EvolutionaryOperator<List<ColouredPolygon>> createEvolutionPipeline(PolygonImageFactory factory,
Dimension canvasSize,
Random rng) {
"""
Construct the combination of evolutionary operators that will be used to evolve the
polygon-based images.
@param factory A source of polygons.
@param canvasSize The size of the target image.
@param rng A source of randomness.
@return A complex evolutionary operator constructed from simpler operators.
"""
List<EvolutionaryOperator<List<ColouredPolygon>>> operators
= new LinkedList<EvolutionaryOperator<List<ColouredPolygon>>>();
operators.add(new ListCrossover<ColouredPolygon>(new ConstantGenerator<Integer>(2),
crossOverControl.getNumberGenerator()));
operators.add(new RemovePolygonMutation(removePolygonControl.getNumberGenerator()));
operators.add(new MovePolygonMutation(movePolygonControl.getNumberGenerator()));
operators.add(new ListOperator<ColouredPolygon>(new RemoveVertexMutation(canvasSize,
removeVertexControl.getNumberGenerator())));
operators.add(new ListOperator<ColouredPolygon>(new AdjustVertexMutation(canvasSize,
moveVertexControl.getNumberGenerator(),
new GaussianGenerator(0, 3, rng))));
operators.add(new ListOperator<ColouredPolygon>(new AddVertexMutation(canvasSize,
addVertexControl.getNumberGenerator())));
operators.add(new ListOperator<ColouredPolygon>(new PolygonColourMutation(changeColourControl.getNumberGenerator(),
new GaussianGenerator(0, 20, rng))));
operators.add(new AddPolygonMutation(addPolygonControl.getNumberGenerator(), factory, 50));
return new EvolutionPipeline<List<ColouredPolygon>>(operators);
} | java | public EvolutionaryOperator<List<ColouredPolygon>> createEvolutionPipeline(PolygonImageFactory factory,
Dimension canvasSize,
Random rng)
{
List<EvolutionaryOperator<List<ColouredPolygon>>> operators
= new LinkedList<EvolutionaryOperator<List<ColouredPolygon>>>();
operators.add(new ListCrossover<ColouredPolygon>(new ConstantGenerator<Integer>(2),
crossOverControl.getNumberGenerator()));
operators.add(new RemovePolygonMutation(removePolygonControl.getNumberGenerator()));
operators.add(new MovePolygonMutation(movePolygonControl.getNumberGenerator()));
operators.add(new ListOperator<ColouredPolygon>(new RemoveVertexMutation(canvasSize,
removeVertexControl.getNumberGenerator())));
operators.add(new ListOperator<ColouredPolygon>(new AdjustVertexMutation(canvasSize,
moveVertexControl.getNumberGenerator(),
new GaussianGenerator(0, 3, rng))));
operators.add(new ListOperator<ColouredPolygon>(new AddVertexMutation(canvasSize,
addVertexControl.getNumberGenerator())));
operators.add(new ListOperator<ColouredPolygon>(new PolygonColourMutation(changeColourControl.getNumberGenerator(),
new GaussianGenerator(0, 20, rng))));
operators.add(new AddPolygonMutation(addPolygonControl.getNumberGenerator(), factory, 50));
return new EvolutionPipeline<List<ColouredPolygon>>(operators);
} | [
"public",
"EvolutionaryOperator",
"<",
"List",
"<",
"ColouredPolygon",
">",
">",
"createEvolutionPipeline",
"(",
"PolygonImageFactory",
"factory",
",",
"Dimension",
"canvasSize",
",",
"Random",
"rng",
")",
"{",
"List",
"<",
"EvolutionaryOperator",
"<",
"List",
"<",
"ColouredPolygon",
">>>",
"operators",
"=",
"new",
"LinkedList",
"<",
"EvolutionaryOperator",
"<",
"List",
"<",
"ColouredPolygon",
">",
">",
">",
"(",
")",
";",
"operators",
".",
"add",
"(",
"new",
"ListCrossover",
"<",
"ColouredPolygon",
">",
"(",
"new",
"ConstantGenerator",
"<",
"Integer",
">",
"(",
"2",
")",
",",
"crossOverControl",
".",
"getNumberGenerator",
"(",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"RemovePolygonMutation",
"(",
"removePolygonControl",
".",
"getNumberGenerator",
"(",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"MovePolygonMutation",
"(",
"movePolygonControl",
".",
"getNumberGenerator",
"(",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"ListOperator",
"<",
"ColouredPolygon",
">",
"(",
"new",
"RemoveVertexMutation",
"(",
"canvasSize",
",",
"removeVertexControl",
".",
"getNumberGenerator",
"(",
")",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"ListOperator",
"<",
"ColouredPolygon",
">",
"(",
"new",
"AdjustVertexMutation",
"(",
"canvasSize",
",",
"moveVertexControl",
".",
"getNumberGenerator",
"(",
")",
",",
"new",
"GaussianGenerator",
"(",
"0",
",",
"3",
",",
"rng",
")",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"ListOperator",
"<",
"ColouredPolygon",
">",
"(",
"new",
"AddVertexMutation",
"(",
"canvasSize",
",",
"addVertexControl",
".",
"getNumberGenerator",
"(",
")",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"ListOperator",
"<",
"ColouredPolygon",
">",
"(",
"new",
"PolygonColourMutation",
"(",
"changeColourControl",
".",
"getNumberGenerator",
"(",
")",
",",
"new",
"GaussianGenerator",
"(",
"0",
",",
"20",
",",
"rng",
")",
")",
")",
")",
";",
"operators",
".",
"add",
"(",
"new",
"AddPolygonMutation",
"(",
"addPolygonControl",
".",
"getNumberGenerator",
"(",
")",
",",
"factory",
",",
"50",
")",
")",
";",
"return",
"new",
"EvolutionPipeline",
"<",
"List",
"<",
"ColouredPolygon",
">",
">",
"(",
"operators",
")",
";",
"}"
] | Construct the combination of evolutionary operators that will be used to evolve the
polygon-based images.
@param factory A source of polygons.
@param canvasSize The size of the target image.
@param rng A source of randomness.
@return A complex evolutionary operator constructed from simpler operators. | [
"Construct",
"the",
"combination",
"of",
"evolutionary",
"operators",
"that",
"will",
"be",
"used",
"to",
"evolve",
"the",
"polygon",
"-",
"based",
"images",
"."
] | train | https://github.com/dwdyer/watchmaker/blob/33d942350e6bf7d9a17b9262a4f898158530247e/examples/src/java/main/org/uncommons/watchmaker/examples/monalisa/ProbabilitiesPanel.java#L150-L171 |
yidongnan/grpc-spring-boot-starter | grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/nameresolver/StaticNameResolverProvider.java | StaticNameResolverProvider.of | private NameResolver of(final String targetAuthority, final Helper helper) {
"""
Creates a new {@link NameResolver} for the given authority and attributes.
@param targetAuthority The authority to connect to.
@param helper Optional parameters that customize the resolve process.
@return The newly created name resolver for the given target.
"""
requireNonNull(targetAuthority, "targetAuthority");
// Determine target ips
final String[] hosts = PATTERN_COMMA.split(targetAuthority);
final List<EquivalentAddressGroup> targets = new ArrayList<>(hosts.length);
for (final String host : hosts) {
final URI uri = URI.create("//" + host);
int port = uri.getPort();
if (port == -1) {
port = helper.getDefaultPort();
}
targets.add(new EquivalentAddressGroup(new InetSocketAddress(uri.getHost(), port)));
}
if (targets.isEmpty()) {
throw new IllegalArgumentException("Must have at least one target, but was: " + targetAuthority);
}
return new StaticNameResolver(targetAuthority, targets);
} | java | private NameResolver of(final String targetAuthority, final Helper helper) {
requireNonNull(targetAuthority, "targetAuthority");
// Determine target ips
final String[] hosts = PATTERN_COMMA.split(targetAuthority);
final List<EquivalentAddressGroup> targets = new ArrayList<>(hosts.length);
for (final String host : hosts) {
final URI uri = URI.create("//" + host);
int port = uri.getPort();
if (port == -1) {
port = helper.getDefaultPort();
}
targets.add(new EquivalentAddressGroup(new InetSocketAddress(uri.getHost(), port)));
}
if (targets.isEmpty()) {
throw new IllegalArgumentException("Must have at least one target, but was: " + targetAuthority);
}
return new StaticNameResolver(targetAuthority, targets);
} | [
"private",
"NameResolver",
"of",
"(",
"final",
"String",
"targetAuthority",
",",
"final",
"Helper",
"helper",
")",
"{",
"requireNonNull",
"(",
"targetAuthority",
",",
"\"targetAuthority\"",
")",
";",
"// Determine target ips",
"final",
"String",
"[",
"]",
"hosts",
"=",
"PATTERN_COMMA",
".",
"split",
"(",
"targetAuthority",
")",
";",
"final",
"List",
"<",
"EquivalentAddressGroup",
">",
"targets",
"=",
"new",
"ArrayList",
"<>",
"(",
"hosts",
".",
"length",
")",
";",
"for",
"(",
"final",
"String",
"host",
":",
"hosts",
")",
"{",
"final",
"URI",
"uri",
"=",
"URI",
".",
"create",
"(",
"\"//\"",
"+",
"host",
")",
";",
"int",
"port",
"=",
"uri",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"port",
"==",
"-",
"1",
")",
"{",
"port",
"=",
"helper",
".",
"getDefaultPort",
"(",
")",
";",
"}",
"targets",
".",
"add",
"(",
"new",
"EquivalentAddressGroup",
"(",
"new",
"InetSocketAddress",
"(",
"uri",
".",
"getHost",
"(",
")",
",",
"port",
")",
")",
")",
";",
"}",
"if",
"(",
"targets",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must have at least one target, but was: \"",
"+",
"targetAuthority",
")",
";",
"}",
"return",
"new",
"StaticNameResolver",
"(",
"targetAuthority",
",",
"targets",
")",
";",
"}"
] | Creates a new {@link NameResolver} for the given authority and attributes.
@param targetAuthority The authority to connect to.
@param helper Optional parameters that customize the resolve process.
@return The newly created name resolver for the given target. | [
"Creates",
"a",
"new",
"{",
"@link",
"NameResolver",
"}",
"for",
"the",
"given",
"authority",
"and",
"attributes",
"."
] | train | https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/nameresolver/StaticNameResolverProvider.java#L75-L92 |
haifengl/smile | core/src/main/java/smile/neighbor/CoverTree.java | CoverTree.distSplit | private void distSplit(ArrayList<DistanceSet> pointSet, ArrayList<DistanceSet> newPointSet, E newPoint, int maxScale) {
"""
Moves all the points in pointSet covered by (the ball of) newPoint
into newPointSet, based on the given scale/level.
@param pointSet the supplied set of instances from which
all points covered by newPoint will be removed.
@param newPointSet the set in which all points covered by
newPoint will be put into.
@param newPoint the given new point.
@param maxScale the scale based on which distances are
judged (radius of cover ball is calculated).
"""
double fmax = getCoverRadius(maxScale);
ArrayList<DistanceSet> newSet = new ArrayList<>();
for (int i = 0; i < pointSet.size(); i++) {
DistanceSet n = pointSet.get(i);
double newDist = distance.d(newPoint, n.getObject());
if (newDist <= fmax) {
pointSet.get(i).dist.add(newDist);
newPointSet.add(n);
} else {
newSet.add(n);
}
}
pointSet.clear();
pointSet.addAll(newSet);
} | java | private void distSplit(ArrayList<DistanceSet> pointSet, ArrayList<DistanceSet> newPointSet, E newPoint, int maxScale) {
double fmax = getCoverRadius(maxScale);
ArrayList<DistanceSet> newSet = new ArrayList<>();
for (int i = 0; i < pointSet.size(); i++) {
DistanceSet n = pointSet.get(i);
double newDist = distance.d(newPoint, n.getObject());
if (newDist <= fmax) {
pointSet.get(i).dist.add(newDist);
newPointSet.add(n);
} else {
newSet.add(n);
}
}
pointSet.clear();
pointSet.addAll(newSet);
} | [
"private",
"void",
"distSplit",
"(",
"ArrayList",
"<",
"DistanceSet",
">",
"pointSet",
",",
"ArrayList",
"<",
"DistanceSet",
">",
"newPointSet",
",",
"E",
"newPoint",
",",
"int",
"maxScale",
")",
"{",
"double",
"fmax",
"=",
"getCoverRadius",
"(",
"maxScale",
")",
";",
"ArrayList",
"<",
"DistanceSet",
">",
"newSet",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pointSet",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"DistanceSet",
"n",
"=",
"pointSet",
".",
"get",
"(",
"i",
")",
";",
"double",
"newDist",
"=",
"distance",
".",
"d",
"(",
"newPoint",
",",
"n",
".",
"getObject",
"(",
")",
")",
";",
"if",
"(",
"newDist",
"<=",
"fmax",
")",
"{",
"pointSet",
".",
"get",
"(",
"i",
")",
".",
"dist",
".",
"add",
"(",
"newDist",
")",
";",
"newPointSet",
".",
"add",
"(",
"n",
")",
";",
"}",
"else",
"{",
"newSet",
".",
"add",
"(",
"n",
")",
";",
"}",
"}",
"pointSet",
".",
"clear",
"(",
")",
";",
"pointSet",
".",
"addAll",
"(",
"newSet",
")",
";",
"}"
] | Moves all the points in pointSet covered by (the ball of) newPoint
into newPointSet, based on the given scale/level.
@param pointSet the supplied set of instances from which
all points covered by newPoint will be removed.
@param newPointSet the set in which all points covered by
newPoint will be put into.
@param newPoint the given new point.
@param maxScale the scale based on which distances are
judged (radius of cover ball is calculated). | [
"Moves",
"all",
"the",
"points",
"in",
"pointSet",
"covered",
"by",
"(",
"the",
"ball",
"of",
")",
"newPoint",
"into",
"newPointSet",
"based",
"on",
"the",
"given",
"scale",
"/",
"level",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/CoverTree.java#L483-L499 |
greese/dasein-util | src/main/java/org/dasein/attributes/DataTypeFactory.java | DataTypeFactory.getDisplayValue | public String getDisplayValue(Locale loc, Object ob) {
"""
Provides a display version of the specified value translated for the target locale.
@param loc the locale for which the display should be translated
@param ob the target value
@return a display version of the specified value
"""
if( ob == null ) {
return "";
}
if( ob instanceof Translator ) {
@SuppressWarnings("rawtypes") Translation trans = ((Translator)ob).get(loc);
if( trans == null ) {
return null;
}
return getDisplayValue(trans.getData());
}
else {
return getDisplayValue(ob);
}
} | java | public String getDisplayValue(Locale loc, Object ob) {
if( ob == null ) {
return "";
}
if( ob instanceof Translator ) {
@SuppressWarnings("rawtypes") Translation trans = ((Translator)ob).get(loc);
if( trans == null ) {
return null;
}
return getDisplayValue(trans.getData());
}
else {
return getDisplayValue(ob);
}
} | [
"public",
"String",
"getDisplayValue",
"(",
"Locale",
"loc",
",",
"Object",
"ob",
")",
"{",
"if",
"(",
"ob",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"ob",
"instanceof",
"Translator",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"Translation",
"trans",
"=",
"(",
"(",
"Translator",
")",
"ob",
")",
".",
"get",
"(",
"loc",
")",
";",
"if",
"(",
"trans",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"getDisplayValue",
"(",
"trans",
".",
"getData",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"getDisplayValue",
"(",
"ob",
")",
";",
"}",
"}"
] | Provides a display version of the specified value translated for the target locale.
@param loc the locale for which the display should be translated
@param ob the target value
@return a display version of the specified value | [
"Provides",
"a",
"display",
"version",
"of",
"the",
"specified",
"value",
"translated",
"for",
"the",
"target",
"locale",
"."
] | train | https://github.com/greese/dasein-util/blob/648606dcb4bd382e3287a6c897a32e65d553dc47/src/main/java/org/dasein/attributes/DataTypeFactory.java#L362-L377 |
nguillaumin/slick2d-maven | slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java | GraphEditorWindow.registerValue | public void registerValue(LinearInterpolator value, String name) {
"""
Register a configurable value with the graph panel
@param value The value to be registered
@param name The name to display for this value
"""
// add to properties combobox
properties.addItem(name);
// add to value map
values.put(name, value);
// set as current interpolator
panel.setInterpolator(value);
// enable all input fields
enableControls();
} | java | public void registerValue(LinearInterpolator value, String name) {
// add to properties combobox
properties.addItem(name);
// add to value map
values.put(name, value);
// set as current interpolator
panel.setInterpolator(value);
// enable all input fields
enableControls();
} | [
"public",
"void",
"registerValue",
"(",
"LinearInterpolator",
"value",
",",
"String",
"name",
")",
"{",
"// add to properties combobox\r",
"properties",
".",
"addItem",
"(",
"name",
")",
";",
"// add to value map\r",
"values",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"// set as current interpolator\r",
"panel",
".",
"setInterpolator",
"(",
"value",
")",
";",
"// enable all input fields\r",
"enableControls",
"(",
")",
";",
"}"
] | Register a configurable value with the graph panel
@param value The value to be registered
@param name The name to display for this value | [
"Register",
"a",
"configurable",
"value",
"with",
"the",
"graph",
"panel"
] | train | https://github.com/nguillaumin/slick2d-maven/blob/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-peditor/src/main/java/org/newdawn/slick/tools/peditor/GraphEditorWindow.java#L260-L272 |
alkacon/opencms-core | src/org/opencms/util/CmsFileUtil.java | CmsFileUtil.normalizePath | public static String normalizePath(URL url, char separatorChar) {
"""
Returns the normalized file path created from the given URL.<p>
The path part {@link URL#getPath()} is used, unescaped and
normalized using {@link #normalizePath(String, char)}.<p>
@param url the URL to extract the path information from
@param separatorChar the file separator char to use, for example {@link File#separatorChar}
@return the normalized file path created from the given URL
"""
// get the path part from the URL
String path = new File(url.getPath()).getAbsolutePath();
// trick to get the OS default encoding, taken from the official Java i18n FAQ
String systemEncoding = (new OutputStreamWriter(new ByteArrayOutputStream())).getEncoding();
// decode url in order to remove spaces and escaped chars from path
return CmsFileUtil.normalizePath(CmsEncoder.decode(path, systemEncoding), separatorChar);
} | java | public static String normalizePath(URL url, char separatorChar) {
// get the path part from the URL
String path = new File(url.getPath()).getAbsolutePath();
// trick to get the OS default encoding, taken from the official Java i18n FAQ
String systemEncoding = (new OutputStreamWriter(new ByteArrayOutputStream())).getEncoding();
// decode url in order to remove spaces and escaped chars from path
return CmsFileUtil.normalizePath(CmsEncoder.decode(path, systemEncoding), separatorChar);
} | [
"public",
"static",
"String",
"normalizePath",
"(",
"URL",
"url",
",",
"char",
"separatorChar",
")",
"{",
"// get the path part from the URL",
"String",
"path",
"=",
"new",
"File",
"(",
"url",
".",
"getPath",
"(",
")",
")",
".",
"getAbsolutePath",
"(",
")",
";",
"// trick to get the OS default encoding, taken from the official Java i18n FAQ",
"String",
"systemEncoding",
"=",
"(",
"new",
"OutputStreamWriter",
"(",
"new",
"ByteArrayOutputStream",
"(",
")",
")",
")",
".",
"getEncoding",
"(",
")",
";",
"// decode url in order to remove spaces and escaped chars from path",
"return",
"CmsFileUtil",
".",
"normalizePath",
"(",
"CmsEncoder",
".",
"decode",
"(",
"path",
",",
"systemEncoding",
")",
",",
"separatorChar",
")",
";",
"}"
] | Returns the normalized file path created from the given URL.<p>
The path part {@link URL#getPath()} is used, unescaped and
normalized using {@link #normalizePath(String, char)}.<p>
@param url the URL to extract the path information from
@param separatorChar the file separator char to use, for example {@link File#separatorChar}
@return the normalized file path created from the given URL | [
"Returns",
"the",
"normalized",
"file",
"path",
"created",
"from",
"the",
"given",
"URL",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsFileUtil.java#L550-L558 |
OpenLiberty/open-liberty | dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java | BatchUpdateDaemon.pushAliasEntry | public synchronized void pushAliasEntry(AliasEntry aliasEntry, DCache cache) {
"""
This allows a cache entry to be added to the BatchUpdateDaemon.
The cache entry will be added to all caches.
@param cacheEntry The cache entry to be added.
"""
BatchUpdateList bul = getUpdateList(cache);
bul.aliasEntryEvents.add(aliasEntry);
} | java | public synchronized void pushAliasEntry(AliasEntry aliasEntry, DCache cache) {
BatchUpdateList bul = getUpdateList(cache);
bul.aliasEntryEvents.add(aliasEntry);
} | [
"public",
"synchronized",
"void",
"pushAliasEntry",
"(",
"AliasEntry",
"aliasEntry",
",",
"DCache",
"cache",
")",
"{",
"BatchUpdateList",
"bul",
"=",
"getUpdateList",
"(",
"cache",
")",
";",
"bul",
".",
"aliasEntryEvents",
".",
"add",
"(",
"aliasEntry",
")",
";",
"}"
] | This allows a cache entry to be added to the BatchUpdateDaemon.
The cache entry will be added to all caches.
@param cacheEntry The cache entry to be added. | [
"This",
"allows",
"a",
"cache",
"entry",
"to",
"be",
"added",
"to",
"the",
"BatchUpdateDaemon",
".",
"The",
"cache",
"entry",
"will",
"be",
"added",
"to",
"all",
"caches",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.dynacache/src/com/ibm/ws/cache/BatchUpdateDaemon.java#L213-L216 |
HeidelTime/heideltime | src/jvntextpro/util/StringUtils.java | StringUtils.isContained | public static boolean isContained( String[] array, String s ) {
"""
Indicates whether the specified array of <tt>String</tt>s contains
a given <tt>String</tt>.
@param array the array
@param s the s
@return otherwise.
"""
for (String string : array)
{
if( string.equals( s ) )
{
return true;
}
}
return false;
} | java | public static boolean isContained( String[] array, String s )
{
for (String string : array)
{
if( string.equals( s ) )
{
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"isContained",
"(",
"String",
"[",
"]",
"array",
",",
"String",
"s",
")",
"{",
"for",
"(",
"String",
"string",
":",
"array",
")",
"{",
"if",
"(",
"string",
".",
"equals",
"(",
"s",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Indicates whether the specified array of <tt>String</tt>s contains
a given <tt>String</tt>.
@param array the array
@param s the s
@return otherwise. | [
"Indicates",
"whether",
"the",
"specified",
"array",
"of",
"<tt",
">",
"String<",
"/",
"tt",
">",
"s",
"contains",
"a",
"given",
"<tt",
">",
"String<",
"/",
"tt",
">",
"."
] | train | https://github.com/HeidelTime/heideltime/blob/4ef5002eb5ecfeb818086ff7e394e792ee360335/src/jvntextpro/util/StringUtils.java#L556-L566 |
Polidea/RxAndroidBle | rxandroidble/src/main/java/com/polidea/rxandroidble2/internal/operations/ServiceDiscoveryOperation.java | ServiceDiscoveryOperation.timeoutFallbackProcedure | @NonNull
@Override
protected Single<RxBleDeviceServices> timeoutFallbackProcedure(
final BluetoothGatt bluetoothGatt,
final RxBleGattCallback rxBleGattCallback,
final Scheduler timeoutScheduler
) {
"""
Sometimes it happens that the {@link BluetoothGatt} will receive all {@link BluetoothGattService}'s,
{@link android.bluetooth.BluetoothGattCharacteristic}'s and {@link android.bluetooth.BluetoothGattDescriptor}
but it won't receive the final callback that the service discovery was completed. This is a potential workaround.
<p>
There is a change in Android 7.0.0_r1 where all data is received at once - in this situation returned services size will be always 0
https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r1/core/java/android/bluetooth/BluetoothGatt.java#206
https://android.googlesource.com/platform/frameworks/base/+/android-6.0.1_r72/core/java/android/bluetooth/BluetoothGatt.java#205
@param bluetoothGatt the BluetoothGatt to use
@param rxBleGattCallback the RxBleGattCallback to use
@param timeoutScheduler the Scheduler for timeout to use
@return Observable that may emit {@link RxBleDeviceServices} or {@link TimeoutException}
"""
return Single.defer(new Callable<SingleSource<? extends RxBleDeviceServices>>() {
@Override
public SingleSource<? extends RxBleDeviceServices> call() throws Exception {
final List<BluetoothGattService> services = bluetoothGatt.getServices();
if (services.size() == 0) {
// if after the timeout services are empty we have no other option to declare a failed discovery
return Single.error(new BleGattCallbackTimeoutException(bluetoothGatt, BleGattOperationType.SERVICE_DISCOVERY));
} else {
/*
it is observed that usually the Android OS is returning services, characteristics and descriptors in a short period of time
if there are some services available we will wait for 5 more seconds just to be sure that
the timeout was not triggered right in the moment of filling the services and then emit a value.
*/
return Single
.timer(5, TimeUnit.SECONDS, timeoutScheduler)
.flatMap(new Function<Long, Single<RxBleDeviceServices>>() {
@Override
public Single<RxBleDeviceServices> apply(Long delayedSeconds) {
return Single.fromCallable(new Callable<RxBleDeviceServices>() {
@Override
public RxBleDeviceServices call() throws Exception {
return new RxBleDeviceServices(bluetoothGatt.getServices());
}
});
}
});
}
}
});
} | java | @NonNull
@Override
protected Single<RxBleDeviceServices> timeoutFallbackProcedure(
final BluetoothGatt bluetoothGatt,
final RxBleGattCallback rxBleGattCallback,
final Scheduler timeoutScheduler
) {
return Single.defer(new Callable<SingleSource<? extends RxBleDeviceServices>>() {
@Override
public SingleSource<? extends RxBleDeviceServices> call() throws Exception {
final List<BluetoothGattService> services = bluetoothGatt.getServices();
if (services.size() == 0) {
// if after the timeout services are empty we have no other option to declare a failed discovery
return Single.error(new BleGattCallbackTimeoutException(bluetoothGatt, BleGattOperationType.SERVICE_DISCOVERY));
} else {
/*
it is observed that usually the Android OS is returning services, characteristics and descriptors in a short period of time
if there are some services available we will wait for 5 more seconds just to be sure that
the timeout was not triggered right in the moment of filling the services and then emit a value.
*/
return Single
.timer(5, TimeUnit.SECONDS, timeoutScheduler)
.flatMap(new Function<Long, Single<RxBleDeviceServices>>() {
@Override
public Single<RxBleDeviceServices> apply(Long delayedSeconds) {
return Single.fromCallable(new Callable<RxBleDeviceServices>() {
@Override
public RxBleDeviceServices call() throws Exception {
return new RxBleDeviceServices(bluetoothGatt.getServices());
}
});
}
});
}
}
});
} | [
"@",
"NonNull",
"@",
"Override",
"protected",
"Single",
"<",
"RxBleDeviceServices",
">",
"timeoutFallbackProcedure",
"(",
"final",
"BluetoothGatt",
"bluetoothGatt",
",",
"final",
"RxBleGattCallback",
"rxBleGattCallback",
",",
"final",
"Scheduler",
"timeoutScheduler",
")",
"{",
"return",
"Single",
".",
"defer",
"(",
"new",
"Callable",
"<",
"SingleSource",
"<",
"?",
"extends",
"RxBleDeviceServices",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"SingleSource",
"<",
"?",
"extends",
"RxBleDeviceServices",
">",
"call",
"(",
")",
"throws",
"Exception",
"{",
"final",
"List",
"<",
"BluetoothGattService",
">",
"services",
"=",
"bluetoothGatt",
".",
"getServices",
"(",
")",
";",
"if",
"(",
"services",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// if after the timeout services are empty we have no other option to declare a failed discovery",
"return",
"Single",
".",
"error",
"(",
"new",
"BleGattCallbackTimeoutException",
"(",
"bluetoothGatt",
",",
"BleGattOperationType",
".",
"SERVICE_DISCOVERY",
")",
")",
";",
"}",
"else",
"{",
"/*\n it is observed that usually the Android OS is returning services, characteristics and descriptors in a short period of time\n if there are some services available we will wait for 5 more seconds just to be sure that\n the timeout was not triggered right in the moment of filling the services and then emit a value.\n */",
"return",
"Single",
".",
"timer",
"(",
"5",
",",
"TimeUnit",
".",
"SECONDS",
",",
"timeoutScheduler",
")",
".",
"flatMap",
"(",
"new",
"Function",
"<",
"Long",
",",
"Single",
"<",
"RxBleDeviceServices",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Single",
"<",
"RxBleDeviceServices",
">",
"apply",
"(",
"Long",
"delayedSeconds",
")",
"{",
"return",
"Single",
".",
"fromCallable",
"(",
"new",
"Callable",
"<",
"RxBleDeviceServices",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"RxBleDeviceServices",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"new",
"RxBleDeviceServices",
"(",
"bluetoothGatt",
".",
"getServices",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Sometimes it happens that the {@link BluetoothGatt} will receive all {@link BluetoothGattService}'s,
{@link android.bluetooth.BluetoothGattCharacteristic}'s and {@link android.bluetooth.BluetoothGattDescriptor}
but it won't receive the final callback that the service discovery was completed. This is a potential workaround.
<p>
There is a change in Android 7.0.0_r1 where all data is received at once - in this situation returned services size will be always 0
https://android.googlesource.com/platform/frameworks/base/+/android-7.0.0_r1/core/java/android/bluetooth/BluetoothGatt.java#206
https://android.googlesource.com/platform/frameworks/base/+/android-6.0.1_r72/core/java/android/bluetooth/BluetoothGatt.java#205
@param bluetoothGatt the BluetoothGatt to use
@param rxBleGattCallback the RxBleGattCallback to use
@param timeoutScheduler the Scheduler for timeout to use
@return Observable that may emit {@link RxBleDeviceServices} or {@link TimeoutException} | [
"Sometimes",
"it",
"happens",
"that",
"the",
"{",
"@link",
"BluetoothGatt",
"}",
"will",
"receive",
"all",
"{",
"@link",
"BluetoothGattService",
"}",
"s",
"{",
"@link",
"android",
".",
"bluetooth",
".",
"BluetoothGattCharacteristic",
"}",
"s",
"and",
"{",
"@link",
"android",
".",
"bluetooth",
".",
"BluetoothGattDescriptor",
"}",
"but",
"it",
"won",
"t",
"receive",
"the",
"final",
"callback",
"that",
"the",
"service",
"discovery",
"was",
"completed",
".",
"This",
"is",
"a",
"potential",
"workaround",
".",
"<p",
">",
"There",
"is",
"a",
"change",
"in",
"Android",
"7",
".",
"0",
".",
"0_r1",
"where",
"all",
"data",
"is",
"received",
"at",
"once",
"-",
"in",
"this",
"situation",
"returned",
"services",
"size",
"will",
"be",
"always",
"0",
"https",
":",
"//",
"android",
".",
"googlesource",
".",
"com",
"/",
"platform",
"/",
"frameworks",
"/",
"base",
"/",
"+",
"/",
"android",
"-",
"7",
".",
"0",
".",
"0_r1",
"/",
"core",
"/",
"java",
"/",
"android",
"/",
"bluetooth",
"/",
"BluetoothGatt",
".",
"java#206",
"https",
":",
"//",
"android",
".",
"googlesource",
".",
"com",
"/",
"platform",
"/",
"frameworks",
"/",
"base",
"/",
"+",
"/",
"android",
"-",
"6",
".",
"0",
".",
"1_r72",
"/",
"core",
"/",
"java",
"/",
"android",
"/",
"bluetooth",
"/",
"BluetoothGatt",
".",
"java#205"
] | train | https://github.com/Polidea/RxAndroidBle/blob/c6e4a9753c834d710e255306bb290e9244cdbc10/rxandroidble/src/main/java/com/polidea/rxandroidble2/internal/operations/ServiceDiscoveryOperation.java#L70-L106 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java | Grid.addCoords | public void addCoords(Point3d[] iAtoms, Point3d[] jAtoms) {
"""
Adds the i and j coordinates and fills the grid. Their bounds will be computed.
Subsequent call to {@link #getIndicesContacts()} will produce the
contacts, i.e. the set of points within distance cutoff.
Subsequent calls to method {@link #getAtomContacts()} will produce a NullPointerException
since this only adds coordinates and no atom information.
@param iAtoms
@param jAtoms
"""
addCoords(iAtoms, null, jAtoms, null);
} | java | public void addCoords(Point3d[] iAtoms, Point3d[] jAtoms) {
addCoords(iAtoms, null, jAtoms, null);
} | [
"public",
"void",
"addCoords",
"(",
"Point3d",
"[",
"]",
"iAtoms",
",",
"Point3d",
"[",
"]",
"jAtoms",
")",
"{",
"addCoords",
"(",
"iAtoms",
",",
"null",
",",
"jAtoms",
",",
"null",
")",
";",
"}"
] | Adds the i and j coordinates and fills the grid. Their bounds will be computed.
Subsequent call to {@link #getIndicesContacts()} will produce the
contacts, i.e. the set of points within distance cutoff.
Subsequent calls to method {@link #getAtomContacts()} will produce a NullPointerException
since this only adds coordinates and no atom information.
@param iAtoms
@param jAtoms | [
"Adds",
"the",
"i",
"and",
"j",
"coordinates",
"and",
"fills",
"the",
"grid",
".",
"Their",
"bounds",
"will",
"be",
"computed",
".",
"Subsequent",
"call",
"to",
"{",
"@link",
"#getIndicesContacts",
"()",
"}",
"will",
"produce",
"the",
"contacts",
"i",
".",
"e",
".",
"the",
"set",
"of",
"points",
"within",
"distance",
"cutoff",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java#L202-L204 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/block/component/ColorComponent.java | ColorComponent.getMapColor | @Override
public MapColor getMapColor(Block block, IBlockState state, IBlockAccess world, BlockPos pos) {
"""
Get the {@link MapColor} for this {@link Block} and the given {@link IBlockState}.
@param block the block
@param state the state
@return the map color
"""
return MapColor.getBlockColor(state.getValue(getProperty()));
} | java | @Override
public MapColor getMapColor(Block block, IBlockState state, IBlockAccess world, BlockPos pos)
{
return MapColor.getBlockColor(state.getValue(getProperty()));
} | [
"@",
"Override",
"public",
"MapColor",
"getMapColor",
"(",
"Block",
"block",
",",
"IBlockState",
"state",
",",
"IBlockAccess",
"world",
",",
"BlockPos",
"pos",
")",
"{",
"return",
"MapColor",
".",
"getBlockColor",
"(",
"state",
".",
"getValue",
"(",
"getProperty",
"(",
")",
")",
")",
";",
"}"
] | Get the {@link MapColor} for this {@link Block} and the given {@link IBlockState}.
@param block the block
@param state the state
@return the map color | [
"Get",
"the",
"{",
"@link",
"MapColor",
"}",
"for",
"this",
"{",
"@link",
"Block",
"}",
"and",
"the",
"given",
"{",
"@link",
"IBlockState",
"}",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/block/component/ColorComponent.java#L163-L167 |
alkacon/opencms-core | src/org/opencms/db/generic/CmsProjectDriver.java | CmsProjectDriver.fixMovedResource | protected CmsResourceState fixMovedResource(
CmsDbContext dbc,
CmsProject onlineProject,
CmsResource offlineResource,
CmsUUID publishHistoryId,
int publishTag)
throws CmsDataAccessException {
"""
Checks if the given resource (by id) is available in the online project,
if there exists a resource with a different path (a moved file), then the
online entry is moved to the right (new) location before publishing.<p>
@param dbc the db context
@param onlineProject the online project
@param offlineResource the offline resource to check
@param publishHistoryId the publish history id
@param publishTag the publish tag
@return <code>true</code> if the resource has actually been moved
@throws CmsDataAccessException if something goes wrong
"""
CmsResource onlineResource;
// check if the resource has been moved since last publishing
try {
onlineResource = m_driverManager.getVfsDriver(dbc).readResource(
dbc,
onlineProject.getUuid(),
offlineResource.getStructureId(),
true);
if (onlineResource.getRootPath().equals(offlineResource.getRootPath())) {
// resource changed, not moved
return offlineResource.getState();
}
} catch (CmsVfsResourceNotFoundException e) {
// ok, resource new, not moved
return offlineResource.getState();
}
// move the online resource to the new position
m_driverManager.getVfsDriver(dbc).moveResource(
dbc,
onlineProject.getUuid(),
onlineResource,
offlineResource.getRootPath());
try {
// write the resource to the publish history
m_driverManager.getProjectDriver(dbc).writePublishHistory(
dbc,
publishHistoryId,
new CmsPublishedResource(onlineResource, publishTag, CmsPublishedResource.STATE_MOVED_SOURCE));
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(
Messages.LOG_WRITING_PUBLISHING_HISTORY_1,
onlineResource.getRootPath()),
e);
}
throw e;
}
return offlineResource.getState().isDeleted()
? CmsResource.STATE_DELETED
: CmsPublishedResource.STATE_MOVED_DESTINATION;
} | java | protected CmsResourceState fixMovedResource(
CmsDbContext dbc,
CmsProject onlineProject,
CmsResource offlineResource,
CmsUUID publishHistoryId,
int publishTag)
throws CmsDataAccessException {
CmsResource onlineResource;
// check if the resource has been moved since last publishing
try {
onlineResource = m_driverManager.getVfsDriver(dbc).readResource(
dbc,
onlineProject.getUuid(),
offlineResource.getStructureId(),
true);
if (onlineResource.getRootPath().equals(offlineResource.getRootPath())) {
// resource changed, not moved
return offlineResource.getState();
}
} catch (CmsVfsResourceNotFoundException e) {
// ok, resource new, not moved
return offlineResource.getState();
}
// move the online resource to the new position
m_driverManager.getVfsDriver(dbc).moveResource(
dbc,
onlineProject.getUuid(),
onlineResource,
offlineResource.getRootPath());
try {
// write the resource to the publish history
m_driverManager.getProjectDriver(dbc).writePublishHistory(
dbc,
publishHistoryId,
new CmsPublishedResource(onlineResource, publishTag, CmsPublishedResource.STATE_MOVED_SOURCE));
} catch (CmsDataAccessException e) {
if (LOG.isErrorEnabled()) {
LOG.error(
Messages.get().getBundle().key(
Messages.LOG_WRITING_PUBLISHING_HISTORY_1,
onlineResource.getRootPath()),
e);
}
throw e;
}
return offlineResource.getState().isDeleted()
? CmsResource.STATE_DELETED
: CmsPublishedResource.STATE_MOVED_DESTINATION;
} | [
"protected",
"CmsResourceState",
"fixMovedResource",
"(",
"CmsDbContext",
"dbc",
",",
"CmsProject",
"onlineProject",
",",
"CmsResource",
"offlineResource",
",",
"CmsUUID",
"publishHistoryId",
",",
"int",
"publishTag",
")",
"throws",
"CmsDataAccessException",
"{",
"CmsResource",
"onlineResource",
";",
"// check if the resource has been moved since last publishing",
"try",
"{",
"onlineResource",
"=",
"m_driverManager",
".",
"getVfsDriver",
"(",
"dbc",
")",
".",
"readResource",
"(",
"dbc",
",",
"onlineProject",
".",
"getUuid",
"(",
")",
",",
"offlineResource",
".",
"getStructureId",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"onlineResource",
".",
"getRootPath",
"(",
")",
".",
"equals",
"(",
"offlineResource",
".",
"getRootPath",
"(",
")",
")",
")",
"{",
"// resource changed, not moved",
"return",
"offlineResource",
".",
"getState",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"CmsVfsResourceNotFoundException",
"e",
")",
"{",
"// ok, resource new, not moved",
"return",
"offlineResource",
".",
"getState",
"(",
")",
";",
"}",
"// move the online resource to the new position",
"m_driverManager",
".",
"getVfsDriver",
"(",
"dbc",
")",
".",
"moveResource",
"(",
"dbc",
",",
"onlineProject",
".",
"getUuid",
"(",
")",
",",
"onlineResource",
",",
"offlineResource",
".",
"getRootPath",
"(",
")",
")",
";",
"try",
"{",
"// write the resource to the publish history",
"m_driverManager",
".",
"getProjectDriver",
"(",
"dbc",
")",
".",
"writePublishHistory",
"(",
"dbc",
",",
"publishHistoryId",
",",
"new",
"CmsPublishedResource",
"(",
"onlineResource",
",",
"publishTag",
",",
"CmsPublishedResource",
".",
"STATE_MOVED_SOURCE",
")",
")",
";",
"}",
"catch",
"(",
"CmsDataAccessException",
"e",
")",
"{",
"if",
"(",
"LOG",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"Messages",
".",
"get",
"(",
")",
".",
"getBundle",
"(",
")",
".",
"key",
"(",
"Messages",
".",
"LOG_WRITING_PUBLISHING_HISTORY_1",
",",
"onlineResource",
".",
"getRootPath",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"throw",
"e",
";",
"}",
"return",
"offlineResource",
".",
"getState",
"(",
")",
".",
"isDeleted",
"(",
")",
"?",
"CmsResource",
".",
"STATE_DELETED",
":",
"CmsPublishedResource",
".",
"STATE_MOVED_DESTINATION",
";",
"}"
] | Checks if the given resource (by id) is available in the online project,
if there exists a resource with a different path (a moved file), then the
online entry is moved to the right (new) location before publishing.<p>
@param dbc the db context
@param onlineProject the online project
@param offlineResource the offline resource to check
@param publishHistoryId the publish history id
@param publishTag the publish tag
@return <code>true</code> if the resource has actually been moved
@throws CmsDataAccessException if something goes wrong | [
"Checks",
"if",
"the",
"given",
"resource",
"(",
"by",
"id",
")",
"is",
"available",
"in",
"the",
"online",
"project",
"if",
"there",
"exists",
"a",
"resource",
"with",
"a",
"different",
"path",
"(",
"a",
"moved",
"file",
")",
"then",
"the",
"online",
"entry",
"is",
"moved",
"to",
"the",
"right",
"(",
"new",
")",
"location",
"before",
"publishing",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/generic/CmsProjectDriver.java#L2993-L3044 |
Subsets and Splits